aboutsummaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--scene/2d/animated_sprite.cpp423
-rw-r--r--scene/2d/animated_sprite.h85
-rw-r--r--scene/2d/area_2d.cpp490
-rw-r--r--scene/2d/area_2d.h45
-rw-r--r--scene/2d/back_buffer_copy.cpp50
-rw-r--r--scene/2d/back_buffer_copy.h9
-rw-r--r--scene/2d/camera_2d.cpp415
-rw-r--r--scene/2d/camera_2d.h21
-rw-r--r--scene/2d/canvas_item.cpp674
-rw-r--r--scene/2d/canvas_item.h106
-rw-r--r--scene/2d/canvas_modulate.cpp56
-rw-r--r--scene/2d/canvas_modulate.h7
-rw-r--r--scene/2d/collision_object_2d.cpp220
-rw-r--r--scene/2d/collision_object_2d.h30
-rw-r--r--scene/2d/collision_polygon_2d.cpp203
-rw-r--r--scene/2d/collision_polygon_2d.h19
-rw-r--r--scene/2d/collision_shape_2d.cpp107
-rw-r--r--scene/2d/collision_shape_2d.h7
-rw-r--r--scene/2d/joints_2d.cpp265
-rw-r--r--scene/2d/joints_2d.h31
-rw-r--r--scene/2d/light_2d.cpp343
-rw-r--r--scene/2d/light_2d.h47
-rw-r--r--scene/2d/light_occluder_2d.cpp132
-rw-r--r--scene/2d/light_occluder_2d.h19
-rw-r--r--scene/2d/navigation2d.cpp556
-rw-r--r--scene/2d/navigation2d.h79
-rw-r--r--scene/2d/navigation_polygon.cpp293
-rw-r--r--scene/2d/navigation_polygon.h34
-rw-r--r--scene/2d/node_2d.cpp271
-rw-r--r--scene/2d/node_2d.h38
-rw-r--r--scene/2d/parallax_background.cpp124
-rw-r--r--scene/2d/parallax_background.h22
-rw-r--r--scene/2d/parallax_layer.cpp85
-rw-r--r--scene/2d/parallax_layer.h12
-rw-r--r--scene/2d/particles_2d.cpp812
-rw-r--r--scene/2d/particles_2d.h54
-rw-r--r--scene/2d/path_2d.cpp228
-rw-r--r--scene/2d/path_2d.h29
-rw-r--r--scene/2d/path_texture.cpp40
-rw-r--r--scene/2d/path_texture.h10
-rw-r--r--scene/2d/physics_body_2d.cpp968
-rw-r--r--scene/2d/physics_body_2d.h84
-rw-r--r--scene/2d/polygon_2d.cpp294
-rw-r--r--scene/2d/polygon_2d.h23
-rw-r--r--scene/2d/position_2d.cpp13
-rw-r--r--scene/2d/position_2d.h7
-rw-r--r--scene/2d/ray_cast_2d.cpp155
-rw-r--r--scene/2d/ray_cast_2d.h18
-rw-r--r--scene/2d/remote_transform_2d.cpp33
-rw-r--r--scene/2d/remote_transform_2d.h7
-rw-r--r--scene/2d/sample_player_2d.cpp133
-rw-r--r--scene/2d/sample_player_2d.h22
-rw-r--r--scene/2d/screen_button.cpp234
-rw-r--r--scene/2d/screen_button.h25
-rw-r--r--scene/2d/sound_player_2d.cpp75
-rw-r--r--scene/2d/sound_player_2d.h33
-rw-r--r--scene/2d/sprite.cpp302
-rw-r--r--scene/2d/sprite.h30
-rw-r--r--scene/2d/tile_map.cpp915
-rw-r--r--scene/2d/tile_map.h112
-rw-r--r--scene/2d/visibility_notifier_2d.cpp212
-rw-r--r--scene/2d/visibility_notifier_2d.h34
-rw-r--r--scene/2d/y_sort.cpp17
-rw-r--r--scene/2d/y_sort.h4
-rw-r--r--scene/3d/area.cpp486
-rw-r--r--scene/3d/area.h46
-rw-r--r--scene/3d/baked_light_instance.cpp104
-rw-r--r--scene/3d/baked_light_instance.h36
-rw-r--r--scene/3d/body_shape.cpp168
-rw-r--r--scene/3d/body_shape.h10
-rw-r--r--scene/3d/bone_attachment.cpp65
-rw-r--r--scene/3d/bone_attachment.h13
-rw-r--r--scene/3d/camera.cpp557
-rw-r--r--scene/3d/camera.h45
-rw-r--r--scene/3d/character_camera.cpp1
-rw-r--r--scene/3d/character_camera.h1
-rw-r--r--scene/3d/collision_object.cpp230
-rw-r--r--scene/3d/collision_object.h36
-rw-r--r--scene/3d/collision_polygon.cpp134
-rw-r--r--scene/3d/collision_polygon.h18
-rw-r--r--scene/3d/immediate_geometry.cpp120
-rw-r--r--scene/3d/immediate_geometry.h27
-rw-r--r--scene/3d/interpolated_camera.cpp66
-rw-r--r--scene/3d/interpolated_camera.h8
-rw-r--r--scene/3d/light.cpp512
-rw-r--r--scene/3d/light.h87
-rw-r--r--scene/3d/listener.cpp62
-rw-r--r--scene/3d/listener.h15
-rw-r--r--scene/3d/mesh_instance.cpp168
-rw-r--r--scene/3d/mesh_instance.h28
-rw-r--r--scene/3d/multimesh_instance.cpp22
-rw-r--r--scene/3d/multimesh_instance.h10
-rw-r--r--scene/3d/navigation.cpp577
-rw-r--r--scene/3d/navigation.h94
-rw-r--r--scene/3d/navigation_mesh.cpp240
-rw-r--r--scene/3d/navigation_mesh.h28
-rw-r--r--scene/3d/particles.cpp415
-rw-r--r--scene/3d/particles.h64
-rw-r--r--scene/3d/path.cpp240
-rw-r--r--scene/3d/path.h25
-rw-r--r--scene/3d/physics_body.cpp944
-rw-r--r--scene/3d/physics_body.h89
-rw-r--r--scene/3d/physics_joint.cpp1008
-rw-r--r--scene/3d/physics_joint.h208
-rw-r--r--scene/3d/portal.cpp189
-rw-r--r--scene/3d/portal.h16
-rw-r--r--scene/3d/position_3d.cpp42
-rw-r--r--scene/3d/position_3d.h5
-rw-r--r--scene/3d/proximity_group.cpp45
-rw-r--r--scene/3d/proximity_group.h8
-rw-r--r--scene/3d/quad.cpp153
-rw-r--r--scene/3d/quad.h13
-rw-r--r--scene/3d/ray_cast.cpp139
-rw-r--r--scene/3d/ray_cast.h16
-rw-r--r--scene/3d/room_instance.cpp158
-rw-r--r--scene/3d/room_instance.h20
-rw-r--r--scene/3d/scenario_fx.cpp46
-rw-r--r--scene/3d/scenario_fx.h9
-rw-r--r--scene/3d/skeleton.cpp423
-rw-r--r--scene/3d/skeleton.h49
-rw-r--r--scene/3d/spatial.cpp399
-rw-r--r--scene/3d/spatial.h82
-rw-r--r--scene/3d/spatial_indexer.cpp2
-rw-r--r--scene/3d/spatial_player.cpp194
-rw-r--r--scene/3d/spatial_player.h37
-rw-r--r--scene/3d/spatial_sample_player.cpp119
-rw-r--r--scene/3d/spatial_sample_player.h24
-rw-r--r--scene/3d/spatial_stream_player.cpp185
-rw-r--r--scene/3d/spatial_stream_player.h14
-rw-r--r--scene/3d/sprite_3d.cpp715
-rw-r--r--scene/3d/sprite_3d.h69
-rw-r--r--scene/3d/test_cube.cpp8
-rw-r--r--scene/3d/test_cube.h9
-rw-r--r--scene/3d/vehicle_body.cpp738
-rw-r--r--scene/3d/vehicle_body.h100
-rw-r--r--scene/3d/visibility_notifier.cpp176
-rw-r--r--scene/3d/visibility_notifier.h33
-rw-r--r--scene/3d/visual_instance.cpp258
-rw-r--r--scene/3d/visual_instance.h66
-rw-r--r--scene/animation/animation_cache.cpp206
-rw-r--r--scene/animation/animation_cache.h29
-rw-r--r--scene/animation/animation_player.cpp918
-rw-r--r--scene/animation/animation_player.h162
-rw-r--r--scene/animation/animation_tree_player.cpp1483
-rw-r--r--scene/animation/animation_tree_player.h284
-rw-r--r--scene/animation/tween.cpp1014
-rw-r--r--scene/animation/tween.h153
-rw-r--r--scene/animation/tween_interpolaters.cpp448
-rw-r--r--scene/audio/event_player.cpp162
-rw-r--r--scene/audio/event_player.h10
-rw-r--r--scene/audio/sample_player.cpp581
-rw-r--r--scene/audio/sample_player.h39
-rw-r--r--scene/audio/sound_room_params.cpp124
-rw-r--r--scene/audio/sound_room_params.h35
-rw-r--r--scene/audio/stream_player.cpp196
-rw-r--r--scene/audio/stream_player.h14
-rw-r--r--scene/gui/base_button.cpp259
-rw-r--r--scene/gui/base_button.h17
-rw-r--r--scene/gui/box_container.cpp183
-rw-r--r--scene/gui/box_container.h27
-rw-r--r--scene/gui/button.cpp157
-rw-r--r--scene/gui/button.h21
-rw-r--r--scene/gui/button_array.cpp462
-rw-r--r--scene/gui/button_array.h46
-rw-r--r--scene/gui/button_group.cpp68
-rw-r--r--scene/gui/button_group.h13
-rw-r--r--scene/gui/center_container.cpp33
-rw-r--r--scene/gui/center_container.h7
-rw-r--r--scene/gui/check_box.cpp59
-rw-r--r--scene/gui/check_box.h15
-rw-r--r--scene/gui/check_button.cpp27
-rw-r--r--scene/gui/check_button.h6
-rw-r--r--scene/gui/color_picker.cpp426
-rw-r--r--scene/gui/color_picker.h45
-rw-r--r--scene/gui/color_ramp_edit.cpp292
-rw-r--r--scene/gui/color_ramp_edit.h15
-rw-r--r--scene/gui/color_rect.cpp22
-rw-r--r--scene/gui/color_rect.h10
-rw-r--r--scene/gui/container.cpp63
-rw-r--r--scene/gui/container.h9
-rw-r--r--scene/gui/control.cpp1727
-rw-r--r--scene/gui/control.h196
-rw-r--r--scene/gui/dialogs.cpp258
-rw-r--r--scene/gui/dialogs.h57
-rw-r--r--scene/gui/file_dialog.cpp572
-rw-r--r--scene/gui/file_dialog.h46
-rw-r--r--scene/gui/graph_edit.cpp584
-rw-r--r--scene/gui/graph_edit.h42
-rw-r--r--scene/gui/graph_node.cpp449
-rw-r--r--scene/gui/graph_node.h43
-rw-r--r--scene/gui/grid_container.cpp153
-rw-r--r--scene/gui/grid_container.h6
-rw-r--r--scene/gui/input_action.cpp70
-rw-r--r--scene/gui/input_action.h10
-rw-r--r--scene/gui/item_list.cpp1081
-rw-r--r--scene/gui/item_list.h49
-rw-r--r--scene/gui/label.cpp552
-rw-r--r--scene/gui/label.h28
-rw-r--r--scene/gui/line_edit.cpp640
-rw-r--r--scene/gui/line_edit.h14
-rw-r--r--scene/gui/link_button.cpp73
-rw-r--r--scene/gui/link_button.h12
-rw-r--r--scene/gui/margin_container.cpp18
-rw-r--r--scene/gui/margin_container.h4
-rw-r--r--scene/gui/menu_button.cpp38
-rw-r--r--scene/gui/menu_button.h11
-rw-r--r--scene/gui/option_button.cpp206
-rw-r--r--scene/gui/option_button.h26
-rw-r--r--scene/gui/panel.cpp10
-rw-r--r--scene/gui/panel.h8
-rw-r--r--scene/gui/panel_container.cpp46
-rw-r--r--scene/gui/panel_container.h5
-rw-r--r--scene/gui/patch_9_frame.cpp101
-rw-r--r--scene/gui/patch_9_frame.h14
-rw-r--r--scene/gui/popup.cpp155
-rw-r--r--scene/gui/popup.h24
-rw-r--r--scene/gui/popup_menu.cpp743
-rw-r--r--scene/gui/popup_menu.h77
-rw-r--r--scene/gui/progress_bar.cpp36
-rw-r--r--scene/gui/progress_bar.h6
-rw-r--r--scene/gui/range.cpp160
-rw-r--r--scene/gui/range.h17
-rw-r--r--scene/gui/reference_frame.cpp7
-rw-r--r--scene/gui/reference_frame.h4
-rw-r--r--scene/gui/rich_text_label.cpp1701
-rw-r--r--scene/gui/rich_text_label.h123
-rw-r--r--scene/gui/scroll_bar.cpp523
-rw-r--r--scene/gui/scroll_bar.h32
-rw-r--r--scene/gui/scroll_container.cpp303
-rw-r--r--scene/gui/scroll_container.h9
-rw-r--r--scene/gui/separator.cpp29
-rw-r--r--scene/gui/separator.h15
-rw-r--r--scene/gui/slider.cpp155
-rw-r--r--scene/gui/slider.h23
-rw-r--r--scene/gui/spin_box.cpp167
-rw-r--r--scene/gui/spin_box.h20
-rw-r--r--scene/gui/split_container.cpp290
-rw-r--r--scene/gui/split_container.h32
-rw-r--r--scene/gui/tab_container.cpp410
-rw-r--r--scene/gui/tab_container.h29
-rw-r--r--scene/gui/tabs.cpp493
-rw-r--r--scene/gui/tabs.h23
-rw-r--r--scene/gui/text_edit.cpp2804
-rw-r--r--scene/gui/text_edit.h162
-rw-r--r--scene/gui/texture_button.cpp171
-rw-r--r--scene/gui/texture_button.h25
-rw-r--r--scene/gui/texture_frame.cpp112
-rw-r--r--scene/gui/texture_frame.h14
-rw-r--r--scene/gui/texture_progress.cpp309
-rw-r--r--scene/gui/texture_progress.h14
-rw-r--r--scene/gui/tool_button.h3
-rw-r--r--scene/gui/tree.cpp2678
-rw-r--r--scene/gui/tree.h222
-rw-r--r--scene/gui/video_player.cpp176
-rw-r--r--scene/gui/video_player.h20
-rw-r--r--scene/io/resource_format_image.cpp147
-rw-r--r--scene/io/resource_format_image.h5
-rw-r--r--scene/io/resource_format_wav.cpp167
-rw-r--r--scene/io/resource_format_wav.h5
-rw-r--r--scene/main/canvas_layer.cpp165
-rw-r--r--scene/main/canvas_layer.h15
-rw-r--r--scene/main/http_request.cpp375
-rw-r--r--scene/main/http_request.h21
-rw-r--r--scene/main/instance_placeholder.cpp51
-rw-r--r--scene/main/instance_placeholder.h13
-rw-r--r--scene/main/node.cpp1318
-rw-r--r--scene/main/node.h160
-rw-r--r--scene/main/resource_preloader.cpp101
-rw-r--r--scene/main/resource_preloader.h21
-rw-r--r--scene/main/scene_main_loop.cpp985
-rw-r--r--scene/main/scene_main_loop.h197
-rw-r--r--scene/main/timer.cpp82
-rw-r--r--scene/main/timer.h7
-rw-r--r--scene/main/viewport.cpp1449
-rw-r--r--scene/main/viewport.h138
-rw-r--r--scene/register_scene_types.cpp303
-rw-r--r--scene/resources/animation.cpp1536
-rw-r--r--scene/resources/animation.h145
-rw-r--r--scene/resources/audio_stream.cpp31
-rw-r--r--scene/resources/audio_stream.h48
-rw-r--r--scene/resources/audio_stream_resampled.cpp1
-rw-r--r--scene/resources/baked_light.cpp443
-rw-r--r--scene/resources/baked_light.h38
-rw-r--r--scene/resources/bit_mask.cpp144
-rw-r--r--scene/resources/bit_mask.h21
-rw-r--r--scene/resources/bounds.cpp16
-rw-r--r--scene/resources/bounds.h8
-rw-r--r--scene/resources/box_shape.cpp32
-rw-r--r--scene/resources/box_shape.h6
-rw-r--r--scene/resources/canvas.cpp4
-rw-r--r--scene/resources/canvas.h4
-rw-r--r--scene/resources/capsule_shape.cpp70
-rw-r--r--scene/resources/capsule_shape.h6
-rw-r--r--scene/resources/capsule_shape_2d.cpp50
-rw-r--r--scene/resources/capsule_shape_2d.h10
-rw-r--r--scene/resources/circle_shape_2d.cpp31
-rw-r--r--scene/resources/circle_shape_2d.h9
-rw-r--r--scene/resources/color_ramp.cpp87
-rw-r--r--scene/resources/color_ramp.h59
-rw-r--r--scene/resources/concave_polygon_shape.cpp62
-rw-r--r--scene/resources/concave_polygon_shape.h33
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp42
-rw-r--r--scene/resources/concave_polygon_shape_2d.h12
-rw-r--r--scene/resources/convex_polygon_shape.cpp37
-rw-r--r--scene/resources/convex_polygon_shape.h7
-rw-r--r--scene/resources/convex_polygon_shape_2d.cpp53
-rw-r--r--scene/resources/convex_polygon_shape_2d.h14
-rw-r--r--scene/resources/curve.cpp824
-rw-r--r--scene/resources/curve.h57
-rw-r--r--scene/resources/default_theme/default_theme.cpp1106
-rw-r--r--scene/resources/default_theme/default_theme.h2
-rw-r--r--scene/resources/default_theme/theme_data.h599
-rw-r--r--scene/resources/dynamic_font.cpp703
-rw-r--r--scene/resources/dynamic_font.h104
-rw-r--r--scene/resources/dynamic_font_stb.cpp336
-rw-r--r--scene/resources/dynamic_font_stb.h70
-rw-r--r--scene/resources/environment.cpp347
-rw-r--r--scene/resources/environment.h126
-rw-r--r--scene/resources/event_stream.cpp33
-rw-r--r--scene/resources/event_stream.h66
-rw-r--r--scene/resources/font.cpp407
-rw-r--r--scene/resources/font.h73
-rw-r--r--scene/resources/material.cpp448
-rw-r--r--scene/resources/material.h124
-rw-r--r--scene/resources/mesh.cpp669
-rw-r--r--scene/resources/mesh.h101
-rw-r--r--scene/resources/mesh_data_tool.cpp485
-rw-r--r--scene/resources/mesh_data_tool.h42
-rw-r--r--scene/resources/mesh_library.cpp171
-rw-r--r--scene/resources/mesh_library.h32
-rw-r--r--scene/resources/multimesh.cpp161
-rw-r--r--scene/resources/multimesh.h19
-rw-r--r--scene/resources/packed_scene.cpp1099
-rw-r--r--scene/resources/packed_scene.h84
-rw-r--r--scene/resources/plane_shape.cpp31
-rw-r--r--scene/resources/plane_shape.h5
-rw-r--r--scene/resources/polygon_path_finder.cpp481
-rw-r--r--scene/resources/polygon_path_finder.h38
-rw-r--r--scene/resources/ray_shape.cpp17
-rw-r--r--scene/resources/ray_shape.h5
-rw-r--r--scene/resources/rectangle_shape_2d.cpp31
-rw-r--r--scene/resources/rectangle_shape_2d.h12
-rw-r--r--scene/resources/room.cpp45
-rw-r--r--scene/resources/room.h12
-rw-r--r--scene/resources/sample.cpp177
-rw-r--r--scene/resources/sample.h19
-rw-r--r--scene/resources/sample_library.cpp120
-rw-r--r--scene/resources/sample_library.h36
-rw-r--r--scene/resources/scene_format_text.cpp1181
-rw-r--r--scene/resources/scene_format_text.h87
-rw-r--r--scene/resources/scene_preloader.cpp256
-rw-r--r--scene/resources/scene_preloader.h16
-rw-r--r--scene/resources/segment_shape_2d.cpp101
-rw-r--r--scene/resources/segment_shape_2d.h23
-rw-r--r--scene/resources/shader.cpp294
-rw-r--r--scene/resources/shader.h59
-rw-r--r--scene/resources/shader_graph.cpp2695
-rw-r--r--scene/resources/shader_graph.h216
-rw-r--r--scene/resources/shape.cpp39
-rw-r--r--scene/resources/shape.h10
-rw-r--r--scene/resources/shape_2d.cpp82
-rw-r--r--scene/resources/shape_2d.h21
-rw-r--r--scene/resources/shape_line_2d.cpp52
-rw-r--r--scene/resources/shape_line_2d.h10
-rw-r--r--scene/resources/space_2d.cpp18
-rw-r--r--scene/resources/space_2d.h10
-rw-r--r--scene/resources/sphere_shape.cpp40
-rw-r--r--scene/resources/sphere_shape.h6
-rw-r--r--scene/resources/style_box.cpp393
-rw-r--r--scene/resources/style_box.h66
-rw-r--r--scene/resources/surface_tool.cpp721
-rw-r--r--scene/resources/surface_tool.h87
-rw-r--r--scene/resources/texture.cpp863
-rw-r--r--scene/resources/texture.h188
-rw-r--r--scene/resources/theme.cpp698
-rw-r--r--scene/resources/theme.h171
-rw-r--r--scene/resources/tile_set.cpp363
-rw-r--r--scene/resources/tile_set.h51
-rw-r--r--scene/resources/video_stream.cpp6
-rw-r--r--scene/resources/video_stream.h50
-rw-r--r--scene/resources/world.cpp194
-rw-r--r--scene/resources/world.h31
-rw-r--r--scene/resources/world_2d.cpp238
-rw-r--r--scene/resources/world_2d.h28
-rw-r--r--scene/scene_string_names.cpp168
-rw-r--r--scene/scene_string_names.h22
386 files changed, 34876 insertions, 42191 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 2ead6b2c9..65966de5d 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -27,24 +27,19 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "animated_sprite.h"
-#include "scene/scene_string_names.h"
#include "os/os.h"
#include "scene/scene_string_names.h"
-
-
-
+#include "scene/scene_string_names.h"
////////////////////////////
+void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture> &p_frame, int p_at_pos) {
-
-void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture>& p_frame, int p_at_pos) {
-
- Map<StringName,Anim>::Element *E=animations.find(p_anim);
+ Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E);
- if (p_at_pos>=0 && p_at_pos<E->get().frames.size())
- E->get().frames.insert(p_at_pos,p_frame);
+ if (p_at_pos >= 0 && p_at_pos < E->get().frames.size())
+ E->get().frames.insert(p_at_pos, p_frame);
else
E->get().frames.push_back(p_frame);
@@ -52,15 +47,15 @@ void SpriteFrames::add_frame(const StringName &p_anim, const Ref<Texture>& p_fra
}
int SpriteFrames::get_frame_count(const StringName &p_anim) const {
- const Map<StringName,Anim>::Element *E=animations.find(p_anim);
- ERR_FAIL_COND_V(!E,0);
+ const Map<StringName, Anim>::Element *E = animations.find(p_anim);
+ ERR_FAIL_COND_V(!E, 0);
return E->get().frames.size();
}
void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) {
- Map<StringName,Anim>::Element *E=animations.find(p_anim);
+ Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E);
E->get().frames.remove(p_idx);
@@ -68,7 +63,7 @@ void SpriteFrames::remove_frame(const StringName &p_anim, int p_idx) {
}
void SpriteFrames::clear(const StringName &p_anim) {
- Map<StringName,Anim>::Element *E=animations.find(p_anim);
+ Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E);
E->get().frames.clear();
@@ -81,33 +76,30 @@ void SpriteFrames::clear_all() {
add_animation("default");
}
-
-
-void SpriteFrames::add_animation(const StringName& p_anim) {
+void SpriteFrames::add_animation(const StringName &p_anim) {
ERR_FAIL_COND(animations.has(p_anim));
- animations[p_anim]=Anim();
+ animations[p_anim] = Anim();
}
-bool SpriteFrames::has_animation(const StringName& p_anim) const{
+bool SpriteFrames::has_animation(const StringName &p_anim) const {
return animations.has(p_anim);
}
-void SpriteFrames::remove_animation(const StringName& p_anim){
+void SpriteFrames::remove_animation(const StringName &p_anim) {
animations.erase(p_anim);
}
-void SpriteFrames::rename_animation(const StringName& p_prev,const StringName& p_next) {
+void SpriteFrames::rename_animation(const StringName &p_prev, const StringName &p_next) {
ERR_FAIL_COND(!animations.has(p_prev));
ERR_FAIL_COND(animations.has(p_next));
Anim anim = animations[p_prev];
animations.erase(p_prev);
- animations[p_next]=anim;
-
+ animations[p_next] = anim;
}
Vector<String> SpriteFrames::_get_animation_list() const {
@@ -115,7 +107,7 @@ Vector<String> SpriteFrames::_get_animation_list() const {
Vector<String> ret;
List<StringName> al;
get_animation_list(&al);
- for(List<StringName>::Element *E=al.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = al.front(); E; E = E->next()) {
ret.push_back(E->get());
}
@@ -123,49 +115,47 @@ Vector<String> SpriteFrames::_get_animation_list() const {
return ret;
}
-void SpriteFrames::get_animation_list(List<StringName> *r_animations) const{
+void SpriteFrames::get_animation_list(List<StringName> *r_animations) const {
- for (const Map<StringName,Anim>::Element *E=animations.front();E;E=E->next()) {
+ for (const Map<StringName, Anim>::Element *E = animations.front(); E; E = E->next()) {
r_animations->push_back(E->key());
}
}
-void SpriteFrames::set_animation_speed(const StringName& p_anim,float p_fps){
+void SpriteFrames::set_animation_speed(const StringName &p_anim, float p_fps) {
- ERR_FAIL_COND(p_fps<0);
- Map<StringName,Anim>::Element *E=animations.find(p_anim);
+ ERR_FAIL_COND(p_fps < 0);
+ Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E);
- E->get().speed=p_fps;
+ E->get().speed = p_fps;
}
-float SpriteFrames::get_animation_speed(const StringName& p_anim) const{
+float SpriteFrames::get_animation_speed(const StringName &p_anim) const {
- const Map<StringName,Anim>::Element *E=animations.find(p_anim);
- ERR_FAIL_COND_V(!E,0);
+ const Map<StringName, Anim>::Element *E = animations.find(p_anim);
+ ERR_FAIL_COND_V(!E, 0);
return E->get().speed;
}
-void SpriteFrames::set_animation_loop(const StringName& p_anim,bool p_loop){
- Map<StringName,Anim>::Element *E=animations.find(p_anim);
+void SpriteFrames::set_animation_loop(const StringName &p_anim, bool p_loop) {
+ Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E);
- E->get().loop=p_loop;
+ E->get().loop = p_loop;
}
-bool SpriteFrames::get_animation_loop(const StringName& p_anim) const{
- const Map<StringName,Anim>::Element *E=animations.find(p_anim);
- ERR_FAIL_COND_V(!E,false);
+bool SpriteFrames::get_animation_loop(const StringName &p_anim) const {
+ const Map<StringName, Anim>::Element *E = animations.find(p_anim);
+ ERR_FAIL_COND_V(!E, false);
return E->get().loop;
-
}
-void SpriteFrames::_set_frames(const Array& p_frames) {
+void SpriteFrames::_set_frames(const Array &p_frames) {
clear_all();
- Map<StringName,Anim>::Element *E=animations.find(SceneStringNames::get_singleton()->_default);
+ Map<StringName, Anim>::Element *E = animations.find(SceneStringNames::get_singleton()->_default);
ERR_FAIL_COND(!E);
E->get().frames.resize(p_frames.size());
- for(int i=0;i<E->get().frames.size();i++)
- E->get().frames[i]=p_frames[i];
-
+ for (int i = 0; i < E->get().frames.size(); i++)
+ E->get().frames[i] = p_frames[i];
}
Array SpriteFrames::_get_frames() const {
@@ -175,27 +165,27 @@ Array SpriteFrames::_get_frames() const {
Array SpriteFrames::_get_animations() const {
Array anims;
- for (Map<StringName,Anim>::Element *E=animations.front();E;E=E->next()) {
+ for (Map<StringName, Anim>::Element *E = animations.front(); E; E = E->next()) {
Dictionary d;
- d["name"]=E->key();
- d["speed"]=E->get().speed;
- d["loop"]=E->get().loop;
+ d["name"] = E->key();
+ d["speed"] = E->get().speed;
+ d["loop"] = E->get().loop;
Array frames;
- for(int i=0;i<E->get().frames.size();i++) {
+ for (int i = 0; i < E->get().frames.size(); i++) {
frames.push_back(E->get().frames[i]);
}
- d["frames"]=frames;
+ d["frames"] = frames;
anims.push_back(d);
}
return anims;
}
-void SpriteFrames::_set_animations(const Array& p_animations) {
+void SpriteFrames::_set_animations(const Array &p_animations) {
animations.clear();
- for(int i=0;i<p_animations.size();i++) {
+ for (int i = 0; i < p_animations.size(); i++) {
- Dictionary d=p_animations[i];
+ Dictionary d = p_animations[i];
ERR_CONTINUE(!d.has("name"));
ERR_CONTINUE(!d.has("speed"));
@@ -203,71 +193,57 @@ void SpriteFrames::_set_animations(const Array& p_animations) {
ERR_CONTINUE(!d.has("frames"));
Anim anim;
- anim.speed=d["speed"];
- anim.loop=d["loop"];
- Array frames=d["frames"];
- for(int i=0;i<frames.size();i++) {
+ anim.speed = d["speed"];
+ anim.loop = d["loop"];
+ Array frames = d["frames"];
+ for (int i = 0; i < frames.size(); i++) {
RES res = frames[i];
anim.frames.push_back(res);
}
- animations[d["name"]]=anim;
-
-
+ animations[d["name"]] = anim;
}
}
-
void SpriteFrames::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("add_animation", "anim"), &SpriteFrames::add_animation);
+ ObjectTypeDB::bind_method(_MD("has_animation", "anim"), &SpriteFrames::has_animation);
+ ObjectTypeDB::bind_method(_MD("remove_animation", "anim"), &SpriteFrames::remove_animation);
+ ObjectTypeDB::bind_method(_MD("rename_animation", "anim", "newname"), &SpriteFrames::rename_animation);
- ObjectTypeDB::bind_method(_MD("add_animation","anim"),&SpriteFrames::add_animation);
- ObjectTypeDB::bind_method(_MD("has_animation","anim"),&SpriteFrames::has_animation);
- ObjectTypeDB::bind_method(_MD("remove_animation","anim"),&SpriteFrames::remove_animation);
- ObjectTypeDB::bind_method(_MD("rename_animation","anim","newname"),&SpriteFrames::rename_animation);
-
- ObjectTypeDB::bind_method(_MD("set_animation_speed","anim","speed"),&SpriteFrames::set_animation_speed);
- ObjectTypeDB::bind_method(_MD("get_animation_speed","anim"),&SpriteFrames::get_animation_speed);
-
- ObjectTypeDB::bind_method(_MD("set_animation_loop","anim","loop"),&SpriteFrames::set_animation_loop);
- ObjectTypeDB::bind_method(_MD("get_animation_loop","anim"),&SpriteFrames::get_animation_loop);
+ ObjectTypeDB::bind_method(_MD("set_animation_speed", "anim", "speed"), &SpriteFrames::set_animation_speed);
+ ObjectTypeDB::bind_method(_MD("get_animation_speed", "anim"), &SpriteFrames::get_animation_speed);
- ObjectTypeDB::bind_method(_MD("add_frame","anim","frame","atpos"),&SpriteFrames::add_frame,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_frame_count","anim"),&SpriteFrames::get_frame_count);
- ObjectTypeDB::bind_method(_MD("get_frame","anim","idx"),&SpriteFrames::get_frame);
- ObjectTypeDB::bind_method(_MD("set_frame","anim","idx","txt"),&SpriteFrames::set_frame);
- ObjectTypeDB::bind_method(_MD("remove_frame","anim","idx"),&SpriteFrames::remove_frame);
- ObjectTypeDB::bind_method(_MD("clear","anim"),&SpriteFrames::clear);
- ObjectTypeDB::bind_method(_MD("clear_all"),&SpriteFrames::clear_all);
+ ObjectTypeDB::bind_method(_MD("set_animation_loop", "anim", "loop"), &SpriteFrames::set_animation_loop);
+ ObjectTypeDB::bind_method(_MD("get_animation_loop", "anim"), &SpriteFrames::get_animation_loop);
- ObjectTypeDB::bind_method(_MD("_set_frames"),&SpriteFrames::_set_frames);
- ObjectTypeDB::bind_method(_MD("_get_frames"),&SpriteFrames::_get_frames);
+ ObjectTypeDB::bind_method(_MD("add_frame", "anim", "frame", "atpos"), &SpriteFrames::add_frame, DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("get_frame_count", "anim"), &SpriteFrames::get_frame_count);
+ ObjectTypeDB::bind_method(_MD("get_frame", "anim", "idx"), &SpriteFrames::get_frame);
+ ObjectTypeDB::bind_method(_MD("set_frame", "anim", "idx", "txt"), &SpriteFrames::set_frame);
+ ObjectTypeDB::bind_method(_MD("remove_frame", "anim", "idx"), &SpriteFrames::remove_frame);
+ ObjectTypeDB::bind_method(_MD("clear", "anim"), &SpriteFrames::clear);
+ ObjectTypeDB::bind_method(_MD("clear_all"), &SpriteFrames::clear_all);
- ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"frames",PROPERTY_HINT_NONE,"",0),_SCS("_set_frames"),_SCS("_get_frames")); //compatibility
+ ObjectTypeDB::bind_method(_MD("_set_frames"), &SpriteFrames::_set_frames);
+ ObjectTypeDB::bind_method(_MD("_get_frames"), &SpriteFrames::_get_frames);
- ObjectTypeDB::bind_method(_MD("_set_animations"),&SpriteFrames::_set_animations);
- ObjectTypeDB::bind_method(_MD("_get_animations"),&SpriteFrames::_get_animations);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::ARRAY, "frames", PROPERTY_HINT_NONE, "", 0), _SCS("_set_frames"), _SCS("_get_frames")); //compatibility
- ADD_PROPERTYNZ( PropertyInfo(Variant::ARRAY,"animations",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_animations"),_SCS("_get_animations")); //compatibility
+ ObjectTypeDB::bind_method(_MD("_set_animations"), &SpriteFrames::_set_animations);
+ ObjectTypeDB::bind_method(_MD("_get_animations"), &SpriteFrames::_get_animations);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_animations"), _SCS("_get_animations")); //compatibility
}
-
-
-
SpriteFrames::SpriteFrames() {
add_animation(SceneStringNames::get_singleton()->_default);
-
}
-
-
-
-
-
-void AnimatedSprite::edit_set_pivot(const Point2& p_pivot) {
+void AnimatedSprite::edit_set_pivot(const Point2 &p_pivot) {
set_offset(p_pivot);
}
@@ -281,88 +257,85 @@ bool AnimatedSprite::edit_has_pivot() const {
return true;
}
-
-void AnimatedSprite::_validate_property(PropertyInfo& property) const {
+void AnimatedSprite::_validate_property(PropertyInfo &property) const {
if (!frames.is_valid())
return;
- if (property.name=="animation") {
+ if (property.name == "animation") {
- property.hint=PROPERTY_HINT_ENUM;
+ property.hint = PROPERTY_HINT_ENUM;
List<StringName> names;
frames->get_animation_list(&names);
names.sort_custom<StringName::AlphCompare>();
- bool current_found=false;
+ bool current_found = false;
- for (List<StringName>::Element *E=names.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
if (E->prev()) {
- property.hint_string+=",";
+ property.hint_string += ",";
}
- property.hint_string+=String(E->get());
- if (animation==E->get()) {
- current_found=true;
+ property.hint_string += String(E->get());
+ if (animation == E->get()) {
+ current_found = true;
}
}
if (!current_found) {
- if (property.hint_string==String()) {
- property.hint_string=String(animation);
+ if (property.hint_string == String()) {
+ property.hint_string = String(animation);
} else {
- property.hint_string=String(animation)+","+property.hint_string;
+ property.hint_string = String(animation) + "," + property.hint_string;
}
}
}
+ if (property.name == "frame") {
- if (property.name=="frame") {
-
- property.hint=PROPERTY_HINT_SPRITE_FRAME;
+ property.hint = PROPERTY_HINT_SPRITE_FRAME;
if (frames->has_animation(animation)) {
- property.hint_string="0,"+itos(frames->get_frame_count(animation)-1)+",1";
+ property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1";
} else {
- property.hint_string="0,0,0";
+ property.hint_string = "0,0,0";
}
}
-
}
void AnimatedSprite::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_PROCESS: {
if (frames.is_null())
return;
if (!frames->has_animation(animation))
return;
- if (frame<0)
+ if (frame < 0)
return;
float speed = frames->get_animation_speed(animation);
- if (speed==0)
+ if (speed == 0)
return; //do nothing
float remaining = get_process_delta_time();
- while(remaining) {
+ while (remaining) {
- if (timeout<=0) {
+ if (timeout <= 0) {
- timeout=1.0/speed;
+ timeout = 1.0 / speed;
int fc = frames->get_frame_count(animation);
- if (frame>=fc-1) {
+ if (frame >= fc - 1) {
if (frames->get_animation_loop(animation)) {
- frame=0;
+ frame = 0;
} else {
- frame=fc-1;
+ frame = fc - 1;
}
} else {
frame++;
- if (frame==fc-1) {
+ if (frame == fc - 1) {
emit_signal(SceneStringNames::get_singleton()->finished);
}
}
@@ -371,9 +344,9 @@ void AnimatedSprite::_notification(int p_what) {
_change_notify("frame");
}
- float to_process = MIN(timeout,remaining);
- remaining-=to_process;
- timeout-=to_process;
+ float to_process = MIN(timeout, remaining);
+ remaining -= to_process;
+ timeout -= to_process;
}
} break;
@@ -384,19 +357,17 @@ void AnimatedSprite::_notification(int p_what) {
return;
}
- if (frame<0) {
+ if (frame < 0) {
print_line("no draw frame <0");
return;
}
if (!frames->has_animation(animation)) {
- print_line("no draw no anim: "+String(animation));
+ print_line("no draw no anim: " + String(animation));
return;
}
-
-
- Ref<Texture> texture = frames->get_frame(animation,frame);
+ Ref<Texture> texture = frames->get_frame(animation, frame);
if (texture.is_null()) {
print_line("no draw texture is null");
return;
@@ -413,50 +384,46 @@ void AnimatedSprite::_notification(int p_what) {
Size2i s;
s = texture->get_size();
- Point2 ofs=offset;
+ Point2 ofs = offset;
if (centered)
- ofs-=s/2;
+ ofs -= s / 2;
if (OS::get_singleton()->get_use_pixel_snap()) {
- ofs=ofs.floor();
+ ofs = ofs.floor();
}
- Rect2 dst_rect(ofs,s);
+ Rect2 dst_rect(ofs, s);
if (hflip)
- dst_rect.size.x=-dst_rect.size.x;
+ dst_rect.size.x = -dst_rect.size.x;
if (vflip)
- dst_rect.size.y=-dst_rect.size.y;
+ dst_rect.size.y = -dst_rect.size.y;
//texture->draw_rect(ci,dst_rect,false,modulate);
- texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()),modulate);
-// VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
+ texture->draw_rect_region(ci, dst_rect, Rect2(Vector2(), texture->get_size()), modulate);
+ // VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate);
} break;
}
-
}
void AnimatedSprite::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
if (frames.is_valid())
- frames->disconnect("changed",this,"_res_changed");
- frames=p_frames;
+ frames->disconnect("changed", this, "_res_changed");
+ frames = p_frames;
if (frames.is_valid())
- frames->connect("changed",this,"_res_changed");
+ frames->connect("changed", this, "_res_changed");
if (!frames.is_valid()) {
- frame=0;
+ frame = 0;
} else {
set_frame(frame);
}
-
-
_change_notify();
_reset_timeout();
update();
update_configuration_warning();
-
}
Ref<SpriteFrames> AnimatedSprite::get_sprite_frames() const {
@@ -472,36 +439,30 @@ void AnimatedSprite::set_frame(int p_frame) {
if (frames->has_animation(animation)) {
int limit = frames->get_frame_count(animation);
- if (p_frame>=limit)
- p_frame=limit-1;
-
+ if (p_frame >= limit)
+ p_frame = limit - 1;
}
- if (p_frame<0)
- p_frame=0;
+ if (p_frame < 0)
+ p_frame = 0;
-
- if (frame==p_frame)
+ if (frame == p_frame)
return;
- frame=p_frame;
+ frame = p_frame;
_reset_timeout();
update();
_change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
-
-
-
}
int AnimatedSprite::get_frame() const {
return frame;
}
-
void AnimatedSprite::set_centered(bool p_center) {
- centered=p_center;
+ centered = p_center;
update();
item_rect_changed();
}
@@ -511,9 +472,9 @@ bool AnimatedSprite::is_centered() const {
return centered;
}
-void AnimatedSprite::set_offset(const Point2& p_offset) {
+void AnimatedSprite::set_offset(const Point2 &p_offset) {
- offset=p_offset;
+ offset = p_offset;
update();
item_rect_changed();
_change_notify("offset");
@@ -525,7 +486,7 @@ Point2 AnimatedSprite::get_offset() const {
void AnimatedSprite::set_flip_h(bool p_flip) {
- hflip=p_flip;
+ hflip = p_flip;
update();
}
bool AnimatedSprite::is_flipped_h() const {
@@ -535,7 +496,7 @@ bool AnimatedSprite::is_flipped_h() const {
void AnimatedSprite::set_flip_v(bool p_flip) {
- vflip=p_flip;
+ vflip = p_flip;
update();
}
bool AnimatedSprite::is_flipped_v() const {
@@ -543,40 +504,38 @@ bool AnimatedSprite::is_flipped_v() const {
return vflip;
}
+void AnimatedSprite::set_modulate(const Color &p_color) {
-void AnimatedSprite::set_modulate(const Color& p_color) {
-
- modulate=p_color;
+ modulate = p_color;
update();
}
-Color AnimatedSprite::get_modulate() const{
+Color AnimatedSprite::get_modulate() const {
return modulate;
}
-
Rect2 AnimatedSprite::get_item_rect() const {
- if (!frames.is_valid() || !frames->has_animation(animation) || frame<0 || frame>=frames->get_frame_count(animation)) {
+ if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) {
return Node2D::get_item_rect();
}
Ref<Texture> t;
if (animation)
- t = frames->get_frame(animation,frame);
+ t = frames->get_frame(animation, frame);
if (t.is_null())
return Node2D::get_item_rect();
Size2i s = t->get_size();
- Point2 ofs=offset;
+ Point2 ofs = offset;
if (centered)
- ofs-=s/2;
+ ofs -= s / 2;
- if (s==Size2(0,0))
- s=Size2(1,1);
+ if (s == Size2(0, 0))
+ s = Size2(1, 1);
- return Rect2(ofs,s);
+ return Rect2(ofs, s);
}
void AnimatedSprite::_res_changed() {
@@ -589,9 +548,9 @@ void AnimatedSprite::_res_changed() {
void AnimatedSprite::_set_playing(bool p_playing) {
- if (playing==p_playing)
+ if (playing == p_playing)
return;
- playing=p_playing;
+ playing = p_playing;
_reset_timeout();
set_process(playing);
}
@@ -601,14 +560,14 @@ bool AnimatedSprite::_is_playing() const {
return playing;
}
-void AnimatedSprite::play(const StringName& p_animation) {
+void AnimatedSprite::play(const StringName &p_animation) {
if (p_animation)
set_animation(p_animation);
_set_playing(true);
}
-void AnimatedSprite::stop(){
+void AnimatedSprite::stop() {
_set_playing(false);
}
@@ -625,29 +584,28 @@ void AnimatedSprite::_reset_timeout() {
if (frames.is_valid() && frames->has_animation(animation)) {
float speed = frames->get_animation_speed(animation);
- if (speed>0) {
- timeout=1.0/speed;
+ if (speed > 0) {
+ timeout = 1.0 / speed;
} else {
- timeout=0;
+ timeout = 0;
}
} else {
- timeout=0;
+ timeout = 0;
}
-
}
-void AnimatedSprite::set_animation(const StringName& p_animation){
+void AnimatedSprite::set_animation(const StringName &p_animation) {
- if (animation==p_animation)
+ if (animation == p_animation)
return;
- animation=p_animation;
+ animation = p_animation;
_reset_timeout();
set_frame(0);
_change_notify();
update();
}
-StringName AnimatedSprite::get_animation() const{
+StringName AnimatedSprite::get_animation() const {
return animation;
}
@@ -663,69 +621,62 @@ String AnimatedSprite::get_configuration_warning() const {
void AnimatedSprite::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_sprite_frames", "sprite_frames:SpriteFrames"), &AnimatedSprite::set_sprite_frames);
+ ObjectTypeDB::bind_method(_MD("get_sprite_frames:SpriteFrames"), &AnimatedSprite::get_sprite_frames);
- ObjectTypeDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite::set_sprite_frames);
- ObjectTypeDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite::get_sprite_frames);
-
- ObjectTypeDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite::set_animation);
- ObjectTypeDB::bind_method(_MD("get_animation"),&AnimatedSprite::get_animation);
+ ObjectTypeDB::bind_method(_MD("set_animation", "animation"), &AnimatedSprite::set_animation);
+ ObjectTypeDB::bind_method(_MD("get_animation"), &AnimatedSprite::get_animation);
- ObjectTypeDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite::_set_playing);
- ObjectTypeDB::bind_method(_MD("_is_playing"),&AnimatedSprite::_is_playing);
+ ObjectTypeDB::bind_method(_MD("_set_playing", "playing"), &AnimatedSprite::_set_playing);
+ ObjectTypeDB::bind_method(_MD("_is_playing"), &AnimatedSprite::_is_playing);
- ObjectTypeDB::bind_method(_MD("play","anim"),&AnimatedSprite::play,DEFVAL(StringName()));
- ObjectTypeDB::bind_method(_MD("stop"),&AnimatedSprite::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&AnimatedSprite::is_playing);
+ ObjectTypeDB::bind_method(_MD("play", "anim"), &AnimatedSprite::play, DEFVAL(StringName()));
+ ObjectTypeDB::bind_method(_MD("stop"), &AnimatedSprite::stop);
+ ObjectTypeDB::bind_method(_MD("is_playing"), &AnimatedSprite::is_playing);
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&AnimatedSprite::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&AnimatedSprite::is_centered);
+ ObjectTypeDB::bind_method(_MD("set_centered", "centered"), &AnimatedSprite::set_centered);
+ ObjectTypeDB::bind_method(_MD("is_centered"), &AnimatedSprite::is_centered);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&AnimatedSprite::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&AnimatedSprite::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &AnimatedSprite::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &AnimatedSprite::get_offset);
- ObjectTypeDB::bind_method(_MD("set_flip_h","flip_h"),&AnimatedSprite::set_flip_h);
- ObjectTypeDB::bind_method(_MD("is_flipped_h"),&AnimatedSprite::is_flipped_h);
+ ObjectTypeDB::bind_method(_MD("set_flip_h", "flip_h"), &AnimatedSprite::set_flip_h);
+ ObjectTypeDB::bind_method(_MD("is_flipped_h"), &AnimatedSprite::is_flipped_h);
- ObjectTypeDB::bind_method(_MD("set_flip_v","flip_v"),&AnimatedSprite::set_flip_v);
- ObjectTypeDB::bind_method(_MD("is_flipped_v"),&AnimatedSprite::is_flipped_v);
+ ObjectTypeDB::bind_method(_MD("set_flip_v", "flip_v"), &AnimatedSprite::set_flip_v);
+ ObjectTypeDB::bind_method(_MD("is_flipped_v"), &AnimatedSprite::is_flipped_v);
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&AnimatedSprite::get_frame);
+ ObjectTypeDB::bind_method(_MD("set_frame", "frame"), &AnimatedSprite::set_frame);
+ ObjectTypeDB::bind_method(_MD("get_frame"), &AnimatedSprite::get_frame);
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&AnimatedSprite::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&AnimatedSprite::get_modulate);
+ ObjectTypeDB::bind_method(_MD("set_modulate", "modulate"), &AnimatedSprite::set_modulate);
+ ObjectTypeDB::bind_method(_MD("get_modulate"), &AnimatedSprite::get_modulate);
-
- ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed);
+ ObjectTypeDB::bind_method(_MD("_res_changed"), &AnimatedSprite::_res_changed);
ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("finished"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
- ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), _SCS("set_animation"),_SCS("get_animation"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "playing"), _SCS("_set_playing"),_SCS("_is_playing"));
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v"));
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
-
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), _SCS("set_sprite_frames"), _SCS("get_sprite_frames"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), _SCS("set_animation"), _SCS("get_animation"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"), _SCS("get_frame"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "playing"), _SCS("_set_playing"), _SCS("_is_playing"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "centered"), _SCS("set_centered"), _SCS("is_centered"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "flip_h"), _SCS("set_flip_h"), _SCS("is_flipped_h"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "flip_v"), _SCS("set_flip_v"), _SCS("is_flipped_v"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
}
AnimatedSprite::AnimatedSprite() {
- centered=true;
- hflip=false;
- vflip=false;
-
- frame=0;
- playing=false;
- animation="default";
- modulate=Color(1,1,1,1);
- timeout=0;
-
+ centered = true;
+ hflip = false;
+ vflip = false;
+ frame = 0;
+ playing = false;
+ animation = "default";
+ modulate = Color(1, 1, 1, 1);
+ timeout = 0;
}
-
-
diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h
index d44745554..2d2fac1ad 100644
--- a/scene/2d/animated_sprite.h
+++ b/scene/2d/animated_sprite.h
@@ -32,84 +32,80 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/texture.h"
-
class SpriteFrames : public Resource {
- OBJ_TYPE(SpriteFrames,Resource);
+ OBJ_TYPE(SpriteFrames, Resource);
struct Anim {
float speed;
bool loop;
- Vector< Ref<Texture> > frames;
+ Vector<Ref<Texture> > frames;
- Anim() { loop=true; speed=5; }
+ Anim() {
+ loop = true;
+ speed = 5;
+ }
};
- Map<StringName,Anim> animations;
+ Map<StringName, Anim> animations;
Array _get_frames() const;
- void _set_frames(const Array& p_frames);
+ void _set_frames(const Array &p_frames);
Array _get_animations() const;
- void _set_animations(const Array& p_animations);
+ void _set_animations(const Array &p_animations);
Vector<String> _get_animation_list() const;
protected:
-
static void _bind_methods();
public:
-
- void add_animation(const StringName& p_anim);
- bool has_animation(const StringName& p_anim) const;
- void remove_animation(const StringName& p_anim);
- void rename_animation(const StringName& p_prev,const StringName& p_next);
+ void add_animation(const StringName &p_anim);
+ bool has_animation(const StringName &p_anim) const;
+ void remove_animation(const StringName &p_anim);
+ void rename_animation(const StringName &p_prev, const StringName &p_next);
void get_animation_list(List<StringName> *r_animations) const;
- void set_animation_speed(const StringName& p_anim,float p_fps);
- float get_animation_speed(const StringName& p_anim) const;
+ void set_animation_speed(const StringName &p_anim, float p_fps);
+ float get_animation_speed(const StringName &p_anim) const;
- void set_animation_loop(const StringName& p_anim,bool p_loop);
- bool get_animation_loop(const StringName& p_anim) const;
+ void set_animation_loop(const StringName &p_anim, bool p_loop);
+ bool get_animation_loop(const StringName &p_anim) const;
- void add_frame(const StringName& p_anim,const Ref<Texture>& p_frame,int p_at_pos=-1);
- int get_frame_count(const StringName& p_anim) const;
- _FORCE_INLINE_ Ref<Texture> get_frame(const StringName& p_anim,int p_idx) const {
+ void add_frame(const StringName &p_anim, const Ref<Texture> &p_frame, int p_at_pos = -1);
+ int get_frame_count(const StringName &p_anim) const;
+ _FORCE_INLINE_ Ref<Texture> get_frame(const StringName &p_anim, int p_idx) const {
- const Map<StringName,Anim>::Element *E=animations.find(p_anim);
- ERR_FAIL_COND_V(!E,Ref<Texture>());
- ERR_FAIL_COND_V(p_idx<0,Ref<Texture>());
- if (p_idx>=E->get().frames.size())
+ const Map<StringName, Anim>::Element *E = animations.find(p_anim);
+ ERR_FAIL_COND_V(!E, Ref<Texture>());
+ ERR_FAIL_COND_V(p_idx < 0, Ref<Texture>());
+ if (p_idx >= E->get().frames.size())
return Ref<Texture>();
return E->get().frames[p_idx];
}
- void set_frame(const StringName& p_anim,int p_idx,const Ref<Texture>& p_frame){
- Map<StringName,Anim>::Element *E=animations.find(p_anim);
+ void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture> &p_frame) {
+ Map<StringName, Anim>::Element *E = animations.find(p_anim);
ERR_FAIL_COND(!E);
- ERR_FAIL_COND(p_idx<0);
- if (p_idx>=E->get().frames.size())
+ ERR_FAIL_COND(p_idx < 0);
+ if (p_idx >= E->get().frames.size())
return;
- E->get().frames[p_idx]=p_frame;
+ E->get().frames[p_idx] = p_frame;
}
- void remove_frame(const StringName& p_anim,int p_idx);
- void clear(const StringName& p_anim);
+ void remove_frame(const StringName &p_anim, int p_idx);
+ void clear(const StringName &p_anim);
void clear_all();
-
SpriteFrames();
-
};
-
-
class AnimatedSprite : public Node2D {
- OBJ_TYPE(AnimatedSprite,Node2D);
+ OBJ_TYPE(AnimatedSprite, Node2D);
Ref<SpriteFrames> frames;
bool playing;
@@ -132,28 +128,24 @@ class AnimatedSprite : public Node2D {
void _set_playing(bool p_playing);
bool _is_playing() const;
-
protected:
-
static void _bind_methods();
void _notification(int p_what);
- virtual void _validate_property(PropertyInfo& property) const;
+ virtual void _validate_property(PropertyInfo &property) const;
public:
-
-
- virtual void edit_set_pivot(const Point2& p_pivot);
+ virtual void edit_set_pivot(const Point2 &p_pivot);
virtual Point2 edit_get_pivot() const;
virtual bool edit_has_pivot() const;
void set_sprite_frames(const Ref<SpriteFrames> &p_frames);
Ref<SpriteFrames> get_sprite_frames() const;
- void play(const StringName& p_animation=StringName());
+ void play(const StringName &p_animation = StringName());
void stop();
bool is_playing() const;
- void set_animation(const StringName& p_animation);
+ void set_animation(const StringName &p_animation);
StringName get_animation() const;
void set_frame(int p_frame);
@@ -162,7 +154,7 @@ public:
void set_centered(bool p_center);
bool is_centered() const;
- void set_offset(const Point2& p_offset);
+ void set_offset(const Point2 &p_offset);
Point2 get_offset() const;
void set_flip_h(bool p_flip);
@@ -171,7 +163,7 @@ public:
void set_flip_v(bool p_flip);
bool is_flipped_v() const;
- void set_modulate(const Color& p_color);
+ void set_modulate(const Color &p_color);
Color get_modulate() const;
virtual Rect2 get_item_rect() const;
@@ -180,5 +172,4 @@ public:
AnimatedSprite();
};
-
#endif // ANIMATED_SPRITE_H
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 24934233c..fff399f8f 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -31,108 +31,101 @@
#include "servers/physics_2d_server.h"
void Area2D::set_space_override_mode(SpaceOverride p_mode) {
- space_override=p_mode;
- Physics2DServer::get_singleton()->area_set_space_override_mode(get_rid(),Physics2DServer::AreaSpaceOverrideMode(p_mode));
-
-
+ space_override = p_mode;
+ Physics2DServer::get_singleton()->area_set_space_override_mode(get_rid(), Physics2DServer::AreaSpaceOverrideMode(p_mode));
}
-Area2D::SpaceOverride Area2D::get_space_override_mode() const{
+Area2D::SpaceOverride Area2D::get_space_override_mode() const {
return space_override;
}
-void Area2D::set_gravity_is_point(bool p_enabled){
-
- gravity_is_point=p_enabled;
- Physics2DServer::get_singleton()->area_set_param(get_rid(),Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT,p_enabled);
+void Area2D::set_gravity_is_point(bool p_enabled) {
+ gravity_is_point = p_enabled;
+ Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
}
-bool Area2D::is_gravity_a_point() const{
+bool Area2D::is_gravity_a_point() const {
return gravity_is_point;
}
-void Area2D::set_gravity_distance_scale(real_t p_scale){
-
- gravity_distance_scale=p_scale;
- Physics2DServer::get_singleton()->area_set_param(get_rid(),Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE,p_scale);
+void Area2D::set_gravity_distance_scale(real_t p_scale) {
+ gravity_distance_scale = p_scale;
+ Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
}
-real_t Area2D::get_gravity_distance_scale() const{
+real_t Area2D::get_gravity_distance_scale() const {
return gravity_distance_scale;
}
-void Area2D::set_gravity_vector(const Vector2& p_vec){
-
- gravity_vec=p_vec;
- Physics2DServer::get_singleton()->area_set_param(get_rid(),Physics2DServer::AREA_PARAM_GRAVITY_VECTOR,p_vec);
+void Area2D::set_gravity_vector(const Vector2 &p_vec) {
+ gravity_vec = p_vec;
+ Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY_VECTOR, p_vec);
}
-Vector2 Area2D::get_gravity_vector() const{
+Vector2 Area2D::get_gravity_vector() const {
return gravity_vec;
}
-void Area2D::set_gravity(real_t p_gravity){
+void Area2D::set_gravity(real_t p_gravity) {
- gravity=p_gravity;
- Physics2DServer::get_singleton()->area_set_param(get_rid(),Physics2DServer::AREA_PARAM_GRAVITY,p_gravity);
+ gravity = p_gravity;
+ Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_GRAVITY, p_gravity);
}
-real_t Area2D::get_gravity() const{
+real_t Area2D::get_gravity() const {
return gravity;
}
-void Area2D::set_linear_damp(real_t p_linear_damp){
+void Area2D::set_linear_damp(real_t p_linear_damp) {
- linear_damp=p_linear_damp;
- Physics2DServer::get_singleton()->area_set_param(get_rid(),Physics2DServer::AREA_PARAM_LINEAR_DAMP,p_linear_damp);
+ linear_damp = p_linear_damp;
+ Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
}
-real_t Area2D::get_linear_damp() const{
+real_t Area2D::get_linear_damp() const {
return linear_damp;
}
-void Area2D::set_angular_damp(real_t p_angular_damp){
+void Area2D::set_angular_damp(real_t p_angular_damp) {
- angular_damp=p_angular_damp;
- Physics2DServer::get_singleton()->area_set_param(get_rid(),Physics2DServer::AREA_PARAM_ANGULAR_DAMP,p_angular_damp);
+ angular_damp = p_angular_damp;
+ Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
}
-real_t Area2D::get_angular_damp() const{
+real_t Area2D::get_angular_damp() const {
return angular_damp;
}
-void Area2D::set_priority(real_t p_priority){
+void Area2D::set_priority(real_t p_priority) {
- priority=p_priority;
- Physics2DServer::get_singleton()->area_set_param(get_rid(),Physics2DServer::AREA_PARAM_PRIORITY,p_priority);
+ priority = p_priority;
+ Physics2DServer::get_singleton()->area_set_param(get_rid(), Physics2DServer::AREA_PARAM_PRIORITY, p_priority);
}
-real_t Area2D::get_priority() const{
+real_t Area2D::get_priority() const {
return priority;
}
-
void Area2D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,BodyState>::Element *E=body_map.find(p_id);
+ Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_tree);
- E->get().in_tree=true;
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ E->get().in_tree = true;
+ emit_signal(SceneStringNames::get_singleton()->body_enter, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_enter_shape, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
-
}
void Area2D::_body_exit_tree(ObjectID p_id) {
@@ -140,54 +133,51 @@ void Area2D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,BodyState>::Element *E=body_map.find(p_id);
+ Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
- E->get().in_tree=false;
- emit_signal(SceneStringNames::get_singleton()->body_exit,node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ E->get().in_tree = false;
+ emit_signal(SceneStringNames::get_singleton()->body_exit, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
-
}
-void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape) {
+void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape) {
- bool body_in = p_status==Physics2DServer::AREA_BODY_ADDED;
- ObjectID objid=p_instance;
+ bool body_in = p_status == Physics2DServer::AREA_BODY_ADDED;
+ ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
Node *node = obj ? obj->cast_to<Node>() : NULL;
- Map<ObjectID,BodyState>::Element *E=body_map.find(objid);
+ Map<ObjectID, BodyState>::Element *E = body_map.find(objid);
ERR_FAIL_COND(!body_in && !E);
- locked=true;
+ locked = true;
if (body_in) {
if (!E) {
- E = body_map.insert(objid,BodyState());
- E->get().rc=0;
- E->get().in_tree=node && node->is_inside_tree();
+ E = body_map.insert(objid, BodyState());
+ E->get().rc = 0;
+ E->get().in_tree = node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_enter, node);
}
}
-
}
E->get().rc++;
if (node)
- E->get().shapes.insert(ShapePair(p_body_shape,p_area_shape));
-
+ E->get().shapes.insert(ShapePair(p_body_shape, p_area_shape));
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_enter_shape, objid, node, p_body_shape, p_area_shape);
}
} else {
@@ -195,56 +185,48 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b
E->get().rc--;
if (node)
- E->get().shapes.erase(ShapePair(p_body_shape,p_area_shape));
+ E->get().shapes.erase(ShapePair(p_body_shape, p_area_shape));
- bool eraseit=false;
+ bool eraseit = false;
- if (E->get().rc==0) {
+ if (E->get().rc == 0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (E->get().in_tree)
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
-
+ emit_signal(SceneStringNames::get_singleton()->body_exit, obj);
}
- eraseit=true;
-
+ eraseit = true;
}
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, objid, obj, p_body_shape, p_area_shape);
}
if (eraseit)
body_map.erase(E);
-
}
- locked=false;
-
-
+ locked = false;
}
-
-
void Area2D::_area_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,AreaState>::Element *E=area_map.find(p_id);
+ Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_tree);
- E->get().in_tree=true;
- emit_signal(SceneStringNames::get_singleton()->area_enter,node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ E->get().in_tree = true;
+ emit_signal(SceneStringNames::get_singleton()->area_enter, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->area_enter_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_enter_shape, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
-
}
void Area2D::_area_exit_tree(ObjectID p_id) {
@@ -252,54 +234,51 @@ void Area2D::_area_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,AreaState>::Element *E=area_map.find(p_id);
+ Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
- E->get().in_tree=false;
- emit_signal(SceneStringNames::get_singleton()->area_exit,node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ E->get().in_tree = false;
+ emit_signal(SceneStringNames::get_singleton()->area_exit, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
-
}
-void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_area_shape,int p_self_shape) {
+void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_area_shape, int p_self_shape) {
- bool area_in = p_status==Physics2DServer::AREA_BODY_ADDED;
- ObjectID objid=p_instance;
+ bool area_in = p_status == Physics2DServer::AREA_BODY_ADDED;
+ ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
Node *node = obj ? obj->cast_to<Node>() : NULL;
- Map<ObjectID,AreaState>::Element *E=area_map.find(objid);
+ Map<ObjectID, AreaState>::Element *E = area_map.find(objid);
ERR_FAIL_COND(!area_in && !E);
- locked=true;
+ locked = true;
if (area_in) {
if (!E) {
- E = area_map.insert(objid,AreaState());
- E->get().rc=0;
- E->get().in_tree=node && node->is_inside_tree();
+ E = area_map.insert(objid, AreaState());
+ E->get().rc = 0;
+ E->get().in_tree = node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->area_enter, node);
}
}
-
}
E->get().rc++;
if (node)
- E->get().shapes.insert(AreaShapePair(p_area_shape,p_self_shape));
-
+ E->get().shapes.insert(AreaShapePair(p_area_shape, p_self_shape));
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_enter_shape,objid,node,p_area_shape,p_self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_enter_shape, objid, node, p_area_shape, p_self_shape);
}
} else {
@@ -307,39 +286,32 @@ void Area2D::_area_inout(int p_status,const RID& p_area, int p_instance, int p_a
E->get().rc--;
if (node)
- E->get().shapes.erase(AreaShapePair(p_area_shape,p_self_shape));
+ E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape));
- bool eraseit=false;
+ bool eraseit = false;
- if (E->get().rc==0) {
+ if (E->get().rc == 0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_area_exit_tree);
if (E->get().in_tree)
- emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
-
+ emit_signal(SceneStringNames::get_singleton()->area_exit, obj);
}
- eraseit=true;
-
+ eraseit = true;
}
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,objid,obj,p_area_shape,p_self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape, objid, obj, p_area_shape, p_self_shape);
}
if (eraseit)
area_map.erase(E);
-
}
- locked=false;
-
-
+ locked = false;
}
-
-
void Area2D::_clear_monitoring() {
if (locked) {
@@ -348,40 +320,38 @@ void Area2D::_clear_monitoring() {
ERR_FAIL_COND(locked);
{
- Map<ObjectID,BodyState> bmcopy = body_map;
+ Map<ObjectID, BodyState> bmcopy = body_map;
body_map.clear();
//disconnect all monitored stuff
- for (Map<ObjectID,BodyState>::Element *E=bmcopy.front();E;E=E->next()) {
+ for (Map<ObjectID, BodyState>::Element *E = bmcopy.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_CONTINUE(!node);
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (!E->get().in_tree)
continue;
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
-
+ emit_signal(SceneStringNames::get_singleton()->body_exit, obj);
}
-
}
{
- Map<ObjectID,AreaState> bmcopy = area_map;
+ Map<ObjectID, AreaState> bmcopy = area_map;
area_map.clear();
//disconnect all monitored stuff
- for (Map<ObjectID,AreaState>::Element *E=bmcopy.front();E;E=E->next()) {
+ for (Map<ObjectID, AreaState>::Element *E = bmcopy.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
@@ -390,26 +360,25 @@ void Area2D::_clear_monitoring() {
continue;
//ERR_CONTINUE(!node);
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_area_exit_tree);
if (!E->get().in_tree)
continue;
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,E->key(),node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
- emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->area_exit, obj);
}
}
-
}
void Area2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_EXIT_TREE: {
@@ -418,36 +387,32 @@ void Area2D::_notification(int p_what) {
_clear_monitoring();
} break;
case NOTIFICATION_ENTER_TREE: {
-
+
set_enable_monitoring(monitoring_stored);
} break;
}
-
}
-
void Area2D::set_enable_monitoring(bool p_enable) {
-
- if (p_enable==monitoring)
+ if (p_enable == monitoring)
return;
if (locked) {
ERR_EXPLAIN("Function blocked during in/out signal. Use call_deferred(\"set_enable_monitoring\",true/false)");
}
ERR_FAIL_COND(locked);
- monitoring=p_enable;
+ monitoring = p_enable;
if (monitoring) {
- Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(),this,SceneStringNames::get_singleton()->_body_inout);
- Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(),this,SceneStringNames::get_singleton()->_area_inout);
+ Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
+ Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
} else {
- Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(),NULL,StringName());
- Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(),NULL,StringName());
+ Physics2DServer::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName());
+ Physics2DServer::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName());
_clear_monitoring();
-
}
}
@@ -463,12 +428,12 @@ void Area2D::set_monitorable(bool p_enable) {
}
ERR_FAIL_COND(locked);
- if (p_enable==monitorable)
+ if (p_enable == monitorable)
return;
- monitorable=p_enable;
+ monitorable = p_enable;
- Physics2DServer::get_singleton()->area_set_monitorable(get_rid(),monitorable);
+ Physics2DServer::get_singleton()->area_set_monitorable(get_rid(), monitorable);
}
bool Area2D::is_monitorable() const {
@@ -478,18 +443,17 @@ bool Area2D::is_monitorable() const {
Array Area2D::get_overlapping_bodies() const {
- ERR_FAIL_COND_V(!monitoring,Array());
+ ERR_FAIL_COND_V(!monitoring, Array());
Array ret;
ret.resize(body_map.size());
- int idx=0;
- for (const Map<ObjectID,BodyState>::Element *E=body_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (const Map<ObjectID, BodyState>::Element *E = body_map.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
if (!obj) {
- ret.resize( ret.size() -1 ); //ops
+ ret.resize(ret.size() - 1); //ops
} else {
- ret[idx++]=obj;
+ ret[idx++] = obj;
}
-
}
return ret;
@@ -497,49 +461,44 @@ Array Area2D::get_overlapping_bodies() const {
Array Area2D::get_overlapping_areas() const {
- ERR_FAIL_COND_V(!monitoring,Array());
+ ERR_FAIL_COND_V(!monitoring, Array());
Array ret;
ret.resize(area_map.size());
- int idx=0;
- for (const Map<ObjectID,AreaState>::Element *E=area_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (const Map<ObjectID, AreaState>::Element *E = area_map.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
if (!obj) {
- ret.resize( ret.size() -1 ); //ops
+ ret.resize(ret.size() - 1); //ops
} else {
- ret[idx++]=obj;
+ ret[idx++] = obj;
}
-
}
return ret;
}
-bool Area2D::overlaps_area(Node* p_area) const {
+bool Area2D::overlaps_area(Node *p_area) const {
- ERR_FAIL_NULL_V(p_area,false);
- const Map<ObjectID,AreaState>::Element *E=area_map.find(p_area->get_instance_ID());
+ ERR_FAIL_NULL_V(p_area, false);
+ const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_ID());
if (!E)
return false;
return E->get().in_tree;
-
-
-
}
-bool Area2D::overlaps_body(Node* p_body) const{
+bool Area2D::overlaps_body(Node *p_body) const {
- ERR_FAIL_NULL_V(p_body,false);
- const Map<ObjectID,BodyState>::Element *E=body_map.find(p_body->get_instance_ID());
+ ERR_FAIL_NULL_V(p_body, false);
+ const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_ID());
if (!E)
return false;
return E->get().in_tree;
-
}
void Area2D::set_collision_mask(uint32_t p_mask) {
- collision_mask=p_mask;
- Physics2DServer::get_singleton()->area_set_collision_mask(get_rid(),p_mask);
+ collision_mask = p_mask;
+ Physics2DServer::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
}
uint32_t Area2D::get_collision_mask() const {
@@ -547,11 +506,10 @@ uint32_t Area2D::get_collision_mask() const {
return collision_mask;
}
-
void Area2D::set_layer_mask(uint32_t p_mask) {
- layer_mask=p_mask;
- Physics2DServer::get_singleton()->area_set_layer_mask(get_rid(),p_mask);
+ layer_mask = p_mask;
+ Physics2DServer::get_singleton()->area_set_layer_mask(get_rid(), p_mask);
}
uint32_t Area2D::get_layer_mask() const {
@@ -563,143 +521,135 @@ void Area2D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
- mask|=1<<p_bit;
+ mask |= 1 << p_bit;
else
- mask&=~(1<<p_bit);
+ mask &= ~(1 << p_bit);
set_collision_mask(mask);
-
}
-bool Area2D::get_collision_mask_bit(int p_bit) const{
+bool Area2D::get_collision_mask_bit(int p_bit) const {
- return get_collision_mask()&(1<<p_bit);
+ return get_collision_mask() & (1 << p_bit);
}
-
void Area2D::set_layer_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_layer_mask();
if (p_value)
- mask|=1<<p_bit;
+ mask |= 1 << p_bit;
else
- mask&=~(1<<p_bit);
+ mask &= ~(1 << p_bit);
set_layer_mask(mask);
-
}
-bool Area2D::get_layer_mask_bit(int p_bit) const{
+bool Area2D::get_layer_mask_bit(int p_bit) const {
- return get_layer_mask()&(1<<p_bit);
+ return get_layer_mask() & (1 << p_bit);
}
-
void Area2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_body_enter_tree","id"),&Area2D::_body_enter_tree);
- ObjectTypeDB::bind_method(_MD("_body_exit_tree","id"),&Area2D::_body_exit_tree);
-
- ObjectTypeDB::bind_method(_MD("_area_enter_tree","id"),&Area2D::_area_enter_tree);
- ObjectTypeDB::bind_method(_MD("_area_exit_tree","id"),&Area2D::_area_exit_tree);
-
- ObjectTypeDB::bind_method(_MD("set_space_override_mode","enable"),&Area2D::set_space_override_mode);
- ObjectTypeDB::bind_method(_MD("get_space_override_mode"),&Area2D::get_space_override_mode);
+ ObjectTypeDB::bind_method(_MD("_body_enter_tree", "id"), &Area2D::_body_enter_tree);
+ ObjectTypeDB::bind_method(_MD("_body_exit_tree", "id"), &Area2D::_body_exit_tree);
- ObjectTypeDB::bind_method(_MD("set_gravity_is_point","enable"),&Area2D::set_gravity_is_point);
- ObjectTypeDB::bind_method(_MD("is_gravity_a_point"),&Area2D::is_gravity_a_point);
+ ObjectTypeDB::bind_method(_MD("_area_enter_tree", "id"), &Area2D::_area_enter_tree);
+ ObjectTypeDB::bind_method(_MD("_area_exit_tree", "id"), &Area2D::_area_exit_tree);
- ObjectTypeDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area2D::set_gravity_distance_scale);
- ObjectTypeDB::bind_method(_MD("get_gravity_distance_scale"),&Area2D::get_gravity_distance_scale);
+ ObjectTypeDB::bind_method(_MD("set_space_override_mode", "enable"), &Area2D::set_space_override_mode);
+ ObjectTypeDB::bind_method(_MD("get_space_override_mode"), &Area2D::get_space_override_mode);
- ObjectTypeDB::bind_method(_MD("set_gravity_vector","vector"),&Area2D::set_gravity_vector);
- ObjectTypeDB::bind_method(_MD("get_gravity_vector"),&Area2D::get_gravity_vector);
+ ObjectTypeDB::bind_method(_MD("set_gravity_is_point", "enable"), &Area2D::set_gravity_is_point);
+ ObjectTypeDB::bind_method(_MD("is_gravity_a_point"), &Area2D::is_gravity_a_point);
- ObjectTypeDB::bind_method(_MD("set_gravity","gravity"),&Area2D::set_gravity);
- ObjectTypeDB::bind_method(_MD("get_gravity"),&Area2D::get_gravity);
+ ObjectTypeDB::bind_method(_MD("set_gravity_distance_scale", "distance_scale"), &Area2D::set_gravity_distance_scale);
+ ObjectTypeDB::bind_method(_MD("get_gravity_distance_scale"), &Area2D::get_gravity_distance_scale);
- ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area2D::set_linear_damp);
- ObjectTypeDB::bind_method(_MD("get_linear_damp"),&Area2D::get_linear_damp);
+ ObjectTypeDB::bind_method(_MD("set_gravity_vector", "vector"), &Area2D::set_gravity_vector);
+ ObjectTypeDB::bind_method(_MD("get_gravity_vector"), &Area2D::get_gravity_vector);
- ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area2D::set_angular_damp);
- ObjectTypeDB::bind_method(_MD("get_angular_damp"),&Area2D::get_angular_damp);
+ ObjectTypeDB::bind_method(_MD("set_gravity", "gravity"), &Area2D::set_gravity);
+ ObjectTypeDB::bind_method(_MD("get_gravity"), &Area2D::get_gravity);
- ObjectTypeDB::bind_method(_MD("set_priority","priority"),&Area2D::set_priority);
- ObjectTypeDB::bind_method(_MD("get_priority"),&Area2D::get_priority);
+ ObjectTypeDB::bind_method(_MD("set_linear_damp", "linear_damp"), &Area2D::set_linear_damp);
+ ObjectTypeDB::bind_method(_MD("get_linear_damp"), &Area2D::get_linear_damp);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&Area2D::get_collision_mask);
+ ObjectTypeDB::bind_method(_MD("set_angular_damp", "angular_damp"), &Area2D::set_angular_damp);
+ ObjectTypeDB::bind_method(_MD("get_angular_damp"), &Area2D::get_angular_damp);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("set_priority", "priority"), &Area2D::set_priority);
+ ObjectTypeDB::bind_method(_MD("get_priority"), &Area2D::get_priority);
- ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area2D::set_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area2D::get_collision_mask_bit);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask", "collision_mask"), &Area2D::set_collision_mask);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask"), &Area2D::get_collision_mask);
- ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area2D::set_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area2D::get_layer_mask_bit);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask", "layer_mask"), &Area2D::set_layer_mask);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask"), &Area2D::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area2D::set_enable_monitoring);
- ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area2D::is_monitoring_enabled);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask_bit", "bit", "value"), &Area2D::set_collision_mask_bit);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask_bit", "bit"), &Area2D::get_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_monitorable","enable"),&Area2D::set_monitorable);
- ObjectTypeDB::bind_method(_MD("is_monitorable"),&Area2D::is_monitorable);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask_bit", "bit", "value"), &Area2D::set_layer_mask_bit);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask_bit", "bit"), &Area2D::get_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_overlapping_bodies"),&Area2D::get_overlapping_bodies);
- ObjectTypeDB::bind_method(_MD("get_overlapping_areas"),&Area2D::get_overlapping_areas);
+ ObjectTypeDB::bind_method(_MD("set_enable_monitoring", "enable"), &Area2D::set_enable_monitoring);
+ ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"), &Area2D::is_monitoring_enabled);
- ObjectTypeDB::bind_method(_MD("overlaps_body","body"),&Area2D::overlaps_body);
- ObjectTypeDB::bind_method(_MD("overlaps_area","area"),&Area2D::overlaps_area);
+ ObjectTypeDB::bind_method(_MD("set_monitorable", "enable"), &Area2D::set_monitorable);
+ ObjectTypeDB::bind_method(_MD("is_monitorable"), &Area2D::is_monitorable);
- ObjectTypeDB::bind_method(_MD("_body_inout"),&Area2D::_body_inout);
- ObjectTypeDB::bind_method(_MD("_area_inout"),&Area2D::_area_inout);
+ ObjectTypeDB::bind_method(_MD("get_overlapping_bodies"), &Area2D::get_overlapping_bodies);
+ ObjectTypeDB::bind_method(_MD("get_overlapping_areas"), &Area2D::get_overlapping_areas);
+ ObjectTypeDB::bind_method(_MD("overlaps_body", "body"), &Area2D::overlaps_body);
+ ObjectTypeDB::bind_method(_MD("overlaps_area", "area"), &Area2D::overlaps_area);
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D")));
+ ObjectTypeDB::bind_method(_MD("_body_inout"), &Area2D::_body_inout);
+ ObjectTypeDB::bind_method(_MD("_area_inout"), &Area2D::_area_inout);
- ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
- ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
- ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
- ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
+ ADD_SIGNAL(MethodInfo("body_enter_shape", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
+ ADD_SIGNAL(MethodInfo("body_exit_shape", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
+ ADD_SIGNAL(MethodInfo("body_enter", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D")));
+ ADD_SIGNAL(MethodInfo("body_exit", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D")));
+ ADD_SIGNAL(MethodInfo("area_enter_shape", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
+ ADD_SIGNAL(MethodInfo("area_exit_shape", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
+ ADD_SIGNAL(MethodInfo("area_enter", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D")));
+ ADD_SIGNAL(MethodInfo("area_exit", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D")));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.001"),_SCS("set_gravity"),_SCS("get_gravity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,100,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
-
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine"), _SCS("set_space_override_mode"), _SCS("get_space_override_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "gravity_point"), _SCS("set_gravity_is_point"), _SCS("is_gravity_a_point"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "gravity_distance_scale", PROPERTY_HINT_RANGE, "0,1024,0.001"), _SCS("set_gravity_distance_scale"), _SCS("get_gravity_distance_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "gravity_vec"), _SCS("set_gravity_vector"), _SCS("get_gravity_vector"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity", PROPERTY_HINT_RANGE, "-1024,1024,0.001"), _SCS("set_gravity"), _SCS("get_gravity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_damp", PROPERTY_HINT_RANGE, "0,100,0.01"), _SCS("set_linear_damp"), _SCS("get_linear_damp"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "0,100,0.01"), _SCS("set_angular_damp"), _SCS("get_angular_damp"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,128,1"), _SCS("set_priority"), _SCS("get_priority"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "monitoring"), _SCS("set_enable_monitoring"), _SCS("is_monitoring_enabled"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "monitorable"), _SCS("set_monitorable"), _SCS("is_monitorable"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "collision/layers", PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "collision/mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_collision_mask"), _SCS("get_collision_mask"));
}
-Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_create(),true) {
+Area2D::Area2D()
+ : CollisionObject2D(Physics2DServer::get_singleton()->area_create(), true) {
- space_override=SPACE_OVERRIDE_DISABLED;
+ space_override = SPACE_OVERRIDE_DISABLED;
set_gravity(98);
- set_gravity_vector(Vector2(0,1));
- gravity_is_point=false;
- gravity_distance_scale=0;
- linear_damp=0.1;
- angular_damp=1;
- locked=false;
- priority=0;
- monitoring=false;
- monitorable=false;
- collision_mask=1;
- layer_mask=1;
+ set_gravity_vector(Vector2(0, 1));
+ gravity_is_point = false;
+ gravity_distance_scale = 0;
+ linear_damp = 0.1;
+ angular_damp = 1;
+ locked = false;
+ priority = 0;
+ monitoring = false;
+ monitorable = false;
+ collision_mask = 1;
+ layer_mask = 1;
monitoring_stored = true;
set_enable_monitoring(true);
set_monitorable(true);
}
Area2D::~Area2D() {
-
-
}
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index a886bd7d9..8e854d474 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -34,9 +34,9 @@
class Area2D : public CollisionObject2D {
- OBJ_TYPE( Area2D, CollisionObject2D );
-public:
+ OBJ_TYPE(Area2D, CollisionObject2D);
+public:
enum SpaceOverride {
SPACE_OVERRIDE_DISABLED,
SPACE_OVERRIDE_COMBINE,
@@ -44,9 +44,8 @@ public:
SPACE_OVERRIDE_REPLACE,
SPACE_OVERRIDE_REPLACE_COMBINE
};
-private:
-
+private:
SpaceOverride space_override;
Vector2 gravity_vec;
real_t gravity;
@@ -62,7 +61,7 @@ private:
bool monitorable;
bool locked;
- void _body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape);
+ void _body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape);
void _body_enter_tree(ObjectID p_id);
void _body_exit_tree(ObjectID p_id);
@@ -71,15 +70,18 @@ private:
int body_shape;
int area_shape;
- bool operator<(const ShapePair& p_sp) const {
- if (body_shape==p_sp.body_shape)
+ bool operator<(const ShapePair &p_sp) const {
+ if (body_shape == p_sp.body_shape)
return area_shape < p_sp.area_shape;
else
return body_shape < p_sp.body_shape;
}
ShapePair() {}
- ShapePair(int p_bs, int p_as) { body_shape=p_bs; area_shape=p_as; }
+ ShapePair(int p_bs, int p_as) {
+ body_shape = p_bs;
+ area_shape = p_as;
+ }
};
struct BodyState {
@@ -89,11 +91,9 @@ private:
VSet<ShapePair> shapes;
};
- Map<ObjectID,BodyState> body_map;
-
+ Map<ObjectID, BodyState> body_map;
-
- void _area_inout(int p_status,const RID& p_area, int p_instance, int p_area_shape,int p_self_shape);
+ void _area_inout(int p_status, const RID &p_area, int p_instance, int p_area_shape, int p_self_shape);
void _area_enter_tree(ObjectID p_id);
void _area_exit_tree(ObjectID p_id);
@@ -102,15 +102,18 @@ private:
int area_shape;
int self_shape;
- bool operator<(const AreaShapePair& p_sp) const {
- if (area_shape==p_sp.area_shape)
+ bool operator<(const AreaShapePair &p_sp) const {
+ if (area_shape == p_sp.area_shape)
return self_shape < p_sp.self_shape;
else
return area_shape < p_sp.area_shape;
}
AreaShapePair() {}
- AreaShapePair(int p_bs, int p_as) { area_shape=p_bs; self_shape=p_as; }
+ AreaShapePair(int p_bs, int p_as) {
+ area_shape = p_bs;
+ self_shape = p_as;
+ }
};
struct AreaState {
@@ -120,16 +123,14 @@ private:
VSet<AreaShapePair> shapes;
};
- Map<ObjectID,AreaState> area_map;
+ Map<ObjectID, AreaState> area_map;
void _clear_monitoring();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_space_override_mode(SpaceOverride p_mode);
SpaceOverride get_space_override_mode() const;
@@ -139,7 +140,7 @@ public:
void set_gravity_distance_scale(real_t p_scale);
real_t get_gravity_distance_scale() const;
- void set_gravity_vector(const Vector2& p_vec);
+ void set_gravity_vector(const Vector2 &p_vec);
Vector2 get_gravity_vector() const;
void set_gravity(real_t p_gravity);
@@ -175,8 +176,8 @@ public:
Array get_overlapping_bodies() const; //function for script
Array get_overlapping_areas() const; //function for script
- bool overlaps_area(Node* p_area) const;
- bool overlaps_body(Node* p_body) const;
+ bool overlaps_area(Node *p_area) const;
+ bool overlaps_body(Node *p_body) const;
Area2D();
~Area2D();
diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp
index bdc06aa67..eb95a56bf 100644
--- a/scene/2d/back_buffer_copy.cpp
+++ b/scene/2d/back_buffer_copy.cpp
@@ -30,22 +30,21 @@
void BackBufferCopy::_update_copy_mode() {
- switch(copy_mode) {
+ switch (copy_mode) {
case COPY_MODE_DISABLED: {
- VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(),false,Rect2());
+ VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), false, Rect2());
} break;
case COPY_MODE_RECT: {
- VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(),true,rect);
+ VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, rect);
} break;
case COPY_MODE_VIEWPORT: {
- VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(),true,Rect2());
+ VS::get_singleton()->canvas_item_set_copy_to_backbuffer(get_canvas_item(), true, Rect2());
} break;
-
}
}
@@ -54,50 +53,47 @@ Rect2 BackBufferCopy::get_item_rect() const {
return rect;
}
-void BackBufferCopy::set_rect(const Rect2& p_rect) {
+void BackBufferCopy::set_rect(const Rect2 &p_rect) {
- rect=p_rect;
+ rect = p_rect;
_update_copy_mode();
}
-Rect2 BackBufferCopy::get_rect() const{
+Rect2 BackBufferCopy::get_rect() const {
return rect;
}
-void BackBufferCopy::set_copy_mode(CopyMode p_mode){
+void BackBufferCopy::set_copy_mode(CopyMode p_mode) {
- copy_mode=p_mode;
+ copy_mode = p_mode;
_update_copy_mode();
}
-BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const{
+BackBufferCopy::CopyMode BackBufferCopy::get_copy_mode() const {
return copy_mode;
}
-
void BackBufferCopy::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_rect","rect"),&BackBufferCopy::set_rect);
- ObjectTypeDB::bind_method(_MD("get_rect"),&BackBufferCopy::get_rect);
+ ObjectTypeDB::bind_method(_MD("set_rect", "rect"), &BackBufferCopy::set_rect);
+ ObjectTypeDB::bind_method(_MD("get_rect"), &BackBufferCopy::get_rect);
- ObjectTypeDB::bind_method(_MD("set_copy_mode","copy_mode"),&BackBufferCopy::set_copy_mode);
- ObjectTypeDB::bind_method(_MD("get_copy_mode"),&BackBufferCopy::get_copy_mode);
+ ObjectTypeDB::bind_method(_MD("set_copy_mode", "copy_mode"), &BackBufferCopy::set_copy_mode);
+ ObjectTypeDB::bind_method(_MD("get_copy_mode"), &BackBufferCopy::get_copy_mode);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"copy_mode",PROPERTY_HINT_ENUM,"Disabled,Rect,Viewport"),_SCS("set_copy_mode"),_SCS("get_copy_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),_SCS("set_rect"),_SCS("get_rect"));
-
- BIND_CONSTANT( COPY_MODE_DISABLED );
- BIND_CONSTANT( COPY_MODE_RECT );
- BIND_CONSTANT( COPY_MODE_VIEWPORT );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "copy_mode", PROPERTY_HINT_ENUM, "Disabled,Rect,Viewport"), _SCS("set_copy_mode"), _SCS("get_copy_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::RECT2, "rect"), _SCS("set_rect"), _SCS("get_rect"));
+ BIND_CONSTANT(COPY_MODE_DISABLED);
+ BIND_CONSTANT(COPY_MODE_RECT);
+ BIND_CONSTANT(COPY_MODE_VIEWPORT);
}
-BackBufferCopy::BackBufferCopy(){
+BackBufferCopy::BackBufferCopy() {
- rect=Rect2(-100,-100,200,200);
- copy_mode=COPY_MODE_RECT;
+ rect = Rect2(-100, -100, 200, 200);
+ copy_mode = COPY_MODE_RECT;
_update_copy_mode();
}
-BackBufferCopy::~BackBufferCopy(){
-
+BackBufferCopy::~BackBufferCopy() {
}
diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h
index 4e49e3fbf..98a0db249 100644
--- a/scene/2d/back_buffer_copy.h
+++ b/scene/2d/back_buffer_copy.h
@@ -32,27 +32,26 @@
#include "scene/2d/node_2d.h"
class BackBufferCopy : public Node2D {
- OBJ_TYPE( BackBufferCopy,Node2D);
+ OBJ_TYPE(BackBufferCopy, Node2D);
+
public:
enum CopyMode {
COPY_MODE_DISABLED,
COPY_MODE_RECT,
COPY_MODE_VIEWPORT
};
-private:
+private:
Rect2 rect;
CopyMode copy_mode;
void _update_copy_mode();
protected:
-
static void _bind_methods();
public:
-
- void set_rect(const Rect2& p_rect);
+ void set_rect(const Rect2 &p_rect);
Rect2 get_rect() const;
void set_copy_mode(CopyMode p_mode);
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index a9de57dde..654f896c2 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -32,7 +32,6 @@
void Camera2D::_update_scroll() {
-
if (!is_inside_tree())
return;
@@ -43,16 +42,15 @@ void Camera2D::_update_scroll() {
if (current) {
- ERR_FAIL_COND( custom_viewport && !ObjectDB::get_instance(custom_viewport_id) );
+ ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));
Matrix32 xform = get_camera_transform();
if (viewport) {
- viewport->set_canvas_transform( xform );
+ viewport->set_canvas_transform(xform);
}
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform);
+ get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME, group_name, "_camera_moved", xform);
};
-
}
void Camera2D::set_zoom(const Vector2 &p_zoom) {
@@ -68,30 +66,27 @@ Vector2 Camera2D::get_zoom() const {
return zoom;
};
-
-Matrix32 Camera2D::get_camera_transform() {
+Matrix32 Camera2D::get_camera_transform() {
if (!get_tree())
return Matrix32();
Size2 screen_size = get_viewport_rect().size;
- screen_size=get_viewport_rect().size;
-
+ screen_size = get_viewport_rect().size;
Point2 new_camera_pos = get_global_transform().get_origin();
Point2 ret_camera_pos;
if (!first) {
-
- if (anchor_mode==ANCHOR_MODE_DRAG_CENTER) {
+ if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) {
if (h_drag_enabled && !get_tree()->is_editor_hint()) {
- camera_pos.x = MIN( camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT]));
- camera_pos.x = MAX( camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * drag_margin[MARGIN_LEFT]));
+ camera_pos.x = MIN(camera_pos.x, (new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT]));
+ camera_pos.x = MAX(camera_pos.x, (new_camera_pos.x - screen_size.x * 0.5 * drag_margin[MARGIN_LEFT]));
} else {
- if (h_ofs<0) {
+ if (h_ofs < 0) {
camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT] * h_ofs;
} else {
camera_pos.x = new_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_LEFT] * h_ofs;
@@ -100,95 +95,85 @@ Matrix32 Camera2D::get_camera_transform() {
if (v_drag_enabled && !get_tree()->is_editor_hint()) {
- camera_pos.y = MIN( camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM]));
- camera_pos.y = MAX( camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * drag_margin[MARGIN_TOP]));
+ camera_pos.y = MIN(camera_pos.y, (new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM]));
+ camera_pos.y = MAX(camera_pos.y, (new_camera_pos.y - screen_size.y * 0.5 * drag_margin[MARGIN_TOP]));
} else {
- if (v_ofs<0) {
+ if (v_ofs < 0) {
camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_TOP] * v_ofs;
} else {
camera_pos.y = new_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs;
}
}
- } else if (anchor_mode==ANCHOR_MODE_FIXED_TOP_LEFT){
+ } else if (anchor_mode == ANCHOR_MODE_FIXED_TOP_LEFT) {
- camera_pos=new_camera_pos;
+ camera_pos = new_camera_pos;
}
-
-
if (smoothing_enabled && !get_tree()->is_editor_hint()) {
- float c = smoothing*get_fixed_process_delta_time();
- smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos;
- ret_camera_pos=smoothed_camera_pos;
+ float c = smoothing * get_fixed_process_delta_time();
+ smoothed_camera_pos = ((camera_pos - smoothed_camera_pos) * c) + smoothed_camera_pos;
+ ret_camera_pos = smoothed_camera_pos;
// camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
} else {
- ret_camera_pos=smoothed_camera_pos=camera_pos;
-
+ ret_camera_pos = smoothed_camera_pos = camera_pos;
}
-
-
} else {
- ret_camera_pos=smoothed_camera_pos=camera_pos=new_camera_pos;
- first=false;
+ ret_camera_pos = smoothed_camera_pos = camera_pos = new_camera_pos;
+ first = false;
}
-
- Point2 screen_offset = (anchor_mode==ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom) : Point2());
+ Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5 * zoom) : Point2());
float angle = get_global_transform().get_rotation();
- if(rotating){
+ if (rotating) {
screen_offset = screen_offset.rotated(angle);
}
- Rect2 screen_rect(-screen_offset+ret_camera_pos,screen_size*zoom);
+ Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom);
if (screen_rect.pos.x + screen_rect.size.x > limit[MARGIN_RIGHT])
screen_rect.pos.x = limit[MARGIN_RIGHT] - screen_rect.size.x;
if (screen_rect.pos.y + screen_rect.size.y > limit[MARGIN_BOTTOM])
screen_rect.pos.y = limit[MARGIN_BOTTOM] - screen_rect.size.y;
-
if (screen_rect.pos.x < limit[MARGIN_LEFT])
- screen_rect.pos.x=limit[MARGIN_LEFT];
+ screen_rect.pos.x = limit[MARGIN_LEFT];
if (screen_rect.pos.y < limit[MARGIN_TOP])
- screen_rect.pos.y =limit[MARGIN_TOP];
+ screen_rect.pos.y = limit[MARGIN_TOP];
- if (offset!=Vector2()) {
+ if (offset != Vector2()) {
- screen_rect.pos+=offset;
+ screen_rect.pos += offset;
if (screen_rect.pos.x + screen_rect.size.x > limit[MARGIN_RIGHT])
screen_rect.pos.x = limit[MARGIN_RIGHT] - screen_rect.size.x;
if (screen_rect.pos.y + screen_rect.size.y > limit[MARGIN_BOTTOM])
screen_rect.pos.y = limit[MARGIN_BOTTOM] - screen_rect.size.y;
-
if (screen_rect.pos.x < limit[MARGIN_LEFT])
- screen_rect.pos.x=limit[MARGIN_LEFT];
+ screen_rect.pos.x = limit[MARGIN_LEFT];
if (screen_rect.pos.y < limit[MARGIN_TOP])
- screen_rect.pos.y =limit[MARGIN_TOP];
-
+ screen_rect.pos.y = limit[MARGIN_TOP];
}
- camera_screen_center=screen_rect.pos+screen_rect.size*0.5;
+ camera_screen_center = screen_rect.pos + screen_rect.size * 0.5;
Matrix32 xform;
- if(rotating){
+ if (rotating) {
xform.set_rotation(angle);
}
xform.scale_basis(zoom);
- xform.set_origin(screen_rect.pos/*.floor()*/);
+ xform.set_origin(screen_rect.pos /*.floor()*/);
-
-/*
+ /*
if (0) {
xform = get_global_transform() * xform;
@@ -198,15 +183,12 @@ Matrix32 Camera2D::get_camera_transform() {
}
*/
-
return (xform).affine_inverse();
}
-
-
void Camera2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_FIXED_PROCESS: {
@@ -215,48 +197,45 @@ void Camera2D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
if (!is_fixed_processing())
_update_scroll();
} break;
case NOTIFICATION_ENTER_TREE: {
-
if (custom_viewport && ObjectDB::get_instance(custom_viewport_id)) {
- viewport=custom_viewport;
+ viewport = custom_viewport;
} else {
- viewport=get_viewport();
+ viewport = get_viewport();
}
canvas = get_canvas();
RID vp = viewport->get_viewport();
- group_name = "__cameras_"+itos(vp.get_id());
- canvas_group_name ="__cameras_c"+itos(canvas.get_id());
+ group_name = "__cameras_" + itos(vp.get_id());
+ canvas_group_name = "__cameras_c" + itos(canvas.get_id());
add_to_group(group_name);
add_to_group(canvas_group_name);
- if(get_tree()->is_editor_hint()) {
+ if (get_tree()->is_editor_hint()) {
set_fixed_process(false);
}
_update_scroll();
- first=true;
-
+ first = true;
} break;
case NOTIFICATION_EXIT_TREE: {
if (is_current()) {
if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
- viewport->set_canvas_transform( Matrix32() );
+ viewport->set_canvas_transform(Matrix32());
}
}
remove_from_group(group_name);
remove_from_group(canvas_group_name);
- viewport=NULL;
+ viewport = NULL;
} break;
case NOTIFICATION_DRAW: {
@@ -266,44 +245,43 @@ void Camera2D::_notification(int p_what) {
Color area_axis_color(0.5, 0.42, 0.87, 0.63);
float area_axis_width = 1;
- if(current)
+ if (current)
area_axis_width = 3;
Matrix32 inv_camera_transform = get_camera_transform().affine_inverse();
Size2 screen_size = get_viewport_rect().size;
- Vector2 screen_endpoints[4]= {
+ Vector2 screen_endpoints[4] = {
inv_camera_transform.xform(Vector2(0, 0)),
- inv_camera_transform.xform(Vector2(screen_size.width,0)),
+ inv_camera_transform.xform(Vector2(screen_size.width, 0)),
inv_camera_transform.xform(Vector2(screen_size.width, screen_size.height)),
inv_camera_transform.xform(Vector2(0, screen_size.height))
};
Matrix32 inv_transform = get_global_transform().affine_inverse(); // undo global space
- for(int i=0;i<4;i++) {
- draw_line(inv_transform.xform(screen_endpoints[i]), inv_transform.xform(screen_endpoints[(i+1)%4]), area_axis_color, area_axis_width);
+ for (int i = 0; i < 4; i++) {
+ draw_line(inv_transform.xform(screen_endpoints[i]), inv_transform.xform(screen_endpoints[(i + 1) % 4]), area_axis_color, area_axis_width);
}
} break;
}
}
-void Camera2D::set_offset(const Vector2& p_offset) {
+void Camera2D::set_offset(const Vector2 &p_offset) {
- offset=p_offset;
+ offset = p_offset;
_update_scroll();
-
}
-Vector2 Camera2D::get_offset() const{
+Vector2 Camera2D::get_offset() const {
return offset;
}
-void Camera2D::set_anchor_mode(AnchorMode p_anchor_mode){
+void Camera2D::set_anchor_mode(AnchorMode p_anchor_mode) {
- anchor_mode=p_anchor_mode;
+ anchor_mode = p_anchor_mode;
_update_scroll();
}
@@ -312,9 +290,9 @@ Camera2D::AnchorMode Camera2D::get_anchor_mode() const {
return anchor_mode;
}
-void Camera2D::set_rotating(bool p_rotating){
+void Camera2D::set_rotating(bool p_rotating) {
- rotating=p_rotating;
+ rotating = p_rotating;
_update_scroll();
}
@@ -323,25 +301,23 @@ bool Camera2D::is_rotating() const {
return rotating;
}
-
void Camera2D::_make_current(Object *p_which) {
- if (p_which==this) {
+ if (p_which == this) {
- current=true;
+ current = true;
_update_scroll();
} else {
- current=false;
+ current = false;
}
}
-
void Camera2D::_set_current(bool p_current) {
if (p_current)
make_current();
- current=p_current;
+ current = p_current;
}
bool Camera2D::is_current() const {
@@ -352,58 +328,51 @@ bool Camera2D::is_current() const {
void Camera2D::make_current() {
if (!is_inside_tree()) {
- current=true;
+ current = true;
} else {
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this);
+ get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", this);
}
}
void Camera2D::clear_current() {
- current=false;
+ current = false;
if (is_inside_tree()) {
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL));
+ get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME, group_name, "_make_current", (Object *)(NULL));
}
-
}
+void Camera2D::set_limit(Margin p_margin, int p_limit) {
-void Camera2D::set_limit(Margin p_margin,int p_limit) {
-
- ERR_FAIL_INDEX(p_margin,4);
- limit[p_margin]=p_limit;
+ ERR_FAIL_INDEX(p_margin, 4);
+ limit[p_margin] = p_limit;
}
-int Camera2D::get_limit(Margin p_margin) const{
+int Camera2D::get_limit(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin,4,0);
+ ERR_FAIL_INDEX_V(p_margin, 4, 0);
return limit[p_margin];
-
}
-void Camera2D::set_drag_margin(Margin p_margin,float p_drag_margin) {
+void Camera2D::set_drag_margin(Margin p_margin, float p_drag_margin) {
- ERR_FAIL_INDEX(p_margin,4);
- drag_margin[p_margin]=p_drag_margin;
+ ERR_FAIL_INDEX(p_margin, 4);
+ drag_margin[p_margin] = p_drag_margin;
}
-float Camera2D::get_drag_margin(Margin p_margin) const{
+float Camera2D::get_drag_margin(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin,4,0);
+ ERR_FAIL_INDEX_V(p_margin, 4, 0);
return drag_margin[p_margin];
-
}
-
Vector2 Camera2D::get_camera_pos() const {
-
return camera_pos;
}
void Camera2D::force_update_scroll() {
-
_update_scroll();
}
@@ -416,22 +385,22 @@ void Camera2D::reset_smoothing() {
void Camera2D::align() {
Size2 screen_size = get_viewport_rect().size;
- screen_size=get_viewport_rect().size;
+ screen_size = get_viewport_rect().size;
Point2 current_camera_pos = get_global_transform().get_origin();
- if (anchor_mode==ANCHOR_MODE_DRAG_CENTER) {
- if (h_ofs<0) {
+ if (anchor_mode == ANCHOR_MODE_DRAG_CENTER) {
+ if (h_ofs < 0) {
camera_pos.x = current_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_RIGHT] * h_ofs;
} else {
camera_pos.x = current_camera_pos.x + screen_size.x * 0.5 * drag_margin[MARGIN_LEFT] * h_ofs;
}
- if (v_ofs<0) {
+ if (v_ofs < 0) {
camera_pos.y = current_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_TOP] * v_ofs;
} else {
camera_pos.y = current_camera_pos.y + screen_size.y * 0.5 * drag_margin[MARGIN_BOTTOM] * v_ofs;
}
- } else if (anchor_mode==ANCHOR_MODE_FIXED_TOP_LEFT){
+ } else if (anchor_mode == ANCHOR_MODE_FIXED_TOP_LEFT) {
- camera_pos=current_camera_pos;
+ camera_pos = current_camera_pos;
}
_update_scroll();
@@ -439,77 +408,73 @@ void Camera2D::align() {
void Camera2D::set_follow_smoothing(float p_speed) {
- smoothing=p_speed;
- if (smoothing>0 && !(is_inside_tree() && get_tree()->is_editor_hint()))
+ smoothing = p_speed;
+ if (smoothing > 0 && !(is_inside_tree() && get_tree()->is_editor_hint()))
set_fixed_process(true);
else
set_fixed_process(false);
}
-float Camera2D::get_follow_smoothing() const{
+float Camera2D::get_follow_smoothing() const {
return smoothing;
}
Point2 Camera2D::get_camera_screen_center() const {
- return camera_screen_center;
+ return camera_screen_center;
}
-
void Camera2D::set_h_drag_enabled(bool p_enabled) {
- h_drag_enabled=p_enabled;
+ h_drag_enabled = p_enabled;
}
-bool Camera2D::is_h_drag_enabled() const{
+bool Camera2D::is_h_drag_enabled() const {
- return h_drag_enabled;
+ return h_drag_enabled;
}
-void Camera2D::set_v_drag_enabled(bool p_enabled){
+void Camera2D::set_v_drag_enabled(bool p_enabled) {
- v_drag_enabled=p_enabled;
+ v_drag_enabled = p_enabled;
}
-bool Camera2D::is_v_drag_enabled() const{
+bool Camera2D::is_v_drag_enabled() const {
- return v_drag_enabled;
+ return v_drag_enabled;
}
void Camera2D::set_v_offset(float p_offset) {
- v_ofs=p_offset;
+ v_ofs = p_offset;
}
-float Camera2D::get_v_offset() const{
+float Camera2D::get_v_offset() const {
- return v_ofs;
+ return v_ofs;
}
-void Camera2D::set_h_offset(float p_offset){
+void Camera2D::set_h_offset(float p_offset) {
- h_ofs=p_offset;
+ h_ofs = p_offset;
}
-float Camera2D::get_h_offset() const{
+float Camera2D::get_h_offset() const {
- return h_ofs;
+ return h_ofs;
}
-
void Camera2D::_set_old_smoothing(float p_val) {
//compatibility
- if (p_val>0) {
- smoothing_enabled=true;
+ if (p_val > 0) {
+ smoothing_enabled = true;
set_follow_smoothing(p_val);
}
-
}
void Camera2D::set_enable_follow_smoothing(bool p_enabled) {
- smoothing_enabled=p_enabled;
-
+ smoothing_enabled = p_enabled;
}
bool Camera2D::is_follow_smoothing_enabled() const {
@@ -524,154 +489,146 @@ void Camera2D::set_custom_viewport(Node *p_viewport) {
remove_from_group(canvas_group_name);
}
- custom_viewport=p_viewport->cast_to<Viewport>();
+ custom_viewport = p_viewport->cast_to<Viewport>();
if (custom_viewport) {
- custom_viewport_id=custom_viewport->get_instance_ID();
+ custom_viewport_id = custom_viewport->get_instance_ID();
} else {
- custom_viewport_id=0;
+ custom_viewport_id = 0;
}
if (is_inside_tree()) {
if (custom_viewport)
- viewport=custom_viewport;
+ viewport = custom_viewport;
else
- viewport=get_viewport();
+ viewport = get_viewport();
RID vp = viewport->get_viewport();
- group_name = "__cameras_"+itos(vp.get_id());
- canvas_group_name ="__cameras_c"+itos(canvas.get_id());
+ group_name = "__cameras_" + itos(vp.get_id());
+ canvas_group_name = "__cameras_c" + itos(canvas.get_id());
add_to_group(group_name);
add_to_group(canvas_group_name);
}
-
}
-Node* Camera2D::get_custom_viewport() const {
+Node *Camera2D::get_custom_viewport() const {
return custom_viewport;
}
-
void Camera2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&Camera2D::get_offset);
-
- ObjectTypeDB::bind_method(_MD("set_anchor_mode","anchor_mode"),&Camera2D::set_anchor_mode);
- ObjectTypeDB::bind_method(_MD("get_anchor_mode"),&Camera2D::get_anchor_mode);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &Camera2D::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &Camera2D::get_offset);
- ObjectTypeDB::bind_method(_MD("set_rotating","rotating"),&Camera2D::set_rotating);
- ObjectTypeDB::bind_method(_MD("is_rotating"),&Camera2D::is_rotating);
+ ObjectTypeDB::bind_method(_MD("set_anchor_mode", "anchor_mode"), &Camera2D::set_anchor_mode);
+ ObjectTypeDB::bind_method(_MD("get_anchor_mode"), &Camera2D::get_anchor_mode);
- ObjectTypeDB::bind_method(_MD("make_current"),&Camera2D::make_current);
- ObjectTypeDB::bind_method(_MD("clear_current"),&Camera2D::clear_current);
- ObjectTypeDB::bind_method(_MD("_make_current"),&Camera2D::_make_current);
+ ObjectTypeDB::bind_method(_MD("set_rotating", "rotating"), &Camera2D::set_rotating);
+ ObjectTypeDB::bind_method(_MD("is_rotating"), &Camera2D::is_rotating);
- ObjectTypeDB::bind_method(_MD("_update_scroll"),&Camera2D::_update_scroll);
+ ObjectTypeDB::bind_method(_MD("make_current"), &Camera2D::make_current);
+ ObjectTypeDB::bind_method(_MD("clear_current"), &Camera2D::clear_current);
+ ObjectTypeDB::bind_method(_MD("_make_current"), &Camera2D::_make_current);
+ ObjectTypeDB::bind_method(_MD("_update_scroll"), &Camera2D::_update_scroll);
- ObjectTypeDB::bind_method(_MD("_set_current","current"),&Camera2D::_set_current);
- ObjectTypeDB::bind_method(_MD("is_current"),&Camera2D::is_current);
+ ObjectTypeDB::bind_method(_MD("_set_current", "current"), &Camera2D::_set_current);
+ ObjectTypeDB::bind_method(_MD("is_current"), &Camera2D::is_current);
- ObjectTypeDB::bind_method(_MD("set_limit","margin","limit"),&Camera2D::set_limit);
- ObjectTypeDB::bind_method(_MD("get_limit","margin"),&Camera2D::get_limit);
+ ObjectTypeDB::bind_method(_MD("set_limit", "margin", "limit"), &Camera2D::set_limit);
+ ObjectTypeDB::bind_method(_MD("get_limit", "margin"), &Camera2D::get_limit);
- ObjectTypeDB::bind_method(_MD("set_v_drag_enabled","enabled"),&Camera2D::set_v_drag_enabled);
- ObjectTypeDB::bind_method(_MD("is_v_drag_enabled"),&Camera2D::is_v_drag_enabled);
+ ObjectTypeDB::bind_method(_MD("set_v_drag_enabled", "enabled"), &Camera2D::set_v_drag_enabled);
+ ObjectTypeDB::bind_method(_MD("is_v_drag_enabled"), &Camera2D::is_v_drag_enabled);
- ObjectTypeDB::bind_method(_MD("set_h_drag_enabled","enabled"),&Camera2D::set_h_drag_enabled);
- ObjectTypeDB::bind_method(_MD("is_h_drag_enabled"),&Camera2D::is_h_drag_enabled);
+ ObjectTypeDB::bind_method(_MD("set_h_drag_enabled", "enabled"), &Camera2D::set_h_drag_enabled);
+ ObjectTypeDB::bind_method(_MD("is_h_drag_enabled"), &Camera2D::is_h_drag_enabled);
- ObjectTypeDB::bind_method(_MD("set_v_offset","ofs"),&Camera2D::set_v_offset);
- ObjectTypeDB::bind_method(_MD("get_v_offset"),&Camera2D::get_v_offset);
+ ObjectTypeDB::bind_method(_MD("set_v_offset", "ofs"), &Camera2D::set_v_offset);
+ ObjectTypeDB::bind_method(_MD("get_v_offset"), &Camera2D::get_v_offset);
- ObjectTypeDB::bind_method(_MD("set_h_offset","ofs"),&Camera2D::set_h_offset);
- ObjectTypeDB::bind_method(_MD("get_h_offset"),&Camera2D::get_h_offset);
+ ObjectTypeDB::bind_method(_MD("set_h_offset", "ofs"), &Camera2D::set_h_offset);
+ ObjectTypeDB::bind_method(_MD("get_h_offset"), &Camera2D::get_h_offset);
- ObjectTypeDB::bind_method(_MD("set_drag_margin","margin","drag_margin"),&Camera2D::set_drag_margin);
- ObjectTypeDB::bind_method(_MD("get_drag_margin","margin"),&Camera2D::get_drag_margin);
+ ObjectTypeDB::bind_method(_MD("set_drag_margin", "margin", "drag_margin"), &Camera2D::set_drag_margin);
+ ObjectTypeDB::bind_method(_MD("get_drag_margin", "margin"), &Camera2D::get_drag_margin);
- ObjectTypeDB::bind_method(_MD("get_camera_pos"),&Camera2D::get_camera_pos);
- ObjectTypeDB::bind_method(_MD("get_camera_screen_center"),&Camera2D::get_camera_screen_center);
+ ObjectTypeDB::bind_method(_MD("get_camera_pos"), &Camera2D::get_camera_pos);
+ ObjectTypeDB::bind_method(_MD("get_camera_screen_center"), &Camera2D::get_camera_screen_center);
- ObjectTypeDB::bind_method(_MD("set_zoom","zoom"),&Camera2D::set_zoom);
- ObjectTypeDB::bind_method(_MD("get_zoom"),&Camera2D::get_zoom);
+ ObjectTypeDB::bind_method(_MD("set_zoom", "zoom"), &Camera2D::set_zoom);
+ ObjectTypeDB::bind_method(_MD("get_zoom"), &Camera2D::get_zoom);
- ObjectTypeDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&Camera2D::set_custom_viewport);
- ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"),&Camera2D::get_custom_viewport);
+ ObjectTypeDB::bind_method(_MD("set_custom_viewport", "viewport:Viewport"), &Camera2D::set_custom_viewport);
+ ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"), &Camera2D::get_custom_viewport);
- ObjectTypeDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing);
- ObjectTypeDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing);
+ ObjectTypeDB::bind_method(_MD("set_follow_smoothing", "follow_smoothing"), &Camera2D::set_follow_smoothing);
+ ObjectTypeDB::bind_method(_MD("get_follow_smoothing"), &Camera2D::get_follow_smoothing);
- ObjectTypeDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing);
- ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled);
+ ObjectTypeDB::bind_method(_MD("set_enable_follow_smoothing", "follow_smoothing"), &Camera2D::set_enable_follow_smoothing);
+ ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"), &Camera2D::is_follow_smoothing_enabled);
- ObjectTypeDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll);
- ObjectTypeDB::bind_method(_MD("reset_smoothing"),&Camera2D::reset_smoothing);
- ObjectTypeDB::bind_method(_MD("align"),&Camera2D::align);
+ ObjectTypeDB::bind_method(_MD("force_update_scroll"), &Camera2D::force_update_scroll);
+ ObjectTypeDB::bind_method(_MD("reset_smoothing"), &Camera2D::reset_smoothing);
+ ObjectTypeDB::bind_method(_MD("align"), &Camera2D::align);
- ObjectTypeDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing);
+ ObjectTypeDB::bind_method(_MD("_set_old_smoothing", "follow_smoothing"), &Camera2D::_set_old_smoothing);
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),_SCS("set_anchor_mode"),_SCS("get_anchor_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"rotating"),_SCS("set_rotating"),_SCS("is_rotating"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_mode", PROPERTY_HINT_ENUM, "Fixed TopLeft,Drag Center"), _SCS("set_anchor_mode"), _SCS("get_anchor_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rotating"), _SCS("set_rotating"), _SCS("is_rotating"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "current"), _SCS("_set_current"), _SCS("is_current"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "zoom"), _SCS("set_zoom"), _SCS("get_zoom"));
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/top"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/right"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_RIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/bottom"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_BOTTOM);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit/left"), _SCS("set_limit"), _SCS("get_limit"), MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit/top"), _SCS("set_limit"), _SCS("get_limit"), MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit/right"), _SCS("set_limit"), _SCS("get_limit"), MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "limit/bottom"), _SCS("set_limit"), _SCS("get_limit"), MARGIN_BOTTOM);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_margin/h_enabled"), _SCS("set_h_drag_enabled"), _SCS("is_h_drag_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_margin/v_enabled"), _SCS("set_v_drag_enabled"), _SCS("is_v_drag_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing/enable"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing/speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smoothing/enable"), _SCS("set_enable_follow_smoothing"), _SCS("is_follow_smoothing_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "smoothing/speed"), _SCS("set_follow_smoothing"), _SCS("get_follow_smoothing"));
//compatibility
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing",PROPERTY_HINT_NONE,"",0),_SCS("_set_old_smoothing"),_SCS("get_follow_smoothing") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "smoothing", PROPERTY_HINT_NONE, "", 0), _SCS("_set_old_smoothing"), _SCS("get_follow_smoothing"));
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/bottom",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_BOTTOM);
-
-
- BIND_CONSTANT( ANCHOR_MODE_DRAG_CENTER );
- BIND_CONSTANT( ANCHOR_MODE_FIXED_TOP_LEFT );
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "drag_margin/left", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_drag_margin"), _SCS("get_drag_margin"), MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "drag_margin/top", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_drag_margin"), _SCS("get_drag_margin"), MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "drag_margin/right", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_drag_margin"), _SCS("get_drag_margin"), MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "drag_margin/bottom", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_drag_margin"), _SCS("get_drag_margin"), MARGIN_BOTTOM);
+ BIND_CONSTANT(ANCHOR_MODE_DRAG_CENTER);
+ BIND_CONSTANT(ANCHOR_MODE_FIXED_TOP_LEFT);
}
Camera2D::Camera2D() {
+ anchor_mode = ANCHOR_MODE_DRAG_CENTER;
+ rotating = false;
+ current = false;
+ limit[MARGIN_LEFT] = -10000000;
+ limit[MARGIN_TOP] = -10000000;
+ limit[MARGIN_RIGHT] = 10000000;
+ limit[MARGIN_BOTTOM] = 10000000;
+ drag_margin[MARGIN_LEFT] = 0.2;
+ drag_margin[MARGIN_TOP] = 0.2;
+ drag_margin[MARGIN_RIGHT] = 0.2;
+ drag_margin[MARGIN_BOTTOM] = 0.2;
+ camera_pos = Vector2();
+ first = true;
+ smoothing_enabled = false;
+ custom_viewport = NULL;
+ custom_viewport_id = 0;
-
- anchor_mode=ANCHOR_MODE_DRAG_CENTER;
- rotating=false;
- current=false;
- limit[MARGIN_LEFT]=-10000000;
- limit[MARGIN_TOP]=-10000000;
- limit[MARGIN_RIGHT]=10000000;
- limit[MARGIN_BOTTOM]=10000000;
- drag_margin[MARGIN_LEFT]=0.2;
- drag_margin[MARGIN_TOP]=0.2;
- drag_margin[MARGIN_RIGHT]=0.2;
- drag_margin[MARGIN_BOTTOM]=0.2;
- camera_pos=Vector2();
- first=true;
- smoothing_enabled=false;
- custom_viewport=NULL;
- custom_viewport_id=0;
-
- smoothing=5.0;
+ smoothing = 5.0;
zoom = Vector2(1, 1);
- h_drag_enabled=true;
- v_drag_enabled=true;
- h_ofs=0;
- v_ofs=0;
-
+ h_drag_enabled = true;
+ v_drag_enabled = true;
+ h_ofs = 0;
+ v_ofs = 0;
}
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index a32a061e7..988ee1b10 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -32,12 +32,11 @@
#include "scene/2d/node_2d.h"
#include "scene/main/viewport.h"
-
class Camera2D : public Node2D {
- OBJ_TYPE( Camera2D, Node2D );
-public:
+ OBJ_TYPE(Camera2D, Node2D);
+public:
enum AnchorMode {
ANCHOR_MODE_FIXED_TOP_LEFT,
ANCHOR_MODE_DRAG_CENTER
@@ -70,7 +69,6 @@ protected:
float h_ofs;
float v_ofs;
-
Point2 camera_screen_center;
void _update_scroll();
@@ -78,14 +76,14 @@ protected:
void _set_current(bool p_current);
void _set_old_smoothing(float p_enable);
-protected:
+protected:
virtual Matrix32 get_camera_transform();
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_offset(const Vector2& p_offset);
+public:
+ void set_offset(const Vector2 &p_offset);
Vector2 get_offset() const;
void set_anchor_mode(AnchorMode p_anchor_mode);
@@ -94,17 +92,16 @@ public:
void set_rotating(bool p_rotating);
bool is_rotating() const;
- void set_limit(Margin p_margin,int p_limit);
+ void set_limit(Margin p_margin, int p_limit);
int get_limit(Margin p_margin) const;
-
void set_h_drag_enabled(bool p_enabled);
bool is_h_drag_enabled() const;
void set_v_drag_enabled(bool p_enabled);
bool is_v_drag_enabled() const;
- void set_drag_margin(Margin p_margin,float p_drag_margin);
+ void set_drag_margin(Margin p_margin, float p_drag_margin);
float get_drag_margin(Margin p_margin) const;
void set_v_offset(float p_offset);
@@ -123,13 +120,13 @@ public:
void clear_current();
bool is_current() const;
- void set_zoom(const Vector2& p_zoom);
+ void set_zoom(const Vector2 &p_zoom);
Vector2 get_zoom() const;
Point2 get_camera_screen_center() const;
void set_custom_viewport(Node *p_viewport);
- Node* get_custom_viewport() const;
+ Node *get_custom_viewport() const;
Vector2 get_camera_pos() const;
void force_update_scroll();
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 1c9db72b5..ba7fba480 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -27,38 +27,37 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "canvas_item.h"
-#include "servers/visual_server.h"
-#include "scene/main/viewport.h"
-#include "scene/main/canvas_layer.h"
#include "message_queue.h"
-#include "scene/scene_string_names.h"
+#include "os/input.h"
+#include "scene/main/canvas_layer.h"
+#include "scene/main/viewport.h"
#include "scene/resources/font.h"
-#include "scene/resources/texture.h"
#include "scene/resources/style_box.h"
-#include "os/input.h"
+#include "scene/resources/texture.h"
+#include "scene/scene_string_names.h"
+#include "servers/visual_server.h"
-bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value) {
+bool CanvasItemMaterial::_set(const StringName &p_name, const Variant &p_value) {
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
+ if (p_name == SceneStringNames::get_singleton()->shader_shader) {
set_shader(p_value);
return true;
- } else if (p_name==SceneStringNames::get_singleton()->shading_mode) {
+ } else if (p_name == SceneStringNames::get_singleton()->shading_mode) {
set_shading_mode(ShadingMode(p_value.operator int()));
return true;
} else {
if (shader.is_valid()) {
-
StringName pr = shader->remap_param(p_name);
if (!pr) {
String n = p_name;
- if (n.find("param/")==0) { //backwards compatibility
- pr = n.substr(6,n.length());
+ if (n.find("param/") == 0) { //backwards compatibility
+ pr = n.substr(6, n.length());
}
}
if (pr) {
- VisualServer::get_singleton()->canvas_item_material_set_shader_param(material,pr,p_value);
+ VisualServer::get_singleton()->canvas_item_material_set_shader_param(material, pr, p_value);
return true;
}
}
@@ -67,17 +66,15 @@ bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value)
return false;
}
-bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const {
-
+bool CanvasItemMaterial::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
+ if (p_name == SceneStringNames::get_singleton()->shader_shader) {
- r_ret=get_shader();
+ r_ret = get_shader();
return true;
- } else if (p_name==SceneStringNames::get_singleton()->shading_mode) {
-
+ } else if (p_name == SceneStringNames::get_singleton()->shading_mode) {
- r_ret=shading_mode;
+ r_ret = shading_mode;
return true;
} else {
@@ -85,58 +82,54 @@ bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const {
StringName pr = shader->remap_param(p_name);
if (pr) {
- r_ret=VisualServer::get_singleton()->canvas_item_material_get_shader_param(material,pr);
+ r_ret = VisualServer::get_singleton()->canvas_item_material_get_shader_param(material, pr);
return true;
}
}
-
}
-
return false;
}
+void CanvasItemMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
-void CanvasItemMaterial::_get_property_list( List<PropertyInfo> *p_list) const {
-
- p_list->push_back( PropertyInfo( Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemShader,CanvasItemShaderGraph" ) );
- p_list->push_back( PropertyInfo( Variant::INT, "shader/shading_mode",PROPERTY_HINT_ENUM,"Normal,Unshaded,Light Only") );
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph"));
+ p_list->push_back(PropertyInfo(Variant::INT, "shader/shading_mode", PROPERTY_HINT_ENUM, "Normal,Unshaded,Light Only"));
if (!shader.is_null()) {
shader->get_param_list(p_list);
}
-
}
-void CanvasItemMaterial::set_shader(const Ref<Shader>& p_shader) {
+void CanvasItemMaterial::set_shader(const Ref<Shader> &p_shader) {
- ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_CANVAS_ITEM);
+ ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode() != Shader::MODE_CANVAS_ITEM);
- shader=p_shader;
+ shader = p_shader;
RID rid;
if (shader.is_valid())
- rid=shader->get_rid();
+ rid = shader->get_rid();
- VS::get_singleton()->canvas_item_material_set_shader(material,rid);
+ VS::get_singleton()->canvas_item_material_set_shader(material, rid);
_change_notify(); //properties for shader exposed
emit_changed();
}
-Ref<Shader> CanvasItemMaterial::get_shader() const{
+Ref<Shader> CanvasItemMaterial::get_shader() const {
return shader;
}
-void CanvasItemMaterial::set_shader_param(const StringName& p_param,const Variant& p_value){
+void CanvasItemMaterial::set_shader_param(const StringName &p_param, const Variant &p_value) {
- VS::get_singleton()->canvas_item_material_set_shader_param(material,p_param,p_value);
+ VS::get_singleton()->canvas_item_material_set_shader_param(material, p_param, p_value);
}
-Variant CanvasItemMaterial::get_shader_param(const StringName& p_param) const{
+Variant CanvasItemMaterial::get_shader_param(const StringName &p_param) const {
- return VS::get_singleton()->canvas_item_material_get_shader_param(material,p_param);
+ return VS::get_singleton()->canvas_item_material_get_shader_param(material, p_param);
}
RID CanvasItemMaterial::get_rid() const {
@@ -146,83 +139,70 @@ RID CanvasItemMaterial::get_rid() const {
void CanvasItemMaterial::set_shading_mode(ShadingMode p_mode) {
- shading_mode=p_mode;
- VS::get_singleton()->canvas_item_material_set_shading_mode(material,VS::CanvasItemShadingMode(p_mode));
+ shading_mode = p_mode;
+ VS::get_singleton()->canvas_item_material_set_shading_mode(material, VS::CanvasItemShadingMode(p_mode));
}
CanvasItemMaterial::ShadingMode CanvasItemMaterial::get_shading_mode() const {
return shading_mode;
}
-
void CanvasItemMaterial::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shader","shader:Shader"),&CanvasItemMaterial::set_shader);
- ObjectTypeDB::bind_method(_MD("get_shader:Shader"),&CanvasItemMaterial::get_shader);
- ObjectTypeDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItemMaterial::set_shader_param);
- ObjectTypeDB::bind_method(_MD("get_shader_param","param"),&CanvasItemMaterial::get_shader_param);
- ObjectTypeDB::bind_method(_MD("set_shading_mode","mode"),&CanvasItemMaterial::set_shading_mode);
- ObjectTypeDB::bind_method(_MD("get_shading_mode"),&CanvasItemMaterial::get_shading_mode);
-
- BIND_CONSTANT( SHADING_NORMAL );
- BIND_CONSTANT( SHADING_UNSHADED );
- BIND_CONSTANT( SHADING_ONLY_LIGHT );
-
+ ObjectTypeDB::bind_method(_MD("set_shader", "shader:Shader"), &CanvasItemMaterial::set_shader);
+ ObjectTypeDB::bind_method(_MD("get_shader:Shader"), &CanvasItemMaterial::get_shader);
+ ObjectTypeDB::bind_method(_MD("set_shader_param", "param", "value"), &CanvasItemMaterial::set_shader_param);
+ ObjectTypeDB::bind_method(_MD("get_shader_param", "param"), &CanvasItemMaterial::get_shader_param);
+ ObjectTypeDB::bind_method(_MD("set_shading_mode", "mode"), &CanvasItemMaterial::set_shading_mode);
+ ObjectTypeDB::bind_method(_MD("get_shading_mode"), &CanvasItemMaterial::get_shading_mode);
+ BIND_CONSTANT(SHADING_NORMAL);
+ BIND_CONSTANT(SHADING_UNSHADED);
+ BIND_CONSTANT(SHADING_ONLY_LIGHT);
}
-void CanvasItemMaterial::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
+void CanvasItemMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
String f = p_function.operator String();
- if ((f=="get_shader_param" || f=="set_shader_param") && p_idx==0) {
+ if ((f == "get_shader_param" || f == "set_shader_param") && p_idx == 0) {
if (shader.is_valid()) {
List<PropertyInfo> pl;
shader->get_param_list(&pl);
- for (List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {
- r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\"");
+ for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) {
+ r_options->push_back("\"" + E->get().name.replace_first("shader_param/", "") + "\"");
}
}
}
- Resource::get_argument_options(p_function,p_idx,r_options);
+ Resource::get_argument_options(p_function, p_idx, r_options);
}
CanvasItemMaterial::CanvasItemMaterial() {
- material=VS::get_singleton()->canvas_item_material_create();
- shading_mode=SHADING_NORMAL;
+ material = VS::get_singleton()->canvas_item_material_create();
+ shading_mode = SHADING_NORMAL;
}
-CanvasItemMaterial::~CanvasItemMaterial(){
+CanvasItemMaterial::~CanvasItemMaterial() {
VS::get_singleton()->free(material);
}
-
-
-
-
-
-
-
///////////////////////////////////////////////////////////////////
-
-
bool CanvasItem::is_visible() const {
if (!is_inside_tree())
return false;
- const CanvasItem *p=this;
+ const CanvasItem *p = this;
- while(p) {
+ while (p) {
if (p->hidden)
return false;
- p=p->get_parent_item();
+ p = p->get_parent_item();
}
-
return true;
}
@@ -244,16 +224,15 @@ void CanvasItem::_propagate_visibility_changed(bool p_visible) {
emit_signal(SceneStringNames::get_singleton()->hide);
_block();
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
+ CanvasItem *c = get_child(i)->cast_to<CanvasItem>();
if (c && !c->hidden) //should the toplevels stop propagation? i think so but..
c->_propagate_visibility_changed(p_visible);
}
_unblock();
-
}
void CanvasItem::show() {
@@ -261,8 +240,8 @@ void CanvasItem::show() {
if (!hidden)
return;
- hidden=false;
- VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,true);
+ hidden = false;
+ VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, true);
if (!is_inside_tree())
return;
@@ -271,14 +250,13 @@ void CanvasItem::show() {
_change_notify("visibility/visible");
}
-
void CanvasItem::hide() {
if (hidden)
return;
- hidden=true;
- VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false);
+ hidden = true;
+ VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, false);
if (!is_inside_tree())
return;
@@ -296,38 +274,30 @@ void CanvasItem::set_hidden(bool p_hidden) {
_set_visible_(!p_hidden);
}
-
Variant CanvasItem::edit_get_state() const {
-
return Variant();
}
-void CanvasItem::edit_set_state(const Variant& p_state) {
-
-
+void CanvasItem::edit_set_state(const Variant &p_state) {
}
-void CanvasItem::edit_set_rect(const Rect2& p_edit_rect) {
+void CanvasItem::edit_set_rect(const Rect2 &p_edit_rect) {
//used by editors, implement at will
}
void CanvasItem::edit_rotate(float p_rot) {
-
-
}
Size2 CanvasItem::edit_get_minimum_size() const {
- return Size2(-1,-1); //no limit
+ return Size2(-1, -1); //no limit
}
void CanvasItem::_update_callback() {
-
-
if (!is_inside_tree()) {
- pending_update=false;
+ pending_update = false;
return;
}
@@ -336,33 +306,32 @@ void CanvasItem::_update_callback() {
if (is_visible()) { //todo optimize this!!
if (first_draw) {
notification(NOTIFICATION_VISIBILITY_CHANGED);
- first_draw=false;
+ first_draw = false;
}
- drawing=true;
+ drawing = true;
notification(NOTIFICATION_DRAW);
emit_signal(SceneStringNames::get_singleton()->draw);
if (get_script_instance()) {
Variant::CallError err;
- get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_draw,NULL,0);
+ get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_draw, NULL, 0);
}
- drawing=false;
-
+ drawing = false;
}
//todo updating = false
- pending_update=false; // don't change to false until finished drawing (avoid recursive update)
+ pending_update = false; // don't change to false until finished drawing (avoid recursive update)
}
Matrix32 CanvasItem::get_global_transform_with_canvas() const {
const CanvasItem *ci = this;
Matrix32 xform;
- const CanvasItem *last_valid=NULL;
+ const CanvasItem *last_valid = NULL;
- while(ci) {
+ while (ci) {
- last_valid=ci;
+ last_valid = ci;
xform = ci->get_transform() * xform;
- ci=ci->get_parent_item();
+ ci = ci->get_parent_item();
}
if (last_valid->canvas_layer)
@@ -373,7 +342,6 @@ Matrix32 CanvasItem::get_global_transform_with_canvas() const {
Matrix32 CanvasItem::get_global_transform() const {
-
if (global_invalid) {
const CanvasItem *pi = get_parent_item();
@@ -382,37 +350,35 @@ Matrix32 CanvasItem::get_global_transform() const {
else
global_transform = get_transform();
- global_invalid=false;
+ global_invalid = false;
}
return global_transform;
-
}
-
void CanvasItem::_queue_sort_children() {
if (pending_children_sort)
return;
- pending_children_sort=true;
- MessageQueue::get_singleton()->push_call(this,"_sort_children");
+ pending_children_sort = true;
+ MessageQueue::get_singleton()->push_call(this, "_sort_children");
}
void CanvasItem::_sort_children() {
- pending_children_sort=false;
+ pending_children_sort = false;
if (!is_inside_tree())
return;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Node *n = get_child(i);
- CanvasItem *ci=n->cast_to<CanvasItem>();
+ CanvasItem *ci = n->cast_to<CanvasItem>();
if (ci) {
- if (ci->toplevel || ci->group!="")
+ if (ci->toplevel || ci->group != "")
continue;
VisualServer::get_singleton()->canvas_item_raise(n->cast_to<CanvasItem>()->canvas_item);
}
@@ -427,74 +393,69 @@ void CanvasItem::_raise_self() {
VisualServer::get_singleton()->canvas_item_raise(canvas_item);
}
-
void CanvasItem::_enter_canvas() {
if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) {
Node *n = this;
- canvas_layer=NULL;
+ canvas_layer = NULL;
- while(n) {
+ while (n) {
canvas_layer = n->cast_to<CanvasLayer>();
if (canvas_layer) {
break;
}
- n=n->get_parent();
+ n = n->get_parent();
}
RID canvas;
if (canvas_layer)
- canvas=canvas_layer->get_world_2d()->get_canvas();
+ canvas = canvas_layer->get_world_2d()->get_canvas();
else
- canvas=get_viewport()->find_world_2d()->get_canvas();
+ canvas = get_viewport()->find_world_2d()->get_canvas();
- VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,canvas);
+ VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, canvas);
- group = "root_canvas"+itos(canvas.get_id());
+ group = "root_canvas" + itos(canvas.get_id());
add_to_group(group);
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
+ get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE, group, "_raise_self");
} else {
CanvasItem *parent = get_parent_item();
- canvas_layer=parent->canvas_layer;
- VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item());
+ canvas_layer = parent->canvas_layer;
+ VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, parent->get_canvas_item());
parent->_queue_sort_children();
}
- pending_update=false;
+ pending_update = false;
update();
notification(NOTIFICATION_ENTER_CANVAS);
-
}
void CanvasItem::_exit_canvas() {
- notification(NOTIFICATION_EXIT_CANVAS,true); //reverse the notification
- VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,RID());
- canvas_layer=NULL;
- group="";
-
+ notification(NOTIFICATION_EXIT_CANVAS, true); //reverse the notification
+ VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, RID());
+ canvas_layer = NULL;
+ group = "";
}
-
void CanvasItem::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- first_draw=true;
- pending_children_sort=false;
+ first_draw = true;
+ pending_children_sort = false;
if (get_parent()) {
CanvasItem *ci = get_parent()->cast_to<CanvasItem>();
if (ci)
- C=ci->children_items.push_back(this);
+ C = ci->children_items.push_back(this);
}
_enter_canvas();
if (!block_transform_notify && !xform_change.in_list()) {
@@ -503,16 +464,14 @@ void CanvasItem::_notification(int p_what) {
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
-
- if (group!="") {
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
+ if (group != "") {
+ get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE, group, "_raise_self");
} else {
CanvasItem *p = get_parent_item();
ERR_FAIL_COND(!p);
p->_queue_sort_children();
}
-
} break;
case NOTIFICATION_EXIT_TREE: {
if (xform_change.in_list())
@@ -520,22 +479,20 @@ void CanvasItem::_notification(int p_what) {
_exit_canvas();
if (C) {
get_parent()->cast_to<CanvasItem>()->children_items.erase(C);
- C=NULL;
+ C = NULL;
}
- global_invalid=true;
+ global_invalid = true;
} break;
case NOTIFICATION_DRAW: {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
} break;
-
}
}
@@ -551,7 +508,6 @@ bool CanvasItem::_is_visible_() const {
return !is_hidden();
}
-
void CanvasItem::update() {
if (!is_inside_tree())
@@ -559,35 +515,33 @@ void CanvasItem::update() {
if (pending_update)
return;
- pending_update=true;
+ pending_update = true;
- MessageQueue::get_singleton()->push_call(this,"_update_callback");
+ MessageQueue::get_singleton()->push_call(this, "_update_callback");
}
void CanvasItem::set_opacity(float p_opacity) {
- opacity=p_opacity;
- VisualServer::get_singleton()->canvas_item_set_opacity(canvas_item,opacity);
-
+ opacity = p_opacity;
+ VisualServer::get_singleton()->canvas_item_set_opacity(canvas_item, opacity);
}
float CanvasItem::get_opacity() const {
return opacity;
}
-
void CanvasItem::set_as_toplevel(bool p_toplevel) {
- if (toplevel==p_toplevel)
+ if (toplevel == p_toplevel)
return;
if (!is_inside_tree()) {
- toplevel=p_toplevel;
+ toplevel = p_toplevel;
return;
}
_exit_canvas();
- toplevel=p_toplevel;
+ toplevel = p_toplevel;
_enter_canvas();
}
@@ -608,12 +562,10 @@ CanvasItem *CanvasItem::get_parent_item() const {
return parent->cast_to<CanvasItem>();
}
-
void CanvasItem::set_self_opacity(float p_self_opacity) {
- self_opacity=p_self_opacity;
- VisualServer::get_singleton()->canvas_item_set_self_opacity(canvas_item,self_opacity);
-
+ self_opacity = p_self_opacity;
+ VisualServer::get_singleton()->canvas_item_set_self_opacity(canvas_item, self_opacity);
}
float CanvasItem::get_self_opacity() const {
@@ -622,10 +574,9 @@ float CanvasItem::get_self_opacity() const {
void CanvasItem::set_blend_mode(BlendMode p_blend_mode) {
- ERR_FAIL_INDEX(p_blend_mode,5);
- blend_mode=p_blend_mode;
- VisualServer::get_singleton()->canvas_item_set_blend_mode(canvas_item,VS::MaterialBlendMode(blend_mode));
-
+ ERR_FAIL_INDEX(p_blend_mode, 5);
+ blend_mode = p_blend_mode;
+ VisualServer::get_singleton()->canvas_item_set_blend_mode(canvas_item, VS::MaterialBlendMode(blend_mode));
}
CanvasItem::BlendMode CanvasItem::get_blend_mode() const {
@@ -635,56 +586,52 @@ CanvasItem::BlendMode CanvasItem::get_blend_mode() const {
void CanvasItem::set_light_mask(int p_light_mask) {
- light_mask=p_light_mask;
- VS::get_singleton()->canvas_item_set_light_mask(canvas_item,p_light_mask);
+ light_mask = p_light_mask;
+ VS::get_singleton()->canvas_item_set_light_mask(canvas_item, p_light_mask);
}
-int CanvasItem::get_light_mask() const{
+int CanvasItem::get_light_mask() const {
return light_mask;
}
-
void CanvasItem::item_rect_changed() {
update();
emit_signal(SceneStringNames::get_singleton()->item_rect_changed);
}
-
-void CanvasItem::draw_line(const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width) {
+void CanvasItem::draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
}
- VisualServer::get_singleton()->canvas_item_add_line(canvas_item,p_from,p_to,p_color,p_width);
+ VisualServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width);
}
-void CanvasItem::draw_rect(const Rect2& p_rect, const Color& p_color) {
+void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
}
- VisualServer::get_singleton()->canvas_item_add_rect(canvas_item,p_rect,p_color);
-
+ VisualServer::get_singleton()->canvas_item_add_rect(canvas_item, p_rect, p_color);
}
-void CanvasItem::draw_circle(const Point2& p_pos, float p_radius, const Color& p_color) {
+void CanvasItem::draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
}
- VisualServer::get_singleton()->canvas_item_add_circle(canvas_item,p_pos,p_radius,p_color);
-
+ VisualServer::get_singleton()->canvas_item_add_circle(canvas_item, p_pos, p_radius, p_color);
}
-void CanvasItem::draw_texture(const Ref<Texture>& p_texture,const Point2& p_pos,const Color& p_modulate) {
+void CanvasItem::draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -693,10 +640,10 @@ void CanvasItem::draw_texture(const Ref<Texture>& p_texture,const Point2& p_pos,
ERR_FAIL_COND(p_texture.is_null());
- p_texture->draw(canvas_item,p_pos,p_modulate);
+ p_texture->draw(canvas_item, p_pos, p_modulate);
}
-void CanvasItem::draw_texture_rect(const Ref<Texture>& p_texture,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) {
+void CanvasItem::draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -704,20 +651,19 @@ void CanvasItem::draw_texture_rect(const Ref<Texture>& p_texture,const Rect2& p_
}
ERR_FAIL_COND(p_texture.is_null());
- p_texture->draw_rect(canvas_item,p_rect,p_tile,p_modulate,p_transpose);
-
+ p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose);
}
-void CanvasItem::draw_texture_rect_region(const Ref<Texture>& p_texture,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) {
+void CanvasItem::draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
}
ERR_FAIL_COND(p_texture.is_null());
- p_texture->draw_rect_region(canvas_item,p_rect,p_src_rect,p_modulate,p_transpose);
+ p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose);
}
-void CanvasItem::draw_style_box(const Ref<StyleBox>& p_style_box,const Rect2& p_rect) {
+void CanvasItem::draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
@@ -725,10 +671,9 @@ void CanvasItem::draw_style_box(const Ref<StyleBox>& p_style_box,const Rect2& p_
ERR_FAIL_COND(p_style_box.is_null());
- p_style_box->draw(canvas_item,p_rect);
-
+ p_style_box->draw(canvas_item, p_rect);
}
-void CanvasItem::draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, Ref<Texture> p_texture,float p_width) {
+void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, float p_width) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -737,32 +682,31 @@ void CanvasItem::draw_primitive(const Vector<Point2>& p_points, const Vector<Col
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_primitive(canvas_item,p_points,p_colors,p_uvs,rid,p_width);
+ VisualServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width);
}
-void CanvasItem::draw_set_transform(const Point2& p_offset, float p_rot, const Size2& p_scale) {
+void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
}
- Matrix32 xform(p_rot,p_offset);
+ Matrix32 xform(p_rot, p_offset);
xform.scale_basis(p_scale);
- VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item,xform);
+ VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, xform);
}
-void CanvasItem::draw_set_transform_matrix(const Matrix32& p_matrix) {
+void CanvasItem::draw_set_transform_matrix(const Matrix32 &p_matrix) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL();
}
- VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item,p_matrix);
-
+ VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
}
-void CanvasItem::draw_polygon(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, Ref<Texture> p_texture) {
+void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -771,12 +715,10 @@ void CanvasItem::draw_polygon(const Vector<Point2>& p_points, const Vector<Color
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item,p_points,p_colors,p_uvs,rid);
-
-
+ VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid);
}
-void CanvasItem::draw_colored_polygon(const Vector<Point2>& p_points, const Color& p_color,const Vector<Point2>& p_uvs, Ref<Texture> p_texture) {
+void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -787,10 +729,10 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2>& p_points, const Colo
colors.push_back(p_color);
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item,p_points,colors,p_uvs,rid);
+ VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid);
}
-void CanvasItem::draw_string(const Ref<Font>& p_font,const Point2& p_pos, const String& p_text,const Color& p_modulate,int p_clip_w) {
+void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -798,31 +740,28 @@ void CanvasItem::draw_string(const Ref<Font>& p_font,const Point2& p_pos, const
}
ERR_FAIL_COND(p_font.is_null());
- p_font->draw(canvas_item,p_pos,p_text,p_modulate,p_clip_w);
-
+ p_font->draw(canvas_item, p_pos, p_text, p_modulate, p_clip_w);
}
-float CanvasItem::draw_char(const Ref<Font>& p_font,const Point2& p_pos, const String& p_char,const String& p_next,const Color& p_modulate) {
+float CanvasItem::draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next, const Color &p_modulate) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
ERR_FAIL_V(0);
}
- ERR_FAIL_COND_V(p_char.length()!=1,0);
- ERR_FAIL_COND_V(p_font.is_null(),0);
-
- return p_font->draw_char(canvas_item,p_pos,p_char[0],p_next.c_str()[0],p_modulate);
+ ERR_FAIL_COND_V(p_char.length() != 1, 0);
+ ERR_FAIL_COND_V(p_font.is_null(), 0);
+ return p_font->draw_char(canvas_item, p_pos, p_char[0], p_next.c_str()[0], p_modulate);
}
-
void CanvasItem::_notify_transform(CanvasItem *p_node) {
if (p_node->xform_change.in_list() && p_node->global_invalid)
return; //nothing to do
- p_node->global_invalid=true;
+ p_node->global_invalid = true;
if (!p_node->xform_change.in_list()) {
if (!p_node->block_transform_notify) {
@@ -831,51 +770,46 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) {
}
}
+ for (List<CanvasItem *>::Element *E = p_node->children_items.front(); E; E = E->next()) {
- for(List<CanvasItem*>::Element *E=p_node->children_items.front();E;E=E->next()) {
-
- CanvasItem* ci=E->get();
+ CanvasItem *ci = E->get();
if (ci->toplevel)
continue;
_notify_transform(ci);
}
}
-
Rect2 CanvasItem::get_viewport_rect() const {
- ERR_FAIL_COND_V(!is_inside_tree(),Rect2());
+ ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
return get_viewport()->get_visible_rect();
}
RID CanvasItem::get_canvas() const {
- ERR_FAIL_COND_V(!is_inside_tree(),RID());
+ ERR_FAIL_COND_V(!is_inside_tree(), RID());
if (canvas_layer)
return canvas_layer->get_world_2d()->get_canvas();
else
return get_viewport()->find_world_2d()->get_canvas();
-
-
}
CanvasItem *CanvasItem::get_toplevel() const {
- CanvasItem *ci=const_cast<CanvasItem*>(this);
- while(!ci->toplevel && ci->get_parent() && ci->get_parent()->cast_to<CanvasItem>()) {
- ci=ci->get_parent()->cast_to<CanvasItem>();
+ CanvasItem *ci = const_cast<CanvasItem *>(this);
+ while (!ci->toplevel && ci->get_parent() && ci->get_parent()->cast_to<CanvasItem>()) {
+ ci = ci->get_parent()->cast_to<CanvasItem>();
}
return ci;
}
-
Ref<World2D> CanvasItem::get_world_2d() const {
- ERR_FAIL_COND_V(!is_inside_tree(),Ref<World2D>());
+ ERR_FAIL_COND_V(!is_inside_tree(), Ref<World2D>());
- CanvasItem *tl=get_toplevel();
+ CanvasItem *tl = get_toplevel();
if (tl->canvas_layer) {
return tl->canvas_layer->get_world_2d();
@@ -884,17 +818,16 @@ Ref<World2D> CanvasItem::get_world_2d() const {
} else {
return Ref<World2D>();
}
-
}
RID CanvasItem::get_viewport_rid() const {
- ERR_FAIL_COND_V(!is_inside_tree(),RID());
+ ERR_FAIL_COND_V(!is_inside_tree(), RID());
return get_viewport()->get_viewport();
}
void CanvasItem::set_block_transform_notify(bool p_enable) {
- block_transform_notify=p_enable;
+ block_transform_notify = p_enable;
}
bool CanvasItem::is_block_transform_notify_enabled() const {
@@ -904,204 +837,195 @@ bool CanvasItem::is_block_transform_notify_enabled() const {
void CanvasItem::set_draw_behind_parent(bool p_enable) {
- if (behind==p_enable)
+ if (behind == p_enable)
return;
- behind=p_enable;
- VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item,!behind);
-
+ behind = p_enable;
+ VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item, !behind);
}
-bool CanvasItem::is_draw_behind_parent_enabled() const{
+bool CanvasItem::is_draw_behind_parent_enabled() const {
return behind;
}
-void CanvasItem::set_material(const Ref<CanvasItemMaterial>& p_material) {
-
+void CanvasItem::set_material(const Ref<CanvasItemMaterial> &p_material) {
- material=p_material;
+ material = p_material;
RID rid;
if (material.is_valid())
- rid=material->get_rid();
- VS::get_singleton()->canvas_item_set_material(canvas_item,rid);
+ rid = material->get_rid();
+ VS::get_singleton()->canvas_item_set_material(canvas_item, rid);
_change_notify(); //properties for material exposed
}
void CanvasItem::set_use_parent_material(bool p_use_parent_material) {
- use_parent_material=p_use_parent_material;
- VS::get_singleton()->canvas_item_set_use_parent_material(canvas_item,p_use_parent_material);
+ use_parent_material = p_use_parent_material;
+ VS::get_singleton()->canvas_item_set_use_parent_material(canvas_item, p_use_parent_material);
}
-bool CanvasItem::get_use_parent_material() const{
+bool CanvasItem::get_use_parent_material() const {
return use_parent_material;
}
-Ref<CanvasItemMaterial> CanvasItem::get_material() const{
+Ref<CanvasItemMaterial> CanvasItem::get_material() const {
return material;
}
-Vector2 CanvasItem::make_canvas_pos_local(const Vector2& screen_point) const {
+Vector2 CanvasItem::make_canvas_pos_local(const Vector2 &screen_point) const {
- ERR_FAIL_COND_V(!is_inside_tree(),screen_point);
+ ERR_FAIL_COND_V(!is_inside_tree(), screen_point);
- Matrix32 local_matrix = (get_canvas_transform() *
- get_global_transform()).affine_inverse();
+ Matrix32 local_matrix = (get_canvas_transform() *
+ get_global_transform())
+ .affine_inverse();
return local_matrix.xform(screen_point);
}
-InputEvent CanvasItem::make_input_local(const InputEvent& p_event) const {
+InputEvent CanvasItem::make_input_local(const InputEvent &p_event) const {
- ERR_FAIL_COND_V(!is_inside_tree(),p_event);
-
- return p_event.xform_by( (get_canvas_transform() * get_global_transform()).affine_inverse() );
+ ERR_FAIL_COND_V(!is_inside_tree(), p_event);
+ return p_event.xform_by((get_canvas_transform() * get_global_transform()).affine_inverse());
}
-
Vector2 CanvasItem::get_global_mouse_pos() const {
- ERR_FAIL_COND_V(!get_viewport(),Vector2());
- return get_canvas_transform().affine_inverse().xform( get_viewport()->get_mouse_pos() );
+ ERR_FAIL_COND_V(!get_viewport(), Vector2());
+ return get_canvas_transform().affine_inverse().xform(get_viewport()->get_mouse_pos());
}
-Vector2 CanvasItem::get_local_mouse_pos() const{
+Vector2 CanvasItem::get_local_mouse_pos() const {
- ERR_FAIL_COND_V(!get_viewport(),Vector2());
+ ERR_FAIL_COND_V(!get_viewport(), Vector2());
- return get_global_transform().affine_inverse().xform( get_global_mouse_pos() );
+ return get_global_transform().affine_inverse().xform(get_global_mouse_pos());
}
-
void CanvasItem::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_sort_children"),&CanvasItem::_sort_children);
- ObjectTypeDB::bind_method(_MD("_raise_self"),&CanvasItem::_raise_self);
- ObjectTypeDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback);
- ObjectTypeDB::bind_method(_MD("_set_visible_"),&CanvasItem::_set_visible_);
- ObjectTypeDB::bind_method(_MD("_is_visible_"),&CanvasItem::_is_visible_);
+ ObjectTypeDB::bind_method(_MD("_sort_children"), &CanvasItem::_sort_children);
+ ObjectTypeDB::bind_method(_MD("_raise_self"), &CanvasItem::_raise_self);
+ ObjectTypeDB::bind_method(_MD("_update_callback"), &CanvasItem::_update_callback);
+ ObjectTypeDB::bind_method(_MD("_set_visible_"), &CanvasItem::_set_visible_);
+ ObjectTypeDB::bind_method(_MD("_is_visible_"), &CanvasItem::_is_visible_);
- ObjectTypeDB::bind_method(_MD("edit_set_state","state"),&CanvasItem::edit_set_state);
- ObjectTypeDB::bind_method(_MD("edit_get_state:Variant"),&CanvasItem::edit_get_state);
- ObjectTypeDB::bind_method(_MD("edit_set_rect","rect"),&CanvasItem::edit_set_rect);
- ObjectTypeDB::bind_method(_MD("edit_rotate","degrees"),&CanvasItem::edit_rotate);
+ ObjectTypeDB::bind_method(_MD("edit_set_state", "state"), &CanvasItem::edit_set_state);
+ ObjectTypeDB::bind_method(_MD("edit_get_state:Variant"), &CanvasItem::edit_get_state);
+ ObjectTypeDB::bind_method(_MD("edit_set_rect", "rect"), &CanvasItem::edit_set_rect);
+ ObjectTypeDB::bind_method(_MD("edit_rotate", "degrees"), &CanvasItem::edit_rotate);
- ObjectTypeDB::bind_method(_MD("get_item_rect"),&CanvasItem::get_item_rect);
- ObjectTypeDB::bind_method(_MD("get_item_and_children_rect"),&CanvasItem::get_item_and_children_rect);
+ ObjectTypeDB::bind_method(_MD("get_item_rect"), &CanvasItem::get_item_rect);
+ ObjectTypeDB::bind_method(_MD("get_item_and_children_rect"), &CanvasItem::get_item_and_children_rect);
//ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
- ObjectTypeDB::bind_method(_MD("get_canvas_item"),&CanvasItem::get_canvas_item);
+ ObjectTypeDB::bind_method(_MD("get_canvas_item"), &CanvasItem::get_canvas_item);
- ObjectTypeDB::bind_method(_MD("is_visible"),&CanvasItem::is_visible);
- ObjectTypeDB::bind_method(_MD("is_hidden"),&CanvasItem::is_hidden);
- ObjectTypeDB::bind_method(_MD("show"),&CanvasItem::show);
- ObjectTypeDB::bind_method(_MD("hide"),&CanvasItem::hide);
- ObjectTypeDB::bind_method(_MD("set_hidden","hidden"),&CanvasItem::set_hidden);
+ ObjectTypeDB::bind_method(_MD("is_visible"), &CanvasItem::is_visible);
+ ObjectTypeDB::bind_method(_MD("is_hidden"), &CanvasItem::is_hidden);
+ ObjectTypeDB::bind_method(_MD("show"), &CanvasItem::show);
+ ObjectTypeDB::bind_method(_MD("hide"), &CanvasItem::hide);
+ ObjectTypeDB::bind_method(_MD("set_hidden", "hidden"), &CanvasItem::set_hidden);
- ObjectTypeDB::bind_method(_MD("update"),&CanvasItem::update);
+ ObjectTypeDB::bind_method(_MD("update"), &CanvasItem::update);
- ObjectTypeDB::bind_method(_MD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel);
- ObjectTypeDB::bind_method(_MD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel);
+ ObjectTypeDB::bind_method(_MD("set_as_toplevel", "enable"), &CanvasItem::set_as_toplevel);
+ ObjectTypeDB::bind_method(_MD("is_set_as_toplevel"), &CanvasItem::is_set_as_toplevel);
- ObjectTypeDB::bind_method(_MD("set_blend_mode","blend_mode"),&CanvasItem::set_blend_mode);
- ObjectTypeDB::bind_method(_MD("get_blend_mode"),&CanvasItem::get_blend_mode);
+ ObjectTypeDB::bind_method(_MD("set_blend_mode", "blend_mode"), &CanvasItem::set_blend_mode);
+ ObjectTypeDB::bind_method(_MD("get_blend_mode"), &CanvasItem::get_blend_mode);
- ObjectTypeDB::bind_method(_MD("set_light_mask","light_mask"),&CanvasItem::set_light_mask);
- ObjectTypeDB::bind_method(_MD("get_light_mask"),&CanvasItem::get_light_mask);
+ ObjectTypeDB::bind_method(_MD("set_light_mask", "light_mask"), &CanvasItem::set_light_mask);
+ ObjectTypeDB::bind_method(_MD("get_light_mask"), &CanvasItem::get_light_mask);
- ObjectTypeDB::bind_method(_MD("set_opacity","opacity"),&CanvasItem::set_opacity);
- ObjectTypeDB::bind_method(_MD("get_opacity"),&CanvasItem::get_opacity);
- ObjectTypeDB::bind_method(_MD("set_self_opacity","self_opacity"),&CanvasItem::set_self_opacity);
- ObjectTypeDB::bind_method(_MD("get_self_opacity"),&CanvasItem::get_self_opacity);
+ ObjectTypeDB::bind_method(_MD("set_opacity", "opacity"), &CanvasItem::set_opacity);
+ ObjectTypeDB::bind_method(_MD("get_opacity"), &CanvasItem::get_opacity);
+ ObjectTypeDB::bind_method(_MD("set_self_opacity", "self_opacity"), &CanvasItem::set_self_opacity);
+ ObjectTypeDB::bind_method(_MD("get_self_opacity"), &CanvasItem::get_self_opacity);
- ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent);
- ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled);
+ ObjectTypeDB::bind_method(_MD("set_draw_behind_parent", "enable"), &CanvasItem::set_draw_behind_parent);
+ ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"), &CanvasItem::is_draw_behind_parent_enabled);
- ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top);
- ObjectTypeDB::bind_method(_MD("_is_on_top"),&CanvasItem::_is_on_top);
+ ObjectTypeDB::bind_method(_MD("_set_on_top", "on_top"), &CanvasItem::_set_on_top);
+ ObjectTypeDB::bind_method(_MD("_is_on_top"), &CanvasItem::_is_on_top);
//ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
- ObjectTypeDB::bind_method(_MD("draw_line","from","to","color","width"),&CanvasItem::draw_line,DEFVAL(1.0));
- ObjectTypeDB::bind_method(_MD("draw_rect","rect","color"),&CanvasItem::draw_rect);
- ObjectTypeDB::bind_method(_MD("draw_circle","pos","radius","color"),&CanvasItem::draw_circle);
- ObjectTypeDB::bind_method(_MD("draw_texture","texture:Texture","pos","modulate"),&CanvasItem::draw_texture,DEFVAL(Color(1,1,1,1)));
- ObjectTypeDB::bind_method(_MD("draw_texture_rect","texture:Texture","rect","tile","modulate","transpose"),&CanvasItem::draw_texture_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_texture_rect_region","texture:Texture","rect","src_rect","modulate","transpose"),&CanvasItem::draw_texture_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_style_box","style_box:StyleBox","rect"),&CanvasItem::draw_style_box);
- ObjectTypeDB::bind_method(_MD("draw_primitive","points","colors","uvs","texture:Texture","width"),&CanvasItem::draw_primitive,DEFVAL(Variant()),DEFVAL(1.0));
- ObjectTypeDB::bind_method(_MD("draw_polygon","points","colors","uvs","texture:Texture"),&CanvasItem::draw_polygon,DEFVAL(Vector2Array()),DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("draw_colored_polygon","points","color","uvs","texture:Texture"),&CanvasItem::draw_colored_polygon,DEFVAL(Vector2Array()),DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("draw_string","font:Font","pos","text","modulate","clip_w"),&CanvasItem::draw_string,DEFVAL(Color(1,1,1)),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("draw_char","font:Font","pos","char","next","modulate"),&CanvasItem::draw_char,DEFVAL(Color(1,1,1)));
+ ObjectTypeDB::bind_method(_MD("draw_line", "from", "to", "color", "width"), &CanvasItem::draw_line, DEFVAL(1.0));
+ ObjectTypeDB::bind_method(_MD("draw_rect", "rect", "color"), &CanvasItem::draw_rect);
+ ObjectTypeDB::bind_method(_MD("draw_circle", "pos", "radius", "color"), &CanvasItem::draw_circle);
+ ObjectTypeDB::bind_method(_MD("draw_texture", "texture:Texture", "pos", "modulate"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)));
+ ObjectTypeDB::bind_method(_MD("draw_texture_rect", "texture:Texture", "rect", "tile", "modulate", "transpose"), &CanvasItem::draw_texture_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("draw_texture_rect_region", "texture:Texture", "rect", "src_rect", "modulate", "transpose"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("draw_style_box", "style_box:StyleBox", "rect"), &CanvasItem::draw_style_box);
+ ObjectTypeDB::bind_method(_MD("draw_primitive", "points", "colors", "uvs", "texture:Texture", "width"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0));
+ ObjectTypeDB::bind_method(_MD("draw_polygon", "points", "colors", "uvs", "texture:Texture"), &CanvasItem::draw_polygon, DEFVAL(Vector2Array()), DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("draw_colored_polygon", "points", "color", "uvs", "texture:Texture"), &CanvasItem::draw_colored_polygon, DEFVAL(Vector2Array()), DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("draw_string", "font:Font", "pos", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("draw_char", "font:Font", "pos", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1)));
- ObjectTypeDB::bind_method(_MD("draw_set_transform","pos","rot","scale"),&CanvasItem::draw_set_transform);
- ObjectTypeDB::bind_method(_MD("draw_set_transform_matrix","xform"),&CanvasItem::draw_set_transform_matrix);
- ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasItem::get_transform);
- ObjectTypeDB::bind_method(_MD("get_global_transform"),&CanvasItem::get_global_transform);
- ObjectTypeDB::bind_method(_MD("get_global_transform_with_canvas"),&CanvasItem::get_global_transform_with_canvas);
- ObjectTypeDB::bind_method(_MD("get_viewport_transform"),&CanvasItem::get_viewport_transform);
- ObjectTypeDB::bind_method(_MD("get_viewport_rect"),&CanvasItem::get_viewport_rect);
- ObjectTypeDB::bind_method(_MD("get_canvas_transform"),&CanvasItem::get_canvas_transform);
- ObjectTypeDB::bind_method(_MD("get_local_mouse_pos"),&CanvasItem::get_local_mouse_pos);
- ObjectTypeDB::bind_method(_MD("get_global_mouse_pos"),&CanvasItem::get_global_mouse_pos);
- ObjectTypeDB::bind_method(_MD("get_canvas"),&CanvasItem::get_canvas);
- ObjectTypeDB::bind_method(_MD("get_world_2d"),&CanvasItem::get_world_2d);
+ ObjectTypeDB::bind_method(_MD("draw_set_transform", "pos", "rot", "scale"), &CanvasItem::draw_set_transform);
+ ObjectTypeDB::bind_method(_MD("draw_set_transform_matrix", "xform"), &CanvasItem::draw_set_transform_matrix);
+ ObjectTypeDB::bind_method(_MD("get_transform"), &CanvasItem::get_transform);
+ ObjectTypeDB::bind_method(_MD("get_global_transform"), &CanvasItem::get_global_transform);
+ ObjectTypeDB::bind_method(_MD("get_global_transform_with_canvas"), &CanvasItem::get_global_transform_with_canvas);
+ ObjectTypeDB::bind_method(_MD("get_viewport_transform"), &CanvasItem::get_viewport_transform);
+ ObjectTypeDB::bind_method(_MD("get_viewport_rect"), &CanvasItem::get_viewport_rect);
+ ObjectTypeDB::bind_method(_MD("get_canvas_transform"), &CanvasItem::get_canvas_transform);
+ ObjectTypeDB::bind_method(_MD("get_local_mouse_pos"), &CanvasItem::get_local_mouse_pos);
+ ObjectTypeDB::bind_method(_MD("get_global_mouse_pos"), &CanvasItem::get_global_mouse_pos);
+ ObjectTypeDB::bind_method(_MD("get_canvas"), &CanvasItem::get_canvas);
+ ObjectTypeDB::bind_method(_MD("get_world_2d"), &CanvasItem::get_world_2d);
//ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasItem::get_viewport);
- ObjectTypeDB::bind_method(_MD("set_material","material:CanvasItemMaterial"),&CanvasItem::set_material);
- ObjectTypeDB::bind_method(_MD("get_material:CanvasItemMaterial"),&CanvasItem::get_material);
+ ObjectTypeDB::bind_method(_MD("set_material", "material:CanvasItemMaterial"), &CanvasItem::set_material);
+ ObjectTypeDB::bind_method(_MD("get_material:CanvasItemMaterial"), &CanvasItem::get_material);
- ObjectTypeDB::bind_method(_MD("set_use_parent_material","enable"),&CanvasItem::set_use_parent_material);
- ObjectTypeDB::bind_method(_MD("get_use_parent_material"),&CanvasItem::get_use_parent_material);
+ ObjectTypeDB::bind_method(_MD("set_use_parent_material", "enable"), &CanvasItem::set_use_parent_material);
+ ObjectTypeDB::bind_method(_MD("get_use_parent_material"), &CanvasItem::get_use_parent_material);
- ObjectTypeDB::bind_method(_MD("make_canvas_pos_local","screen_point"),
+ ObjectTypeDB::bind_method(_MD("make_canvas_pos_local", "screen_point"),
&CanvasItem::make_canvas_pos_local);
- ObjectTypeDB::bind_method(_MD("make_input_local","event"),&CanvasItem::make_input_local);
+ ObjectTypeDB::bind_method(_MD("make_input_local", "event"), &CanvasItem::make_input_local);
BIND_VMETHOD(MethodInfo("_draw"));
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
- ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") );
- ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "visibility/visible"), _SCS("_set_visible_"), _SCS("_is_visible_"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "visibility/opacity", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"), _SCS("get_opacity"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "visibility/self_opacity", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"), _SCS("get_self_opacity"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "visibility/behind_parent"), _SCS("set_draw_behind_parent"), _SCS("is_draw_behind_parent_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visibility/on_top", PROPERTY_HINT_NONE, "", 0), _SCS("_set_on_top"), _SCS("_is_on_top")); //compatibility
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") );
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"visibility/light_mask",PROPERTY_HINT_ALL_FLAGS), _SCS("set_light_mask"),_SCS("get_light_mask") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material/material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"),_SCS("get_material") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"material/use_parent"), _SCS("set_use_parent_material"),_SCS("get_use_parent_material") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "visibility/blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"), _SCS("get_blend_mode"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "visibility/light_mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_light_mask"), _SCS("get_light_mask"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "material/material", PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"), _SCS("get_material"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "material/use_parent"), _SCS("set_use_parent_material"), _SCS("get_use_parent_material"));
//exporting these two things doesn't really make much sense i think
//ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), _SCS("set_as_toplevel"),_SCS("is_set_as_toplevel") );
//ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),_SCS("set_transform_notify"),_SCS("is_transform_notify_enabled"));
- ADD_SIGNAL( MethodInfo("draw") );
- ADD_SIGNAL( MethodInfo("visibility_changed") );
- ADD_SIGNAL( MethodInfo("hide") );
- ADD_SIGNAL( MethodInfo("item_rect_changed") );
-
-
-
- BIND_CONSTANT( BLEND_MODE_MIX );
- BIND_CONSTANT( BLEND_MODE_ADD );
- BIND_CONSTANT( BLEND_MODE_SUB );
- BIND_CONSTANT( BLEND_MODE_MUL );
- BIND_CONSTANT( BLEND_MODE_PREMULT_ALPHA );
-
-
- BIND_CONSTANT( NOTIFICATION_DRAW);
- BIND_CONSTANT( NOTIFICATION_VISIBILITY_CHANGED );
- BIND_CONSTANT( NOTIFICATION_ENTER_CANVAS );
- BIND_CONSTANT( NOTIFICATION_EXIT_CANVAS );
- BIND_CONSTANT( NOTIFICATION_TRANSFORM_CHANGED );
+ ADD_SIGNAL(MethodInfo("draw"));
+ ADD_SIGNAL(MethodInfo("visibility_changed"));
+ ADD_SIGNAL(MethodInfo("hide"));
+ ADD_SIGNAL(MethodInfo("item_rect_changed"));
+ BIND_CONSTANT(BLEND_MODE_MIX);
+ BIND_CONSTANT(BLEND_MODE_ADD);
+ BIND_CONSTANT(BLEND_MODE_SUB);
+ BIND_CONSTANT(BLEND_MODE_MUL);
+ BIND_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
+ BIND_CONSTANT(NOTIFICATION_DRAW);
+ BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED);
+ BIND_CONSTANT(NOTIFICATION_ENTER_CANVAS);
+ BIND_CONSTANT(NOTIFICATION_EXIT_CANVAS);
+ BIND_CONSTANT(NOTIFICATION_TRANSFORM_CHANGED);
}
Matrix32 CanvasItem::get_canvas_transform() const {
- ERR_FAIL_COND_V(!is_inside_tree(),Matrix32());
+ ERR_FAIL_COND_V(!is_inside_tree(), Matrix32());
if (canvas_layer)
return canvas_layer->get_transform();
@@ -1109,12 +1033,11 @@ Matrix32 CanvasItem::get_canvas_transform() const {
return get_parent()->cast_to<CanvasItem>()->get_canvas_transform();
else
return get_viewport()->get_canvas_transform();
-
}
Matrix32 CanvasItem::get_viewport_transform() const {
- ERR_FAIL_COND_V(!is_inside_tree(),Matrix32());
+ ERR_FAIL_COND_V(!is_inside_tree(), Matrix32());
if (canvas_layer) {
@@ -1127,12 +1050,10 @@ Matrix32 CanvasItem::get_viewport_transform() const {
} else {
return get_viewport()->get_final_transform() * get_viewport()->get_canvas_transform();
}
-
}
-
void CanvasItem::set_notify_local_transform(bool p_enable) {
- notify_local_transform=p_enable;
+ notify_local_transform = p_enable;
}
bool CanvasItem::is_local_transform_notification_enabled() const {
@@ -1147,14 +1068,12 @@ int CanvasItem::get_canvas_layer() const {
return 0;
}
-
Rect2 CanvasItem::get_item_and_children_rect() const {
Rect2 rect = get_item_rect();
-
- for(int i=0;i<get_child_count();i++) {
- CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
+ for (int i = 0; i < get_child_count(); i++) {
+ CanvasItem *c = get_child(i)->cast_to<CanvasItem>();
if (c) {
Rect2 sir = c->get_transform().xform(c->get_item_and_children_rect());
rect = rect.merge(sir);
@@ -1164,30 +1083,29 @@ Rect2 CanvasItem::get_item_and_children_rect() const {
return rect;
}
-CanvasItem::CanvasItem() : xform_change(this) {
-
-
- canvas_item=VisualServer::get_singleton()->canvas_item_create();
- hidden=false;
- pending_update=false;
- opacity=1;
- self_opacity=1;
- toplevel=false;
- pending_children_sort=false;
- first_draw=false;
- blend_mode=BLEND_MODE_MIX;
- drawing=false;
- behind=false;
- block_transform_notify=false;
-// viewport=NULL;
- canvas_layer=NULL;
- use_parent_material=false;
- global_invalid=true;
- notify_local_transform=false;
- light_mask=1;
+CanvasItem::CanvasItem()
+ : xform_change(this) {
- C=NULL;
+ canvas_item = VisualServer::get_singleton()->canvas_item_create();
+ hidden = false;
+ pending_update = false;
+ opacity = 1;
+ self_opacity = 1;
+ toplevel = false;
+ pending_children_sort = false;
+ first_draw = false;
+ blend_mode = BLEND_MODE_MIX;
+ drawing = false;
+ behind = false;
+ block_transform_notify = false;
+ // viewport=NULL;
+ canvas_layer = NULL;
+ use_parent_material = false;
+ global_invalid = true;
+ notify_local_transform = false;
+ light_mask = 1;
+ C = NULL;
}
CanvasItem::~CanvasItem() {
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 5c13c7d20..776fbd7fb 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -30,9 +30,9 @@
#define CANVAS_ITEM_H
#include "scene/main/node.h"
-#include "scene/resources/texture.h"
#include "scene/main/scene_main_loop.h"
#include "scene/resources/shader.h"
+#include "scene/resources/texture.h"
class CanvasLayer;
class Viewport;
@@ -40,11 +40,12 @@ class Font;
class StyleBox;
-class CanvasItemMaterial : public Resource{
+class CanvasItemMaterial : public Resource {
- OBJ_TYPE(CanvasItemMaterial,Resource);
+ OBJ_TYPE(CanvasItemMaterial, Resource);
RID material;
Ref<Shader> shader;
+
public:
enum ShadingMode {
SHADING_NORMAL,
@@ -53,24 +54,22 @@ public:
};
protected:
-
ShadingMode shading_mode;
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
- void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
+ void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
public:
-
- void set_shader(const Ref<Shader>& p_shader);
+ void set_shader(const Ref<Shader> &p_shader);
Ref<Shader> get_shader() const;
- void set_shader_param(const StringName& p_param,const Variant& p_value);
- Variant get_shader_param(const StringName& p_param) const;
+ void set_shader_param(const StringName &p_param, const Variant &p_value);
+ Variant get_shader_param(const StringName &p_param) const;
void set_shading_mode(ShadingMode p_mode);
ShadingMode get_shading_mode() const;
@@ -80,14 +79,13 @@ public:
~CanvasItemMaterial();
};
-VARIANT_ENUM_CAST( CanvasItemMaterial::ShadingMode );
-
+VARIANT_ENUM_CAST(CanvasItemMaterial::ShadingMode);
class CanvasItem : public Node {
- OBJ_TYPE( CanvasItem, Node );
-public:
+ OBJ_TYPE(CanvasItem, Node);
+public:
enum BlendMode {
BLEND_MODE_MIX, //default
@@ -98,20 +96,18 @@ public:
};
private:
-
mutable SelfList<Node> xform_change;
RID canvas_item;
String group;
-
CanvasLayer *canvas_layer;
float opacity;
float self_opacity;
- List<CanvasItem*> children_items;
- List<CanvasItem*>::Element *C;
+ List<CanvasItem *> children_items;
+ List<CanvasItem *>::Element *C;
BlendMode blend_mode;
int light_mask;
@@ -132,7 +128,6 @@ private:
mutable Matrix32 global_transform;
mutable bool global_invalid;
-
void _raise_self();
void _propagate_visibility_changed(bool p_visible);
@@ -154,32 +149,34 @@ private:
bool _is_on_top() const { return !is_draw_behind_parent_enabled(); }
protected:
-
- _FORCE_INLINE_ void _notify_transform() { if (!is_inside_tree()) return; _notify_transform(this); if (!block_transform_notify && notify_local_transform) notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED); }
+ _FORCE_INLINE_ void _notify_transform() {
+ if (!is_inside_tree()) return;
+ _notify_transform(this);
+ if (!block_transform_notify && notify_local_transform) notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED);
+ }
void item_rect_changed();
void _notification(int p_what);
static void _bind_methods();
-public:
-
+public:
enum {
- NOTIFICATION_TRANSFORM_CHANGED=SceneTree::NOTIFICATION_TRANSFORM_CHANGED, //unique
- NOTIFICATION_DRAW=30,
- NOTIFICATION_VISIBILITY_CHANGED=31,
- NOTIFICATION_ENTER_CANVAS=32,
- NOTIFICATION_EXIT_CANVAS=33,
- NOTIFICATION_LOCAL_TRANSFORM_CHANGED=35,
- NOTIFICATION_WORLD_2D_CHANGED=36,
+ NOTIFICATION_TRANSFORM_CHANGED = SceneTree::NOTIFICATION_TRANSFORM_CHANGED, //unique
+ NOTIFICATION_DRAW = 30,
+ NOTIFICATION_VISIBILITY_CHANGED = 31,
+ NOTIFICATION_ENTER_CANVAS = 32,
+ NOTIFICATION_EXIT_CANVAS = 33,
+ NOTIFICATION_LOCAL_TRANSFORM_CHANGED = 35,
+ NOTIFICATION_WORLD_2D_CHANGED = 36,
};
/* EDITOR */
virtual Variant edit_get_state() const;
- virtual void edit_set_state(const Variant& p_state);
- virtual void edit_set_rect(const Rect2& p_edit_rect);
+ virtual void edit_set_state(const Variant &p_state);
+ virtual void edit_set_rect(const Rect2 &p_edit_rect);
virtual void edit_rotate(float p_rot);
virtual Size2 edit_get_minimum_size() const;
@@ -207,22 +204,22 @@ public:
/* DRAWING API */
- void draw_line(const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width=1.0);
- void draw_rect(const Rect2& p_rect, const Color& p_color);
- void draw_circle(const Point2& p_pos, float p_radius, const Color& p_color);
- void draw_texture(const Ref<Texture>& p_texture, const Point2& p_pos, const Color &p_modulate=Color(1,1,1,1));
- void draw_texture_rect(const Ref<Texture>& p_texture, const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false);
- void draw_texture_rect_region(const Ref<Texture>& p_texture,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false);
- void draw_style_box(const Ref<StyleBox>& p_style_box,const Rect2& p_rect);
- void draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, Ref<Texture> p_texture=Ref<Texture>(),float p_width=1);
- void draw_polygon(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs=Vector<Point2>(), Ref<Texture> p_texture=Ref<Texture>());
- void draw_colored_polygon(const Vector<Point2>& p_points, const Color& p_color,const Vector<Point2>& p_uvs=Vector<Point2>(), Ref<Texture> p_texture=Ref<Texture>());
+ void draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0);
+ void draw_rect(const Rect2 &p_rect, const Color &p_color);
+ void draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color);
+ void draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1));
+ void draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false);
+ void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false);
+ void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect);
+ void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture = Ref<Texture>(), float p_width = 1);
+ void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>());
+ void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>());
- void draw_string(const Ref<Font>& p_font, const Point2& p_pos, const String& p_text,const Color& p_modulate=Color(1,1,1),int p_clip_w=-1);
- float draw_char(const Ref<Font>& p_font,const Point2& p_pos, const String& p_char,const String& p_next="",const Color& p_modulate=Color(1,1,1));
+ void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1);
+ float draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", const Color &p_modulate = Color(1, 1, 1));
- void draw_set_transform(const Point2& p_offset, float p_rot, const Size2& p_scale);
- void draw_set_transform_matrix(const Matrix32& p_matrix);
+ void draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale);
+ void draw_set_transform_matrix(const Matrix32 &p_matrix);
/* RECT / TRANSFORM */
@@ -234,8 +231,8 @@ public:
CanvasItem *get_parent_item() const;
- virtual Rect2 get_item_rect() const=0;
- virtual Matrix32 get_transform() const=0;
+ virtual Rect2 get_item_rect() const = 0;
+ virtual Matrix32 get_transform() const = 0;
virtual Matrix32 get_global_transform() const;
virtual Matrix32 get_global_transform_with_canvas() const;
@@ -248,7 +245,6 @@ public:
void set_block_transform_notify(bool p_enable);
bool is_block_transform_notify_enabled() const;
-
Matrix32 get_canvas_transform() const;
Matrix32 get_viewport_transform() const;
Rect2 get_viewport_rect() const;
@@ -256,14 +252,14 @@ public:
RID get_canvas() const;
Ref<World2D> get_world_2d() const;
- void set_material(const Ref<CanvasItemMaterial>& p_material);
+ void set_material(const Ref<CanvasItemMaterial> &p_material);
Ref<CanvasItemMaterial> get_material() const;
void set_use_parent_material(bool p_use_parent_material);
bool get_use_parent_material() const;
- InputEvent make_input_local(const InputEvent& pevent) const;
- Vector2 make_canvas_pos_local(const Vector2& screen_point) const;
+ InputEvent make_input_local(const InputEvent &pevent) const;
+ Vector2 make_canvas_pos_local(const Vector2 &screen_point) const;
Vector2 get_global_mouse_pos() const;
Vector2 get_local_mouse_pos() const;
@@ -277,6 +273,6 @@ public:
~CanvasItem();
};
-VARIANT_ENUM_CAST( CanvasItem::BlendMode );
+VARIANT_ENUM_CAST(CanvasItem::BlendMode);
#endif // CANVAS_ITEM_H
diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp
index 383006838..ab189d5ce 100644
--- a/scene/2d/canvas_modulate.cpp
+++ b/scene/2d/canvas_modulate.cpp
@@ -28,52 +28,48 @@
/*************************************************************************/
#include "canvas_modulate.h"
-
void CanvasModulate::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_CANVAS) {
+ if (p_what == NOTIFICATION_ENTER_CANVAS) {
if (is_visible()) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
- add_to_group("_canvas_modulate_"+itos(get_canvas().get_id()));
+ VS::get_singleton()->canvas_set_modulate(get_canvas(), color);
+ add_to_group("_canvas_modulate_" + itos(get_canvas().get_id()));
}
-
-
- } else if (p_what==NOTIFICATION_EXIT_CANVAS) {
+ } else if (p_what == NOTIFICATION_EXIT_CANVAS) {
if (is_visible()) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1));
- remove_from_group("_canvas_modulate_"+itos(get_canvas().get_id()));
+ VS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1));
+ remove_from_group("_canvas_modulate_" + itos(get_canvas().get_id()));
}
- } else if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (is_visible()) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
- add_to_group("_canvas_modulate_"+itos(get_canvas().get_id()));
+ VS::get_singleton()->canvas_set_modulate(get_canvas(), color);
+ add_to_group("_canvas_modulate_" + itos(get_canvas().get_id()));
} else {
- VS::get_singleton()->canvas_set_modulate(get_canvas(),Color(1,1,1,1));
- remove_from_group("_canvas_modulate_"+itos(get_canvas().get_id()));
+ VS::get_singleton()->canvas_set_modulate(get_canvas(), Color(1, 1, 1, 1));
+ remove_from_group("_canvas_modulate_" + itos(get_canvas().get_id()));
}
update_configuration_warning();
}
}
-void CanvasModulate::_bind_methods(){
+void CanvasModulate::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_color","color"),&CanvasModulate::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&CanvasModulate::get_color);
+ ObjectTypeDB::bind_method(_MD("set_color", "color"), &CanvasModulate::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color"), &CanvasModulate::get_color);
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), _SCS("set_color"), _SCS("get_color"));
}
+void CanvasModulate::set_color(const Color &p_color) {
-void CanvasModulate::set_color(const Color& p_color){
-
- color=p_color;
+ color = p_color;
if (is_inside_tree()) {
- VS::get_singleton()->canvas_set_modulate(get_canvas(),color);
+ VS::get_singleton()->canvas_set_modulate(get_canvas(), color);
}
}
Color CanvasModulate::get_color() const {
@@ -86,23 +82,19 @@ String CanvasModulate::get_configuration_warning() const {
if (!is_visible() || !is_inside_tree())
return String();
- List<Node*> nodes;
- get_tree()->get_nodes_in_group("_canvas_modulate_"+itos(get_canvas().get_id()),&nodes);
+ List<Node *> nodes;
+ get_tree()->get_nodes_in_group("_canvas_modulate_" + itos(get_canvas().get_id()), &nodes);
- if (nodes.size()>1) {
+ if (nodes.size() > 1) {
return TTR("Only one visible CanvasModulate is allowed per scene (or set of instanced scenes). The first created one will work, while the rest will be ignored.");
}
return String();
}
-CanvasModulate::CanvasModulate()
-{
- color=Color(1,1,1,1);
+CanvasModulate::CanvasModulate() {
+ color = Color(1, 1, 1, 1);
}
-CanvasModulate::~CanvasModulate()
-{
-
+CanvasModulate::~CanvasModulate() {
}
-
diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h
index d4cfc0ff6..558596330 100644
--- a/scene/2d/canvas_modulate.h
+++ b/scene/2d/canvas_modulate.h
@@ -33,15 +33,16 @@
class CanvasModulate : public Node2D {
- OBJ_TYPE(CanvasModulate,Node2D);
+ OBJ_TYPE(CanvasModulate, Node2D);
Color color;
+
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_color(const Color& p_color);
+public:
+ void set_color(const Color &p_color);
Color get_color() const;
String get_configuration_warning() const;
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 1ea8921bf..8285e9169 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -27,16 +27,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "collision_object_2d.h"
-#include "servers/physics_2d_server.h"
#include "scene/scene_string_names.h"
+#include "servers/physics_2d_server.h"
void CollisionObject2D::_update_shapes_from_children() {
shapes.clear();
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- Node* n = get_child(i);
- n->call("_add_to_collision_object",this);
+ Node *n = get_child(i);
+ n->call("_add_to_collision_object", this);
}
_update_shapes();
@@ -44,24 +44,24 @@ void CollisionObject2D::_update_shapes_from_children() {
void CollisionObject2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (area)
- Physics2DServer::get_singleton()->area_set_transform(rid,get_global_transform());
+ Physics2DServer::get_singleton()->area_set_transform(rid, get_global_transform());
else
- Physics2DServer::get_singleton()->body_set_state(rid,Physics2DServer::BODY_STATE_TRANSFORM,get_global_transform());
+ Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, get_global_transform());
RID space = get_world_2d()->get_space();
if (area) {
- Physics2DServer::get_singleton()->area_set_space(rid,space);
+ Physics2DServer::get_singleton()->area_set_space(rid, space);
} else
- Physics2DServer::get_singleton()->body_set_space(rid,space);
+ Physics2DServer::get_singleton()->body_set_space(rid, space);
_update_pickable();
- //get space
+ //get space
}
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -71,17 +71,17 @@ void CollisionObject2D::_notification(int p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
if (area)
- Physics2DServer::get_singleton()->area_set_transform(rid,get_global_transform());
+ Physics2DServer::get_singleton()->area_set_transform(rid, get_global_transform());
else
- Physics2DServer::get_singleton()->body_set_state(rid,Physics2DServer::BODY_STATE_TRANSFORM,get_global_transform());
+ Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, get_global_transform());
} break;
case NOTIFICATION_EXIT_TREE: {
if (area) {
- Physics2DServer::get_singleton()->area_set_space(rid,RID());
+ Physics2DServer::get_singleton()->area_set_space(rid, RID());
} else
- Physics2DServer::get_singleton()->body_set_space(rid,RID());
+ Physics2DServer::get_singleton()->body_set_space(rid, RID());
} break;
}
@@ -97,84 +97,80 @@ void CollisionObject2D::_update_shapes() {
else
Physics2DServer::get_singleton()->body_clear_shapes(rid);
- for(int i=0;i<shapes.size();i++) {
+ for (int i = 0; i < shapes.size(); i++) {
if (shapes[i].shape.is_null())
continue;
if (area)
- Physics2DServer::get_singleton()->area_add_shape(rid,shapes[i].shape->get_rid(),shapes[i].xform);
+ Physics2DServer::get_singleton()->area_add_shape(rid, shapes[i].shape->get_rid(), shapes[i].xform);
else {
- Physics2DServer::get_singleton()->body_add_shape(rid,shapes[i].shape->get_rid(),shapes[i].xform);
+ Physics2DServer::get_singleton()->body_add_shape(rid, shapes[i].shape->get_rid(), shapes[i].xform);
if (shapes[i].trigger)
- Physics2DServer::get_singleton()->body_set_shape_as_trigger(rid,i,shapes[i].trigger);
+ Physics2DServer::get_singleton()->body_set_shape_as_trigger(rid, i, shapes[i].trigger);
}
}
}
-
-bool CollisionObject2D::_set(const StringName& p_name, const Variant& p_value) {
- String name=p_name;
+bool CollisionObject2D::_set(const StringName &p_name, const Variant &p_value) {
+ String name = p_name;
if (name.begins_with("shapes/")) {
- int idx=name.get_slicec('/',1).to_int();
- String what=name.get_slicec('/',2);
- if (what=="shape") {
- if (idx>=shapes.size())
+ int idx = name.get_slicec('/', 1).to_int();
+ String what = name.get_slicec('/', 2);
+ if (what == "shape") {
+ if (idx >= shapes.size())
add_shape(RefPtr(p_value));
else
- set_shape(idx,RefPtr(p_value));
- } else if (what=="transform")
- set_shape_transform(idx,p_value);
- else if (what=="trigger")
- set_shape_as_trigger(idx,p_value);
+ set_shape(idx, RefPtr(p_value));
+ } else if (what == "transform")
+ set_shape_transform(idx, p_value);
+ else if (what == "trigger")
+ set_shape_as_trigger(idx, p_value);
} else
return false;
return true;
-
-
}
-bool CollisionObject2D::_get(const StringName& p_name,Variant &r_ret) const {
+bool CollisionObject2D::_get(const StringName &p_name, Variant &r_ret) const {
- String name=p_name;
+ String name = p_name;
if (name.begins_with("shapes/")) {
- int idx=name.get_slicec('/',1).to_int();
- String what=name.get_slicec('/',2);
- if (what=="shape")
- r_ret= get_shape(idx);
- else if (what=="transform")
- r_ret= get_shape_transform(idx);
- else if (what=="trigger")
- r_ret= is_shape_set_as_trigger(idx);
+ int idx = name.get_slicec('/', 1).to_int();
+ String what = name.get_slicec('/', 2);
+ if (what == "shape")
+ r_ret = get_shape(idx);
+ else if (what == "transform")
+ r_ret = get_shape_transform(idx);
+ else if (what == "trigger")
+ r_ret = is_shape_set_as_trigger(idx);
} else
return false;
return true;
}
-void CollisionObject2D::_get_property_list( List<PropertyInfo> *p_list) const {
+void CollisionObject2D::_get_property_list(List<PropertyInfo> *p_list) const {
//p_list->push_back( PropertyInfo(Variant::INT,"shape_count",PROPERTY_HINT_RANGE,"0,256,1",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) );
- for(int i=0;i<shapes.size();i++) {
- String path="shapes/"+itos(i)+"/";
- p_list->push_back( PropertyInfo(Variant::OBJECT,path+"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) );
- p_list->push_back( PropertyInfo(Variant::TRANSFORM,path+"transform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) );
- p_list->push_back( PropertyInfo(Variant::BOOL,path+"trigger",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) );
+ for (int i = 0; i < shapes.size(); i++) {
+ String path = "shapes/" + itos(i) + "/";
+ p_list->push_back(PropertyInfo(Variant::OBJECT, path + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM, path + "transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
+ p_list->push_back(PropertyInfo(Variant::BOOL, path + "trigger", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
}
}
-
void CollisionObject2D::set_pickable(bool p_enabled) {
- if (pickable==p_enabled)
+ if (pickable == p_enabled)
return;
- pickable=p_enabled;
+ pickable = p_enabled;
_update_pickable();
}
@@ -183,12 +179,12 @@ bool CollisionObject2D::is_pickable() const {
return pickable;
}
-void CollisionObject2D::_input_event(Node *p_viewport, const InputEvent& p_input_event, int p_shape) {
+void CollisionObject2D::_input_event(Node *p_viewport, const InputEvent &p_input_event, int p_shape) {
if (get_script_instance()) {
- get_script_instance()->call(SceneStringNames::get_singleton()->_input_event,p_viewport,p_input_event,p_shape);
+ get_script_instance()->call(SceneStringNames::get_singleton()->_input_event, p_viewport, p_input_event, p_shape);
}
- emit_signal(SceneStringNames::get_singleton()->input_event,p_viewport,p_input_event,p_shape);
+ emit_signal(SceneStringNames::get_singleton()->input_event, p_viewport, p_input_event, p_shape);
}
void CollisionObject2D::_mouse_enter() {
@@ -199,14 +195,12 @@ void CollisionObject2D::_mouse_enter() {
emit_signal(SceneStringNames::get_singleton()->mouse_enter);
}
-
void CollisionObject2D::_mouse_exit() {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
}
emit_signal(SceneStringNames::get_singleton()->mouse_exit);
-
}
void CollisionObject2D::_update_pickable() {
@@ -214,103 +208,97 @@ void CollisionObject2D::_update_pickable() {
return;
bool pickable = this->pickable && is_inside_tree() && is_visible();
if (area)
- Physics2DServer::get_singleton()->area_set_pickable(rid,pickable);
+ Physics2DServer::get_singleton()->area_set_pickable(rid, pickable);
else
- Physics2DServer::get_singleton()->body_set_pickable(rid,pickable);
+ Physics2DServer::get_singleton()->body_set_pickable(rid, pickable);
}
void CollisionObject2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_shape","shape:Shape2D","transform"),&CollisionObject2D::add_shape,DEFVAL(Matrix32()));
- ObjectTypeDB::bind_method(_MD("get_shape_count"),&CollisionObject2D::get_shape_count);
- ObjectTypeDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject2D::set_shape);
- ObjectTypeDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject2D::set_shape_transform);
- ObjectTypeDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject2D::set_shape_as_trigger);
- ObjectTypeDB::bind_method(_MD("get_shape:Shape2D","shape_idx"),&CollisionObject2D::get_shape);
- ObjectTypeDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject2D::get_shape_transform);
- ObjectTypeDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject2D::is_shape_set_as_trigger);
- ObjectTypeDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject2D::remove_shape);
- ObjectTypeDB::bind_method(_MD("clear_shapes"),&CollisionObject2D::clear_shapes);
- ObjectTypeDB::bind_method(_MD("get_rid"),&CollisionObject2D::get_rid);
-
- ObjectTypeDB::bind_method(_MD("set_pickable","enabled"),&CollisionObject2D::set_pickable);
- ObjectTypeDB::bind_method(_MD("is_pickable"),&CollisionObject2D::is_pickable);
+ ObjectTypeDB::bind_method(_MD("add_shape", "shape:Shape2D", "transform"), &CollisionObject2D::add_shape, DEFVAL(Matrix32()));
+ ObjectTypeDB::bind_method(_MD("get_shape_count"), &CollisionObject2D::get_shape_count);
+ ObjectTypeDB::bind_method(_MD("set_shape", "shape_idx", "shape:Shape"), &CollisionObject2D::set_shape);
+ ObjectTypeDB::bind_method(_MD("set_shape_transform", "shape_idx", "transform"), &CollisionObject2D::set_shape_transform);
+ ObjectTypeDB::bind_method(_MD("set_shape_as_trigger", "shape_idx", "enable"), &CollisionObject2D::set_shape_as_trigger);
+ ObjectTypeDB::bind_method(_MD("get_shape:Shape2D", "shape_idx"), &CollisionObject2D::get_shape);
+ ObjectTypeDB::bind_method(_MD("get_shape_transform", "shape_idx"), &CollisionObject2D::get_shape_transform);
+ ObjectTypeDB::bind_method(_MD("is_shape_set_as_trigger", "shape_idx"), &CollisionObject2D::is_shape_set_as_trigger);
+ ObjectTypeDB::bind_method(_MD("remove_shape", "shape_idx"), &CollisionObject2D::remove_shape);
+ ObjectTypeDB::bind_method(_MD("clear_shapes"), &CollisionObject2D::clear_shapes);
+ ObjectTypeDB::bind_method(_MD("get_rid"), &CollisionObject2D::get_rid);
- BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::OBJECT,"viewport"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::INT,"shape_idx")));
+ ObjectTypeDB::bind_method(_MD("set_pickable", "enabled"), &CollisionObject2D::set_pickable);
+ ObjectTypeDB::bind_method(_MD("is_pickable"), &CollisionObject2D::is_pickable);
- ADD_SIGNAL( MethodInfo("input_event",PropertyInfo(Variant::OBJECT,"viewport"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::INT,"shape_idx")));
- ADD_SIGNAL( MethodInfo("mouse_enter"));
- ADD_SIGNAL( MethodInfo("mouse_exit"));
+ BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "viewport"), PropertyInfo(Variant::INPUT_EVENT, "event"), PropertyInfo(Variant::INT, "shape_idx")));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input/pickable"),_SCS("set_pickable"),_SCS("is_pickable"));
+ ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "viewport"), PropertyInfo(Variant::INPUT_EVENT, "event"), PropertyInfo(Variant::INT, "shape_idx")));
+ ADD_SIGNAL(MethodInfo("mouse_enter"));
+ ADD_SIGNAL(MethodInfo("mouse_exit"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input/pickable"), _SCS("set_pickable"), _SCS("is_pickable"));
}
-
-void CollisionObject2D::add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform) {
+void CollisionObject2D::add_shape(const Ref<Shape2D> &p_shape, const Matrix32 &p_transform) {
ERR_FAIL_COND(p_shape.is_null());
ShapeData sdata;
- sdata.shape=p_shape;
- sdata.xform=p_transform;
- sdata.trigger=false;
+ sdata.shape = p_shape;
+ sdata.xform = p_transform;
+ sdata.trigger = false;
if (area)
- Physics2DServer::get_singleton()->area_add_shape(get_rid(),p_shape->get_rid(),p_transform);
+ Physics2DServer::get_singleton()->area_add_shape(get_rid(), p_shape->get_rid(), p_transform);
else
- Physics2DServer::get_singleton()->body_add_shape(get_rid(),p_shape->get_rid(),p_transform);
+ Physics2DServer::get_singleton()->body_add_shape(get_rid(), p_shape->get_rid(), p_transform);
shapes.push_back(sdata);
-
}
int CollisionObject2D::get_shape_count() const {
return shapes.size();
-
}
-void CollisionObject2D::set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape) {
+void CollisionObject2D::set_shape(int p_shape_idx, const Ref<Shape2D> &p_shape) {
- ERR_FAIL_INDEX(p_shape_idx,shapes.size());
+ ERR_FAIL_INDEX(p_shape_idx, shapes.size());
ERR_FAIL_COND(p_shape.is_null());
- shapes[p_shape_idx].shape=p_shape;
+ shapes[p_shape_idx].shape = p_shape;
if (area)
- Physics2DServer::get_singleton()->area_set_shape(get_rid(),p_shape_idx,p_shape->get_rid());
+ Physics2DServer::get_singleton()->area_set_shape(get_rid(), p_shape_idx, p_shape->get_rid());
else
- Physics2DServer::get_singleton()->body_set_shape(get_rid(),p_shape_idx,p_shape->get_rid());
+ Physics2DServer::get_singleton()->body_set_shape(get_rid(), p_shape_idx, p_shape->get_rid());
-// _update_shapes();
+ // _update_shapes();
}
-void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32& p_transform) {
+void CollisionObject2D::set_shape_transform(int p_shape_idx, const Matrix32 &p_transform) {
- ERR_FAIL_INDEX(p_shape_idx,shapes.size());
- shapes[p_shape_idx].xform=p_transform;
+ ERR_FAIL_INDEX(p_shape_idx, shapes.size());
+ shapes[p_shape_idx].xform = p_transform;
if (area)
- Physics2DServer::get_singleton()->area_set_shape_transform(get_rid(),p_shape_idx,p_transform);
+ Physics2DServer::get_singleton()->area_set_shape_transform(get_rid(), p_shape_idx, p_transform);
else
- Physics2DServer::get_singleton()->body_set_shape_transform(get_rid(),p_shape_idx,p_transform);
+ Physics2DServer::get_singleton()->body_set_shape_transform(get_rid(), p_shape_idx, p_transform);
-// _update_shapes();
+ // _update_shapes();
}
Ref<Shape2D> CollisionObject2D::get_shape(int p_shape_idx) const {
- ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Ref<Shape2D>());
+ ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), Ref<Shape2D>());
return shapes[p_shape_idx].shape;
-
}
Matrix32 CollisionObject2D::get_shape_transform(int p_shape_idx) const {
- ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Matrix32());
+ ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), Matrix32());
return shapes[p_shape_idx].xform;
-
}
void CollisionObject2D::remove_shape(int p_shape_idx) {
- ERR_FAIL_INDEX(p_shape_idx,shapes.size());
+ ERR_FAIL_INDEX(p_shape_idx, shapes.size());
shapes.remove(p_shape_idx);
_update_shapes();
@@ -318,18 +306,17 @@ void CollisionObject2D::remove_shape(int p_shape_idx) {
void CollisionObject2D::set_shape_as_trigger(int p_shape_idx, bool p_trigger) {
- ERR_FAIL_INDEX(p_shape_idx,shapes.size());
- shapes[p_shape_idx].trigger=p_trigger;
+ ERR_FAIL_INDEX(p_shape_idx, shapes.size());
+ shapes[p_shape_idx].trigger = p_trigger;
if (!area && rid.is_valid()) {
- Physics2DServer::get_singleton()->body_set_shape_as_trigger(rid,p_shape_idx,p_trigger);
-
+ Physics2DServer::get_singleton()->body_set_shape_as_trigger(rid, p_shape_idx, p_trigger);
}
}
bool CollisionObject2D::is_shape_set_as_trigger(int p_shape_idx) const {
- ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),false);
+ ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), false);
return shapes[p_shape_idx].trigger;
}
@@ -340,29 +327,22 @@ void CollisionObject2D::clear_shapes() {
_update_shapes();
}
-
CollisionObject2D::CollisionObject2D(RID p_rid, bool p_area) {
- rid=p_rid;
- area=p_area;
- pickable=true;
+ rid = p_rid;
+ area = p_area;
+ pickable = true;
if (p_area) {
- Physics2DServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID());
+ Physics2DServer::get_singleton()->area_attach_object_instance_ID(rid, get_instance_ID());
} else {
- Physics2DServer::get_singleton()->body_attach_object_instance_ID(rid,get_instance_ID());
+ Physics2DServer::get_singleton()->body_attach_object_instance_ID(rid, get_instance_ID());
}
-
-
}
-
CollisionObject2D::CollisionObject2D() {
-
//owner=
-
-
}
CollisionObject2D::~CollisionObject2D() {
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index 78dacc1fd..144394d26 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -34,7 +34,7 @@
class CollisionObject2D : public Node2D {
- OBJ_TYPE( CollisionObject2D, Node2D );
+ OBJ_TYPE(CollisionObject2D, Node2D);
bool area;
RID rid;
@@ -46,42 +46,38 @@ class CollisionObject2D : public Node2D {
bool trigger;
ShapeData() {
- trigger=false;
+ trigger = false;
}
};
-
Vector<ShapeData> shapes;
void _update_shapes();
-friend class CollisionShape2D;
-friend class CollisionPolygon2D;
+ friend class CollisionShape2D;
+ friend class CollisionPolygon2D;
void _update_shapes_from_children();
-protected:
+protected:
CollisionObject2D(RID p_rid, bool p_area);
void _notification(int p_what);
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
void _update_pickable();
-friend class Viewport;
- void _input_event(Node *p_viewport, const InputEvent& p_input_event, int p_shape);
+ friend class Viewport;
+ void _input_event(Node *p_viewport, const InputEvent &p_input_event, int p_shape);
void _mouse_enter();
void _mouse_exit();
public:
-
-
-
- void add_shape(const Ref<Shape2D>& p_shape, const Matrix32& p_transform=Matrix32());
+ void add_shape(const Ref<Shape2D> &p_shape, const Matrix32 &p_transform = Matrix32());
int get_shape_count() const;
- void set_shape(int p_shape_idx, const Ref<Shape2D>& p_shape);
- void set_shape_transform(int p_shape_idx, const Matrix32& p_transform);
+ void set_shape(int p_shape_idx, const Ref<Shape2D> &p_shape);
+ void set_shape_transform(int p_shape_idx, const Matrix32 &p_transform);
Ref<Shape2D> get_shape(int p_shape_idx) const;
Matrix32 get_shape_transform(int p_shape_idx) const;
void set_shape_as_trigger(int p_shape_idx, bool p_trigger);
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index 4bc0f1638..eefb97c84 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -39,57 +39,54 @@ void CollisionPolygon2D::_add_to_collision_object(Object *p_obj) {
CollisionObject2D *co = p_obj->cast_to<CollisionObject2D>();
ERR_FAIL_COND(!co);
- if (polygon.size()==0)
+ if (polygon.size() == 0)
return;
- bool solids=build_mode==BUILD_SOLIDS;
+ bool solids = build_mode == BUILD_SOLIDS;
if (solids) {
//here comes the sun, lalalala
//decompose concave into multiple convex polygons and add them
- Vector< Vector<Vector2> > decomp = _decompose_in_convex();
- shape_from=co->get_shape_count();
- for(int i=0;i<decomp.size();i++) {
- Ref<ConvexPolygonShape2D> convex = memnew( ConvexPolygonShape2D );
+ Vector<Vector<Vector2> > decomp = _decompose_in_convex();
+ shape_from = co->get_shape_count();
+ for (int i = 0; i < decomp.size(); i++) {
+ Ref<ConvexPolygonShape2D> convex = memnew(ConvexPolygonShape2D);
convex->set_points(decomp[i]);
- co->add_shape(convex,get_transform());
+ co->add_shape(convex, get_transform());
if (trigger)
- co->set_shape_as_trigger(co->get_shape_count()-1,true);
-
+ co->set_shape_as_trigger(co->get_shape_count() - 1, true);
}
- shape_to=co->get_shape_count()-1;
- if (shape_to<shape_from) {
- shape_from=-1;
- shape_to=-1;
+ shape_to = co->get_shape_count() - 1;
+ if (shape_to < shape_from) {
+ shape_from = -1;
+ shape_to = -1;
}
} else {
- Ref<ConcavePolygonShape2D> concave = memnew( ConcavePolygonShape2D );
+ Ref<ConcavePolygonShape2D> concave = memnew(ConcavePolygonShape2D);
DVector<Vector2> segments;
- segments.resize(polygon.size()*2);
- DVector<Vector2>::Write w=segments.write();
+ segments.resize(polygon.size() * 2);
+ DVector<Vector2>::Write w = segments.write();
- for(int i=0;i<polygon.size();i++) {
- w[(i<<1)+0]=polygon[i];
- w[(i<<1)+1]=polygon[(i+1)%polygon.size()];
+ for (int i = 0; i < polygon.size(); i++) {
+ w[(i << 1) + 0] = polygon[i];
+ w[(i << 1) + 1] = polygon[(i + 1) % polygon.size()];
}
- w=DVector<Vector2>::Write();
+ w = DVector<Vector2>::Write();
concave->set_segments(segments);
- co->add_shape(concave,get_transform());
+ co->add_shape(concave, get_transform());
if (trigger)
- co->set_shape_as_trigger(co->get_shape_count()-1,true);
-
- shape_from=co->get_shape_count()-1;
- shape_to=co->get_shape_count()-1;
+ co->set_shape_as_trigger(co->get_shape_count() - 1, true);
+ shape_from = co->get_shape_count() - 1;
+ shape_to = co->get_shape_count() - 1;
}
-
//co->add_shape(shape,get_transform());
}
@@ -106,41 +103,41 @@ void CollisionPolygon2D::_update_parent() {
co->_update_shapes_from_children();
}
-Vector< Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() {
+Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() {
- Vector< Vector<Vector2> > decomp;
+ Vector<Vector<Vector2> > decomp;
#if 0
//fast but imprecise triangulator, gave us problems
decomp = Geometry::decompose_polygon(polygon);
#else
- List<TriangulatorPoly> in_poly,out_poly;
+ List<TriangulatorPoly> in_poly, out_poly;
TriangulatorPoly inp;
inp.Init(polygon.size());
- for(int i=0;i<polygon.size();i++) {
- inp.GetPoint(i)=polygon[i];
+ for (int i = 0; i < polygon.size(); i++) {
+ inp.GetPoint(i) = polygon[i];
}
inp.SetOrientation(TRIANGULATOR_CCW);
in_poly.push_back(inp);
TriangulatorPartition tpart;
- if (tpart.ConvexPartition_HM(&in_poly,&out_poly)==0) { //failed!
+ if (tpart.ConvexPartition_HM(&in_poly, &out_poly) == 0) { //failed!
ERR_PRINT("Convex decomposing failed!");
return decomp;
}
decomp.resize(out_poly.size());
- int idx=0;
+ int idx = 0;
- for(List<TriangulatorPoly>::Element*I = out_poly.front();I;I=I->next()) {
+ for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) {
- TriangulatorPoly& tp = I->get();
+ TriangulatorPoly &tp = I->get();
decomp[idx].resize(tp.GetNumPoints());
- for(int i=0;i<tp.GetNumPoints();i++) {
+ for (int i = 0; i < tp.GetNumPoints(); i++) {
- decomp[idx][i]=tp.GetPoint(i);
+ decomp[idx][i] = tp.GetPoint(i);
}
idx++;
@@ -153,20 +150,19 @@ Vector< Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() {
void CollisionPolygon2D::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- unparenting=false;
- can_update_body=get_tree()->is_editor_hint();
+ unparenting = false;
+ can_update_body = get_tree()->is_editor_hint();
if (!get_tree()->is_editor_hint()) {
//display above all else
set_z_as_relative(false);
- set_z(VS::CANVAS_ITEM_Z_MAX-1);
+ set_z(VS::CANVAS_ITEM_Z_MAX - 1);
}
} break;
case NOTIFICATION_EXIT_TREE: {
- can_update_body=false;
+ can_update_body = false;
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
@@ -174,14 +170,13 @@ void CollisionPolygon2D::_notification(int p_what) {
break;
if (can_update_body) {
_update_parent();
- } else if (shape_from>=0 && shape_to>=0) {
+ } else if (shape_from >= 0 && shape_to >= 0) {
CollisionObject2D *co = get_parent()->cast_to<CollisionObject2D>();
- for(int i=shape_from;i<=shape_to;i++) {
- co->set_shape_transform(i,get_transform());
+ for (int i = shape_from; i <= shape_to; i++) {
+ co->set_shape_transform(i, get_transform());
}
}
-
} break;
case NOTIFICATION_DRAW: {
@@ -190,55 +185,52 @@ void CollisionPolygon2D::_notification(int p_what) {
break;
}
-
- for(int i=0;i<polygon.size();i++) {
+ for (int i = 0; i < polygon.size(); i++) {
Vector2 p = polygon[i];
- Vector2 n = polygon[(i+1)%polygon.size()];
- draw_line(p,n,Color(0.9,0.2,0.0,0.8),3);
+ Vector2 n = polygon[(i + 1) % polygon.size()];
+ draw_line(p, n, Color(0.9, 0.2, 0.0, 0.8), 3);
}
#define DEBUG_DECOMPOSE
-#if defined(TOOLS_ENABLED) && defined (DEBUG_DECOMPOSE)
+#if defined(TOOLS_ENABLED) && defined(DEBUG_DECOMPOSE)
- Vector< Vector<Vector2> > decomp = _decompose_in_convex();
+ Vector<Vector<Vector2> > decomp = _decompose_in_convex();
- Color c(0.4,0.9,0.1);
- for(int i=0;i<decomp.size();i++) {
+ Color c(0.4, 0.9, 0.1);
+ for (int i = 0; i < decomp.size(); i++) {
- c.set_hsv( Math::fmod(c.get_h() + 0.738,1),c.get_s(),c.get_v(),0.5);
- draw_colored_polygon(decomp[i],c);
+ c.set_hsv(Math::fmod(c.get_h() + 0.738, 1), c.get_s(), c.get_v(), 0.5);
+ draw_colored_polygon(decomp[i], c);
}
#else
- draw_colored_polygon(polygon,get_tree()->get_debug_collisions_color());
+ draw_colored_polygon(polygon, get_tree()->get_debug_collisions_color());
#endif
-
} break;
case NOTIFICATION_UNPARENTED: {
unparenting = true;
_update_parent();
} break;
-
}
}
-void CollisionPolygon2D::set_polygon(const Vector<Point2>& p_polygon) {
+void CollisionPolygon2D::set_polygon(const Vector<Point2> &p_polygon) {
- polygon=p_polygon;
+ polygon = p_polygon;
if (can_update_body) {
- for(int i=0;i<polygon.size();i++) {
- if (i==0)
- aabb=Rect2(polygon[i],Size2());
+ for (int i = 0; i < polygon.size(); i++) {
+ if (i == 0)
+ aabb = Rect2(polygon[i], Size2());
else
aabb.expand_to(polygon[i]);
}
- if (aabb==Rect2()) {
+ if (aabb == Rect2()) {
- aabb=Rect2(-10,-10,20,20);
+ aabb = Rect2(-10, -10, 20, 20);
} else {
- aabb.pos-=aabb.size*0.3;
- aabb.size+=aabb.size*0.6;
+ aabb.pos -= aabb.size * 0.3;
+ aabb.size += aabb.size * 0.6;
}
_update_parent();
}
@@ -253,12 +245,12 @@ Vector<Point2> CollisionPolygon2D::get_polygon() const {
void CollisionPolygon2D::set_build_mode(BuildMode p_mode) {
- ERR_FAIL_INDEX(p_mode,2);
- build_mode=p_mode;
+ ERR_FAIL_INDEX(p_mode, 2);
+ build_mode = p_mode;
_update_parent();
}
-CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const{
+CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const {
return build_mode;
}
@@ -270,32 +262,30 @@ Rect2 CollisionPolygon2D::get_item_rect() const {
void CollisionPolygon2D::set_trigger(bool p_trigger) {
- trigger=p_trigger;
+ trigger = p_trigger;
_update_parent();
- if (!can_update_body && is_inside_tree() && shape_from>=0 && shape_to>=0) {
+ if (!can_update_body && is_inside_tree() && shape_from >= 0 && shape_to >= 0) {
CollisionObject2D *co = get_parent()->cast_to<CollisionObject2D>();
- for(int i=shape_from;i<=shape_to;i++) {
- co->set_shape_as_trigger(i,p_trigger);
+ for (int i = shape_from; i <= shape_to; i++) {
+ co->set_shape_as_trigger(i, p_trigger);
}
-
}
}
-bool CollisionPolygon2D::is_trigger() const{
+bool CollisionPolygon2D::is_trigger() const {
return trigger;
}
+void CollisionPolygon2D::_set_shape_range(const Vector2 &p_range) {
-void CollisionPolygon2D::_set_shape_range(const Vector2& p_range) {
-
- shape_from=p_range.x;
- shape_to=p_range.y;
+ shape_from = p_range.x;
+ shape_to = p_range.y;
}
Vector2 CollisionPolygon2D::_get_shape_range() const {
- return Vector2(shape_from,shape_to);
+ return Vector2(shape_from, shape_to);
}
String CollisionPolygon2D::get_configuration_warning() const {
@@ -306,7 +296,6 @@ String CollisionPolygon2D::get_configuration_warning() const {
if (polygon.empty()) {
return TTR("An empty CollisionPolygon2D has no effect on collision.");
-
}
return String();
@@ -314,38 +303,36 @@ String CollisionPolygon2D::get_configuration_warning() const {
void CollisionPolygon2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon2D::_add_to_collision_object);
- ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon2D::set_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon"),&CollisionPolygon2D::get_polygon);
-
- ObjectTypeDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon2D::set_build_mode);
- ObjectTypeDB::bind_method(_MD("get_build_mode"),&CollisionPolygon2D::get_build_mode);
+ ObjectTypeDB::bind_method(_MD("_add_to_collision_object"), &CollisionPolygon2D::_add_to_collision_object);
+ ObjectTypeDB::bind_method(_MD("set_polygon", "polygon"), &CollisionPolygon2D::set_polygon);
+ ObjectTypeDB::bind_method(_MD("get_polygon"), &CollisionPolygon2D::get_polygon);
- ObjectTypeDB::bind_method(_MD("set_trigger","trigger"),&CollisionPolygon2D::set_trigger);
- ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionPolygon2D::is_trigger);
+ ObjectTypeDB::bind_method(_MD("set_build_mode", "build_mode"), &CollisionPolygon2D::set_build_mode);
+ ObjectTypeDB::bind_method(_MD("get_build_mode"), &CollisionPolygon2D::get_build_mode);
- ObjectTypeDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon2D::_set_shape_range);
- ObjectTypeDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon2D::_get_shape_range);
+ ObjectTypeDB::bind_method(_MD("set_trigger", "trigger"), &CollisionPolygon2D::set_trigger);
+ ObjectTypeDB::bind_method(_MD("is_trigger"), &CollisionPolygon2D::is_trigger);
- ObjectTypeDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon2D::get_collision_object_first_shape);
- ObjectTypeDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon2D::get_collision_object_last_shape);
+ ObjectTypeDB::bind_method(_MD("_set_shape_range", "shape_range"), &CollisionPolygon2D::_set_shape_range);
+ ObjectTypeDB::bind_method(_MD("_get_shape_range"), &CollisionPolygon2D::_get_shape_range);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Segments"),_SCS("set_build_mode"),_SCS("get_build_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"shape_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_shape_range"),_SCS("_get_shape_range"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
+ ObjectTypeDB::bind_method(_MD("get_collision_object_first_shape"), &CollisionPolygon2D::get_collision_object_first_shape);
+ ObjectTypeDB::bind_method(_MD("get_collision_object_last_shape"), &CollisionPolygon2D::get_collision_object_last_shape);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "build_mode", PROPERTY_HINT_ENUM, "Solids,Segments"), _SCS("set_build_mode"), _SCS("get_build_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "polygon"), _SCS("set_polygon"), _SCS("get_polygon"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "shape_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_shape_range"), _SCS("_get_shape_range"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trigger"), _SCS("set_trigger"), _SCS("is_trigger"));
}
CollisionPolygon2D::CollisionPolygon2D() {
- aabb=Rect2(-10,-10,20,20);
- build_mode=BUILD_SOLIDS;
- trigger=false;
- unparenting=false;
- shape_from=-1;
- shape_to=-1;
- can_update_body=false;
+ aabb = Rect2(-10, -10, 20, 20);
+ build_mode = BUILD_SOLIDS;
+ trigger = false;
+ unparenting = false;
+ shape_from = -1;
+ shape_to = -1;
+ can_update_body = false;
set_notify_local_transform(true);
-
}
diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h
index eaec2d1c1..54ec21422 100644
--- a/scene/2d/collision_polygon_2d.h
+++ b/scene/2d/collision_polygon_2d.h
@@ -32,21 +32,17 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/shape_2d.h"
-
-
class CollisionPolygon2D : public Node2D {
- OBJ_TYPE(CollisionPolygon2D,Node2D);
-public:
+ OBJ_TYPE(CollisionPolygon2D, Node2D);
+public:
enum BuildMode {
BUILD_SOLIDS,
BUILD_SEGMENTS,
};
protected:
-
-
Rect2 aabb;
BuildMode build_mode;
Vector<Point2> polygon;
@@ -60,24 +56,23 @@ protected:
int shape_from;
int shape_to;
- void _set_shape_range(const Vector2& p_range);
+ void _set_shape_range(const Vector2 &p_range);
Vector2 _get_shape_range() const;
- Vector< Vector<Vector2> > _decompose_in_convex();
+ Vector<Vector<Vector2> > _decompose_in_convex();
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_trigger(bool p_trigger);
bool is_trigger() const;
void set_build_mode(BuildMode p_mode);
BuildMode get_build_mode() const;
- void set_polygon(const Vector<Point2>& p_polygon);
+ void set_polygon(const Vector<Point2> &p_polygon);
Vector<Point2> get_polygon() const;
virtual Rect2 get_item_rect() const;
@@ -90,6 +85,6 @@ public:
CollisionPolygon2D();
};
-VARIANT_ENUM_CAST( CollisionPolygon2D::BuildMode );
+VARIANT_ENUM_CAST(CollisionPolygon2D::BuildMode);
#endif // COLLISION_POLYGON_2D_H
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index 0ab98acb4..08ff33b01 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -28,14 +28,13 @@
/*************************************************************************/
#include "collision_shape_2d.h"
#include "collision_object_2d.h"
-#include "scene/resources/segment_shape_2d.h"
-#include "scene/resources/shape_line_2d.h"
-#include "scene/resources/circle_shape_2d.h"
-#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/capsule_shape_2d.h"
-#include "scene/resources/convex_polygon_shape_2d.h"
+#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
-
+#include "scene/resources/convex_polygon_shape_2d.h"
+#include "scene/resources/rectangle_shape_2d.h"
+#include "scene/resources/segment_shape_2d.h"
+#include "scene/resources/shape_line_2d.h"
void CollisionShape2D::_add_to_collision_object(Object *p_obj) {
@@ -44,12 +43,10 @@ void CollisionShape2D::_add_to_collision_object(Object *p_obj) {
CollisionObject2D *co = p_obj->cast_to<CollisionObject2D>();
ERR_FAIL_COND(!co);
- update_shape_index=co->get_shape_count();
- co->add_shape(shape,get_transform());
+ update_shape_index = co->get_shape_count();
+ co->add_shape(shape, get_transform());
if (trigger)
- co->set_shape_as_trigger(co->get_shape_count()-1,true);
-
-
+ co->set_shape_as_trigger(co->get_shape_count() - 1, true);
}
void CollisionShape2D::_shape_changed() {
@@ -60,7 +57,6 @@ void CollisionShape2D::_shape_changed() {
void CollisionShape2D::_update_parent() {
-
Node *parent = get_parent();
if (!parent)
return;
@@ -72,15 +68,15 @@ void CollisionShape2D::_update_parent() {
void CollisionShape2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- unparenting=false;
- can_update_body=get_tree()->is_editor_hint();
+ unparenting = false;
+ can_update_body = get_tree()->is_editor_hint();
if (!get_tree()->is_editor_hint()) {
//display above all else
set_z_as_relative(false);
- set_z(VS::CANVAS_ITEM_Z_MAX-1);
+ set_z(VS::CANVAS_ITEM_Z_MAX - 1);
}
} break;
@@ -90,18 +86,17 @@ void CollisionShape2D::_notification(int p_what) {
break;
if (can_update_body) {
_update_parent();
- } else if (update_shape_index>=0){
+ } else if (update_shape_index >= 0) {
CollisionObject2D *co = get_parent()->cast_to<CollisionObject2D>();
if (co) {
- co->set_shape_transform(update_shape_index,get_transform());
+ co->set_shape_transform(update_shape_index, get_transform());
}
-
}
} break;
case NOTIFICATION_EXIT_TREE: {
- can_update_body=false;
+ can_update_body = false;
} break;
/*
@@ -122,16 +117,13 @@ void CollisionShape2D::_notification(int p_what) {
break;
}
- rect=Rect2();
-
-
-
- Color draw_col=get_tree()->get_debug_collisions_color();
- shape->draw(get_canvas_item(),draw_col);
+ rect = Rect2();
+ Color draw_col = get_tree()->get_debug_collisions_color();
+ shape->draw(get_canvas_item(), draw_col);
- rect=shape->get_rect();
- rect=rect.grow(3);
+ rect = shape->get_rect();
+ rect = rect.grow(3);
} break;
case NOTIFICATION_UNPARENTED: {
@@ -139,25 +131,24 @@ void CollisionShape2D::_notification(int p_what) {
_update_parent();
} break;
}
-
}
-void CollisionShape2D::set_shape(const Ref<Shape2D>& p_shape) {
+void CollisionShape2D::set_shape(const Ref<Shape2D> &p_shape) {
if (shape.is_valid())
- shape->disconnect("changed",this,"_shape_changed");
- shape=p_shape;
+ shape->disconnect("changed", this, "_shape_changed");
+ shape = p_shape;
update();
if (is_inside_tree() && can_update_body)
_update_parent();
- if (is_inside_tree() && !can_update_body && update_shape_index>=0) {
+ if (is_inside_tree() && !can_update_body && update_shape_index >= 0) {
CollisionObject2D *co = get_parent()->cast_to<CollisionObject2D>();
if (co) {
- co->set_shape(update_shape_index,p_shape);
+ co->set_shape(update_shape_index, p_shape);
}
}
if (shape.is_valid())
- shape->connect("changed",this,"_shape_changed");
+ shape->connect("changed", this, "_shape_changed");
update_configuration_warning();
}
@@ -174,30 +165,28 @@ Rect2 CollisionShape2D::get_item_rect() const {
void CollisionShape2D::set_trigger(bool p_trigger) {
- trigger=p_trigger;
+ trigger = p_trigger;
if (can_update_body) {
_update_parent();
- } else if (is_inside_tree() && update_shape_index>=0){
+ } else if (is_inside_tree() && update_shape_index >= 0) {
CollisionObject2D *co = get_parent()->cast_to<CollisionObject2D>();
if (co) {
- co->set_shape_as_trigger(update_shape_index,p_trigger);
+ co->set_shape_as_trigger(update_shape_index, p_trigger);
}
}
}
-bool CollisionShape2D::is_trigger() const{
+bool CollisionShape2D::is_trigger() const {
return trigger;
}
-
void CollisionShape2D::_set_update_shape_index(int p_index) {
-
- update_shape_index=p_index;
+ update_shape_index = p_index;
}
-int CollisionShape2D::_get_update_shape_index() const{
+int CollisionShape2D::_get_update_shape_index() const {
return update_shape_index;
}
@@ -215,33 +204,31 @@ String CollisionShape2D::get_configuration_warning() const {
return String();
}
-
void CollisionShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shape","shape"),&CollisionShape2D::set_shape);
- ObjectTypeDB::bind_method(_MD("get_shape"),&CollisionShape2D::get_shape);
- ObjectTypeDB::bind_method(_MD("_shape_changed"),&CollisionShape2D::_shape_changed);
- ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape2D::_add_to_collision_object);
- ObjectTypeDB::bind_method(_MD("set_trigger","enable"),&CollisionShape2D::set_trigger);
- ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionShape2D::is_trigger);
-
- ObjectTypeDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape2D::_set_update_shape_index);
- ObjectTypeDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape2D::_get_update_shape_index);
+ ObjectTypeDB::bind_method(_MD("set_shape", "shape"), &CollisionShape2D::set_shape);
+ ObjectTypeDB::bind_method(_MD("get_shape"), &CollisionShape2D::get_shape);
+ ObjectTypeDB::bind_method(_MD("_shape_changed"), &CollisionShape2D::_shape_changed);
+ ObjectTypeDB::bind_method(_MD("_add_to_collision_object"), &CollisionShape2D::_add_to_collision_object);
+ ObjectTypeDB::bind_method(_MD("set_trigger", "enable"), &CollisionShape2D::set_trigger);
+ ObjectTypeDB::bind_method(_MD("is_trigger"), &CollisionShape2D::is_trigger);
- ObjectTypeDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape2D::get_collision_object_shape_index);
+ ObjectTypeDB::bind_method(_MD("_set_update_shape_index", "index"), &CollisionShape2D::_set_update_shape_index);
+ ObjectTypeDB::bind_method(_MD("_get_update_shape_index"), &CollisionShape2D::_get_update_shape_index);
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D"),_SCS("set_shape"),_SCS("get_shape"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "_update_shape_index", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR), _SCS("_set_update_shape_index"), _SCS("_get_update_shape_index"));
+ ObjectTypeDB::bind_method(_MD("get_collision_object_shape_index"), &CollisionShape2D::get_collision_object_shape_index);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D"), _SCS("set_shape"), _SCS("get_shape"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trigger"), _SCS("set_trigger"), _SCS("is_trigger"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "_update_shape_index", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_update_shape_index"), _SCS("_get_update_shape_index"));
}
CollisionShape2D::CollisionShape2D() {
- rect=Rect2(-Point2(10,10),Point2(20,20));
+ rect = Rect2(-Point2(10, 10), Point2(20, 20));
set_notify_local_transform(true);
- trigger=false;
+ trigger = false;
unparenting = false;
can_update_body = false;
- update_shape_index=-1;
+ update_shape_index = -1;
}
diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h
index 13ece8243..606a830e3 100644
--- a/scene/2d/collision_shape_2d.h
+++ b/scene/2d/collision_shape_2d.h
@@ -34,7 +34,7 @@
class CollisionShape2D : public Node2D {
- OBJ_TYPE(CollisionShape2D,Node2D);
+ OBJ_TYPE(CollisionShape2D, Node2D);
Ref<Shape2D> shape;
Rect2 rect;
bool trigger;
@@ -47,15 +47,14 @@ class CollisionShape2D : public Node2D {
int _get_update_shape_index() const;
protected:
-
void _update_parent();
void _notification(int p_what);
static void _bind_methods();
void _add_to_collision_object(Object *p_obj);
-public:
- void set_shape(const Ref<Shape2D>& p_shape);
+public:
+ void set_shape(const Ref<Shape2D> &p_shape);
Ref<Shape2D> get_shape() const;
virtual Rect2 get_item_rect() const;
void set_trigger(bool p_trigger);
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 76ba66bfc..d9b5090a9 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "joints_2d.h"
-#include "servers/physics_2d_server.h"
#include "physics_body_2d.h"
+#include "servers/physics_2d_server.h"
void Joint2D::_update_joint() {
@@ -39,49 +39,41 @@ void Joint2D::_update_joint() {
Physics2DServer::get_singleton()->free(joint);
}
- joint=RID();
-
+ joint = RID();
joint = _configure_joint();
- Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint,Physics2DServer::JOINT_PARAM_BIAS,bias);
-
-
+ Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias);
}
+void Joint2D::set_node_a(const NodePath &p_node_a) {
-void Joint2D::set_node_a(const NodePath& p_node_a) {
-
-
- if (a==p_node_a)
+ if (a == p_node_a)
return;
- a=p_node_a;
+ a = p_node_a;
_update_joint();
}
-NodePath Joint2D::get_node_a() const{
+NodePath Joint2D::get_node_a() const {
return a;
}
-void Joint2D::set_node_b(const NodePath& p_node_b){
+void Joint2D::set_node_b(const NodePath &p_node_b) {
- if (b==p_node_b)
+ if (b == p_node_b)
return;
- b=p_node_b;
+ b = p_node_b;
_update_joint();
-
}
-NodePath Joint2D::get_node_b() const{
-
+NodePath Joint2D::get_node_b() const {
return b;
}
-
void Joint2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
_update_joint();
@@ -90,70 +82,61 @@ void Joint2D::_notification(int p_what) {
if (joint.is_valid()) {
Physics2DServer::get_singleton()->free(joint);
- joint=RID();
+ joint = RID();
}
} break;
-
}
-
}
void Joint2D::set_bias(real_t p_bias) {
- bias=p_bias;
+ bias = p_bias;
if (joint.is_valid())
- Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint,Physics2DServer::JOINT_PARAM_BIAS,bias);
+ Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias);
}
-real_t Joint2D::get_bias() const{
-
+real_t Joint2D::get_bias() const {
return bias;
}
void Joint2D::set_exclude_nodes_from_collision(bool p_enable) {
- if (exclude_from_collision==p_enable)
+ if (exclude_from_collision == p_enable)
return;
- exclude_from_collision=p_enable;
+ exclude_from_collision = p_enable;
_update_joint();
}
-bool Joint2D::get_exclude_nodes_from_collision() const{
+bool Joint2D::get_exclude_nodes_from_collision() const {
return exclude_from_collision;
}
-
void Joint2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_node_a", "node"), &Joint2D::set_node_a);
+ ObjectTypeDB::bind_method(_MD("get_node_a"), &Joint2D::get_node_a);
- ObjectTypeDB::bind_method( _MD("set_node_a","node"), &Joint2D::set_node_a );
- ObjectTypeDB::bind_method( _MD("get_node_a"), &Joint2D::get_node_a );
-
- ObjectTypeDB::bind_method( _MD("set_node_b","node"), &Joint2D::set_node_b );
- ObjectTypeDB::bind_method( _MD("get_node_b"), &Joint2D::get_node_b );
+ ObjectTypeDB::bind_method(_MD("set_node_b", "node"), &Joint2D::set_node_b);
+ ObjectTypeDB::bind_method(_MD("get_node_b"), &Joint2D::get_node_b);
- ObjectTypeDB::bind_method( _MD("set_bias","bias"), &Joint2D::set_bias );
- ObjectTypeDB::bind_method( _MD("get_bias"), &Joint2D::get_bias );
-
- ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision );
- ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision );
-
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias/bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") );
+ ObjectTypeDB::bind_method(_MD("set_bias", "bias"), &Joint2D::set_bias);
+ ObjectTypeDB::bind_method(_MD("get_bias"), &Joint2D::get_bias);
+ ObjectTypeDB::bind_method(_MD("set_exclude_nodes_from_collision", "enable"), &Joint2D::set_exclude_nodes_from_collision);
+ ObjectTypeDB::bind_method(_MD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision);
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_a"), _SCS("set_node_a"), _SCS("get_node_a"));
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_b"), _SCS("set_node_b"), _SCS("get_node_b"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bias/bias", PROPERTY_HINT_RANGE, "0,0.9,0.001"), _SCS("set_bias"), _SCS("get_bias"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"), _SCS("get_exclude_nodes_from_collision"));
}
-
-
Joint2D::Joint2D() {
- bias=0;
- exclude_from_collision=true;
+ bias = 0;
+ exclude_from_collision = true;
}
///////////////////////////////////////////////////////////////////////////////
@@ -162,7 +145,7 @@ Joint2D::Joint2D() {
void PinJoint2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
@@ -172,50 +155,46 @@ void PinJoint2D::_notification(int p_what) {
break;
}
-
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,-10),Point2(0,+10),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(-10, 0), Point2(+10, 0), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(0, -10), Point2(0, +10), Color(0.7, 0.6, 0.0, 0.5), 3);
} break;
}
-
}
RID PinJoint2D::_configure_joint() {
- Node *node_a = has_node( get_node_a() ) ? get_node( get_node_a() ) : (Node*)NULL;
- Node *node_b = has_node( get_node_b() ) ? get_node( get_node_b() ) : (Node*)NULL;
+ Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
+ Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
if (!node_a && !node_b)
return RID();
- PhysicsBody2D *body_a=node_a ? node_a->cast_to<PhysicsBody2D>() : (PhysicsBody2D*)NULL;
- PhysicsBody2D *body_b=node_b ? node_b->cast_to<PhysicsBody2D>() : (PhysicsBody2D*)NULL;
+ PhysicsBody2D *body_a = node_a ? node_a->cast_to<PhysicsBody2D>() : (PhysicsBody2D *)NULL;
+ PhysicsBody2D *body_b = node_b ? node_b->cast_to<PhysicsBody2D>() : (PhysicsBody2D *)NULL;
if (!body_a && !body_b)
return RID();
if (!body_a) {
- SWAP(body_a,body_b);
+ SWAP(body_a, body_b);
} else if (body_b) {
//add a collision exception between both
if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(), body_b->get_rid());
}
- RID pj = Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(),body_a->get_rid(),body_b?body_b->get_rid():RID());
+ RID pj = Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(), body_a->get_rid(), body_b ? body_b->get_rid() : RID());
Physics2DServer::get_singleton()->pin_joint_set_param(pj, Physics2DServer::PIN_JOINT_SOFTNESS, softness);
return pj;
-
}
void PinJoint2D::set_softness(real_t p_softness) {
- softness=p_softness;
+ softness = p_softness;
update();
if (get_joint().is_valid())
Physics2DServer::get_singleton()->pin_joint_set_param(get_joint(), Physics2DServer::PIN_JOINT_SOFTNESS, p_softness);
-
}
real_t PinJoint2D::get_softness() const {
@@ -225,10 +204,10 @@ real_t PinJoint2D::get_softness() const {
void PinJoint2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_softness","softness"), &PinJoint2D::set_softness);
+ ObjectTypeDB::bind_method(_MD("set_softness", "softness"), &PinJoint2D::set_softness);
ObjectTypeDB::bind_method(_MD("get_softness"), &PinJoint2D::get_softness);
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE,"0.00,16,0.01"), _SCS("set_softness"), _SCS("get_softness"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE, "0.00,16,0.01"), _SCS("set_softness"), _SCS("get_softness"));
}
PinJoint2D::PinJoint2D() {
@@ -236,16 +215,13 @@ PinJoint2D::PinJoint2D() {
softness = 0;
}
-
-
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-
void GrooveJoint2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
break;
@@ -254,48 +230,44 @@ void GrooveJoint2D::_notification(int p_what) {
break;
}
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,length),Point2(+10,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,0),Point2(0,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,initial_offset),Point2(+10,initial_offset),Color(0.8,0.8,0.9,0.5),5);
+ draw_line(Point2(-10, 0), Point2(+10, 0), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(-10, length), Point2(+10, length), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(0, 0), Point2(0, length), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(-10, initial_offset), Point2(+10, initial_offset), Color(0.8, 0.8, 0.9, 0.5), 5);
} break;
}
}
-RID GrooveJoint2D::_configure_joint(){
+RID GrooveJoint2D::_configure_joint() {
-
- Node *node_a = has_node( get_node_a() ) ? get_node( get_node_a() ) : (Node*)NULL;
- Node *node_b = has_node( get_node_b() ) ? get_node( get_node_b() ) : (Node*)NULL;
+ Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
+ Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
if (!node_a || !node_b)
return RID();
- PhysicsBody2D *body_a=node_a->cast_to<PhysicsBody2D>();
- PhysicsBody2D *body_b=node_b->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_a = node_a->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_b = node_b->cast_to<PhysicsBody2D>();
if (!body_a || !body_b)
return RID();
-
if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(), body_b->get_rid());
Matrix32 gt = get_global_transform();
Vector2 groove_A1 = gt.get_origin();
- Vector2 groove_A2 = gt.xform( Vector2(0,length) );
- Vector2 anchor_B = gt.xform( Vector2(0,initial_offset) );
-
+ Vector2 groove_A2 = gt.xform(Vector2(0, length));
+ Vector2 anchor_B = gt.xform(Vector2(0, initial_offset));
- return Physics2DServer::get_singleton()->groove_joint_create(groove_A1,groove_A2,anchor_B,body_a->get_rid(),body_b->get_rid());
+ return Physics2DServer::get_singleton()->groove_joint_create(groove_A1, groove_A2, anchor_B, body_a->get_rid(), body_b->get_rid());
}
-
void GrooveJoint2D::set_length(real_t p_length) {
- length=p_length;
+ length = p_length;
update();
}
@@ -304,10 +276,9 @@ real_t GrooveJoint2D::get_length() const {
return length;
}
-
void GrooveJoint2D::set_initial_offset(real_t p_initial_offset) {
- initial_offset=p_initial_offset;
+ initial_offset = p_initial_offset;
update();
}
@@ -316,38 +287,30 @@ real_t GrooveJoint2D::get_initial_offset() const {
return initial_offset;
}
-
-
void GrooveJoint2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_length", "length"), &GrooveJoint2D::set_length);
+ ObjectTypeDB::bind_method(_MD("get_length"), &GrooveJoint2D::get_length);
+ ObjectTypeDB::bind_method(_MD("set_initial_offset", "offset"), &GrooveJoint2D::set_initial_offset);
+ ObjectTypeDB::bind_method(_MD("get_initial_offset"), &GrooveJoint2D::get_initial_offset);
- ObjectTypeDB::bind_method(_MD("set_length","length"),&GrooveJoint2D::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&GrooveJoint2D::get_length);
- ObjectTypeDB::bind_method(_MD("set_initial_offset","offset"),&GrooveJoint2D::set_initial_offset);
- ObjectTypeDB::bind_method(_MD("get_initial_offset"),&GrooveJoint2D::get_initial_offset);
-
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_length"),_SCS("get_length"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "initial_offset", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_initial_offset"),_SCS("get_initial_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE, "1,65535,1"), _SCS("set_length"), _SCS("get_length"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "initial_offset", PROPERTY_HINT_EXP_RANGE, "1,65535,1"), _SCS("set_initial_offset"), _SCS("get_initial_offset"));
}
GrooveJoint2D::GrooveJoint2D() {
- length=50;
- initial_offset=25;
+ length = 50;
+ initial_offset = 25;
}
-
-
-
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-
-
void DampedSpringJoint2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
@@ -357,50 +320,48 @@ void DampedSpringJoint2D::_notification(int p_what) {
break;
}
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,length),Point2(+10,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,0),Point2(0,length),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(-10, 0), Point2(+10, 0), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(-10, length), Point2(+10, length), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(0, 0), Point2(0, length), Color(0.7, 0.6, 0.0, 0.5), 3);
} break;
}
}
-RID DampedSpringJoint2D::_configure_joint(){
-
+RID DampedSpringJoint2D::_configure_joint() {
- Node *node_a = has_node( get_node_a() ) ? get_node( get_node_a() ) : (Node*)NULL;
- Node *node_b = has_node( get_node_b() ) ? get_node( get_node_b() ) : (Node*)NULL;
+ Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
+ Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
if (!node_a || !node_b)
return RID();
- PhysicsBody2D *body_a=node_a->cast_to<PhysicsBody2D>();
- PhysicsBody2D *body_b=node_b->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_a = node_a->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_b = node_b->cast_to<PhysicsBody2D>();
if (!body_a || !body_b)
return RID();
if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(), body_b->get_rid());
Matrix32 gt = get_global_transform();
Vector2 anchor_A = gt.get_origin();
- Vector2 anchor_B = gt.xform( Vector2(0,length) );
+ Vector2 anchor_B = gt.xform(Vector2(0, length));
- RID dsj = Physics2DServer::get_singleton()->damped_spring_joint_create(anchor_A,anchor_B,body_a->get_rid(),body_b->get_rid());
+ RID dsj = Physics2DServer::get_singleton()->damped_spring_joint_create(anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid());
if (rest_length)
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj,Physics2DServer::DAMPED_STRING_REST_LENGTH,rest_length);
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj,Physics2DServer::DAMPED_STRING_STIFFNESS,stiffness);
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj,Physics2DServer::DAMPED_STRING_DAMPING,damping);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_REST_LENGTH, rest_length);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_STIFFNESS, stiffness);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_DAMPING, damping);
return dsj;
}
-
void DampedSpringJoint2D::set_length(real_t p_length) {
- length=p_length;
+ length = p_length;
update();
}
@@ -411,11 +372,10 @@ real_t DampedSpringJoint2D::get_length() const {
void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) {
- rest_length=p_rest_length;
+ rest_length = p_rest_length;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(),Physics2DServer::DAMPED_STRING_REST_LENGTH,p_rest_length?p_rest_length:length);
-
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
}
real_t DampedSpringJoint2D::get_rest_length() const {
@@ -425,10 +385,10 @@ real_t DampedSpringJoint2D::get_rest_length() const {
void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) {
- stiffness=p_stiffness;
+ stiffness = p_stiffness;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(),Physics2DServer::DAMPED_STRING_STIFFNESS,p_stiffness);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_STIFFNESS, p_stiffness);
}
real_t DampedSpringJoint2D::get_stiffness() const {
@@ -438,10 +398,10 @@ real_t DampedSpringJoint2D::get_stiffness() const {
void DampedSpringJoint2D::set_damping(real_t p_damping) {
- damping=p_damping;
+ damping = p_damping;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(),Physics2DServer::DAMPED_STRING_DAMPING,p_damping);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_DAMPING, p_damping);
}
real_t DampedSpringJoint2D::get_damping() const {
@@ -449,30 +409,27 @@ real_t DampedSpringJoint2D::get_damping() const {
return damping;
}
-
void DampedSpringJoint2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_length", "length"), &DampedSpringJoint2D::set_length);
+ ObjectTypeDB::bind_method(_MD("get_length"), &DampedSpringJoint2D::get_length);
+ ObjectTypeDB::bind_method(_MD("set_rest_length", "rest_length"), &DampedSpringJoint2D::set_rest_length);
+ ObjectTypeDB::bind_method(_MD("get_rest_length"), &DampedSpringJoint2D::get_rest_length);
+ ObjectTypeDB::bind_method(_MD("set_stiffness", "stiffness"), &DampedSpringJoint2D::set_stiffness);
+ ObjectTypeDB::bind_method(_MD("get_stiffness"), &DampedSpringJoint2D::get_stiffness);
+ ObjectTypeDB::bind_method(_MD("set_damping", "damping"), &DampedSpringJoint2D::set_damping);
+ ObjectTypeDB::bind_method(_MD("get_damping"), &DampedSpringJoint2D::get_damping);
- ObjectTypeDB::bind_method(_MD("set_length","length"),&DampedSpringJoint2D::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&DampedSpringJoint2D::get_length);
- ObjectTypeDB::bind_method(_MD("set_rest_length","rest_length"),&DampedSpringJoint2D::set_rest_length);
- ObjectTypeDB::bind_method(_MD("get_rest_length"),&DampedSpringJoint2D::get_rest_length);
- ObjectTypeDB::bind_method(_MD("set_stiffness","stiffness"),&DampedSpringJoint2D::set_stiffness);
- ObjectTypeDB::bind_method(_MD("get_stiffness"),&DampedSpringJoint2D::get_stiffness);
- ObjectTypeDB::bind_method(_MD("set_damping","damping"),&DampedSpringJoint2D::set_damping);
- ObjectTypeDB::bind_method(_MD("get_damping"),&DampedSpringJoint2D::get_damping);
-
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), _SCS("set_length"),_SCS("get_length"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "rest_length", PROPERTY_HINT_EXP_RANGE,"0,65535,1"), _SCS("set_rest_length"),_SCS("get_rest_length"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "stiffness", PROPERTY_HINT_EXP_RANGE,"0.1,64,0.1"), _SCS("set_stiffness"),_SCS("get_stiffness"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "damping", PROPERTY_HINT_EXP_RANGE,"0.01,16,0.01"), _SCS("set_damping"),_SCS("get_damping"));
-
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE, "1,65535,1"), _SCS("set_length"), _SCS("get_length"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "rest_length", PROPERTY_HINT_EXP_RANGE, "0,65535,1"), _SCS("set_rest_length"), _SCS("get_rest_length"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stiffness", PROPERTY_HINT_EXP_RANGE, "0.1,64,0.1"), _SCS("set_stiffness"), _SCS("get_stiffness"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "damping", PROPERTY_HINT_EXP_RANGE, "0.01,16,0.01"), _SCS("set_damping"), _SCS("get_damping"));
}
DampedSpringJoint2D::DampedSpringJoint2D() {
- length=50;
- rest_length=0;
- stiffness=20;
- damping=1;
+ length = 50;
+ rest_length = 0;
+ stiffness = 20;
+ damping = 1;
}
diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h
index d91e477bd..fde42c6ae 100644
--- a/scene/2d/joints_2d.h
+++ b/scene/2d/joints_2d.h
@@ -29,12 +29,11 @@
#ifndef JOINTS_2D_H
#define JOINTS_2D_H
-
#include "node_2d.h"
class Joint2D : public Node2D {
- OBJ_TYPE(Joint2D,Node2D);
+ OBJ_TYPE(Joint2D, Node2D);
RID joint;
@@ -44,21 +43,19 @@ class Joint2D : public Node2D {
bool exclude_from_collision;
-
protected:
-
void _update_joint();
void _notification(int p_what);
- virtual RID _configure_joint()=0;
+ virtual RID _configure_joint() = 0;
static void _bind_methods();
-public:
- void set_node_a(const NodePath& p_node_a);
+public:
+ void set_node_a(const NodePath &p_node_a);
NodePath get_node_a() const;
- void set_node_b(const NodePath& p_node_b);
+ void set_node_b(const NodePath &p_node_b);
NodePath get_node_b() const;
void set_bias(real_t p_bias);
@@ -69,23 +66,20 @@ public:
RID get_joint() const { return joint; }
Joint2D();
-
};
-
class PinJoint2D : public Joint2D {
- OBJ_TYPE(PinJoint2D,Joint2D);
+ OBJ_TYPE(PinJoint2D, Joint2D);
real_t softness;
protected:
-
void _notification(int p_what);
virtual RID _configure_joint();
static void _bind_methods();
-public:
+public:
void set_softness(real_t p_stiffness);
real_t get_softness() const;
@@ -94,18 +88,17 @@ public:
class GrooveJoint2D : public Joint2D {
- OBJ_TYPE(GrooveJoint2D,Joint2D);
+ OBJ_TYPE(GrooveJoint2D, Joint2D);
real_t length;
real_t initial_offset;
protected:
-
void _notification(int p_what);
virtual RID _configure_joint();
static void _bind_methods();
-public:
+public:
void set_length(real_t p_length);
real_t get_length() const;
@@ -117,7 +110,7 @@ public:
class DampedSpringJoint2D : public Joint2D {
- OBJ_TYPE(DampedSpringJoint2D,Joint2D);
+ OBJ_TYPE(DampedSpringJoint2D, Joint2D);
real_t stiffness;
real_t damping;
@@ -125,12 +118,11 @@ class DampedSpringJoint2D : public Joint2D {
real_t length;
protected:
-
void _notification(int p_what);
virtual RID _configure_joint();
static void _bind_methods();
-public:
+public:
void set_length(real_t p_length);
real_t get_length() const;
@@ -146,5 +138,4 @@ public:
DampedSpringJoint2D();
};
-
#endif // JOINTS_2D_H
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index 11ae6c3d3..c4b338530 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -29,10 +29,9 @@
#include "light_2d.h"
#include "servers/visual_server.h"
-void Light2D::edit_set_pivot(const Point2& p_pivot) {
+void Light2D::edit_set_pivot(const Point2 &p_pivot) {
set_texture_offset(p_pivot);
-
}
Point2 Light2D::edit_get_pivot() const {
@@ -47,49 +46,47 @@ bool Light2D::edit_has_pivot() const {
Rect2 Light2D::get_item_rect() const {
if (texture.is_null())
- return Rect2(0,0,1,1);
+ return Rect2(0, 0, 1, 1);
Size2i s;
- s = texture->get_size()*_scale;
- Point2i ofs=texture_offset;
- ofs-=s/2;
+ s = texture->get_size() * _scale;
+ Point2i ofs = texture_offset;
+ ofs -= s / 2;
- if (s==Size2(0,0))
- s=Size2(1,1);
+ if (s == Size2(0, 0))
+ s = Size2(1, 1);
- return Rect2(ofs,s);
+ return Rect2(ofs, s);
}
-
void Light2D::_update_light_visibility() {
if (!is_inside_tree())
return;
- bool editor_ok=true;
+ bool editor_ok = true;
#ifdef TOOLS_ENABLED
if (editor_only) {
if (!get_tree()->is_editor_hint()) {
- editor_ok=false;
+ editor_ok = false;
} else {
- editor_ok = (get_tree()->get_edited_scene_root() && (this==get_tree()->get_edited_scene_root() || get_owner()==get_tree()->get_edited_scene_root()));
+ editor_ok = (get_tree()->get_edited_scene_root() && (this == get_tree()->get_edited_scene_root() || get_owner() == get_tree()->get_edited_scene_root()));
}
}
#else
if (editor_only) {
- editor_ok=false;
+ editor_ok = false;
}
#endif
- VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible() && editor_ok);
+ VS::get_singleton()->canvas_light_set_enabled(canvas_light, enabled && is_visible() && editor_ok);
}
-void Light2D::set_enabled( bool p_enabled) {
+void Light2D::set_enabled(bool p_enabled) {
-
- enabled=p_enabled;
+ enabled = p_enabled;
_update_light_visibility();
}
@@ -100,22 +97,22 @@ bool Light2D::is_enabled() const {
void Light2D::set_editor_only(bool p_editor_only) {
- editor_only=p_editor_only;
+ editor_only = p_editor_only;
_update_light_visibility();
}
-bool Light2D::is_editor_only() const{
+bool Light2D::is_editor_only() const {
return editor_only;
}
-void Light2D::set_texture( const Ref<Texture>& p_texture) {
+void Light2D::set_texture(const Ref<Texture> &p_texture) {
- texture=p_texture;
+ texture = p_texture;
if (texture.is_valid())
- VS::get_singleton()->canvas_light_set_texture(canvas_light,texture->get_rid());
+ VS::get_singleton()->canvas_light_set_texture(canvas_light, texture->get_rid());
else
- VS::get_singleton()->canvas_light_set_texture(canvas_light,RID());
+ VS::get_singleton()->canvas_light_set_texture(canvas_light, RID());
update_configuration_warning();
}
@@ -125,12 +122,11 @@ Ref<Texture> Light2D::get_texture() const {
return texture;
}
-void Light2D::set_texture_offset( const Vector2& p_offset) {
+void Light2D::set_texture_offset(const Vector2 &p_offset) {
- texture_offset=p_offset;
- VS::get_singleton()->canvas_light_set_texture_offset(canvas_light,texture_offset);
+ texture_offset = p_offset;
+ VS::get_singleton()->canvas_light_set_texture_offset(canvas_light, texture_offset);
item_rect_changed();
-
}
Vector2 Light2D::get_texture_offset() const {
@@ -138,108 +134,94 @@ Vector2 Light2D::get_texture_offset() const {
return texture_offset;
}
-void Light2D::set_color( const Color& p_color) {
-
- color=p_color;
- VS::get_singleton()->canvas_light_set_color(canvas_light,color);
+void Light2D::set_color(const Color &p_color) {
+ color = p_color;
+ VS::get_singleton()->canvas_light_set_color(canvas_light, color);
}
Color Light2D::get_color() const {
return color;
}
-void Light2D::set_height( float p_height) {
-
- height=p_height;
- VS::get_singleton()->canvas_light_set_height(canvas_light,height);
+void Light2D::set_height(float p_height) {
+ height = p_height;
+ VS::get_singleton()->canvas_light_set_height(canvas_light, height);
}
-
float Light2D::get_height() const {
return height;
}
-void Light2D::set_energy( float p_energy) {
-
- energy=p_energy;
- VS::get_singleton()->canvas_light_set_energy(canvas_light,energy);
+void Light2D::set_energy(float p_energy) {
+ energy = p_energy;
+ VS::get_singleton()->canvas_light_set_energy(canvas_light, energy);
}
-
float Light2D::get_energy() const {
return energy;
}
+void Light2D::set_texture_scale(float p_scale) {
-
-void Light2D::set_texture_scale( float p_scale) {
-
- _scale=p_scale;
- VS::get_singleton()->canvas_light_set_scale(canvas_light,_scale);
+ _scale = p_scale;
+ VS::get_singleton()->canvas_light_set_scale(canvas_light, _scale);
item_rect_changed();
-
}
-
float Light2D::get_texture_scale() const {
return _scale;
}
-void Light2D::set_z_range_min( int p_min_z) {
-
- z_min=p_min_z;
- VS::get_singleton()->canvas_light_set_z_range(canvas_light,z_min,z_max);
+void Light2D::set_z_range_min(int p_min_z) {
+ z_min = p_min_z;
+ VS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max);
}
int Light2D::get_z_range_min() const {
return z_min;
}
-void Light2D::set_z_range_max( int p_max_z) {
-
- z_max=p_max_z;
- VS::get_singleton()->canvas_light_set_z_range(canvas_light,z_min,z_max);
+void Light2D::set_z_range_max(int p_max_z) {
+ z_max = p_max_z;
+ VS::get_singleton()->canvas_light_set_z_range(canvas_light, z_min, z_max);
}
int Light2D::get_z_range_max() const {
return z_max;
}
-void Light2D::set_layer_range_min( int p_min_layer) {
-
- layer_min=p_min_layer;
- VS::get_singleton()->canvas_light_set_layer_range(canvas_light,layer_min,layer_max);
+void Light2D::set_layer_range_min(int p_min_layer) {
+ layer_min = p_min_layer;
+ VS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max);
}
int Light2D::get_layer_range_min() const {
return layer_min;
}
-void Light2D::set_layer_range_max( int p_max_layer) {
-
- layer_max=p_max_layer;
- VS::get_singleton()->canvas_light_set_layer_range(canvas_light,layer_min,layer_max);
+void Light2D::set_layer_range_max(int p_max_layer) {
+ layer_max = p_max_layer;
+ VS::get_singleton()->canvas_light_set_layer_range(canvas_light, layer_min, layer_max);
}
int Light2D::get_layer_range_max() const {
return layer_max;
}
-void Light2D::set_item_mask( int p_mask) {
-
- item_mask=p_mask;
- VS::get_singleton()->canvas_light_set_item_mask(canvas_light,item_mask);
+void Light2D::set_item_mask(int p_mask) {
+ item_mask = p_mask;
+ VS::get_singleton()->canvas_light_set_item_mask(canvas_light, item_mask);
}
int Light2D::get_item_mask() const {
@@ -247,11 +229,10 @@ int Light2D::get_item_mask() const {
return item_mask;
}
-void Light2D::set_item_shadow_mask( int p_mask) {
-
- item_shadow_mask=p_mask;
- VS::get_singleton()->canvas_light_set_item_shadow_mask(canvas_light,item_shadow_mask);
+void Light2D::set_item_shadow_mask(int p_mask) {
+ item_shadow_mask = p_mask;
+ VS::get_singleton()->canvas_light_set_item_shadow_mask(canvas_light, item_shadow_mask);
}
int Light2D::get_item_shadow_mask() const {
@@ -259,10 +240,10 @@ int Light2D::get_item_shadow_mask() const {
return item_shadow_mask;
}
-void Light2D::set_mode( Mode p_mode ) {
+void Light2D::set_mode(Mode p_mode) {
- mode=p_mode;
- VS::get_singleton()->canvas_light_set_mode(canvas_light,VS::CanvasLightMode(p_mode));
+ mode = p_mode;
+ VS::get_singleton()->canvas_light_set_mode(canvas_light, VS::CanvasLightMode(p_mode));
}
Light2D::Mode Light2D::get_mode() const {
@@ -270,21 +251,20 @@ Light2D::Mode Light2D::get_mode() const {
return mode;
}
-void Light2D::set_shadow_enabled( bool p_enabled) {
-
- shadow=p_enabled;
- VS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light,shadow);
+void Light2D::set_shadow_enabled(bool p_enabled) {
+ shadow = p_enabled;
+ VS::get_singleton()->canvas_light_set_shadow_enabled(canvas_light, shadow);
}
bool Light2D::is_shadow_enabled() const {
return shadow;
}
-void Light2D::set_shadow_buffer_size( int p_size ) {
+void Light2D::set_shadow_buffer_size(int p_size) {
- shadow_buffer_size=p_size;
- VS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light,shadow_buffer_size);
+ shadow_buffer_size = p_size;
+ VS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light, shadow_buffer_size);
}
int Light2D::get_shadow_buffer_size() const {
@@ -292,51 +272,48 @@ int Light2D::get_shadow_buffer_size() const {
return shadow_buffer_size;
}
-void Light2D::set_shadow_esm_multiplier( float p_multiplier) {
+void Light2D::set_shadow_esm_multiplier(float p_multiplier) {
- shadow_esm_multiplier=p_multiplier;
- VS::get_singleton()->canvas_light_set_shadow_esm_multiplier(canvas_light,p_multiplier);
+ shadow_esm_multiplier = p_multiplier;
+ VS::get_singleton()->canvas_light_set_shadow_esm_multiplier(canvas_light, p_multiplier);
}
-float Light2D::get_shadow_esm_multiplier() const{
+float Light2D::get_shadow_esm_multiplier() const {
return shadow_esm_multiplier;
}
-void Light2D::set_shadow_color( const Color& p_shadow_color) {
- shadow_color=p_shadow_color;
- VS::get_singleton()->canvas_light_set_shadow_color(canvas_light,shadow_color);
+void Light2D::set_shadow_color(const Color &p_shadow_color) {
+ shadow_color = p_shadow_color;
+ VS::get_singleton()->canvas_light_set_shadow_color(canvas_light, shadow_color);
}
Color Light2D::get_shadow_color() const {
return shadow_color;
}
-
-
void Light2D::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- VS::get_singleton()->canvas_light_attach_to_canvas( canvas_light, get_canvas() );
+ VS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, get_canvas());
_update_light_visibility();
}
- if (p_what==NOTIFICATION_TRANSFORM_CHANGED) {
+ if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
- VS::get_singleton()->canvas_light_set_transform( canvas_light, get_global_transform());
+ VS::get_singleton()->canvas_light_set_transform(canvas_light, get_global_transform());
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
_update_light_visibility();
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
- VS::get_singleton()->canvas_light_attach_to_canvas( canvas_light, RID() );
+ VS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, RID());
_update_light_visibility();
}
-
}
String Light2D::get_configuration_warning() const {
@@ -348,119 +325,111 @@ String Light2D::get_configuration_warning() const {
return String();
}
-
void Light2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_enabled", "enabled"), &Light2D::set_enabled);
+ ObjectTypeDB::bind_method(_MD("is_enabled"), &Light2D::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&Light2D::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&Light2D::is_enabled);
+ ObjectTypeDB::bind_method(_MD("set_editor_only", "editor_only"), &Light2D::set_editor_only);
+ ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light2D::is_editor_only);
- ObjectTypeDB::bind_method(_MD("set_editor_only","editor_only"), &Light2D::set_editor_only );
- ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light2D::is_editor_only );
+ ObjectTypeDB::bind_method(_MD("set_texture", "texture"), &Light2D::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture"), &Light2D::get_texture);
- ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Light2D::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture"),&Light2D::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_texture_offset", "texture_offset"), &Light2D::set_texture_offset);
+ ObjectTypeDB::bind_method(_MD("get_texture_offset"), &Light2D::get_texture_offset);
- ObjectTypeDB::bind_method(_MD("set_texture_offset","texture_offset"),&Light2D::set_texture_offset);
- ObjectTypeDB::bind_method(_MD("get_texture_offset"),&Light2D::get_texture_offset);
+ ObjectTypeDB::bind_method(_MD("set_color", "color"), &Light2D::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color"), &Light2D::get_color);
- ObjectTypeDB::bind_method(_MD("set_color","color"),&Light2D::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&Light2D::get_color);
+ ObjectTypeDB::bind_method(_MD("set_height", "height"), &Light2D::set_height);
+ ObjectTypeDB::bind_method(_MD("get_height"), &Light2D::get_height);
- ObjectTypeDB::bind_method(_MD("set_height","height"),&Light2D::set_height);
- ObjectTypeDB::bind_method(_MD("get_height"),&Light2D::get_height);
+ ObjectTypeDB::bind_method(_MD("set_energy", "energy"), &Light2D::set_energy);
+ ObjectTypeDB::bind_method(_MD("get_energy"), &Light2D::get_energy);
- ObjectTypeDB::bind_method(_MD("set_energy","energy"),&Light2D::set_energy);
- ObjectTypeDB::bind_method(_MD("get_energy"),&Light2D::get_energy);
+ ObjectTypeDB::bind_method(_MD("set_texture_scale", "texture_scale"), &Light2D::set_texture_scale);
+ ObjectTypeDB::bind_method(_MD("get_texture_scale"), &Light2D::get_texture_scale);
- ObjectTypeDB::bind_method(_MD("set_texture_scale","texture_scale"),&Light2D::set_texture_scale);
- ObjectTypeDB::bind_method(_MD("get_texture_scale"),&Light2D::get_texture_scale);
+ ObjectTypeDB::bind_method(_MD("set_z_range_min", "z"), &Light2D::set_z_range_min);
+ ObjectTypeDB::bind_method(_MD("get_z_range_min"), &Light2D::get_z_range_min);
+ ObjectTypeDB::bind_method(_MD("set_z_range_max", "z"), &Light2D::set_z_range_max);
+ ObjectTypeDB::bind_method(_MD("get_z_range_max"), &Light2D::get_z_range_max);
- ObjectTypeDB::bind_method(_MD("set_z_range_min","z"),&Light2D::set_z_range_min);
- ObjectTypeDB::bind_method(_MD("get_z_range_min"),&Light2D::get_z_range_min);
+ ObjectTypeDB::bind_method(_MD("set_layer_range_min", "layer"), &Light2D::set_layer_range_min);
+ ObjectTypeDB::bind_method(_MD("get_layer_range_min"), &Light2D::get_layer_range_min);
- ObjectTypeDB::bind_method(_MD("set_z_range_max","z"),&Light2D::set_z_range_max);
- ObjectTypeDB::bind_method(_MD("get_z_range_max"),&Light2D::get_z_range_max);
+ ObjectTypeDB::bind_method(_MD("set_layer_range_max", "layer"), &Light2D::set_layer_range_max);
+ ObjectTypeDB::bind_method(_MD("get_layer_range_max"), &Light2D::get_layer_range_max);
- ObjectTypeDB::bind_method(_MD("set_layer_range_min","layer"),&Light2D::set_layer_range_min);
- ObjectTypeDB::bind_method(_MD("get_layer_range_min"),&Light2D::get_layer_range_min);
+ ObjectTypeDB::bind_method(_MD("set_item_mask", "item_mask"), &Light2D::set_item_mask);
+ ObjectTypeDB::bind_method(_MD("get_item_mask"), &Light2D::get_item_mask);
- ObjectTypeDB::bind_method(_MD("set_layer_range_max","layer"),&Light2D::set_layer_range_max);
- ObjectTypeDB::bind_method(_MD("get_layer_range_max"),&Light2D::get_layer_range_max);
+ ObjectTypeDB::bind_method(_MD("set_item_shadow_mask", "item_shadow_mask"), &Light2D::set_item_shadow_mask);
+ ObjectTypeDB::bind_method(_MD("get_item_shadow_mask"), &Light2D::get_item_shadow_mask);
+ ObjectTypeDB::bind_method(_MD("set_mode", "mode"), &Light2D::set_mode);
+ ObjectTypeDB::bind_method(_MD("get_mode"), &Light2D::get_mode);
- ObjectTypeDB::bind_method(_MD("set_item_mask","item_mask"),&Light2D::set_item_mask);
- ObjectTypeDB::bind_method(_MD("get_item_mask"),&Light2D::get_item_mask);
+ ObjectTypeDB::bind_method(_MD("set_shadow_enabled", "enabled"), &Light2D::set_shadow_enabled);
+ ObjectTypeDB::bind_method(_MD("is_shadow_enabled"), &Light2D::is_shadow_enabled);
- ObjectTypeDB::bind_method(_MD("set_item_shadow_mask","item_shadow_mask"),&Light2D::set_item_shadow_mask);
- ObjectTypeDB::bind_method(_MD("get_item_shadow_mask"),&Light2D::get_item_shadow_mask);
+ ObjectTypeDB::bind_method(_MD("set_shadow_buffer_size", "size"), &Light2D::set_shadow_buffer_size);
+ ObjectTypeDB::bind_method(_MD("get_shadow_buffer_size"), &Light2D::get_shadow_buffer_size);
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&Light2D::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&Light2D::get_mode);
+ ObjectTypeDB::bind_method(_MD("set_shadow_esm_multiplier", "multiplier"), &Light2D::set_shadow_esm_multiplier);
+ ObjectTypeDB::bind_method(_MD("get_shadow_esm_multiplier"), &Light2D::get_shadow_esm_multiplier);
- ObjectTypeDB::bind_method(_MD("set_shadow_enabled","enabled"),&Light2D::set_shadow_enabled);
- ObjectTypeDB::bind_method(_MD("is_shadow_enabled"),&Light2D::is_shadow_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_shadow_buffer_size","size"),&Light2D::set_shadow_buffer_size);
- ObjectTypeDB::bind_method(_MD("get_shadow_buffer_size"),&Light2D::get_shadow_buffer_size);
-
- ObjectTypeDB::bind_method(_MD("set_shadow_esm_multiplier","multiplier"),&Light2D::set_shadow_esm_multiplier);
- ObjectTypeDB::bind_method(_MD("get_shadow_esm_multiplier"),&Light2D::get_shadow_esm_multiplier);
-
- ObjectTypeDB::bind_method(_MD("set_shadow_color","shadow_color"),&Light2D::set_shadow_color);
- ObjectTypeDB::bind_method(_MD("get_shadow_color"),&Light2D::get_shadow_color);
-
-
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "editor_only"),_SCS("set_editor_only"),_SCS("is_editor_only"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,50,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"energy",PROPERTY_HINT_RANGE,"0.01,100,0.01"),_SCS("set_energy"),_SCS("get_energy"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Add,Sub,Mix,Mask"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"range/height",PROPERTY_HINT_RANGE,"-100,100,0.1"),_SCS("set_height"),_SCS("get_height"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_min",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_min"),_SCS("get_z_range_min"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_max",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_max"),_SCS("get_layer_range_max"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_mask"),_SCS("get_item_mask"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow/enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"shadow/color"),_SCS("set_shadow_color"),_SCS("get_shadow_color"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/buffer_size",PROPERTY_HINT_RANGE,"32,16384,1"),_SCS("set_shadow_buffer_size"),_SCS("get_shadow_buffer_size"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow/esm_multiplier",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_esm_multiplier"),_SCS("get_shadow_esm_multiplier"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_shadow_mask"),_SCS("get_item_shadow_mask"));
-
- BIND_CONSTANT( MODE_ADD );
- BIND_CONSTANT( MODE_SUB );
- BIND_CONSTANT( MODE_MIX );
- BIND_CONSTANT( MODE_MASK );
+ ObjectTypeDB::bind_method(_MD("set_shadow_color", "shadow_color"), &Light2D::set_shadow_color);
+ ObjectTypeDB::bind_method(_MD("get_shadow_color"), &Light2D::get_shadow_color);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), _SCS("set_editor_only"), _SCS("is_editor_only"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_texture_offset"), _SCS("get_texture_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "scale", PROPERTY_HINT_RANGE, "0.01,50,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), _SCS("set_color"), _SCS("get_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "energy", PROPERTY_HINT_RANGE, "0.01,100,0.01"), _SCS("set_energy"), _SCS("get_energy"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Add,Sub,Mix,Mask"), _SCS("set_mode"), _SCS("get_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "range/height", PROPERTY_HINT_RANGE, "-100,100,0.1"), _SCS("set_height"), _SCS("get_height"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "range/z_min", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), _SCS("set_z_range_min"), _SCS("get_z_range_min"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "range/z_max", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), _SCS("set_z_range_max"), _SCS("get_z_range_max"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "range/layer_min", PROPERTY_HINT_RANGE, "-512,512,1"), _SCS("set_layer_range_min"), _SCS("get_layer_range_min"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "range/layer_max", PROPERTY_HINT_RANGE, "-512,512,1"), _SCS("set_layer_range_max"), _SCS("get_layer_range_max"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "range/item_mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_item_mask"), _SCS("get_item_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow/enabled"), _SCS("set_shadow_enabled"), _SCS("is_shadow_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow/color"), _SCS("set_shadow_color"), _SCS("get_shadow_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow/buffer_size", PROPERTY_HINT_RANGE, "32,16384,1"), _SCS("set_shadow_buffer_size"), _SCS("get_shadow_buffer_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "shadow/esm_multiplier", PROPERTY_HINT_RANGE, "1,4096,0.1"), _SCS("set_shadow_esm_multiplier"), _SCS("get_shadow_esm_multiplier"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow/item_mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_item_shadow_mask"), _SCS("get_item_shadow_mask"));
+ BIND_CONSTANT(MODE_ADD);
+ BIND_CONSTANT(MODE_SUB);
+ BIND_CONSTANT(MODE_MIX);
+ BIND_CONSTANT(MODE_MASK);
}
Light2D::Light2D() {
- canvas_light=VisualServer::get_singleton()->canvas_light_create();
- enabled=true;
- editor_only=false;
- shadow=false;
- color=Color(1,1,1);
- height=0;
- _scale=1.0;
- z_min=-1024;
- z_max=1024;
- layer_min=0;
- layer_max=0;
- item_mask=1;
- item_shadow_mask=1;
- mode=MODE_ADD;
- shadow_buffer_size=2048;
- shadow_esm_multiplier=80;
- energy=1.0;
- shadow_color=Color(0,0,0,0);
-
+ canvas_light = VisualServer::get_singleton()->canvas_light_create();
+ enabled = true;
+ editor_only = false;
+ shadow = false;
+ color = Color(1, 1, 1);
+ height = 0;
+ _scale = 1.0;
+ z_min = -1024;
+ z_max = 1024;
+ layer_min = 0;
+ layer_max = 0;
+ item_mask = 1;
+ item_shadow_mask = 1;
+ mode = MODE_ADD;
+ shadow_buffer_size = 2048;
+ shadow_esm_multiplier = 80;
+ energy = 1.0;
+ shadow_color = Color(0, 0, 0, 0);
}
Light2D::~Light2D() {
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index 7bed13734..93c5326d1 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -33,7 +33,8 @@
class Light2D : public Node2D {
- OBJ_TYPE(Light2D,Node2D);
+ OBJ_TYPE(Light2D, Node2D);
+
public:
enum Mode {
MODE_ADD,
@@ -65,75 +66,73 @@ private:
Vector2 texture_offset;
void _update_light_visibility();
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
-
- virtual void edit_set_pivot(const Point2& p_pivot);
+public:
+ virtual void edit_set_pivot(const Point2 &p_pivot);
virtual Point2 edit_get_pivot() const;
virtual bool edit_has_pivot() const;
- void set_enabled( bool p_enabled);
+ void set_enabled(bool p_enabled);
bool is_enabled() const;
void set_editor_only(bool p_editor_only);
bool is_editor_only() const;
- void set_texture( const Ref<Texture>& p_texture);
+ void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
- void set_texture_offset( const Vector2& p_offset);
+ void set_texture_offset(const Vector2 &p_offset);
Vector2 get_texture_offset() const;
- void set_color( const Color& p_color);
+ void set_color(const Color &p_color);
Color get_color() const;
- void set_height( float p_height);
+ void set_height(float p_height);
float get_height() const;
- void set_energy( float p_energy);
+ void set_energy(float p_energy);
float get_energy() const;
- void set_texture_scale( float p_scale);
+ void set_texture_scale(float p_scale);
float get_texture_scale() const;
- void set_z_range_min( int p_min_z);
+ void set_z_range_min(int p_min_z);
int get_z_range_min() const;
- void set_z_range_max( int p_max_z);
+ void set_z_range_max(int p_max_z);
int get_z_range_max() const;
- void set_layer_range_min( int p_min_layer);
+ void set_layer_range_min(int p_min_layer);
int get_layer_range_min() const;
- void set_layer_range_max( int p_max_layer);
+ void set_layer_range_max(int p_max_layer);
int get_layer_range_max() const;
- void set_item_mask( int p_mask);
+ void set_item_mask(int p_mask);
int get_item_mask() const;
- void set_item_shadow_mask( int p_mask);
+ void set_item_shadow_mask(int p_mask);
int get_item_shadow_mask() const;
- void set_mode( Mode p_mode );
+ void set_mode(Mode p_mode);
Mode get_mode() const;
- void set_shadow_enabled( bool p_enabled);
+ void set_shadow_enabled(bool p_enabled);
bool is_shadow_enabled() const;
- void set_shadow_buffer_size( int p_size );
+ void set_shadow_buffer_size(int p_size);
int get_shadow_buffer_size() const;
- void set_shadow_esm_multiplier( float p_multiplier);
+ void set_shadow_esm_multiplier(float p_multiplier);
float get_shadow_esm_multiplier() const;
- void set_shadow_color( const Color& p_shadow_color);
+ void set_shadow_color(const Color &p_shadow_color);
Color get_shadow_color() const;
-
virtual Rect2 get_item_rect() const;
String get_configuration_warning() const;
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp
index 28044801a..9e4cf3ccf 100644
--- a/scene/2d/light_occluder_2d.cpp
+++ b/scene/2d/light_occluder_2d.cpp
@@ -28,80 +28,74 @@
/*************************************************************************/
#include "light_occluder_2d.h"
+void OccluderPolygon2D::set_polygon(const DVector<Vector2> &p_polygon) {
-void OccluderPolygon2D::set_polygon(const DVector<Vector2>& p_polygon) {
-
- polygon=p_polygon;
- VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,p_polygon,closed);
+ polygon = p_polygon;
+ VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, p_polygon, closed);
emit_changed();
}
-DVector<Vector2> OccluderPolygon2D::get_polygon() const{
+DVector<Vector2> OccluderPolygon2D::get_polygon() const {
return polygon;
}
void OccluderPolygon2D::set_closed(bool p_closed) {
- if (closed==p_closed)
+ if (closed == p_closed)
return;
- closed=p_closed;
+ closed = p_closed;
if (polygon.size())
- VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon,polygon,closed);
+ VS::get_singleton()->canvas_occluder_polygon_set_shape(occ_polygon, polygon, closed);
emit_changed();
}
-bool OccluderPolygon2D::is_closed() const{
+bool OccluderPolygon2D::is_closed() const {
return closed;
}
-void OccluderPolygon2D::set_cull_mode(CullMode p_mode){
+void OccluderPolygon2D::set_cull_mode(CullMode p_mode) {
- cull=p_mode;
- VS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon,VS::CanvasOccluderPolygonCullMode(p_mode));
+ cull = p_mode;
+ VS::get_singleton()->canvas_occluder_polygon_set_cull_mode(occ_polygon, VS::CanvasOccluderPolygonCullMode(p_mode));
}
-OccluderPolygon2D::CullMode OccluderPolygon2D::get_cull_mode() const{
+OccluderPolygon2D::CullMode OccluderPolygon2D::get_cull_mode() const {
return cull;
}
-
RID OccluderPolygon2D::get_rid() const {
return occ_polygon;
}
-
-
void OccluderPolygon2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_closed", "closed"), &OccluderPolygon2D::set_closed);
+ ObjectTypeDB::bind_method(_MD("is_closed"), &OccluderPolygon2D::is_closed);
- ObjectTypeDB::bind_method(_MD("set_closed","closed"),&OccluderPolygon2D::set_closed);
- ObjectTypeDB::bind_method(_MD("is_closed"),&OccluderPolygon2D::is_closed);
+ ObjectTypeDB::bind_method(_MD("set_cull_mode", "cull_mode"), &OccluderPolygon2D::set_cull_mode);
+ ObjectTypeDB::bind_method(_MD("get_cull_mode"), &OccluderPolygon2D::get_cull_mode);
- ObjectTypeDB::bind_method(_MD("set_cull_mode","cull_mode"),&OccluderPolygon2D::set_cull_mode);
- ObjectTypeDB::bind_method(_MD("get_cull_mode"),&OccluderPolygon2D::get_cull_mode);
+ ObjectTypeDB::bind_method(_MD("set_polygon", "polygon"), &OccluderPolygon2D::set_polygon);
+ ObjectTypeDB::bind_method(_MD("get_polygon"), &OccluderPolygon2D::get_polygon);
- ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&OccluderPolygon2D::set_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon"),&OccluderPolygon2D::get_polygon);
-
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"closed"),_SCS("set_closed"),_SCS("is_closed"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cull_mode",PROPERTY_HINT_ENUM,"Disabled,ClockWise,CounterClockWise"),_SCS("set_cull_mode"),_SCS("get_cull_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "closed"), _SCS("set_closed"), _SCS("is_closed"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mode", PROPERTY_HINT_ENUM, "Disabled,ClockWise,CounterClockWise"), _SCS("set_cull_mode"), _SCS("get_cull_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "polygon"), _SCS("set_polygon"), _SCS("get_polygon"));
BIND_CONSTANT(CULL_DISABLED);
BIND_CONSTANT(CULL_CLOCKWISE);
BIND_CONSTANT(CULL_COUNTER_CLOCKWISE);
}
-
OccluderPolygon2D::OccluderPolygon2D() {
- occ_polygon=VS::get_singleton()->canvas_occluder_polygon_create();
- closed=true;
- cull=CULL_DISABLED;
+ occ_polygon = VS::get_singleton()->canvas_occluder_polygon_create();
+ closed = true;
+ cull = CULL_DISABLED;
}
OccluderPolygon2D::~OccluderPolygon2D() {
@@ -116,26 +110,24 @@ void LightOccluder2D::_poly_changed() {
}
#endif
-
void LightOccluder2D::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_CANVAS) {
-
- VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,get_canvas());
- VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ if (p_what == NOTIFICATION_ENTER_CANVAS) {
+ VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, get_canvas());
+ VS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible());
}
- if (p_what==NOTIFICATION_TRANSFORM_CHANGED) {
+ if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
- VS::get_singleton()->canvas_light_occluder_set_transform(occluder,get_global_transform());
+ VS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- VS::get_singleton()->canvas_light_occluder_set_enabled(occluder,is_visible());
+ VS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible());
}
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
if (get_tree()->is_editor_hint()) {
@@ -146,15 +138,15 @@ void LightOccluder2D::_notification(int p_what) {
if (poly.size()) {
if (occluder_polygon->is_closed()) {
Vector<Color> color;
- color.push_back(Color(0,0,0,0.6));
- draw_polygon(Variant(poly),color);
+ color.push_back(Color(0, 0, 0, 0.6));
+ draw_polygon(Variant(poly), color);
} else {
- int ps=poly.size();
+ int ps = poly.size();
DVector<Vector2>::Read r = poly.read();
- for(int i=0;i<ps-1;i++) {
+ for (int i = 0; i < ps - 1; i++) {
- draw_line(r[i],r[i+1],Color(0,0,0,0.6),3);
+ draw_line(r[i], r[i + 1], Color(0, 0, 0, 0.6), 3);
}
}
}
@@ -162,34 +154,30 @@ void LightOccluder2D::_notification(int p_what) {
}
}
+ if (p_what == NOTIFICATION_EXIT_CANVAS) {
- if (p_what==NOTIFICATION_EXIT_CANVAS) {
-
- VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder,RID());
+ VS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID());
}
-
-
}
-void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D>& p_polygon) {
+void LightOccluder2D::set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon) {
#ifdef DEBUG_ENABLED
if (occluder_polygon.is_valid())
- occluder_polygon->disconnect("changed",this,"_poly_changed");
+ occluder_polygon->disconnect("changed", this, "_poly_changed");
#endif
- occluder_polygon=p_polygon;
+ occluder_polygon = p_polygon;
if (occluder_polygon.is_valid())
- VS::get_singleton()->canvas_light_occluder_set_polygon(occluder,occluder_polygon->get_rid());
+ VS::get_singleton()->canvas_light_occluder_set_polygon(occluder, occluder_polygon->get_rid());
else
- VS::get_singleton()->canvas_light_occluder_set_polygon(occluder,RID());
+ VS::get_singleton()->canvas_light_occluder_set_polygon(occluder, RID());
#ifdef DEBUG_ENABLED
if (occluder_polygon.is_valid())
- occluder_polygon->connect("changed",this,"_poly_changed");
+ occluder_polygon->connect("changed", this, "_poly_changed");
update();
#endif
-
}
Ref<OccluderPolygon2D> LightOccluder2D::get_occluder_polygon() const {
@@ -199,23 +187,22 @@ Ref<OccluderPolygon2D> LightOccluder2D::get_occluder_polygon() const {
void LightOccluder2D::set_occluder_light_mask(int p_mask) {
- mask=p_mask;
- VS::get_singleton()->canvas_light_occluder_set_light_mask(occluder,mask);
+ mask = p_mask;
+ VS::get_singleton()->canvas_light_occluder_set_light_mask(occluder, mask);
}
-int LightOccluder2D::get_occluder_light_mask() const{
+int LightOccluder2D::get_occluder_light_mask() const {
return mask;
}
-
String LightOccluder2D::get_configuration_warning() const {
if (!occluder_polygon.is_valid()) {
return TTR("An occluder polygon must be set (or drawn) for this occluder to take effect.");
}
- if (occluder_polygon.is_valid() && occluder_polygon->get_polygon().size()==0) {
+ if (occluder_polygon.is_valid() && occluder_polygon->get_polygon().size() == 0) {
return TTR("The occluder polygon for this occluder is empty. Please draw a polygon!");
}
@@ -224,28 +211,27 @@ String LightOccluder2D::get_configuration_warning() const {
void LightOccluder2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_occluder_polygon","polygon:OccluderPolygon2D"),&LightOccluder2D::set_occluder_polygon);
- ObjectTypeDB::bind_method(_MD("get_occluder_polygon:OccluderPolygon2D"),&LightOccluder2D::get_occluder_polygon);
+ ObjectTypeDB::bind_method(_MD("set_occluder_polygon", "polygon:OccluderPolygon2D"), &LightOccluder2D::set_occluder_polygon);
+ ObjectTypeDB::bind_method(_MD("get_occluder_polygon:OccluderPolygon2D"), &LightOccluder2D::get_occluder_polygon);
- ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&LightOccluder2D::set_occluder_light_mask);
- ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&LightOccluder2D::get_occluder_light_mask);
+ ObjectTypeDB::bind_method(_MD("set_occluder_light_mask", "mask"), &LightOccluder2D::set_occluder_light_mask);
+ ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"), &LightOccluder2D::get_occluder_light_mask);
#ifdef DEBUG_ENABLED
- ObjectTypeDB::bind_method("_poly_changed",&LightOccluder2D::_poly_changed);
+ ObjectTypeDB::bind_method("_poly_changed", &LightOccluder2D::_poly_changed);
#endif
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"),_SCS("set_occluder_polygon"),_SCS("get_occluder_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "occluder", PROPERTY_HINT_RESOURCE_TYPE, "OccluderPolygon2D"), _SCS("set_occluder_polygon"), _SCS("get_occluder_polygon"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_occluder_light_mask"), _SCS("get_occluder_light_mask"));
}
LightOccluder2D::LightOccluder2D() {
- occluder=VS::get_singleton()->canvas_light_occluder_create();
- mask=1;
+ occluder = VS::get_singleton()->canvas_light_occluder_create();
+ mask = 1;
}
LightOccluder2D::~LightOccluder2D() {
VS::get_singleton()->free(occluder);
}
-
diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h
index a6a3fb68e..71c778abf 100644
--- a/scene/2d/light_occluder_2d.h
+++ b/scene/2d/light_occluder_2d.h
@@ -33,28 +33,26 @@
class OccluderPolygon2D : public Resource {
- OBJ_TYPE(OccluderPolygon2D,Resource);
-public:
+ OBJ_TYPE(OccluderPolygon2D, Resource);
+public:
enum CullMode {
CULL_DISABLED,
CULL_CLOCKWISE,
CULL_COUNTER_CLOCKWISE
};
-private:
-
+private:
RID occ_polygon;
DVector<Vector2> polygon;
bool closed;
CullMode cull;
protected:
-
static void _bind_methods();
-public:
- void set_polygon(const DVector<Vector2>& p_polygon);
+public:
+ void set_polygon(const DVector<Vector2> &p_polygon);
DVector<Vector2> get_polygon() const;
void set_closed(bool p_closed);
@@ -66,13 +64,12 @@ public:
virtual RID get_rid() const;
OccluderPolygon2D();
~OccluderPolygon2D();
-
};
VARIANT_ENUM_CAST(OccluderPolygon2D::CullMode);
class LightOccluder2D : public Node2D {
- OBJ_TYPE(LightOccluder2D,Node2D);
+ OBJ_TYPE(LightOccluder2D, Node2D);
RID occluder;
bool enabled;
@@ -86,9 +83,9 @@ class LightOccluder2D : public Node2D {
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_occluder_polygon(const Ref<OccluderPolygon2D>& p_polygon);
+public:
+ void set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon);
Ref<OccluderPolygon2D> get_occluder_polygon() const;
void set_occluder_light_mask(int p_mask);
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index b49d9c40d..f1ed41f9e 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -33,61 +33,59 @@
void Navigation2D::_navpoly_link(int p_id) {
ERR_FAIL_COND(!navpoly_map.has(p_id));
- NavMesh &nm=navpoly_map[p_id];
+ NavMesh &nm = navpoly_map[p_id];
ERR_FAIL_COND(nm.linked);
- DVector<Vector2> vertices=nm.navpoly->get_vertices();
+ DVector<Vector2> vertices = nm.navpoly->get_vertices();
int len = vertices.size();
- if (len==0)
+ if (len == 0)
return;
- DVector<Vector2>::Read r=vertices.read();
+ DVector<Vector2>::Read r = vertices.read();
- for(int i=0;i<nm.navpoly->get_polygon_count();i++) {
+ for (int i = 0; i < nm.navpoly->get_polygon_count(); i++) {
//build
- List<Polygon>::Element *P=nm.polygons.push_back(Polygon());
- Polygon &p=P->get();
- p.owner=&nm;
+ List<Polygon>::Element *P = nm.polygons.push_back(Polygon());
+ Polygon &p = P->get();
+ p.owner = &nm;
Vector<int> poly = nm.navpoly->get_polygon(i);
- int plen=poly.size();
- const int *indices=poly.ptr();
- bool valid=true;
+ int plen = poly.size();
+ const int *indices = poly.ptr();
+ bool valid = true;
p.edges.resize(plen);
Vector2 center;
- float sum=0;
+ float sum = 0;
- for(int j=0;j<plen;j++) {
+ for (int j = 0; j < plen; j++) {
int idx = indices[j];
- if (idx<0 || idx>=len) {
- valid=false;
+ if (idx < 0 || idx >= len) {
+ valid = false;
break;
}
Polygon::Edge e;
- Vector2 ep=nm.xform.xform(r[idx]);
- center+=ep;
- e.point=_get_point(ep);
- p.edges[j]=e;
+ Vector2 ep = nm.xform.xform(r[idx]);
+ center += ep;
+ e.point = _get_point(ep);
+ p.edges[j] = e;
- int idxn = indices[(j+1)%plen];
- if (idxn<0 || idxn>=len) {
- valid=false;
+ int idxn = indices[(j + 1) % plen];
+ if (idxn < 0 || idxn >= len) {
+ valid = false;
break;
}
Vector2 epn = nm.xform.xform(r[idxn]);
- sum+=(epn.x-ep.x)*(epn.y+ep.y);
-
-
+ sum += (epn.x - ep.x) * (epn.y + ep.y);
}
- p.clockwise=sum>0;
+ p.clockwise = sum > 0;
if (!valid) {
nm.polygons.pop_back();
@@ -95,106 +93,103 @@ void Navigation2D::_navpoly_link(int p_id) {
continue;
}
- p.center=center/plen;
+ p.center = center / plen;
//connect
- for(int j=0;j<plen;j++) {
+ for (int j = 0; j < plen; j++) {
- int next = (j+1)%plen;
- EdgeKey ek(p.edges[j].point,p.edges[next].point);
+ int next = (j + 1) % plen;
+ EdgeKey ek(p.edges[j].point, p.edges[next].point);
- Map<EdgeKey,Connection>::Element *C=connections.find(ek);
+ Map<EdgeKey, Connection>::Element *C = connections.find(ek);
if (!C) {
Connection c;
- c.A=&p;
- c.A_edge=j;
- c.B=NULL;
- c.B_edge=-1;
- connections[ek]=c;
+ c.A = &p;
+ c.A_edge = j;
+ c.B = NULL;
+ c.B_edge = -1;
+ connections[ek] = c;
} else {
- if (C->get().B!=NULL) {
+ if (C->get().B != NULL) {
ConnectionPending pending;
- pending.polygon=&p;
- pending.edge=j;
- p.edges[j].P=C->get().pending.push_back(pending);
+ pending.polygon = &p;
+ pending.edge = j;
+ p.edges[j].P = C->get().pending.push_back(pending);
continue;
//print_line(String()+_get_vertex(ek.a)+" -> "+_get_vertex(ek.b));
}
- C->get().B=&p;
- C->get().B_edge=j;
- C->get().A->edges[C->get().A_edge].C=&p;
- C->get().A->edges[C->get().A_edge].C_edge=j;
- p.edges[j].C=C->get().A;
- p.edges[j].C_edge=C->get().A_edge;
+ C->get().B = &p;
+ C->get().B_edge = j;
+ C->get().A->edges[C->get().A_edge].C = &p;
+ C->get().A->edges[C->get().A_edge].C_edge = j;
+ p.edges[j].C = C->get().A;
+ p.edges[j].C_edge = C->get().A_edge;
//connection successful.
}
}
}
- nm.linked=true;
-
+ nm.linked = true;
}
-
void Navigation2D::_navpoly_unlink(int p_id) {
ERR_FAIL_COND(!navpoly_map.has(p_id));
- NavMesh &nm=navpoly_map[p_id];
+ NavMesh &nm = navpoly_map[p_id];
ERR_FAIL_COND(!nm.linked);
//print_line("UNLINK");
- for (List<Polygon>::Element *E=nm.polygons.front();E;E=E->next()) {
-
+ for (List<Polygon>::Element *E = nm.polygons.front(); E; E = E->next()) {
- Polygon &p=E->get();
+ Polygon &p = E->get();
int ec = p.edges.size();
- Polygon::Edge *edges=p.edges.ptr();
+ Polygon::Edge *edges = p.edges.ptr();
- for(int i=0;i<ec;i++) {
- int next = (i+1)%ec;
+ for (int i = 0; i < ec; i++) {
+ int next = (i + 1) % ec;
- EdgeKey ek(edges[i].point,edges[next].point);
- Map<EdgeKey,Connection>::Element *C=connections.find(ek);
+ EdgeKey ek(edges[i].point, edges[next].point);
+ Map<EdgeKey, Connection>::Element *C = connections.find(ek);
ERR_CONTINUE(!C);
if (edges[i].P) {
C->get().pending.erase(edges[i].P);
- edges[i].P=NULL;
+ edges[i].P = NULL;
} else if (C->get().B) {
//disconnect
- C->get().B->edges[C->get().B_edge].C=NULL;
- C->get().B->edges[C->get().B_edge].C_edge=-1;
- C->get().A->edges[C->get().A_edge].C=NULL;
- C->get().A->edges[C->get().A_edge].C_edge=-1;
+ C->get().B->edges[C->get().B_edge].C = NULL;
+ C->get().B->edges[C->get().B_edge].C_edge = -1;
+ C->get().A->edges[C->get().A_edge].C = NULL;
+ C->get().A->edges[C->get().A_edge].C_edge = -1;
- if (C->get().A==&E->get()) {
+ if (C->get().A == &E->get()) {
- C->get().A=C->get().B;
- C->get().A_edge=C->get().B_edge;
+ C->get().A = C->get().B;
+ C->get().A_edge = C->get().B_edge;
}
- C->get().B=NULL;
- C->get().B_edge=-1;
+ C->get().B = NULL;
+ C->get().B_edge = -1;
if (C->get().pending.size()) {
//reconnect if something is pending
ConnectionPending cp = C->get().pending.front()->get();
C->get().pending.pop_front();
- C->get().B=cp.polygon;
- C->get().B_edge=cp.edge;
- C->get().A->edges[C->get().A_edge].C=cp.polygon;
- C->get().A->edges[C->get().A_edge].C_edge=cp.edge;
- cp.polygon->edges[cp.edge].C=C->get().A;
- cp.polygon->edges[cp.edge].C_edge=C->get().A_edge;
- cp.polygon->edges[cp.edge].P=NULL;
+ C->get().B = cp.polygon;
+ C->get().B_edge = cp.edge;
+ C->get().A->edges[C->get().A_edge].C = cp.polygon;
+ C->get().A->edges[C->get().A_edge].C_edge = cp.edge;
+ cp.polygon->edges[cp.edge].C = C->get().A;
+ cp.polygon->edges[cp.edge].C_edge = C->get().A_edge;
+ cp.polygon->edges[cp.edge].P = NULL;
}
} else {
@@ -206,46 +201,39 @@ void Navigation2D::_navpoly_unlink(int p_id) {
nm.polygons.clear();
- nm.linked=false;
-
-
+ nm.linked = false;
}
-
-int Navigation2D::navpoly_create(const Ref<NavigationPolygon>& p_mesh, const Matrix32& p_xform, Object *p_owner) {
+int Navigation2D::navpoly_create(const Ref<NavigationPolygon> &p_mesh, const Matrix32 &p_xform, Object *p_owner) {
int id = last_id++;
NavMesh nm;
- nm.linked=false;
- nm.navpoly=p_mesh;
- nm.xform=p_xform;
- nm.owner=p_owner;
- navpoly_map[id]=nm;
+ nm.linked = false;
+ nm.navpoly = p_mesh;
+ nm.xform = p_xform;
+ nm.owner = p_owner;
+ navpoly_map[id] = nm;
_navpoly_link(id);
return id;
}
-void Navigation2D::navpoly_set_transform(int p_id, const Matrix32& p_xform){
+void Navigation2D::navpoly_set_transform(int p_id, const Matrix32 &p_xform) {
ERR_FAIL_COND(!navpoly_map.has(p_id));
- NavMesh &nm=navpoly_map[p_id];
- if (nm.xform==p_xform)
+ NavMesh &nm = navpoly_map[p_id];
+ if (nm.xform == p_xform)
return; //bleh
_navpoly_unlink(p_id);
- nm.xform=p_xform;
+ nm.xform = p_xform;
_navpoly_link(p_id);
-
-
-
}
-void Navigation2D::navpoly_remove(int p_id){
+void Navigation2D::navpoly_remove(int p_id) {
ERR_FAIL_COND(!navpoly_map.has(p_id));
_navpoly_unlink(p_id);
navpoly_map.erase(p_id);
-
}
#if 0
void Navigation2D::_clip_path(Vector<Vector2>& path, Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly) {
@@ -284,96 +272,91 @@ void Navigation2D::_clip_path(Vector<Vector2>& path, Polygon *from_poly, const V
}
#endif
-Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vector2& p_end, bool p_optimize) {
+Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) {
-
- Polygon *begin_poly=NULL;
- Polygon *end_poly=NULL;
+ Polygon *begin_poly = NULL;
+ Polygon *end_poly = NULL;
Vector2 begin_point;
Vector2 end_point;
- float begin_d=1e20;
- float end_d=1e20;
+ float begin_d = 1e20;
+ float end_d = 1e20;
//look for point inside triangle
- for (Map<int,NavMesh>::Element*E=navpoly_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navpoly_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
-
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
+ Polygon &p = F->get();
if (begin_d || end_d) {
- for(int i=2;i<p.edges.size();i++) {
+ for (int i = 2; i < p.edges.size(); i++) {
- if (begin_d>0) {
+ if (begin_d > 0) {
- if (Geometry::is_point_in_triangle(p_start,_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point))) {
+ if (Geometry::is_point_in_triangle(p_start, _get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point))) {
- begin_poly=&p;
- begin_point=p_start;
- begin_d=0;
- if (end_d==0)
+ begin_poly = &p;
+ begin_point = p_start;
+ begin_d = 0;
+ if (end_d == 0)
break;
-
}
}
- if (end_d>0) {
+ if (end_d > 0) {
- if (Geometry::is_point_in_triangle(p_end,_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point))) {
+ if (Geometry::is_point_in_triangle(p_end, _get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point))) {
- end_poly=&p;
- end_point=p_end;
- end_d=0;
- if (begin_d==0)
+ end_poly = &p;
+ end_point = p_end;
+ end_d = 0;
+ if (begin_d == 0)
break;
}
}
-
}
}
- p.prev_edge=-1;
+ p.prev_edge = -1;
}
}
//start or end not inside triangle.. look for closest segment :|
if (begin_d || end_d) {
- for (Map<int,NavMesh>::Element*E=navpoly_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navpoly_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
+ Polygon &p = F->get();
int es = p.edges.size();
- for(int i=0;i<es;i++) {
+ for (int i = 0; i < es; i++) {
- Vector2 edge[2]={
+ Vector2 edge[2] = {
_get_vertex(p.edges[i].point),
- _get_vertex(p.edges[(i+1)%es].point)
+ _get_vertex(p.edges[(i + 1) % es].point)
};
-
- if (begin_d>0) {
- Vector2 spoint=Geometry::get_closest_point_to_segment_2d(p_start,edge);
+ if (begin_d > 0) {
+ Vector2 spoint = Geometry::get_closest_point_to_segment_2d(p_start, edge);
float d = spoint.distance_to(p_start);
- if (d<begin_d) {
- begin_poly=&p;
- begin_point=spoint;
- begin_d=d;
+ if (d < begin_d) {
+ begin_poly = &p;
+ begin_point = spoint;
+ begin_d = d;
}
}
- if (end_d>0) {
- Vector2 spoint=Geometry::get_closest_point_to_segment_2d(p_end,edge);
+ if (end_d > 0) {
+ Vector2 spoint = Geometry::get_closest_point_to_segment_2d(p_end, edge);
float d = spoint.distance_to(p_end);
- if (d<end_d) {
- end_poly=&p;
- end_point=spoint;
- end_d=d;
+ if (d < end_d) {
+ end_poly = &p;
+ end_point = spoint;
+ end_d = d;
}
}
}
@@ -386,96 +369,91 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
return Vector<Vector2>(); //no path
}
- if (begin_poly==end_poly) {
+ if (begin_poly == end_poly) {
Vector<Vector2> path;
path.resize(2);
- path[0]=begin_point;
- path[1]=end_point;
+ path[0] = begin_point;
+ path[1] = end_point;
//print_line("Direct Path");
return path;
}
+ bool found_route = false;
- bool found_route=false;
-
- List<Polygon*> open_list;
+ List<Polygon *> open_list;
- begin_poly->entry=p_start;
+ begin_poly->entry = p_start;
- for(int i=0;i<begin_poly->edges.size();i++) {
+ for (int i = 0; i < begin_poly->edges.size(); i++) {
if (begin_poly->edges[i].C) {
- begin_poly->edges[i].C->prev_edge=begin_poly->edges[i].C_edge;
+ begin_poly->edges[i].C->prev_edge = begin_poly->edges[i].C_edge;
#ifdef USE_ENTRY_POINT
- Vector2 edge[2]={
+ Vector2 edge[2] = {
_get_vertex(begin_poly->edges[i].point),
- _get_vertex(begin_poly->edges[(i+1)%begin_poly->edges.size()].point)
+ _get_vertex(begin_poly->edges[(i + 1) % begin_poly->edges.size()].point)
};
- Vector2 entry = Geometry::get_closest_point_to_segment_2d(begin_poly->entry,edge);
+ Vector2 entry = Geometry::get_closest_point_to_segment_2d(begin_poly->entry, edge);
begin_poly->edges[i].C->distance = begin_poly->entry.distance_to(entry);
- begin_poly->edges[i].C->entry=entry;
+ begin_poly->edges[i].C->entry = entry;
#else
- begin_poly->edges[i].C->distance=begin_poly->center.distance_to(begin_poly->edges[i].C->center);
+ begin_poly->edges[i].C->distance = begin_poly->center.distance_to(begin_poly->edges[i].C->center);
#endif
open_list.push_back(begin_poly->edges[i].C);
- if (begin_poly->edges[i].C==end_poly) {
- found_route=true;
+ if (begin_poly->edges[i].C == end_poly) {
+ found_route = true;
}
}
}
+ while (!found_route) {
- while(!found_route) {
-
- if (open_list.size()==0) {
- // print_line("NOU OPEN LIST");
+ if (open_list.size() == 0) {
+ // print_line("NOU OPEN LIST");
break;
}
//check open list
- List<Polygon*>::Element *least_cost_poly=NULL;
- float least_cost=1e30;
+ List<Polygon *>::Element *least_cost_poly = NULL;
+ float least_cost = 1e30;
//this could be faster (cache previous results)
- for (List<Polygon*>::Element *E=open_list.front();E;E=E->next()) {
-
- Polygon *p=E->get();
+ for (List<Polygon *>::Element *E = open_list.front(); E; E = E->next()) {
+ Polygon *p = E->get();
- float cost=p->distance;
- cost+=p->center.distance_to(end_point);
+ float cost = p->distance;
+ cost += p->center.distance_to(end_point);
- if (cost<least_cost) {
+ if (cost < least_cost) {
- least_cost_poly=E;
- least_cost=cost;
+ least_cost_poly = E;
+ least_cost = cost;
}
}
-
- Polygon *p=least_cost_poly->get();
+ Polygon *p = least_cost_poly->get();
//open the neighbours for search
int es = p->edges.size();
- for(int i=0;i<es;i++) {
+ for (int i = 0; i < es; i++) {
-
- Polygon::Edge &e=p->edges[i];
+ Polygon::Edge &e = p->edges[i];
if (!e.C)
continue;
#ifdef USE_ENTRY_POINT
- Vector2 edge[2]={
+ Vector2 edge[2] = {
_get_vertex(p->edges[i].point),
- _get_vertex(p->edges[(i+1)%es].point)
+ _get_vertex(p->edges[(i + 1) % es].point)
};
- Vector2 edge_entry = Geometry::get_closest_point_to_segment_2d(p->entry,edge);
+ Vector2 edge_entry = Geometry::get_closest_point_to_segment_2d(p->entry, edge);
float distance = p->entry.distance_to(edge_entry) + p->distance;
#else
@@ -484,36 +462,33 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2& p_start, const Vect
#endif
-
- if (e.C->prev_edge!=-1) {
+ if (e.C->prev_edge != -1) {
//oh this was visited already, can we win the cost?
- if (e.C->distance>distance) {
+ if (e.C->distance > distance) {
- e.C->prev_edge=e.C_edge;
- e.C->distance=distance;
+ e.C->prev_edge = e.C_edge;
+ e.C->distance = distance;
#ifdef USE_ENTRY_POINT
- e.C->entry=edge_entry;
+ e.C->entry = edge_entry;
#endif
}
} else {
//add to open neighbours
- e.C->prev_edge=e.C_edge;
- e.C->distance=distance;
+ e.C->prev_edge = e.C_edge;
+ e.C->distance = distance;
#ifdef USE_ENTRY_POINT
- e.C->entry=edge_entry;
+ e.C->entry = edge_entry;
#endif
open_list.push_back(e.C);
- if (e.C==end_poly) {
+ if (e.C == end_poly) {
//oh my reached end! stop algorithm
- found_route=true;
+ found_route = true;
break;
-
}
-
}
}
@@ -552,40 +527,40 @@ debug path
if (p_optimize) {
//string pulling
- Vector2 apex_point=end_point;
- Vector2 portal_left=apex_point;
- Vector2 portal_right=apex_point;
- Polygon *left_poly=end_poly;
- Polygon *right_poly=end_poly;
- Polygon *p=end_poly;
+ Vector2 apex_point = end_point;
+ Vector2 portal_left = apex_point;
+ Vector2 portal_right = apex_point;
+ Polygon *left_poly = end_poly;
+ Polygon *right_poly = end_poly;
+ Polygon *p = end_poly;
path.push_back(end_point);
- while(p) {
+ while (p) {
Vector2 left;
Vector2 right;
//#define CLOCK_TANGENT(m_a,m_b,m_c) ( ((m_a)-(m_c)).cross((m_a)-(m_b)) )
-#define CLOCK_TANGENT(m_a,m_b,m_c) ((((m_a).x - (m_c).x) * ((m_b).y - (m_c).y) - ((m_b).x - (m_c).x) * ((m_a).y - (m_c).y)))
+#define CLOCK_TANGENT(m_a, m_b, m_c) ((((m_a).x - (m_c).x) * ((m_b).y - (m_c).y) - ((m_b).x - (m_c).x) * ((m_a).y - (m_c).y)))
- if (p==begin_poly) {
- left=begin_point;
- right=begin_point;
+ if (p == begin_poly) {
+ left = begin_point;
+ right = begin_point;
} else {
int prev = p->prev_edge;
- int prev_n = (p->prev_edge+1)%p->edges.size();
+ int prev_n = (p->prev_edge + 1) % p->edges.size();
left = _get_vertex(p->edges[prev].point);
right = _get_vertex(p->edges[prev_n].point);
if (p->clockwise) {
- SWAP(left,right);
+ SWAP(left, right);
}
/*if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5) < 0){
SWAP(left,right);
}*/
}
- bool skip=false;
+ bool skip = false;
/*
print_line("-----\nAPEX: "+(apex_point-end_point));
@@ -603,221 +578,202 @@ debug path
print_line("\tRight Test: "+rtos(CLOCK_TANGENT(apex_point,right,portal_left)));
*/
-
- if (CLOCK_TANGENT(apex_point,portal_left,left) >= 0){
+ if (CLOCK_TANGENT(apex_point, portal_left, left) >= 0) {
//process
- if (portal_left.distance_squared_to(apex_point)<CMP_EPSILON || CLOCK_TANGENT(apex_point,left,portal_right) > 0) {
- left_poly=p;
- portal_left=left;
+ if (portal_left.distance_squared_to(apex_point) < CMP_EPSILON || CLOCK_TANGENT(apex_point, left, portal_right) > 0) {
+ left_poly = p;
+ portal_left = left;
//print_line("***ADVANCE LEFT");
} else {
- apex_point=portal_right;
- p=right_poly;
- left_poly=p;
- portal_left=apex_point;
- portal_right=apex_point;
- if (path[path.size()-1].distance_to(apex_point)>CMP_EPSILON)
+ apex_point = portal_right;
+ p = right_poly;
+ left_poly = p;
+ portal_left = apex_point;
+ portal_right = apex_point;
+ if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
path.push_back(apex_point);
- skip=true;
+ skip = true;
//print_line("addpoint left");
//print_line("***CLIP LEFT");
}
}
- if (!skip && CLOCK_TANGENT(apex_point,portal_right,right) <= 0){
+ if (!skip && CLOCK_TANGENT(apex_point, portal_right, right) <= 0) {
//process
- if (portal_right.distance_squared_to(apex_point)<CMP_EPSILON || CLOCK_TANGENT(apex_point,right,portal_left) < 0) {
- right_poly=p;
- portal_right=right;
+ if (portal_right.distance_squared_to(apex_point) < CMP_EPSILON || CLOCK_TANGENT(apex_point, right, portal_left) < 0) {
+ right_poly = p;
+ portal_right = right;
//print_line("***ADVANCE RIGHT");
} else {
- apex_point=portal_left;
- p=left_poly;
- right_poly=p;
- portal_right=apex_point;
- portal_left=apex_point;
- if (path[path.size()-1].distance_to(apex_point)>CMP_EPSILON)
+ apex_point = portal_left;
+ p = left_poly;
+ right_poly = p;
+ portal_right = apex_point;
+ portal_left = apex_point;
+ if (path[path.size() - 1].distance_to(apex_point) > CMP_EPSILON)
path.push_back(apex_point);
//print_line("addpoint right");
//print_line("***CLIP RIGHT");
-
}
}
- if (p!=begin_poly)
- p=p->edges[p->prev_edge].C;
+ if (p != begin_poly)
+ p = p->edges[p->prev_edge].C;
else
- p=NULL;
-
+ p = NULL;
}
- if (path[path.size()-1].distance_to(begin_point)>CMP_EPSILON)
+ if (path[path.size() - 1].distance_to(begin_point) > CMP_EPSILON)
path.push_back(begin_point);
path.invert();
-
-
-
} else {
//midpoints
- Polygon *p=end_poly;
+ Polygon *p = end_poly;
path.push_back(end_point);
- while(true) {
+ while (true) {
int prev = p->prev_edge;
- int prev_n = (p->prev_edge+1)%p->edges.size();
- Vector2 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point))*0.5;
+ int prev_n = (p->prev_edge + 1) % p->edges.size();
+ Vector2 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point)) * 0.5;
path.push_back(point);
p = p->edges[prev].C;
- if (p==begin_poly)
+ if (p == begin_poly)
break;
}
path.push_back(begin_point);
-
path.invert();
}
return path;
}
-
return Vector<Vector2>();
-
}
+Vector2 Navigation2D::get_closest_point(const Vector2 &p_point) {
-Vector2 Navigation2D::get_closest_point(const Vector2& p_point) {
-
- Vector2 closest_point=Vector2();
- float closest_point_d=1e20;
+ Vector2 closest_point = Vector2();
+ float closest_point_d = 1e20;
- for (Map<int,NavMesh>::Element*E=navpoly_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navpoly_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
- for(int i=2;i<p.edges.size();i++) {
+ Polygon &p = F->get();
+ for (int i = 2; i < p.edges.size(); i++) {
- if (Geometry::is_point_in_triangle(p_point,_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point))) {
+ if (Geometry::is_point_in_triangle(p_point, _get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point))) {
return p_point; //inside triangle, nothing else to discuss
}
-
}
}
}
- for (Map<int,NavMesh>::Element*E=navpoly_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navpoly_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
+ Polygon &p = F->get();
int es = p.edges.size();
- for(int i=0;i<es;i++) {
+ for (int i = 0; i < es; i++) {
- Vector2 edge[2]={
+ Vector2 edge[2] = {
_get_vertex(p.edges[i].point),
- _get_vertex(p.edges[(i+1)%es].point)
+ _get_vertex(p.edges[(i + 1) % es].point)
};
-
- Vector2 spoint=Geometry::get_closest_point_to_segment_2d(p_point,edge);
+ Vector2 spoint = Geometry::get_closest_point_to_segment_2d(p_point, edge);
float d = spoint.distance_squared_to(p_point);
- if (d<closest_point_d) {
+ if (d < closest_point_d) {
- closest_point=spoint;
- closest_point_d=d;
+ closest_point = spoint;
+ closest_point_d = d;
}
}
}
}
return closest_point;
-
}
-Object* Navigation2D::get_closest_point_owner(const Vector2& p_point) {
+Object *Navigation2D::get_closest_point_owner(const Vector2 &p_point) {
- Object *owner=NULL;
- Vector2 closest_point=Vector2();
- float closest_point_d=1e20;
+ Object *owner = NULL;
+ Vector2 closest_point = Vector2();
+ float closest_point_d = 1e20;
- for (Map<int,NavMesh>::Element*E=navpoly_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navpoly_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
- for(int i=2;i<p.edges.size();i++) {
+ Polygon &p = F->get();
+ for (int i = 2; i < p.edges.size(); i++) {
- if (Geometry::is_point_in_triangle(p_point,_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point))) {
+ if (Geometry::is_point_in_triangle(p_point, _get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point))) {
E->get().owner;
}
-
}
}
}
- for (Map<int,NavMesh>::Element*E=navpoly_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navpoly_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
+ Polygon &p = F->get();
int es = p.edges.size();
- for(int i=0;i<es;i++) {
+ for (int i = 0; i < es; i++) {
- Vector2 edge[2]={
+ Vector2 edge[2] = {
_get_vertex(p.edges[i].point),
- _get_vertex(p.edges[(i+1)%es].point)
+ _get_vertex(p.edges[(i + 1) % es].point)
};
-
- Vector2 spoint=Geometry::get_closest_point_to_segment_2d(p_point,edge);
+ Vector2 spoint = Geometry::get_closest_point_to_segment_2d(p_point, edge);
float d = spoint.distance_squared_to(p_point);
- if (d<closest_point_d) {
+ if (d < closest_point_d) {
- closest_point=spoint;
- closest_point_d=d;
- owner=E->get().owner;
+ closest_point = spoint;
+ closest_point_d = d;
+ owner = E->get().owner;
}
}
}
}
return owner;
-
}
-
void Navigation2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("navpoly_create","mesh:NavigationPolygon","xform","owner"),&Navigation2D::navpoly_create,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("navpoly_set_transform","id","xform"),&Navigation2D::navpoly_set_transform);
- ObjectTypeDB::bind_method(_MD("navpoly_remove","id"),&Navigation2D::navpoly_remove);
-
- ObjectTypeDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation2D::get_simple_path,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("get_closest_point","to_point"),&Navigation2D::get_closest_point);
- ObjectTypeDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation2D::get_closest_point_owner);
+ ObjectTypeDB::bind_method(_MD("navpoly_create", "mesh:NavigationPolygon", "xform", "owner"), &Navigation2D::navpoly_create, DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("navpoly_set_transform", "id", "xform"), &Navigation2D::navpoly_set_transform);
+ ObjectTypeDB::bind_method(_MD("navpoly_remove", "id"), &Navigation2D::navpoly_remove);
+ ObjectTypeDB::bind_method(_MD("get_simple_path", "start", "end", "optimize"), &Navigation2D::get_simple_path, DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("get_closest_point", "to_point"), &Navigation2D::get_closest_point);
+ ObjectTypeDB::bind_method(_MD("get_closest_point_owner", "to_point"), &Navigation2D::get_closest_point_owner);
}
Navigation2D::Navigation2D() {
- ERR_FAIL_COND( sizeof(Point)!=8 );
- cell_size=1; // one pixel
- last_id=1;
-
+ ERR_FAIL_COND(sizeof(Point) != 8);
+ cell_size = 1; // one pixel
+ last_id = 1;
}
diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h
index a5468d770..3e43d9c6d 100644
--- a/scene/2d/navigation2d.h
+++ b/scene/2d/navigation2d.h
@@ -29,45 +29,42 @@
#ifndef NAVIGATION_2D_H
#define NAVIGATION_2D_H
-#include "scene/2d/node_2d.h"
#include "scene/2d/navigation_polygon.h"
+#include "scene/2d/node_2d.h"
class Navigation2D : public Node2D {
- OBJ_TYPE( Navigation2D, Node2D);
-
+ OBJ_TYPE(Navigation2D, Node2D);
union Point {
struct {
- int64_t x:32;
- int64_t y:32;
+ int64_t x : 32;
+ int64_t y : 32;
};
uint64_t key;
- bool operator<(const Point& p_key) const { return key < p_key.key; }
+ bool operator<(const Point &p_key) const { return key < p_key.key; }
};
-
struct EdgeKey {
Point a;
Point b;
- bool operator<(const EdgeKey& p_key) const {
- return (a.key==p_key.a.key)?(b.key<p_key.b.key):(a.key<p_key.a.key);
+ bool operator<(const EdgeKey &p_key) const {
+ return (a.key == p_key.a.key) ? (b.key < p_key.b.key) : (a.key < p_key.a.key);
};
- EdgeKey(const Point& p_a=Point(),const Point& p_b=Point()) {
- a=p_a;
- b=p_b;
+ EdgeKey(const Point &p_a = Point(), const Point &p_b = Point()) {
+ a = p_a;
+ b = p_b;
if (a.key > b.key) {
- SWAP(a,b);
+ SWAP(a, b);
}
}
};
-
struct NavMesh;
struct Polygon;
@@ -84,7 +81,11 @@ class Navigation2D : public Node2D {
Polygon *C; //connection
int C_edge;
List<ConnectionPending>::Element *P;
- Edge() { C=NULL; C_edge=-1; P=NULL; }
+ Edge() {
+ C = NULL;
+ C_edge = -1;
+ P = NULL;
+ }
};
Vector<Edge> edges;
@@ -100,7 +101,6 @@ class Navigation2D : public Node2D {
NavMesh *owner;
};
-
struct Connection {
Polygon *A;
@@ -110,11 +110,15 @@ class Navigation2D : public Node2D {
List<ConnectionPending> pending;
- Connection() { A=NULL; B=NULL; A_edge=-1; B_edge=-1;}
+ Connection() {
+ A = NULL;
+ B = NULL;
+ A_edge = -1;
+ B_edge = -1;
+ }
};
- Map<EdgeKey,Connection> connections;
-
+ Map<EdgeKey, Connection> connections;
struct NavMesh {
@@ -123,57 +127,48 @@ class Navigation2D : public Node2D {
bool linked;
Ref<NavigationPolygon> navpoly;
List<Polygon> polygons;
-
};
+ _FORCE_INLINE_ Point _get_point(const Vector2 &p_pos) const {
-
- _FORCE_INLINE_ Point _get_point(const Vector2& p_pos) const {
-
- int x = int(Math::floor(p_pos.x/cell_size));
- int y = int(Math::floor(p_pos.y/cell_size));
+ int x = int(Math::floor(p_pos.x / cell_size));
+ int y = int(Math::floor(p_pos.y / cell_size));
Point p;
- p.key=0;
- p.x=x;
- p.y=y;
+ p.key = 0;
+ p.x = x;
+ p.y = y;
return p;
-
}
- _FORCE_INLINE_ Vector2 _get_vertex(const Point& p_point) const {
+ _FORCE_INLINE_ Vector2 _get_vertex(const Point &p_point) const {
- return Vector2(p_point.x,p_point.y)*cell_size;
+ return Vector2(p_point.x, p_point.y) * cell_size;
}
-
-
void _navpoly_link(int p_id);
void _navpoly_unlink(int p_id);
float cell_size;
- Map<int,NavMesh> navpoly_map;
+ Map<int, NavMesh> navpoly_map;
int last_id;
#if 0
void _clip_path(Vector<Vector2>& path,Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly);
#endif
protected:
-
static void _bind_methods();
public:
-
//API should be as dynamic as possible
- int navpoly_create(const Ref<NavigationPolygon>& p_mesh,const Matrix32& p_xform,Object* p_owner=NULL);
- void navpoly_set_transform(int p_id, const Matrix32& p_xform);
+ int navpoly_create(const Ref<NavigationPolygon> &p_mesh, const Matrix32 &p_xform, Object *p_owner = NULL);
+ void navpoly_set_transform(int p_id, const Matrix32 &p_xform);
void navpoly_remove(int p_id);
- Vector<Vector2> get_simple_path(const Vector2& p_start, const Vector2& p_end,bool p_optimize=true);
- Vector2 get_closest_point(const Vector2& p_point);
- Object* get_closest_point_owner(const Vector2& p_point);
+ Vector<Vector2> get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize = true);
+ Vector2 get_closest_point(const Vector2 &p_point);
+ Object *get_closest_point_owner(const Vector2 &p_point);
Navigation2D();
};
-
#endif // Navigation2D2D_H
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index f624b3ed8..dde1386c1 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -27,26 +27,25 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "navigation_polygon.h"
+#include "core_string_names.h"
#include "navigation2d.h"
#include "triangulator.h"
-#include "core_string_names.h"
-void NavigationPolygon::set_vertices(const DVector<Vector2>& p_vertices) {
+void NavigationPolygon::set_vertices(const DVector<Vector2> &p_vertices) {
- vertices=p_vertices;
+ vertices = p_vertices;
}
-DVector<Vector2> NavigationPolygon::get_vertices() const{
+DVector<Vector2> NavigationPolygon::get_vertices() const {
return vertices;
}
-
-void NavigationPolygon::_set_polygons(const Array& p_array) {
+void NavigationPolygon::_set_polygons(const Array &p_array) {
polygons.resize(p_array.size());
- for(int i=0;i<p_array.size();i++) {
- polygons[i].indices=p_array[i];
+ for (int i = 0; i < p_array.size(); i++) {
+ polygons[i].indices = p_array[i];
}
}
@@ -54,18 +53,18 @@ Array NavigationPolygon::_get_polygons() const {
Array ret;
ret.resize(polygons.size());
- for(int i=0;i<ret.size();i++) {
- ret[i]=polygons[i].indices;
+ for (int i = 0; i < ret.size(); i++) {
+ ret[i] = polygons[i].indices;
}
return ret;
}
-void NavigationPolygon::_set_outlines(const Array& p_array) {
+void NavigationPolygon::_set_outlines(const Array &p_array) {
outlines.resize(p_array.size());
- for(int i=0;i<p_array.size();i++) {
- outlines[i]=p_array[i];
+ for (int i = 0; i < p_array.size(); i++) {
+ outlines[i] = p_array[i];
}
}
@@ -73,132 +72,125 @@ Array NavigationPolygon::_get_outlines() const {
Array ret;
ret.resize(outlines.size());
- for(int i=0;i<ret.size();i++) {
- ret[i]=outlines[i];
+ for (int i = 0; i < ret.size(); i++) {
+ ret[i] = outlines[i];
}
return ret;
}
-
-void NavigationPolygon::add_polygon(const Vector<int>& p_polygon){
+void NavigationPolygon::add_polygon(const Vector<int> &p_polygon) {
Polygon polygon;
- polygon.indices=p_polygon;
+ polygon.indices = p_polygon;
polygons.push_back(polygon);
-
}
-void NavigationPolygon::add_outline_at_index(const DVector<Vector2>& p_outline,int p_index) {
+void NavigationPolygon::add_outline_at_index(const DVector<Vector2> &p_outline, int p_index) {
- outlines.insert(p_index,p_outline);
+ outlines.insert(p_index, p_outline);
}
-int NavigationPolygon::get_polygon_count() const{
+int NavigationPolygon::get_polygon_count() const {
return polygons.size();
}
-Vector<int> NavigationPolygon::get_polygon(int p_idx){
+Vector<int> NavigationPolygon::get_polygon(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx,polygons.size(),Vector<int>());
+ ERR_FAIL_INDEX_V(p_idx, polygons.size(), Vector<int>());
return polygons[p_idx].indices;
}
-void NavigationPolygon::clear_polygons(){
+void NavigationPolygon::clear_polygons() {
polygons.clear();
}
-void NavigationPolygon::add_outline(const DVector<Vector2>& p_outline) {
+void NavigationPolygon::add_outline(const DVector<Vector2> &p_outline) {
outlines.push_back(p_outline);
}
-int NavigationPolygon::get_outline_count() const{
+int NavigationPolygon::get_outline_count() const {
return outlines.size();
}
-void NavigationPolygon::set_outline(int p_idx,const DVector<Vector2>& p_outline) {
- ERR_FAIL_INDEX(p_idx,outlines.size());
- outlines[p_idx]=p_outline;
+void NavigationPolygon::set_outline(int p_idx, const DVector<Vector2> &p_outline) {
+ ERR_FAIL_INDEX(p_idx, outlines.size());
+ outlines[p_idx] = p_outline;
}
void NavigationPolygon::remove_outline(int p_idx) {
- ERR_FAIL_INDEX(p_idx,outlines.size());
+ ERR_FAIL_INDEX(p_idx, outlines.size());
outlines.remove(p_idx);
-
}
DVector<Vector2> NavigationPolygon::get_outline(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,outlines.size(),DVector<Vector2>());
+ ERR_FAIL_INDEX_V(p_idx, outlines.size(), DVector<Vector2>());
return outlines[p_idx];
}
-void NavigationPolygon::clear_outlines(){
+void NavigationPolygon::clear_outlines() {
outlines.clear();
}
-void NavigationPolygon::make_polygons_from_outlines(){
+void NavigationPolygon::make_polygons_from_outlines() {
- List<TriangulatorPoly> in_poly,out_poly;
+ List<TriangulatorPoly> in_poly, out_poly;
- Vector2 outside_point(-1e10,-1e10);
+ Vector2 outside_point(-1e10, -1e10);
- for(int i=0;i<outlines.size();i++) {
+ for (int i = 0; i < outlines.size(); i++) {
DVector<Vector2> ol = outlines[i];
int olsize = ol.size();
- if (olsize<3)
+ if (olsize < 3)
continue;
- DVector<Vector2>::Read r=ol.read();
- for(int j=0;j<olsize;j++) {
- outside_point.x = MAX( r[j].x, outside_point.x );
- outside_point.y = MAX( r[j].y, outside_point.y );
+ DVector<Vector2>::Read r = ol.read();
+ for (int j = 0; j < olsize; j++) {
+ outside_point.x = MAX(r[j].x, outside_point.x);
+ outside_point.y = MAX(r[j].y, outside_point.y);
}
-
}
- outside_point+=Vector2(0.7239784,0.819238); //avoid precision issues
+ outside_point += Vector2(0.7239784, 0.819238); //avoid precision issues
-
-
- for(int i=0;i<outlines.size();i++) {
+ for (int i = 0; i < outlines.size(); i++) {
DVector<Vector2> ol = outlines[i];
int olsize = ol.size();
- if (olsize<3)
+ if (olsize < 3)
continue;
- DVector<Vector2>::Read r=ol.read();
+ DVector<Vector2>::Read r = ol.read();
- int interscount=0;
+ int interscount = 0;
//test if this is an outer outline
- for(int k=0;k<outlines.size();k++) {
+ for (int k = 0; k < outlines.size(); k++) {
- if (i==k)
+ if (i == k)
continue; //no self intersect
DVector<Vector2> ol2 = outlines[k];
int olsize2 = ol2.size();
- if (olsize2<3)
+ if (olsize2 < 3)
continue;
- DVector<Vector2>::Read r2=ol2.read();
+ DVector<Vector2>::Read r2 = ol2.read();
- for(int l=0;l<olsize2;l++) {
+ for (int l = 0; l < olsize2; l++) {
- if (Geometry::segment_intersects_segment_2d(r[0],outside_point,r2[l],r2[(l+1)%olsize2],NULL)) {
+ if (Geometry::segment_intersects_segment_2d(r[0], outside_point, r2[l], r2[(l + 1) % olsize2], NULL)) {
interscount++;
}
}
-
}
- bool outer = (interscount%2)==0;
+ bool outer = (interscount % 2) == 0;
TriangulatorPoly tp;
tp.Init(olsize);
- for(int j=0;j<olsize;j++) {
- tp[j]=r[j];
+ for (int j = 0; j < olsize; j++) {
+ tp[j] = r[j];
}
if (outer)
@@ -211,9 +203,8 @@ void NavigationPolygon::make_polygons_from_outlines(){
in_poly.push_back(tp);
}
-
TriangulatorPartition tpart;
- if (tpart.ConvexPartition_HM(&in_poly,&out_poly)==0) { //failed!
+ if (tpart.ConvexPartition_HM(&in_poly, &out_poly) == 0) { //failed!
print_line("convex partition failed!");
return;
}
@@ -221,18 +212,18 @@ void NavigationPolygon::make_polygons_from_outlines(){
polygons.clear();
vertices.resize(0);
- Map<Vector2,int> points;
- for(List<TriangulatorPoly>::Element*I = out_poly.front();I;I=I->next()) {
+ Map<Vector2, int> points;
+ for (List<TriangulatorPoly>::Element *I = out_poly.front(); I; I = I->next()) {
- TriangulatorPoly& tp = I->get();
+ TriangulatorPoly &tp = I->get();
struct Polygon p;
- for(int i=0;i<tp.GetNumPoints();i++) {
+ for (int i = 0; i < tp.GetNumPoints(); i++) {
- Map<Vector2,int>::Element *E=points.find(tp[i]);
+ Map<Vector2, int>::Element *E = points.find(tp[i]);
if (!E) {
- E=points.insert(tp[i],vertices.size());
+ E = points.insert(tp[i], vertices.size());
vertices.push_back(tp[i]);
}
p.indices.push_back(E->get());
@@ -244,56 +235,53 @@ void NavigationPolygon::make_polygons_from_outlines(){
emit_signal(CoreStringNames::get_singleton()->changed);
}
-
void NavigationPolygon::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_vertices","vertices"),&NavigationPolygon::set_vertices);
- ObjectTypeDB::bind_method(_MD("get_vertices"),&NavigationPolygon::get_vertices);
+ ObjectTypeDB::bind_method(_MD("set_vertices", "vertices"), &NavigationPolygon::set_vertices);
+ ObjectTypeDB::bind_method(_MD("get_vertices"), &NavigationPolygon::get_vertices);
- ObjectTypeDB::bind_method(_MD("add_polygon","polygon"),&NavigationPolygon::add_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon_count"),&NavigationPolygon::get_polygon_count);
- ObjectTypeDB::bind_method(_MD("get_polygon","idx"),&NavigationPolygon::get_polygon);
- ObjectTypeDB::bind_method(_MD("clear_polygons"),&NavigationPolygon::clear_polygons);
+ ObjectTypeDB::bind_method(_MD("add_polygon", "polygon"), &NavigationPolygon::add_polygon);
+ ObjectTypeDB::bind_method(_MD("get_polygon_count"), &NavigationPolygon::get_polygon_count);
+ ObjectTypeDB::bind_method(_MD("get_polygon", "idx"), &NavigationPolygon::get_polygon);
+ ObjectTypeDB::bind_method(_MD("clear_polygons"), &NavigationPolygon::clear_polygons);
- ObjectTypeDB::bind_method(_MD("add_outline","outline"),&NavigationPolygon::add_outline);
- ObjectTypeDB::bind_method(_MD("add_outline_at_index","outline","index"),&NavigationPolygon::add_outline_at_index);
- ObjectTypeDB::bind_method(_MD("get_outline_count"),&NavigationPolygon::get_outline_count);
- ObjectTypeDB::bind_method(_MD("set_outline","idx","outline"),&NavigationPolygon::set_outline);
- ObjectTypeDB::bind_method(_MD("get_outline","idx"),&NavigationPolygon::get_outline);
- ObjectTypeDB::bind_method(_MD("remove_outline","idx"),&NavigationPolygon::remove_outline);
- ObjectTypeDB::bind_method(_MD("clear_outlines"),&NavigationPolygon::clear_outlines);
- ObjectTypeDB::bind_method(_MD("make_polygons_from_outlines"),&NavigationPolygon::make_polygons_from_outlines);
+ ObjectTypeDB::bind_method(_MD("add_outline", "outline"), &NavigationPolygon::add_outline);
+ ObjectTypeDB::bind_method(_MD("add_outline_at_index", "outline", "index"), &NavigationPolygon::add_outline_at_index);
+ ObjectTypeDB::bind_method(_MD("get_outline_count"), &NavigationPolygon::get_outline_count);
+ ObjectTypeDB::bind_method(_MD("set_outline", "idx", "outline"), &NavigationPolygon::set_outline);
+ ObjectTypeDB::bind_method(_MD("get_outline", "idx"), &NavigationPolygon::get_outline);
+ ObjectTypeDB::bind_method(_MD("remove_outline", "idx"), &NavigationPolygon::remove_outline);
+ ObjectTypeDB::bind_method(_MD("clear_outlines"), &NavigationPolygon::clear_outlines);
+ ObjectTypeDB::bind_method(_MD("make_polygons_from_outlines"), &NavigationPolygon::make_polygons_from_outlines);
- ObjectTypeDB::bind_method(_MD("_set_polygons","polygons"),&NavigationPolygon::_set_polygons);
- ObjectTypeDB::bind_method(_MD("_get_polygons"),&NavigationPolygon::_get_polygons);
+ ObjectTypeDB::bind_method(_MD("_set_polygons", "polygons"), &NavigationPolygon::_set_polygons);
+ ObjectTypeDB::bind_method(_MD("_get_polygons"), &NavigationPolygon::_get_polygons);
- ObjectTypeDB::bind_method(_MD("_set_outlines","outlines"),&NavigationPolygon::_set_outlines);
- ObjectTypeDB::bind_method(_MD("_get_outlines"),&NavigationPolygon::_get_outlines);
+ ObjectTypeDB::bind_method(_MD("_set_outlines", "outlines"), &NavigationPolygon::_set_outlines);
+ ObjectTypeDB::bind_method(_MD("_get_outlines"), &NavigationPolygon::_get_outlines);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices"));
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_polygons"),_SCS("_get_polygons"));
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"outlines",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_outlines"),_SCS("_get_outlines"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("set_vertices"), _SCS("get_vertices"));
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_polygons"), _SCS("_get_polygons"));
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "outlines", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_outlines"), _SCS("_get_outlines"));
}
NavigationPolygon::NavigationPolygon() {
-
-
}
void NavigationPolygonInstance::set_enabled(bool p_enabled) {
- if (enabled==p_enabled)
+ if (enabled == p_enabled)
return;
- enabled=p_enabled;
+ enabled = p_enabled;
if (!is_inside_tree())
return;
if (!enabled) {
- if (nav_id!=-1) {
+ if (nav_id != -1) {
navigation->navpoly_remove(nav_id);
- nav_id=-1;
+ nav_id = -1;
}
} else {
@@ -301,55 +289,50 @@ void NavigationPolygonInstance::set_enabled(bool p_enabled) {
if (navpoly.is_valid()) {
- nav_id = navigation->navpoly_create(navpoly,get_relative_transform_to_parent(navigation),this);
+ nav_id = navigation->navpoly_create(navpoly, get_relative_transform_to_parent(navigation), this);
}
}
-
}
if (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
update();
-// update_gizmo();
+ // update_gizmo();
}
bool NavigationPolygonInstance::is_enabled() const {
-
return enabled;
}
-
/////////////////////////////
-
void NavigationPolygonInstance::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- Node2D *c=this;
- while(c) {
+ Node2D *c = this;
+ while (c) {
- navigation=c->cast_to<Navigation2D>();
+ navigation = c->cast_to<Navigation2D>();
if (navigation) {
if (enabled && navpoly.is_valid()) {
- nav_id = navigation->navpoly_create(navpoly,get_relative_transform_to_parent(navigation),this);
+ nav_id = navigation->navpoly_create(navpoly, get_relative_transform_to_parent(navigation), this);
}
break;
}
- c=c->get_parent()->cast_to<Node2D>();
+ c = c->get_parent()->cast_to<Node2D>();
}
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- if (navigation && nav_id!=-1) {
- navigation->navpoly_set_transform(nav_id,get_relative_transform_to_parent(navigation));
+ if (navigation && nav_id != -1) {
+ navigation->navpoly_set_transform(nav_id, get_relative_transform_to_parent(navigation));
}
} break;
@@ -357,28 +340,27 @@ void NavigationPolygonInstance::_notification(int p_what) {
if (navigation) {
- if (nav_id!=-1) {
+ if (nav_id != -1) {
navigation->navpoly_remove(nav_id);
- nav_id=-1;
+ nav_id = -1;
}
}
- navigation=NULL;
+ navigation = NULL;
} break;
case NOTIFICATION_DRAW: {
if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint()) && navpoly.is_valid()) {
- DVector<Vector2> verts=navpoly->get_vertices();
+ DVector<Vector2> verts = navpoly->get_vertices();
int vsize = verts.size();
- if (vsize<3)
+ if (vsize < 3)
return;
-
Color color;
if (enabled) {
- color=get_tree()->get_debug_navigation_color();
+ color = get_tree()->get_debug_navigation_color();
} else {
- color=get_tree()->get_debug_navigation_disabled_color();
+ color = get_tree()->get_debug_navigation_disabled_color();
}
Vector<Color> colors;
Vector<Vector2> vertices;
@@ -386,66 +368,61 @@ void NavigationPolygonInstance::_notification(int p_what) {
colors.resize(vsize);
{
DVector<Vector2>::Read vr = verts.read();
- for(int i=0;i<vsize;i++) {
- vertices[i]=vr[i];
- colors[i]=color;
+ for (int i = 0; i < vsize; i++) {
+ vertices[i] = vr[i];
+ colors[i] = color;
}
}
Vector<int> indices;
-
- for(int i=0;i<navpoly->get_polygon_count();i++) {
+ for (int i = 0; i < navpoly->get_polygon_count(); i++) {
Vector<int> polygon = navpoly->get_polygon(i);
- for(int j=2;j<polygon.size();j++) {
+ for (int j = 2; j < polygon.size(); j++) {
- int kofs[3]={0,j-1,j};
- for(int k=0;k<3;k++) {
+ int kofs[3] = { 0, j - 1, j };
+ for (int k = 0; k < 3; k++) {
- int idx = polygon[ kofs[k] ];
- ERR_FAIL_INDEX(idx,vsize);
+ int idx = polygon[kofs[k]];
+ ERR_FAIL_INDEX(idx, vsize);
indices.push_back(idx);
}
}
}
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(),indices,vertices,colors);
-
+ VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, vertices, colors);
}
} break;
-
}
}
+void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly) {
-void NavigationPolygonInstance::set_navigation_polygon(const Ref<NavigationPolygon>& p_navpoly) {
-
- if (p_navpoly==navpoly)
+ if (p_navpoly == navpoly)
return;
- if (navigation && nav_id!=-1) {
+ if (navigation && nav_id != -1) {
navigation->navpoly_remove(nav_id);
- nav_id=-1;
+ nav_id = -1;
}
if (navpoly.is_valid()) {
- navpoly->disconnect(CoreStringNames::get_singleton()->changed,this,"_navpoly_changed");
+ navpoly->disconnect(CoreStringNames::get_singleton()->changed, this, "_navpoly_changed");
}
- navpoly=p_navpoly;
+ navpoly = p_navpoly;
if (navpoly.is_valid()) {
- navpoly->connect(CoreStringNames::get_singleton()->changed,this,"_navpoly_changed");
+ navpoly->connect(CoreStringNames::get_singleton()->changed, this, "_navpoly_changed");
}
if (navigation && navpoly.is_valid() && enabled) {
- nav_id = navigation->navpoly_create(navpoly,get_relative_transform_to_parent(navigation),this);
+ nav_id = navigation->navpoly_create(navpoly, get_relative_transform_to_parent(navigation), this);
}
//update_gizmo();
_change_notify("navpoly");
update_configuration_warning();
-
}
-Ref<NavigationPolygon> NavigationPolygonInstance::get_navigation_polygon() const{
+Ref<NavigationPolygon> NavigationPolygonInstance::get_navigation_polygon() const {
return navpoly;
}
@@ -456,7 +433,6 @@ void NavigationPolygonInstance::_navpoly_changed() {
update();
}
-
String NavigationPolygonInstance::get_configuration_warning() const {
if (!is_visible() || !is_inside_tree())
@@ -465,14 +441,14 @@ String NavigationPolygonInstance::get_configuration_warning() const {
if (!navpoly.is_valid()) {
return TTR("A NavigationPolygon resource must be set or created for this node to work. Please set a property or draw a polygon.");
}
- const Node2D *c=this;
- while(c) {
+ const Node2D *c = this;
+ while (c) {
if (c->cast_to<Navigation2D>()) {
return String();
}
- c=c->get_parent()->cast_to<Node2D>();
+ c = c->get_parent()->cast_to<Node2D>();
}
return TTR("NavigationPolygonInstance must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
@@ -480,22 +456,21 @@ String NavigationPolygonInstance::get_configuration_warning() const {
void NavigationPolygonInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_navigation_polygon","navpoly:NavigationPolygon"),&NavigationPolygonInstance::set_navigation_polygon);
- ObjectTypeDB::bind_method(_MD("get_navigation_polygon:NavigationPolygon"),&NavigationPolygonInstance::get_navigation_polygon);
+ ObjectTypeDB::bind_method(_MD("set_navigation_polygon", "navpoly:NavigationPolygon"), &NavigationPolygonInstance::set_navigation_polygon);
+ ObjectTypeDB::bind_method(_MD("get_navigation_polygon:NavigationPolygon"), &NavigationPolygonInstance::get_navigation_polygon);
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&NavigationPolygonInstance::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&NavigationPolygonInstance::is_enabled);
+ ObjectTypeDB::bind_method(_MD("set_enabled", "enabled"), &NavigationPolygonInstance::set_enabled);
+ ObjectTypeDB::bind_method(_MD("is_enabled"), &NavigationPolygonInstance::is_enabled);
- ObjectTypeDB::bind_method(_MD("_navpoly_changed"),&NavigationPolygonInstance::_navpoly_changed);
+ ObjectTypeDB::bind_method(_MD("_navpoly_changed"), &NavigationPolygonInstance::_navpoly_changed);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navpoly",PROPERTY_HINT_RESOURCE_TYPE,"NavigationPolygon"),_SCS("set_navigation_polygon"),_SCS("get_navigation_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navpoly", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"), _SCS("set_navigation_polygon"), _SCS("get_navigation_polygon"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
}
NavigationPolygonInstance::NavigationPolygonInstance() {
- navigation=NULL;
- nav_id=-1;
- enabled=true;
-
+ navigation = NULL;
+ nav_id = -1;
+ enabled = true;
}
diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h
index f35315804..cc809b2f7 100644
--- a/scene/2d/navigation_polygon.h
+++ b/scene/2d/navigation_polygon.h
@@ -31,41 +31,36 @@
#include "scene/2d/node_2d.h"
+class NavigationPolygon : public Resource {
-class NavigationPolygon : public Resource {
-
- OBJ_TYPE( NavigationPolygon, Resource );
+ OBJ_TYPE(NavigationPolygon, Resource);
DVector<Vector2> vertices;
struct Polygon {
Vector<int> indices;
};
Vector<Polygon> polygons;
- Vector< DVector<Vector2> > outlines;
+ Vector<DVector<Vector2> > outlines;
protected:
-
static void _bind_methods();
- void _set_polygons(const Array& p_array);
+ void _set_polygons(const Array &p_array);
Array _get_polygons() const;
- void _set_outlines(const Array& p_array);
+ void _set_outlines(const Array &p_array);
Array _get_outlines() const;
public:
-
-
-
- void set_vertices(const DVector<Vector2>& p_vertices);
+ void set_vertices(const DVector<Vector2> &p_vertices);
DVector<Vector2> get_vertices() const;
- void add_polygon(const Vector<int>& p_polygon);
+ void add_polygon(const Vector<int> &p_polygon);
int get_polygon_count() const;
- void add_outline(const DVector<Vector2>& p_outline);
- void add_outline_at_index(const DVector<Vector2>& p_outline,int p_index);
- void set_outline(int p_idx,const DVector<Vector2>& p_outline);
+ void add_outline(const DVector<Vector2> &p_outline);
+ void add_outline_at_index(const DVector<Vector2> &p_outline, int p_index);
+ void set_outline(int p_idx, const DVector<Vector2> &p_outline);
DVector<Vector2> get_outline(int p_idx) const;
void remove_outline(int p_idx);
int get_outline_count() const;
@@ -79,12 +74,11 @@ public:
NavigationPolygon();
};
-
class Navigation2D;
class NavigationPolygonInstance : public Node2D {
- OBJ_TYPE(NavigationPolygonInstance,Node2D);
+ OBJ_TYPE(NavigationPolygonInstance, Node2D);
bool enabled;
int nav_id;
@@ -94,15 +88,14 @@ class NavigationPolygonInstance : public Node2D {
void _navpoly_changed();
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_enabled(bool p_enabled);
bool is_enabled() const;
- void set_navigation_polygon(const Ref<NavigationPolygon>& p_navpoly);
+ void set_navigation_polygon(const Ref<NavigationPolygon> &p_navpoly);
Ref<NavigationPolygon> get_navigation_polygon() const;
String get_configuration_warning() const;
@@ -110,5 +103,4 @@ public:
NavigationPolygonInstance();
};
-
#endif // NAVIGATIONPOLYGON_H
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 7e3057dbf..eaba766b7 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -28,15 +28,12 @@
/*************************************************************************/
#include "node_2d.h"
-#include "servers/visual_server.h"
+#include "message_queue.h"
#include "scene/gui/control.h"
#include "scene/main/viewport.h"
-#include "message_queue.h"
-
-
-void Node2D::edit_set_pivot(const Point2& p_pivot) {
-
+#include "servers/visual_server.h"
+void Node2D::edit_set_pivot(const Point2 &p_pivot) {
}
Point2 Node2D::edit_get_pivot() const {
@@ -56,12 +53,11 @@ Variant Node2D::edit_get_state() const {
state.push_back(get_scale());
return state;
-
}
-void Node2D::edit_set_state(const Variant& p_state) {
+void Node2D::edit_set_state(const Variant &p_state) {
Array state = p_state;
- ERR_FAIL_COND( state.size() != 3);
+ ERR_FAIL_COND(state.size() != 3);
pos = state[0];
angle = state[1];
@@ -70,89 +66,82 @@ void Node2D::edit_set_state(const Variant& p_state) {
_change_notify("transform/rot");
_change_notify("transform/scale");
_change_notify("transform/pos");
-
}
-void Node2D::edit_set_rect(const Rect2& p_edit_rect) {
+void Node2D::edit_set_rect(const Rect2 &p_edit_rect) {
Rect2 r = get_item_rect();
Vector2 zero_offset;
- if (r.size.x!=0)
+ if (r.size.x != 0)
zero_offset.x = -r.pos.x / r.size.x;
- if (r.size.y!=0)
+ if (r.size.y != 0)
zero_offset.y = -r.pos.y / r.size.y;
- Size2 new_scale(1,1);
+ Size2 new_scale(1, 1);
- if (r.size.x!=0)
+ if (r.size.x != 0)
new_scale.x = p_edit_rect.size.x / r.size.x;
- if (r.size.y!=0)
+ if (r.size.y != 0)
new_scale.y = p_edit_rect.size.y / r.size.y;
- Point2 new_pos = p_edit_rect.pos + p_edit_rect.size*zero_offset;//p_edit_rect.pos - r.pos;
+ Point2 new_pos = p_edit_rect.pos + p_edit_rect.size * zero_offset; //p_edit_rect.pos - r.pos;
Matrix32 postxf;
- postxf.set_rotation_and_scale(angle,_scale);
+ postxf.set_rotation_and_scale(angle, _scale);
new_pos = postxf.xform(new_pos);
- pos+=new_pos;
- _scale*=new_scale;
+ pos += new_pos;
+ _scale *= new_scale;
_update_transform();
_change_notify("transform/scale");
_change_notify("transform/pos");
-
}
-
void Node2D::edit_rotate(float p_rot) {
- angle+=p_rot;
+ angle += p_rot;
_update_transform();
_change_notify("transform/rot");
}
-
void Node2D::_update_xform_values() {
- pos=_mat.elements[2];
- angle=_mat.get_rotation();
- _scale=_mat.get_scale();
- _xform_dirty=false;
+ pos = _mat.elements[2];
+ angle = _mat.get_rotation();
+ _scale = _mat.get_scale();
+ _xform_dirty = false;
}
void Node2D::_update_transform() {
- Matrix32 mat(angle,pos);
- _mat.set_rotation_and_scale(angle,_scale);
- _mat.elements[2]=pos;
+ Matrix32 mat(angle, pos);
+ _mat.set_rotation_and_scale(angle, _scale);
+ _mat.elements[2] = pos;
- VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),_mat);
+ VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
if (!is_inside_tree())
return;
-
_notify_transform();
}
-void Node2D::set_pos(const Point2& p_pos) {
+void Node2D::set_pos(const Point2 &p_pos) {
if (_xform_dirty)
- ((Node2D*)this)->_update_xform_values();
- pos=p_pos;
+ ((Node2D *)this)->_update_xform_values();
+ pos = p_pos;
_update_transform();
_change_notify("transform/pos");
-
-
}
void Node2D::set_rot(float p_radians) {
if (_xform_dirty)
- ((Node2D*)this)->_update_xform_values();
- angle=p_radians;
+ ((Node2D *)this)->_update_xform_values();
+ angle = p_radians;
_update_transform();
_change_notify("transform/rot");
}
@@ -170,29 +159,28 @@ void Node2D::_set_rotd(float p_degrees) {
set_rotd(p_degrees);
}
-void Node2D::set_scale(const Size2& p_scale) {
+void Node2D::set_scale(const Size2 &p_scale) {
if (_xform_dirty)
- ((Node2D*)this)->_update_xform_values();
- _scale=p_scale;
- if (_scale.x==0)
- _scale.x=CMP_EPSILON;
- if (_scale.y==0)
- _scale.y=CMP_EPSILON;
+ ((Node2D *)this)->_update_xform_values();
+ _scale = p_scale;
+ if (_scale.x == 0)
+ _scale.x = CMP_EPSILON;
+ if (_scale.y == 0)
+ _scale.y = CMP_EPSILON;
_update_transform();
_change_notify("transform/scale");
-
}
Point2 Node2D::get_pos() const {
if (_xform_dirty)
- ((Node2D*)this)->_update_xform_values();
+ ((Node2D *)this)->_update_xform_values();
return pos;
}
float Node2D::get_rot() const {
if (_xform_dirty)
- ((Node2D*)this)->_update_xform_values();
+ ((Node2D *)this)->_update_xform_values();
return angle;
}
@@ -209,16 +197,14 @@ float Node2D::_get_rotd() const {
}
Size2 Node2D::get_scale() const {
if (_xform_dirty)
- ((Node2D*)this)->_update_xform_values();
+ ((Node2D *)this)->_update_xform_values();
return _scale;
}
-
void Node2D::_notification(int p_what) {
- switch(p_what) {
-
+ switch (p_what) {
}
}
@@ -231,59 +217,57 @@ Rect2 Node2D::get_item_rect() const {
if (get_script_instance()) {
Variant::CallError err;
- Rect2 r = get_script_instance()->call("_get_item_rect",NULL,0,err);
- if (err.error==Variant::CallError::CALL_OK)
+ Rect2 r = get_script_instance()->call("_get_item_rect", NULL, 0, err);
+ if (err.error == Variant::CallError::CALL_OK)
return r;
}
- return Rect2(Point2(-32,-32),Size2(64,64));
+ return Rect2(Point2(-32, -32), Size2(64, 64));
}
void Node2D::rotate(float p_radians) {
- set_rot( get_rot() + p_radians);
+ set_rot(get_rot() + p_radians);
}
-void Node2D::translate(const Vector2& p_amount) {
+void Node2D::translate(const Vector2 &p_amount) {
- set_pos( get_pos() + p_amount );
+ set_pos(get_pos() + p_amount);
}
-void Node2D::global_translate(const Vector2& p_amount) {
+void Node2D::global_translate(const Vector2 &p_amount) {
- set_global_pos( get_global_pos() + p_amount );
+ set_global_pos(get_global_pos() + p_amount);
}
-void Node2D::scale(const Size2& p_amount) {
+void Node2D::scale(const Size2 &p_amount) {
- set_scale( get_scale() * p_amount );
+ set_scale(get_scale() * p_amount);
}
-
-void Node2D::move_x(float p_delta,bool p_scaled){
+void Node2D::move_x(float p_delta, bool p_scaled) {
Matrix32 t = get_transform();
Vector2 m = t[0];
if (!p_scaled)
m.normalize();
- set_pos(t[2]+m*p_delta);
+ set_pos(t[2] + m * p_delta);
}
-void Node2D::move_y(float p_delta,bool p_scaled){
+void Node2D::move_y(float p_delta, bool p_scaled) {
Matrix32 t = get_transform();
Vector2 m = t[1];
if (!p_scaled)
m.normalize();
- set_pos(t[2]+m*p_delta);
+ set_pos(t[2] + m * p_delta);
}
-
Point2 Node2D::get_global_pos() const {
return get_global_transform().get_origin();
}
-void Node2D::set_global_pos(const Point2& p_pos) {
+void Node2D::set_global_pos(const Point2 &p_pos) {
Matrix32 inv;
CanvasItem *pi = get_parent_item();
@@ -295,7 +279,6 @@ void Node2D::set_global_pos(const Point2& p_pos) {
}
}
-
float Node2D::get_global_rot() const {
return get_global_transform().get_rotation();
@@ -312,7 +295,6 @@ void Node2D::set_global_rot(float p_radians) {
}
}
-
float Node2D::get_global_rotd() const {
return Math::rad2deg(get_global_rot());
@@ -323,13 +305,12 @@ void Node2D::set_global_rotd(float p_degrees) {
set_global_rot(Math::deg2rad(p_degrees));
}
-
Size2 Node2D::get_global_scale() const {
return get_global_transform().get_scale();
}
-void Node2D::set_global_scale(const Size2& p_scale) {
+void Node2D::set_global_scale(const Size2 &p_scale) {
CanvasItem *pi = get_parent_item();
if (pi) {
@@ -338,16 +319,14 @@ void Node2D::set_global_scale(const Size2& p_scale) {
} else {
set_scale(p_scale);
}
-
}
+void Node2D::set_transform(const Matrix32 &p_transform) {
-void Node2D::set_transform(const Matrix32& p_transform) {
+ _mat = p_transform;
+ _xform_dirty = true;
- _mat=p_transform;
- _xform_dirty=true;
-
- VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),_mat);
+ VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
if (!is_inside_tree())
return;
@@ -355,32 +334,29 @@ void Node2D::set_transform(const Matrix32& p_transform) {
_notify_transform();
}
-void Node2D::set_global_transform(const Matrix32& p_transform) {
+void Node2D::set_global_transform(const Matrix32 &p_transform) {
CanvasItem *pi = get_parent_item();
if (pi)
- set_transform( pi->get_global_transform().affine_inverse() * p_transform);
+ set_transform(pi->get_global_transform().affine_inverse() * p_transform);
else
set_transform(p_transform);
-
-
}
void Node2D::set_z(int p_z) {
- ERR_FAIL_COND(p_z<VS::CANVAS_ITEM_Z_MIN);
- ERR_FAIL_COND(p_z>VS::CANVAS_ITEM_Z_MAX);
- z=p_z;
- VS::get_singleton()->canvas_item_set_z(get_canvas_item(),z);
-
+ ERR_FAIL_COND(p_z < VS::CANVAS_ITEM_Z_MIN);
+ ERR_FAIL_COND(p_z > VS::CANVAS_ITEM_Z_MAX);
+ z = p_z;
+ VS::get_singleton()->canvas_item_set_z(get_canvas_item(), z);
}
void Node2D::set_z_as_relative(bool p_enabled) {
- if (z_relative==p_enabled)
+ if (z_relative == p_enabled)
return;
- z_relative=p_enabled;
- VS::get_singleton()->canvas_item_set_z_as_relative_to_parent(get_canvas_item(),p_enabled);
+ z_relative = p_enabled;
+ VS::get_singleton()->canvas_item_set_z_as_relative_to_parent(get_canvas_item(), p_enabled);
}
bool Node2D::is_z_relative() const {
@@ -388,104 +364,95 @@ bool Node2D::is_z_relative() const {
return z_relative;
}
-
-int Node2D::get_z() const{
+int Node2D::get_z() const {
return z;
}
Matrix32 Node2D::get_relative_transform_to_parent(const Node *p_parent) const {
- if (p_parent==this)
+ if (p_parent == this)
return Matrix32();
Node2D *parent_2d = get_parent()->cast_to<Node2D>();
- ERR_FAIL_COND_V(!parent_2d,Matrix32());
- if (p_parent==parent_2d)
+ ERR_FAIL_COND_V(!parent_2d, Matrix32());
+ if (p_parent == parent_2d)
return get_transform();
else
return parent_2d->get_relative_transform_to_parent(p_parent) * get_transform();
}
-
-void Node2D::look_at(const Vector2& p_pos) {
+void Node2D::look_at(const Vector2 &p_pos) {
rotate(get_angle_to(p_pos));
}
-float Node2D::get_angle_to(const Vector2& p_pos) const {
+float Node2D::get_angle_to(const Vector2 &p_pos) const {
return (get_global_transform().affine_inverse().xform(p_pos)).angle();
}
void Node2D::_bind_methods() {
-
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_get_rotd"),&Node2D::_get_rotd);
- ObjectTypeDB::bind_method(_MD("_set_rotd","degrees"),&Node2D::_set_rotd);
-
- ObjectTypeDB::bind_method(_MD("set_pos","pos"),&Node2D::set_pos);
- ObjectTypeDB::bind_method(_MD("set_rot","radians"),&Node2D::set_rot);
- ObjectTypeDB::bind_method(_MD("set_rotd","degrees"),&Node2D::set_rotd);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Node2D::set_scale);
-
- ObjectTypeDB::bind_method(_MD("get_pos"),&Node2D::get_pos);
- ObjectTypeDB::bind_method(_MD("get_rot"),&Node2D::get_rot);
- ObjectTypeDB::bind_method(_MD("get_rotd"),&Node2D::get_rotd);
- ObjectTypeDB::bind_method(_MD("get_scale"),&Node2D::get_scale);
+ ObjectTypeDB::bind_method(_MD("_get_rotd"), &Node2D::_get_rotd);
+ ObjectTypeDB::bind_method(_MD("_set_rotd", "degrees"), &Node2D::_set_rotd);
- ObjectTypeDB::bind_method(_MD("rotate","radians"),&Node2D::rotate);
- ObjectTypeDB::bind_method(_MD("move_local_x","delta","scaled"),&Node2D::move_x,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("move_local_y","delta","scaled"),&Node2D::move_y,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("translate","offset"),&Node2D::translate);
- ObjectTypeDB::bind_method(_MD("global_translate","offset"),&Node2D::global_translate);
- ObjectTypeDB::bind_method(_MD("scale","ratio"),&Node2D::scale);
+ ObjectTypeDB::bind_method(_MD("set_pos", "pos"), &Node2D::set_pos);
+ ObjectTypeDB::bind_method(_MD("set_rot", "radians"), &Node2D::set_rot);
+ ObjectTypeDB::bind_method(_MD("set_rotd", "degrees"), &Node2D::set_rotd);
+ ObjectTypeDB::bind_method(_MD("set_scale", "scale"), &Node2D::set_scale);
- ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Node2D::set_global_pos);
- ObjectTypeDB::bind_method(_MD("get_global_pos"),&Node2D::get_global_pos);
- ObjectTypeDB::bind_method(_MD("set_global_rot","radians"),&Node2D::set_global_rot);
- ObjectTypeDB::bind_method(_MD("get_global_rot"),&Node2D::get_global_rot);
- ObjectTypeDB::bind_method(_MD("set_global_rotd","degrees"),&Node2D::set_global_rotd);
- ObjectTypeDB::bind_method(_MD("get_global_rotd"),&Node2D::get_global_rotd);
- ObjectTypeDB::bind_method(_MD("set_global_scale","scale"),&Node2D::set_global_scale);
- ObjectTypeDB::bind_method(_MD("get_global_scale"),&Node2D::get_global_scale);
+ ObjectTypeDB::bind_method(_MD("get_pos"), &Node2D::get_pos);
+ ObjectTypeDB::bind_method(_MD("get_rot"), &Node2D::get_rot);
+ ObjectTypeDB::bind_method(_MD("get_rotd"), &Node2D::get_rotd);
+ ObjectTypeDB::bind_method(_MD("get_scale"), &Node2D::get_scale);
- ObjectTypeDB::bind_method(_MD("set_transform","xform"),&Node2D::set_transform);
- ObjectTypeDB::bind_method(_MD("set_global_transform","xform"),&Node2D::set_global_transform);
+ ObjectTypeDB::bind_method(_MD("rotate", "radians"), &Node2D::rotate);
+ ObjectTypeDB::bind_method(_MD("move_local_x", "delta", "scaled"), &Node2D::move_x, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("move_local_y", "delta", "scaled"), &Node2D::move_y, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("translate", "offset"), &Node2D::translate);
+ ObjectTypeDB::bind_method(_MD("global_translate", "offset"), &Node2D::global_translate);
+ ObjectTypeDB::bind_method(_MD("scale", "ratio"), &Node2D::scale);
- ObjectTypeDB::bind_method(_MD("look_at","point"),&Node2D::look_at);
- ObjectTypeDB::bind_method(_MD("get_angle_to","point"),&Node2D::get_angle_to);
+ ObjectTypeDB::bind_method(_MD("set_global_pos", "pos"), &Node2D::set_global_pos);
+ ObjectTypeDB::bind_method(_MD("get_global_pos"), &Node2D::get_global_pos);
+ ObjectTypeDB::bind_method(_MD("set_global_rot", "radians"), &Node2D::set_global_rot);
+ ObjectTypeDB::bind_method(_MD("get_global_rot"), &Node2D::get_global_rot);
+ ObjectTypeDB::bind_method(_MD("set_global_rotd", "degrees"), &Node2D::set_global_rotd);
+ ObjectTypeDB::bind_method(_MD("get_global_rotd"), &Node2D::get_global_rotd);
+ ObjectTypeDB::bind_method(_MD("set_global_scale", "scale"), &Node2D::set_global_scale);
+ ObjectTypeDB::bind_method(_MD("get_global_scale"), &Node2D::get_global_scale);
- ObjectTypeDB::bind_method(_MD("set_z","z"),&Node2D::set_z);
- ObjectTypeDB::bind_method(_MD("get_z"),&Node2D::get_z);
+ ObjectTypeDB::bind_method(_MD("set_transform", "xform"), &Node2D::set_transform);
+ ObjectTypeDB::bind_method(_MD("set_global_transform", "xform"), &Node2D::set_global_transform);
- ObjectTypeDB::bind_method(_MD("set_z_as_relative","enable"),&Node2D::set_z_as_relative);
- ObjectTypeDB::bind_method(_MD("is_z_relative"),&Node2D::is_z_relative);
+ ObjectTypeDB::bind_method(_MD("look_at", "point"), &Node2D::look_at);
+ ObjectTypeDB::bind_method(_MD("get_angle_to", "point"), &Node2D::get_angle_to);
- ObjectTypeDB::bind_method(_MD("edit_set_pivot","pivot"),&Node2D::edit_set_pivot);
+ ObjectTypeDB::bind_method(_MD("set_z", "z"), &Node2D::set_z);
+ ObjectTypeDB::bind_method(_MD("get_z"), &Node2D::get_z);
- ObjectTypeDB::bind_method(_MD("get_relative_transform_to_parent","parent"),&Node2D::get_relative_transform_to_parent);
+ ObjectTypeDB::bind_method(_MD("set_z_as_relative", "enable"), &Node2D::set_z_as_relative);
+ ObjectTypeDB::bind_method(_MD("is_z_relative"), &Node2D::is_z_relative);
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"transform/pos"),_SCS("set_pos"),_SCS("get_pos"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"transform/rot",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("set_rotd"),_SCS("get_rotd"));
- ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"transform/scale"),_SCS("set_scale"),_SCS("get_scale"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"z/z",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z"),_SCS("get_z"));
- ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"z/relative"),_SCS("set_z_as_relative"),_SCS("is_z_relative"));
+ ObjectTypeDB::bind_method(_MD("edit_set_pivot", "pivot"), &Node2D::edit_set_pivot);
+ ObjectTypeDB::bind_method(_MD("get_relative_transform_to_parent", "parent"), &Node2D::get_relative_transform_to_parent);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "transform/pos"), _SCS("set_pos"), _SCS("get_pos"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "transform/rot", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), _SCS("set_rotd"), _SCS("get_rotd"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "transform/scale"), _SCS("set_scale"), _SCS("get_scale"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "z/z", PROPERTY_HINT_RANGE, itos(VS::CANVAS_ITEM_Z_MIN) + "," + itos(VS::CANVAS_ITEM_Z_MAX) + ",1"), _SCS("set_z"), _SCS("get_z"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "z/relative"), _SCS("set_z_as_relative"), _SCS("is_z_relative"));
}
-
Node2D::Node2D() {
-
- angle=0;
- _scale=Vector2(1,1);
- _xform_dirty=false;
- z=0;
- z_relative=true;
-
+ angle = 0;
+ _scale = Vector2(1, 1);
+ _xform_dirty = false;
+ z = 0;
+ z_relative = true;
}
-
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index 6e1659542..1df4806a8 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -33,7 +33,7 @@
class Node2D : public CanvasItem {
- OBJ_TYPE(Node2D, CanvasItem );
+ OBJ_TYPE(Node2D, CanvasItem);
Point2 pos;
float angle;
@@ -54,32 +54,30 @@ class Node2D : public CanvasItem {
void _update_xform_values();
protected:
-
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
virtual Variant edit_get_state() const;
- virtual void edit_set_state(const Variant& p_state);
- virtual void edit_set_rect(const Rect2& p_edit_rect);
+ virtual void edit_set_state(const Variant &p_state);
+ virtual void edit_set_rect(const Rect2 &p_edit_rect);
virtual void edit_rotate(float p_rot);
- virtual void edit_set_pivot(const Point2& p_pivot);
+ virtual void edit_set_pivot(const Point2 &p_pivot);
virtual Point2 edit_get_pivot() const;
virtual bool edit_has_pivot() const;
- void set_pos(const Point2& p_pos);
+ void set_pos(const Point2 &p_pos);
void set_rot(float p_radians);
void set_rotd(float p_degrees);
- void set_scale(const Size2& p_scale);
+ void set_scale(const Size2 &p_scale);
void rotate(float p_radians);
- void move_x(float p_delta,bool p_scaled=false);
- void move_y(float p_delta,bool p_scaled=false);
- void translate(const Vector2& p_amount);
- void global_translate(const Vector2& p_amount);
- void scale(const Size2& p_amount);
+ void move_x(float p_delta, bool p_scaled = false);
+ void move_y(float p_delta, bool p_scaled = false);
+ void translate(const Vector2 &p_amount);
+ void global_translate(const Vector2 &p_amount);
+ void scale(const Size2 &p_amount);
Point2 get_pos() const;
float get_rot() const;
@@ -92,18 +90,18 @@ public:
Size2 get_global_scale() const;
virtual Rect2 get_item_rect() const;
- void set_transform(const Matrix32& p_transform);
- void set_global_transform(const Matrix32& p_transform);
- void set_global_pos(const Point2& p_pos);
+ void set_transform(const Matrix32 &p_transform);
+ void set_global_transform(const Matrix32 &p_transform);
+ void set_global_pos(const Point2 &p_pos);
void set_global_rot(float p_radians);
void set_global_rotd(float p_degrees);
- void set_global_scale(const Size2& p_scale);
+ void set_global_scale(const Size2 &p_scale);
void set_z(int p_z);
int get_z() const;
- void look_at(const Vector2& p_pos);
- float get_angle_to(const Vector2& p_pos) const;
+ void look_at(const Vector2 &p_pos);
+ float get_angle_to(const Vector2 &p_pos) const;
void set_z_as_relative(bool p_enabled);
bool is_z_relative() const;
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index 4c466c03d..c85497795 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -29,16 +29,13 @@
#include "parallax_background.h"
#include "parallax_layer.h"
-
-
void ParallaxBackground::_notification(int p_what) {
- switch(p_what) {
-
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- group_name = "__cameras_"+itos(get_viewport().get_id());
+ group_name = "__cameras_" + itos(get_viewport().get_id());
add_to_group(group_name);
} break;
@@ -47,31 +44,27 @@ void ParallaxBackground::_notification(int p_what) {
remove_from_group(group_name);
} break;
}
-
}
-void ParallaxBackground::_camera_moved(const Matrix32& p_transform) {
-
+void ParallaxBackground::_camera_moved(const Matrix32 &p_transform) {
set_scroll_offset(p_transform.get_origin());
- set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5,0.5)));
+ set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5, 0.5)));
}
-
void ParallaxBackground::set_scroll_scale(float p_scale) {
- scale=p_scale;
+ scale = p_scale;
}
-float ParallaxBackground::get_scroll_scale() const{
+float ParallaxBackground::get_scroll_scale() const {
return scale;
}
+void ParallaxBackground::set_scroll_offset(const Point2 &p_ofs) {
-void ParallaxBackground::set_scroll_offset(const Point2& p_ofs) {
-
- offset=p_ofs;
+ offset = p_ofs;
_update_scroll();
}
@@ -81,7 +74,7 @@ void ParallaxBackground::_update_scroll() {
if (!is_inside_tree())
return;
- Vector2 ofs = base_offset+offset*base_scale;
+ Vector2 ofs = base_offset + offset * base_scale;
Size2 vps = get_viewport_size();
@@ -89,26 +82,25 @@ void ParallaxBackground::_update_scroll() {
if (limit_begin.x < limit_end.x) {
if (ofs.x < limit_begin.x)
- ofs.x=limit_begin.x;
- else if (ofs.x+vps.x > limit_end.x)
- ofs.x=limit_end.x-vps.x;
+ ofs.x = limit_begin.x;
+ else if (ofs.x + vps.x > limit_end.x)
+ ofs.x = limit_end.x - vps.x;
}
-
if (limit_begin.y < limit_end.y) {
if (ofs.y < limit_begin.y)
- ofs.y=limit_begin.y;
- else if (ofs.y+vps.y > limit_end.y)
- ofs.y=limit_end.y-vps.y;
+ ofs.y = limit_begin.y;
+ else if (ofs.y + vps.y > limit_end.y)
+ ofs.y = limit_end.y - vps.y;
}
ofs = -ofs;
- final_offset=ofs;
+ final_offset = ofs;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- ParallaxLayer *l=get_child(i)->cast_to<ParallaxLayer>();
+ ParallaxLayer *l = get_child(i)->cast_to<ParallaxLayer>();
if (!l)
continue;
@@ -124,32 +116,31 @@ Point2 ParallaxBackground::get_scroll_offset() const {
return offset;
}
-void ParallaxBackground::set_scroll_base_offset(const Point2& p_ofs) {
+void ParallaxBackground::set_scroll_base_offset(const Point2 &p_ofs) {
- base_offset=p_ofs;
+ base_offset = p_ofs;
_update_scroll();
}
-Point2 ParallaxBackground::get_scroll_base_offset() const{
+Point2 ParallaxBackground::get_scroll_base_offset() const {
return base_offset;
}
-void ParallaxBackground::set_scroll_base_scale(const Point2& p_ofs) {
+void ParallaxBackground::set_scroll_base_scale(const Point2 &p_ofs) {
- base_scale=p_ofs;
+ base_scale = p_ofs;
_update_scroll();
}
-Point2 ParallaxBackground::get_scroll_base_scale() const{
+Point2 ParallaxBackground::get_scroll_base_scale() const {
return base_scale;
}
+void ParallaxBackground::set_limit_begin(const Point2 &p_ofs) {
-void ParallaxBackground::set_limit_begin(const Point2& p_ofs) {
-
- limit_begin=p_ofs;
+ limit_begin = p_ofs;
_update_scroll();
}
@@ -158,11 +149,10 @@ Point2 ParallaxBackground::get_limit_begin() const {
return limit_begin;
}
-void ParallaxBackground::set_limit_end(const Point2& p_ofs) {
+void ParallaxBackground::set_limit_end(const Point2 &p_ofs) {
- limit_end=p_ofs;
+ limit_end = p_ofs;
_update_scroll();
-
}
Point2 ParallaxBackground::get_limit_end() const {
@@ -170,16 +160,14 @@ Point2 ParallaxBackground::get_limit_end() const {
return limit_end;
}
-void ParallaxBackground::set_ignore_camera_zoom(bool ignore){
-
- ignore_camera_zoom = ignore;
+void ParallaxBackground::set_ignore_camera_zoom(bool ignore) {
+ ignore_camera_zoom = ignore;
}
-bool ParallaxBackground::is_ignore_camera_zoom(){
-
- return ignore_camera_zoom;
+bool ParallaxBackground::is_ignore_camera_zoom() {
+ return ignore_camera_zoom;
}
Vector2 ParallaxBackground::get_final_offset() const {
@@ -189,37 +177,31 @@ Vector2 ParallaxBackground::get_final_offset() const {
void ParallaxBackground::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
- ObjectTypeDB::bind_method(_MD("set_scroll_offset","ofs"),&ParallaxBackground::set_scroll_offset);
- ObjectTypeDB::bind_method(_MD("get_scroll_offset"),&ParallaxBackground::get_scroll_offset);
- ObjectTypeDB::bind_method(_MD("set_scroll_base_offset","ofs"),&ParallaxBackground::set_scroll_base_offset);
- ObjectTypeDB::bind_method(_MD("get_scroll_base_offset"),&ParallaxBackground::get_scroll_base_offset);
- ObjectTypeDB::bind_method(_MD("set_scroll_base_scale","scale"),&ParallaxBackground::set_scroll_base_scale);
- ObjectTypeDB::bind_method(_MD("get_scroll_base_scale"),&ParallaxBackground::get_scroll_base_scale);
- ObjectTypeDB::bind_method(_MD("set_limit_begin","ofs"),&ParallaxBackground::set_limit_begin);
- ObjectTypeDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
- ObjectTypeDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
- ObjectTypeDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end);
- ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom","ignore"), &ParallaxBackground::set_ignore_camera_zoom);
- ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
-
-
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_offset"),_SCS("set_scroll_base_offset"),_SCS("get_scroll_base_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
+ ObjectTypeDB::bind_method(_MD("_camera_moved"), &ParallaxBackground::_camera_moved);
+ ObjectTypeDB::bind_method(_MD("set_scroll_offset", "ofs"), &ParallaxBackground::set_scroll_offset);
+ ObjectTypeDB::bind_method(_MD("get_scroll_offset"), &ParallaxBackground::get_scroll_offset);
+ ObjectTypeDB::bind_method(_MD("set_scroll_base_offset", "ofs"), &ParallaxBackground::set_scroll_base_offset);
+ ObjectTypeDB::bind_method(_MD("get_scroll_base_offset"), &ParallaxBackground::get_scroll_base_offset);
+ ObjectTypeDB::bind_method(_MD("set_scroll_base_scale", "scale"), &ParallaxBackground::set_scroll_base_scale);
+ ObjectTypeDB::bind_method(_MD("get_scroll_base_scale"), &ParallaxBackground::get_scroll_base_scale);
+ ObjectTypeDB::bind_method(_MD("set_limit_begin", "ofs"), &ParallaxBackground::set_limit_begin);
+ ObjectTypeDB::bind_method(_MD("get_limit_begin"), &ParallaxBackground::get_limit_begin);
+ ObjectTypeDB::bind_method(_MD("set_limit_end", "ofs"), &ParallaxBackground::set_limit_end);
+ ObjectTypeDB::bind_method(_MD("get_limit_end"), &ParallaxBackground::get_limit_end);
+ ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom", "ignore"), &ParallaxBackground::set_ignore_camera_zoom);
+ ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/offset"), _SCS("set_scroll_offset"), _SCS("get_scroll_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/base_offset"), _SCS("set_scroll_base_offset"), _SCS("get_scroll_base_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/base_scale"), _SCS("set_scroll_base_scale"), _SCS("get_scroll_base_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/limit_begin"), _SCS("set_limit_begin"), _SCS("get_limit_begin"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scroll/limit_end"), _SCS("set_limit_end"), _SCS("get_limit_end"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
}
-
-
-
-
ParallaxBackground::ParallaxBackground() {
- base_scale=Vector2(1,1);
- scale=1.0;
+ base_scale = Vector2(1, 1);
+ scale = 1.0;
set_layer(-1); //behind all by default
}
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index b4ea54558..64014055e 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -29,13 +29,13 @@
#ifndef PARALLAX_BACKGROUND_H
#define PARALLAX_BACKGROUND_H
-#include "scene/main/canvas_layer.h"
-#include "scene/2d/node_2d.h"
#include "scene/2d/camera_2d.h"
+#include "scene/2d/node_2d.h"
+#include "scene/main/canvas_layer.h"
class ParallaxBackground : public CanvasLayer {
- OBJ_TYPE( ParallaxBackground, CanvasLayer );
+ OBJ_TYPE(ParallaxBackground, CanvasLayer);
Point2 offset;
float scale;
@@ -48,30 +48,30 @@ class ParallaxBackground : public CanvasLayer {
bool ignore_camera_zoom;
void _update_scroll();
-protected:
- void _camera_moved(const Matrix32& p_transform);
+protected:
+ void _camera_moved(const Matrix32 &p_transform);
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_scroll_offset(const Point2& p_ofs);
+public:
+ void set_scroll_offset(const Point2 &p_ofs);
Point2 get_scroll_offset() const;
void set_scroll_scale(float p_ofs);
float get_scroll_scale() const;
- void set_scroll_base_offset(const Point2& p_ofs);
+ void set_scroll_base_offset(const Point2 &p_ofs);
Point2 get_scroll_base_offset() const;
- void set_scroll_base_scale(const Point2& p_ofs);
+ void set_scroll_base_scale(const Point2 &p_ofs);
Point2 get_scroll_base_scale() const;
- void set_limit_begin(const Point2& p_ofs);
+ void set_limit_begin(const Point2 &p_ofs);
Point2 get_limit_begin() const;
- void set_limit_end(const Point2& p_ofs);
+ void set_limit_end(const Point2 &p_ofs);
Point2 get_limit_end() const;
void set_ignore_camera_zoom(bool ignore);
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index d9836bc08..2862120e7 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -29,42 +29,38 @@
#include "parallax_layer.h"
#include "parallax_background.h"
-void ParallaxLayer::set_motion_scale(const Size2& p_scale) {
-
- motion_scale=p_scale;
+void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
+ motion_scale = p_scale;
ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
if (is_inside_tree() && pb) {
Vector2 ofs = pb->get_final_offset();
float scale = pb->get_scroll_scale();
- set_base_offset_and_scale(ofs,scale);
+ set_base_offset_and_scale(ofs, scale);
}
-
}
Size2 ParallaxLayer::get_motion_scale() const {
return motion_scale;
-
}
-void ParallaxLayer::set_motion_offset(const Size2& p_offset) {
+void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
- motion_offset=p_offset;
+ motion_offset = p_offset;
ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
if (is_inside_tree() && pb) {
Vector2 ofs = pb->get_final_offset();
float scale = pb->get_scroll_scale();
- set_base_offset_and_scale(ofs,scale);
+ set_base_offset_and_scale(ofs, scale);
}
}
Size2 ParallaxLayer::get_motion_offset() const {
return motion_offset;
-
}
void ParallaxLayer::_update_mirroring() {
@@ -77,68 +73,61 @@ void ParallaxLayer::_update_mirroring() {
RID c = pb->get_world_2d()->get_canvas();
RID ci = get_canvas_item();
- VisualServer::get_singleton()->canvas_set_item_mirroring(c,ci,mirroring);
+ VisualServer::get_singleton()->canvas_set_item_mirroring(c, ci, mirroring);
}
-
}
-void ParallaxLayer::set_mirroring(const Size2& p_mirroring) {
+void ParallaxLayer::set_mirroring(const Size2 &p_mirroring) {
- mirroring=p_mirroring;
- if (mirroring.x<0)
- mirroring.x=0;
- if (mirroring.y<0)
- mirroring.y=0;
+ mirroring = p_mirroring;
+ if (mirroring.x < 0)
+ mirroring.x = 0;
+ if (mirroring.y < 0)
+ mirroring.y = 0;
_update_mirroring();
-
}
-Size2 ParallaxLayer::get_mirroring() const{
+Size2 ParallaxLayer::get_mirroring() const {
return mirroring;
}
-
-
void ParallaxLayer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- orig_offset=get_pos();
- orig_scale=get_scale();
+ orig_offset = get_pos();
+ orig_scale = get_scale();
_update_mirroring();
} break;
}
}
-void ParallaxLayer::set_base_offset_and_scale(const Point2& p_offset,float p_scale) {
+void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_scale) {
if (!is_inside_tree())
return;
if (get_tree()->is_editor_hint())
return;
- Point2 new_ofs = ((orig_offset+p_offset)*motion_scale)*p_scale+motion_offset;
+ Point2 new_ofs = ((orig_offset + p_offset) * motion_scale) * p_scale + motion_offset;
if (mirroring.x) {
- double den = mirroring.x*p_scale;
- new_ofs.x -= den*ceil(new_ofs.x/den);
+ double den = mirroring.x * p_scale;
+ new_ofs.x -= den * ceil(new_ofs.x / den);
}
if (mirroring.y) {
- double den = mirroring.y*p_scale;
- new_ofs.y -= den*ceil(new_ofs.y/den);
+ double den = mirroring.y * p_scale;
+ new_ofs.y -= den * ceil(new_ofs.y / den);
}
set_pos(new_ofs);
- set_scale(Vector2(1,1)*p_scale);
-
-
+ set_scale(Vector2(1, 1) * p_scale);
}
-
String ParallaxLayer::get_configuration_warning() const {
if (!get_parent() || !get_parent()->cast_to<ParallaxBackground>()) {
@@ -150,22 +139,18 @@ String ParallaxLayer::get_configuration_warning() const {
void ParallaxLayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale);
- ObjectTypeDB::bind_method(_MD("get_motion_scale"),&ParallaxLayer::get_motion_scale);
- ObjectTypeDB::bind_method(_MD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset);
- ObjectTypeDB::bind_method(_MD("get_motion_offset"),&ParallaxLayer::get_motion_offset);
- ObjectTypeDB::bind_method(_MD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring);
- ObjectTypeDB::bind_method(_MD("get_mirroring"),&ParallaxLayer::get_mirroring);
-
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/scale"),_SCS("set_motion_scale"),_SCS("get_motion_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/offset"),_SCS("set_motion_offset"),_SCS("get_motion_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/mirroring"),_SCS("set_mirroring"),_SCS("get_mirroring"));
+ ObjectTypeDB::bind_method(_MD("set_motion_scale", "scale"), &ParallaxLayer::set_motion_scale);
+ ObjectTypeDB::bind_method(_MD("get_motion_scale"), &ParallaxLayer::get_motion_scale);
+ ObjectTypeDB::bind_method(_MD("set_motion_offset", "offset"), &ParallaxLayer::set_motion_offset);
+ ObjectTypeDB::bind_method(_MD("get_motion_offset"), &ParallaxLayer::get_motion_offset);
+ ObjectTypeDB::bind_method(_MD("set_mirroring", "mirror"), &ParallaxLayer::set_mirroring);
+ ObjectTypeDB::bind_method(_MD("get_mirroring"), &ParallaxLayer::get_mirroring);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion/scale"), _SCS("set_motion_scale"), _SCS("get_motion_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion/offset"), _SCS("set_motion_offset"), _SCS("get_motion_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "motion/mirroring"), _SCS("set_mirroring"), _SCS("get_mirroring"));
}
-
-
-ParallaxLayer::ParallaxLayer()
-{
- motion_scale=Size2(1,1);
+ParallaxLayer::ParallaxLayer() {
+ motion_scale = Size2(1, 1);
}
diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h
index 956195502..c29c3ec92 100644
--- a/scene/2d/parallax_layer.h
+++ b/scene/2d/parallax_layer.h
@@ -33,7 +33,7 @@
class ParallaxLayer : public Node2D {
- OBJ_TYPE( ParallaxLayer, Node2D );
+ OBJ_TYPE(ParallaxLayer, Node2D);
Point2 orig_offset;
Point2 orig_scale;
@@ -43,22 +43,20 @@ class ParallaxLayer : public Node2D {
void _update_mirroring();
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
- void set_motion_offset(const Size2& p_scale);
+ void set_motion_offset(const Size2 &p_scale);
Size2 get_motion_offset() const;
- void set_motion_scale(const Size2& p_scale);
+ void set_motion_scale(const Size2 &p_scale);
Size2 get_motion_scale() const;
- void set_mirroring(const Size2& p_mirroring);
+ void set_mirroring(const Size2 &p_mirroring);
Size2 get_mirroring() const;
- void set_base_offset_and_scale(const Point2& p_offsetf,float p_scale);
+ void set_base_offset_and_scale(const Point2 &p_offsetf, float p_scale);
virtual String get_configuration_warning() const;
ParallaxLayer();
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index b7c6c2094..d2c8faad0 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -28,11 +28,9 @@
/*************************************************************************/
#include "particles_2d.h"
-
-
void ParticleAttractor2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -45,16 +43,16 @@ void ParticleAttractor2D::_notification(int p_what) {
return;
Vector2 pv;
- float dr = MIN(disable_radius,radius);
- for(int i=0;i<=32;i++) {
- Vector2 v(Math::sin(i/32.0*Math_PI*2),Math::cos(i/32.0*Math_PI*2));
- if (i>0) {
- draw_line(pv*radius,v*radius,Color(0,0,0.5,0.9));
- if (dr>0) {
- draw_line(pv*dr,v*dr,Color(0.5,0,0.0,0.9));
+ float dr = MIN(disable_radius, radius);
+ for (int i = 0; i <= 32; i++) {
+ Vector2 v(Math::sin(i / 32.0 * Math_PI * 2), Math::cos(i / 32.0 * Math_PI * 2));
+ if (i > 0) {
+ draw_line(pv * radius, v * radius, Color(0, 0, 0.5, 0.9));
+ if (dr > 0) {
+ draw_line(pv * dr, v * dr, Color(0.5, 0, 0.0, 0.9));
}
}
- pv=v;
+ pv = v;
}
} break;
@@ -71,7 +69,7 @@ void ParticleAttractor2D::_owner_exited() {
ERR_FAIL_COND(!owner);
owner->attractors.erase(this);
- owner=NULL;
+ owner = NULL;
}
void ParticleAttractor2D::_update_owner() {
@@ -92,63 +90,59 @@ void ParticleAttractor2D::_update_owner() {
_set_owner(pn);
}
-void ParticleAttractor2D::_set_owner(Particles2D* p_owner) {
+void ParticleAttractor2D::_set_owner(Particles2D *p_owner) {
- if (owner==p_owner)
+ if (owner == p_owner)
return;
if (owner) {
- owner->disconnect("exit_tree",this,"_owner_exited");
+ owner->disconnect("exit_tree", this, "_owner_exited");
owner->attractors.erase(this);
- owner=NULL;
+ owner = NULL;
}
- owner=p_owner;
+ owner = p_owner;
if (owner) {
- owner->connect("exit_tree",this,"_owner_exited",varray(),CONNECT_ONESHOT);
+ owner->connect("exit_tree", this, "_owner_exited", varray(), CONNECT_ONESHOT);
owner->attractors.insert(this);
}
}
void ParticleAttractor2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&ParticleAttractor2D::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&ParticleAttractor2D::is_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&ParticleAttractor2D::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&ParticleAttractor2D::get_radius);
-
- ObjectTypeDB::bind_method(_MD("set_disable_radius","radius"),&ParticleAttractor2D::set_disable_radius);
- ObjectTypeDB::bind_method(_MD("get_disable_radius"),&ParticleAttractor2D::get_disable_radius);
+ ObjectTypeDB::bind_method(_MD("set_enabled", "enabled"), &ParticleAttractor2D::set_enabled);
+ ObjectTypeDB::bind_method(_MD("is_enabled"), &ParticleAttractor2D::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_gravity","gravity"),&ParticleAttractor2D::set_gravity);
- ObjectTypeDB::bind_method(_MD("get_gravity"),&ParticleAttractor2D::get_gravity);
+ ObjectTypeDB::bind_method(_MD("set_radius", "radius"), &ParticleAttractor2D::set_radius);
+ ObjectTypeDB::bind_method(_MD("get_radius"), &ParticleAttractor2D::get_radius);
- ObjectTypeDB::bind_method(_MD("set_absorption","absorption"),&ParticleAttractor2D::set_absorption);
- ObjectTypeDB::bind_method(_MD("get_absorption"),&ParticleAttractor2D::get_absorption);
+ ObjectTypeDB::bind_method(_MD("set_disable_radius", "radius"), &ParticleAttractor2D::set_disable_radius);
+ ObjectTypeDB::bind_method(_MD("get_disable_radius"), &ParticleAttractor2D::get_disable_radius);
- ObjectTypeDB::bind_method(_MD("set_particles_path","path"),&ParticleAttractor2D::set_particles_path);
- ObjectTypeDB::bind_method(_MD("get_particles_path"),&ParticleAttractor2D::get_particles_path);
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.1,16000,0.1"),_SCS("set_radius"),_SCS("get_radius"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"disable_radius",PROPERTY_HINT_RANGE,"0.1,16000,0.1"),_SCS("set_disable_radius"),_SCS("get_disable_radius"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-512,512,0.01"),_SCS("set_gravity"),_SCS("get_gravity"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"absorption",PROPERTY_HINT_RANGE,"0,512,0.01"),_SCS("set_absorption"),_SCS("get_absorption"));
- ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH,"particles_path",PROPERTY_HINT_RESOURCE_TYPE,"Particles2D"),_SCS("set_particles_path"),_SCS("get_particles_path"));
+ ObjectTypeDB::bind_method(_MD("set_gravity", "gravity"), &ParticleAttractor2D::set_gravity);
+ ObjectTypeDB::bind_method(_MD("get_gravity"), &ParticleAttractor2D::get_gravity);
+ ObjectTypeDB::bind_method(_MD("set_absorption", "absorption"), &ParticleAttractor2D::set_absorption);
+ ObjectTypeDB::bind_method(_MD("get_absorption"), &ParticleAttractor2D::get_absorption);
+ ObjectTypeDB::bind_method(_MD("set_particles_path", "path"), &ParticleAttractor2D::set_particles_path);
+ ObjectTypeDB::bind_method(_MD("get_particles_path"), &ParticleAttractor2D::get_particles_path);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.1,16000,0.1"), _SCS("set_radius"), _SCS("get_radius"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "disable_radius", PROPERTY_HINT_RANGE, "0.1,16000,0.1"), _SCS("set_disable_radius"), _SCS("get_disable_radius"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity", PROPERTY_HINT_RANGE, "-512,512,0.01"), _SCS("set_gravity"), _SCS("get_gravity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "absorption", PROPERTY_HINT_RANGE, "0,512,0.01"), _SCS("set_absorption"), _SCS("get_absorption"));
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "particles_path", PROPERTY_HINT_RESOURCE_TYPE, "Particles2D"), _SCS("set_particles_path"), _SCS("get_particles_path"));
}
-
void ParticleAttractor2D::set_enabled(bool p_enabled) {
- enabled=p_enabled;
+ enabled = p_enabled;
}
-bool ParticleAttractor2D::is_enabled() const{
+bool ParticleAttractor2D::is_enabled() const {
return enabled;
}
@@ -176,8 +170,7 @@ float ParticleAttractor2D::get_disable_radius() const {
void ParticleAttractor2D::set_gravity(float p_gravity) {
- gravity=p_gravity;
-
+ gravity = p_gravity;
}
float ParticleAttractor2D::get_gravity() const {
@@ -186,8 +179,7 @@ float ParticleAttractor2D::get_gravity() const {
void ParticleAttractor2D::set_absorption(float p_absorption) {
- absorption=p_absorption;
-
+ absorption = p_absorption;
}
float ParticleAttractor2D::get_absorption() const {
@@ -196,7 +188,7 @@ float ParticleAttractor2D::get_absorption() const {
void ParticleAttractor2D::set_particles_path(NodePath p_path) {
- path=p_path;
+ path = p_path;
_update_owner();
update_configuration_warning();
}
@@ -216,13 +208,13 @@ String ParticleAttractor2D::get_configuration_warning() const {
ParticleAttractor2D::ParticleAttractor2D() {
- owner=NULL;
- radius=50;
- disable_radius=0;
- gravity=100;
- absorption=0;
- path=String("..");
- enabled=true;
+ owner = NULL;
+ radius = 50;
+ disable_radius = 0;
+ gravity = 100;
+ absorption = 0;
+ path = String("..");
+ enabled = true;
}
/****************************************/
@@ -239,19 +231,19 @@ _FORCE_INLINE_ static float _rand_from_seed(uint32_t *seed) {
s += 2147483647;
(*seed) = s;
- float v=((float)((*seed) & 0xFFFFF))/(float)0xFFFFF;
- v=v*2.0-1.0;
+ float v = ((float)((*seed) & 0xFFFFF)) / (float)0xFFFFF;
+ v = v * 2.0 - 1.0;
return v;
}
void Particles2D::_process_particles(float p_delta) {
- if (particles.size()==0 || lifetime==0)
+ if (particles.size() == 0 || lifetime == 0)
return;
- p_delta*=time_scale;
+ p_delta *= time_scale;
- float frame_time=p_delta;
+ float frame_time = p_delta;
if (emit_timeout > 0) {
time_to_live -= frame_time;
@@ -262,114 +254,110 @@ void Particles2D::_process_particles(float p_delta) {
};
};
- float next_time = time+frame_time;
+ float next_time = time + frame_time;
if (next_time > lifetime)
- next_time=Math::fmod(next_time,lifetime);
-
+ next_time = Math::fmod(next_time, lifetime);
- Particle *pdata=&particles[0];
- int particle_count=particles.size();
+ Particle *pdata = &particles[0];
+ int particle_count = particles.size();
Matrix32 xform;
if (!local_space)
- xform=get_global_transform();
+ xform = get_global_transform();
- active_count=0;
+ active_count = 0;
DVector<Point2>::Read r;
- int emission_point_count=0;
+ int emission_point_count = 0;
if (emission_points.size()) {
- emission_point_count=emission_points.size();
- r=emission_points.read();
+ emission_point_count = emission_points.size();
+ r = emission_points.read();
}
- int attractor_count=0;
- AttractorCache *attractor_ptr=NULL;
+ int attractor_count = 0;
+ AttractorCache *attractor_ptr = NULL;
if (attractors.size()) {
- if (attractors.size()!=attractor_cache.size()) {
+ if (attractors.size() != attractor_cache.size()) {
attractor_cache.resize(attractors.size());
}
- int idx=0;
+ int idx = 0;
Matrix32 m;
if (local_space) {
- m= get_global_transform().affine_inverse();
+ m = get_global_transform().affine_inverse();
}
- for (Set<ParticleAttractor2D*>::Element *E=attractors.front();E;E=E->next()) {
+ for (Set<ParticleAttractor2D *>::Element *E = attractors.front(); E; E = E->next()) {
- attractor_cache[idx].pos=m.xform( E->get()->get_global_pos() );
- attractor_cache[idx].attractor=E->get();
+ attractor_cache[idx].pos = m.xform(E->get()->get_global_pos());
+ attractor_cache[idx].attractor = E->get();
idx++;
}
- attractor_ptr=attractor_cache.ptr();
- attractor_count=attractor_cache.size();
+ attractor_ptr = attractor_cache.ptr();
+ attractor_count = attractor_cache.size();
}
- for(int i=0;i<particle_count;i++) {
+ for (int i = 0; i < particle_count; i++) {
- Particle &p=pdata[i];
+ Particle &p = pdata[i];
float restart_time = (i * lifetime / particle_count) * explosiveness;
- bool restart=false;
+ bool restart = false;
- if ( next_time < time ) {
+ if (next_time < time) {
- if (restart_time > time || restart_time < next_time )
- restart=true;
+ if (restart_time > time || restart_time < next_time)
+ restart = true;
- } else if (restart_time > time && restart_time < next_time ) {
- restart=true;
+ } else if (restart_time > time && restart_time < next_time) {
+ restart = true;
}
if (restart) {
-
if (emitting) {
- p.pos=emissor_offset;
+ p.pos = emissor_offset;
if (emission_point_count) {
-
- Vector2 ep = r[Math::rand()%emission_point_count];
+ Vector2 ep = r[Math::rand() % emission_point_count];
if (!local_space) {
- p.pos=xform.xform(p.pos+ep*extents);
+ p.pos = xform.xform(p.pos + ep * extents);
} else {
- p.pos+=ep*extents;
+ p.pos += ep * extents;
}
} else {
if (!local_space) {
- p.pos=xform.xform(p.pos+Vector2(Math::random(-extents.x,extents.x),Math::random(-extents.y,extents.y)));
+ p.pos = xform.xform(p.pos + Vector2(Math::random(-extents.x, extents.x), Math::random(-extents.y, extents.y)));
} else {
- p.pos+=Vector2(Math::random(-extents.x,extents.x),Math::random(-extents.y,extents.y));
+ p.pos += Vector2(Math::random(-extents.x, extents.x), Math::random(-extents.y, extents.y));
}
}
- p.seed=Math::rand() % 12345678;
- uint32_t rand_seed=p.seed*(i+1);
+ p.seed = Math::rand() % 12345678;
+ uint32_t rand_seed = p.seed * (i + 1);
- float angle = Math::deg2rad(param[PARAM_DIRECTION]+_rand_from_seed(&rand_seed)*param[PARAM_SPREAD]);
+ float angle = Math::deg2rad(param[PARAM_DIRECTION] + _rand_from_seed(&rand_seed) * param[PARAM_SPREAD]);
- p.velocity=Vector2( Math::sin(angle), Math::cos(angle) );
+ p.velocity = Vector2(Math::sin(angle), Math::cos(angle));
if (!local_space) {
p.velocity = xform.basis_xform(p.velocity).normalized();
}
- p.velocity*=param[PARAM_LINEAR_VELOCITY]+param[PARAM_LINEAR_VELOCITY]*_rand_from_seed(&rand_seed)*randomness[PARAM_LINEAR_VELOCITY];
- p.velocity+=initial_velocity;
- p.active=true;
- p.rot=Math::deg2rad(param[PARAM_INITIAL_ANGLE]+param[PARAM_INITIAL_ANGLE]*randomness[PARAM_INITIAL_ANGLE]*_rand_from_seed(&rand_seed));
+ p.velocity *= param[PARAM_LINEAR_VELOCITY] + param[PARAM_LINEAR_VELOCITY] * _rand_from_seed(&rand_seed) * randomness[PARAM_LINEAR_VELOCITY];
+ p.velocity += initial_velocity;
+ p.active = true;
+ p.rot = Math::deg2rad(param[PARAM_INITIAL_ANGLE] + param[PARAM_INITIAL_ANGLE] * randomness[PARAM_INITIAL_ANGLE] * _rand_from_seed(&rand_seed));
active_count++;
- p.frame=Math::fmod(param[PARAM_ANIM_INITIAL_POS]+randomness[PARAM_ANIM_INITIAL_POS]*_rand_from_seed(&rand_seed),1.0);
-
+ p.frame = Math::fmod(param[PARAM_ANIM_INITIAL_POS] + randomness[PARAM_ANIM_INITIAL_POS] * _rand_from_seed(&rand_seed), 1.0);
} else {
- p.active=false;
+ p.active = false;
}
} else {
@@ -377,135 +365,121 @@ void Particles2D::_process_particles(float p_delta) {
if (!p.active)
continue;
- uint32_t rand_seed=p.seed*(i+1);
+ uint32_t rand_seed = p.seed * (i + 1);
Vector2 force;
//apply gravity
- float gravity_dir = Math::deg2rad( param[PARAM_GRAVITY_DIRECTION]+180*randomness[PARAM_GRAVITY_DIRECTION]*_rand_from_seed(&rand_seed));
- force+=Vector2( Math::sin(gravity_dir), Math::cos(gravity_dir) ) * (param[PARAM_GRAVITY_STRENGTH]+param[PARAM_GRAVITY_STRENGTH]*randomness[PARAM_GRAVITY_STRENGTH]*_rand_from_seed(&rand_seed));
+ float gravity_dir = Math::deg2rad(param[PARAM_GRAVITY_DIRECTION] + 180 * randomness[PARAM_GRAVITY_DIRECTION] * _rand_from_seed(&rand_seed));
+ force += Vector2(Math::sin(gravity_dir), Math::cos(gravity_dir)) * (param[PARAM_GRAVITY_STRENGTH] + param[PARAM_GRAVITY_STRENGTH] * randomness[PARAM_GRAVITY_STRENGTH] * _rand_from_seed(&rand_seed));
//apply radial
Vector2 rvec = (p.pos - emissor_offset).normalized();
- force+=rvec*(param[PARAM_RADIAL_ACCEL]+param[PARAM_RADIAL_ACCEL]*randomness[PARAM_RADIAL_ACCEL]*_rand_from_seed(&rand_seed));
+ force += rvec * (param[PARAM_RADIAL_ACCEL] + param[PARAM_RADIAL_ACCEL] * randomness[PARAM_RADIAL_ACCEL] * _rand_from_seed(&rand_seed));
//apply orbit
- float orbitvel = (param[PARAM_ORBIT_VELOCITY]+param[PARAM_ORBIT_VELOCITY]*randomness[PARAM_ORBIT_VELOCITY]*_rand_from_seed(&rand_seed));
- if (orbitvel!=0) {
+ float orbitvel = (param[PARAM_ORBIT_VELOCITY] + param[PARAM_ORBIT_VELOCITY] * randomness[PARAM_ORBIT_VELOCITY] * _rand_from_seed(&rand_seed));
+ if (orbitvel != 0) {
Vector2 rel = p.pos - xform.elements[2];
- Matrix32 rot(orbitvel*frame_time,Vector2());
+ Matrix32 rot(orbitvel * frame_time, Vector2());
p.pos = rot.xform(rel) + xform.elements[2];
-
}
- Vector2 tvec=rvec.tangent();
- force+=tvec*(param[PARAM_TANGENTIAL_ACCEL]+param[PARAM_TANGENTIAL_ACCEL]*randomness[PARAM_TANGENTIAL_ACCEL]*_rand_from_seed(&rand_seed));
+ Vector2 tvec = rvec.tangent();
+ force += tvec * (param[PARAM_TANGENTIAL_ACCEL] + param[PARAM_TANGENTIAL_ACCEL] * randomness[PARAM_TANGENTIAL_ACCEL] * _rand_from_seed(&rand_seed));
- for(int j=0;j<attractor_count;j++) {
+ for (int j = 0; j < attractor_count; j++) {
Vector2 vec = (attractor_ptr[j].pos - p.pos);
float vl = vec.length();
- if (!attractor_ptr[j].attractor->enabled || vl==0 || vl > attractor_ptr[j].attractor->radius)
+ if (!attractor_ptr[j].attractor->enabled || vl == 0 || vl > attractor_ptr[j].attractor->radius)
continue;
-
-
- force+=vec*attractor_ptr[j].attractor->gravity;
+ force += vec * attractor_ptr[j].attractor->gravity;
float fvl = p.velocity.length();
if (fvl && attractor_ptr[j].attractor->absorption) {
Vector2 target = vec.normalized();
- p.velocity = p.velocity.normalized().linear_interpolate(target,MIN(frame_time*attractor_ptr[j].attractor->absorption,1))*fvl;
+ p.velocity = p.velocity.normalized().linear_interpolate(target, MIN(frame_time * attractor_ptr[j].attractor->absorption, 1)) * fvl;
}
if (attractor_ptr[j].attractor->disable_radius && vl < attractor_ptr[j].attractor->disable_radius) {
- p.active=false;
+ p.active = false;
}
}
- p.velocity+=force*frame_time;
+ p.velocity += force * frame_time;
if (param[PARAM_DAMPING]) {
- float dmp = param[PARAM_DAMPING]+param[PARAM_DAMPING]*randomness[PARAM_DAMPING]*_rand_from_seed(&rand_seed);
+ float dmp = param[PARAM_DAMPING] + param[PARAM_DAMPING] * randomness[PARAM_DAMPING] * _rand_from_seed(&rand_seed);
float v = p.velocity.length();
v -= dmp * frame_time;
- if (v<=0) {
- p.velocity=Vector2();
+ if (v <= 0) {
+ p.velocity = Vector2();
} else {
- p.velocity=p.velocity.normalized() * v;
+ p.velocity = p.velocity.normalized() * v;
}
-
}
- p.pos+=p.velocity*frame_time;
- p.rot+=Math::lerp(param[PARAM_SPIN_VELOCITY],param[PARAM_SPIN_VELOCITY]*randomness[PARAM_SPIN_VELOCITY]*_rand_from_seed(&rand_seed),randomness[PARAM_SPIN_VELOCITY])*frame_time;
- float anim_spd=param[PARAM_ANIM_SPEED_SCALE]+param[PARAM_ANIM_SPEED_SCALE]*randomness[PARAM_ANIM_SPEED_SCALE]*_rand_from_seed(&rand_seed);
- p.frame=Math::fposmod(p.frame+(frame_time/lifetime)*anim_spd,1.0);
+ p.pos += p.velocity * frame_time;
+ p.rot += Math::lerp(param[PARAM_SPIN_VELOCITY], param[PARAM_SPIN_VELOCITY] * randomness[PARAM_SPIN_VELOCITY] * _rand_from_seed(&rand_seed), randomness[PARAM_SPIN_VELOCITY]) * frame_time;
+ float anim_spd = param[PARAM_ANIM_SPEED_SCALE] + param[PARAM_ANIM_SPEED_SCALE] * randomness[PARAM_ANIM_SPEED_SCALE] * _rand_from_seed(&rand_seed);
+ p.frame = Math::fposmod(p.frame + (frame_time / lifetime) * anim_spd, 1.0);
active_count++;
-
}
-
-
}
-
-
- time=Math::fmod( time+frame_time, lifetime );
- if (!emitting && active_count==0) {
+ time = Math::fmod(time + frame_time, lifetime);
+ if (!emitting && active_count == 0) {
set_process(false);
set_fixed_process(false);
}
update();
-
-
}
-
void Particles2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_PROCESS: {
- _process_particles( get_process_delta_time() );
+ _process_particles(get_process_delta_time());
} break;
case NOTIFICATION_FIXED_PROCESS: {
- _process_particles( get_fixed_process_delta_time() );
+ _process_particles(get_fixed_process_delta_time());
} break;
case NOTIFICATION_ENTER_TREE: {
- float ppt=preprocess;
- while(ppt>0) {
+ float ppt = preprocess;
+ while (ppt > 0) {
_process_particles(0.1);
- ppt-=0.1;
+ ppt -= 0.1;
}
} break;
case NOTIFICATION_DRAW: {
-
- if (particles.size()==0 || lifetime==0)
+ if (particles.size() == 0 || lifetime == 0)
return;
- RID ci=get_canvas_item();
- Size2 size(1,1);
+ RID ci = get_canvas_item();
+ Size2 size(1, 1);
Point2 center;
- int total_frames=1;
+ int total_frames = 1;
if (!texture.is_null()) {
- size=texture->get_size();
- size.x/=h_frames;
- size.y/=v_frames;
- total_frames=h_frames*v_frames;
+ size = texture->get_size();
+ size.x /= h_frames;
+ size.y /= v_frames;
+ total_frames = h_frames * v_frames;
}
+ float time_pos = (time / lifetime);
- float time_pos=(time/lifetime);
-
- Particle *pdata=&particles[0];
- int particle_count=particles.size();
+ Particle *pdata = &particles[0];
+ int particle_count = particles.size();
RID texrid;
@@ -514,64 +488,61 @@ void Particles2D::_notification(int p_what) {
Matrix32 invxform;
if (!local_space)
- invxform=get_global_transform().affine_inverse();
+ invxform = get_global_transform().affine_inverse();
int start_particle = (int)(time * (float)particle_count / lifetime);
- for (int id=0;id<particle_count;++id) {
+ for (int id = 0; id < particle_count; ++id) {
int i = start_particle + id;
if (i >= particle_count) {
i -= particle_count;
}
- Particle &p=pdata[i];
+ Particle &p = pdata[i];
if (!p.active)
continue;
- float ptime = ((float)i / particle_count)*explosiveness;
+ float ptime = ((float)i / particle_count) * explosiveness;
- if (ptime<time_pos)
- ptime=time_pos-ptime;
+ if (ptime < time_pos)
+ ptime = time_pos - ptime;
else
- ptime=(1.0-ptime)+time_pos;
+ ptime = (1.0 - ptime) + time_pos;
- uint32_t rand_seed=p.seed*(i+1);
+ uint32_t rand_seed = p.seed * (i + 1);
Color color;
- if(color_ramp.is_valid())
- {
+ if (color_ramp.is_valid()) {
color = color_ramp->get_color_at_offset(ptime);
- } else
- {
+ } else {
color = default_color;
}
-
{
- float huerand=_rand_from_seed(&rand_seed);
+ float huerand = _rand_from_seed(&rand_seed);
float huerot = param[PARAM_HUE_VARIATION] + randomness[PARAM_HUE_VARIATION] * huerand;
if (Math::abs(huerot) > CMP_EPSILON) {
- float h=color.get_h();
- float s=color.get_s();
- float v=color.get_v();
- float a=color.a;
+ float h = color.get_h();
+ float s = color.get_s();
+ float v = color.get_v();
+ float a = color.a;
//float preh=h;
- h+=huerot;
- h=Math::abs(Math::fposmod(h,1.0));
+ h += huerot;
+ h = Math::abs(Math::fposmod(h, 1.0));
//print_line("rand: "+rtos(randomness[PARAM_HUE_VARIATION])+" rand: "+rtos(huerand));
//print_line(itos(i)+":hue: "+rtos(preh)+" + "+rtos(huerot)+" = "+rtos(h));
- color.set_hsv(h,s,v);
- color.a=a;
+ color.set_hsv(h, s, v);
+ color.a = a;
}
}
- float initial_size = param[PARAM_INITIAL_SIZE]+param[PARAM_INITIAL_SIZE]*_rand_from_seed(&rand_seed)*randomness[PARAM_INITIAL_SIZE];
- float final_size = param[PARAM_FINAL_SIZE]+param[PARAM_FINAL_SIZE]*_rand_from_seed(&rand_seed)*randomness[PARAM_FINAL_SIZE];
+ float initial_size = param[PARAM_INITIAL_SIZE] + param[PARAM_INITIAL_SIZE] * _rand_from_seed(&rand_seed) * randomness[PARAM_INITIAL_SIZE];
+ float final_size = param[PARAM_FINAL_SIZE] + param[PARAM_FINAL_SIZE] * _rand_from_seed(&rand_seed) * randomness[PARAM_FINAL_SIZE];
- float size_mult=initial_size*(1.0-ptime) + final_size*ptime;
+ float size_mult = initial_size * (1.0 - ptime) + final_size * ptime;
//Size2 rectsize=size * size_mult;
//rectsize=rectsize.floor();
@@ -583,57 +554,49 @@ void Particles2D::_notification(int p_what) {
if (p.rot) {
xform.set_rotation(p.rot);
- xform.translate(-size*size_mult/2.0);
- xform.elements[2]+=p.pos;
+ xform.translate(-size * size_mult / 2.0);
+ xform.elements[2] += p.pos;
} else {
- xform.elements[2]=-size*size_mult/2.0;
- xform.elements[2]+=p.pos;
+ xform.elements[2] = -size * size_mult / 2.0;
+ xform.elements[2] += p.pos;
}
if (!local_space) {
xform = invxform * xform;
}
+ xform.scale_basis(Size2(size_mult, size_mult));
- xform.scale_basis(Size2(size_mult,size_mult));
-
-
- VisualServer::get_singleton()->canvas_item_add_set_transform(ci,xform);
-
+ VisualServer::get_singleton()->canvas_item_add_set_transform(ci, xform);
if (texrid.is_valid()) {
Rect2 src_rect;
- src_rect.size=size;
+ src_rect.size = size;
- if (total_frames>1) {
- int frame = Math::fast_ftoi(Math::floor(p.frame*total_frames)) % total_frames;
- src_rect.pos.x = size.x * (frame%h_frames);
- src_rect.pos.y = size.y * (frame/h_frames);
+ if (total_frames > 1) {
+ int frame = Math::fast_ftoi(Math::floor(p.frame * total_frames)) % total_frames;
+ src_rect.pos.x = size.x * (frame % h_frames);
+ src_rect.pos.y = size.y * (frame / h_frames);
}
if (flip_h)
- src_rect.size.x=-src_rect.size.x;
+ src_rect.size.x = -src_rect.size.x;
if (flip_v)
- src_rect.size.y=-src_rect.size.y;
+ src_rect.size.y = -src_rect.size.y;
- texture->draw_rect_region(ci,Rect2(Point2(),size),src_rect,color);
+ texture->draw_rect_region(ci, Rect2(Point2(), size), src_rect, color);
//VisualServer::get_singleton()->canvas_item_add_texture_rect(ci,r,texrid,false,color);
} else {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2(),size),color);
-
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(), size), color);
}
-
}
-
} break;
-
}
-
}
-static const char* _particlesframe_property_names[Particles2D::PARAM_MAX]={
+static const char *_particlesframe_property_names[Particles2D::PARAM_MAX] = {
"params/direction",
"params/spread",
"params/linear_velocity",
@@ -652,7 +615,7 @@ static const char* _particlesframe_property_names[Particles2D::PARAM_MAX]={
"params/anim_initial_pos",
};
-static const char* _particlesframe_property_rnames[Particles2D::PARAM_MAX]={
+static const char *_particlesframe_property_rnames[Particles2D::PARAM_MAX] = {
"randomness/direction",
"randomness/spread",
"randomness/linear_velocity",
@@ -671,7 +634,7 @@ static const char* _particlesframe_property_rnames[Particles2D::PARAM_MAX]={
"randomness/anim_initial_pos",
};
-static const char* _particlesframe_property_ranges[Particles2D::PARAM_MAX]={
+static const char *_particlesframe_property_ranges[Particles2D::PARAM_MAX] = {
"0,360,0.01",
"0,180,0.01",
"-1024,1024,0.01",
@@ -690,21 +653,20 @@ static const char* _particlesframe_property_ranges[Particles2D::PARAM_MAX]={
"0,1,0.01",
};
-
void Particles2D::set_emitting(bool p_emitting) {
- if (emitting==p_emitting)
+ if (emitting == p_emitting)
return;
if (p_emitting) {
- if (active_count==0)
- time=0;
- set_process(process_mode==PROCESS_IDLE);
- set_fixed_process(process_mode==PROCESS_FIXED);
+ if (active_count == 0)
+ time = 0;
+ set_process(process_mode == PROCESS_IDLE);
+ set_fixed_process(process_mode == PROCESS_FIXED);
time_to_live = emit_timeout;
}
- emitting=p_emitting;
+ emitting = p_emitting;
_change_notify("config/emitting");
}
@@ -715,10 +677,10 @@ bool Particles2D::is_emitting() const {
void Particles2D::set_process_mode(ProcessMode p_mode) {
- process_mode=p_mode;
- const bool should_process=emitting || active_count!=0;
- set_process(should_process && process_mode==PROCESS_IDLE);
- set_fixed_process(should_process && process_mode==PROCESS_FIXED);
+ process_mode = p_mode;
+ const bool should_process = emitting || active_count != 0;
+ set_process(should_process && process_mode == PROCESS_IDLE);
+ set_fixed_process(should_process && process_mode == PROCESS_FIXED);
}
Particles2D::ProcessMode Particles2D::get_process_mode() const {
@@ -728,7 +690,7 @@ Particles2D::ProcessMode Particles2D::get_process_mode() const {
void Particles2D::set_amount(int p_amount) {
- ERR_FAIL_INDEX(p_amount,1024+1);
+ ERR_FAIL_INDEX(p_amount, 1024 + 1);
particles.resize(p_amount);
}
@@ -750,9 +712,9 @@ float Particles2D::get_emit_timeout() const {
void Particles2D::set_lifetime(float p_lifetime) {
- ERR_FAIL_INDEX(p_lifetime,3600+1);
+ ERR_FAIL_INDEX(p_lifetime, 3600 + 1);
- lifetime=p_lifetime;
+ lifetime = p_lifetime;
}
float Particles2D::get_lifetime() const {
@@ -761,7 +723,7 @@ float Particles2D::get_lifetime() const {
void Particles2D::set_time_scale(float p_time_scale) {
- time_scale=p_time_scale;
+ time_scale = p_time_scale;
}
float Particles2D::get_time_scale() const {
@@ -770,42 +732,39 @@ float Particles2D::get_time_scale() const {
void Particles2D::set_pre_process_time(float p_pre_process_time) {
- preprocess=p_pre_process_time;
+ preprocess = p_pre_process_time;
}
-float Particles2D::get_pre_process_time() const{
+float Particles2D::get_pre_process_time() const {
return preprocess;
}
-
void Particles2D::set_param(Parameter p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- param[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ param[p_param] = p_value;
}
float Particles2D::get_param(Parameter p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return param[p_param];
}
void Particles2D::set_randomness(Parameter p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- randomness[p_param]=p_value;
-
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ randomness[p_param] = p_value;
}
-float Particles2D::get_randomness(Parameter p_param) const {
+float Particles2D::get_randomness(Parameter p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return randomness[p_param];
-
}
-void Particles2D::set_texture(const Ref<Texture>& p_texture) {
+void Particles2D::set_texture(const Ref<Texture> &p_texture) {
- texture=p_texture;
+ texture = p_texture;
}
Ref<Texture> Particles2D::get_texture() const {
@@ -813,7 +772,7 @@ Ref<Texture> Particles2D::get_texture() const {
return texture;
}
-void Particles2D::set_color(const Color& p_color) {
+void Particles2D::set_color(const Color &p_color) {
default_color = p_color;
}
@@ -823,10 +782,9 @@ Color Particles2D::get_color() const {
return default_color;
}
+void Particles2D::set_color_ramp(const Ref<ColorRamp> &p_color_ramp) {
-void Particles2D::set_color_ramp(const Ref<ColorRamp>& p_color_ramp) {
-
- color_ramp=p_color_ramp;
+ color_ramp = p_color_ramp;
}
Ref<ColorRamp> Particles2D::get_color_ramp() const {
@@ -834,9 +792,9 @@ Ref<ColorRamp> Particles2D::get_color_ramp() const {
return color_ramp;
}
-void Particles2D::set_emissor_offset(const Point2& p_offset) {
+void Particles2D::set_emissor_offset(const Point2 &p_offset) {
- emissor_offset=p_offset;
+ emissor_offset = p_offset;
}
Point2 Particles2D::get_emissor_offset() const {
@@ -844,10 +802,9 @@ Point2 Particles2D::get_emissor_offset() const {
return emissor_offset;
}
-
void Particles2D::set_use_local_space(bool p_use) {
- local_space=p_use;
+ local_space = p_use;
}
bool Particles2D::is_using_local_space() const {
@@ -860,12 +817,10 @@ void Particles2D::set_color_phases(int p_phases) {
//Create color ramp if we have 2 or more phases.
//Otherwise first phase phase will be assigned to default color.
- if(p_phases > 1 && color_ramp.is_null())
- {
- color_ramp = Ref<ColorRamp>(memnew (ColorRamp()));
+ if (p_phases > 1 && color_ramp.is_null()) {
+ color_ramp = Ref<ColorRamp>(memnew(ColorRamp()));
}
- if(color_ramp.is_valid())
- {
+ if (color_ramp.is_valid()) {
color_ramp->get_points().resize(p_phases);
}
}
@@ -873,24 +828,21 @@ void Particles2D::set_color_phases(int p_phases) {
//Deprecated.
int Particles2D::get_color_phases() const {
- if(color_ramp.is_valid())
- {
+ if (color_ramp.is_valid()) {
return color_ramp->get_points_count();
}
return 0;
}
//Deprecated. Converts color phases to color ramp
-void Particles2D::set_color_phase_color(int p_phase,const Color& p_color) {
+void Particles2D::set_color_phase_color(int p_phase, const Color &p_color) {
- ERR_FAIL_INDEX(p_phase,MAX_COLOR_PHASES);
- if(color_ramp.is_valid())
- {
- if(color_ramp->get_points_count() > p_phase)
+ ERR_FAIL_INDEX(p_phase, MAX_COLOR_PHASES);
+ if (color_ramp.is_valid()) {
+ if (color_ramp->get_points_count() > p_phase)
color_ramp->set_color(p_phase, p_color);
- } else
- {
- if(p_phase == 0)
+ } else {
+ if (p_phase == 0)
default_color = p_color;
}
}
@@ -898,20 +850,18 @@ void Particles2D::set_color_phase_color(int p_phase,const Color& p_color) {
//Deprecated.
Color Particles2D::get_color_phase_color(int p_phase) const {
- ERR_FAIL_INDEX_V(p_phase,MAX_COLOR_PHASES,Color());
- if(color_ramp.is_valid())
- {
+ ERR_FAIL_INDEX_V(p_phase, MAX_COLOR_PHASES, Color());
+ if (color_ramp.is_valid()) {
return color_ramp->get_color(p_phase);
}
- return Color(0,0,0,1);
+ return Color(0, 0, 0, 1);
}
//Deprecated. Converts color phases to color ramp
-void Particles2D::set_color_phase_pos(int p_phase,float p_pos) {
- ERR_FAIL_INDEX(p_phase,MAX_COLOR_PHASES);
- ERR_FAIL_COND(p_pos<0.0 || p_pos>1.0);
- if(color_ramp.is_valid() && color_ramp->get_points_count() > p_phase)
- {
+void Particles2D::set_color_phase_pos(int p_phase, float p_pos) {
+ ERR_FAIL_INDEX(p_phase, MAX_COLOR_PHASES);
+ ERR_FAIL_COND(p_pos < 0.0 || p_pos > 1.0);
+ if (color_ramp.is_valid() && color_ramp->get_points_count() > p_phase) {
return color_ramp->set_offset(p_phase, p_pos);
}
}
@@ -919,17 +869,16 @@ void Particles2D::set_color_phase_pos(int p_phase,float p_pos) {
//Deprecated.
float Particles2D::get_color_phase_pos(int p_phase) const {
- ERR_FAIL_INDEX_V(p_phase,MAX_COLOR_PHASES,0);
- if(color_ramp.is_valid())
- {
+ ERR_FAIL_INDEX_V(p_phase, MAX_COLOR_PHASES, 0);
+ if (color_ramp.is_valid()) {
return color_ramp->get_offset(p_phase);
}
return 0;
}
-void Particles2D::set_emission_half_extents(const Vector2& p_extents) {
+void Particles2D::set_emission_half_extents(const Vector2 &p_extents) {
- extents=p_extents;
+ extents = p_extents;
}
Vector2 Particles2D::get_emission_half_extents() const {
@@ -946,276 +895,267 @@ void Particles2D::testee(int a, int b, int c, int d, int e) {
print_line(itos(e));
}
-void Particles2D::set_initial_velocity(const Vector2& p_velocity) {
+void Particles2D::set_initial_velocity(const Vector2 &p_velocity) {
-
- initial_velocity=p_velocity;
+ initial_velocity = p_velocity;
}
-Vector2 Particles2D::get_initial_velocity() const{
+Vector2 Particles2D::get_initial_velocity() const {
return initial_velocity;
}
-
void Particles2D::pre_process(float p_delta) {
_process_particles(p_delta);
}
-
void Particles2D::set_explosiveness(float p_value) {
- explosiveness=p_value;
+ explosiveness = p_value;
}
-float Particles2D::get_explosiveness() const{
+float Particles2D::get_explosiveness() const {
return explosiveness;
}
void Particles2D::set_flip_h(bool p_flip) {
- flip_h=p_flip;
+ flip_h = p_flip;
}
-bool Particles2D::is_flipped_h() const{
+bool Particles2D::is_flipped_h() const {
return flip_h;
}
-void Particles2D::set_flip_v(bool p_flip){
+void Particles2D::set_flip_v(bool p_flip) {
- flip_v=p_flip;
+ flip_v = p_flip;
}
-bool Particles2D::is_flipped_v() const{
+bool Particles2D::is_flipped_v() const {
return flip_v;
}
void Particles2D::set_h_frames(int p_frames) {
- ERR_FAIL_COND(p_frames<1);
- h_frames=p_frames;
+ ERR_FAIL_COND(p_frames < 1);
+ h_frames = p_frames;
}
-int Particles2D::get_h_frames() const{
+int Particles2D::get_h_frames() const {
return h_frames;
}
-void Particles2D::set_v_frames(int p_frames){
+void Particles2D::set_v_frames(int p_frames) {
- ERR_FAIL_COND(p_frames<1);
- v_frames=p_frames;
+ ERR_FAIL_COND(p_frames < 1);
+ v_frames = p_frames;
}
-int Particles2D::get_v_frames() const{
+int Particles2D::get_v_frames() const {
return v_frames;
}
+void Particles2D::set_emission_points(const DVector<Vector2> &p_points) {
-
-void Particles2D::set_emission_points(const DVector<Vector2>& p_points) {
-
- emission_points=p_points;
+ emission_points = p_points;
}
-DVector<Vector2> Particles2D::get_emission_points() const{
+DVector<Vector2> Particles2D::get_emission_points() const {
return emission_points;
}
void Particles2D::reset() {
- for(int i=0;i<particles.size();i++) {
- particles[i].active=false;
+ for (int i = 0; i < particles.size(); i++) {
+ particles[i].active = false;
}
- time=0;
- active_count=0;
+ time = 0;
+ active_count = 0;
}
void Particles2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_emitting","active"),&Particles2D::set_emitting);
- ObjectTypeDB::bind_method(_MD("is_emitting"),&Particles2D::is_emitting);
-
- ObjectTypeDB::bind_method(_MD("set_process_mode","mode"),&Particles2D::set_process_mode);
- ObjectTypeDB::bind_method(_MD("get_process_mode"),&Particles2D::get_process_mode);
+ ObjectTypeDB::bind_method(_MD("set_emitting", "active"), &Particles2D::set_emitting);
+ ObjectTypeDB::bind_method(_MD("is_emitting"), &Particles2D::is_emitting);
- ObjectTypeDB::bind_method(_MD("set_amount","amount"),&Particles2D::set_amount);
- ObjectTypeDB::bind_method(_MD("get_amount"),&Particles2D::get_amount);
+ ObjectTypeDB::bind_method(_MD("set_process_mode", "mode"), &Particles2D::set_process_mode);
+ ObjectTypeDB::bind_method(_MD("get_process_mode"), &Particles2D::get_process_mode);
- ObjectTypeDB::bind_method(_MD("set_lifetime","lifetime"),&Particles2D::set_lifetime);
- ObjectTypeDB::bind_method(_MD("get_lifetime"),&Particles2D::get_lifetime);
+ ObjectTypeDB::bind_method(_MD("set_amount", "amount"), &Particles2D::set_amount);
+ ObjectTypeDB::bind_method(_MD("get_amount"), &Particles2D::get_amount);
- ObjectTypeDB::bind_method(_MD("set_time_scale","time_scale"),&Particles2D::set_time_scale);
- ObjectTypeDB::bind_method(_MD("get_time_scale"),&Particles2D::get_time_scale);
+ ObjectTypeDB::bind_method(_MD("set_lifetime", "lifetime"), &Particles2D::set_lifetime);
+ ObjectTypeDB::bind_method(_MD("get_lifetime"), &Particles2D::get_lifetime);
- ObjectTypeDB::bind_method(_MD("set_pre_process_time","time"),&Particles2D::set_pre_process_time);
- ObjectTypeDB::bind_method(_MD("get_pre_process_time"),&Particles2D::get_pre_process_time);
+ ObjectTypeDB::bind_method(_MD("set_time_scale", "time_scale"), &Particles2D::set_time_scale);
+ ObjectTypeDB::bind_method(_MD("get_time_scale"), &Particles2D::get_time_scale);
- ObjectTypeDB::bind_method(_MD("set_emit_timeout","value"),&Particles2D::set_emit_timeout);
- ObjectTypeDB::bind_method(_MD("get_emit_timeout"),&Particles2D::get_emit_timeout);
+ ObjectTypeDB::bind_method(_MD("set_pre_process_time", "time"), &Particles2D::set_pre_process_time);
+ ObjectTypeDB::bind_method(_MD("get_pre_process_time"), &Particles2D::get_pre_process_time);
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&Particles2D::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&Particles2D::get_param);
+ ObjectTypeDB::bind_method(_MD("set_emit_timeout", "value"), &Particles2D::set_emit_timeout);
+ ObjectTypeDB::bind_method(_MD("get_emit_timeout"), &Particles2D::get_emit_timeout);
- ObjectTypeDB::bind_method(_MD("set_randomness","param","value"),&Particles2D::set_randomness);
- ObjectTypeDB::bind_method(_MD("get_randomness","param"),&Particles2D::get_randomness);
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &Particles2D::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &Particles2D::get_param);
- ObjectTypeDB::bind_method(_MD("set_texture:Texture","texture"),&Particles2D::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&Particles2D::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_randomness", "param", "value"), &Particles2D::set_randomness);
+ ObjectTypeDB::bind_method(_MD("get_randomness", "param"), &Particles2D::get_randomness);
- ObjectTypeDB::bind_method(_MD("set_color","color"),&Particles2D::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&Particles2D::get_color);
+ ObjectTypeDB::bind_method(_MD("set_texture:Texture", "texture"), &Particles2D::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture"), &Particles2D::get_texture);
- ObjectTypeDB::bind_method(_MD("set_color_ramp:ColorRamp","color_ramp"),&Particles2D::set_color_ramp);
- ObjectTypeDB::bind_method(_MD("get_color_ramp:ColorRamp"),&Particles2D::get_color_ramp);
+ ObjectTypeDB::bind_method(_MD("set_color", "color"), &Particles2D::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color"), &Particles2D::get_color);
- ObjectTypeDB::bind_method(_MD("set_emissor_offset","offset"),&Particles2D::set_emissor_offset);
- ObjectTypeDB::bind_method(_MD("get_emissor_offset"),&Particles2D::get_emissor_offset);
+ ObjectTypeDB::bind_method(_MD("set_color_ramp:ColorRamp", "color_ramp"), &Particles2D::set_color_ramp);
+ ObjectTypeDB::bind_method(_MD("get_color_ramp:ColorRamp"), &Particles2D::get_color_ramp);
- ObjectTypeDB::bind_method(_MD("set_flip_h","enable"),&Particles2D::set_flip_h);
- ObjectTypeDB::bind_method(_MD("is_flipped_h"),&Particles2D::is_flipped_h);
+ ObjectTypeDB::bind_method(_MD("set_emissor_offset", "offset"), &Particles2D::set_emissor_offset);
+ ObjectTypeDB::bind_method(_MD("get_emissor_offset"), &Particles2D::get_emissor_offset);
- ObjectTypeDB::bind_method(_MD("set_flip_v","enable"),&Particles2D::set_flip_v);
- ObjectTypeDB::bind_method(_MD("is_flipped_v"),&Particles2D::is_flipped_v);
+ ObjectTypeDB::bind_method(_MD("set_flip_h", "enable"), &Particles2D::set_flip_h);
+ ObjectTypeDB::bind_method(_MD("is_flipped_h"), &Particles2D::is_flipped_h);
- ObjectTypeDB::bind_method(_MD("set_h_frames","enable"),&Particles2D::set_h_frames);
- ObjectTypeDB::bind_method(_MD("get_h_frames"),&Particles2D::get_h_frames);
+ ObjectTypeDB::bind_method(_MD("set_flip_v", "enable"), &Particles2D::set_flip_v);
+ ObjectTypeDB::bind_method(_MD("is_flipped_v"), &Particles2D::is_flipped_v);
- ObjectTypeDB::bind_method(_MD("set_v_frames","enable"),&Particles2D::set_v_frames);
- ObjectTypeDB::bind_method(_MD("get_v_frames"),&Particles2D::get_v_frames);
+ ObjectTypeDB::bind_method(_MD("set_h_frames", "enable"), &Particles2D::set_h_frames);
+ ObjectTypeDB::bind_method(_MD("get_h_frames"), &Particles2D::get_h_frames);
- ObjectTypeDB::bind_method(_MD("set_emission_half_extents","extents"),&Particles2D::set_emission_half_extents);
- ObjectTypeDB::bind_method(_MD("get_emission_half_extents"),&Particles2D::get_emission_half_extents);
+ ObjectTypeDB::bind_method(_MD("set_v_frames", "enable"), &Particles2D::set_v_frames);
+ ObjectTypeDB::bind_method(_MD("get_v_frames"), &Particles2D::get_v_frames);
- ObjectTypeDB::bind_method(_MD("set_color_phases","phases"),&Particles2D::set_color_phases);
- ObjectTypeDB::bind_method(_MD("get_color_phases"),&Particles2D::get_color_phases);
+ ObjectTypeDB::bind_method(_MD("set_emission_half_extents", "extents"), &Particles2D::set_emission_half_extents);
+ ObjectTypeDB::bind_method(_MD("get_emission_half_extents"), &Particles2D::get_emission_half_extents);
- ObjectTypeDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles2D::set_color_phase_color);
- ObjectTypeDB::bind_method(_MD("get_color_phase_color","phase"),&Particles2D::get_color_phase_color);
+ ObjectTypeDB::bind_method(_MD("set_color_phases", "phases"), &Particles2D::set_color_phases);
+ ObjectTypeDB::bind_method(_MD("get_color_phases"), &Particles2D::get_color_phases);
- ObjectTypeDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles2D::set_color_phase_pos);
- ObjectTypeDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles2D::get_color_phase_pos);
+ ObjectTypeDB::bind_method(_MD("set_color_phase_color", "phase", "color"), &Particles2D::set_color_phase_color);
+ ObjectTypeDB::bind_method(_MD("get_color_phase_color", "phase"), &Particles2D::get_color_phase_color);
- ObjectTypeDB::bind_method(_MD("pre_process","time"),&Particles2D::pre_process);
- ObjectTypeDB::bind_method(_MD("reset"),&Particles2D::reset);
+ ObjectTypeDB::bind_method(_MD("set_color_phase_pos", "phase", "pos"), &Particles2D::set_color_phase_pos);
+ ObjectTypeDB::bind_method(_MD("get_color_phase_pos", "phase"), &Particles2D::get_color_phase_pos);
- ObjectTypeDB::bind_method(_MD("set_use_local_space","enable"),&Particles2D::set_use_local_space);
- ObjectTypeDB::bind_method(_MD("is_using_local_space"),&Particles2D::is_using_local_space);
+ ObjectTypeDB::bind_method(_MD("pre_process", "time"), &Particles2D::pre_process);
+ ObjectTypeDB::bind_method(_MD("reset"), &Particles2D::reset);
- ObjectTypeDB::bind_method(_MD("set_initial_velocity","velocity"),&Particles2D::set_initial_velocity);
- ObjectTypeDB::bind_method(_MD("get_initial_velocity"),&Particles2D::get_initial_velocity);
+ ObjectTypeDB::bind_method(_MD("set_use_local_space", "enable"), &Particles2D::set_use_local_space);
+ ObjectTypeDB::bind_method(_MD("is_using_local_space"), &Particles2D::is_using_local_space);
- ObjectTypeDB::bind_method(_MD("set_explosiveness","amount"),&Particles2D::set_explosiveness);
- ObjectTypeDB::bind_method(_MD("get_explosiveness"),&Particles2D::get_explosiveness);
+ ObjectTypeDB::bind_method(_MD("set_initial_velocity", "velocity"), &Particles2D::set_initial_velocity);
+ ObjectTypeDB::bind_method(_MD("get_initial_velocity"), &Particles2D::get_initial_velocity);
- ObjectTypeDB::bind_method(_MD("set_emission_points","points"),&Particles2D::set_emission_points);
- ObjectTypeDB::bind_method(_MD("get_emission_points"),&Particles2D::get_emission_points);
+ ObjectTypeDB::bind_method(_MD("set_explosiveness", "amount"), &Particles2D::set_explosiveness);
+ ObjectTypeDB::bind_method(_MD("get_explosiveness"), &Particles2D::get_explosiveness);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"config/amount",PROPERTY_HINT_EXP_RANGE,"1,1024"),_SCS("set_amount"),_SCS("get_amount") );
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"config/lifetime",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_lifetime"),_SCS("get_lifetime") );
- ADD_PROPERTYNO(PropertyInfo(Variant::REAL,"config/time_scale",PROPERTY_HINT_EXP_RANGE,"0.01,128,0.01"),_SCS("set_time_scale"),_SCS("get_time_scale") );
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"config/preprocess",PROPERTY_HINT_EXP_RANGE,"0.1,3600,0.1"),_SCS("set_pre_process_time"),_SCS("get_pre_process_time") );
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"config/emit_timeout",PROPERTY_HINT_RANGE,"0,3600,0.1"),_SCS("set_emit_timeout"),_SCS("get_emit_timeout") );
- ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"config/emitting"),_SCS("set_emitting"),_SCS("is_emitting") );
- ADD_PROPERTY(PropertyInfo( Variant::INT, "config/process_mode",PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_process_mode"), _SCS("get_process_mode") );
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"config/offset"),_SCS("set_emissor_offset"),_SCS("get_emissor_offset"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"config/half_extents"),_SCS("set_emission_half_extents"),_SCS("get_emission_half_extents"));
- ADD_PROPERTYNO(PropertyInfo(Variant::BOOL,"config/local_space"),_SCS("set_use_local_space"),_SCS("is_using_local_space"));
- ADD_PROPERTYNO(PropertyInfo(Variant::REAL,"config/explosiveness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_explosiveness"),_SCS("get_explosiveness"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"config/flip_h"),_SCS("set_flip_h"),_SCS("is_flipped_h"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL,"config/flip_v"),_SCS("set_flip_v"),_SCS("is_flipped_v"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"config/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTYNO(PropertyInfo(Variant::INT,"config/h_frames",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_h_frames"),_SCS("get_h_frames"));
- ADD_PROPERTYNO(PropertyInfo(Variant::INT,"config/v_frames",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_v_frames"),_SCS("get_v_frames"));
+ ObjectTypeDB::bind_method(_MD("set_emission_points", "points"), &Particles2D::set_emission_points);
+ ObjectTypeDB::bind_method(_MD("get_emission_points"), &Particles2D::get_emission_points);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "config/amount", PROPERTY_HINT_EXP_RANGE, "1,1024"), _SCS("set_amount"), _SCS("get_amount"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "config/lifetime", PROPERTY_HINT_EXP_RANGE, "0.1,3600,0.1"), _SCS("set_lifetime"), _SCS("get_lifetime"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "config/time_scale", PROPERTY_HINT_EXP_RANGE, "0.01,128,0.01"), _SCS("set_time_scale"), _SCS("get_time_scale"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "config/preprocess", PROPERTY_HINT_EXP_RANGE, "0.1,3600,0.1"), _SCS("set_pre_process_time"), _SCS("get_pre_process_time"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "config/emit_timeout", PROPERTY_HINT_RANGE, "0,3600,0.1"), _SCS("set_emit_timeout"), _SCS("get_emit_timeout"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "config/emitting"), _SCS("set_emitting"), _SCS("is_emitting"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "config/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_process_mode"), _SCS("get_process_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "config/offset"), _SCS("set_emissor_offset"), _SCS("get_emissor_offset"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "config/half_extents"), _SCS("set_emission_half_extents"), _SCS("get_emission_half_extents"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "config/local_space"), _SCS("set_use_local_space"), _SCS("is_using_local_space"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "config/explosiveness", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_explosiveness"), _SCS("get_explosiveness"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "config/flip_h"), _SCS("set_flip_h"), _SCS("is_flipped_h"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "config/flip_v"), _SCS("set_flip_v"), _SCS("is_flipped_v"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "config/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "config/h_frames", PROPERTY_HINT_RANGE, "1,512,1"), _SCS("set_h_frames"), _SCS("get_h_frames"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "config/v_frames", PROPERTY_HINT_RANGE, "1,512,1"), _SCS("set_v_frames"), _SCS("get_v_frames"));
- for(int i=0;i<PARAM_MAX;i++) {
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,_particlesframe_property_names[i],PROPERTY_HINT_RANGE,_particlesframe_property_ranges[i]),_SCS("set_param"),_SCS("get_param"),i);
+ for (int i = 0; i < PARAM_MAX; i++) {
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, _particlesframe_property_names[i], PROPERTY_HINT_RANGE, _particlesframe_property_ranges[i]), _SCS("set_param"), _SCS("get_param"), i);
}
- for(int i=0;i<PARAM_MAX;i++) {
- ADD_PROPERTYINZ(PropertyInfo(Variant::REAL,_particlesframe_property_rnames[i],PROPERTY_HINT_RANGE,"-1,1,0.01"),_SCS("set_randomness"),_SCS("get_randomness"),i);
+ for (int i = 0; i < PARAM_MAX; i++) {
+ ADD_PROPERTYINZ(PropertyInfo(Variant::REAL, _particlesframe_property_rnames[i], PROPERTY_HINT_RANGE, "-1,1,0.01"), _SCS("set_randomness"), _SCS("get_randomness"), i);
}
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "color_phases/count",PROPERTY_HINT_RANGE,"0,4,1", 0), _SCS("set_color_phases"), _SCS("get_color_phases"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "color_phases/count", PROPERTY_HINT_RANGE, "0,4,1", 0), _SCS("set_color_phases"), _SCS("get_color_phases"));
//Backward compatibility. They will be converted to color ramp
- for(int i=0;i<MAX_COLOR_PHASES;i++) {
- String phase="phase_"+itos(i)+"/";
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, phase+"pos", PROPERTY_HINT_RANGE,"0,1,0.01", 0),_SCS("set_color_phase_pos"),_SCS("get_color_phase_pos"),i );
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, phase+"color", PROPERTY_HINT_NONE, "", 0),_SCS("set_color_phase_color"),_SCS("get_color_phase_color"),i );
+ for (int i = 0; i < MAX_COLOR_PHASES; i++) {
+ String phase = "phase_" + itos(i) + "/";
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, phase + "pos", PROPERTY_HINT_RANGE, "0,1,0.01", 0), _SCS("set_color_phase_pos"), _SCS("get_color_phase_pos"), i);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, phase + "color", PROPERTY_HINT_NONE, "", 0), _SCS("set_color_phase_color"), _SCS("get_color_phase_color"), i);
}
- ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "color/color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"color/color_ramp",PROPERTY_HINT_RESOURCE_TYPE,"ColorRamp"),_SCS("set_color_ramp"),_SCS("get_color_ramp"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "color/color"), _SCS("set_color"), _SCS("get_color"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "color/color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "ColorRamp"), _SCS("set_color_ramp"), _SCS("get_color_ramp"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2_ARRAY,"emission_points",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_emission_points"),_SCS("get_emission_points"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2_ARRAY, "emission_points", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("set_emission_points"), _SCS("get_emission_points"));
- BIND_CONSTANT( PARAM_DIRECTION );
- BIND_CONSTANT( PARAM_SPREAD );
- BIND_CONSTANT( PARAM_LINEAR_VELOCITY );
- BIND_CONSTANT( PARAM_SPIN_VELOCITY );
- BIND_CONSTANT( PARAM_ORBIT_VELOCITY );
- BIND_CONSTANT( PARAM_GRAVITY_DIRECTION );
- BIND_CONSTANT( PARAM_GRAVITY_STRENGTH );
- BIND_CONSTANT( PARAM_RADIAL_ACCEL );
- BIND_CONSTANT( PARAM_TANGENTIAL_ACCEL );
- BIND_CONSTANT( PARAM_DAMPING );
- BIND_CONSTANT( PARAM_INITIAL_ANGLE );
- BIND_CONSTANT( PARAM_INITIAL_SIZE );
- BIND_CONSTANT( PARAM_FINAL_SIZE );
- BIND_CONSTANT( PARAM_HUE_VARIATION );
- BIND_CONSTANT( PARAM_ANIM_SPEED_SCALE );
- BIND_CONSTANT( PARAM_ANIM_INITIAL_POS );
- BIND_CONSTANT( PARAM_MAX );
-
- BIND_CONSTANT( MAX_COLOR_PHASES );
+ BIND_CONSTANT(PARAM_DIRECTION);
+ BIND_CONSTANT(PARAM_SPREAD);
+ BIND_CONSTANT(PARAM_LINEAR_VELOCITY);
+ BIND_CONSTANT(PARAM_SPIN_VELOCITY);
+ BIND_CONSTANT(PARAM_ORBIT_VELOCITY);
+ BIND_CONSTANT(PARAM_GRAVITY_DIRECTION);
+ BIND_CONSTANT(PARAM_GRAVITY_STRENGTH);
+ BIND_CONSTANT(PARAM_RADIAL_ACCEL);
+ BIND_CONSTANT(PARAM_TANGENTIAL_ACCEL);
+ BIND_CONSTANT(PARAM_DAMPING);
+ BIND_CONSTANT(PARAM_INITIAL_ANGLE);
+ BIND_CONSTANT(PARAM_INITIAL_SIZE);
+ BIND_CONSTANT(PARAM_FINAL_SIZE);
+ BIND_CONSTANT(PARAM_HUE_VARIATION);
+ BIND_CONSTANT(PARAM_ANIM_SPEED_SCALE);
+ BIND_CONSTANT(PARAM_ANIM_INITIAL_POS);
+ BIND_CONSTANT(PARAM_MAX);
+ BIND_CONSTANT(MAX_COLOR_PHASES);
}
Particles2D::Particles2D() {
- for(int i=0;i<PARAM_MAX;i++) {
+ for (int i = 0; i < PARAM_MAX; i++) {
- param[i]=0;
- randomness[i]=0;
+ param[i] = 0;
+ randomness[i] = 0;
}
+ set_param(PARAM_SPREAD, 10);
+ set_param(PARAM_LINEAR_VELOCITY, 20);
+ set_param(PARAM_GRAVITY_STRENGTH, 9.8);
+ set_param(PARAM_RADIAL_ACCEL, 0);
+ set_param(PARAM_TANGENTIAL_ACCEL, 0);
+ set_param(PARAM_INITIAL_ANGLE, 0.0);
+ set_param(PARAM_INITIAL_SIZE, 1.0);
+ set_param(PARAM_FINAL_SIZE, 1.0);
+ set_param(PARAM_ANIM_SPEED_SCALE, 1.0);
- set_param(PARAM_SPREAD,10);
- set_param(PARAM_LINEAR_VELOCITY,20);
- set_param(PARAM_GRAVITY_STRENGTH,9.8);
- set_param(PARAM_RADIAL_ACCEL,0);
- set_param(PARAM_TANGENTIAL_ACCEL,0);
- set_param(PARAM_INITIAL_ANGLE,0.0);
- set_param(PARAM_INITIAL_SIZE,1.0);
- set_param(PARAM_FINAL_SIZE,1.0);
- set_param(PARAM_ANIM_SPEED_SCALE,1.0);
-
- set_color(Color(1,1,1,1));
+ set_color(Color(1, 1, 1, 1));
- time=0;
- lifetime=2;
- emitting=false;
+ time = 0;
+ lifetime = 2;
+ emitting = false;
particles.resize(32);
- active_count=-1;
+ active_count = -1;
set_emitting(true);
- process_mode=PROCESS_IDLE;
- local_space=true;
- preprocess=0;
- time_scale=1.0;
-
+ process_mode = PROCESS_IDLE;
+ local_space = true;
+ preprocess = 0;
+ time_scale = 1.0;
- flip_h=false;
- flip_v=false;
+ flip_h = false;
+ flip_v = false;
- v_frames=1;
- h_frames=1;
+ v_frames = 1;
+ h_frames = 1;
emit_timeout = 0;
time_to_live = 0;
- explosiveness=1.0;
+ explosiveness = 1.0;
}
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index c75a810a5..554066630 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -30,16 +30,15 @@
#define PARTICLES_FRAME_H
#include "scene/2d/node_2d.h"
-#include "scene/resources/texture.h"
#include "scene/resources/color_ramp.h"
+#include "scene/resources/texture.h"
class Particles2D;
class ParticleAttractor2D : public Node2D {
- OBJ_TYPE(ParticleAttractor2D,Node2D);
+ OBJ_TYPE(ParticleAttractor2D, Node2D);
-
-friend class Particles2D;
+ friend class Particles2D;
bool enabled;
float radius;
float disable_radius;
@@ -51,12 +50,12 @@ friend class Particles2D;
void _update_owner();
void _owner_exited();
- void _set_owner(Particles2D* p_owner);
+ void _set_owner(Particles2D *p_owner);
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_enabled(bool p_enabled);
bool is_enabled() const;
@@ -80,13 +79,11 @@ public:
ParticleAttractor2D();
};
-
-
class Particles2D : public Node2D {
OBJ_TYPE(Particles2D, Node2D);
-public:
+public:
enum Parameter {
PARAM_DIRECTION,
PARAM_SPREAD,
@@ -108,7 +105,7 @@ public:
};
enum {
- MAX_COLOR_PHASES=4
+ MAX_COLOR_PHASES = 4
};
enum ProcessMode {
@@ -117,7 +114,6 @@ public:
};
private:
-
float param[PARAM_MAX];
float randomness[PARAM_MAX];
@@ -129,7 +125,12 @@ private:
float rot;
float frame;
uint32_t seed;
- Particle() { active=false; seed=123465789; rot=0; frame=0;}
+ Particle() {
+ active = false;
+ seed = 123465789;
+ rot = 0;
+ frame = 0;
+ }
};
Vector<Particle> particles;
@@ -172,17 +173,15 @@ private:
void testee(int a, int b, int c, int d, int e);
void _process_particles(float p_delta);
-friend class ParticleAttractor2D;
+ friend class ParticleAttractor2D;
- Set<ParticleAttractor2D*> attractors;
+ Set<ParticleAttractor2D *> attractors;
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
void set_emitting(bool p_emitting);
bool is_emitting() const;
@@ -204,7 +203,7 @@ public:
void set_emit_timeout(float p_timeout);
float get_emit_timeout() const;
- void set_emission_half_extents(const Vector2& p_extents);
+ void set_emission_half_extents(const Vector2 &p_extents);
Vector2 get_emission_half_extents() const;
void set_param(Parameter p_param, float p_value);
@@ -222,7 +221,6 @@ public:
void set_flip_v(bool p_flip);
bool is_flipped_v() const;
-
void set_h_frames(int p_frames);
int get_h_frames() const;
@@ -232,31 +230,31 @@ public:
void set_color_phases(int p_phases);
int get_color_phases() const;
- void set_color_phase_color(int p_phase,const Color& p_color);
+ void set_color_phase_color(int p_phase, const Color &p_color);
Color get_color_phase_color(int p_phase) const;
- void set_color_phase_pos(int p_phase,float p_pos);
+ void set_color_phase_pos(int p_phase, float p_pos);
float get_color_phase_pos(int p_phase) const;
- void set_texture(const Ref<Texture>& p_texture);
+ void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
- void set_color(const Color& p_color);
+ void set_color(const Color &p_color);
Color get_color() const;
- void set_color_ramp(const Ref<ColorRamp>& p_texture);
+ void set_color_ramp(const Ref<ColorRamp> &p_texture);
Ref<ColorRamp> get_color_ramp() const;
- void set_emissor_offset(const Point2& p_offset);
+ void set_emissor_offset(const Point2 &p_offset);
Point2 get_emissor_offset() const;
void set_use_local_space(bool p_use);
bool is_using_local_space() const;
- void set_initial_velocity(const Vector2& p_velocity);
+ void set_initial_velocity(const Vector2 &p_velocity);
Vector2 get_initial_velocity() const;
- void set_emission_points(const DVector<Vector2>& p_points);
+ void set_emission_points(const DVector<Vector2> &p_points);
DVector<Vector2> get_emission_points() const;
void pre_process(float p_delta);
@@ -265,7 +263,7 @@ public:
Particles2D();
};
-VARIANT_ENUM_CAST( Particles2D::ProcessMode );
-VARIANT_ENUM_CAST( Particles2D::Parameter );
+VARIANT_ENUM_CAST(Particles2D::ProcessMode);
+VARIANT_ENUM_CAST(Particles2D::Parameter);
#endif // PARTICLES_FRAME_H
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index f426b7fd0..191212cee 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -31,23 +31,23 @@
void Path2D::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW && curve.is_valid()) {
+ if (p_what == NOTIFICATION_DRAW && curve.is_valid()) {
//draw the curve!!
if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_navigation_hint()) {
return;
}
- for(int i=0;i<curve->get_point_count();i++) {
+ for (int i = 0; i < curve->get_point_count(); i++) {
- Vector2 prev_p=curve->get_point_pos(i);
+ Vector2 prev_p = curve->get_point_pos(i);
- for(int j=1;j<=8;j++) {
+ for (int j = 1; j <= 8; j++) {
- real_t frac = j/8.0;
- Vector2 p = curve->interpolate(i,frac);
- draw_line(prev_p,p,Color(0.5,0.6,1.0,0.7),2);
- prev_p=p;
+ real_t frac = j / 8.0;
+ Vector2 p = curve->interpolate(i, frac);
+ draw_line(prev_p, p, Color(0.5, 0.6, 1.0, 0.7), 2);
+ prev_p = p;
}
}
}
@@ -55,98 +55,89 @@ void Path2D::_notification(int p_what) {
void Path2D::_curve_changed() {
-
if (is_inside_tree() && get_tree()->is_editor_hint())
update();
-
}
-
-void Path2D::set_curve(const Ref<Curve2D>& p_curve) {
+void Path2D::set_curve(const Ref<Curve2D> &p_curve) {
if (curve.is_valid()) {
- curve->disconnect("changed",this,"_curve_changed");
+ curve->disconnect("changed", this, "_curve_changed");
}
- curve=p_curve;
+ curve = p_curve;
if (curve.is_valid()) {
- curve->connect("changed",this,"_curve_changed");
+ curve->connect("changed", this, "_curve_changed");
}
_curve_changed();
-
}
-Ref<Curve2D> Path2D::get_curve() const{
+Ref<Curve2D> Path2D::get_curve() const {
return curve;
}
void Path2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_curve","curve:Curve2D"),&Path2D::set_curve);
- ObjectTypeDB::bind_method(_MD("get_curve:Curve2D","curve"),&Path2D::get_curve);
- ObjectTypeDB::bind_method(_MD("_curve_changed"),&Path2D::_curve_changed);
+ ObjectTypeDB::bind_method(_MD("set_curve", "curve:Curve2D"), &Path2D::set_curve);
+ ObjectTypeDB::bind_method(_MD("get_curve:Curve2D", "curve"), &Path2D::get_curve);
+ ObjectTypeDB::bind_method(_MD("_curve_changed"), &Path2D::_curve_changed);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), _SCS("set_curve"),_SCS("get_curve"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve2D"), _SCS("set_curve"), _SCS("get_curve"));
}
Path2D::Path2D() {
- set_curve(Ref<Curve2D>( memnew( Curve2D ))); //create one by default
+ set_curve(Ref<Curve2D>(memnew(Curve2D))); //create one by default
}
/////////////////////////////////////////////////////////////////////////////////
-
void PathFollow2D::_update_transform() {
-
if (!path)
return;
- Ref<Curve2D> c =path->get_curve();
+ Ref<Curve2D> c = path->get_curve();
if (!c.is_valid())
return;
-
float o = offset;
if (loop)
- o=Math::fposmod(o,c->get_baked_length());
+ o = Math::fposmod(o, c->get_baked_length());
- Vector2 pos = c->interpolate_baked(o,cubic);
+ Vector2 pos = c->interpolate_baked(o, cubic);
if (rotate) {
- Vector2 n = (c->interpolate_baked(o+lookahead,cubic)-pos).normalized();
+ Vector2 n = (c->interpolate_baked(o + lookahead, cubic) - pos).normalized();
Vector2 t = -n.tangent();
- pos+=n*h_offset;
- pos+=t*v_offset;
+ pos += n * h_offset;
+ pos += t * v_offset;
set_rot(t.angle());
} else {
- pos.x+=h_offset;
- pos.y+=v_offset;
+ pos.x += h_offset;
+ pos.y += v_offset;
}
set_pos(pos);
-
}
void PathFollow2D::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- Node *parent=get_parent();
+ Node *parent = get_parent();
if (parent) {
- path=parent->cast_to<Path2D>();
+ path = parent->cast_to<Path2D>();
if (path) {
_update_transform();
}
@@ -155,16 +146,14 @@ void PathFollow2D::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
- path=NULL;
+ path = NULL;
} break;
}
-
}
void PathFollow2D::set_cubic_interpolation(bool p_enable) {
- cubic=p_enable;
+ cubic = p_enable;
}
bool PathFollow2D::get_cubic_interpolation() const {
@@ -172,24 +161,23 @@ bool PathFollow2D::get_cubic_interpolation() const {
return cubic;
}
+bool PathFollow2D::_set(const StringName &p_name, const Variant &p_value) {
-bool PathFollow2D::_set(const StringName& p_name, const Variant& p_value) {
-
- if (p_name==SceneStringNames::get_singleton()->offset) {
+ if (p_name == SceneStringNames::get_singleton()->offset) {
set_offset(p_value);
- } else if (p_name==SceneStringNames::get_singleton()->unit_offset) {
+ } else if (p_name == SceneStringNames::get_singleton()->unit_offset) {
set_unit_offset(p_value);
- } else if (p_name==SceneStringNames::get_singleton()->rotate) {
+ } else if (p_name == SceneStringNames::get_singleton()->rotate) {
set_rotate(p_value);
- } else if (p_name==SceneStringNames::get_singleton()->v_offset) {
+ } else if (p_name == SceneStringNames::get_singleton()->v_offset) {
set_v_offset(p_value);
- } else if (p_name==SceneStringNames::get_singleton()->h_offset) {
+ } else if (p_name == SceneStringNames::get_singleton()->h_offset) {
set_h_offset(p_value);
- } else if (String(p_name)=="cubic_interp") {
+ } else if (String(p_name) == "cubic_interp") {
set_cubic_interpolation(p_value);
- } else if (String(p_name)=="loop") {
+ } else if (String(p_name) == "loop") {
set_loop(p_value);
- } else if (String(p_name)=="lookahead") {
+ } else if (String(p_name) == "lookahead") {
set_lookahead(p_value);
} else
return false;
@@ -197,46 +185,44 @@ bool PathFollow2D::_set(const StringName& p_name, const Variant& p_value) {
return true;
}
-bool PathFollow2D::_get(const StringName& p_name,Variant &r_ret) const{
+bool PathFollow2D::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name==SceneStringNames::get_singleton()->offset) {
- r_ret=get_offset();
- } else if (p_name==SceneStringNames::get_singleton()->unit_offset) {
- r_ret=get_unit_offset();
- } else if (p_name==SceneStringNames::get_singleton()->rotate) {
- r_ret=is_rotating();
- } else if (p_name==SceneStringNames::get_singleton()->v_offset) {
- r_ret=get_v_offset();
- } else if (p_name==SceneStringNames::get_singleton()->h_offset) {
- r_ret=get_h_offset();
- } else if (String(p_name)=="cubic_interp") {
- r_ret=cubic;
- } else if (String(p_name)=="loop") {
- r_ret=loop;
- } else if (String(p_name)=="lookahead") {
- r_ret=lookahead;
+ if (p_name == SceneStringNames::get_singleton()->offset) {
+ r_ret = get_offset();
+ } else if (p_name == SceneStringNames::get_singleton()->unit_offset) {
+ r_ret = get_unit_offset();
+ } else if (p_name == SceneStringNames::get_singleton()->rotate) {
+ r_ret = is_rotating();
+ } else if (p_name == SceneStringNames::get_singleton()->v_offset) {
+ r_ret = get_v_offset();
+ } else if (p_name == SceneStringNames::get_singleton()->h_offset) {
+ r_ret = get_h_offset();
+ } else if (String(p_name) == "cubic_interp") {
+ r_ret = cubic;
+ } else if (String(p_name) == "loop") {
+ r_ret = loop;
+ } else if (String(p_name) == "lookahead") {
+ r_ret = lookahead;
} else
return false;
return true;
-
}
-void PathFollow2D::_get_property_list( List<PropertyInfo> *p_list) const{
+void PathFollow2D::_get_property_list(List<PropertyInfo> *p_list) const {
- float max=10000;
+ float max = 10000;
if (path && path->get_curve().is_valid())
- max=path->get_curve()->get_baked_length();
- p_list->push_back( PropertyInfo( Variant::REAL, "offset", PROPERTY_HINT_RANGE,"0,"+rtos(max)+",0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE,"0,1,0.0001",PROPERTY_USAGE_EDITOR));
- p_list->push_back( PropertyInfo( Variant::REAL, "h_offset") );
- p_list->push_back( PropertyInfo( Variant::REAL, "v_offset") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "rotate") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "cubic_interp"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "loop"));
- p_list->push_back( PropertyInfo( Variant::REAL, "lookahead",PROPERTY_HINT_RANGE,"0.001,1024.0,0.001"));
+ max = path->get_curve()->get_baked_length();
+ p_list->push_back(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0," + rtos(max) + ",0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::REAL, "h_offset"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "v_offset"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "rotate"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "cubic_interp"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "loop"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "lookahead", PROPERTY_HINT_RANGE, "0.001,1024.0,0.001"));
}
-
String PathFollow2D::get_configuration_warning() const {
if (!is_visible() || !is_inside_tree())
@@ -247,51 +233,46 @@ String PathFollow2D::get_configuration_warning() const {
}
return String();
-
}
void PathFollow2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&PathFollow2D::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&PathFollow2D::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &PathFollow2D::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &PathFollow2D::get_offset);
- ObjectTypeDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow2D::set_h_offset);
- ObjectTypeDB::bind_method(_MD("get_h_offset"),&PathFollow2D::get_h_offset);
+ ObjectTypeDB::bind_method(_MD("set_h_offset", "h_offset"), &PathFollow2D::set_h_offset);
+ ObjectTypeDB::bind_method(_MD("get_h_offset"), &PathFollow2D::get_h_offset);
- ObjectTypeDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow2D::set_v_offset);
- ObjectTypeDB::bind_method(_MD("get_v_offset"),&PathFollow2D::get_v_offset);
+ ObjectTypeDB::bind_method(_MD("set_v_offset", "v_offset"), &PathFollow2D::set_v_offset);
+ ObjectTypeDB::bind_method(_MD("get_v_offset"), &PathFollow2D::get_v_offset);
- ObjectTypeDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow2D::set_unit_offset);
- ObjectTypeDB::bind_method(_MD("get_unit_offset"),&PathFollow2D::get_unit_offset);
+ ObjectTypeDB::bind_method(_MD("set_unit_offset", "unit_offset"), &PathFollow2D::set_unit_offset);
+ ObjectTypeDB::bind_method(_MD("get_unit_offset"), &PathFollow2D::get_unit_offset);
- ObjectTypeDB::bind_method(_MD("set_rotate","enable"),&PathFollow2D::set_rotate);
- ObjectTypeDB::bind_method(_MD("is_rotating"),&PathFollow2D::is_rotating);
-
- ObjectTypeDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow2D::set_cubic_interpolation);
- ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow2D::get_cubic_interpolation);
-
- ObjectTypeDB::bind_method(_MD("set_loop","loop"),&PathFollow2D::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&PathFollow2D::has_loop);
+ ObjectTypeDB::bind_method(_MD("set_rotate", "enable"), &PathFollow2D::set_rotate);
+ ObjectTypeDB::bind_method(_MD("is_rotating"), &PathFollow2D::is_rotating);
+ ObjectTypeDB::bind_method(_MD("set_cubic_interpolation", "enable"), &PathFollow2D::set_cubic_interpolation);
+ ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"), &PathFollow2D::get_cubic_interpolation);
+ ObjectTypeDB::bind_method(_MD("set_loop", "loop"), &PathFollow2D::set_loop);
+ ObjectTypeDB::bind_method(_MD("has_loop"), &PathFollow2D::has_loop);
}
void PathFollow2D::set_offset(float p_offset) {
- offset=p_offset;
+ offset = p_offset;
if (path)
_update_transform();
_change_notify("offset");
_change_notify("unit_offset");
-
}
void PathFollow2D::set_h_offset(float p_h_offset) {
- h_offset=p_h_offset;
+ h_offset = p_h_offset;
if (path)
_update_transform();
-
}
float PathFollow2D::get_h_offset() const {
@@ -301,10 +282,9 @@ float PathFollow2D::get_h_offset() const {
void PathFollow2D::set_v_offset(float p_v_offset) {
- v_offset=p_v_offset;
+ v_offset = p_v_offset;
if (path)
_update_transform();
-
}
float PathFollow2D::get_v_offset() const {
@@ -312,8 +292,7 @@ float PathFollow2D::get_v_offset() const {
return v_offset;
}
-
-float PathFollow2D::get_offset() const{
+float PathFollow2D::get_offset() const {
return offset;
}
@@ -321,32 +300,30 @@ float PathFollow2D::get_offset() const{
void PathFollow2D::set_unit_offset(float p_unit_offset) {
if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
- set_offset(p_unit_offset*path->get_curve()->get_baked_length());
-
+ set_offset(p_unit_offset * path->get_curve()->get_baked_length());
}
-float PathFollow2D::get_unit_offset() const{
+float PathFollow2D::get_unit_offset() const {
if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
- return get_offset()/path->get_curve()->get_baked_length();
+ return get_offset() / path->get_curve()->get_baked_length();
else
return 0;
}
void PathFollow2D::set_lookahead(float p_lookahead) {
- lookahead=p_lookahead;
-
+ lookahead = p_lookahead;
}
-float PathFollow2D::get_lookahead() const{
+float PathFollow2D::get_lookahead() const {
return lookahead;
}
void PathFollow2D::set_rotate(bool p_rotate) {
- rotate=p_rotate;
+ rotate = p_rotate;
_update_transform();
}
@@ -357,23 +334,22 @@ bool PathFollow2D::is_rotating() const {
void PathFollow2D::set_loop(bool p_loop) {
- loop=p_loop;
+ loop = p_loop;
}
-bool PathFollow2D::has_loop() const{
+bool PathFollow2D::has_loop() const {
return loop;
}
-
PathFollow2D::PathFollow2D() {
- offset=0;
- h_offset=0;
- v_offset=0;
- path=NULL;
- rotate=true;
- cubic=true;
- loop=true;
- lookahead=4;
+ offset = 0;
+ h_offset = 0;
+ v_offset = 0;
+ path = NULL;
+ rotate = true;
+ cubic = true;
+ loop = true;
+ lookahead = 4;
}
diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h
index 875a7be0d..e4a388bf7 100644
--- a/scene/2d/path_2d.h
+++ b/scene/2d/path_2d.h
@@ -29,39 +29,33 @@
#ifndef PATH_2D_H
#define PATH_2D_H
-#include "scene/resources/curve.h"
#include "scene/2d/node_2d.h"
+#include "scene/resources/curve.h"
class Path2D : public Node2D {
- OBJ_TYPE( Path2D, Node2D );
+ OBJ_TYPE(Path2D, Node2D);
Ref<Curve2D> curve;
void _curve_changed();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_curve(const Ref<Curve2D>& p_curve);
+public:
+ void set_curve(const Ref<Curve2D> &p_curve);
Ref<Curve2D> get_curve() const;
-
Path2D();
};
-
-
class PathFollow2D : public Node2D {
- OBJ_TYPE(PathFollow2D,Node2D);
-public:
-
+ OBJ_TYPE(PathFollow2D, Node2D);
+public:
private:
Path2D *path;
real_t offset;
@@ -74,17 +68,15 @@ private:
void _update_transform();
-
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_offset(float p_offset);
float get_offset() const;
@@ -114,5 +106,4 @@ public:
PathFollow2D();
};
-
#endif // PATH_2D_H
diff --git a/scene/2d/path_texture.cpp b/scene/2d/path_texture.cpp
index 626928a24..60efccec3 100644
--- a/scene/2d/path_texture.cpp
+++ b/scene/2d/path_texture.cpp
@@ -28,65 +28,61 @@
/*************************************************************************/
#include "path_texture.h"
+void PathTexture::set_begin_texture(const Ref<Texture> &p_texture) {
-void PathTexture::set_begin_texture(const Ref<Texture>& p_texture) {
-
- begin=p_texture;
+ begin = p_texture;
update();
}
-Ref<Texture> PathTexture::get_begin_texture() const{
+Ref<Texture> PathTexture::get_begin_texture() const {
return begin;
}
-void PathTexture::set_repeat_texture(const Ref<Texture>& p_texture){
+void PathTexture::set_repeat_texture(const Ref<Texture> &p_texture) {
- repeat=p_texture;
+ repeat = p_texture;
update();
-
}
-Ref<Texture> PathTexture::get_repeat_texture() const{
+Ref<Texture> PathTexture::get_repeat_texture() const {
return repeat;
}
-void PathTexture::set_end_texture(const Ref<Texture>& p_texture){
+void PathTexture::set_end_texture(const Ref<Texture> &p_texture) {
- end=p_texture;
+ end = p_texture;
update();
}
-Ref<Texture> PathTexture::get_end_texture() const{
+Ref<Texture> PathTexture::get_end_texture() const {
return end;
}
-void PathTexture::set_subdivisions(int p_amount){
+void PathTexture::set_subdivisions(int p_amount) {
- ERR_FAIL_INDEX(p_amount,32);
- subdivs=p_amount;
+ ERR_FAIL_INDEX(p_amount, 32);
+ subdivs = p_amount;
update();
-
}
-int PathTexture::get_subdivisions() const{
+int PathTexture::get_subdivisions() const {
return subdivs;
}
-void PathTexture::set_overlap(int p_amount){
+void PathTexture::set_overlap(int p_amount) {
- overlap=p_amount;
+ overlap = p_amount;
update();
}
-int PathTexture::get_overlap() const{
+int PathTexture::get_overlap() const {
return overlap;
}
-
PathTexture::PathTexture() {
- overlap=0;
- subdivs=1;
+ overlap = 0;
+ subdivs = 1;
}
diff --git a/scene/2d/path_texture.h b/scene/2d/path_texture.h
index 2f2e40409..4e1126f89 100644
--- a/scene/2d/path_texture.h
+++ b/scene/2d/path_texture.h
@@ -32,22 +32,22 @@
#include "scene/2d/node_2d.h"
class PathTexture : public Node2D {
- OBJ_TYPE( PathTexture, Node2D );
+ OBJ_TYPE(PathTexture, Node2D);
Ref<Texture> begin;
Ref<Texture> repeat;
Ref<Texture> end;
int subdivs;
bool overlap;
-public:
- void set_begin_texture(const Ref<Texture>& p_texture);
+public:
+ void set_begin_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_begin_texture() const;
- void set_repeat_texture(const Ref<Texture>& p_texture);
+ void set_repeat_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_repeat_texture() const;
- void set_end_texture(const Ref<Texture>& p_texture);
+ void set_end_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_end_texture() const;
void set_subdivisions(int p_amount);
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 6c1ff6477..65a921caa 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -29,11 +29,11 @@
#include "physics_body_2d.h"
#include "scene/scene_string_names.h"
-bool PhysicsBody2D::motion_fix_enabled=false;
+bool PhysicsBody2D::motion_fix_enabled = false;
void PhysicsBody2D::_notification(int p_what) {
-/*
+ /*
switch(p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -45,75 +45,71 @@ void PhysicsBody2D::_notification(int p_what) {
*/
}
-void PhysicsBody2D::set_one_way_collision_direction(const Vector2& p_dir) {
+void PhysicsBody2D::set_one_way_collision_direction(const Vector2 &p_dir) {
- one_way_collision_direction=p_dir;
- Physics2DServer::get_singleton()->body_set_one_way_collision_direction(get_rid(),p_dir);
+ one_way_collision_direction = p_dir;
+ Physics2DServer::get_singleton()->body_set_one_way_collision_direction(get_rid(), p_dir);
}
-Vector2 PhysicsBody2D::get_one_way_collision_direction() const{
+Vector2 PhysicsBody2D::get_one_way_collision_direction() const {
return one_way_collision_direction;
}
-
void PhysicsBody2D::set_one_way_collision_max_depth(float p_depth) {
- one_way_collision_max_depth=p_depth;
- Physics2DServer::get_singleton()->body_set_one_way_collision_max_depth(get_rid(),p_depth);
-
+ one_way_collision_max_depth = p_depth;
+ Physics2DServer::get_singleton()->body_set_one_way_collision_max_depth(get_rid(), p_depth);
}
-float PhysicsBody2D::get_one_way_collision_max_depth() const{
+float PhysicsBody2D::get_one_way_collision_max_depth() const {
return one_way_collision_max_depth;
}
-
void PhysicsBody2D::_set_layers(uint32_t p_mask) {
set_layer_mask(p_mask);
set_collision_mask(p_mask);
}
-uint32_t PhysicsBody2D::_get_layers() const{
+uint32_t PhysicsBody2D::_get_layers() const {
return get_layer_mask();
}
void PhysicsBody2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask", "mask"), &PhysicsBody2D::set_layer_mask);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask"), &PhysicsBody2D::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask", "mask"), &PhysicsBody2D::set_collision_mask);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask"), &PhysicsBody2D::get_collision_mask);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask_bit", "bit", "value"), &PhysicsBody2D::set_collision_mask_bit);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask_bit", "bit"), &PhysicsBody2D::get_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask_bit", "bit", "value"), &PhysicsBody2D::set_layer_mask_bit);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask_bit", "bit"), &PhysicsBody2D::get_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody2D::set_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody2D::get_layer_mask_bit);
-
- ObjectTypeDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers);
- ObjectTypeDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers);
- ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction);
- ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction);
- ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth);
- ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth);
- ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with);
- ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),_SCS("set_one_way_collision_max_depth"),_SCS("get_one_way_collision_max_depth"));
+ ObjectTypeDB::bind_method(_MD("_set_layers", "mask"), &PhysicsBody2D::_set_layers);
+ ObjectTypeDB::bind_method(_MD("_get_layers"), &PhysicsBody2D::_get_layers);
+ ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction", "dir"), &PhysicsBody2D::set_one_way_collision_direction);
+ ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"), &PhysicsBody2D::get_one_way_collision_direction);
+ ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth", "depth"), &PhysicsBody2D::set_one_way_collision_max_depth);
+ ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"), &PhysicsBody2D::get_one_way_collision_max_depth);
+ ObjectTypeDB::bind_method(_MD("add_collision_exception_with", "body:PhysicsBody2D"), &PhysicsBody2D::add_collision_exception_with);
+ ObjectTypeDB::bind_method(_MD("remove_collision_exception_with", "body:PhysicsBody2D"), &PhysicsBody2D::remove_collision_exception_with);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_ALL_FLAGS, "", 0), _SCS("_set_layers"), _SCS("_get_layers")); //for backwards compat
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision/layers", PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision/mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_collision_mask"), _SCS("get_collision_mask"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "one_way_collision/direction"), _SCS("set_one_way_collision_direction"), _SCS("get_one_way_collision_direction"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "one_way_collision/max_depth"), _SCS("set_one_way_collision_max_depth"), _SCS("get_one_way_collision_max_depth"));
}
void PhysicsBody2D::set_layer_mask(uint32_t p_mask) {
- mask=p_mask;
- Physics2DServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask);
+ mask = p_mask;
+ Physics2DServer::get_singleton()->body_set_layer_mask(get_rid(), p_mask);
}
uint32_t PhysicsBody2D::get_layer_mask() const {
@@ -123,8 +119,8 @@ uint32_t PhysicsBody2D::get_layer_mask() const {
void PhysicsBody2D::set_collision_mask(uint32_t p_mask) {
- collision_mask=p_mask;
- Physics2DServer::get_singleton()->body_set_collision_mask(get_rid(),p_mask);
+ collision_mask = p_mask;
+ Physics2DServer::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
}
uint32_t PhysicsBody2D::get_collision_mask() const {
@@ -136,44 +132,41 @@ void PhysicsBody2D::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
- mask|=1<<p_bit;
+ mask |= 1 << p_bit;
else
- mask&=~(1<<p_bit);
+ mask &= ~(1 << p_bit);
set_collision_mask(mask);
-
}
-bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const{
+bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const {
- return get_collision_mask()&(1<<p_bit);
+ return get_collision_mask() & (1 << p_bit);
}
-
void PhysicsBody2D::set_layer_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_layer_mask();
if (p_value)
- mask|=1<<p_bit;
+ mask |= 1 << p_bit;
else
- mask&=~(1<<p_bit);
+ mask &= ~(1 << p_bit);
set_layer_mask(mask);
-
}
-bool PhysicsBody2D::get_layer_mask_bit(int p_bit) const{
+bool PhysicsBody2D::get_layer_mask_bit(int p_bit) const {
- return get_layer_mask()&(1<<p_bit);
+ return get_layer_mask() & (1 << p_bit);
}
-PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) {
+PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode)
+ : CollisionObject2D(Physics2DServer::get_singleton()->body_create(p_mode), false) {
- mask=1;
- collision_mask=1;
+ mask = 1;
+ collision_mask = 1;
set_one_way_collision_max_depth(0);
set_pickable(false);
-
}
-void PhysicsBody2D::add_collision_exception_with(Node* p_node) {
+void PhysicsBody2D::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
PhysicsBody2D *physics_body = p_node->cast_to<PhysicsBody2D>();
@@ -181,11 +174,10 @@ void PhysicsBody2D::add_collision_exception_with(Node* p_node) {
ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
}
ERR_FAIL_COND(!physics_body);
- Physics2DServer::get_singleton()->body_add_collision_exception(get_rid(),physics_body->get_rid());
-
+ Physics2DServer::get_singleton()->body_add_collision_exception(get_rid(), physics_body->get_rid());
}
-void PhysicsBody2D::remove_collision_exception_with(Node* p_node) {
+void PhysicsBody2D::remove_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
PhysicsBody2D *physics_body = p_node->cast_to<PhysicsBody2D>();
@@ -193,20 +185,19 @@ void PhysicsBody2D::remove_collision_exception_with(Node* p_node) {
ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
}
ERR_FAIL_COND(!physics_body);
- Physics2DServer::get_singleton()->body_remove_collision_exception(get_rid(),physics_body->get_rid());
+ Physics2DServer::get_singleton()->body_remove_collision_exception(get_rid(), physics_body->get_rid());
}
-void StaticBody2D::set_constant_linear_velocity(const Vector2& p_vel) {
-
- constant_linear_velocity=p_vel;
- Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_LINEAR_VELOCITY,constant_linear_velocity);
+void StaticBody2D::set_constant_linear_velocity(const Vector2 &p_vel) {
+ constant_linear_velocity = p_vel;
+ Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
}
void StaticBody2D::set_constant_angular_velocity(real_t p_vel) {
- constant_angular_velocity=p_vel;
- Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_ANGULAR_VELOCITY,constant_angular_velocity);
+ constant_angular_velocity = p_vel;
+ Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
}
Vector2 StaticBody2D::get_constant_linear_velocity() const {
@@ -241,91 +232,80 @@ void StaticBody2D::_update_xform() {
}
#endif
+void StaticBody2D::set_friction(real_t p_friction) {
-void StaticBody2D::set_friction(real_t p_friction){
-
- ERR_FAIL_COND(p_friction<0 || p_friction>1);
-
- friction=p_friction;
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_FRICTION,friction);
+ ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
+ friction = p_friction;
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, friction);
}
-real_t StaticBody2D::get_friction() const{
+real_t StaticBody2D::get_friction() const {
return friction;
}
-void StaticBody2D::set_bounce(real_t p_bounce){
-
- ERR_FAIL_COND(p_bounce<0 || p_bounce>1);
+void StaticBody2D::set_bounce(real_t p_bounce) {
- bounce=p_bounce;
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_BOUNCE,bounce);
+ ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
+ bounce = p_bounce;
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, bounce);
}
-real_t StaticBody2D::get_bounce() const{
+real_t StaticBody2D::get_bounce() const {
return bounce;
}
void StaticBody2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody2D::set_constant_linear_velocity);
- ObjectTypeDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody2D::set_constant_angular_velocity);
- ObjectTypeDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody2D::get_constant_linear_velocity);
- ObjectTypeDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody2D::get_constant_angular_velocity);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&StaticBody2D::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&StaticBody2D::get_friction);
+ ObjectTypeDB::bind_method(_MD("set_constant_linear_velocity", "vel"), &StaticBody2D::set_constant_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("set_constant_angular_velocity", "vel"), &StaticBody2D::set_constant_angular_velocity);
+ ObjectTypeDB::bind_method(_MD("get_constant_linear_velocity"), &StaticBody2D::get_constant_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("get_constant_angular_velocity"), &StaticBody2D::get_constant_angular_velocity);
+ ObjectTypeDB::bind_method(_MD("set_friction", "friction"), &StaticBody2D::set_friction);
+ ObjectTypeDB::bind_method(_MD("get_friction"), &StaticBody2D::get_friction);
- ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&StaticBody2D::set_bounce);
- ObjectTypeDB::bind_method(_MD("get_bounce"),&StaticBody2D::get_bounce);
+ ObjectTypeDB::bind_method(_MD("set_bounce", "bounce"), &StaticBody2D::set_bounce);
+ ObjectTypeDB::bind_method(_MD("get_bounce"), &StaticBody2D::get_bounce);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"constant_linear_velocity"),_SCS("set_constant_linear_velocity"),_SCS("get_constant_linear_velocity"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"constant_angular_velocity"),_SCS("set_constant_angular_velocity"),_SCS("get_constant_angular_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "constant_linear_velocity"), _SCS("set_constant_linear_velocity"), _SCS("get_constant_linear_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "constant_angular_velocity"), _SCS("set_constant_angular_velocity"), _SCS("get_constant_angular_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_friction"), _SCS("get_friction"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_bounce"), _SCS("get_bounce"));
}
-StaticBody2D::StaticBody2D() : PhysicsBody2D(Physics2DServer::BODY_MODE_STATIC) {
-
- constant_angular_velocity=0;
- bounce=0;
- friction=1;
-
+StaticBody2D::StaticBody2D()
+ : PhysicsBody2D(Physics2DServer::BODY_MODE_STATIC) {
+ constant_angular_velocity = 0;
+ bounce = 0;
+ friction = 1;
}
StaticBody2D::~StaticBody2D() {
-
}
-
-
-
void RigidBody2D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(p_id);
+ Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_scene);
- contact_monitor->locked=true;
+ contact_monitor->locked = true;
- E->get().in_scene=true;
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ E->get().in_scene = true;
+ emit_signal(SceneStringNames::get_singleton()->body_enter, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- for(int i=0;i<E->get().shapes.size();i++) {
-
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_enter_shape, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
}
- contact_monitor->locked=false;
-
-
+ contact_monitor->locked = false;
}
void RigidBody2D::_body_exit_tree(ObjectID p_id) {
@@ -333,33 +313,32 @@ void RigidBody2D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(p_id);
+ Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_scene);
- E->get().in_scene=false;
+ E->get().in_scene = false;
- contact_monitor->locked=true;
+ contact_monitor->locked = true;
- emit_signal(SceneStringNames::get_singleton()->body_exit,node);
+ emit_signal(SceneStringNames::get_singleton()->body_exit, node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
}
- contact_monitor->locked=false;
-
+ contact_monitor->locked = false;
}
-void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,int p_local_shape) {
+void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) {
- bool body_in = p_status==1;
- ObjectID objid=p_instance;
+ bool body_in = p_status == 1;
+ ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
Node *node = obj ? obj->cast_to<Node>() : NULL;
- Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(objid);
+ Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid);
/*if (obj) {
if (body_in)
@@ -373,14 +352,14 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (body_in) {
if (!E) {
- E = contact_monitor->body_map.insert(objid,BodyState());
-// E->get().rc=0;
- E->get().in_scene=node && node->is_inside_tree();
+ E = contact_monitor->body_map.insert(objid, BodyState());
+ // E->get().rc=0;
+ E->get().in_scene = node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_scene) {
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_enter, node);
}
}
@@ -388,11 +367,10 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
}
if (node)
- E->get().shapes.insert(ShapePair(p_body_shape,p_local_shape));
-
+ E->get().shapes.insert(ShapePair(p_body_shape, p_local_shape));
if (E->get().in_scene) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_enter_shape, objid, node, p_body_shape, p_local_shape);
}
} else {
@@ -400,31 +378,27 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
//E->get().rc--;
if (node)
- E->get().shapes.erase(ShapePair(p_body_shape,p_local_shape));
+ E->get().shapes.erase(ShapePair(p_body_shape, p_local_shape));
bool in_scene = E->get().in_scene;
if (E->get().shapes.empty()) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (in_scene)
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
-
+ emit_signal(SceneStringNames::get_singleton()->body_exit, obj);
}
contact_monitor->body_map.erase(E);
}
if (node && in_scene) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, objid, obj, p_body_shape, p_local_shape);
}
-
}
-
}
-
struct _RigidBody2DInOut {
ObjectID id;
@@ -432,337 +406,315 @@ struct _RigidBody2DInOut {
int local_shape;
};
+bool RigidBody2D::_test_motion(const Vector2 &p_motion, float p_margin, const Ref<Physics2DTestMotionResult> &p_result) {
-bool RigidBody2D::_test_motion(const Vector2& p_motion,float p_margin,const Ref<Physics2DTestMotionResult>& p_result) {
-
- Physics2DServer::MotionResult *r=NULL;
+ Physics2DServer::MotionResult *r = NULL;
if (p_result.is_valid())
- r=p_result->get_result_ptr();
+ r = p_result->get_result_ptr();
if (motion_fix_enabled) {
- return Physics2DServer::get_singleton()->body_test_motion_from(get_rid(),get_global_transform(),p_motion,p_margin,r);
+ return Physics2DServer::get_singleton()->body_test_motion_from(get_rid(), get_global_transform(), p_motion, p_margin, r);
} else {
- return Physics2DServer::get_singleton()->body_test_motion(get_rid(),p_motion,p_margin,r);
+ return Physics2DServer::get_singleton()->body_test_motion(get_rid(), p_motion, p_margin, r);
}
-
}
void RigidBody2D::_direct_state_changed(Object *p_state) {
- //eh.. fuck
+//eh.. fuck
#ifdef DEBUG_ENABLED
- state=p_state->cast_to<Physics2DDirectBodyState>();
+ state = p_state->cast_to<Physics2DDirectBodyState>();
#else
- state=(Physics2DDirectBodyState*)p_state; //trust it
+ state = (Physics2DDirectBodyState *)p_state; //trust it
#endif
set_block_transform_notify(true); // don't want notify (would feedback loop)
- if (mode!=MODE_KINEMATIC)
+ if (mode != MODE_KINEMATIC)
set_global_transform(state->get_transform());
- linear_velocity=state->get_linear_velocity();
- angular_velocity=state->get_angular_velocity();
- if(sleeping!=state->is_sleeping()) {
- sleeping=state->is_sleeping();
+ linear_velocity = state->get_linear_velocity();
+ angular_velocity = state->get_angular_velocity();
+ if (sleeping != state->is_sleeping()) {
+ sleeping = state->is_sleeping();
emit_signal(SceneStringNames::get_singleton()->sleeping_state_changed);
}
if (get_script_instance())
- get_script_instance()->call("_integrate_forces",state);
+ get_script_instance()->call("_integrate_forces", state);
set_block_transform_notify(false); // want it back
if (contact_monitor) {
- contact_monitor->locked=true;
+ contact_monitor->locked = true;
//untag all
- int rc=0;
- for( Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
+ int rc = 0;
+ for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- E->get().shapes[i].tagged=false;
+ E->get().shapes[i].tagged = false;
rc++;
}
}
- _RigidBody2DInOut *toadd=(_RigidBody2DInOut*)alloca(state->get_contact_count()*sizeof(_RigidBody2DInOut));
- int toadd_count=0;//state->get_contact_count();
- RigidBody2D_RemoveAction *toremove=(RigidBody2D_RemoveAction*)alloca(rc*sizeof(RigidBody2D_RemoveAction));
- int toremove_count=0;
+ _RigidBody2DInOut *toadd = (_RigidBody2DInOut *)alloca(state->get_contact_count() * sizeof(_RigidBody2DInOut));
+ int toadd_count = 0; //state->get_contact_count();
+ RigidBody2D_RemoveAction *toremove = (RigidBody2D_RemoveAction *)alloca(rc * sizeof(RigidBody2D_RemoveAction));
+ int toremove_count = 0;
//put the ones to add
- for(int i=0;i<state->get_contact_count();i++) {
+ for (int i = 0; i < state->get_contact_count(); i++) {
ObjectID obj = state->get_contact_collider_id(i);
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
-// bool found=false;
+ // bool found=false;
- Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj);
+ Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(obj);
if (!E) {
- toadd[toadd_count].local_shape=local_shape;
- toadd[toadd_count].id=obj;
- toadd[toadd_count].shape=shape;
+ toadd[toadd_count].local_shape = local_shape;
+ toadd[toadd_count].id = obj;
+ toadd[toadd_count].shape = shape;
toadd_count++;
continue;
}
- ShapePair sp( shape,local_shape );
+ ShapePair sp(shape, local_shape);
int idx = E->get().shapes.find(sp);
- if (idx==-1) {
+ if (idx == -1) {
- toadd[toadd_count].local_shape=local_shape;
- toadd[toadd_count].id=obj;
- toadd[toadd_count].shape=shape;
+ toadd[toadd_count].local_shape = local_shape;
+ toadd[toadd_count].id = obj;
+ toadd[toadd_count].shape = shape;
toadd_count++;
continue;
}
- E->get().shapes[idx].tagged=true;
+ E->get().shapes[idx].tagged = true;
}
//put the ones to remove
- for( Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
+ for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
if (!E->get().shapes[i].tagged) {
- toremove[toremove_count].body_id=E->key();
- toremove[toremove_count].pair=E->get().shapes[i];
+ toremove[toremove_count].body_id = E->key();
+ toremove[toremove_count].pair = E->get().shapes[i];
toremove_count++;
}
}
}
-
//process remotions
+ for (int i = 0; i < toremove_count; i++) {
- for(int i=0;i<toremove_count;i++) {
-
- _body_inout(0,toremove[i].body_id,toremove[i].pair.body_shape,toremove[i].pair.local_shape);
+ _body_inout(0, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape);
}
//process aditions
+ for (int i = 0; i < toadd_count; i++) {
- for(int i=0;i<toadd_count;i++) {
-
- _body_inout(1,toadd[i].id,toadd[i].shape,toadd[i].local_shape);
+ _body_inout(1, toadd[i].id, toadd[i].shape, toadd[i].local_shape);
}
- contact_monitor->locked=false;
-
+ contact_monitor->locked = false;
}
-
-
- state=NULL;
+ state = NULL;
}
-
void RigidBody2D::set_mode(Mode p_mode) {
- mode=p_mode;
- switch(p_mode) {
+ mode = p_mode;
+ switch (p_mode) {
case MODE_RIGID: {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(),Physics2DServer::BODY_MODE_RIGID);
+ Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_RIGID);
} break;
case MODE_STATIC: {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(),Physics2DServer::BODY_MODE_STATIC);
+ Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_STATIC);
} break;
case MODE_KINEMATIC: {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(),Physics2DServer::BODY_MODE_KINEMATIC);
+ Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_KINEMATIC);
} break;
case MODE_CHARACTER: {
- Physics2DServer::get_singleton()->body_set_mode(get_rid(),Physics2DServer::BODY_MODE_CHARACTER);
+ Physics2DServer::get_singleton()->body_set_mode(get_rid(), Physics2DServer::BODY_MODE_CHARACTER);
} break;
-
}
}
-RigidBody2D::Mode RigidBody2D::get_mode() const{
+RigidBody2D::Mode RigidBody2D::get_mode() const {
return mode;
}
-void RigidBody2D::set_mass(real_t p_mass){
+void RigidBody2D::set_mass(real_t p_mass) {
- ERR_FAIL_COND(p_mass<=0);
- mass=p_mass;
+ ERR_FAIL_COND(p_mass <= 0);
+ mass = p_mass;
_change_notify("mass");
_change_notify("weight");
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_MASS,mass);
-
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_MASS, mass);
}
-real_t RigidBody2D::get_mass() const{
+real_t RigidBody2D::get_mass() const {
return mass;
}
void RigidBody2D::set_inertia(real_t p_inertia) {
- ERR_FAIL_COND(p_inertia<=0);
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_INERTIA,p_inertia);
+ ERR_FAIL_COND(p_inertia <= 0);
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_INERTIA, p_inertia);
}
-real_t RigidBody2D::get_inertia() const{
+real_t RigidBody2D::get_inertia() const {
- return Physics2DServer::get_singleton()->body_get_param(get_rid(),Physics2DServer::BODY_PARAM_INERTIA);
+ return Physics2DServer::get_singleton()->body_get_param(get_rid(), Physics2DServer::BODY_PARAM_INERTIA);
}
-void RigidBody2D::set_weight(real_t p_weight){
+void RigidBody2D::set_weight(real_t p_weight) {
- set_mass(p_weight/9.8);
+ set_mass(p_weight / 9.8);
}
-real_t RigidBody2D::get_weight() const{
+real_t RigidBody2D::get_weight() const {
- return mass*9.8;
+ return mass * 9.8;
}
+void RigidBody2D::set_friction(real_t p_friction) {
-void RigidBody2D::set_friction(real_t p_friction){
-
- ERR_FAIL_COND(p_friction<0 || p_friction>1);
-
- friction=p_friction;
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_FRICTION,friction);
+ ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
+ friction = p_friction;
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_FRICTION, friction);
}
-real_t RigidBody2D::get_friction() const{
+real_t RigidBody2D::get_friction() const {
return friction;
}
-void RigidBody2D::set_bounce(real_t p_bounce){
+void RigidBody2D::set_bounce(real_t p_bounce) {
- ERR_FAIL_COND(p_bounce<0 || p_bounce>1);
-
- bounce=p_bounce;
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_BOUNCE,bounce);
+ ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
+ bounce = p_bounce;
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_BOUNCE, bounce);
}
-real_t RigidBody2D::get_bounce() const{
+real_t RigidBody2D::get_bounce() const {
return bounce;
}
+void RigidBody2D::set_gravity_scale(real_t p_gravity_scale) {
-void RigidBody2D::set_gravity_scale(real_t p_gravity_scale){
-
- gravity_scale=p_gravity_scale;
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_GRAVITY_SCALE,gravity_scale);
-
+ gravity_scale = p_gravity_scale;
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
-real_t RigidBody2D::get_gravity_scale() const{
+real_t RigidBody2D::get_gravity_scale() const {
return gravity_scale;
}
-void RigidBody2D::set_linear_damp(real_t p_linear_damp){
-
- ERR_FAIL_COND(p_linear_damp<-1);
- linear_damp=p_linear_damp;
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_LINEAR_DAMP,linear_damp);
+void RigidBody2D::set_linear_damp(real_t p_linear_damp) {
+ ERR_FAIL_COND(p_linear_damp < -1);
+ linear_damp = p_linear_damp;
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
-real_t RigidBody2D::get_linear_damp() const{
+real_t RigidBody2D::get_linear_damp() const {
return linear_damp;
}
-void RigidBody2D::set_angular_damp(real_t p_angular_damp){
-
- ERR_FAIL_COND(p_angular_damp<-1);
- angular_damp=p_angular_damp;
- Physics2DServer::get_singleton()->body_set_param(get_rid(),Physics2DServer::BODY_PARAM_ANGULAR_DAMP,angular_damp);
+void RigidBody2D::set_angular_damp(real_t p_angular_damp) {
+ ERR_FAIL_COND(p_angular_damp < -1);
+ angular_damp = p_angular_damp;
+ Physics2DServer::get_singleton()->body_set_param(get_rid(), Physics2DServer::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
-real_t RigidBody2D::get_angular_damp() const{
+real_t RigidBody2D::get_angular_damp() const {
return angular_damp;
}
-void RigidBody2D::set_axis_velocity(const Vector2& p_axis) {
+void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) {
- Vector2 v = state? state->get_linear_velocity() : linear_velocity;
+ Vector2 v = state ? state->get_linear_velocity() : linear_velocity;
Vector2 axis = p_axis.normalized();
- v-=axis*axis.dot(v);
- v+=p_axis;
+ v -= axis * axis.dot(v);
+ v += p_axis;
if (state) {
set_linear_velocity(v);
} else {
- Physics2DServer::get_singleton()->body_set_axis_velocity(get_rid(),p_axis);
- linear_velocity=v;
+ Physics2DServer::get_singleton()->body_set_axis_velocity(get_rid(), p_axis);
+ linear_velocity = v;
}
}
-void RigidBody2D::set_linear_velocity(const Vector2& p_velocity){
+void RigidBody2D::set_linear_velocity(const Vector2 &p_velocity) {
- linear_velocity=p_velocity;
+ linear_velocity = p_velocity;
if (state)
state->set_linear_velocity(linear_velocity);
else {
- Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_LINEAR_VELOCITY,linear_velocity);
+ Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
-
}
-Vector2 RigidBody2D::get_linear_velocity() const{
+Vector2 RigidBody2D::get_linear_velocity() const {
return linear_velocity;
}
-void RigidBody2D::set_angular_velocity(real_t p_velocity){
+void RigidBody2D::set_angular_velocity(real_t p_velocity) {
- angular_velocity=p_velocity;
+ angular_velocity = p_velocity;
if (state)
state->set_angular_velocity(angular_velocity);
else
- Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_ANGULAR_VELOCITY,angular_velocity);
+ Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
}
-real_t RigidBody2D::get_angular_velocity() const{
+real_t RigidBody2D::get_angular_velocity() const {
return angular_velocity;
}
-void RigidBody2D::set_use_custom_integrator(bool p_enable){
+void RigidBody2D::set_use_custom_integrator(bool p_enable) {
- if (custom_integrator==p_enable)
+ if (custom_integrator == p_enable)
return;
- custom_integrator=p_enable;
- Physics2DServer::get_singleton()->body_set_omit_force_integration(get_rid(),p_enable);
-
-
+ custom_integrator = p_enable;
+ Physics2DServer::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
}
-bool RigidBody2D::is_using_custom_integrator(){
+bool RigidBody2D::is_using_custom_integrator() {
return custom_integrator;
}
void RigidBody2D::set_sleeping(bool p_sleeping) {
- sleeping=p_sleeping;
- Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_SLEEPING,sleeping);
-
+ sleeping = p_sleeping;
+ Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_SLEEPING, sleeping);
}
void RigidBody2D::set_can_sleep(bool p_active) {
- can_sleep=p_active;
- Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_CAN_SLEEP,p_active);
+ can_sleep = p_active;
+ Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_CAN_SLEEP, p_active);
}
bool RigidBody2D::is_able_to_sleep() const {
@@ -777,21 +729,21 @@ bool RigidBody2D::is_sleeping() const {
void RigidBody2D::set_max_contacts_reported(int p_amount) {
- max_contacts_reported=p_amount;
- Physics2DServer::get_singleton()->body_set_max_contacts_reported(get_rid(),p_amount);
+ max_contacts_reported = p_amount;
+ Physics2DServer::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
-int RigidBody2D::get_max_contacts_reported() const{
+int RigidBody2D::get_max_contacts_reported() const {
return max_contacts_reported;
}
-void RigidBody2D::apply_impulse(const Vector2& p_offset, const Vector2& p_impulse) {
+void RigidBody2D::apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse) {
- Physics2DServer::get_singleton()->body_apply_impulse(get_rid(),p_offset,p_impulse);
+ Physics2DServer::get_singleton()->body_apply_impulse(get_rid(), p_offset, p_impulse);
}
-void RigidBody2D::set_applied_force(const Vector2& p_force) {
+void RigidBody2D::set_applied_force(const Vector2 &p_force) {
Physics2DServer::get_singleton()->body_set_applied_force(get_rid(), p_force);
};
@@ -811,16 +763,15 @@ float RigidBody2D::get_applied_torque() const {
return Physics2DServer::get_singleton()->body_get_applied_torque(get_rid());
};
-void RigidBody2D::add_force(const Vector2& p_offset, const Vector2& p_force) {
+void RigidBody2D::add_force(const Vector2 &p_offset, const Vector2 &p_force) {
- Physics2DServer::get_singleton()->body_add_force(get_rid(),p_offset,p_force);
+ Physics2DServer::get_singleton()->body_add_force(get_rid(), p_offset, p_force);
}
void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) {
- ccd_mode=p_mode;
- Physics2DServer::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(),Physics2DServer::CCDMode(p_mode));
-
+ ccd_mode = p_mode;
+ Physics2DServer::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), Physics2DServer::CCDMode(p_mode));
}
RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() const {
@@ -828,22 +779,20 @@ RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() cons
return ccd_mode;
}
-
Array RigidBody2D::get_colliding_bodies() const {
- ERR_FAIL_COND_V(!contact_monitor,Array());
+ ERR_FAIL_COND_V(!contact_monitor, Array());
Array ret;
ret.resize(contact_monitor->body_map.size());
- int idx=0;
- for (const Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (const Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
if (!obj) {
- ret.resize( ret.size() -1 ); //ops
+ ret.resize(ret.size() - 1); //ops
} else {
- ret[idx++]=obj;
+ ret[idx++] = obj;
}
-
}
return ret;
@@ -851,7 +800,7 @@ Array RigidBody2D::get_colliding_bodies() const {
void RigidBody2D::set_contact_monitor(bool p_enabled) {
- if (p_enabled==is_contact_monitor_enabled())
+ if (p_enabled == is_contact_monitor_enabled())
return;
if (!p_enabled) {
@@ -861,177 +810,171 @@ void RigidBody2D::set_contact_monitor(bool p_enabled) {
}
ERR_FAIL_COND(contact_monitor->locked);
- for(Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
+ for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
//clean up mess
}
- memdelete( contact_monitor );
- contact_monitor=NULL;
+ memdelete(contact_monitor);
+ contact_monitor = NULL;
} else {
- contact_monitor = memnew( ContactMonitor );
- contact_monitor->locked=false;
+ contact_monitor = memnew(ContactMonitor);
+ contact_monitor->locked = false;
}
-
}
bool RigidBody2D::is_contact_monitor_enabled() const {
- return contact_monitor!=NULL;
+ return contact_monitor != NULL;
}
-
-
void RigidBody2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&RigidBody2D::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&RigidBody2D::get_mode);
-
- ObjectTypeDB::bind_method(_MD("set_mass","mass"),&RigidBody2D::set_mass);
- ObjectTypeDB::bind_method(_MD("get_mass"),&RigidBody2D::get_mass);
+ ObjectTypeDB::bind_method(_MD("set_mode", "mode"), &RigidBody2D::set_mode);
+ ObjectTypeDB::bind_method(_MD("get_mode"), &RigidBody2D::get_mode);
- ObjectTypeDB::bind_method(_MD("get_inertia"),&RigidBody2D::get_inertia);
- ObjectTypeDB::bind_method(_MD("set_inertia","inertia"),&RigidBody2D::set_inertia);
+ ObjectTypeDB::bind_method(_MD("set_mass", "mass"), &RigidBody2D::set_mass);
+ ObjectTypeDB::bind_method(_MD("get_mass"), &RigidBody2D::get_mass);
- ObjectTypeDB::bind_method(_MD("set_weight","weight"),&RigidBody2D::set_weight);
- ObjectTypeDB::bind_method(_MD("get_weight"),&RigidBody2D::get_weight);
+ ObjectTypeDB::bind_method(_MD("get_inertia"), &RigidBody2D::get_inertia);
+ ObjectTypeDB::bind_method(_MD("set_inertia", "inertia"), &RigidBody2D::set_inertia);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&RigidBody2D::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&RigidBody2D::get_friction);
+ ObjectTypeDB::bind_method(_MD("set_weight", "weight"), &RigidBody2D::set_weight);
+ ObjectTypeDB::bind_method(_MD("get_weight"), &RigidBody2D::get_weight);
- ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&RigidBody2D::set_bounce);
- ObjectTypeDB::bind_method(_MD("get_bounce"),&RigidBody2D::get_bounce);
+ ObjectTypeDB::bind_method(_MD("set_friction", "friction"), &RigidBody2D::set_friction);
+ ObjectTypeDB::bind_method(_MD("get_friction"), &RigidBody2D::get_friction);
- ObjectTypeDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody2D::set_gravity_scale);
- ObjectTypeDB::bind_method(_MD("get_gravity_scale"),&RigidBody2D::get_gravity_scale);
+ ObjectTypeDB::bind_method(_MD("set_bounce", "bounce"), &RigidBody2D::set_bounce);
+ ObjectTypeDB::bind_method(_MD("get_bounce"), &RigidBody2D::get_bounce);
- ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody2D::set_linear_damp);
- ObjectTypeDB::bind_method(_MD("get_linear_damp"),&RigidBody2D::get_linear_damp);
+ ObjectTypeDB::bind_method(_MD("set_gravity_scale", "gravity_scale"), &RigidBody2D::set_gravity_scale);
+ ObjectTypeDB::bind_method(_MD("get_gravity_scale"), &RigidBody2D::get_gravity_scale);
- ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody2D::set_angular_damp);
- ObjectTypeDB::bind_method(_MD("get_angular_damp"),&RigidBody2D::get_angular_damp);
+ ObjectTypeDB::bind_method(_MD("set_linear_damp", "linear_damp"), &RigidBody2D::set_linear_damp);
+ ObjectTypeDB::bind_method(_MD("get_linear_damp"), &RigidBody2D::get_linear_damp);
- ObjectTypeDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody2D::set_linear_velocity);
- ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&RigidBody2D::get_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("set_angular_damp", "angular_damp"), &RigidBody2D::set_angular_damp);
+ ObjectTypeDB::bind_method(_MD("get_angular_damp"), &RigidBody2D::get_angular_damp);
- ObjectTypeDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody2D::set_angular_velocity);
- ObjectTypeDB::bind_method(_MD("get_angular_velocity"),&RigidBody2D::get_angular_velocity);
+ ObjectTypeDB::bind_method(_MD("set_linear_velocity", "linear_velocity"), &RigidBody2D::set_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("get_linear_velocity"), &RigidBody2D::get_linear_velocity);
- ObjectTypeDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody2D::set_max_contacts_reported);
- ObjectTypeDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody2D::get_max_contacts_reported);
+ ObjectTypeDB::bind_method(_MD("set_angular_velocity", "angular_velocity"), &RigidBody2D::set_angular_velocity);
+ ObjectTypeDB::bind_method(_MD("get_angular_velocity"), &RigidBody2D::get_angular_velocity);
- ObjectTypeDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody2D::set_use_custom_integrator);
- ObjectTypeDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody2D::is_using_custom_integrator);
+ ObjectTypeDB::bind_method(_MD("set_max_contacts_reported", "amount"), &RigidBody2D::set_max_contacts_reported);
+ ObjectTypeDB::bind_method(_MD("get_max_contacts_reported"), &RigidBody2D::get_max_contacts_reported);
- ObjectTypeDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody2D::set_contact_monitor);
- ObjectTypeDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody2D::is_contact_monitor_enabled);
+ ObjectTypeDB::bind_method(_MD("set_use_custom_integrator", "enable"), &RigidBody2D::set_use_custom_integrator);
+ ObjectTypeDB::bind_method(_MD("is_using_custom_integrator"), &RigidBody2D::is_using_custom_integrator);
- ObjectTypeDB::bind_method(_MD("set_continuous_collision_detection_mode","mode"),&RigidBody2D::set_continuous_collision_detection_mode);
- ObjectTypeDB::bind_method(_MD("get_continuous_collision_detection_mode"),&RigidBody2D::get_continuous_collision_detection_mode);
+ ObjectTypeDB::bind_method(_MD("set_contact_monitor", "enabled"), &RigidBody2D::set_contact_monitor);
+ ObjectTypeDB::bind_method(_MD("is_contact_monitor_enabled"), &RigidBody2D::is_contact_monitor_enabled);
- ObjectTypeDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody2D::set_axis_velocity);
- ObjectTypeDB::bind_method(_MD("apply_impulse","offset","impulse"),&RigidBody2D::apply_impulse);
+ ObjectTypeDB::bind_method(_MD("set_continuous_collision_detection_mode", "mode"), &RigidBody2D::set_continuous_collision_detection_mode);
+ ObjectTypeDB::bind_method(_MD("get_continuous_collision_detection_mode"), &RigidBody2D::get_continuous_collision_detection_mode);
- ObjectTypeDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force);
- ObjectTypeDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force);
+ ObjectTypeDB::bind_method(_MD("set_axis_velocity", "axis_velocity"), &RigidBody2D::set_axis_velocity);
+ ObjectTypeDB::bind_method(_MD("apply_impulse", "offset", "impulse"), &RigidBody2D::apply_impulse);
- ObjectTypeDB::bind_method(_MD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque);
- ObjectTypeDB::bind_method(_MD("get_applied_torque"),&RigidBody2D::get_applied_torque);
+ ObjectTypeDB::bind_method(_MD("set_applied_force", "force"), &RigidBody2D::set_applied_force);
+ ObjectTypeDB::bind_method(_MD("get_applied_force"), &RigidBody2D::get_applied_force);
- ObjectTypeDB::bind_method(_MD("add_force","offset","force"),&RigidBody2D::add_force);
+ ObjectTypeDB::bind_method(_MD("set_applied_torque", "torque"), &RigidBody2D::set_applied_torque);
+ ObjectTypeDB::bind_method(_MD("get_applied_torque"), &RigidBody2D::get_applied_torque);
- ObjectTypeDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping);
- ObjectTypeDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping);
+ ObjectTypeDB::bind_method(_MD("add_force", "offset", "force"), &RigidBody2D::add_force);
- ObjectTypeDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep);
- ObjectTypeDB::bind_method(_MD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep);
+ ObjectTypeDB::bind_method(_MD("set_sleeping", "sleeping"), &RigidBody2D::set_sleeping);
+ ObjectTypeDB::bind_method(_MD("is_sleeping"), &RigidBody2D::is_sleeping);
- ObjectTypeDB::bind_method(_MD("test_motion","motion","margin","result:Physics2DTestMotionResult"),&RigidBody2D::_test_motion,DEFVAL(0.08),DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("set_can_sleep", "able_to_sleep"), &RigidBody2D::set_can_sleep);
+ ObjectTypeDB::bind_method(_MD("is_able_to_sleep"), &RigidBody2D::is_able_to_sleep);
- ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&RigidBody2D::_direct_state_changed);
- ObjectTypeDB::bind_method(_MD("_body_enter_tree"),&RigidBody2D::_body_enter_tree);
- ObjectTypeDB::bind_method(_MD("_body_exit_tree"),&RigidBody2D::_body_exit_tree);
+ ObjectTypeDB::bind_method(_MD("test_motion", "motion", "margin", "result:Physics2DTestMotionResult"), &RigidBody2D::_test_motion, DEFVAL(0.08), DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("get_colliding_bodies"),&RigidBody2D::get_colliding_bodies);
+ ObjectTypeDB::bind_method(_MD("_direct_state_changed"), &RigidBody2D::_direct_state_changed);
+ ObjectTypeDB::bind_method(_MD("_body_enter_tree"), &RigidBody2D::_body_enter_tree);
+ ObjectTypeDB::bind_method(_MD("_body_exit_tree"), &RigidBody2D::_body_exit_tree);
- BIND_VMETHOD(MethodInfo("_integrate_forces",PropertyInfo(Variant::OBJECT,"state:Physics2DDirectBodyState")));
+ ObjectTypeDB::bind_method(_MD("get_colliding_bodies"), &RigidBody2D::get_colliding_bodies);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Rigid,Static,Character,Kinematic"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01"),_SCS("set_mass"),_SCS("get_mass"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"weight",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01",PROPERTY_USAGE_EDITOR),_SCS("set_weight"),_SCS("get_weight"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_scale",PROPERTY_HINT_RANGE,"-128,128,0.01"),_SCS("set_gravity_scale"),_SCS("get_gravity_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"custom_integrator"),_SCS("set_use_custom_integrator"),_SCS("is_using_custom_integrator"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"continuous_cd",PROPERTY_HINT_ENUM,"Disabled,Cast Ray,Cast Shape"),_SCS("set_continuous_collision_detection_mode"),_SCS("get_continuous_collision_detection_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"contacts_reported"),_SCS("set_max_contacts_reported"),_SCS("get_max_contacts_reported"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),_SCS("set_contact_monitor"),_SCS("is_contact_monitor_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),_SCS("set_sleeping"),_SCS("is_sleeping"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"velocity/linear"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"velocity/angular"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/linear",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/angular",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
+ BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state:Physics2DDirectBodyState")));
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("sleeping_state_changed"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Rigid,Static,Character,Kinematic"), _SCS("set_mode"), _SCS("get_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), _SCS("set_mass"), _SCS("get_mass"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "weight", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", PROPERTY_USAGE_EDITOR), _SCS("set_weight"), _SCS("get_weight"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_friction"), _SCS("get_friction"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_bounce"), _SCS("get_bounce"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), _SCS("set_gravity_scale"), _SCS("get_gravity_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), _SCS("set_use_custom_integrator"), _SCS("is_using_custom_integrator"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "continuous_cd", PROPERTY_HINT_ENUM, "Disabled,Cast Ray,Cast Shape"), _SCS("set_continuous_collision_detection_mode"), _SCS("get_continuous_collision_detection_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "contacts_reported"), _SCS("set_max_contacts_reported"), _SCS("get_max_contacts_reported"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "contact_monitor"), _SCS("set_contact_monitor"), _SCS("is_contact_monitor_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), _SCS("set_sleeping"), _SCS("is_sleeping"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "can_sleep"), _SCS("set_can_sleep"), _SCS("is_able_to_sleep"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "velocity/linear"), _SCS("set_linear_velocity"), _SCS("get_linear_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "velocity/angular"), _SCS("set_angular_velocity"), _SCS("get_angular_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "damp_override/linear", PROPERTY_HINT_RANGE, "-1,128,0.01"), _SCS("set_linear_damp"), _SCS("get_linear_damp"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "damp_override/angular", PROPERTY_HINT_RANGE, "-1,128,0.01"), _SCS("set_angular_damp"), _SCS("get_angular_damp"));
- BIND_CONSTANT( MODE_STATIC );
- BIND_CONSTANT( MODE_KINEMATIC );
- BIND_CONSTANT( MODE_RIGID );
- BIND_CONSTANT( MODE_CHARACTER );
+ ADD_SIGNAL(MethodInfo("body_enter_shape", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
+ ADD_SIGNAL(MethodInfo("body_exit_shape", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
+ ADD_SIGNAL(MethodInfo("body_enter", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("body_exit", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
- BIND_CONSTANT( CCD_MODE_DISABLED );
- BIND_CONSTANT( CCD_MODE_CAST_RAY );
- BIND_CONSTANT( CCD_MODE_CAST_SHAPE );
+ BIND_CONSTANT(MODE_STATIC);
+ BIND_CONSTANT(MODE_KINEMATIC);
+ BIND_CONSTANT(MODE_RIGID);
+ BIND_CONSTANT(MODE_CHARACTER);
+ BIND_CONSTANT(CCD_MODE_DISABLED);
+ BIND_CONSTANT(CCD_MODE_CAST_RAY);
+ BIND_CONSTANT(CCD_MODE_CAST_SHAPE);
}
-RigidBody2D::RigidBody2D() : PhysicsBody2D(Physics2DServer::BODY_MODE_RIGID) {
+RigidBody2D::RigidBody2D()
+ : PhysicsBody2D(Physics2DServer::BODY_MODE_RIGID) {
- mode=MODE_RIGID;
+ mode = MODE_RIGID;
- bounce=0;
- mass=1;
- friction=1;
+ bounce = 0;
+ mass = 1;
+ friction = 1;
- gravity_scale=1;
- linear_damp=-1;
- angular_damp=-1;
+ gravity_scale = 1;
+ linear_damp = -1;
+ angular_damp = -1;
- max_contacts_reported=0;
- state=NULL;
+ max_contacts_reported = 0;
+ state = NULL;
- angular_velocity=0;
- sleeping=false;
- ccd_mode=CCD_MODE_DISABLED;
+ angular_velocity = 0;
+ sleeping = false;
+ ccd_mode = CCD_MODE_DISABLED;
- custom_integrator=false;
- contact_monitor=NULL;
- can_sleep=true;
+ custom_integrator = false;
+ contact_monitor = NULL;
+ can_sleep = true;
- Physics2DServer::get_singleton()->body_set_force_integration_callback(get_rid(),this,"_direct_state_changed");
+ Physics2DServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
}
RigidBody2D::~RigidBody2D() {
if (contact_monitor)
- memdelete( contact_monitor );
-
-
-
+ memdelete(contact_monitor);
}
//////////////////////////
Variant KinematicBody2D::_get_collider() const {
- ObjectID oid=get_collider();
- if (oid==0)
+ ObjectID oid = get_collider();
+ if (oid == 0)
return Variant();
Object *obj = ObjectDB::get_instance(oid);
if (!obj)
@@ -1048,9 +991,9 @@ Variant KinematicBody2D::_get_collider() const {
void KinematicBody2D::revert_motion() {
Matrix32 gt = get_global_transform();
- gt.elements[2]-=travel;
+ gt.elements[2] -= travel;
set_global_transform(gt);
- travel=Vector2();
+ travel = Vector2();
}
Vector2 KinematicBody2D::get_travel() const {
@@ -1058,30 +1001,28 @@ Vector2 KinematicBody2D::get_travel() const {
return travel;
}
-Vector2 KinematicBody2D::move(const Vector2& p_motion) {
+Vector2 KinematicBody2D::move(const Vector2 &p_motion) {
#if 1
Matrix32 gt = get_global_transform();
Physics2DServer::MotionResult result;
if (motion_fix_enabled) {
- colliding = Physics2DServer::get_singleton()->body_test_motion_from(get_rid(),gt,p_motion,margin,&result);
+ colliding = Physics2DServer::get_singleton()->body_test_motion_from(get_rid(), gt, p_motion, margin, &result);
} else {
- colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(),p_motion,margin,&result);
+ colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(), p_motion, margin, &result);
}
- collider_metadata=result.collider_metadata;
- collider_shape=result.collider_shape;
- collider_vel=result.collider_velocity;
- collision=result.collision_point;
- normal=result.collision_normal;
- collider=result.collider_id;
+ collider_metadata = result.collider_metadata;
+ collider_shape = result.collider_shape;
+ collider_vel = result.collider_velocity;
+ collision = result.collision_point;
+ normal = result.collision_normal;
+ collider = result.collider_id;
-
- gt.elements[2]+=result.motion;
+ gt.elements[2] += result.motion;
set_global_transform(gt);
- travel=result.motion;
-
+ travel = result.motion;
return result.remainder;
@@ -1093,43 +1034,41 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
//this took about a week to get right..
//but is it right? who knows at this point..
- colliding=false;
- ERR_FAIL_COND_V(!is_inside_tree(),Vector2());
+ colliding = false;
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector2());
Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(get_world_2d()->get_space());
- ERR_FAIL_COND_V(!dss,Vector2());
- const int max_shapes=32;
- Vector2 sr[max_shapes*2];
+ ERR_FAIL_COND_V(!dss, Vector2());
+ const int max_shapes = 32;
+ Vector2 sr[max_shapes * 2];
int res_shapes;
Set<RID> exclude;
exclude.insert(get_rid());
-
//recover first
- int recover_attempts=4;
+ int recover_attempts = 4;
- bool collided=false;
- uint32_t mask=0;
+ bool collided = false;
+ uint32_t mask = 0;
if (true)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_STATIC_BODY;
+ mask |= Physics2DDirectSpaceState::TYPE_MASK_STATIC_BODY;
if (true)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
+ mask |= Physics2DDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
if (true)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_RIGID_BODY;
+ mask |= Physics2DDirectSpaceState::TYPE_MASK_RIGID_BODY;
if (true)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
+ mask |= Physics2DDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
//print_line("margin: "+rtos(margin));
do {
//motion recover
- for(int i=0;i<get_shape_count();i++) {
+ for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_set_as_trigger(i))
continue;
- if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),Vector2(),margin,sr,max_shapes,res_shapes,exclude,get_layer_mask(),mask))
- collided=true;
-
+ if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), Vector2(), margin, sr, max_shapes, res_shapes, exclude, get_layer_mask(), mask))
+ collided = true;
}
if (!collided)
@@ -1137,143 +1076,134 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) {
Vector2 recover_motion;
- for(int i=0;i<res_shapes;i++) {
+ for (int i = 0; i < res_shapes; i++) {
- Vector2 a = sr[i*2+0];
- Vector2 b = sr[i*2+1];
+ Vector2 a = sr[i * 2 + 0];
+ Vector2 b = sr[i * 2 + 1];
float d = a.distance_to(b);
//if (d<margin)
/// continue;
- recover_motion+=(b-a)*0.4;
+ recover_motion += (b - a) * 0.4;
}
- if (recover_motion==Vector2()) {
- collided=false;
+ if (recover_motion == Vector2()) {
+ collided = false;
break;
}
-
-
Matrix32 gt = get_global_transform();
- gt.elements[2]+=recover_motion;
+ gt.elements[2] += recover_motion;
set_global_transform(gt);
recover_attempts--;
} while (recover_attempts);
-
//move second
float safe = 1.0;
float unsafe = 1.0;
- int best_shape=-1;
+ int best_shape = -1;
- for(int i=0;i<get_shape_count();i++) {
+ for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_set_as_trigger(i))
continue;
- float lsafe,lunsafe;
- bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion, 0,lsafe,lunsafe,exclude,get_layer_mask(),mask);
+ float lsafe, lunsafe;
+ bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion, 0, lsafe, lunsafe, exclude, get_layer_mask(), mask);
//print_line("shape: "+itos(i)+" travel:"+rtos(ltravel));
if (!valid) {
- safe=0;
- unsafe=0;
- best_shape=i; //sadly it's the best
+ safe = 0;
+ unsafe = 0;
+ best_shape = i; //sadly it's the best
break;
}
- if (lsafe==1.0) {
+ if (lsafe == 1.0) {
continue;
}
if (lsafe < safe) {
- safe=lsafe;
- unsafe=lunsafe;
- best_shape=i;
+ safe = lsafe;
+ unsafe = lunsafe;
+ best_shape = i;
}
}
-
//print_line("best shape: "+itos(best_shape)+" motion "+p_motion);
- if (safe>=1) {
+ if (safe >= 1) {
//not collided
- colliding=false;
-
+ colliding = false;
} else {
//it collided, let's get the rest info in unsafe advance
Matrix32 ugt = get_global_transform();
- ugt.elements[2]+=p_motion*unsafe;
+ ugt.elements[2] += p_motion * unsafe;
Physics2DDirectSpaceState::ShapeRestInfo rest_info;
- bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), Vector2(), margin,&rest_info,exclude,get_layer_mask(),mask);
+ bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt * get_shape_transform(best_shape), Vector2(), margin, &rest_info, exclude, get_layer_mask(), mask);
if (!c2) {
//should not happen, but floating point precision is so weird..
- colliding=false;
+ colliding = false;
} else {
-
//print_line("Travel: "+rtos(travel));
- colliding=true;
- collision=rest_info.point;
- normal=rest_info.normal;
- collider=rest_info.collider_id;
- collider_vel=rest_info.linear_velocity;
- collider_shape=rest_info.shape;
- collider_metadata=rest_info.metadata;
+ colliding = true;
+ collision = rest_info.point;
+ normal = rest_info.normal;
+ collider = rest_info.collider_id;
+ collider_vel = rest_info.linear_velocity;
+ collider_shape = rest_info.shape;
+ collider_metadata = rest_info.metadata;
}
-
}
- Vector2 motion=p_motion*safe;
+ Vector2 motion = p_motion * safe;
Matrix32 gt = get_global_transform();
- gt.elements[2]+=motion;
+ gt.elements[2] += motion;
set_global_transform(gt);
- return p_motion-motion;
+ return p_motion - motion;
#endif
}
-Vector2 KinematicBody2D::move_to(const Vector2& p_position) {
+Vector2 KinematicBody2D::move_to(const Vector2 &p_position) {
- return move(p_position-get_global_pos());
+ return move(p_position - get_global_pos());
}
-bool KinematicBody2D::test_move(const Vector2& p_motion) {
+bool KinematicBody2D::test_move(const Vector2 &p_motion) {
- ERR_FAIL_COND_V(!is_inside_tree(),false);
+ ERR_FAIL_COND_V(!is_inside_tree(), false);
if (motion_fix_enabled) {
- return Physics2DServer::get_singleton()->body_test_motion_from(get_rid(),get_global_transform(),p_motion,margin);
+ return Physics2DServer::get_singleton()->body_test_motion_from(get_rid(), get_global_transform(), p_motion, margin);
} else {
- return Physics2DServer::get_singleton()->body_test_motion(get_rid(),p_motion,margin);
+ return Physics2DServer::get_singleton()->body_test_motion(get_rid(), p_motion, margin);
}
}
-bool KinematicBody2D::test_move_from(const Matrix32& p_from,const Vector2& p_motion) {
+bool KinematicBody2D::test_move_from(const Matrix32 &p_from, const Vector2 &p_motion) {
- ERR_FAIL_COND_V(!is_inside_tree(),false);
+ ERR_FAIL_COND_V(!is_inside_tree(), false);
- return Physics2DServer::get_singleton()->body_test_motion_from(get_rid(),p_from,p_motion,margin);
+ return Physics2DServer::get_singleton()->body_test_motion_from(get_rid(), p_from, p_motion, margin);
}
Vector2 KinematicBody2D::get_collision_pos() const {
- ERR_FAIL_COND_V(!colliding,Vector2());
+ ERR_FAIL_COND_V(!colliding, Vector2());
return collision;
-
}
Vector2 KinematicBody2D::get_collision_normal() const {
- ERR_FAIL_COND_V(!colliding,Vector2());
+ ERR_FAIL_COND_V(!colliding, Vector2());
return normal;
-
}
Vector2 KinematicBody2D::get_collider_velocity() const {
@@ -1283,79 +1213,71 @@ Vector2 KinematicBody2D::get_collider_velocity() const {
ObjectID KinematicBody2D::get_collider() const {
- ERR_FAIL_COND_V(!colliding,0);
+ ERR_FAIL_COND_V(!colliding, 0);
return collider;
}
-
int KinematicBody2D::get_collider_shape() const {
- ERR_FAIL_COND_V(!colliding,0);
+ ERR_FAIL_COND_V(!colliding, 0);
return collider_shape;
}
Variant KinematicBody2D::get_collider_metadata() const {
- ERR_FAIL_COND_V(!colliding,0);
+ ERR_FAIL_COND_V(!colliding, 0);
return collider_metadata;
-
}
-
-bool KinematicBody2D::is_colliding() const{
+bool KinematicBody2D::is_colliding() const {
return colliding;
}
void KinematicBody2D::set_collision_margin(float p_margin) {
- margin=p_margin;
+ margin = p_margin;
}
-float KinematicBody2D::get_collision_margin() const{
+float KinematicBody2D::get_collision_margin() const {
return margin;
}
void KinematicBody2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("move", "rel_vec"), &KinematicBody2D::move);
+ ObjectTypeDB::bind_method(_MD("move_to", "position"), &KinematicBody2D::move_to);
- ObjectTypeDB::bind_method(_MD("move","rel_vec"),&KinematicBody2D::move);
- ObjectTypeDB::bind_method(_MD("move_to","position"),&KinematicBody2D::move_to);
-
- ObjectTypeDB::bind_method(_MD("test_move","rel_vec"),&KinematicBody2D::test_move);
- ObjectTypeDB::bind_method(_MD("test_move_from","from","rel_vec"),&KinematicBody2D::test_move_from);
- ObjectTypeDB::bind_method(_MD("get_travel"),&KinematicBody2D::get_travel);
- ObjectTypeDB::bind_method(_MD("revert_motion"),&KinematicBody2D::revert_motion);
+ ObjectTypeDB::bind_method(_MD("test_move", "rel_vec"), &KinematicBody2D::test_move);
+ ObjectTypeDB::bind_method(_MD("test_move_from", "from", "rel_vec"), &KinematicBody2D::test_move_from);
+ ObjectTypeDB::bind_method(_MD("get_travel"), &KinematicBody2D::get_travel);
+ ObjectTypeDB::bind_method(_MD("revert_motion"), &KinematicBody2D::revert_motion);
- ObjectTypeDB::bind_method(_MD("is_colliding"),&KinematicBody2D::is_colliding);
+ ObjectTypeDB::bind_method(_MD("is_colliding"), &KinematicBody2D::is_colliding);
- ObjectTypeDB::bind_method(_MD("get_collision_pos"),&KinematicBody2D::get_collision_pos);
- ObjectTypeDB::bind_method(_MD("get_collision_normal"),&KinematicBody2D::get_collision_normal);
- ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity);
- ObjectTypeDB::bind_method(_MD("get_collider:Variant"),&KinematicBody2D::_get_collider);
- ObjectTypeDB::bind_method(_MD("get_collider_shape"),&KinematicBody2D::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("get_collider_metadata:Variant"),&KinematicBody2D::get_collider_metadata);
-
- ObjectTypeDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody2D::set_collision_margin);
- ObjectTypeDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody2D::get_collision_margin);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/margin",PROPERTY_HINT_RANGE,"0.001,256,0.001"),_SCS("set_collision_margin"),_SCS("get_collision_margin"));
+ ObjectTypeDB::bind_method(_MD("get_collision_pos"), &KinematicBody2D::get_collision_pos);
+ ObjectTypeDB::bind_method(_MD("get_collision_normal"), &KinematicBody2D::get_collision_normal);
+ ObjectTypeDB::bind_method(_MD("get_collider_velocity"), &KinematicBody2D::get_collider_velocity);
+ ObjectTypeDB::bind_method(_MD("get_collider:Variant"), &KinematicBody2D::_get_collider);
+ ObjectTypeDB::bind_method(_MD("get_collider_shape"), &KinematicBody2D::get_collider_shape);
+ ObjectTypeDB::bind_method(_MD("get_collider_metadata:Variant"), &KinematicBody2D::get_collider_metadata);
+ ObjectTypeDB::bind_method(_MD("set_collision_margin", "pixels"), &KinematicBody2D::set_collision_margin);
+ ObjectTypeDB::bind_method(_MD("get_collision_margin", "pixels"), &KinematicBody2D::get_collision_margin);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), _SCS("set_collision_margin"), _SCS("get_collision_margin"));
}
-KinematicBody2D::KinematicBody2D() : PhysicsBody2D(Physics2DServer::BODY_MODE_KINEMATIC){
+KinematicBody2D::KinematicBody2D()
+ : PhysicsBody2D(Physics2DServer::BODY_MODE_KINEMATIC) {
- colliding=false;
- collider=0;
+ colliding = false;
+ collider = 0;
- collider_shape=0;
+ collider_shape = 0;
- margin=0.08;
+ margin = 0.08;
}
-KinematicBody2D::~KinematicBody2D() {
-
-
+KinematicBody2D::~KinematicBody2D() {
}
-
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index c86bb031a..705b58aa0 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -35,19 +35,17 @@
class PhysicsBody2D : public CollisionObject2D {
- OBJ_TYPE(PhysicsBody2D,CollisionObject2D);
+ OBJ_TYPE(PhysicsBody2D, CollisionObject2D);
uint32_t mask;
uint32_t collision_mask;
Vector2 one_way_collision_direction;
float one_way_collision_max_depth;
-
void _set_layers(uint32_t p_mask);
uint32_t _get_layers() const;
protected:
-
// So this flag can be set at startup and cached for every body
friend void register_scene_types();
static bool motion_fix_enabled;
@@ -56,37 +54,35 @@ protected:
PhysicsBody2D(Physics2DServer::BodyMode p_mode);
static void _bind_methods();
-public:
+public:
void set_layer_mask(uint32_t p_mask);
uint32_t get_layer_mask() const;
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
-
void set_collision_mask_bit(int p_bit, bool p_value);
bool get_collision_mask_bit(int p_bit) const;
void set_layer_mask_bit(int p_bit, bool p_value);
bool get_layer_mask_bit(int p_bit) const;
- void add_collision_exception_with(Node* p_node); //must be physicsbody
- void remove_collision_exception_with(Node* p_node);
+ void add_collision_exception_with(Node *p_node); //must be physicsbody
+ void remove_collision_exception_with(Node *p_node);
- void set_one_way_collision_direction(const Vector2& p_dir);
+ void set_one_way_collision_direction(const Vector2 &p_dir);
Vector2 get_one_way_collision_direction() const;
void set_one_way_collision_max_depth(float p_dir);
float get_one_way_collision_max_depth() const;
PhysicsBody2D();
-
};
class StaticBody2D : public PhysicsBody2D {
- OBJ_TYPE(StaticBody2D,PhysicsBody2D);
+ OBJ_TYPE(StaticBody2D, PhysicsBody2D);
Vector2 constant_linear_velocity;
real_t constant_angular_velocity;
@@ -94,21 +90,17 @@ class StaticBody2D : public PhysicsBody2D {
real_t bounce;
real_t friction;
-
protected:
-
static void _bind_methods();
public:
-
void set_friction(real_t p_friction);
real_t get_friction() const;
void set_bounce(real_t p_bounce);
real_t get_bounce() const;
-
- void set_constant_linear_velocity(const Vector2& p_vel);
+ void set_constant_linear_velocity(const Vector2 &p_vel);
void set_constant_angular_velocity(real_t p_vel);
Vector2 get_constant_linear_velocity() const;
@@ -116,14 +108,13 @@ public:
StaticBody2D();
~StaticBody2D();
-
};
class RigidBody2D : public PhysicsBody2D {
- OBJ_TYPE(RigidBody2D,PhysicsBody2D);
-public:
+ OBJ_TYPE(RigidBody2D, PhysicsBody2D);
+public:
enum Mode {
MODE_RIGID,
MODE_STATIC,
@@ -138,7 +129,6 @@ public:
};
private:
-
bool can_sleep;
Physics2DDirectBodyState *state;
Mode mode;
@@ -154,35 +144,34 @@ private:
real_t angular_velocity;
bool sleeping;
-
int max_contacts_reported;
bool custom_integrator;
CCDMode ccd_mode;
-
struct ShapePair {
int body_shape;
int local_shape;
bool tagged;
- bool operator<(const ShapePair& p_sp) const {
- if (body_shape==p_sp.body_shape)
+ bool operator<(const ShapePair &p_sp) const {
+ if (body_shape == p_sp.body_shape)
return local_shape < p_sp.local_shape;
else
return body_shape < p_sp.body_shape;
}
ShapePair() {}
- ShapePair(int p_bs, int p_ls) { body_shape=p_bs; local_shape=p_ls; }
+ ShapePair(int p_bs, int p_ls) {
+ body_shape = p_bs;
+ local_shape = p_ls;
+ }
};
struct RigidBody2D_RemoveAction {
-
ObjectID body_id;
ShapePair pair;
-
};
struct BodyState {
@@ -194,26 +183,22 @@ private:
struct ContactMonitor {
bool locked;
- Map<ObjectID,BodyState> body_map;
-
+ Map<ObjectID, BodyState> body_map;
};
-
ContactMonitor *contact_monitor;
void _body_enter_tree(ObjectID p_id);
void _body_exit_tree(ObjectID p_id);
-
- void _body_inout(int p_status, ObjectID p_instance, int p_body_shape,int p_local_shape);
+ void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape);
void _direct_state_changed(Object *p_state);
- bool _test_motion(const Vector2& p_motion,float p_margin=0.08,const Ref<Physics2DTestMotionResult>& p_result=Ref<Physics2DTestMotionResult>());
+ bool _test_motion(const Vector2 &p_motion, float p_margin = 0.08, const Ref<Physics2DTestMotionResult> &p_result = Ref<Physics2DTestMotionResult>());
protected:
-
static void _bind_methods();
-public:
+public:
void set_mode(Mode p_mode);
Mode get_mode() const;
@@ -241,10 +226,10 @@ public:
void set_angular_damp(real_t p_angular_damp);
real_t get_angular_damp() const;
- void set_linear_velocity(const Vector2& p_velocity);
+ void set_linear_velocity(const Vector2 &p_velocity);
Vector2 get_linear_velocity() const;
- void set_axis_velocity(const Vector2& p_axis);
+ void set_axis_velocity(const Vector2 &p_axis);
void set_angular_velocity(real_t p_velocity);
real_t get_angular_velocity() const;
@@ -267,33 +252,28 @@ public:
void set_continuous_collision_detection_mode(CCDMode p_mode);
CCDMode get_continuous_collision_detection_mode() const;
- void apply_impulse(const Vector2& p_offset, const Vector2& p_impulse);
+ void apply_impulse(const Vector2 &p_offset, const Vector2 &p_impulse);
- void set_applied_force(const Vector2& p_force);
+ void set_applied_force(const Vector2 &p_force);
Vector2 get_applied_force() const;
void set_applied_torque(const float p_torque);
float get_applied_torque() const;
- void add_force(const Vector2& p_offset, const Vector2& p_force);
-
-
+ void add_force(const Vector2 &p_offset, const Vector2 &p_force);
Array get_colliding_bodies() const; //function for script
RigidBody2D();
~RigidBody2D();
-
};
VARIANT_ENUM_CAST(RigidBody2D::Mode);
VARIANT_ENUM_CAST(RigidBody2D::CCDMode);
-
-
class KinematicBody2D : public PhysicsBody2D {
- OBJ_TYPE(KinematicBody2D,PhysicsBody2D);
+ OBJ_TYPE(KinematicBody2D, PhysicsBody2D);
float margin;
bool colliding;
@@ -308,16 +288,16 @@ class KinematicBody2D : public PhysicsBody2D {
Variant _get_collider() const;
_FORCE_INLINE_ bool _ignores_mode(Physics2DServer::BodyMode) const;
-protected:
+protected:
static void _bind_methods();
-public:
- Vector2 move(const Vector2& p_motion);
- Vector2 move_to(const Vector2& p_position);
+public:
+ Vector2 move(const Vector2 &p_motion);
+ Vector2 move_to(const Vector2 &p_position);
- bool test_move(const Vector2& p_motion);
- bool test_move_from(const Matrix32 &p_from, const Vector2& p_motion);
+ bool test_move(const Vector2 &p_motion);
+ bool test_move_from(const Matrix32 &p_from, const Vector2 &p_motion);
bool is_colliding() const;
Vector2 get_travel() const;
@@ -335,8 +315,6 @@ public:
KinematicBody2D();
~KinematicBody2D();
-
};
-
#endif // PHYSICS_BODY_2D_H
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index db71a2701..b9d8adec6 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -30,29 +30,25 @@
Rect2 Polygon2D::get_item_rect() const {
-
- if (rect_cache_dirty){
- int l =polygon.size();
+ if (rect_cache_dirty) {
+ int l = polygon.size();
DVector<Vector2>::Read r = polygon.read();
- item_rect=Rect2();
- for(int i=0;i<l;i++) {
+ item_rect = Rect2();
+ for (int i = 0; i < l; i++) {
Vector2 pos = r[i] + offset;
- if (i==0)
- item_rect.pos=pos;
+ if (i == 0)
+ item_rect.pos = pos;
else
item_rect.expand_to(pos);
}
- item_rect=item_rect.grow(20);
- rect_cache_dirty=false;
+ item_rect = item_rect.grow(20);
+ rect_cache_dirty = false;
}
-
return item_rect;
-
-
}
-void Polygon2D::edit_set_pivot(const Point2& p_pivot) {
+void Polygon2D::edit_set_pivot(const Point2 &p_pivot) {
set_offset(p_pivot);
}
@@ -68,12 +64,11 @@ bool Polygon2D::edit_has_pivot() const {
void Polygon2D::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
- if (polygon.size()<3)
+ if (polygon.size() < 3)
return;
Vector<Vector2> points;
@@ -84,162 +79,155 @@ void Polygon2D::_notification(int p_what) {
int len = points.size();
{
- DVector<Vector2>::Read polyr =polygon.read();
- for(int i=0;i<len;i++) {
- points[i]=polyr[i]+offset;
+ DVector<Vector2>::Read polyr = polygon.read();
+ for (int i = 0; i < len; i++) {
+ points[i] = polyr[i] + offset;
}
}
if (invert) {
Rect2 bounds;
- int highest_idx=-1;
- float highest_y=-1e20;
- float sum=0;
+ int highest_idx = -1;
+ float highest_y = -1e20;
+ float sum = 0;
- for(int i=0;i<len;i++) {
- if (i==0)
- bounds.pos=points[i];
+ for (int i = 0; i < len; i++) {
+ if (i == 0)
+ bounds.pos = points[i];
else
bounds.expand_to(points[i]);
- if (points[i].y>highest_y) {
- highest_idx=i;
- highest_y=points[i].y;
+ if (points[i].y > highest_y) {
+ highest_idx = i;
+ highest_y = points[i].y;
}
- int ni=(i+1)%len;
- sum+=(points[ni].x-points[i].x)*(points[ni].y+points[i].y);
+ int ni = (i + 1) % len;
+ sum += (points[ni].x - points[i].x) * (points[ni].y + points[i].y);
}
- bounds=bounds.grow(invert_border);
+ bounds = bounds.grow(invert_border);
- Vector2 ep[7]={
- Vector2(points[highest_idx].x,points[highest_idx].y+invert_border),
- Vector2(bounds.pos+bounds.size),
- Vector2(bounds.pos+Vector2(bounds.size.x,0)),
+ Vector2 ep[7] = {
+ Vector2(points[highest_idx].x, points[highest_idx].y + invert_border),
+ Vector2(bounds.pos + bounds.size),
+ Vector2(bounds.pos + Vector2(bounds.size.x, 0)),
Vector2(bounds.pos),
- Vector2(bounds.pos+Vector2(0,bounds.size.y)),
- Vector2(points[highest_idx].x-CMP_EPSILON,points[highest_idx].y+invert_border),
- Vector2(points[highest_idx].x-CMP_EPSILON,points[highest_idx].y),
+ Vector2(bounds.pos + Vector2(0, bounds.size.y)),
+ Vector2(points[highest_idx].x - CMP_EPSILON, points[highest_idx].y + invert_border),
+ Vector2(points[highest_idx].x - CMP_EPSILON, points[highest_idx].y),
};
-
- if (sum>0) {
- SWAP(ep[1],ep[4]);
- SWAP(ep[2],ep[3]);
- SWAP(ep[5],ep[0]);
- SWAP(ep[6],points[highest_idx]);
+ if (sum > 0) {
+ SWAP(ep[1], ep[4]);
+ SWAP(ep[2], ep[3]);
+ SWAP(ep[5], ep[0]);
+ SWAP(ep[6], points[highest_idx]);
}
- points.resize(points.size()+7);
- for(int i=points.size()-1;i>=highest_idx+7;i--) {
+ points.resize(points.size() + 7);
+ for (int i = points.size() - 1; i >= highest_idx + 7; i--) {
- points[i]=points[i-7];
+ points[i] = points[i - 7];
}
- for(int i=0;i<7;i++) {
+ for (int i = 0; i < 7; i++) {
- points[highest_idx+i+1]=ep[i];
+ points[highest_idx + i + 1] = ep[i];
}
-
- len=points.size();
-
+ len = points.size();
}
if (texture.is_valid()) {
- Matrix32 texmat(tex_rot,tex_ofs);
+ Matrix32 texmat(tex_rot, tex_ofs);
texmat.scale(tex_scale);
- Size2 tex_size=Vector2(1,1);
+ Size2 tex_size = Vector2(1, 1);
- tex_size=texture->get_size();
+ tex_size = texture->get_size();
uvs.resize(points.size());
- if (points.size()==uv.size()) {
+ if (points.size() == uv.size()) {
DVector<Vector2>::Read uvr = uv.read();
- for(int i=0;i<len;i++) {
- uvs[i]=texmat.xform(uvr[i])/tex_size;
+ for (int i = 0; i < len; i++) {
+ uvs[i] = texmat.xform(uvr[i]) / tex_size;
}
} else {
- for(int i=0;i<len;i++) {
- uvs[i]=texmat.xform(points[i])/tex_size;
+ for (int i = 0; i < len; i++) {
+ uvs[i] = texmat.xform(points[i]) / tex_size;
}
}
-
}
-
Vector<Color> colors;
- int color_len=vertex_colors.size();
+ int color_len = vertex_colors.size();
colors.resize(len);
{
- DVector<Color>::Read color_r=vertex_colors.read();
- for(int i=0;i<color_len && i<len;i++){
- colors[i]=color_r[i];
+ DVector<Color>::Read color_r = vertex_colors.read();
+ for (int i = 0; i < color_len && i < len; i++) {
+ colors[i] = color_r[i];
}
- for(int i=color_len;i<len;i++){
- colors[i]=color;
+ for (int i = color_len; i < len; i++) {
+ colors[i] = color;
}
}
Vector<int> indices = Geometry::triangulate_polygon(points);
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(),indices,points,colors,uvs,texture.is_valid()?texture->get_rid():RID());
+ VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
} break;
}
}
-
-void Polygon2D::set_polygon(const DVector<Vector2>& p_polygon) {
- polygon=p_polygon;
- rect_cache_dirty=true;
+void Polygon2D::set_polygon(const DVector<Vector2> &p_polygon) {
+ polygon = p_polygon;
+ rect_cache_dirty = true;
update();
}
-DVector<Vector2> Polygon2D::get_polygon() const{
+DVector<Vector2> Polygon2D::get_polygon() const {
return polygon;
}
+void Polygon2D::set_uv(const DVector<Vector2> &p_uv) {
-void Polygon2D::set_uv(const DVector<Vector2>& p_uv) {
-
- uv=p_uv;
+ uv = p_uv;
update();
}
-DVector<Vector2> Polygon2D::get_uv() const{
+DVector<Vector2> Polygon2D::get_uv() const {
return uv;
}
-void Polygon2D::set_color(const Color& p_color){
+void Polygon2D::set_color(const Color &p_color) {
- color=p_color;
+ color = p_color;
update();
}
-Color Polygon2D::get_color() const{
+Color Polygon2D::get_color() const {
return color;
}
-void Polygon2D::set_vertex_colors(const DVector<Color>& p_colors){
+void Polygon2D::set_vertex_colors(const DVector<Color> &p_colors) {
- vertex_colors=p_colors;
+ vertex_colors = p_colors;
update();
}
-DVector<Color> Polygon2D::get_vertex_colors() const{
+DVector<Color> Polygon2D::get_vertex_colors() const {
return vertex_colors;
}
-void Polygon2D::set_texture(const Ref<Texture>& p_texture){
+void Polygon2D::set_texture(const Ref<Texture> &p_texture) {
- texture=p_texture;
+ texture = p_texture;
/*if (texture.is_valid()) {
uint32_t flags=texture->get_flags();
@@ -251,77 +239,74 @@ void Polygon2D::set_texture(const Ref<Texture>& p_texture){
}*/
update();
}
-Ref<Texture> Polygon2D::get_texture() const{
+Ref<Texture> Polygon2D::get_texture() const {
return texture;
}
+void Polygon2D::set_texture_offset(const Vector2 &p_offset) {
-void Polygon2D::set_texture_offset(const Vector2& p_offset){
-
- tex_ofs=p_offset;
+ tex_ofs = p_offset;
update();
}
-Vector2 Polygon2D::get_texture_offset() const{
+Vector2 Polygon2D::get_texture_offset() const {
return tex_ofs;
}
-void Polygon2D::set_texture_rotation(float p_rot){
+void Polygon2D::set_texture_rotation(float p_rot) {
- tex_rot=p_rot;
+ tex_rot = p_rot;
update();
}
-float Polygon2D::get_texture_rotation() const{
+float Polygon2D::get_texture_rotation() const {
return tex_rot;
}
-
-void Polygon2D::_set_texture_rotationd(float p_rot){
+void Polygon2D::_set_texture_rotationd(float p_rot) {
set_texture_rotation(Math::deg2rad(p_rot));
}
-float Polygon2D::_get_texture_rotationd() const{
+float Polygon2D::_get_texture_rotationd() const {
return Math::rad2deg(get_texture_rotation());
}
+void Polygon2D::set_texture_scale(const Size2 &p_scale) {
-void Polygon2D::set_texture_scale(const Size2& p_scale){
-
- tex_scale=p_scale;
+ tex_scale = p_scale;
update();
}
-Size2 Polygon2D::get_texture_scale() const{
+Size2 Polygon2D::get_texture_scale() const {
return tex_scale;
}
-void Polygon2D::set_invert(bool p_invert){
+void Polygon2D::set_invert(bool p_invert) {
- invert=p_invert;
+ invert = p_invert;
update();
}
-bool Polygon2D::get_invert() const{
+bool Polygon2D::get_invert() const {
return invert;
}
-void Polygon2D::set_invert_border(float p_invert_border){
+void Polygon2D::set_invert_border(float p_invert_border) {
- invert_border=p_invert_border;
+ invert_border = p_invert_border;
update();
}
-float Polygon2D::get_invert_border() const{
+float Polygon2D::get_invert_border() const {
return invert_border;
}
-void Polygon2D::set_offset(const Vector2& p_offset) {
+void Polygon2D::set_offset(const Vector2 &p_offset) {
- offset=p_offset;
- rect_cache_dirty=true;
+ offset = p_offset;
+ rect_cache_dirty = true;
update();
}
@@ -330,69 +315,64 @@ Vector2 Polygon2D::get_offset() const {
return offset;
}
-
void Polygon2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&Polygon2D::set_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon"),&Polygon2D::get_polygon);
-
- ObjectTypeDB::bind_method(_MD("set_uv","uv"),&Polygon2D::set_uv);
- ObjectTypeDB::bind_method(_MD("get_uv"),&Polygon2D::get_uv);
-
- ObjectTypeDB::bind_method(_MD("set_color","color"),&Polygon2D::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&Polygon2D::get_color);
-
- ObjectTypeDB::bind_method(_MD("set_vertex_colors","vertex_colors"),&Polygon2D::set_vertex_colors);
- ObjectTypeDB::bind_method(_MD("get_vertex_colors"),&Polygon2D::get_vertex_colors);
-
- ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Polygon2D::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture"),&Polygon2D::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_polygon", "polygon"), &Polygon2D::set_polygon);
+ ObjectTypeDB::bind_method(_MD("get_polygon"), &Polygon2D::get_polygon);
- ObjectTypeDB::bind_method(_MD("set_texture_offset","texture_offset"),&Polygon2D::set_texture_offset);
- ObjectTypeDB::bind_method(_MD("get_texture_offset"),&Polygon2D::get_texture_offset);
+ ObjectTypeDB::bind_method(_MD("set_uv", "uv"), &Polygon2D::set_uv);
+ ObjectTypeDB::bind_method(_MD("get_uv"), &Polygon2D::get_uv);
- ObjectTypeDB::bind_method(_MD("set_texture_rotation","texture_rotation"),&Polygon2D::set_texture_rotation);
- ObjectTypeDB::bind_method(_MD("get_texture_rotation"),&Polygon2D::get_texture_rotation);
+ ObjectTypeDB::bind_method(_MD("set_color", "color"), &Polygon2D::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color"), &Polygon2D::get_color);
- ObjectTypeDB::bind_method(_MD("_set_texture_rotationd","texture_rotation"),&Polygon2D::_set_texture_rotationd);
- ObjectTypeDB::bind_method(_MD("_get_texture_rotationd"),&Polygon2D::_get_texture_rotationd);
+ ObjectTypeDB::bind_method(_MD("set_vertex_colors", "vertex_colors"), &Polygon2D::set_vertex_colors);
+ ObjectTypeDB::bind_method(_MD("get_vertex_colors"), &Polygon2D::get_vertex_colors);
- ObjectTypeDB::bind_method(_MD("set_texture_scale","texture_scale"),&Polygon2D::set_texture_scale);
- ObjectTypeDB::bind_method(_MD("get_texture_scale"),&Polygon2D::get_texture_scale);
+ ObjectTypeDB::bind_method(_MD("set_texture", "texture"), &Polygon2D::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture"), &Polygon2D::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_texture_offset", "texture_offset"), &Polygon2D::set_texture_offset);
+ ObjectTypeDB::bind_method(_MD("get_texture_offset"), &Polygon2D::get_texture_offset);
- ObjectTypeDB::bind_method(_MD("set_invert","invert"),&Polygon2D::set_invert);
- ObjectTypeDB::bind_method(_MD("get_invert"),&Polygon2D::get_invert);
+ ObjectTypeDB::bind_method(_MD("set_texture_rotation", "texture_rotation"), &Polygon2D::set_texture_rotation);
+ ObjectTypeDB::bind_method(_MD("get_texture_rotation"), &Polygon2D::get_texture_rotation);
- ObjectTypeDB::bind_method(_MD("set_invert_border","invert_border"),&Polygon2D::set_invert_border);
- ObjectTypeDB::bind_method(_MD("get_invert_border"),&Polygon2D::get_invert_border);
+ ObjectTypeDB::bind_method(_MD("_set_texture_rotationd", "texture_rotation"), &Polygon2D::_set_texture_rotationd);
+ ObjectTypeDB::bind_method(_MD("_get_texture_rotationd"), &Polygon2D::_get_texture_rotationd);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Polygon2D::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&Polygon2D::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_texture_scale", "texture_scale"), &Polygon2D::set_texture_scale);
+ ObjectTypeDB::bind_method(_MD("get_texture_scale"), &Polygon2D::get_texture_scale);
+ ObjectTypeDB::bind_method(_MD("set_invert", "invert"), &Polygon2D::set_invert);
+ ObjectTypeDB::bind_method(_MD("get_invert"), &Polygon2D::get_invert);
+ ObjectTypeDB::bind_method(_MD("set_invert_border", "invert_border"), &Polygon2D::set_invert_border);
+ ObjectTypeDB::bind_method(_MD("get_invert_border"), &Polygon2D::get_invert_border);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"uv"),_SCS("set_uv"),_SCS("get_uv"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color"));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR_ARRAY,"vertex_colors"),_SCS("set_vertex_colors"),_SCS("get_vertex_colors"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture/offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"texture/scale"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"texture/rotation",PROPERTY_HINT_RANGE,"-1440,1440,0.1"),_SCS("_set_texture_rotationd"),_SCS("_get_texture_rotationd"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"invert/enable"),_SCS("set_invert"),_SCS("get_invert"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"invert/border",PROPERTY_HINT_RANGE,"0.1,16384,0.1"),_SCS("set_invert_border"),_SCS("get_invert_border"));
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &Polygon2D::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &Polygon2D::get_offset);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "polygon"), _SCS("set_polygon"), _SCS("get_polygon"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "uv"), _SCS("set_uv"), _SCS("get_uv"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), _SCS("set_color"), _SCS("get_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR_ARRAY, "vertex_colors"), _SCS("set_vertex_colors"), _SCS("get_vertex_colors"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture/offset"), _SCS("set_texture_offset"), _SCS("get_texture_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture/scale"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture/rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), _SCS("_set_texture_rotationd"), _SCS("_get_texture_rotationd"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert/enable"), _SCS("set_invert"), _SCS("get_invert"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "invert/border", PROPERTY_HINT_RANGE, "0.1,16384,0.1"), _SCS("set_invert_border"), _SCS("get_invert_border"));
}
Polygon2D::Polygon2D() {
- invert=0;
- invert_border=100;
- tex_rot=0;
- tex_tile=true;
- tex_scale=Vector2(1,1);
- color=Color(1,1,1);
- rect_cache_dirty=true;
+ invert = 0;
+ invert_border = 100;
+ tex_rot = 0;
+ tex_tile = true;
+ tex_scale = Vector2(1, 1);
+ color = Color(1, 1, 1);
+ rect_cache_dirty = true;
}
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index b092a8e3d..1e72e4798 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -33,7 +33,7 @@
class Polygon2D : public Node2D {
- OBJ_TYPE(Polygon2D,Node2D);
+ OBJ_TYPE(Polygon2D, Node2D);
DVector<Vector2> polygon;
DVector<Vector2> uv;
@@ -55,33 +55,32 @@ class Polygon2D : public Node2D {
float _get_texture_rotationd() const;
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_polygon(const DVector<Vector2>& p_polygon);
+public:
+ void set_polygon(const DVector<Vector2> &p_polygon);
DVector<Vector2> get_polygon() const;
- void set_uv(const DVector<Vector2>& p_uv);
+ void set_uv(const DVector<Vector2> &p_uv);
DVector<Vector2> get_uv() const;
- void set_color(const Color& p_color);
+ void set_color(const Color &p_color);
Color get_color() const;
- void set_vertex_colors(const DVector<Color>& p_colors);
+ void set_vertex_colors(const DVector<Color> &p_colors);
DVector<Color> get_vertex_colors() const;
- void set_texture(const Ref<Texture>& p_texture);
+ void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
- void set_texture_offset(const Vector2& p_offset);
+ void set_texture_offset(const Vector2 &p_offset);
Vector2 get_texture_offset() const;
void set_texture_rotation(float p_rot);
float get_texture_rotation() const;
- void set_texture_scale(const Size2& p_scale);
+ void set_texture_scale(const Size2 &p_scale);
Size2 get_texture_scale() const;
void set_invert(bool p_rot);
@@ -90,12 +89,12 @@ public:
void set_invert_border(float p_border);
float get_invert_border() const;
- void set_offset(const Vector2& p_offset);
+ void set_offset(const Vector2 &p_offset);
Vector2 get_offset() const;
//editor stuff
- virtual void edit_set_pivot(const Point2& p_pivot);
+ virtual void edit_set_pivot(const Point2 &p_pivot);
virtual Point2 edit_get_pivot() const;
virtual bool edit_has_pivot() const;
diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp
index a25be18cb..39fc6352e 100644
--- a/scene/2d/position_2d.cpp
+++ b/scene/2d/position_2d.cpp
@@ -31,19 +31,18 @@
void Position2D::_draw_cross() {
- draw_line(Point2(-10,0),Point2(+10,0),Color(1,0.5,0.5));
- draw_line(Point2(0,-10),Point2(0,+10),Color(0.5,1,0.5));
-
+ draw_line(Point2(-10, 0), Point2(+10, 0), Color(1, 0.5, 0.5));
+ draw_line(Point2(0, -10), Point2(0, +10), Color(0.5, 1, 0.5));
}
Rect2 Position2D::get_item_rect() const {
- return Rect2(Point2(-10,-10),Size2(20,20));
+ return Rect2(Point2(-10, -10), Size2(20, 20));
}
void Position2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -57,9 +56,7 @@ void Position2D::_notification(int p_what) {
} break;
}
-
}
-Position2D::Position2D()
-{
+Position2D::Position2D() {
}
diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h
index f743a06dd..54a75c830 100644
--- a/scene/2d/position_2d.h
+++ b/scene/2d/position_2d.h
@@ -29,19 +29,18 @@
#ifndef POSITION_2D_H
#define POSITION_2D_H
-
#include "scene/2d/node_2d.h"
class Position2D : public Node2D {
- OBJ_TYPE(Position2D,Node2D)
+ OBJ_TYPE(Position2D, Node2D)
void _draw_cross();
-protected:
+protected:
void _notification(int p_what);
-public:
+public:
virtual Rect2 get_item_rect() const;
Position2D();
};
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index fcaa6cc1d..a0fea7638 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -27,25 +27,24 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "ray_cast_2d.h"
-#include "servers/physics_2d_server.h"
#include "collision_object_2d.h"
+#include "servers/physics_2d_server.h"
-void RayCast2D::set_cast_to(const Vector2& p_point) {
+void RayCast2D::set_cast_to(const Vector2 &p_point) {
- cast_to=p_point;
+ cast_to = p_point;
if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
update();
-
}
-Vector2 RayCast2D::get_cast_to() const{
+Vector2 RayCast2D::get_cast_to() const {
return cast_to;
}
void RayCast2D::set_layer_mask(uint32_t p_mask) {
- layer_mask=p_mask;
+ layer_mask = p_mask;
}
uint32_t RayCast2D::get_layer_mask() const {
@@ -55,7 +54,7 @@ uint32_t RayCast2D::get_layer_mask() const {
void RayCast2D::set_type_mask(uint32_t p_mask) {
- type_mask=p_mask;
+ type_mask = p_mask;
}
uint32_t RayCast2D::get_type_mask() const {
@@ -63,13 +62,13 @@ uint32_t RayCast2D::get_type_mask() const {
return type_mask;
}
-bool RayCast2D::is_colliding() const{
+bool RayCast2D::is_colliding() const {
return collided;
}
-Object *RayCast2D::get_collider() const{
+Object *RayCast2D::get_collider() const {
- if (against==0)
+ if (against == 0)
return NULL;
return ObjectDB::get_instance(against);
@@ -79,37 +78,32 @@ int RayCast2D::get_collider_shape() const {
return against_shape;
}
-Vector2 RayCast2D::get_collision_point() const{
+Vector2 RayCast2D::get_collision_point() const {
return collision_point;
}
-Vector2 RayCast2D::get_collision_normal() const{
+Vector2 RayCast2D::get_collision_normal() const {
return collision_normal;
}
-
void RayCast2D::set_enabled(bool p_enabled) {
- enabled=p_enabled;
+ enabled = p_enabled;
if (is_inside_tree() && !get_tree()->is_editor_hint())
set_fixed_process(p_enabled);
if (!p_enabled)
- collided=false;
-
+ collided = false;
}
-
bool RayCast2D::is_enabled() const {
-
return enabled;
}
-
void RayCast2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -128,29 +122,28 @@ void RayCast2D::_notification(int p_what) {
case NOTIFICATION_DRAW: {
- if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
+ if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
break;
Matrix32 xf;
xf.rotate(cast_to.angle());
- xf.translate(Vector2(0,cast_to.length()));
+ xf.translate(Vector2(0, cast_to.length()));
//Vector2 tip = Vector2(0,s->get_length());
- Color dcol=get_tree()->get_debug_collisions_color();//0.9,0.2,0.2,0.4);
- draw_line(Vector2(),cast_to,dcol,3);
+ Color dcol = get_tree()->get_debug_collisions_color(); //0.9,0.2,0.2,0.4);
+ draw_line(Vector2(), cast_to, dcol, 3);
Vector<Vector2> pts;
- float tsize=4;
- pts.push_back(xf.xform(Vector2(0,tsize)));
- pts.push_back(xf.xform(Vector2(0.707*tsize,0)));
- pts.push_back(xf.xform(Vector2(-0.707*tsize,0)));
+ float tsize = 4;
+ pts.push_back(xf.xform(Vector2(0, tsize)));
+ pts.push_back(xf.xform(Vector2(0.707 * tsize, 0)));
+ pts.push_back(xf.xform(Vector2(-0.707 * tsize, 0)));
Vector<Color> cols;
- for(int i=0;i<3;i++)
+ for (int i = 0; i < 3; i++)
cols.push_back(dcol);
- draw_primitive(pts,cols,Vector<Vector2>()); //small arrow
+ draw_primitive(pts, cols, Vector<Vector2>()); //small arrow
} break;
-
case NOTIFICATION_FIXED_PROCESS: {
if (!enabled)
@@ -158,35 +151,34 @@ void RayCast2D::_notification(int p_what) {
_update_raycast_state();
-
} break;
}
}
void RayCast2D::_update_raycast_state() {
Ref<World2D> w2d = get_world_2d();
- ERR_FAIL_COND( w2d.is_null() );
+ ERR_FAIL_COND(w2d.is_null());
Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(w2d->get_space());
- ERR_FAIL_COND( !dss );
+ ERR_FAIL_COND(!dss);
Matrix32 gt = get_global_transform();
Vector2 to = cast_to;
- if (to==Vector2())
- to=Vector2(0,0.01);
+ if (to == Vector2())
+ to = Vector2(0, 0.01);
Physics2DDirectSpaceState::RayResult rr;
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {
+ if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, layer_mask, type_mask)) {
- collided=true;
- against=rr.collider_id;
- collision_point=rr.position;
- collision_normal=rr.normal;
- against_shape=rr.shape;
+ collided = true;
+ against = rr.collider_id;
+ collision_point = rr.position;
+ collision_normal = rr.normal;
+ against_shape = rr.shape;
} else {
- collided=false;
+ collided = false;
}
}
@@ -194,85 +186,82 @@ void RayCast2D::force_raycast_update() {
_update_raycast_state();
}
-void RayCast2D::add_exception_rid(const RID& p_rid) {
+void RayCast2D::add_exception_rid(const RID &p_rid) {
exclude.insert(p_rid);
}
-void RayCast2D::add_exception(const Object* p_object){
+void RayCast2D::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- CollisionObject2D *co=((Object*)p_object)->cast_to<CollisionObject2D>();
+ CollisionObject2D *co = ((Object *)p_object)->cast_to<CollisionObject2D>();
if (!co)
return;
add_exception_rid(co->get_rid());
}
-void RayCast2D::remove_exception_rid(const RID& p_rid) {
+void RayCast2D::remove_exception_rid(const RID &p_rid) {
exclude.erase(p_rid);
}
-void RayCast2D::remove_exception(const Object* p_object){
+void RayCast2D::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- CollisionObject2D *co=((Object*)p_object)->cast_to<CollisionObject2D>();
+ CollisionObject2D *co = ((Object *)p_object)->cast_to<CollisionObject2D>();
if (!co)
return;
remove_exception_rid(co->get_rid());
}
-
-void RayCast2D::clear_exceptions(){
+void RayCast2D::clear_exceptions() {
exclude.clear();
}
-
void RayCast2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_enabled", "enabled"), &RayCast2D::set_enabled);
+ ObjectTypeDB::bind_method(_MD("is_enabled"), &RayCast2D::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&RayCast2D::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&RayCast2D::is_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_cast_to","local_point"),&RayCast2D::set_cast_to);
- ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast2D::get_cast_to);
+ ObjectTypeDB::bind_method(_MD("set_cast_to", "local_point"), &RayCast2D::set_cast_to);
+ ObjectTypeDB::bind_method(_MD("get_cast_to"), &RayCast2D::get_cast_to);
- ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast2D::is_colliding);
- ObjectTypeDB::bind_method(_MD("force_raycast_update"),&RayCast2D::force_raycast_update);
+ ObjectTypeDB::bind_method(_MD("is_colliding"), &RayCast2D::is_colliding);
+ ObjectTypeDB::bind_method(_MD("force_raycast_update"), &RayCast2D::force_raycast_update);
- ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast2D::get_collider);
- ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast2D::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("get_collision_point"),&RayCast2D::get_collision_point);
- ObjectTypeDB::bind_method(_MD("get_collision_normal"),&RayCast2D::get_collision_normal);
+ ObjectTypeDB::bind_method(_MD("get_collider"), &RayCast2D::get_collider);
+ ObjectTypeDB::bind_method(_MD("get_collider_shape"), &RayCast2D::get_collider_shape);
+ ObjectTypeDB::bind_method(_MD("get_collision_point"), &RayCast2D::get_collision_point);
+ ObjectTypeDB::bind_method(_MD("get_collision_normal"), &RayCast2D::get_collision_normal);
- ObjectTypeDB::bind_method(_MD("add_exception_rid","rid"),&RayCast2D::add_exception_rid);
- ObjectTypeDB::bind_method(_MD("add_exception","node"),&RayCast2D::add_exception);
+ ObjectTypeDB::bind_method(_MD("add_exception_rid", "rid"), &RayCast2D::add_exception_rid);
+ ObjectTypeDB::bind_method(_MD("add_exception", "node"), &RayCast2D::add_exception);
- ObjectTypeDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast2D::remove_exception_rid);
- ObjectTypeDB::bind_method(_MD("remove_exception","node"),&RayCast2D::remove_exception);
+ ObjectTypeDB::bind_method(_MD("remove_exception_rid", "rid"), &RayCast2D::remove_exception_rid);
+ ObjectTypeDB::bind_method(_MD("remove_exception", "node"), &RayCast2D::remove_exception);
- ObjectTypeDB::bind_method(_MD("clear_exceptions"),&RayCast2D::clear_exceptions);
+ ObjectTypeDB::bind_method(_MD("clear_exceptions"), &RayCast2D::clear_exceptions);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&RayCast2D::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&RayCast2D::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask", "mask"), &RayCast2D::set_layer_mask);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask"), &RayCast2D::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_type_mask","mask"),&RayCast2D::set_type_mask);
- ObjectTypeDB::bind_method(_MD("get_type_mask"),&RayCast2D::get_type_mask);
+ ObjectTypeDB::bind_method(_MD("set_type_mask", "mask"), &RayCast2D::set_type_mask);
+ ObjectTypeDB::bind_method(_MD("get_type_mask"), &RayCast2D::get_type_mask);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),_SCS("set_type_mask"),_SCS("get_type_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "cast_to"), _SCS("set_cast_to"), _SCS("get_cast_to"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "layer_mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type_mask", PROPERTY_HINT_FLAGS, "Static,Kinematic,Rigid,Character,Area"), _SCS("set_type_mask"), _SCS("get_type_mask"));
}
RayCast2D::RayCast2D() {
- enabled=false;
- against=0;
- collided=false;
- against_shape=0;
- layer_mask=1;
- type_mask=Physics2DDirectSpaceState::TYPE_MASK_COLLISION;
- cast_to=Vector2(0,50);
+ enabled = false;
+ against = 0;
+ collided = false;
+ against_shape = 0;
+ layer_mask = 1;
+ type_mask = Physics2DDirectSpaceState::TYPE_MASK_COLLISION;
+ cast_to = Vector2(0, 50);
}
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index f051c9318..1e8ed3533 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -33,8 +33,7 @@
class RayCast2D : public Node2D {
- OBJ_TYPE(RayCast2D,Node2D);
-
+ OBJ_TYPE(RayCast2D, Node2D);
bool enabled;
bool collided;
@@ -46,19 +45,18 @@ class RayCast2D : public Node2D {
uint32_t layer_mask;
uint32_t type_mask;
-
Vector2 cast_to;
-protected:
+protected:
void _notification(int p_what);
void _update_raycast_state();
static void _bind_methods();
-public:
+public:
void set_enabled(bool p_enabled);
bool is_enabled() const;
- void set_cast_to(const Vector2& p_point);
+ void set_cast_to(const Vector2 &p_point);
Vector2 get_cast_to() const;
void set_layer_mask(uint32_t p_mask);
@@ -75,10 +73,10 @@ public:
Vector2 get_collision_point() const;
Vector2 get_collision_normal() const;
- void add_exception_rid(const RID& p_rid);
- void add_exception(const Object* p_object);
- void remove_exception_rid(const RID& p_rid);
- void remove_exception(const Object* p_object);
+ void add_exception_rid(const RID &p_rid);
+ void add_exception(const Object *p_object);
+ void remove_exception_rid(const RID &p_rid);
+ void remove_exception(const Object *p_object);
void clear_exceptions();
RayCast2D();
diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp
index 4bb1bcb41..a96e8ca38 100644
--- a/scene/2d/remote_transform_2d.cpp
+++ b/scene/2d/remote_transform_2d.cpp
@@ -31,20 +31,19 @@
void RemoteTransform2D::_update_cache() {
- cache=0;
+ cache = 0;
if (has_node(remote_node)) {
Node *node = get_node(remote_node);
- if (!node || this==node || node->is_a_parent_of(this) || this->is_a_parent_of(node)) {
+ if (!node || this == node || node->is_a_parent_of(this) || this->is_a_parent_of(node)) {
return;
}
- cache=node->get_instance_ID();
+ cache = node->get_instance_ID();
}
}
void RemoteTransform2D::_update_remote() {
-
if (!is_inside_tree())
return;
@@ -62,14 +61,13 @@ void RemoteTransform2D::_update_remote() {
if (!n->is_inside_tree())
return;
- //todo make faster
+ //todo make faster
n->set_global_transform(get_global_transform());
-
}
void RemoteTransform2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
@@ -83,30 +81,26 @@ void RemoteTransform2D::_notification(int p_what) {
if (cache) {
_update_remote();
-
}
} break;
-
}
}
+void RemoteTransform2D::set_remote_node(const NodePath &p_remote_node) {
-void RemoteTransform2D::set_remote_node(const NodePath& p_remote_node) {
-
- remote_node=p_remote_node;
+ remote_node = p_remote_node;
if (is_inside_tree())
_update_cache();
update_configuration_warning();
}
-NodePath RemoteTransform2D::get_remote_node() const{
+NodePath RemoteTransform2D::get_remote_node() const {
return remote_node;
}
-
String RemoteTransform2D::get_configuration_warning() const {
if (!has_node(remote_node) || !get_node(remote_node) || !get_node(remote_node)->cast_to<Node2D>()) {
@@ -118,16 +112,13 @@ String RemoteTransform2D::get_configuration_warning() const {
void RemoteTransform2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_remote_node","path"),&RemoteTransform2D::set_remote_node);
- ObjectTypeDB::bind_method(_MD("get_remote_node"),&RemoteTransform2D::get_remote_node);
+ ObjectTypeDB::bind_method(_MD("set_remote_node", "path"), &RemoteTransform2D::set_remote_node);
+ ObjectTypeDB::bind_method(_MD("get_remote_node"), &RemoteTransform2D::get_remote_node);
- ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"remote_path"),_SCS("set_remote_node"),_SCS("get_remote_node"));
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "remote_path"), _SCS("set_remote_node"), _SCS("get_remote_node"));
}
RemoteTransform2D::RemoteTransform2D() {
- cache=0;
-
+ cache = 0;
}
-
-
diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h
index 27b76bcdc..ae5ac459b 100644
--- a/scene/2d/remote_transform_2d.h
+++ b/scene/2d/remote_transform_2d.h
@@ -30,7 +30,7 @@
class RemoteTransform2D : public Node2D {
- OBJ_TYPE(RemoteTransform2D,Node2D);
+ OBJ_TYPE(RemoteTransform2D, Node2D);
NodePath remote_node;
@@ -40,12 +40,11 @@ class RemoteTransform2D : public Node2D {
void _update_cache();
//void _node_exited_scene();
protected:
-
static void _bind_methods();
void _notification(int p_what);
-public:
- void set_remote_node(const NodePath& p_remote_node);
+public:
+ void set_remote_node(const NodePath &p_remote_node);
NodePath get_remote_node() const;
virtual String get_configuration_warning() const;
diff --git a/scene/2d/sample_player_2d.cpp b/scene/2d/sample_player_2d.cpp
index 2158faac2..07f0e3fb3 100644
--- a/scene/2d/sample_player_2d.cpp
+++ b/scene/2d/sample_player_2d.cpp
@@ -32,21 +32,20 @@
#include "servers/audio_server.h"
#include "servers/spatial_sound_server.h"
+bool SamplePlayer2D::_set(const StringName &p_name, const Variant &p_value) {
-bool SamplePlayer2D::_set(const StringName& p_name, const Variant& p_value) {
+ String name = p_name;
- String name=p_name;
-
- if (name=="play/play") {
+ if (name == "play/play") {
if (library.is_valid()) {
- String what=p_value;
- if (what=="")
+ String what = p_value;
+ if (what == "")
stop_all();
else
play(what);
- played_back=what;
+ played_back = what;
}
} else
return false;
@@ -54,13 +53,12 @@ bool SamplePlayer2D::_set(const StringName& p_name, const Variant& p_value) {
return true;
}
-bool SamplePlayer2D::_get(const StringName& p_name,Variant &r_ret) const {
-
+bool SamplePlayer2D::_get(const StringName &p_name, Variant &r_ret) const {
- String name=p_name;
+ String name = p_name;
- if (name=="play/play") {
- r_ret=played_back;
+ if (name == "play/play") {
+ r_ret = played_back;
} else
return false;
@@ -69,39 +67,36 @@ bool SamplePlayer2D::_get(const StringName& p_name,Variant &r_ret) const {
void SamplePlayer2D::_get_property_list(List<PropertyInfo> *p_list) const {
- String en="";
+ String en = "";
if (library.is_valid()) {
List<StringName> samples;
- Ref<SampleLibrary> ncl=library;
+ Ref<SampleLibrary> ncl = library;
ncl->get_sample_list(&samples);
- for (List<StringName>::Element *E=samples.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = samples.front(); E; E = E->next()) {
- en+=",";
- en+=E->get();
+ en += ",";
+ en += E->get();
}
}
- p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
+ p_list->push_back(PropertyInfo(Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en, PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
}
void SamplePlayer2D::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony);
-
+ SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(), polyphony);
} break;
}
-
}
-void SamplePlayer2D::set_sample_library(const Ref<SampleLibrary>& p_library) {
+void SamplePlayer2D::set_sample_library(const Ref<SampleLibrary> &p_library) {
- library=p_library;
+ library = p_library;
_change_notify();
update_configuration_warning();
}
@@ -113,11 +108,10 @@ Ref<SampleLibrary> SamplePlayer2D::get_sample_library() const {
void SamplePlayer2D::set_polyphony(int p_voice_count) {
- ERR_FAIL_COND(p_voice_count<0 || p_voice_count>64);
- polyphony=p_voice_count;
+ ERR_FAIL_COND(p_voice_count < 0 || p_voice_count > 64);
+ polyphony = p_voice_count;
if (get_source_rid().is_valid())
- SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony);
-
+ SpatialSound2DServer::get_singleton()->source_set_polyphony(get_source_rid(), polyphony);
}
int SamplePlayer2D::get_polyphony() const {
@@ -125,7 +119,7 @@ int SamplePlayer2D::get_polyphony() const {
return polyphony;
}
-SamplePlayer2D::VoiceID SamplePlayer2D::play(const String& p_sample,int p_voice) {
+SamplePlayer2D::VoiceID SamplePlayer2D::play(const String &p_sample, int p_voice) {
if (!get_source_rid().is_valid())
return INVALID_VOICE;
@@ -137,19 +131,17 @@ SamplePlayer2D::VoiceID SamplePlayer2D::play(const String& p_sample,int p_voice)
float vol_change = library->sample_get_volume_db(p_sample);
float pitch_change = library->sample_get_pitch_scale(p_sample);
- VoiceID vid = SpatialSound2DServer::get_singleton()->source_play_sample(get_source_rid(),sample->get_rid(),sample->get_mix_rate()*pitch_change,p_voice);
+ VoiceID vid = SpatialSound2DServer::get_singleton()->source_play_sample(get_source_rid(), sample->get_rid(), sample->get_mix_rate() * pitch_change, p_voice);
if (vol_change)
- SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),vid,vol_change);
-
+ SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(), vid, vol_change);
if (random_pitch_scale) {
- float ps = Math::random(-random_pitch_scale,random_pitch_scale);
- if (ps>0)
- ps=1.0+ps;
+ float ps = Math::random(-random_pitch_scale, random_pitch_scale);
+ if (ps > 0)
+ ps = 1.0 + ps;
else
- ps=1.0/(1.0-ps);
- SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),vid,ps*pitch_change);
-
+ ps = 1.0 / (1.0 - ps);
+ SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(), vid, ps * pitch_change);
}
return vid;
@@ -160,32 +152,28 @@ void SamplePlayer2D::voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale)
if (!get_source_rid().is_valid())
return;
- SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),p_voice,p_pitch_scale);
-
+ SpatialSound2DServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(), p_voice, p_pitch_scale);
}
void SamplePlayer2D::voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db) {
if (!get_source_rid().is_valid())
return;
- SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),p_voice,p_volume_db);
-
+ SpatialSound2DServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(), p_voice, p_volume_db);
}
bool SamplePlayer2D::is_voice_active(VoiceID p_voice) const {
if (!get_source_rid().is_valid())
return false;
- return SpatialSound2DServer::get_singleton()->source_is_voice_active(get_source_rid(),p_voice);
-
+ return SpatialSound2DServer::get_singleton()->source_is_voice_active(get_source_rid(), p_voice);
}
void SamplePlayer2D::stop_voice(VoiceID p_voice) {
if (!get_source_rid().is_valid())
return;
- SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(),p_voice);
-
+ SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(), p_voice);
}
void SamplePlayer2D::stop_all() {
@@ -193,14 +181,14 @@ void SamplePlayer2D::stop_all() {
if (!get_source_rid().is_valid())
return;
- for(int i=0;i<polyphony;i++) {
+ for (int i = 0; i < polyphony; i++) {
- SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(),i);
+ SpatialSound2DServer::get_singleton()->source_stop_voice(get_source_rid(), i);
}
}
void SamplePlayer2D::set_random_pitch_scale(float p_scale) {
- random_pitch_scale=p_scale;
+ random_pitch_scale = p_scale;
}
float SamplePlayer2D::get_random_pitch_scale() const {
@@ -219,44 +207,37 @@ String SamplePlayer2D::get_configuration_warning() const {
void SamplePlayer2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_sample_library", "library:SampleLibrary"), &SamplePlayer2D::set_sample_library);
+ ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"), &SamplePlayer2D::get_sample_library);
- ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer2D::set_sample_library);
- ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer2D::get_sample_library);
-
- ObjectTypeDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer2D::set_polyphony);
- ObjectTypeDB::bind_method(_MD("get_polyphony"),&SamplePlayer2D::get_polyphony);
+ ObjectTypeDB::bind_method(_MD("set_polyphony", "max_voices"), &SamplePlayer2D::set_polyphony);
+ ObjectTypeDB::bind_method(_MD("get_polyphony"), &SamplePlayer2D::get_polyphony);
- ObjectTypeDB::bind_method(_MD("play","sample","voice"),&SamplePlayer2D::play,DEFVAL(NEXT_VOICE));
+ ObjectTypeDB::bind_method(_MD("play", "sample", "voice"), &SamplePlayer2D::play, DEFVAL(NEXT_VOICE));
//voices,DEV
- ObjectTypeDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SamplePlayer2D::voice_set_pitch_scale);
- ObjectTypeDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SamplePlayer2D::voice_set_volume_scale_db);
-
- ObjectTypeDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer2D::is_voice_active);
- ObjectTypeDB::bind_method(_MD("stop_voice","voice"),&SamplePlayer2D::stop_voice);
- ObjectTypeDB::bind_method(_MD("stop_all"),&SamplePlayer2D::stop_all);
-
- ObjectTypeDB::bind_method(_MD("set_random_pitch_scale","val"),&SamplePlayer2D::set_random_pitch_scale);
- ObjectTypeDB::bind_method(_MD("get_random_pitch_scale"),&SamplePlayer2D::get_random_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("voice_set_pitch_scale", "voice", "ratio"), &SamplePlayer2D::voice_set_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("voice_set_volume_scale_db", "voice", "db"), &SamplePlayer2D::voice_set_volume_scale_db);
- BIND_CONSTANT( INVALID_VOICE );
- BIND_CONSTANT( NEXT_VOICE );
+ ObjectTypeDB::bind_method(_MD("is_voice_active", "voice"), &SamplePlayer2D::is_voice_active);
+ ObjectTypeDB::bind_method(_MD("stop_voice", "voice"), &SamplePlayer2D::stop_voice);
+ ObjectTypeDB::bind_method(_MD("stop_all"), &SamplePlayer2D::stop_all);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "config/pitch_random", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_random_pitch_scale"),_SCS("get_random_pitch_scale"));
+ ObjectTypeDB::bind_method(_MD("set_random_pitch_scale", "val"), &SamplePlayer2D::set_random_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("get_random_pitch_scale"), &SamplePlayer2D::get_random_pitch_scale);
+ BIND_CONSTANT(INVALID_VOICE);
+ BIND_CONSTANT(NEXT_VOICE);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,64,1"), _SCS("set_polyphony"), _SCS("get_polyphony"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary"), _SCS("set_sample_library"), _SCS("get_sample_library"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "config/pitch_random", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary"), _SCS("set_random_pitch_scale"), _SCS("get_random_pitch_scale"));
}
-
SamplePlayer2D::SamplePlayer2D() {
- polyphony=1;
- random_pitch_scale=0;
-
+ polyphony = 1;
+ random_pitch_scale = 0;
}
SamplePlayer2D::~SamplePlayer2D() {
-
-
}
diff --git a/scene/2d/sample_player_2d.h b/scene/2d/sample_player_2d.h
index 7fc9ea427..a0f9aadfe 100644
--- a/scene/2d/sample_player_2d.h
+++ b/scene/2d/sample_player_2d.h
@@ -34,29 +34,26 @@
class SamplePlayer2D : public SoundPlayer2D {
- OBJ_TYPE(SamplePlayer2D,SoundPlayer2D);
-public:
+ OBJ_TYPE(SamplePlayer2D, SoundPlayer2D);
+public:
enum {
- INVALID_VOICE=SpatialSoundServer::SOURCE_INVALID_VOICE,
- NEXT_VOICE=SpatialSoundServer::SOURCE_NEXT_VOICE
+ INVALID_VOICE = SpatialSoundServer::SOURCE_INVALID_VOICE,
+ NEXT_VOICE = SpatialSoundServer::SOURCE_NEXT_VOICE
};
typedef int VoiceID;
-
private:
-
Ref<SampleLibrary> library;
int polyphony;
String played_back;
float random_pitch_scale;
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
@@ -64,14 +61,13 @@ protected:
static void _bind_methods();
public:
-
- void set_sample_library(const Ref<SampleLibrary>& p_library);
+ void set_sample_library(const Ref<SampleLibrary> &p_library);
Ref<SampleLibrary> get_sample_library() const;
void set_polyphony(int p_voice_count);
int get_polyphony() const;
- VoiceID play(const String& p_sample,int p_voice=NEXT_VOICE);
+ VoiceID play(const String &p_sample, int p_voice = NEXT_VOICE);
//voices
void voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale);
void voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db);
@@ -87,8 +83,6 @@ public:
SamplePlayer2D();
~SamplePlayer2D();
-
-
};
#endif // SAMPLE_PLAYER_2D_H
diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp
index 438b668ec..569303138 100644
--- a/scene/2d/screen_button.cpp
+++ b/scene/2d/screen_button.cpp
@@ -27,45 +27,45 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "screen_button.h"
-#include "os/os.h"
#include "input_map.h"
#include "os/input.h"
+#include "os/os.h"
-void TouchScreenButton::set_texture(const Ref<Texture>& p_texture) {
+void TouchScreenButton::set_texture(const Ref<Texture> &p_texture) {
- texture=p_texture;
+ texture = p_texture;
update();
}
-Ref<Texture> TouchScreenButton::get_texture() const{
+Ref<Texture> TouchScreenButton::get_texture() const {
return texture;
}
-void TouchScreenButton::set_texture_pressed(const Ref<Texture>& p_texture_pressed) {
+void TouchScreenButton::set_texture_pressed(const Ref<Texture> &p_texture_pressed) {
- texture_pressed=p_texture_pressed;
+ texture_pressed = p_texture_pressed;
update();
}
-Ref<Texture> TouchScreenButton::get_texture_pressed() const{
+Ref<Texture> TouchScreenButton::get_texture_pressed() const {
return texture_pressed;
}
-void TouchScreenButton::set_bitmask(const Ref<BitMap>& p_bitmask){
+void TouchScreenButton::set_bitmask(const Ref<BitMap> &p_bitmask) {
- bitmask=p_bitmask;
+ bitmask = p_bitmask;
}
-Ref<BitMap> TouchScreenButton::get_bitmask() const{
+Ref<BitMap> TouchScreenButton::get_bitmask() const {
return bitmask;
}
-void TouchScreenButton::set_shape(const Ref<Shape2D>& p_shape){
+void TouchScreenButton::set_shape(const Ref<Shape2D> &p_shape) {
- shape=p_shape;
+ shape = p_shape;
if (!is_inside_tree())
return;
@@ -74,14 +74,14 @@ void TouchScreenButton::set_shape(const Ref<Shape2D>& p_shape){
update();
}
-Ref<Shape2D> TouchScreenButton::get_shape() const{
+Ref<Shape2D> TouchScreenButton::get_shape() const {
return shape;
}
void TouchScreenButton::set_shape_centered(bool p_shape_centered) {
- shape_centered=p_shape_centered;
+ shape_centered = p_shape_centered;
if (!is_inside_tree())
return;
@@ -97,50 +97,50 @@ bool TouchScreenButton::is_shape_centered() const {
void TouchScreenButton::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
return;
- if (!get_tree()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility==VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!get_tree()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
return;
- if (finger_pressed!=-1) {
+ if (finger_pressed != -1) {
if (texture_pressed.is_valid())
- draw_texture(texture_pressed,Point2());
+ draw_texture(texture_pressed, Point2());
else if (texture.is_valid())
- draw_texture(texture,Point2());
+ draw_texture(texture, Point2());
} else {
if (texture.is_valid())
- draw_texture(texture,Point2());
+ draw_texture(texture, Point2());
}
if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
return;
if (shape.is_valid()) {
- Color draw_col=get_tree()->get_debug_collisions_color();
- Vector2 pos=shape_centered ? get_item_rect().size*0.5f : Vector2();
+ Color draw_col = get_tree()->get_debug_collisions_color();
+ Vector2 pos = shape_centered ? get_item_rect().size * 0.5f : Vector2();
draw_set_transform_matrix(get_canvas_transform().translated(pos));
- shape->draw(get_canvas_item(),draw_col);
+ shape->draw(get_canvas_item(), draw_col);
}
} break;
case NOTIFICATION_ENTER_TREE: {
- if (!get_tree()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility==VISIBILITY_TOUCHSCREEN_ONLY)
+ if (!get_tree()->is_editor_hint() && !OS::get_singleton()->has_touchscreen_ui_hint() && visibility == VISIBILITY_TOUCHSCREEN_ONLY)
return;
update();
if (!get_tree()->is_editor_hint())
set_process_input(is_visible());
- if (action.operator String()!="" && InputMap::get_singleton()->has_action(action)) {
- action_id=InputMap::get_singleton()->get_action_id(action);
+ if (action.operator String() != "" && InputMap::get_singleton()->has_action(action)) {
+ action_id = InputMap::get_singleton()->get_action_id(action);
} else {
- action_id=-1;
+ action_id = -1;
}
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -165,21 +165,19 @@ void TouchScreenButton::_notification(int p_what) {
}
}
+bool TouchScreenButton::is_pressed() const {
-bool TouchScreenButton::is_pressed() const{
-
- return finger_pressed!=-1;
+ return finger_pressed != -1;
}
-void TouchScreenButton::set_action(const String& p_action) {
+void TouchScreenButton::set_action(const String &p_action) {
- action=p_action;
- if (action.operator String()!="" && InputMap::get_singleton()->has_action(action)) {
- action_id=InputMap::get_singleton()->get_action_id(action);
+ action = p_action;
+ if (action.operator String() != "" && InputMap::get_singleton()->has_action(action)) {
+ action_id = InputMap::get_singleton()->get_action_id(action);
} else {
- action_id=-1;
+ action_id = -1;
}
-
}
String TouchScreenButton::get_action() const {
@@ -187,7 +185,7 @@ String TouchScreenButton::get_action() const {
return action;
}
-void TouchScreenButton::_input(const InputEvent& p_event) {
+void TouchScreenButton::_input(const InputEvent &p_event) {
if (!get_tree())
return;
@@ -197,94 +195,88 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
if (passby_press) {
- if (p_event.type==InputEvent::SCREEN_TOUCH && !p_event.screen_touch.pressed && finger_pressed==p_event.screen_touch.index) {
+ if (p_event.type == InputEvent::SCREEN_TOUCH && !p_event.screen_touch.pressed && finger_pressed == p_event.screen_touch.index) {
_release();
}
- if ((p_event.type==InputEvent::SCREEN_TOUCH && p_event.screen_touch.pressed)|| p_event.type==InputEvent::SCREEN_DRAG) {
+ if ((p_event.type == InputEvent::SCREEN_TOUCH && p_event.screen_touch.pressed) || p_event.type == InputEvent::SCREEN_DRAG) {
- if (finger_pressed==-1 || p_event.screen_touch.index==finger_pressed) {
+ if (finger_pressed == -1 || p_event.screen_touch.index == finger_pressed) {
- Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y));
+ Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x, p_event.screen_touch.y));
- bool touched=false;
+ bool touched = false;
if (bitmask.is_valid()) {
- if (Rect2(Point2(),bitmask->get_size()).has_point(coord)) {
+ if (Rect2(Point2(), bitmask->get_size()).has_point(coord)) {
if (bitmask->get_bit(coord))
- touched=true;
+ touched = true;
}
} else {
if (texture.is_valid())
- touched=Rect2(Point2(),texture->get_size()).has_point(coord);
+ touched = Rect2(Point2(), texture->get_size()).has_point(coord);
}
-
-
if (touched) {
- if (finger_pressed==-1) {
+ if (finger_pressed == -1) {
_press(p_event.screen_touch.index);
}
} else {
- if (finger_pressed!=-1) {
+ if (finger_pressed != -1) {
_release();
}
}
-
}
-
-
}
} else {
- if (p_event.type==InputEvent::SCREEN_TOUCH) {
+ if (p_event.type == InputEvent::SCREEN_TOUCH) {
if (p_event.screen_touch.pressed) {
if (!is_visible())
return;
- const bool can_press=finger_pressed==-1;
+ const bool can_press = finger_pressed == -1;
if (!can_press)
return; //already fingering
- Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y));
+ Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x, p_event.screen_touch.y));
Rect2 item_rect = get_item_rect();
- bool touched=false;
- bool check_rect=true;
+ bool touched = false;
+ bool check_rect = true;
if (shape.is_valid()) {
- check_rect=false;
- Matrix32 xform=shape_centered ? Matrix32().translated(get_item_rect().size*0.5f) : Matrix32();
- touched=shape->collide(xform, unit_rect, Matrix32(0, coord + Vector2(0.5,0.5)));
+ check_rect = false;
+ Matrix32 xform = shape_centered ? Matrix32().translated(get_item_rect().size * 0.5f) : Matrix32();
+ touched = shape->collide(xform, unit_rect, Matrix32(0, coord + Vector2(0.5, 0.5)));
}
if (bitmask.is_valid()) {
- check_rect=false;
- if (!touched && Rect2(Point2(),bitmask->get_size()).has_point(coord)) {
+ check_rect = false;
+ if (!touched && Rect2(Point2(), bitmask->get_size()).has_point(coord)) {
if (bitmask->get_bit(coord))
- touched=true;
+ touched = true;
}
}
if (!touched && check_rect) {
if (!texture.is_null())
- touched=item_rect.has_point(coord);
+ touched = item_rect.has_point(coord);
}
-
if (touched) {
_press(p_event.screen_touch.index);
}
} else {
- if (p_event.screen_touch.index==finger_pressed) {
+ if (p_event.screen_touch.index == finger_pressed) {
_release();
}
}
@@ -294,16 +286,16 @@ void TouchScreenButton::_input(const InputEvent& p_event) {
void TouchScreenButton::_press(int p_finger_pressed) {
- finger_pressed=p_finger_pressed;
+ finger_pressed = p_finger_pressed;
- if (action_id!=-1) {
+ if (action_id != -1) {
Input::get_singleton()->action_press(action);
InputEvent ie;
- ie.type=InputEvent::ACTION;
- ie.ID=0;
- ie.action.action=action_id;
- ie.action.pressed=true;
+ ie.type = InputEvent::ACTION;
+ ie.ID = 0;
+ ie.action.action = action_id;
+ ie.action.pressed = true;
get_tree()->input_event(ie);
}
@@ -313,17 +305,17 @@ void TouchScreenButton::_press(int p_finger_pressed) {
void TouchScreenButton::_release(bool p_exiting_tree) {
- finger_pressed=-1;
+ finger_pressed = -1;
- if (action_id!=-1) {
+ if (action_id != -1) {
Input::get_singleton()->action_release(action);
if (!p_exiting_tree) {
InputEvent ie;
- ie.type=InputEvent::ACTION;
- ie.ID=0;
- ie.action.action=action_id;
- ie.action.pressed=false;
+ ie.type = InputEvent::ACTION;
+ ie.ID = 0;
+ ie.action.action = action_id;
+ ie.action.pressed = false;
get_tree()->input_event(ie);
}
}
@@ -337,16 +329,15 @@ void TouchScreenButton::_release(bool p_exiting_tree) {
Rect2 TouchScreenButton::get_item_rect() const {
if (texture.is_null())
- return Rect2(0,0,1,1);
+ return Rect2(0, 0, 1, 1);
//if (texture.is_null())
// return CanvasItem::get_item_rect();
- return Rect2(Size2(),texture->get_size());
+ return Rect2(Size2(), texture->get_size());
}
-
void TouchScreenButton::set_visibility_mode(VisibilityMode p_mode) {
- visibility=p_mode;
+ visibility = p_mode;
update();
}
@@ -357,69 +348,64 @@ TouchScreenButton::VisibilityMode TouchScreenButton::get_visibility_mode() const
void TouchScreenButton::set_passby_press(bool p_enable) {
- passby_press=p_enable;
+ passby_press = p_enable;
}
-bool TouchScreenButton::is_passby_press_enabled() const{
+bool TouchScreenButton::is_passby_press_enabled() const {
return passby_press;
}
-
-
void TouchScreenButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture"),&TouchScreenButton::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture"),&TouchScreenButton::get_texture);
-
- ObjectTypeDB::bind_method(_MD("set_texture_pressed","texture_pressed"),&TouchScreenButton::set_texture_pressed);
- ObjectTypeDB::bind_method(_MD("get_texture_pressed"),&TouchScreenButton::get_texture_pressed);
-
- ObjectTypeDB::bind_method(_MD("set_bitmask","bitmask"),&TouchScreenButton::set_bitmask);
- ObjectTypeDB::bind_method(_MD("get_bitmask"),&TouchScreenButton::get_bitmask);
-
- ObjectTypeDB::bind_method(_MD("set_shape","shape"),&TouchScreenButton::set_shape);
- ObjectTypeDB::bind_method(_MD("get_shape"),&TouchScreenButton::get_shape);
+ ObjectTypeDB::bind_method(_MD("set_texture", "texture"), &TouchScreenButton::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture"), &TouchScreenButton::get_texture);
- ObjectTypeDB::bind_method(_MD("set_shape_centered","bool"),&TouchScreenButton::set_shape_centered);
- ObjectTypeDB::bind_method(_MD("is_shape_centered"),&TouchScreenButton::is_shape_centered);
+ ObjectTypeDB::bind_method(_MD("set_texture_pressed", "texture_pressed"), &TouchScreenButton::set_texture_pressed);
+ ObjectTypeDB::bind_method(_MD("get_texture_pressed"), &TouchScreenButton::get_texture_pressed);
- ObjectTypeDB::bind_method(_MD("set_action","action"),&TouchScreenButton::set_action);
- ObjectTypeDB::bind_method(_MD("get_action"),&TouchScreenButton::get_action);
+ ObjectTypeDB::bind_method(_MD("set_bitmask", "bitmask"), &TouchScreenButton::set_bitmask);
+ ObjectTypeDB::bind_method(_MD("get_bitmask"), &TouchScreenButton::get_bitmask);
- ObjectTypeDB::bind_method(_MD("set_visibility_mode","mode"),&TouchScreenButton::set_visibility_mode);
- ObjectTypeDB::bind_method(_MD("get_visibility_mode"),&TouchScreenButton::get_visibility_mode);
+ ObjectTypeDB::bind_method(_MD("set_shape", "shape"), &TouchScreenButton::set_shape);
+ ObjectTypeDB::bind_method(_MD("get_shape"), &TouchScreenButton::get_shape);
- ObjectTypeDB::bind_method(_MD("set_passby_press","enabled"),&TouchScreenButton::set_passby_press);
- ObjectTypeDB::bind_method(_MD("is_passby_press_enabled"),&TouchScreenButton::is_passby_press_enabled);
+ ObjectTypeDB::bind_method(_MD("set_shape_centered", "bool"), &TouchScreenButton::set_shape_centered);
+ ObjectTypeDB::bind_method(_MD("is_shape_centered"), &TouchScreenButton::is_shape_centered);
- ObjectTypeDB::bind_method(_MD("is_pressed"),&TouchScreenButton::is_pressed);
+ ObjectTypeDB::bind_method(_MD("set_action", "action"), &TouchScreenButton::set_action);
+ ObjectTypeDB::bind_method(_MD("get_action"), &TouchScreenButton::get_action);
- ObjectTypeDB::bind_method(_MD("_input"),&TouchScreenButton::_input);
+ ObjectTypeDB::bind_method(_MD("set_visibility_mode", "mode"), &TouchScreenButton::set_visibility_mode);
+ ObjectTypeDB::bind_method(_MD("get_visibility_mode"), &TouchScreenButton::get_visibility_mode);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture_pressed"),_SCS("get_texture_pressed"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"bitmask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"),_SCS("set_bitmask"),_SCS("get_bitmask"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D"),_SCS("set_shape"),_SCS("get_shape"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shape_centered"),_SCS("set_shape_centered"),_SCS("is_shape_centered"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"passby_press"),_SCS("set_passby_press"),_SCS("is_passby_press_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"action"),_SCS("set_action"),_SCS("get_action"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"visibility_mode",PROPERTY_HINT_ENUM,"Always,TouchScreen Only"),_SCS("set_visibility_mode"),_SCS("get_visibility_mode"));
+ ObjectTypeDB::bind_method(_MD("set_passby_press", "enabled"), &TouchScreenButton::set_passby_press);
+ ObjectTypeDB::bind_method(_MD("is_passby_press_enabled"), &TouchScreenButton::is_passby_press_enabled);
- ADD_SIGNAL( MethodInfo("pressed" ) );
- ADD_SIGNAL( MethodInfo("released" ) );
+ ObjectTypeDB::bind_method(_MD("is_pressed"), &TouchScreenButton::is_pressed);
+ ObjectTypeDB::bind_method(_MD("_input"), &TouchScreenButton::_input);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "pressed", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture_pressed"), _SCS("get_texture_pressed"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "bitmask", PROPERTY_HINT_RESOURCE_TYPE, "BitMap"), _SCS("set_bitmask"), _SCS("get_bitmask"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D"), _SCS("set_shape"), _SCS("get_shape"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shape_centered"), _SCS("set_shape_centered"), _SCS("is_shape_centered"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "passby_press"), _SCS("set_passby_press"), _SCS("is_passby_press_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), _SCS("set_action"), _SCS("get_action"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "visibility_mode", PROPERTY_HINT_ENUM, "Always,TouchScreen Only"), _SCS("set_visibility_mode"), _SCS("get_visibility_mode"));
+ ADD_SIGNAL(MethodInfo("pressed"));
+ ADD_SIGNAL(MethodInfo("released"));
}
TouchScreenButton::TouchScreenButton() {
- finger_pressed=-1;
- action_id=-1;
- passby_press=false;
- visibility=VISIBILITY_ALWAYS;
- shape_centered=true;
- unit_rect=Ref<RectangleShape2D>(memnew(RectangleShape2D));
- unit_rect->set_extents(Vector2(0.5,0.5));
+ finger_pressed = -1;
+ action_id = -1;
+ passby_press = false;
+ visibility = VISIBILITY_ALWAYS;
+ shape_centered = true;
+ unit_rect = Ref<RectangleShape2D>(memnew(RectangleShape2D));
+ unit_rect->set_extents(Vector2(0.5, 0.5));
}
diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h
index 6f3ebdfdd..bbd69a35b 100644
--- a/scene/2d/screen_button.h
+++ b/scene/2d/screen_button.h
@@ -30,15 +30,15 @@
#define SCREEN_BUTTON_H
#include "scene/2d/node_2d.h"
-#include "scene/resources/texture.h"
#include "scene/resources/bit_mask.h"
#include "scene/resources/rectangle_shape_2d.h"
+#include "scene/resources/texture.h"
class TouchScreenButton : public Node2D {
- OBJ_TYPE(TouchScreenButton,Node2D);
-public:
+ OBJ_TYPE(TouchScreenButton, Node2D);
+public:
enum VisibilityMode {
VISIBILITY_ALWAYS,
VISIBILITY_TOUCHSCREEN_ONLY
@@ -60,34 +60,32 @@ private:
VisibilityMode visibility;
- void _input(const InputEvent& p_Event);
+ void _input(const InputEvent &p_Event);
void _press(int p_finger_pressed);
- void _release(bool p_exiting_tree=false);
+ void _release(bool p_exiting_tree = false);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
-
- void set_texture(const Ref<Texture>& p_texture);
+public:
+ void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
- void set_texture_pressed(const Ref<Texture>& p_texture_pressed);
+ void set_texture_pressed(const Ref<Texture> &p_texture_pressed);
Ref<Texture> get_texture_pressed() const;
- void set_bitmask(const Ref<BitMap>& p_bitmask);
+ void set_bitmask(const Ref<BitMap> &p_bitmask);
Ref<BitMap> get_bitmask() const;
- void set_shape(const Ref<Shape2D>& p_shape);
+ void set_shape(const Ref<Shape2D> &p_shape);
Ref<Shape2D> get_shape() const;
void set_shape_centered(bool p_shape_centered);
bool is_shape_centered() const;
- void set_action(const String& p_action);
+ void set_action(const String &p_action);
String get_action() const;
void set_passby_press(bool p_enable);
@@ -100,7 +98,6 @@ public:
Rect2 get_item_rect() const;
-
TouchScreenButton();
};
diff --git a/scene/2d/sound_player_2d.cpp b/scene/2d/sound_player_2d.cpp
index 267ce682e..8d8b2530b 100644
--- a/scene/2d/sound_player_2d.cpp
+++ b/scene/2d/sound_player_2d.cpp
@@ -30,30 +30,27 @@
#include "servers/audio_server.h"
-#include "servers/spatial_sound_2d_server.h"
#include "scene/resources/surface_tool.h"
-
+#include "servers/spatial_sound_2d_server.h"
void SoundPlayer2D::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
//find the sound space
source_rid = SpatialSound2DServer::get_singleton()->source_create(get_world_2d()->get_sound_space());
- for(int i=0;i<PARAM_MAX;i++)
- set_param(Param(i),params[i]);
-
- SpatialSound2DServer::get_singleton()->source_set_transform(source_rid,get_global_transform());
+ for (int i = 0; i < PARAM_MAX; i++)
+ set_param(Param(i), params[i]);
+ SpatialSound2DServer::get_singleton()->source_set_transform(source_rid, get_global_transform());
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- SpatialSound2DServer::get_singleton()->source_set_transform(source_rid,get_global_transform());
+ SpatialSound2DServer::get_singleton()->source_set_transform(source_rid, get_global_transform());
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -63,61 +60,49 @@ void SoundPlayer2D::_notification(int p_what) {
} break;
}
-
}
+void SoundPlayer2D::set_param(Param p_param, float p_value) {
-void SoundPlayer2D::set_param( Param p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params[p_param] = p_value;
if (source_rid.is_valid())
- SpatialSound2DServer::get_singleton()->source_set_param(source_rid,(SpatialSound2DServer::SourceParam)p_param,p_value);
-
+ SpatialSound2DServer::get_singleton()->source_set_param(source_rid, (SpatialSound2DServer::SourceParam)p_param, p_value);
}
-float SoundPlayer2D::get_param( Param p_param) const {
+float SoundPlayer2D::get_param(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
-
}
-
void SoundPlayer2D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &SoundPlayer2D::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &SoundPlayer2D::get_param);
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SoundPlayer2D::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&SoundPlayer2D::get_param);
-
- BIND_CONSTANT( PARAM_VOLUME_DB );
- BIND_CONSTANT( PARAM_PITCH_SCALE );
- BIND_CONSTANT( PARAM_ATTENUATION_MIN_DISTANCE );
- BIND_CONSTANT( PARAM_ATTENUATION_MAX_DISTANCE );
- BIND_CONSTANT( PARAM_ATTENUATION_DISTANCE_EXP );
- BIND_CONSTANT( PARAM_MAX );
-
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/min_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/max_distance",PROPERTY_HINT_EXP_RANGE, "16,16384,1"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP);
+ BIND_CONSTANT(PARAM_VOLUME_DB);
+ BIND_CONSTANT(PARAM_PITCH_SCALE);
+ BIND_CONSTANT(PARAM_ATTENUATION_MIN_DISTANCE);
+ BIND_CONSTANT(PARAM_ATTENUATION_MAX_DISTANCE);
+ BIND_CONSTANT(PARAM_ATTENUATION_DISTANCE_EXP);
+ BIND_CONSTANT(PARAM_MAX);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_VOLUME_DB);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/pitch_scale", PROPERTY_HINT_RANGE, "0.001,32,0.001"), _SCS("set_param"), _SCS("get_param"), PARAM_PITCH_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation/min_distance", PROPERTY_HINT_EXP_RANGE, "16,16384,1"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_MIN_DISTANCE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation/max_distance", PROPERTY_HINT_EXP_RANGE, "16,16384,1"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_MAX_DISTANCE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation/distance_exp", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_DISTANCE_EXP);
}
-
SoundPlayer2D::SoundPlayer2D() {
- params[PARAM_VOLUME_DB]=0.0;
- params[PARAM_PITCH_SCALE]=1.0;
- params[PARAM_ATTENUATION_MIN_DISTANCE]=1;
- params[PARAM_ATTENUATION_MAX_DISTANCE]=2048;
- params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
-
-
+ params[PARAM_VOLUME_DB] = 0.0;
+ params[PARAM_PITCH_SCALE] = 1.0;
+ params[PARAM_ATTENUATION_MIN_DISTANCE] = 1;
+ params[PARAM_ATTENUATION_MAX_DISTANCE] = 2048;
+ params[PARAM_ATTENUATION_DISTANCE_EXP] = 1.0; //linear (and not really good)
}
SoundPlayer2D::~SoundPlayer2D() {
-
-
}
diff --git a/scene/2d/sound_player_2d.h b/scene/2d/sound_player_2d.h
index f0d847daa..abe531352 100644
--- a/scene/2d/sound_player_2d.h
+++ b/scene/2d/sound_player_2d.h
@@ -29,36 +29,31 @@
#ifndef SOUND_PLAYER_2D_H
#define SOUND_PLAYER_2D_H
-
#include "scene/2d/node_2d.h"
+#include "scene/main/viewport.h"
#include "scene/resources/sample_library.h"
#include "servers/spatial_sound_2d_server.h"
-#include "scene/main/viewport.h"
class SoundPlayer2D : public Node2D {
- OBJ_TYPE(SoundPlayer2D,Node2D);
-public:
-
+ OBJ_TYPE(SoundPlayer2D, Node2D);
+public:
enum Param {
- PARAM_VOLUME_DB=SpatialSound2DServer::SOURCE_PARAM_VOLUME_DB,
- PARAM_PITCH_SCALE=SpatialSound2DServer::SOURCE_PARAM_PITCH_SCALE,
- PARAM_ATTENUATION_MIN_DISTANCE=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE,
- PARAM_ATTENUATION_MAX_DISTANCE=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE,
- PARAM_ATTENUATION_DISTANCE_EXP=SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP,
- PARAM_MAX=SpatialSound2DServer::SOURCE_PARAM_MAX
+ PARAM_VOLUME_DB = SpatialSound2DServer::SOURCE_PARAM_VOLUME_DB,
+ PARAM_PITCH_SCALE = SpatialSound2DServer::SOURCE_PARAM_PITCH_SCALE,
+ PARAM_ATTENUATION_MIN_DISTANCE = SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE,
+ PARAM_ATTENUATION_MAX_DISTANCE = SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE,
+ PARAM_ATTENUATION_DISTANCE_EXP = SpatialSound2DServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP,
+ PARAM_MAX = SpatialSound2DServer::SOURCE_PARAM_MAX
};
private:
-
float params[PARAM_MAX];
RID source_rid;
-
protected:
-
_FORCE_INLINE_ RID get_source_rid() const { return source_rid; }
void _notification(int p_what);
@@ -66,17 +61,13 @@ protected:
static void _bind_methods();
public:
-
- void set_param( Param p_param, float p_value);
- float get_param( Param p_param) const;
-
+ void set_param(Param p_param, float p_value);
+ float get_param(Param p_param) const;
SoundPlayer2D();
~SoundPlayer2D();
-
-
};
-VARIANT_ENUM_CAST(SoundPlayer2D::Param );
+VARIANT_ENUM_CAST(SoundPlayer2D::Param);
#endif // SOUND_PLAYER_2D_H
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index c885dddee..8b227115c 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -28,14 +28,13 @@
/*************************************************************************/
#include "sprite.h"
#include "core/core_string_names.h"
-#include "scene/scene_string_names.h"
-#include "scene/main/viewport.h"
#include "os/os.h"
+#include "scene/main/viewport.h"
+#include "scene/scene_string_names.h"
-void Sprite::edit_set_pivot(const Point2& p_pivot) {
+void Sprite::edit_set_pivot(const Point2 &p_pivot) {
set_offset(p_pivot);
-
}
Point2 Sprite::edit_get_pivot() const {
@@ -49,16 +48,13 @@ bool Sprite::edit_has_pivot() const {
void Sprite::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (texture.is_null())
return;
-
-
-
RID ci = get_canvas_item();
/*
@@ -71,52 +67,51 @@ void Sprite::_notification(int p_what) {
if (region) {
- s=region_rect.size;
- src_rect=region_rect;
+ s = region_rect.size;
+ src_rect = region_rect;
} else {
s = Size2(texture->get_size());
- s=s/Size2(hframes,vframes);
-
- src_rect.size=s;
- src_rect.pos.x+=float(frame%hframes)*s.x;
- src_rect.pos.y+=float(frame/hframes)*s.y;
+ s = s / Size2(hframes, vframes);
+ src_rect.size = s;
+ src_rect.pos.x += float(frame % hframes) * s.x;
+ src_rect.pos.y += float(frame / hframes) * s.y;
}
- Point2 ofs=offset;
+ Point2 ofs = offset;
if (centered)
- ofs-=s/2;
+ ofs -= s / 2;
if (OS::get_singleton()->get_use_pixel_snap()) {
- ofs=ofs.floor();
+ ofs = ofs.floor();
}
- Rect2 dst_rect(ofs,s);
+ Rect2 dst_rect(ofs, s);
if (hflip)
- dst_rect.size.x=-dst_rect.size.x;
+ dst_rect.size.x = -dst_rect.size.x;
if (vflip)
- dst_rect.size.y=-dst_rect.size.y;
+ dst_rect.size.y = -dst_rect.size.y;
- texture->draw_rect_region(ci,dst_rect,src_rect,modulate);
+ texture->draw_rect_region(ci, dst_rect, src_rect, modulate);
} break;
}
}
-void Sprite::set_texture(const Ref<Texture>& p_texture) {
+void Sprite::set_texture(const Ref<Texture> &p_texture) {
- if (p_texture==texture)
+ if (p_texture == texture)
return;
#ifdef DEBUG_ENABLED
if (texture.is_valid()) {
- texture->disconnect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->update);
+ texture->disconnect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->update);
}
#endif
- texture=p_texture;
+ texture = p_texture;
#ifdef DEBUG_ENABLED
if (texture.is_valid()) {
texture->set_flags(texture->get_flags()); //remove repeat from texture, it looks bad in sprites
- texture->connect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->update);
+ texture->connect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->update);
}
#endif
update();
@@ -131,7 +126,7 @@ Ref<Texture> Sprite::get_texture() const {
void Sprite::set_centered(bool p_center) {
- centered=p_center;
+ centered = p_center;
update();
item_rect_changed();
}
@@ -141,9 +136,9 @@ bool Sprite::is_centered() const {
return centered;
}
-void Sprite::set_offset(const Point2& p_offset) {
+void Sprite::set_offset(const Point2 &p_offset) {
- offset=p_offset;
+ offset = p_offset;
update();
item_rect_changed();
_change_notify("offset");
@@ -155,7 +150,7 @@ Point2 Sprite::get_offset() const {
void Sprite::set_flip_h(bool p_flip) {
- hflip=p_flip;
+ hflip = p_flip;
update();
}
bool Sprite::is_flipped_h() const {
@@ -165,7 +160,7 @@ bool Sprite::is_flipped_h() const {
void Sprite::set_flip_v(bool p_flip) {
- vflip=p_flip;
+ vflip = p_flip;
update();
}
bool Sprite::is_flipped_v() const {
@@ -175,24 +170,24 @@ bool Sprite::is_flipped_v() const {
void Sprite::set_region(bool p_region) {
- if (p_region==region)
+ if (p_region == region)
return;
- region=p_region;
+ region = p_region;
update();
}
-bool Sprite::is_region() const{
+bool Sprite::is_region() const {
return region;
}
-void Sprite::set_region_rect(const Rect2& p_region_rect) {
+void Sprite::set_region_rect(const Rect2 &p_region_rect) {
- if (region_rect==p_region_rect)
+ if (region_rect == p_region_rect)
return;
- region_rect=p_region_rect;
+ region_rect = p_region_rect;
if (region)
item_rect_changed();
@@ -207,12 +202,12 @@ Rect2 Sprite::get_region_rect() const {
void Sprite::set_frame(int p_frame) {
- ERR_FAIL_INDEX(p_frame,vframes*hframes);
+ ERR_FAIL_INDEX(p_frame, vframes * hframes);
if (frame != p_frame)
item_rect_changed();
- frame=p_frame;
+ frame = p_frame;
_change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
@@ -225,8 +220,8 @@ int Sprite::get_frame() const {
void Sprite::set_vframes(int p_amount) {
- ERR_FAIL_COND(p_amount<1);
- vframes=p_amount;
+ ERR_FAIL_COND(p_amount < 1);
+ vframes = p_amount;
update();
item_rect_changed();
_change_notify("frame");
@@ -238,8 +233,8 @@ int Sprite::get_vframes() const {
void Sprite::set_hframes(int p_amount) {
- ERR_FAIL_COND(p_amount<1);
- hframes=p_amount;
+ ERR_FAIL_COND(p_amount < 1);
+ hframes = p_amount;
update();
item_rect_changed();
_change_notify("frame");
@@ -249,22 +244,21 @@ int Sprite::get_hframes() const {
return hframes;
}
-void Sprite::set_modulate(const Color& p_color) {
+void Sprite::set_modulate(const Color &p_color) {
- modulate=p_color;
+ modulate = p_color;
update();
}
-Color Sprite::get_modulate() const{
+Color Sprite::get_modulate() const {
return modulate;
}
-
Rect2 Sprite::get_item_rect() const {
if (texture.is_null())
- return Rect2(0,0,1,1);
+ return Rect2(0, 0, 1, 1);
//if (texture.is_null())
// return CanvasItem::get_item_rect();
@@ -272,113 +266,104 @@ Rect2 Sprite::get_item_rect() const {
if (region) {
- s=region_rect.size;
+ s = region_rect.size;
} else {
s = texture->get_size();
- s=s/Point2(hframes,vframes);
+ s = s / Point2(hframes, vframes);
}
- Point2 ofs=offset;
+ Point2 ofs = offset;
if (centered)
- ofs-=s/2;
+ ofs -= s / 2;
- if (s==Size2(0,0))
- s=Size2(1,1);
+ if (s == Size2(0, 0))
+ s = Size2(1, 1);
- return Rect2(ofs,s);
+ return Rect2(ofs, s);
}
+void Sprite::_validate_property(PropertyInfo &property) const {
+ if (property.name == "frame") {
-void Sprite::_validate_property(PropertyInfo& property) const {
-
- if (property.name=="frame") {
-
- property.hint=PROPERTY_HINT_SPRITE_FRAME;
+ property.hint = PROPERTY_HINT_SPRITE_FRAME;
- property.hint_string="0,"+itos(vframes*hframes-1)+",1";
+ property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
}
}
void Sprite::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&Sprite::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_texture", "texture:Texture"), &Sprite::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture"), &Sprite::get_texture);
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&Sprite::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&Sprite::is_centered);
+ ObjectTypeDB::bind_method(_MD("set_centered", "centered"), &Sprite::set_centered);
+ ObjectTypeDB::bind_method(_MD("is_centered"), &Sprite::is_centered);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Sprite::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&Sprite::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &Sprite::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &Sprite::get_offset);
- ObjectTypeDB::bind_method(_MD("set_flip_h","flip_h"),&Sprite::set_flip_h);
- ObjectTypeDB::bind_method(_MD("is_flipped_h"),&Sprite::is_flipped_h);
+ ObjectTypeDB::bind_method(_MD("set_flip_h", "flip_h"), &Sprite::set_flip_h);
+ ObjectTypeDB::bind_method(_MD("is_flipped_h"), &Sprite::is_flipped_h);
- ObjectTypeDB::bind_method(_MD("set_flip_v","flip_v"),&Sprite::set_flip_v);
- ObjectTypeDB::bind_method(_MD("is_flipped_v"),&Sprite::is_flipped_v);
+ ObjectTypeDB::bind_method(_MD("set_flip_v", "flip_v"), &Sprite::set_flip_v);
+ ObjectTypeDB::bind_method(_MD("is_flipped_v"), &Sprite::is_flipped_v);
- ObjectTypeDB::bind_method(_MD("set_region","enabled"),&Sprite::set_region);
- ObjectTypeDB::bind_method(_MD("is_region"),&Sprite::is_region);
+ ObjectTypeDB::bind_method(_MD("set_region", "enabled"), &Sprite::set_region);
+ ObjectTypeDB::bind_method(_MD("is_region"), &Sprite::is_region);
- ObjectTypeDB::bind_method(_MD("set_region_rect","rect"),&Sprite::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&Sprite::get_region_rect);
+ ObjectTypeDB::bind_method(_MD("set_region_rect", "rect"), &Sprite::set_region_rect);
+ ObjectTypeDB::bind_method(_MD("get_region_rect"), &Sprite::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&Sprite::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&Sprite::get_frame);
+ ObjectTypeDB::bind_method(_MD("set_frame", "frame"), &Sprite::set_frame);
+ ObjectTypeDB::bind_method(_MD("get_frame"), &Sprite::get_frame);
- ObjectTypeDB::bind_method(_MD("set_vframes","vframes"),&Sprite::set_vframes);
- ObjectTypeDB::bind_method(_MD("get_vframes"),&Sprite::get_vframes);
+ ObjectTypeDB::bind_method(_MD("set_vframes", "vframes"), &Sprite::set_vframes);
+ ObjectTypeDB::bind_method(_MD("get_vframes"), &Sprite::get_vframes);
- ObjectTypeDB::bind_method(_MD("set_hframes","hframes"),&Sprite::set_hframes);
- ObjectTypeDB::bind_method(_MD("get_hframes"),&Sprite::get_hframes);
+ ObjectTypeDB::bind_method(_MD("set_hframes", "hframes"), &Sprite::set_hframes);
+ ObjectTypeDB::bind_method(_MD("get_hframes"), &Sprite::get_hframes);
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&Sprite::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&Sprite::get_modulate);
+ ObjectTypeDB::bind_method(_MD("set_modulate", "modulate"), &Sprite::set_modulate);
+ ObjectTypeDB::bind_method(_MD("get_modulate"), &Sprite::get_modulate);
ADD_SIGNAL(MethodInfo("frame_changed"));
ADD_SIGNAL(MethodInfo("texture_changed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v"));
- ADD_PROPERTYNO( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_vframes"),_SCS("get_vframes"));
- ADD_PROPERTYNO( PropertyInfo( Variant::INT, "hframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_hframes"),_SCS("get_hframes"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
-
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "centered"), _SCS("set_centered"), _SCS("is_centered"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "flip_h"), _SCS("set_flip_h"), _SCS("is_flipped_h"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "flip_v"), _SCS("set_flip_v"), _SCS("is_flipped_v"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), _SCS("set_vframes"), _SCS("get_vframes"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), _SCS("set_hframes"), _SCS("get_hframes"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"), _SCS("get_frame"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "region"), _SCS("set_region"), _SCS("is_region"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::RECT2, "region_rect"), _SCS("set_region_rect"), _SCS("get_region_rect"));
}
Sprite::Sprite() {
- centered=true;
- hflip=false;
- vflip=false;
- region=false;
-
- frame=0;
-
- vframes=1;
- hframes=1;
+ centered = true;
+ hflip = false;
+ vflip = false;
+ region = false;
- modulate=Color(1,1,1,1);
+ frame = 0;
+ vframes = 1;
+ hframes = 1;
+ modulate = Color(1, 1, 1, 1);
}
-
-
-
//////////////////////////// VPSPRITE
///
///
///
-
-void ViewportSprite::edit_set_pivot(const Point2& p_pivot) {
+void ViewportSprite::edit_set_pivot(const Point2 &p_pivot) {
set_offset(p_pivot);
}
@@ -394,7 +379,7 @@ bool ViewportSprite::edit_has_pivot() const {
void ViewportSprite::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -402,12 +387,12 @@ void ViewportSprite::_notification(int p_what) {
Node *n = get_node(viewport_path);
ERR_FAIL_COND(!n);
- Viewport *vp=n->cast_to<Viewport>();
+ Viewport *vp = n->cast_to<Viewport>();
ERR_FAIL_COND(!vp);
Ref<RenderTargetTexture> rtt = vp->get_render_target_texture();
- texture=rtt;
- texture->connect("changed",this,"update");
+ texture = rtt;
+ texture->connect("changed", this, "update");
item_rect_changed();
}
} break;
@@ -415,8 +400,8 @@ void ViewportSprite::_notification(int p_what) {
if (texture.is_valid()) {
- texture->disconnect("changed",this,"update");
- texture=Ref<Texture>();
+ texture->disconnect("changed", this, "update");
+ texture = Ref<Texture>();
}
} break;
case NOTIFICATION_DRAW: {
@@ -436,52 +421,50 @@ void ViewportSprite::_notification(int p_what) {
s = texture->get_size();
- src_rect.size=s;
+ src_rect.size = s;
- Point2 ofs=offset;
+ Point2 ofs = offset;
if (centered)
- ofs-=s/2;
+ ofs -= s / 2;
if (OS::get_singleton()->get_use_pixel_snap()) {
- ofs=ofs.floor();
+ ofs = ofs.floor();
}
- Rect2 dst_rect(ofs,s);
- texture->draw_rect_region(ci,dst_rect,src_rect,modulate);
+ Rect2 dst_rect(ofs, s);
+ texture->draw_rect_region(ci, dst_rect, src_rect, modulate);
} break;
}
}
-void ViewportSprite::set_viewport_path(const NodePath& p_viewport) {
+void ViewportSprite::set_viewport_path(const NodePath &p_viewport) {
- viewport_path=p_viewport;
+ viewport_path = p_viewport;
update();
if (!is_inside_tree())
return;
if (texture.is_valid()) {
- texture->disconnect("changed",this,"update");
- texture=Ref<Texture>();
+ texture->disconnect("changed", this, "update");
+ texture = Ref<Texture>();
}
if (viewport_path.is_empty())
return;
-
Node *n = get_node(viewport_path);
ERR_FAIL_COND(!n);
- Viewport *vp=n->cast_to<Viewport>();
+ Viewport *vp = n->cast_to<Viewport>();
ERR_FAIL_COND(!vp);
Ref<RenderTargetTexture> rtt = vp->get_render_target_texture();
- texture=rtt;
+ texture = rtt;
if (texture.is_valid()) {
- texture->connect("changed",this,"update");
+ texture->connect("changed", this, "update");
}
item_rect_changed();
-
}
NodePath ViewportSprite::get_viewport_path() const {
@@ -491,7 +474,7 @@ NodePath ViewportSprite::get_viewport_path() const {
void ViewportSprite::set_centered(bool p_center) {
- centered=p_center;
+ centered = p_center;
update();
item_rect_changed();
}
@@ -501,9 +484,9 @@ bool ViewportSprite::is_centered() const {
return centered;
}
-void ViewportSprite::set_offset(const Point2& p_offset) {
+void ViewportSprite::set_offset(const Point2 &p_offset) {
- offset=p_offset;
+ offset = p_offset;
update();
item_rect_changed();
}
@@ -511,36 +494,35 @@ Point2 ViewportSprite::get_offset() const {
return offset;
}
-void ViewportSprite::set_modulate(const Color& p_color) {
+void ViewportSprite::set_modulate(const Color &p_color) {
- modulate=p_color;
+ modulate = p_color;
update();
}
-Color ViewportSprite::get_modulate() const{
+Color ViewportSprite::get_modulate() const {
return modulate;
}
-
Rect2 ViewportSprite::get_item_rect() const {
if (texture.is_null())
- return Rect2(0,0,1,1);
+ return Rect2(0, 0, 1, 1);
//if (texture.is_null())
// return CanvasItem::get_item_rect();
Size2i s;
s = texture->get_size();
- Point2 ofs=offset;
+ Point2 ofs = offset;
if (centered)
- ofs-=s/2;
+ ofs -= s / 2;
- if (s==Size2(0,0))
- s=Size2(1,1);
+ if (s == Size2(0, 0))
+ s = Size2(1, 1);
- return Rect2(ofs,s);
+ return Rect2(ofs, s);
}
String ViewportSprite::get_configuration_warning() const {
@@ -560,32 +542,30 @@ String ViewportSprite::get_configuration_warning() const {
}
return String();
-
}
void ViewportSprite::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_viewport_path","path"),&ViewportSprite::set_viewport_path);
- ObjectTypeDB::bind_method(_MD("get_viewport_path"),&ViewportSprite::get_viewport_path);
-
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&ViewportSprite::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&ViewportSprite::is_centered);
+ ObjectTypeDB::bind_method(_MD("set_viewport_path", "path"), &ViewportSprite::set_viewport_path);
+ ObjectTypeDB::bind_method(_MD("get_viewport_path"), &ViewportSprite::get_viewport_path);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&ViewportSprite::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&ViewportSprite::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_centered", "centered"), &ViewportSprite::set_centered);
+ ObjectTypeDB::bind_method(_MD("is_centered"), &ViewportSprite::is_centered);
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&ViewportSprite::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&ViewportSprite::get_modulate);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &ViewportSprite::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &ViewportSprite::get_offset);
- ADD_PROPERTYNZ( PropertyInfo( Variant::NODE_PATH, "viewport"), _SCS("set_viewport_path"),_SCS("get_viewport_path"));
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
+ ObjectTypeDB::bind_method(_MD("set_modulate", "modulate"), &ViewportSprite::set_modulate);
+ ObjectTypeDB::bind_method(_MD("get_modulate"), &ViewportSprite::get_modulate);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::NODE_PATH, "viewport"), _SCS("set_viewport_path"), _SCS("get_viewport_path"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "centered"), _SCS("set_centered"), _SCS("is_centered"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
}
ViewportSprite::ViewportSprite() {
- centered=true;
- modulate=Color(1,1,1,1);
+ centered = true;
+ modulate = Color(1, 1, 1, 1);
}
diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h
index 95e4ff122..26b9b3406 100644
--- a/scene/2d/sprite.h
+++ b/scene/2d/sprite.h
@@ -32,10 +32,9 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/texture.h"
-
class Sprite : public Node2D {
- OBJ_TYPE( Sprite, Node2D );
+ OBJ_TYPE(Sprite, Node2D);
Ref<Texture> texture;
@@ -54,28 +53,25 @@ class Sprite : public Node2D {
Color modulate;
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
- virtual void _validate_property(PropertyInfo& property) const;
+ virtual void _validate_property(PropertyInfo &property) const;
public:
-
- virtual void edit_set_pivot(const Point2& p_pivot);
+ virtual void edit_set_pivot(const Point2 &p_pivot);
virtual Point2 edit_get_pivot() const;
virtual bool edit_has_pivot() const;
- void set_texture(const Ref<Texture>& p_texture);
+ void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
void set_centered(bool p_center);
bool is_centered() const;
- void set_offset(const Point2& p_offset);
+ void set_offset(const Point2 &p_offset);
Point2 get_offset() const;
void set_flip_h(bool p_flip);
@@ -87,7 +83,7 @@ public:
void set_region(bool p_region);
bool is_region() const;
- void set_region_rect(const Rect2& p_region_rect);
+ void set_region_rect(const Rect2 &p_region_rect);
Rect2 get_region_rect() const;
void set_frame(int p_frame);
@@ -99,7 +95,7 @@ public:
void set_hframes(int p_amount);
int get_hframes() const;
- void set_modulate(const Color& p_color);
+ void set_modulate(const Color &p_color);
Color get_modulate() const;
virtual Rect2 get_item_rect() const;
@@ -109,7 +105,7 @@ public:
class ViewportSprite : public Node2D {
- OBJ_TYPE( ViewportSprite, Node2D );
+ OBJ_TYPE(ViewportSprite, Node2D);
Ref<Texture> texture;
NodePath viewport_path;
@@ -119,27 +115,25 @@ class ViewportSprite : public Node2D {
Color modulate;
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
- virtual void edit_set_pivot(const Point2& p_pivot);
+ virtual void edit_set_pivot(const Point2 &p_pivot);
virtual Point2 edit_get_pivot() const;
virtual bool edit_has_pivot() const;
- void set_viewport_path(const NodePath& p_viewport);
+ void set_viewport_path(const NodePath &p_viewport);
NodePath get_viewport_path() const;
void set_centered(bool p_center);
bool is_centered() const;
- void set_offset(const Point2& p_offset);
+ void set_offset(const Point2 &p_offset);
Point2 get_offset() const;
- void set_modulate(const Color& p_color);
+ void set_modulate(const Color &p_color);
Color get_modulate() const;
virtual Rect2 get_item_rect() const;
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 297605a9c..f8edbc3ab 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -28,11 +28,9 @@
/*************************************************************************/
#include "tile_map.h"
#include "io/marshalls.h"
-#include "servers/physics_2d_server.h"
#include "method_bind_ext.inc"
#include "os/os.h"
-
-
+#include "servers/physics_2d_server.h"
int TileMap::_get_quadrant_size() const {
@@ -44,51 +42,49 @@ int TileMap::_get_quadrant_size() const {
void TileMap::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- Node2D *c=this;
- while(c) {
+ Node2D *c = this;
+ while (c) {
- navigation=c->cast_to<Navigation2D>();
+ navigation = c->cast_to<Navigation2D>();
if (navigation) {
break;
}
- c=c->get_parent()->cast_to<Node2D>();
+ c = c->get_parent()->cast_to<Node2D>();
}
- pending_update=true;
+ pending_update = true;
_update_dirty_quadrants();
RID space = get_world_2d()->get_space();
_update_quadrant_transform();
_update_quadrant_space(space);
-
} break;
case NOTIFICATION_EXIT_TREE: {
_update_quadrant_space(RID());
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q=E->get();
+ Quadrant &q = E->get();
if (navigation) {
- for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
navigation->navpoly_remove(E->get().id);
}
q.navpoly_ids.clear();
}
- for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) {
VS::get_singleton()->free(E->get().id);
}
q.occluder_instances.clear();
}
- navigation=NULL;
-
+ navigation = NULL;
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -100,12 +96,12 @@ void TileMap::_notification(int p_what) {
}
}
-void TileMap::_update_quadrant_space(const RID& p_space) {
+void TileMap::_update_quadrant_space(const RID &p_space) {
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q=E->get();
- Physics2DServer::get_singleton()->body_set_space(q.body,p_space);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_space(q.body, p_space);
}
}
@@ -120,43 +116,42 @@ void TileMap::_update_quadrant_transform() {
if (navigation)
nav_rel = get_relative_transform_to_parent(navigation);
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q=E->get();
+ Quadrant &q = E->get();
Matrix32 xform;
- xform.set_origin( q.pos );
+ xform.set_origin(q.pos);
xform = global_transform * xform;
- Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform);
+ Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
if (navigation) {
- for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
- navigation->navpoly_set_transform(E->get().id,nav_rel * E->get().xform);
+ navigation->navpoly_set_transform(E->get().id, nav_rel * E->get().xform);
}
}
- for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) {
- VS::get_singleton()->canvas_light_occluder_set_transform(E->get().id,global_transform * E->get().xform);
+ for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) {
+ VS::get_singleton()->canvas_light_occluder_set_transform(E->get().id, global_transform * E->get().xform);
}
}
}
-void TileMap::set_tileset(const Ref<TileSet>& p_tileset) {
+void TileMap::set_tileset(const Ref<TileSet> &p_tileset) {
if (tile_set.is_valid())
- tile_set->disconnect("changed",this,"_recreate_quadrants");
+ tile_set->disconnect("changed", this, "_recreate_quadrants");
_clear_quadrants();
- tile_set=p_tileset;
+ tile_set = p_tileset;
if (tile_set.is_valid())
- tile_set->connect("changed",this,"_recreate_quadrants");
+ tile_set->connect("changed", this, "_recreate_quadrants");
else
clear();
_recreate_quadrants();
emit_signal("settings_changed");
-
}
Ref<TileSet> TileMap::get_tileset() const {
@@ -166,14 +161,12 @@ Ref<TileSet> TileMap::get_tileset() const {
void TileMap::set_cell_size(Size2 p_size) {
- ERR_FAIL_COND(p_size.x<1 || p_size.y<1);
+ ERR_FAIL_COND(p_size.x < 1 || p_size.y < 1);
_clear_quadrants();
- cell_size=p_size;
+ cell_size = p_size;
_recreate_quadrants();
emit_signal("settings_changed");
-
-
}
Size2 TileMap::get_cell_size() const {
@@ -181,13 +174,12 @@ Size2 TileMap::get_cell_size() const {
}
void TileMap::set_quadrant_size(int p_size) {
- ERR_FAIL_COND(p_size<1);
+ ERR_FAIL_COND(p_size < 1);
_clear_quadrants();
- quadrant_size=p_size;
+ quadrant_size = p_size;
_recreate_quadrants();
emit_signal("settings_changed");
-
}
int TileMap::get_quadrant_size() const {
@@ -196,11 +188,9 @@ int TileMap::get_quadrant_size() const {
void TileMap::set_center_x(bool p_enable) {
- center_x=p_enable;
+ center_x = p_enable;
_recreate_quadrants();
emit_signal("settings_changed");
-
-
}
bool TileMap::get_center_x() const {
@@ -208,24 +198,22 @@ bool TileMap::get_center_x() const {
}
void TileMap::set_center_y(bool p_enable) {
- center_y=p_enable;
+ center_y = p_enable;
_recreate_quadrants();
emit_signal("settings_changed");
-
}
bool TileMap::get_center_y() const {
return center_y;
}
-void TileMap::_fix_cell_transform(Matrix32& xform,const Cell& p_cell, const Vector2& p_offset, const Size2 &p_sc) {
+void TileMap::_fix_cell_transform(Matrix32 &xform, const Cell &p_cell, const Vector2 &p_offset, const Size2 &p_sc) {
- Size2 s=p_sc;
+ Size2 s = p_sc;
Vector2 offset = p_offset;
-
- if (tile_origin==TILE_ORIGIN_BOTTOM_LEFT)
- offset.y+=cell_size.y;
+ if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT)
+ offset.y += cell_size.y;
if (s.y > s.x) {
if ((p_cell.flip_h && (p_cell.flip_v || p_cell.transpose)) || (p_cell.flip_v && !p_cell.transpose))
@@ -242,26 +230,25 @@ void TileMap::_fix_cell_transform(Matrix32& xform,const Cell& p_cell, const Vect
SWAP(s.x, s.y);
}
if (p_cell.flip_h) {
- xform.elements[0].x=-xform.elements[0].x;
- xform.elements[1].x=-xform.elements[1].x;
- if (tile_origin==TILE_ORIGIN_TOP_LEFT || tile_origin==TILE_ORIGIN_BOTTOM_LEFT)
- offset.x=s.x-offset.x;
+ xform.elements[0].x = -xform.elements[0].x;
+ xform.elements[1].x = -xform.elements[1].x;
+ if (tile_origin == TILE_ORIGIN_TOP_LEFT || tile_origin == TILE_ORIGIN_BOTTOM_LEFT)
+ offset.x = s.x - offset.x;
}
if (p_cell.flip_v) {
- xform.elements[0].y=-xform.elements[0].y;
- xform.elements[1].y=-xform.elements[1].y;
- if (tile_origin==TILE_ORIGIN_TOP_LEFT)
- offset.y=s.y-offset.y;
- else if (tile_origin==TILE_ORIGIN_BOTTOM_LEFT) {
- if(p_cell.transpose)
- offset.y+=s.y;
+ xform.elements[0].y = -xform.elements[0].y;
+ xform.elements[1].y = -xform.elements[1].y;
+ if (tile_origin == TILE_ORIGIN_TOP_LEFT)
+ offset.y = s.y - offset.y;
+ else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
+ if (p_cell.transpose)
+ offset.y += s.y;
else
- offset.y-=s.y;
+ offset.y -= s.y;
}
}
- xform.elements[2].x+=offset.x;
- xform.elements[2].y+=offset.y;
-
+ xform.elements[2].x += offset.x;
+ xform.elements[2].y += offset.y;
}
void TileMap::_update_dirty_quadrants() {
@@ -276,26 +263,26 @@ void TileMap::_update_dirty_quadrants() {
VisualServer *vs = VisualServer::get_singleton();
Physics2DServer *ps = Physics2DServer::get_singleton();
Vector2 tofs = get_cell_draw_offset();
- Vector2 tcenter = cell_size/2;
+ Vector2 tcenter = cell_size / 2;
Matrix32 nav_rel;
if (navigation)
nav_rel = get_relative_transform_to_parent(navigation);
Vector2 qofs;
- SceneTree *st=SceneTree::get_singleton();
+ SceneTree *st = SceneTree::get_singleton();
Color debug_collision_color;
bool debug_shapes = st && st->is_debugging_collisions_hint();
if (debug_shapes) {
- debug_collision_color=st->get_debug_collisions_color();
+ debug_collision_color = st->get_debug_collisions_color();
}
while (dirty_quadrant_list.first()) {
Quadrant &q = *dirty_quadrant_list.first()->self();
- for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) {
+ for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
vs->free(E->get());
}
@@ -303,17 +290,17 @@ void TileMap::_update_dirty_quadrants() {
q.canvas_items.clear();
ps->body_clear_shapes(q.body);
- int shape_idx=0;
+ int shape_idx = 0;
if (navigation) {
- for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
navigation->navpoly_remove(E->get().id);
}
q.navpoly_ids.clear();
}
- for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) {
VS::get_singleton()->free(E->get().id);
}
q.occluder_instances.clear();
@@ -321,10 +308,10 @@ void TileMap::_update_dirty_quadrants() {
RID prev_canvas_item;
RID prev_debug_canvas_item;
- for(int i=0;i<q.cells.size();i++) {
+ for (int i = 0; i < q.cells.size(); i++) {
- Map<PosKey,Cell>::Element *E=tile_map.find( q.cells[i] );
- Cell &c=E->get();
+ Map<PosKey, Cell>::Element *E = tile_map.find(q.cells[i]);
+ Cell &c = E->get();
//moment of truth
if (!tile_set->has_tile(c.id))
continue;
@@ -342,57 +329,55 @@ void TileMap::_update_dirty_quadrants() {
RID canvas_item;
RID debug_canvas_item;
- if (prev_canvas_item==RID() || prev_material!=mat) {
+ if (prev_canvas_item == RID() || prev_material != mat) {
- canvas_item=vs->canvas_item_create();
+ canvas_item = vs->canvas_item_create();
if (mat.is_valid())
- vs->canvas_item_set_material(canvas_item,mat->get_rid());
- vs->canvas_item_set_parent( canvas_item, get_canvas_item() );
+ vs->canvas_item_set_material(canvas_item, mat->get_rid());
+ vs->canvas_item_set_parent(canvas_item, get_canvas_item());
Matrix32 xform;
- xform.set_origin( q.pos );
- vs->canvas_item_set_transform( canvas_item, xform );
- vs->canvas_item_set_light_mask(canvas_item,get_light_mask());
+ xform.set_origin(q.pos);
+ vs->canvas_item_set_transform(canvas_item, xform);
+ vs->canvas_item_set_light_mask(canvas_item, get_light_mask());
q.canvas_items.push_back(canvas_item);
if (debug_shapes) {
- debug_canvas_item=vs->canvas_item_create();
- vs->canvas_item_set_parent( debug_canvas_item, canvas_item );
- vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item,false);
- vs->canvas_item_set_z(debug_canvas_item,VS::CANVAS_ITEM_Z_MAX-1);
+ debug_canvas_item = vs->canvas_item_create();
+ vs->canvas_item_set_parent(debug_canvas_item, canvas_item);
+ vs->canvas_item_set_z_as_relative_to_parent(debug_canvas_item, false);
+ vs->canvas_item_set_z(debug_canvas_item, VS::CANVAS_ITEM_Z_MAX - 1);
q.canvas_items.push_back(debug_canvas_item);
- prev_debug_canvas_item=debug_canvas_item;
+ prev_debug_canvas_item = debug_canvas_item;
}
- prev_canvas_item=canvas_item;
- prev_material=mat;
+ prev_canvas_item = canvas_item;
+ prev_material = mat;
} else {
- canvas_item=prev_canvas_item;
+ canvas_item = prev_canvas_item;
if (debug_shapes) {
- debug_canvas_item=prev_debug_canvas_item;
+ debug_canvas_item = prev_debug_canvas_item;
}
}
-
-
Rect2 r = tile_set->tile_get_region(c.id);
Size2 s = tex->get_size();
- if (r==Rect2())
+ if (r == Rect2())
s = tex->get_size();
else {
s = r.size;
- r.pos.x+=fp_adjust;
- r.pos.y+=fp_adjust;
- r.size.x-=fp_adjust*2.0;
- r.size.y-=fp_adjust*2.0;
+ r.pos.x += fp_adjust;
+ r.pos.y += fp_adjust;
+ r.size.x -= fp_adjust * 2.0;
+ r.size.y -= fp_adjust * 2.0;
}
Rect2 rect;
- rect.pos=offset.floor();
- rect.size=s;
+ rect.pos = offset.floor();
+ rect.size = s;
if (rect.size.y > rect.size.x) {
if ((c.flip_h && (c.flip_v || c.transpose)) || (c.flip_v && !c.transpose))
@@ -402,72 +387,69 @@ void TileMap::_update_dirty_quadrants() {
tile_ofs.x += rect.size.x - rect.size.y;
}
- /* rect.size.x+=fp_adjust;
+ /* rect.size.x+=fp_adjust;
rect.size.y+=fp_adjust;*/
if (c.transpose)
SWAP(tile_ofs.x, tile_ofs.y);
if (c.flip_h) {
- rect.size.x=-rect.size.x;
- tile_ofs.x=-tile_ofs.x;
+ rect.size.x = -rect.size.x;
+ tile_ofs.x = -tile_ofs.x;
}
if (c.flip_v) {
- rect.size.y=-rect.size.y;
- tile_ofs.y=-tile_ofs.y;
+ rect.size.y = -rect.size.y;
+ tile_ofs.y = -tile_ofs.y;
}
Vector2 center_ofs;
- if (tile_origin==TILE_ORIGIN_TOP_LEFT) {
- rect.pos+=tile_ofs;
-
- } else if (tile_origin==TILE_ORIGIN_BOTTOM_LEFT) {
-
- rect.pos+=tile_ofs;
-
- if(c.transpose)
- {
- if(c.flip_h)
- rect.pos.x-=cell_size.x;
+ if (tile_origin == TILE_ORIGIN_TOP_LEFT) {
+ rect.pos += tile_ofs;
+
+ } else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT) {
+
+ rect.pos += tile_ofs;
+
+ if (c.transpose) {
+ if (c.flip_h)
+ rect.pos.x -= cell_size.x;
else
- rect.pos.x+=cell_size.x;
+ rect.pos.x += cell_size.x;
} else {
- if(c.flip_v)
- rect.pos.y-=cell_size.y;
+ if (c.flip_v)
+ rect.pos.y -= cell_size.y;
else
- rect.pos.y+=cell_size.y;
+ rect.pos.y += cell_size.y;
}
-
- } else if (tile_origin==TILE_ORIGIN_CENTER) {
- rect.pos+=tcenter;
- Vector2 center = (s/2) - tile_ofs;
- center_ofs=tcenter-(s/2);
+ } else if (tile_origin == TILE_ORIGIN_CENTER) {
+ rect.pos += tcenter;
+
+ Vector2 center = (s / 2) - tile_ofs;
+ center_ofs = tcenter - (s / 2);
if (c.flip_h)
- rect.pos.x-=s.x-center.x;
+ rect.pos.x -= s.x - center.x;
else
- rect.pos.x-=center.x;
+ rect.pos.x -= center.x;
if (c.flip_v)
- rect.pos.y-=s.y-center.y;
+ rect.pos.y -= s.y - center.y;
else
- rect.pos.y-=center.y;
+ rect.pos.y -= center.y;
}
-
Color modulate = tile_set->tile_get_modulate(c.id);
- if (r==Rect2()) {
- tex->draw_rect(canvas_item,rect,false,modulate,c.transpose);
+ if (r == Rect2()) {
+ tex->draw_rect(canvas_item, rect, false, modulate, c.transpose);
} else {
- tex->draw_rect_region(canvas_item,rect,r,modulate,c.transpose);
+ tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose);
}
- Vector< Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id);
-
+ Vector<Ref<Shape2D> > shapes = tile_set->tile_get_shapes(c.id);
- for(int i=0;i<shapes.size();i++) {
+ for (int i = 0; i < shapes.size(); i++) {
Ref<Shape2D> shape = shapes[i];
if (shape.is_valid()) {
@@ -476,21 +458,19 @@ void TileMap::_update_dirty_quadrants() {
Matrix32 xform;
xform.set_origin(offset.floor());
- _fix_cell_transform(xform,c,shape_ofs+center_ofs,s);
+ _fix_cell_transform(xform, c, shape_ofs + center_ofs, s);
if (debug_canvas_item) {
- vs->canvas_item_add_set_transform(debug_canvas_item,xform);
- shape->draw(debug_canvas_item,debug_collision_color);
-
+ vs->canvas_item_add_set_transform(debug_canvas_item, xform);
+ shape->draw(debug_canvas_item, debug_collision_color);
}
- ps->body_add_shape(q.body,shape->get_rid(),xform);
- ps->body_set_shape_metadata(q.body,shape_idx++,Vector2(E->key().x,E->key().y));
-
+ ps->body_add_shape(q.body, shape->get_rid(), xform);
+ ps->body_set_shape_metadata(q.body, shape_idx++, Vector2(E->key().x, E->key().y));
}
}
if (debug_canvas_item) {
- vs->canvas_item_add_set_transform(debug_canvas_item,Matrix32());
+ vs->canvas_item_add_set_transform(debug_canvas_item, Matrix32());
}
if (navigation) {
@@ -498,152 +478,141 @@ void TileMap::_update_dirty_quadrants() {
if (navpoly.is_valid()) {
Vector2 npoly_ofs = tile_set->tile_get_navigation_polygon_offset(c.id);
Matrix32 xform;
- xform.set_origin(offset.floor()+q.pos);
- _fix_cell_transform(xform,c,npoly_ofs+center_ofs,s);
+ xform.set_origin(offset.floor() + q.pos);
+ _fix_cell_transform(xform, c, npoly_ofs + center_ofs, s);
-
- int pid = navigation->navpoly_create(navpoly,nav_rel * xform);
+ int pid = navigation->navpoly_create(navpoly, nav_rel * xform);
Quadrant::NavPoly np;
- np.id=pid;
- np.xform=xform;
- q.navpoly_ids[E->key()]=np;
+ np.id = pid;
+ np.xform = xform;
+ q.navpoly_ids[E->key()] = np;
}
}
-
- Ref<OccluderPolygon2D> occluder=tile_set->tile_get_light_occluder(c.id);
+ Ref<OccluderPolygon2D> occluder = tile_set->tile_get_light_occluder(c.id);
if (occluder.is_valid()) {
Vector2 occluder_ofs = tile_set->tile_get_occluder_offset(c.id);
Matrix32 xform;
- xform.set_origin(offset.floor()+q.pos);
- _fix_cell_transform(xform,c,occluder_ofs+center_ofs,s);
+ xform.set_origin(offset.floor() + q.pos);
+ _fix_cell_transform(xform, c, occluder_ofs + center_ofs, s);
RID orid = VS::get_singleton()->canvas_light_occluder_create();
- VS::get_singleton()->canvas_light_occluder_set_transform(orid,get_global_transform() * xform);
- VS::get_singleton()->canvas_light_occluder_set_polygon(orid,occluder->get_rid());
- VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid,get_canvas());
- VS::get_singleton()->canvas_light_occluder_set_light_mask(orid,occluder_light_mask);
+ VS::get_singleton()->canvas_light_occluder_set_transform(orid, get_global_transform() * xform);
+ VS::get_singleton()->canvas_light_occluder_set_polygon(orid, occluder->get_rid());
+ VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid, get_canvas());
+ VS::get_singleton()->canvas_light_occluder_set_light_mask(orid, occluder_light_mask);
Quadrant::Occluder oc;
- oc.xform=xform;
- oc.id=orid;
- q.occluder_instances[E->key()]=oc;
+ oc.xform = xform;
+ oc.id = orid;
+ q.occluder_instances[E->key()] = oc;
}
}
- dirty_quadrant_list.remove( dirty_quadrant_list.first() );
- quadrant_order_dirty=true;
+ dirty_quadrant_list.remove(dirty_quadrant_list.first());
+ quadrant_order_dirty = true;
}
-
-
- pending_update=false;
+ pending_update = false;
if (quadrant_order_dirty) {
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q=E->get();
- for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) {
+ Quadrant &q = E->get();
+ for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
VS::get_singleton()->canvas_item_raise(E->get());
}
}
- quadrant_order_dirty=false;
+ quadrant_order_dirty = false;
}
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
+ CanvasItem *c = get_child(i)->cast_to<CanvasItem>();
if (c)
VS::get_singleton()->canvas_item_raise(c->get_canvas_item());
}
_recompute_rect_cache();
-
}
void TileMap::_recompute_rect_cache() {
-
#ifdef DEBUG_ENABLED
if (!rect_cache_dirty)
return;
Rect2 r_total;
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
-
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
Rect2 r;
- r.pos=_map_to_world(E->key().x*_get_quadrant_size(), E->key().y*_get_quadrant_size());
- r.expand_to( _map_to_world(E->key().x*_get_quadrant_size()+_get_quadrant_size(), E->key().y*_get_quadrant_size()) );
- r.expand_to( _map_to_world(E->key().x*_get_quadrant_size()+_get_quadrant_size(), E->key().y*_get_quadrant_size()+_get_quadrant_size()) );
- r.expand_to( _map_to_world(E->key().x*_get_quadrant_size(), E->key().y*_get_quadrant_size()+_get_quadrant_size()) );
- if (E==quadrant_map.front())
- r_total=r;
+ r.pos = _map_to_world(E->key().x * _get_quadrant_size(), E->key().y * _get_quadrant_size());
+ r.expand_to(_map_to_world(E->key().x * _get_quadrant_size() + _get_quadrant_size(), E->key().y * _get_quadrant_size()));
+ r.expand_to(_map_to_world(E->key().x * _get_quadrant_size() + _get_quadrant_size(), E->key().y * _get_quadrant_size() + _get_quadrant_size()));
+ r.expand_to(_map_to_world(E->key().x * _get_quadrant_size(), E->key().y * _get_quadrant_size() + _get_quadrant_size()));
+ if (E == quadrant_map.front())
+ r_total = r;
else
- r_total=r_total.merge(r);
-
+ r_total = r_total.merge(r);
}
- if (r_total==Rect2()) {
- rect_cache=Rect2(-10,-10,20,20);
+ if (r_total == Rect2()) {
+ rect_cache = Rect2(-10, -10, 20, 20);
} else {
- rect_cache=r_total.grow(MAX(cell_size.x,cell_size.y)*_get_quadrant_size());
+ rect_cache = r_total.grow(MAX(cell_size.x, cell_size.y) * _get_quadrant_size());
}
item_rect_changed();
- rect_cache_dirty=false;
+ rect_cache_dirty = false;
#endif
-
-
}
-Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const PosKey& p_qk) {
+Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(const PosKey &p_qk) {
Matrix32 xform;
//xform.set_origin(Point2(p_qk.x,p_qk.y)*cell_size*quadrant_size);
Quadrant q;
- q.pos = _map_to_world(p_qk.x*_get_quadrant_size(),p_qk.y*_get_quadrant_size());
- q.pos+=get_cell_draw_offset();
- if (tile_origin==TILE_ORIGIN_CENTER)
- q.pos+=cell_size/2;
- else if (tile_origin==TILE_ORIGIN_BOTTOM_LEFT)
- q.pos.y+=cell_size.y;
-
+ q.pos = _map_to_world(p_qk.x * _get_quadrant_size(), p_qk.y * _get_quadrant_size());
+ q.pos += get_cell_draw_offset();
+ if (tile_origin == TILE_ORIGIN_CENTER)
+ q.pos += cell_size / 2;
+ else if (tile_origin == TILE_ORIGIN_BOTTOM_LEFT)
+ q.pos.y += cell_size.y;
- xform.set_origin( q.pos );
-// q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
- q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC);
- Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID());
- Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
- Physics2DServer::get_singleton()->body_set_collision_mask(q.body,collision_mask);
- Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_FRICTION,friction);
- Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_BOUNCE,bounce);
+ xform.set_origin(q.pos);
+ // q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
+ q.body = Physics2DServer::get_singleton()->body_create(use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
+ Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body, get_instance_ID());
+ Physics2DServer::get_singleton()->body_set_layer_mask(q.body, collision_layer);
+ Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, friction);
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, bounce);
if (is_inside_tree()) {
xform = get_global_transform() * xform;
RID space = get_world_2d()->get_space();
- Physics2DServer::get_singleton()->body_set_space(q.body,space);
+ Physics2DServer::get_singleton()->body_set_space(q.body, space);
}
- Physics2DServer::get_singleton()->body_set_state(q.body,Physics2DServer::BODY_STATE_TRANSFORM,xform);
+ Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
- rect_cache_dirty=true;
- quadrant_order_dirty=true;
- return quadrant_map.insert(p_qk,q);
+ rect_cache_dirty = true;
+ quadrant_order_dirty = true;
+ return quadrant_map.insert(p_qk, q);
}
-void TileMap::_erase_quadrant(Map<PosKey,Quadrant>::Element *Q) {
+void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
- Quadrant &q=Q->get();
+ Quadrant &q = Q->get();
Physics2DServer::get_singleton()->free(q.body);
- for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) {
+ for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
VisualServer::get_singleton()->free(E->get());
}
@@ -652,58 +621,58 @@ void TileMap::_erase_quadrant(Map<PosKey,Quadrant>::Element *Q) {
dirty_quadrant_list.remove(&q.dirty_list);
if (navigation) {
- for(Map<PosKey,Quadrant::NavPoly>::Element *E=q.navpoly_ids.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant::NavPoly>::Element *E = q.navpoly_ids.front(); E; E = E->next()) {
navigation->navpoly_remove(E->get().id);
}
q.navpoly_ids.clear();
}
- for(Map<PosKey,Quadrant::Occluder>::Element *E=q.occluder_instances.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant::Occluder>::Element *E = q.occluder_instances.front(); E; E = E->next()) {
VS::get_singleton()->free(E->get().id);
}
q.occluder_instances.clear();
quadrant_map.erase(Q);
- rect_cache_dirty=true;
+ rect_cache_dirty = true;
}
-void TileMap::_make_quadrant_dirty(Map<PosKey,Quadrant>::Element *Q) {
+void TileMap::_make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q) {
- Quadrant &q=Q->get();
+ Quadrant &q = Q->get();
if (!q.dirty_list.in_list())
dirty_quadrant_list.add(&q.dirty_list);
if (pending_update)
return;
- pending_update=true;
+ pending_update = true;
if (!is_inside_tree())
return;
call_deferred("_update_dirty_quadrants");
}
-void TileMap::set_cellv(const Vector2& p_pos,int p_tile,bool p_flip_x,bool p_flip_y,bool p_transpose) {
+void TileMap::set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose) {
- set_cell(p_pos.x,p_pos.y,p_tile,p_flip_x,p_flip_y,p_transpose);
+ set_cell(p_pos.x, p_pos.y, p_tile, p_flip_x, p_flip_y, p_transpose);
}
-void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y,bool p_transpose) {
+void TileMap::set_cell(int p_x, int p_y, int p_tile, bool p_flip_x, bool p_flip_y, bool p_transpose) {
- PosKey pk(p_x,p_y);
+ PosKey pk(p_x, p_y);
- Map<PosKey,Cell>::Element *E=tile_map.find(pk);
- if (!E && p_tile==INVALID_CELL)
+ Map<PosKey, Cell>::Element *E = tile_map.find(pk);
+ if (!E && p_tile == INVALID_CELL)
return; //nothing to do
- PosKey qk(p_x/_get_quadrant_size(),p_y/_get_quadrant_size());
- if (p_tile==INVALID_CELL) {
+ PosKey qk(p_x / _get_quadrant_size(), p_y / _get_quadrant_size());
+ if (p_tile == INVALID_CELL) {
//erase existing
tile_map.erase(pk);
- Map<PosKey,Quadrant>::Element *Q = quadrant_map.find(qk);
+ Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
ERR_FAIL_COND(!Q);
- Quadrant &q=Q->get();
+ Quadrant &q = Q->get();
q.cells.erase(pk);
- if (q.cells.size()==0)
+ if (q.cells.size() == 0)
_erase_quadrant(Q);
else
_make_quadrant_dirty(Q);
@@ -711,79 +680,75 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y,bo
return;
}
- Map<PosKey,Quadrant>::Element *Q = quadrant_map.find(qk);
+ Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
if (!E) {
- E=tile_map.insert(pk,Cell());
+ E = tile_map.insert(pk, Cell());
if (!Q) {
- Q=_create_quadrant(qk);
+ Q = _create_quadrant(qk);
}
- Quadrant &q=Q->get();
+ Quadrant &q = Q->get();
q.cells.insert(pk);
} else {
ERR_FAIL_COND(!Q); // quadrant should exist...
- if (E->get().id==p_tile && E->get().flip_h==p_flip_x && E->get().flip_v==p_flip_y && E->get().transpose==p_transpose)
+ if (E->get().id == p_tile && E->get().flip_h == p_flip_x && E->get().flip_v == p_flip_y && E->get().transpose == p_transpose)
return; //nothing changed
-
}
-
Cell &c = E->get();
- c.id=p_tile;
- c.flip_h=p_flip_x;
- c.flip_v=p_flip_y;
- c.transpose=p_transpose;
+ c.id = p_tile;
+ c.flip_h = p_flip_x;
+ c.flip_v = p_flip_y;
+ c.transpose = p_transpose;
_make_quadrant_dirty(Q);
- used_size_cache_dirty=true;
-
+ used_size_cache_dirty = true;
}
-int TileMap::get_cellv(const Vector2& p_pos) const {
- return get_cell(p_pos.x,p_pos.y);
+int TileMap::get_cellv(const Vector2 &p_pos) const {
+ return get_cell(p_pos.x, p_pos.y);
}
-int TileMap::get_cell(int p_x,int p_y) const {
+int TileMap::get_cell(int p_x, int p_y) const {
- PosKey pk(p_x,p_y);
+ PosKey pk(p_x, p_y);
- const Map<PosKey,Cell>::Element *E=tile_map.find(pk);
+ const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
if (!E)
return INVALID_CELL;
return E->get().id;
-
}
-bool TileMap::is_cell_x_flipped(int p_x,int p_y) const {
+bool TileMap::is_cell_x_flipped(int p_x, int p_y) const {
- PosKey pk(p_x,p_y);
+ PosKey pk(p_x, p_y);
- const Map<PosKey,Cell>::Element *E=tile_map.find(pk);
+ const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
if (!E)
return false;
return E->get().flip_h;
}
-bool TileMap::is_cell_y_flipped(int p_x,int p_y) const {
+bool TileMap::is_cell_y_flipped(int p_x, int p_y) const {
- PosKey pk(p_x,p_y);
+ PosKey pk(p_x, p_y);
- const Map<PosKey,Cell>::Element *E=tile_map.find(pk);
+ const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
if (!E)
return false;
return E->get().flip_v;
}
-bool TileMap::is_cell_transposed(int p_x,int p_y) const {
+bool TileMap::is_cell_transposed(int p_x, int p_y) const {
- PosKey pk(p_x,p_y);
+ PosKey pk(p_x, p_y);
- const Map<PosKey,Cell>::Element *E=tile_map.find(pk);
+ const Map<PosKey, Cell>::Element *E = tile_map.find(pk);
if (!E)
return false;
@@ -791,34 +756,29 @@ bool TileMap::is_cell_transposed(int p_x,int p_y) const {
return E->get().transpose;
}
-
void TileMap::_recreate_quadrants() {
_clear_quadrants();
- for (Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {
+ for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
- PosKey qk(E->key().x/_get_quadrant_size(),E->key().y/_get_quadrant_size());
+ PosKey qk(E->key().x / _get_quadrant_size(), E->key().y / _get_quadrant_size());
- Map<PosKey,Quadrant>::Element *Q=quadrant_map.find(qk);
+ Map<PosKey, Quadrant>::Element *Q = quadrant_map.find(qk);
if (!Q) {
- Q=_create_quadrant(qk);
+ Q = _create_quadrant(qk);
dirty_quadrant_list.add(&Q->get().dirty_list);
}
Q->get().cells.insert(E->key());
_make_quadrant_dirty(Q);
}
-
-
-
}
-
void TileMap::_clear_quadrants() {
while (quadrant_map.size()) {
- _erase_quadrant( quadrant_map.front() );
+ _erase_quadrant(quadrant_map.front());
}
}
@@ -826,105 +786,99 @@ void TileMap::clear() {
_clear_quadrants();
tile_map.clear();
- used_size_cache_dirty=true;
+ used_size_cache_dirty = true;
}
-void TileMap::_set_tile_data(const DVector<int>& p_data) {
+void TileMap::_set_tile_data(const DVector<int> &p_data) {
- int c=p_data.size();
+ int c = p_data.size();
DVector<int>::Read r = p_data.read();
+ for (int i = 0; i < c; i += 2) {
- for(int i=0;i<c;i+=2) {
-
- const uint8_t *ptr=(const uint8_t*)&r[i];
+ const uint8_t *ptr = (const uint8_t *)&r[i];
uint8_t local[8];
- for(int j=0;j<8;j++)
- local[j]=ptr[j];
+ for (int j = 0; j < 8; j++)
+ local[j] = ptr[j];
#ifdef BIG_ENDIAN_ENABLED
-
- SWAP(local[0],local[3]);
- SWAP(local[1],local[2]);
- SWAP(local[4],local[7]);
- SWAP(local[5],local[6]);
+ SWAP(local[0], local[3]);
+ SWAP(local[1], local[2]);
+ SWAP(local[4], local[7]);
+ SWAP(local[5], local[6]);
#endif
int16_t x = decode_uint16(&local[0]);
int16_t y = decode_uint16(&local[2]);
uint32_t v = decode_uint32(&local[4]);
- bool flip_h = v&(1<<29);
- bool flip_v = v&(1<<30);
- bool transpose = v&(1<<31);
- v&=(1<<29)-1;
-
-// if (x<-20 || y <-20 || x>4000 || y>4000)
-// continue;
- set_cell(x,y,v,flip_h,flip_v,transpose);
+ bool flip_h = v & (1 << 29);
+ bool flip_v = v & (1 << 30);
+ bool transpose = v & (1 << 31);
+ v &= (1 << 29) - 1;
+ // if (x<-20 || y <-20 || x>4000 || y>4000)
+ // continue;
+ set_cell(x, y, v, flip_h, flip_v, transpose);
}
-
}
DVector<int> TileMap::_get_tile_data() const {
DVector<int> data;
- data.resize(tile_map.size()*2);
+ data.resize(tile_map.size() * 2);
DVector<int>::Write w = data.write();
- int idx=0;
- for(const Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (const Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
- uint8_t *ptr = (uint8_t*)&w[idx];
- encode_uint16(E->key().x,&ptr[0]);
- encode_uint16(E->key().y,&ptr[2]);
+ uint8_t *ptr = (uint8_t *)&w[idx];
+ encode_uint16(E->key().x, &ptr[0]);
+ encode_uint16(E->key().y, &ptr[2]);
uint32_t val = E->get().id;
if (E->get().flip_h)
- val|=(1<<29);
+ val |= (1 << 29);
if (E->get().flip_v)
- val|=(1<<30);
+ val |= (1 << 30);
if (E->get().transpose)
- val|=(1<<31);
+ val |= (1 << 31);
- encode_uint32(val,&ptr[4]);
- idx+=2;
+ encode_uint32(val, &ptr[4]);
+ idx += 2;
}
-
w = DVector<int>::Write();
return data;
-
}
Rect2 TileMap::get_item_rect() const {
- const_cast<TileMap*>(this)->_update_dirty_quadrants();
+ const_cast<TileMap *>(this)->_update_dirty_quadrants();
return rect_cache;
}
void TileMap::set_collision_layer(uint32_t p_layer) {
- collision_layer=p_layer;
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ collision_layer = p_layer;
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q=E->get();
- Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_layer_mask(q.body, collision_layer);
}
}
void TileMap::set_collision_mask(uint32_t p_mask) {
- collision_mask=p_mask;
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ collision_mask = p_mask;
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q=E->get();
- Physics2DServer::get_singleton()->body_set_collision_mask(q.body,collision_mask);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
}
}
-bool TileMap::get_collision_use_kinematic() const{
+bool TileMap::get_collision_use_kinematic() const {
return use_kinematic;
}
@@ -932,42 +886,39 @@ bool TileMap::get_collision_use_kinematic() const{
void TileMap::set_collision_use_kinematic(bool p_use_kinematic) {
_clear_quadrants();
- use_kinematic=p_use_kinematic;
+ use_kinematic = p_use_kinematic;
_recreate_quadrants();
}
void TileMap::set_collision_friction(float p_friction) {
- friction=p_friction;
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ friction = p_friction;
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q=E->get();
- Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_FRICTION,p_friction);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, p_friction);
}
-
}
-float TileMap::get_collision_friction() const{
+float TileMap::get_collision_friction() const {
return friction;
}
-void TileMap::set_collision_bounce(float p_bounce){
+void TileMap::set_collision_bounce(float p_bounce) {
- bounce=p_bounce;
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ bounce = p_bounce;
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q=E->get();
- Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_BOUNCE,p_bounce);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, p_bounce);
}
-
}
-float TileMap::get_collision_bounce() const{
+float TileMap::get_collision_bounce() const {
return bounce;
}
-
uint32_t TileMap::get_collision_layer() const {
return collision_layer;
@@ -981,7 +932,7 @@ uint32_t TileMap::get_collision_mask() const {
void TileMap::set_mode(Mode p_mode) {
_clear_quadrants();
- mode=p_mode;
+ mode = p_mode;
_recreate_quadrants();
emit_signal("settings_changed");
}
@@ -993,7 +944,7 @@ TileMap::Mode TileMap::get_mode() const {
void TileMap::set_half_offset(HalfOffset p_half_offset) {
_clear_quadrants();
- half_offset=p_half_offset;
+ half_offset = p_half_offset;
_recreate_quadrants();
emit_signal("settings_changed");
}
@@ -1001,20 +952,19 @@ void TileMap::set_half_offset(HalfOffset p_half_offset) {
void TileMap::set_tile_origin(TileOrigin p_tile_origin) {
_clear_quadrants();
- tile_origin=p_tile_origin;
+ tile_origin = p_tile_origin;
_recreate_quadrants();
emit_signal("settings_changed");
}
-TileMap::TileOrigin TileMap::get_tile_origin() const{
+TileMap::TileOrigin TileMap::get_tile_origin() const {
return tile_origin;
}
-
Vector2 TileMap::get_cell_draw_offset() const {
- switch(mode) {
+ switch (mode) {
case MODE_SQUARE: {
@@ -1022,22 +972,21 @@ Vector2 TileMap::get_cell_draw_offset() const {
} break;
case MODE_ISOMETRIC: {
- return Vector2(-cell_size.x*0.5,0);
+ return Vector2(-cell_size.x * 0.5, 0);
} break;
case MODE_CUSTOM: {
Vector2 min;
- min.x = MIN(custom_transform[0].x,min.x);
- min.y = MIN(custom_transform[0].y,min.y);
- min.x = MIN(custom_transform[1].x,min.x);
- min.y = MIN(custom_transform[1].y,min.y);
+ min.x = MIN(custom_transform[0].x, min.x);
+ min.y = MIN(custom_transform[0].y, min.y);
+ min.x = MIN(custom_transform[1].x, min.x);
+ min.y = MIN(custom_transform[1].y, min.y);
return min;
} break;
}
return Vector2();
-
}
TileMap::HalfOffset TileMap::get_half_offset() const {
@@ -1046,13 +995,13 @@ TileMap::HalfOffset TileMap::get_half_offset() const {
Matrix32 TileMap::get_cell_transform() const {
- switch(mode) {
+ switch (mode) {
case MODE_SQUARE: {
Matrix32 m;
- m[0]*=cell_size.x;
- m[1]*=cell_size.y;
+ m[0] *= cell_size.x;
+ m[1] *= cell_size.y;
return m;
} break;
case MODE_ISOMETRIC: {
@@ -1060,8 +1009,8 @@ Matrix32 TileMap::get_cell_transform() const {
//isometric only makes sense when y is positive in both x and y vectors, otherwise
//the drawing of tiles will overlap
Matrix32 m;
- m[0]=Vector2(cell_size.x*0.5,cell_size.y*0.5);
- m[1]=Vector2(-cell_size.x*0.5,cell_size.y*0.5);
+ m[0] = Vector2(cell_size.x * 0.5, cell_size.y * 0.5);
+ m[1] = Vector2(-cell_size.x * 0.5, cell_size.y * 0.5);
return m;
} break;
@@ -1074,35 +1023,34 @@ Matrix32 TileMap::get_cell_transform() const {
return Matrix32();
}
-void TileMap::set_custom_transform(const Matrix32& p_xform) {
+void TileMap::set_custom_transform(const Matrix32 &p_xform) {
_clear_quadrants();
- custom_transform=p_xform;
+ custom_transform = p_xform;
_recreate_quadrants();
emit_signal("settings_changed");
-
}
-Matrix32 TileMap::get_custom_transform() const{
+Matrix32 TileMap::get_custom_transform() const {
return custom_transform;
}
-Vector2 TileMap::_map_to_world(int x,int y,bool p_ignore_ofs) const {
+Vector2 TileMap::_map_to_world(int x, int y, bool p_ignore_ofs) const {
- Vector2 ret = get_cell_transform().xform(Vector2(x,y));
+ Vector2 ret = get_cell_transform().xform(Vector2(x, y));
if (!p_ignore_ofs) {
- switch(half_offset) {
+ switch (half_offset) {
case HALF_OFFSET_X: {
- if (ABS(y)&1) {
+ if (ABS(y) & 1) {
- ret+=get_cell_transform()[0]*0.5;
+ ret += get_cell_transform()[0] * 0.5;
}
} break;
case HALF_OFFSET_Y: {
- if (ABS(x)&1) {
- ret+=get_cell_transform()[1]*0.5;
+ if (ABS(x) & 1) {
+ ret += get_cell_transform()[1] * 0.5;
}
} break;
default: {}
@@ -1110,25 +1058,24 @@ Vector2 TileMap::_map_to_world(int x,int y,bool p_ignore_ofs) const {
}
return ret;
}
-Vector2 TileMap::map_to_world(const Vector2& p_pos,bool p_ignore_ofs) const {
+Vector2 TileMap::map_to_world(const Vector2 &p_pos, bool p_ignore_ofs) const {
- return _map_to_world(p_pos.x,p_pos.y,p_ignore_ofs);
+ return _map_to_world(p_pos.x, p_pos.y, p_ignore_ofs);
}
-Vector2 TileMap::world_to_map(const Vector2& p_pos) const{
+Vector2 TileMap::world_to_map(const Vector2 &p_pos) const {
Vector2 ret = get_cell_transform().affine_inverse().xform(p_pos);
-
- switch(half_offset) {
+ switch (half_offset) {
case HALF_OFFSET_X: {
- if ( ret.y > 0 ? int(ret.y)&1 : (int(ret.y)-1)&1 ) {
- ret.x-=0.5;
+ if (ret.y > 0 ? int(ret.y) & 1 : (int(ret.y) - 1) & 1) {
+ ret.x -= 0.5;
}
} break;
case HALF_OFFSET_Y: {
- if ( ret.x > 0 ? int(ret.x)&1 : (int(ret.x)-1)&1) {
- ret.y-=0.5;
+ if (ret.x > 0 ? int(ret.x) & 1 : (int(ret.x) - 1) & 1) {
+ ret.y -= 0.5;
}
} break;
default: {}
@@ -1140,11 +1087,10 @@ Vector2 TileMap::world_to_map(const Vector2& p_pos) const{
void TileMap::set_y_sort_mode(bool p_enable) {
_clear_quadrants();
- y_sort_mode=p_enable;
- VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(),y_sort_mode);
+ y_sort_mode = p_enable;
+ VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), y_sort_mode);
_recreate_quadrants();
emit_signal("settings_changed");
-
}
bool TileMap::is_y_sort_mode_enabled() const {
@@ -1156,11 +1102,11 @@ Array TileMap::get_used_cells() const {
Array a;
a.resize(tile_map.size());
- int i=0;
- for (Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {
+ int i = 0;
+ for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
- Vector2 p (E->key().x,E->key().y);
- a[i++]=p;
+ Vector2 p(E->key().x, E->key().y);
+ a[i++] = p;
}
return a;
@@ -1169,14 +1115,14 @@ Array TileMap::get_used_cells() const {
Rect2 TileMap::get_used_rect() { // Not const because of cache
if (used_size_cache_dirty) {
- if(tile_map.size() > 0) {
+ if (tile_map.size() > 0) {
used_size_cache = Rect2(tile_map.front()->key().x, tile_map.front()->key().y, 0, 0);
- for (Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) {
+ for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
used_size_cache.expand_to(Vector2(E->key().x, E->key().y));
}
- used_size_cache.size += Vector2(1,1);
+ used_size_cache.size += Vector2(1, 1);
} else {
used_size_cache = Rect2();
}
@@ -1187,19 +1133,18 @@ Rect2 TileMap::get_used_rect() { // Not const because of cache
return used_size_cache;
}
-
void TileMap::set_occluder_light_mask(int p_mask) {
- occluder_light_mask=p_mask;
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ occluder_light_mask = p_mask;
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- for (Map<PosKey,Quadrant::Occluder>::Element *F=E->get().occluder_instances.front();F;F=F->next()) {
- VisualServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id,occluder_light_mask);
+ for (Map<PosKey, Quadrant::Occluder>::Element *F = E->get().occluder_instances.front(); F; F = F->next()) {
+ VisualServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id, occluder_light_mask);
}
}
}
-int TileMap::get_occluder_light_mask() const{
+int TileMap::get_occluder_light_mask() const {
return occluder_light_mask;
}
@@ -1207,149 +1152,145 @@ int TileMap::get_occluder_light_mask() const{
void TileMap::set_light_mask(int p_light_mask) {
CanvasItem::set_light_mask(p_light_mask);
- for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- for (List<RID>::Element *F=E->get().canvas_items.front();F;F=F->next()) {
- VisualServer::get_singleton()->canvas_item_set_light_mask(F->get(),get_light_mask());
+ for (List<RID>::Element *F = E->get().canvas_items.front(); F; F = F->next()) {
+ VisualServer::get_singleton()->canvas_item_set_light_mask(F->get(), get_light_mask());
}
}
}
void TileMap::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_tileset", "tileset:TileSet"), &TileMap::set_tileset);
+ ObjectTypeDB::bind_method(_MD("get_tileset:TileSet"), &TileMap::get_tileset);
- ObjectTypeDB::bind_method(_MD("set_tileset","tileset:TileSet"),&TileMap::set_tileset);
- ObjectTypeDB::bind_method(_MD("get_tileset:TileSet"),&TileMap::get_tileset);
-
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&TileMap::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&TileMap::get_mode);
+ ObjectTypeDB::bind_method(_MD("set_mode", "mode"), &TileMap::set_mode);
+ ObjectTypeDB::bind_method(_MD("get_mode"), &TileMap::get_mode);
- ObjectTypeDB::bind_method(_MD("set_half_offset","half_offset"),&TileMap::set_half_offset);
- ObjectTypeDB::bind_method(_MD("get_half_offset"),&TileMap::get_half_offset);
+ ObjectTypeDB::bind_method(_MD("set_half_offset", "half_offset"), &TileMap::set_half_offset);
+ ObjectTypeDB::bind_method(_MD("get_half_offset"), &TileMap::get_half_offset);
- ObjectTypeDB::bind_method(_MD("set_custom_transform","custom_transform"),&TileMap::set_custom_transform);
- ObjectTypeDB::bind_method(_MD("get_custom_transform"),&TileMap::get_custom_transform);
+ ObjectTypeDB::bind_method(_MD("set_custom_transform", "custom_transform"), &TileMap::set_custom_transform);
+ ObjectTypeDB::bind_method(_MD("get_custom_transform"), &TileMap::get_custom_transform);
- ObjectTypeDB::bind_method(_MD("set_cell_size","size"),&TileMap::set_cell_size);
- ObjectTypeDB::bind_method(_MD("get_cell_size"),&TileMap::get_cell_size);
+ ObjectTypeDB::bind_method(_MD("set_cell_size", "size"), &TileMap::set_cell_size);
+ ObjectTypeDB::bind_method(_MD("get_cell_size"), &TileMap::get_cell_size);
- ObjectTypeDB::bind_method(_MD("_set_old_cell_size","size"),&TileMap::_set_old_cell_size);
- ObjectTypeDB::bind_method(_MD("_get_old_cell_size"),&TileMap::_get_old_cell_size);
+ ObjectTypeDB::bind_method(_MD("_set_old_cell_size", "size"), &TileMap::_set_old_cell_size);
+ ObjectTypeDB::bind_method(_MD("_get_old_cell_size"), &TileMap::_get_old_cell_size);
- ObjectTypeDB::bind_method(_MD("set_quadrant_size","size"),&TileMap::set_quadrant_size);
- ObjectTypeDB::bind_method(_MD("get_quadrant_size"),&TileMap::get_quadrant_size);
+ ObjectTypeDB::bind_method(_MD("set_quadrant_size", "size"), &TileMap::set_quadrant_size);
+ ObjectTypeDB::bind_method(_MD("get_quadrant_size"), &TileMap::get_quadrant_size);
- ObjectTypeDB::bind_method(_MD("set_tile_origin","origin"),&TileMap::set_tile_origin);
- ObjectTypeDB::bind_method(_MD("get_tile_origin"),&TileMap::get_tile_origin);
+ ObjectTypeDB::bind_method(_MD("set_tile_origin", "origin"), &TileMap::set_tile_origin);
+ ObjectTypeDB::bind_method(_MD("get_tile_origin"), &TileMap::get_tile_origin);
- ObjectTypeDB::bind_method(_MD("set_center_x","enable"),&TileMap::set_center_x);
- ObjectTypeDB::bind_method(_MD("get_center_x"),&TileMap::get_center_x);
+ ObjectTypeDB::bind_method(_MD("set_center_x", "enable"), &TileMap::set_center_x);
+ ObjectTypeDB::bind_method(_MD("get_center_x"), &TileMap::get_center_x);
- ObjectTypeDB::bind_method(_MD("set_center_y","enable"),&TileMap::set_center_y);
- ObjectTypeDB::bind_method(_MD("get_center_y"),&TileMap::get_center_y);
+ ObjectTypeDB::bind_method(_MD("set_center_y", "enable"), &TileMap::set_center_y);
+ ObjectTypeDB::bind_method(_MD("get_center_y"), &TileMap::get_center_y);
- ObjectTypeDB::bind_method(_MD("set_y_sort_mode","enable"),&TileMap::set_y_sort_mode);
- ObjectTypeDB::bind_method(_MD("is_y_sort_mode_enabled"),&TileMap::is_y_sort_mode_enabled);
+ ObjectTypeDB::bind_method(_MD("set_y_sort_mode", "enable"), &TileMap::set_y_sort_mode);
+ ObjectTypeDB::bind_method(_MD("is_y_sort_mode_enabled"), &TileMap::is_y_sort_mode_enabled);
- ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
- ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
+ ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic", "use_kinematic"), &TileMap::set_collision_use_kinematic);
+ ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"), &TileMap::get_collision_use_kinematic);
- ObjectTypeDB::bind_method(_MD("set_collision_layer","mask"),&TileMap::set_collision_layer);
- ObjectTypeDB::bind_method(_MD("get_collision_layer"),&TileMap::get_collision_layer);
+ ObjectTypeDB::bind_method(_MD("set_collision_layer", "mask"), &TileMap::set_collision_layer);
+ ObjectTypeDB::bind_method(_MD("get_collision_layer"), &TileMap::get_collision_layer);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&TileMap::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&TileMap::get_collision_mask);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask", "mask"), &TileMap::set_collision_mask);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask"), &TileMap::get_collision_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction);
- ObjectTypeDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction);
+ ObjectTypeDB::bind_method(_MD("set_collision_friction", "value"), &TileMap::set_collision_friction);
+ ObjectTypeDB::bind_method(_MD("get_collision_friction"), &TileMap::get_collision_friction);
- ObjectTypeDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce);
- ObjectTypeDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce);
+ ObjectTypeDB::bind_method(_MD("set_collision_bounce", "value"), &TileMap::set_collision_bounce);
+ ObjectTypeDB::bind_method(_MD("get_collision_bounce"), &TileMap::get_collision_bounce);
- ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask);
- ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask);
+ ObjectTypeDB::bind_method(_MD("set_occluder_light_mask", "mask"), &TileMap::set_occluder_light_mask);
+ ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"), &TileMap::get_occluder_light_mask);
- ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell);
- ObjectTypeDB::bind_method(_MD("get_cellv","pos"),&TileMap::get_cellv);
- ObjectTypeDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped);
- ObjectTypeDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped);
- ObjectTypeDB::bind_method(_MD("is_cell_transposed","x","y"),&TileMap::is_cell_transposed);
+ ObjectTypeDB::bind_method(_MD("set_cell", "x", "y", "tile", "flip_x", "flip_y", "transpose"), &TileMap::set_cell, DEFVAL(false), DEFVAL(false), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("set_cellv", "pos", "tile", "flip_x", "flip_y", "transpose"), &TileMap::set_cellv, DEFVAL(false), DEFVAL(false), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_cell", "x", "y"), &TileMap::get_cell);
+ ObjectTypeDB::bind_method(_MD("get_cellv", "pos"), &TileMap::get_cellv);
+ ObjectTypeDB::bind_method(_MD("is_cell_x_flipped", "x", "y"), &TileMap::is_cell_x_flipped);
+ ObjectTypeDB::bind_method(_MD("is_cell_y_flipped", "x", "y"), &TileMap::is_cell_y_flipped);
+ ObjectTypeDB::bind_method(_MD("is_cell_transposed", "x", "y"), &TileMap::is_cell_transposed);
- ObjectTypeDB::bind_method(_MD("clear"),&TileMap::clear);
+ ObjectTypeDB::bind_method(_MD("clear"), &TileMap::clear);
- ObjectTypeDB::bind_method(_MD("get_used_cells"),&TileMap::get_used_cells);
- ObjectTypeDB::bind_method(_MD("get_used_rect"),&TileMap::get_used_rect);
+ ObjectTypeDB::bind_method(_MD("get_used_cells"), &TileMap::get_used_cells);
+ ObjectTypeDB::bind_method(_MD("get_used_rect"), &TileMap::get_used_rect);
- ObjectTypeDB::bind_method(_MD("map_to_world","mappos","ignore_half_ofs"),&TileMap::map_to_world,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("world_to_map","worldpos"),&TileMap::world_to_map);
+ ObjectTypeDB::bind_method(_MD("map_to_world", "mappos", "ignore_half_ofs"), &TileMap::map_to_world, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("world_to_map", "worldpos"), &TileMap::world_to_map);
- ObjectTypeDB::bind_method(_MD("_clear_quadrants"),&TileMap::_clear_quadrants);
- ObjectTypeDB::bind_method(_MD("_recreate_quadrants"),&TileMap::_recreate_quadrants);
- ObjectTypeDB::bind_method(_MD("_update_dirty_quadrants"),&TileMap::_update_dirty_quadrants);
+ ObjectTypeDB::bind_method(_MD("_clear_quadrants"), &TileMap::_clear_quadrants);
+ ObjectTypeDB::bind_method(_MD("_recreate_quadrants"), &TileMap::_recreate_quadrants);
+ ObjectTypeDB::bind_method(_MD("_update_dirty_quadrants"), &TileMap::_update_dirty_quadrants);
- ObjectTypeDB::bind_method(_MD("_set_tile_data"),&TileMap::_set_tile_data);
- ObjectTypeDB::bind_method(_MD("_get_tile_data"),&TileMap::_get_tile_data);
+ ObjectTypeDB::bind_method(_MD("_set_tile_data"), &TileMap::_set_tile_data);
+ ObjectTypeDB::bind_method(_MD("_get_tile_data"), &TileMap::_get_tile_data);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Square,Isometric,Custom"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_set",PROPERTY_HINT_RESOURCE_TYPE,"TileSet"),_SCS("set_tileset"),_SCS("get_tileset"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell_size",PROPERTY_HINT_RANGE,"1,8192,1",0),_SCS("_set_old_cell_size"),_SCS("_get_old_cell_size"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"cell/size",PROPERTY_HINT_RANGE,"1,8192,1"),_SCS("set_cell_size"),_SCS("get_cell_size"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/quadrant_size",PROPERTY_HINT_RANGE,"1,128,1"),_SCS("set_quadrant_size"),_SCS("get_quadrant_size"));
- ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"cell/custom_transform"),_SCS("set_custom_transform"),_SCS("get_custom_transform"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/half_offset",PROPERTY_HINT_ENUM,"Offset X,Offset Y,Disabled"),_SCS("set_half_offset"),_SCS("get_half_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"cell/tile_origin",PROPERTY_HINT_ENUM,"Top Left,Center,Bottom Left"),_SCS("set_tile_origin"),_SCS("get_tile_origin"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"cell/y_sort"),_SCS("set_y_sort_mode"),_SCS("is_y_sort_mode_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision/use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder/light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Square,Isometric,Custom"), _SCS("set_mode"), _SCS("get_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "tile_set", PROPERTY_HINT_RESOURCE_TYPE, "TileSet"), _SCS("set_tileset"), _SCS("get_tileset"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_size", PROPERTY_HINT_RANGE, "1,8192,1", 0), _SCS("_set_old_cell_size"), _SCS("_get_old_cell_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "cell/size", PROPERTY_HINT_RANGE, "1,8192,1"), _SCS("set_cell_size"), _SCS("get_cell_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cell/quadrant_size", PROPERTY_HINT_RANGE, "1,128,1"), _SCS("set_quadrant_size"), _SCS("get_quadrant_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::MATRIX32, "cell/custom_transform"), _SCS("set_custom_transform"), _SCS("get_custom_transform"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cell/half_offset", PROPERTY_HINT_ENUM, "Offset X,Offset Y,Disabled"), _SCS("set_half_offset"), _SCS("get_half_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cell/tile_origin", PROPERTY_HINT_ENUM, "Top Left,Center,Bottom Left"), _SCS("set_tile_origin"), _SCS("get_tile_origin"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell/y_sort"), _SCS("set_y_sort_mode"), _SCS("is_y_sort_mode_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision/use_kinematic", PROPERTY_HINT_NONE, ""), _SCS("set_collision_use_kinematic"), _SCS("get_collision_use_kinematic"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/friction", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_collision_friction"), _SCS("get_collision_friction"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/bounce", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_collision_bounce"), _SCS("get_collision_bounce"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision/layers", PROPERTY_HINT_ALL_FLAGS), _SCS("set_collision_layer"), _SCS("get_collision_layer"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision/mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_collision_mask"), _SCS("get_collision_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "occluder/light_mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_occluder_light_mask"), _SCS("get_occluder_light_mask"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "tile_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_tile_data"), _SCS("_get_tile_data"));
ADD_SIGNAL(MethodInfo("settings_changed"));
- BIND_CONSTANT( INVALID_CELL );
- BIND_CONSTANT( MODE_SQUARE );
- BIND_CONSTANT( MODE_ISOMETRIC );
- BIND_CONSTANT( MODE_CUSTOM );
- BIND_CONSTANT( HALF_OFFSET_X );
- BIND_CONSTANT( HALF_OFFSET_Y );
- BIND_CONSTANT( HALF_OFFSET_DISABLED );
- BIND_CONSTANT( TILE_ORIGIN_TOP_LEFT );
- BIND_CONSTANT( TILE_ORIGIN_CENTER );
- BIND_CONSTANT( TILE_ORIGIN_BOTTOM_LEFT );
-
+ BIND_CONSTANT(INVALID_CELL);
+ BIND_CONSTANT(MODE_SQUARE);
+ BIND_CONSTANT(MODE_ISOMETRIC);
+ BIND_CONSTANT(MODE_CUSTOM);
+ BIND_CONSTANT(HALF_OFFSET_X);
+ BIND_CONSTANT(HALF_OFFSET_Y);
+ BIND_CONSTANT(HALF_OFFSET_DISABLED);
+ BIND_CONSTANT(TILE_ORIGIN_TOP_LEFT);
+ BIND_CONSTANT(TILE_ORIGIN_CENTER);
+ BIND_CONSTANT(TILE_ORIGIN_BOTTOM_LEFT);
}
TileMap::TileMap() {
+ rect_cache_dirty = true;
+ used_size_cache_dirty = true;
+ pending_update = false;
+ quadrant_order_dirty = false;
+ quadrant_size = 16;
+ cell_size = Size2(64, 64);
+ center_x = false;
+ center_y = false;
+ collision_layer = 1;
+ collision_mask = 1;
+ friction = 1;
+ bounce = 0;
+ mode = MODE_SQUARE;
+ half_offset = HALF_OFFSET_DISABLED;
+ use_kinematic = false;
+ navigation = NULL;
+ y_sort_mode = false;
+ occluder_light_mask = 1;
-
- rect_cache_dirty=true;
- used_size_cache_dirty=true;
- pending_update=false;
- quadrant_order_dirty=false;
- quadrant_size=16;
- cell_size=Size2(64,64);
- center_x=false;
- center_y=false;
- collision_layer=1;
- collision_mask=1;
- friction=1;
- bounce=0;
- mode=MODE_SQUARE;
- half_offset=HALF_OFFSET_DISABLED;
- use_kinematic=false;
- navigation=NULL;
- y_sort_mode=false;
- occluder_light_mask=1;
-
- fp_adjust=0.00001;
- tile_origin=TILE_ORIGIN_TOP_LEFT;
+ fp_adjust = 0.00001;
+ tile_origin = TILE_ORIGIN_TOP_LEFT;
}
TileMap::~TileMap() {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 79f7dbda0..b03004705 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -29,17 +29,17 @@
#ifndef TILE_MAP_H
#define TILE_MAP_H
-#include "scene/2d/node_2d.h"
#include "scene/2d/navigation2d.h"
+#include "scene/2d/node_2d.h"
#include "scene/resources/tile_set.h"
#include "self_list.h"
#include "vset.h"
class TileMap : public Node2D {
- OBJ_TYPE( TileMap, Node2D );
-public:
+ OBJ_TYPE(TileMap, Node2D);
+public:
enum Mode {
MODE_SQUARE,
MODE_ISOMETRIC,
@@ -58,20 +58,17 @@ public:
TILE_ORIGIN_BOTTOM_LEFT
};
-
private:
-
Ref<TileSet> tile_set;
Size2i cell_size;
int quadrant_size;
- bool center_x,center_y;
+ bool center_x, center_y;
Mode mode;
Matrix32 custom_transform;
HalfOffset half_offset;
bool use_kinematic;
Navigation2D *navigation;
-
union PosKey {
struct {
@@ -81,29 +78,32 @@ private:
uint32_t key;
//using a more precise comparison so the regions can be sorted later
- bool operator<(const PosKey& p_k) const { return (y==p_k.y) ? x < p_k.x : y < p_k.y; }
-
- PosKey(int16_t p_x, int16_t p_y) { x=p_x; y=p_y; }
- PosKey() { x=0; y=0; }
+ bool operator<(const PosKey &p_k) const { return (y == p_k.y) ? x < p_k.x : y < p_k.y; }
+ PosKey(int16_t p_x, int16_t p_y) {
+ x = p_x;
+ y = p_y;
+ }
+ PosKey() {
+ x = 0;
+ y = 0;
+ }
};
-
union Cell {
struct {
- int32_t id:24;
- bool flip_h:1;
- bool flip_v:1;
- bool transpose:1;
+ int32_t id : 24;
+ bool flip_h : 1;
+ bool flip_v : 1;
+ bool transpose : 1;
};
uint32_t _u32t;
- Cell() { _u32t=0; }
+ Cell() { _u32t = 0; }
};
-
- Map<PosKey,Cell> tile_map;
+ Map<PosKey, Cell> tile_map;
struct Quadrant {
Vector2 pos;
@@ -122,18 +122,33 @@ private:
Matrix32 xform;
};
-
- Map<PosKey,NavPoly> navpoly_ids;
- Map<PosKey,Occluder> occluder_instances;
+ Map<PosKey, NavPoly> navpoly_ids;
+ Map<PosKey, Occluder> occluder_instances;
VSet<PosKey> cells;
- void operator=(const Quadrant& q) { pos=q.pos; canvas_items=q.canvas_items; body=q.body; cells=q.cells; navpoly_ids=q.navpoly_ids; occluder_instances=q.occluder_instances; }
- Quadrant(const Quadrant& q) : dirty_list(this) { pos=q.pos; canvas_items=q.canvas_items; body=q.body; cells=q.cells; occluder_instances=q.occluder_instances; navpoly_ids=q.navpoly_ids;}
- Quadrant() : dirty_list(this) {}
+ void operator=(const Quadrant &q) {
+ pos = q.pos;
+ canvas_items = q.canvas_items;
+ body = q.body;
+ cells = q.cells;
+ navpoly_ids = q.navpoly_ids;
+ occluder_instances = q.occluder_instances;
+ }
+ Quadrant(const Quadrant &q)
+ : dirty_list(this) {
+ pos = q.pos;
+ canvas_items = q.canvas_items;
+ body = q.body;
+ cells = q.cells;
+ occluder_instances = q.occluder_instances;
+ navpoly_ids = q.navpoly_ids;
+ }
+ Quadrant()
+ : dirty_list(this) {}
};
- Map<PosKey,Quadrant> quadrant_map;
+ Map<PosKey, Quadrant> quadrant_map;
SelfList<Quadrant>::List dirty_quadrant_list;
@@ -155,43 +170,38 @@ private:
int occluder_light_mask;
- void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc);
+ void _fix_cell_transform(Matrix32 &xform, const Cell &p_cell, const Vector2 &p_offset, const Size2 &p_sc);
- Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk);
- void _erase_quadrant(Map<PosKey,Quadrant>::Element *Q);
- void _make_quadrant_dirty(Map<PosKey,Quadrant>::Element *Q);
+ Map<PosKey, Quadrant>::Element *_create_quadrant(const PosKey &p_qk);
+ void _erase_quadrant(Map<PosKey, Quadrant>::Element *Q);
+ void _make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q);
void _recreate_quadrants();
void _clear_quadrants();
void _update_dirty_quadrants();
- void _update_quadrant_space(const RID& p_space);
+ void _update_quadrant_space(const RID &p_space);
void _update_quadrant_transform();
void _recompute_rect_cache();
_FORCE_INLINE_ int _get_quadrant_size() const;
-
- void _set_tile_data(const DVector<int>& p_data);
+ void _set_tile_data(const DVector<int> &p_data);
DVector<int> _get_tile_data() const;
- void _set_old_cell_size(int p_size) { set_cell_size(Size2(p_size,p_size)); }
+ void _set_old_cell_size(int p_size) { set_cell_size(Size2(p_size, p_size)); }
int _get_old_cell_size() const { return cell_size.x; }
- _FORCE_INLINE_ Vector2 _map_to_world(int p_x,int p_y,bool p_ignore_ofs=false) const;
+ _FORCE_INLINE_ Vector2 _map_to_world(int p_x, int p_y, bool p_ignore_ofs = false) const;
protected:
-
-
void _notification(int p_what);
static void _bind_methods();
public:
-
enum {
- INVALID_CELL=-1
+ INVALID_CELL = -1
};
-
- void set_tileset(const Ref<TileSet>& p_tileset);
+ void set_tileset(const Ref<TileSet> &p_tileset);
Ref<TileSet> get_tileset() const;
void set_cell_size(Size2 p_size);
@@ -205,14 +215,14 @@ public:
void set_center_y(bool p_enable);
bool get_center_y() const;
- void set_cell(int p_x,int p_y,int p_tile,bool p_flip_x=false,bool p_flip_y=false,bool p_transpose=false);
- int get_cell(int p_x,int p_y) const;
- bool is_cell_x_flipped(int p_x,int p_y) const;
- bool is_cell_y_flipped(int p_x,int p_y) const;
- bool is_cell_transposed(int p_x,int p_y) const;
+ void set_cell(int p_x, int p_y, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false);
+ int get_cell(int p_x, int p_y) const;
+ bool is_cell_x_flipped(int p_x, int p_y) const;
+ bool is_cell_y_flipped(int p_x, int p_y) const;
+ bool is_cell_transposed(int p_x, int p_y) const;
- void set_cellv(const Vector2& p_pos,int p_tile,bool p_flip_x=false,bool p_flip_y=false,bool p_transpose=false);
- int get_cellv(const Vector2& p_pos) const;
+ void set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false);
+ int get_cellv(const Vector2 &p_pos) const;
Rect2 get_item_rect() const;
@@ -240,14 +250,14 @@ public:
void set_tile_origin(TileOrigin p_tile_origin);
TileOrigin get_tile_origin() const;
- void set_custom_transform(const Matrix32& p_xform);
+ void set_custom_transform(const Matrix32 &p_xform);
Matrix32 get_custom_transform() const;
Matrix32 get_cell_transform() const;
Vector2 get_cell_draw_offset() const;
- Vector2 map_to_world(const Vector2& p_pos, bool p_ignore_ofs=false) const;
- Vector2 world_to_map(const Vector2& p_pos) const;
+ Vector2 map_to_world(const Vector2 &p_pos, bool p_ignore_ofs = false) const;
+ Vector2 world_to_map(const Vector2 &p_pos) const;
void set_y_sort_mode(bool p_enable);
bool is_y_sort_mode_enabled() const;
diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp
index 6522fe49c..c38623956 100644
--- a/scene/2d/visibility_notifier_2d.cpp
+++ b/scene/2d/visibility_notifier_2d.cpp
@@ -28,14 +28,14 @@
/*************************************************************************/
#include "visibility_notifier_2d.h"
-#include "scene/scene_string_names.h"
-#include "scene/2d/physics_body_2d.h"
+#include "particles_2d.h"
#include "scene/2d/animated_sprite.h"
+#include "scene/2d/physics_body_2d.h"
#include "scene/animation/animation_player.h"
#include "scene/scene_string_names.h"
-#include "particles_2d.h"
+#include "scene/scene_string_names.h"
-void VisibilityNotifier2D::_enter_viewport(Viewport* p_viewport) {
+void VisibilityNotifier2D::_enter_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(viewports.has(p_viewport));
viewports.insert(p_viewport);
@@ -43,16 +43,15 @@ void VisibilityNotifier2D::_enter_viewport(Viewport* p_viewport) {
if (is_inside_tree() && get_tree()->is_editor_hint())
return;
- if (viewports.size()==1) {
+ if (viewports.size() == 1) {
emit_signal(SceneStringNames::get_singleton()->enter_screen);
_screen_enter();
}
- emit_signal(SceneStringNames::get_singleton()->enter_viewport,p_viewport);
-
+ emit_signal(SceneStringNames::get_singleton()->enter_viewport, p_viewport);
}
-void VisibilityNotifier2D::_exit_viewport(Viewport* p_viewport){
+void VisibilityNotifier2D::_exit_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(!viewports.has(p_viewport));
viewports.erase(p_viewport);
@@ -60,20 +59,19 @@ void VisibilityNotifier2D::_exit_viewport(Viewport* p_viewport){
if (is_inside_tree() && get_tree()->is_editor_hint())
return;
- emit_signal(SceneStringNames::get_singleton()->exit_viewport,p_viewport);
- if (viewports.size()==0) {
+ emit_signal(SceneStringNames::get_singleton()->exit_viewport, p_viewport);
+ if (viewports.size() == 0) {
emit_signal(SceneStringNames::get_singleton()->exit_screen);
_screen_exit();
}
}
+void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
-void VisibilityNotifier2D::set_rect(const Rect2& p_rect){
-
- rect=p_rect;
+ rect = p_rect;
if (is_inside_tree()) {
- get_world_2d()->_update_notifier(this,get_global_transform().xform(rect));
+ get_world_2d()->_update_notifier(this, get_global_transform().xform(rect));
if (get_tree()->is_editor_hint()) {
update();
item_rect_changed();
@@ -88,31 +86,29 @@ Rect2 VisibilityNotifier2D::get_item_rect() const {
return rect;
}
-Rect2 VisibilityNotifier2D::get_rect() const{
+Rect2 VisibilityNotifier2D::get_rect() const {
return rect;
}
-
void VisibilityNotifier2D::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
//get_world_2d()->
- get_world_2d()->_register_notifier(this,get_global_transform().xform(rect));
+ get_world_2d()->_register_notifier(this, get_global_transform().xform(rect));
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
//get_world_2d()->
- get_world_2d()->_update_notifier(this,get_global_transform().xform(rect));
+ get_world_2d()->_update_notifier(this, get_global_transform().xform(rect));
} break;
case NOTIFICATION_DRAW: {
if (get_tree()->is_editor_hint()) {
- draw_rect(rect,Color(1,0.5,1,0.2));
+ draw_rect(rect, Color(1, 0.5, 1, 0.2));
}
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -124,42 +120,35 @@ void VisibilityNotifier2D::_notification(int p_what) {
bool VisibilityNotifier2D::is_on_screen() const {
- return viewports.size()>0;
+ return viewports.size() > 0;
}
-void VisibilityNotifier2D::_bind_methods(){
+void VisibilityNotifier2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_rect","rect"),&VisibilityNotifier2D::set_rect);
- ObjectTypeDB::bind_method(_MD("get_rect"),&VisibilityNotifier2D::get_rect);
- ObjectTypeDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier2D::is_on_screen);
+ ObjectTypeDB::bind_method(_MD("set_rect", "rect"), &VisibilityNotifier2D::set_rect);
+ ObjectTypeDB::bind_method(_MD("get_rect"), &VisibilityNotifier2D::get_rect);
+ ObjectTypeDB::bind_method(_MD("is_on_screen"), &VisibilityNotifier2D::is_on_screen);
- ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"),_SCS("set_rect"),_SCS("get_rect"));
+ ADD_PROPERTY(PropertyInfo(Variant::RECT2, "rect"), _SCS("set_rect"), _SCS("get_rect"));
- ADD_SIGNAL( MethodInfo("enter_viewport",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) );
- ADD_SIGNAL( MethodInfo("exit_viewport",PropertyInfo(Variant::OBJECT,"viewport",PROPERTY_HINT_RESOURCE_TYPE,"Viewport")) );
- ADD_SIGNAL( MethodInfo("enter_screen"));
- ADD_SIGNAL( MethodInfo("exit_screen"));
+ ADD_SIGNAL(MethodInfo("enter_viewport", PropertyInfo(Variant::OBJECT, "viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport")));
+ ADD_SIGNAL(MethodInfo("exit_viewport", PropertyInfo(Variant::OBJECT, "viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport")));
+ ADD_SIGNAL(MethodInfo("enter_screen"));
+ ADD_SIGNAL(MethodInfo("exit_screen"));
}
-
VisibilityNotifier2D::VisibilityNotifier2D() {
- rect=Rect2(-10,-10,20,20);
+ rect = Rect2(-10, -10, 20, 20);
}
-
-
-
-
//////////////////////////////////////
-
void VisibilityEnabler2D::_screen_enter() {
+ for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
- for(Map<Node*,Variant>::Element *E=nodes.front();E;E=E->next()) {
-
- _change_node_state(E->key(),true);
+ _change_node_state(E->key(), true);
}
if (enabler[ENABLER_PARENT_FIXED_PROCESS] && get_parent())
@@ -167,14 +156,14 @@ void VisibilityEnabler2D::_screen_enter() {
if (enabler[ENABLER_PARENT_PROCESS] && get_parent())
get_parent()->set_process(true);
- visible=true;
+ visible = true;
}
-void VisibilityEnabler2D::_screen_exit(){
+void VisibilityEnabler2D::_screen_exit() {
- for(Map<Node*,Variant>::Element *E=nodes.front();E;E=E->next()) {
+ for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
- _change_node_state(E->key(),false);
+ _change_node_state(E->key(), false);
}
if (enabler[ENABLER_PARENT_FIXED_PROCESS] && get_parent())
@@ -182,23 +171,21 @@ void VisibilityEnabler2D::_screen_exit(){
if (enabler[ENABLER_PARENT_PROCESS] && get_parent())
get_parent()->set_process(false);
- visible=false;
+ visible = false;
}
-void VisibilityEnabler2D::_find_nodes(Node* p_node) {
-
+void VisibilityEnabler2D::_find_nodes(Node *p_node) {
- bool add=false;
+ bool add = false;
Variant meta;
if (enabler[ENABLER_FREEZE_BODIES]) {
RigidBody2D *rb2d = p_node->cast_to<RigidBody2D>();
- if (rb2d && ((rb2d->get_mode()==RigidBody2D::MODE_CHARACTER || (rb2d->get_mode()==RigidBody2D::MODE_RIGID && !rb2d->is_able_to_sleep())))) {
-
+ if (rb2d && ((rb2d->get_mode() == RigidBody2D::MODE_CHARACTER || (rb2d->get_mode() == RigidBody2D::MODE_RIGID && !rb2d->is_able_to_sleep())))) {
- add=true;
- meta=rb2d->get_mode();
+ add = true;
+ meta = rb2d->get_mode();
}
}
@@ -206,59 +193,53 @@ void VisibilityEnabler2D::_find_nodes(Node* p_node) {
AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
if (ap) {
- add=true;
+ add = true;
}
-
}
if (enabler[ENABLER_PAUSE_ANIMATED_SPRITES]) {
AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
if (as) {
- add=true;
+ add = true;
}
-
}
-
if (enabler[ENABLER_PAUSE_PARTICLES]) {
Particles2D *ps = p_node->cast_to<Particles2D>();
if (ps) {
- add=true;
+ add = true;
}
-
}
if (add) {
- p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
- nodes[p_node]=meta;
- _change_node_state(p_node,false);
+ p_node->connect(SceneStringNames::get_singleton()->exit_tree, this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
+ nodes[p_node] = meta;
+ _change_node_state(p_node, false);
}
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
- if (c->get_filename()!=String())
+ if (c->get_filename() != String())
continue; //skip, instance
_find_nodes(c);
}
-
}
-void VisibilityEnabler2D::_notification(int p_what){
+void VisibilityEnabler2D::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
if (get_tree()->is_editor_hint())
return;
-
Node *from = this;
//find where current scene starts
- while(from->get_parent() && from->get_filename()==String())
- from=from->get_parent();
+ while (from->get_parent() && from->get_filename() == String())
+ from = from->get_parent();
_find_nodes(from);
@@ -266,29 +247,25 @@ void VisibilityEnabler2D::_notification(int p_what){
get_parent()->set_fixed_process(false);
if (enabler[ENABLER_PARENT_PROCESS] && get_parent())
get_parent()->set_process(false);
-
-
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
if (get_tree()->is_editor_hint())
return;
-
- for (Map<Node*,Variant>::Element *E=nodes.front();E;E=E->next()) {
+ for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
if (!visible)
- _change_node_state(E->key(),true);
- E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed");
+ _change_node_state(E->key(), true);
+ E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree, this, "_node_removed");
}
nodes.clear();
-
}
}
-void VisibilityEnabler2D::_change_node_state(Node* p_node,bool p_enabled) {
+void VisibilityEnabler2D::_change_node_state(Node *p_node, bool p_enabled) {
ERR_FAIL_COND(!nodes.has(p_node));
@@ -301,7 +278,7 @@ void VisibilityEnabler2D::_change_node_state(Node* p_node,bool p_enabled) {
}
{
- AnimationPlayer *ap=p_node->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
if (ap) {
@@ -309,7 +286,7 @@ void VisibilityEnabler2D::_change_node_state(Node* p_node,bool p_enabled) {
}
}
{
- AnimatedSprite *as=p_node->cast_to<AnimatedSprite>();
+ AnimatedSprite *as = p_node->cast_to<AnimatedSprite>();
if (as) {
@@ -321,81 +298,72 @@ void VisibilityEnabler2D::_change_node_state(Node* p_node,bool p_enabled) {
}
{
- Particles2D *ps=p_node->cast_to<Particles2D>();
+ Particles2D *ps = p_node->cast_to<Particles2D>();
if (ps) {
ps->set_emitting(p_enabled);
}
}
-
}
-
-void VisibilityEnabler2D::_node_removed(Node* p_node) {
+void VisibilityEnabler2D::_node_removed(Node *p_node) {
if (!visible)
- _change_node_state(p_node,true);
+ _change_node_state(p_node, true);
//changed to one shot, not needed
//p_node->disconnect(SceneStringNames::get_singleton()->exit_scene,this,"_node_removed");
nodes.erase(p_node);
-
}
String VisibilityEnabler2D::get_configuration_warning() const {
#ifdef TOOLS_ENABLED
- if (is_inside_tree() && get_parent() && (get_parent()->get_filename()==String() && get_parent()!=get_tree()->get_edited_scene_root())) {
+ if (is_inside_tree() && get_parent() && (get_parent()->get_filename() == String() && get_parent() != get_tree()->get_edited_scene_root())) {
return TTR("VisibilityEnable2D works best when used with the edited scene root directly as parent.");
}
#endif
return String();
}
+void VisibilityEnabler2D::_bind_methods() {
-void VisibilityEnabler2D::_bind_methods(){
-
- ObjectTypeDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler2D::set_enabler);
- ObjectTypeDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler2D::is_enabler_enabled);
- ObjectTypeDB::bind_method(_MD("_node_removed"),&VisibilityEnabler2D::_node_removed);
+ ObjectTypeDB::bind_method(_MD("set_enabler", "enabler", "enabled"), &VisibilityEnabler2D::set_enabler);
+ ObjectTypeDB::bind_method(_MD("is_enabler_enabled", "enabler"), &VisibilityEnabler2D::is_enabler_enabled);
+ ObjectTypeDB::bind_method(_MD("_node_removed"), &VisibilityEnabler2D::_node_removed);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_particles"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_PARTICLES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animated_sprites"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATED_SPRITES);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_PROCESS);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/fixed_process_parent"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PARENT_FIXED_PROCESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "enabler/pause_animations"), _SCS("set_enabler"), _SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "enabler/freeze_bodies"), _SCS("set_enabler"), _SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "enabler/pause_particles"), _SCS("set_enabler"), _SCS("is_enabler_enabled"), ENABLER_PAUSE_PARTICLES);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "enabler/pause_animated_sprites"), _SCS("set_enabler"), _SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATED_SPRITES);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "enabler/process_parent"), _SCS("set_enabler"), _SCS("is_enabler_enabled"), ENABLER_PARENT_PROCESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "enabler/fixed_process_parent"), _SCS("set_enabler"), _SCS("is_enabler_enabled"), ENABLER_PARENT_FIXED_PROCESS);
- BIND_CONSTANT( ENABLER_FREEZE_BODIES );
- BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS );
- BIND_CONSTANT( ENABLER_PAUSE_PARTICLES );
- BIND_CONSTANT( ENABLER_PAUSE_ANIMATED_SPRITES );
- BIND_CONSTANT( ENABLER_PARENT_PROCESS );
- BIND_CONSTANT( ENABLER_PARENT_FIXED_PROCESS );
- BIND_CONSTANT( ENABLER_MAX);
+ BIND_CONSTANT(ENABLER_FREEZE_BODIES);
+ BIND_CONSTANT(ENABLER_PAUSE_ANIMATIONS);
+ BIND_CONSTANT(ENABLER_PAUSE_PARTICLES);
+ BIND_CONSTANT(ENABLER_PAUSE_ANIMATED_SPRITES);
+ BIND_CONSTANT(ENABLER_PARENT_PROCESS);
+ BIND_CONSTANT(ENABLER_PARENT_FIXED_PROCESS);
+ BIND_CONSTANT(ENABLER_MAX);
}
-void VisibilityEnabler2D::set_enabler(Enabler p_enabler,bool p_enable){
-
- ERR_FAIL_INDEX(p_enabler,ENABLER_MAX);
- enabler[p_enabler]=p_enable;
+void VisibilityEnabler2D::set_enabler(Enabler p_enabler, bool p_enable) {
+ ERR_FAIL_INDEX(p_enabler, ENABLER_MAX);
+ enabler[p_enabler] = p_enable;
}
-bool VisibilityEnabler2D::is_enabler_enabled(Enabler p_enabler) const{
+bool VisibilityEnabler2D::is_enabler_enabled(Enabler p_enabler) const {
- ERR_FAIL_INDEX_V(p_enabler,ENABLER_MAX,false);
+ ERR_FAIL_INDEX_V(p_enabler, ENABLER_MAX, false);
return enabler[p_enabler];
-
}
VisibilityEnabler2D::VisibilityEnabler2D() {
- for(int i=0;i<ENABLER_MAX;i++)
- enabler[i]=true;
- enabler[ENABLER_PARENT_PROCESS]=false;
- enabler[ENABLER_PARENT_FIXED_PROCESS]=false;
-
- visible=false;
+ for (int i = 0; i < ENABLER_MAX; i++)
+ enabler[i] = true;
+ enabler[ENABLER_PARENT_PROCESS] = false;
+ enabler[ENABLER_PARENT_FIXED_PROCESS] = false;
+ visible = false;
}
-
-
diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h
index 3fe34270d..59fba5ee4 100644
--- a/scene/2d/visibility_notifier_2d.h
+++ b/scene/2d/visibility_notifier_2d.h
@@ -34,27 +34,26 @@
class Viewport;
class VisibilityNotifier2D : public Node2D {
- OBJ_TYPE(VisibilityNotifier2D,Node2D);
+ OBJ_TYPE(VisibilityNotifier2D, Node2D);
- Set<Viewport*> viewports;
+ Set<Viewport *> viewports;
Rect2 rect;
protected:
-friend class SpatialIndexer2D;
-
- void _enter_viewport(Viewport* p_viewport);
- void _exit_viewport(Viewport* p_viewport);
+ friend class SpatialIndexer2D;
+ void _enter_viewport(Viewport *p_viewport);
+ void _exit_viewport(Viewport *p_viewport);
virtual void _screen_enter() {}
virtual void _screen_exit() {}
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_rect(const Rect2& p_rect);
+public:
+ void set_rect(const Rect2 &p_rect);
Rect2 get_rect() const;
bool is_on_screen() const;
@@ -64,12 +63,11 @@ public:
VisibilityNotifier2D();
};
-
class VisibilityEnabler2D : public VisibilityNotifier2D {
- OBJ_TYPE(VisibilityEnabler2D,VisibilityNotifier2D);
-public:
+ OBJ_TYPE(VisibilityEnabler2D, VisibilityNotifier2D);
+public:
enum Enabler {
ENABLER_PAUSE_ANIMATIONS,
ENABLER_FREEZE_BODIES,
@@ -81,35 +79,31 @@ public:
};
protected:
-
virtual void _screen_enter();
virtual void _screen_exit();
bool visible;
- void _find_nodes(Node* p_node);
+ void _find_nodes(Node *p_node);
- Map<Node*,Variant> nodes;
- void _node_removed(Node* p_node);
+ Map<Node *, Variant> nodes;
+ void _node_removed(Node *p_node);
bool enabler[ENABLER_MAX];
- void _change_node_state(Node* p_node,bool p_enabled);
+ void _change_node_state(Node *p_node, bool p_enabled);
void _notification(int p_what);
static void _bind_methods();
public:
-
- void set_enabler(Enabler p_enabler,bool p_enable);
+ void set_enabler(Enabler p_enabler, bool p_enable);
bool is_enabler_enabled(Enabler p_enabler) const;
String get_configuration_warning() const;
VisibilityEnabler2D();
-
};
VARIANT_ENUM_CAST(VisibilityEnabler2D::Enabler);
-
#endif // VISIBILITY_NOTIFIER_2D_H
diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp
index 9578e6786..256bdd572 100644
--- a/scene/2d/y_sort.cpp
+++ b/scene/2d/y_sort.cpp
@@ -28,12 +28,10 @@
/*************************************************************************/
#include "y_sort.h"
-
-
void YSort::set_sort_enabled(bool p_enabled) {
- sort_enabled=p_enabled;
- VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(),sort_enabled);
+ sort_enabled = p_enabled;
+ VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), sort_enabled);
}
bool YSort::is_sort_enabled() const {
@@ -43,15 +41,14 @@ bool YSort::is_sort_enabled() const {
void YSort::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_sort_enabled","enabled"),&YSort::set_sort_enabled);
- ObjectTypeDB::bind_method(_MD("is_sort_enabled"),&YSort::is_sort_enabled);
+ ObjectTypeDB::bind_method(_MD("set_sort_enabled", "enabled"), &YSort::set_sort_enabled);
+ ObjectTypeDB::bind_method(_MD("is_sort_enabled"), &YSort::is_sort_enabled);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"sort/enabled"),_SCS("set_sort_enabled"),_SCS("is_sort_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sort/enabled"), _SCS("set_sort_enabled"), _SCS("is_sort_enabled"));
}
-
YSort::YSort() {
- sort_enabled=true;
- VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(),true);
+ sort_enabled = true;
+ VS::get_singleton()->canvas_item_set_sort_children_by_y(get_canvas_item(), true);
}
diff --git a/scene/2d/y_sort.h b/scene/2d/y_sort.h
index 0cf8773b4..100c0b9ae 100644
--- a/scene/2d/y_sort.h
+++ b/scene/2d/y_sort.h
@@ -32,11 +32,11 @@
#include "scene/2d/node_2d.h"
class YSort : public Node2D {
- OBJ_TYPE(YSort,Node2D);
+ OBJ_TYPE(YSort, Node2D);
bool sort_enabled;
static void _bind_methods();
-public:
+public:
void set_sort_enabled(bool p_enabled);
bool is_sort_enabled() const;
YSort();
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index 0cf55db61..f0dec5d2e 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -31,164 +31,152 @@
#include "servers/physics_server.h"
void Area::set_space_override_mode(SpaceOverride p_mode) {
- space_override=p_mode;
- PhysicsServer::get_singleton()->area_set_space_override_mode(get_rid(),PhysicsServer::AreaSpaceOverrideMode(p_mode));
-
-
+ space_override = p_mode;
+ PhysicsServer::get_singleton()->area_set_space_override_mode(get_rid(), PhysicsServer::AreaSpaceOverrideMode(p_mode));
}
-Area::SpaceOverride Area::get_space_override_mode() const{
+Area::SpaceOverride Area::get_space_override_mode() const {
return space_override;
}
-void Area::set_gravity_is_point(bool p_enabled){
-
- gravity_is_point=p_enabled;
- PhysicsServer::get_singleton()->area_set_param(get_rid(),PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT,p_enabled);
+void Area::set_gravity_is_point(bool p_enabled) {
+ gravity_is_point = p_enabled;
+ PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_IS_POINT, p_enabled);
}
-bool Area::is_gravity_a_point() const{
+bool Area::is_gravity_a_point() const {
return gravity_is_point;
}
-void Area::set_gravity_distance_scale(real_t p_scale){
-
- gravity_distance_scale=p_scale;
- PhysicsServer::get_singleton()->area_set_param(get_rid(),PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE,p_scale);
+void Area::set_gravity_distance_scale(real_t p_scale) {
+ gravity_distance_scale = p_scale;
+ PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_DISTANCE_SCALE, p_scale);
}
-real_t Area::get_gravity_distance_scale() const{
+real_t Area::get_gravity_distance_scale() const {
return gravity_distance_scale;
}
-void Area::set_gravity_vector(const Vector3& p_vec){
-
- gravity_vec=p_vec;
- PhysicsServer::get_singleton()->area_set_param(get_rid(),PhysicsServer::AREA_PARAM_GRAVITY_VECTOR,p_vec);
+void Area::set_gravity_vector(const Vector3 &p_vec) {
+ gravity_vec = p_vec;
+ PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY_VECTOR, p_vec);
}
-Vector3 Area::get_gravity_vector() const{
+Vector3 Area::get_gravity_vector() const {
return gravity_vec;
}
-void Area::set_gravity(real_t p_gravity){
+void Area::set_gravity(real_t p_gravity) {
- gravity=p_gravity;
- PhysicsServer::get_singleton()->area_set_param(get_rid(),PhysicsServer::AREA_PARAM_GRAVITY,p_gravity);
+ gravity = p_gravity;
+ PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_GRAVITY, p_gravity);
}
-real_t Area::get_gravity() const{
+real_t Area::get_gravity() const {
return gravity;
}
-void Area::set_linear_damp(real_t p_linear_damp){
+void Area::set_linear_damp(real_t p_linear_damp) {
- linear_damp=p_linear_damp;
- PhysicsServer::get_singleton()->area_set_param(get_rid(),PhysicsServer::AREA_PARAM_LINEAR_DAMP,p_linear_damp);
+ linear_damp = p_linear_damp;
+ PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_LINEAR_DAMP, p_linear_damp);
}
-real_t Area::get_linear_damp() const{
+real_t Area::get_linear_damp() const {
return linear_damp;
}
-void Area::set_angular_damp(real_t p_angular_damp){
+void Area::set_angular_damp(real_t p_angular_damp) {
- angular_damp=p_angular_damp;
- PhysicsServer::get_singleton()->area_set_param(get_rid(),PhysicsServer::AREA_PARAM_ANGULAR_DAMP,p_angular_damp);
+ angular_damp = p_angular_damp;
+ PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_ANGULAR_DAMP, p_angular_damp);
}
-real_t Area::get_angular_damp() const{
+real_t Area::get_angular_damp() const {
return angular_damp;
}
-void Area::set_priority(real_t p_priority){
+void Area::set_priority(real_t p_priority) {
- priority=p_priority;
- PhysicsServer::get_singleton()->area_set_param(get_rid(),PhysicsServer::AREA_PARAM_PRIORITY,p_priority);
+ priority = p_priority;
+ PhysicsServer::get_singleton()->area_set_param(get_rid(), PhysicsServer::AREA_PARAM_PRIORITY, p_priority);
}
-real_t Area::get_priority() const{
+real_t Area::get_priority() const {
return priority;
}
-
void Area::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,BodyState>::Element *E=body_map.find(p_id);
+ Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_tree);
- E->get().in_tree=true;
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ E->get().in_tree = true;
+ emit_signal(SceneStringNames::get_singleton()->body_enter, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_enter_shape, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
-
}
void Area::_body_exit_tree(ObjectID p_id) {
-
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,BodyState>::Element *E=body_map.find(p_id);
+ Map<ObjectID, BodyState>::Element *E = body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
- E->get().in_tree=false;
- emit_signal(SceneStringNames::get_singleton()->body_exit,node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ E->get().in_tree = false;
+ emit_signal(SceneStringNames::get_singleton()->body_exit, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
-
}
-void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape) {
-
+void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape) {
- bool body_in = p_status==PhysicsServer::AREA_BODY_ADDED;
- ObjectID objid=p_instance;
+ bool body_in = p_status == PhysicsServer::AREA_BODY_ADDED;
+ ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
Node *node = obj ? obj->cast_to<Node>() : NULL;
- Map<ObjectID,BodyState>::Element *E=body_map.find(objid);
+ Map<ObjectID, BodyState>::Element *E = body_map.find(objid);
ERR_FAIL_COND(!body_in && !E);
- locked=true;
+ locked = true;
if (body_in) {
if (!E) {
- E = body_map.insert(objid,BodyState());
- E->get().rc=0;
- E->get().in_tree=node && node->is_inside_tree();
+ E = body_map.insert(objid, BodyState());
+ E->get().rc = 0;
+ E->get().in_tree = node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_enter, node);
}
}
-
}
E->get().rc++;
if (node)
- E->get().shapes.insert(ShapePair(p_body_shape,p_area_shape));
-
+ E->get().shapes.insert(ShapePair(p_body_shape, p_area_shape));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_enter_shape, objid, node, p_body_shape, p_area_shape);
}
} else {
@@ -196,38 +184,32 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod
E->get().rc--;
if (node)
- E->get().shapes.erase(ShapePair(p_body_shape,p_area_shape));
+ E->get().shapes.erase(ShapePair(p_body_shape, p_area_shape));
- bool eraseit=false;
+ bool eraseit = false;
- if (E->get().rc==0) {
+ if (E->get().rc == 0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (E->get().in_tree)
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
-
+ emit_signal(SceneStringNames::get_singleton()->body_exit, obj);
}
- eraseit=true;
-
+ eraseit = true;
}
if (node && E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, objid, obj, p_body_shape, p_area_shape);
}
if (eraseit)
body_map.erase(E);
-
}
- locked=false;
-
-
+ locked = false;
}
-
void Area::_clear_monitoring() {
if (locked) {
@@ -236,11 +218,11 @@ void Area::_clear_monitoring() {
ERR_FAIL_COND(locked);
{
- Map<ObjectID,BodyState> bmcopy = body_map;
+ Map<ObjectID, BodyState> bmcopy = body_map;
body_map.clear();
//disconnect all monitored stuff
- for (Map<ObjectID,BodyState>::Element *E=bmcopy.front();E;E=E->next()) {
+ for (Map<ObjectID, BodyState>::Element *E = bmcopy.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
@@ -248,26 +230,25 @@ void Area::_clear_monitoring() {
if (!E->get().in_tree)
continue;
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,E->key(),node,E->get().shapes[i].body_shape,E->get().shapes[i].area_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, E->key(), node, E->get().shapes[i].body_shape, E->get().shapes[i].area_shape);
}
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->body_exit, obj);
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree);
}
-
}
{
- Map<ObjectID,AreaState> bmcopy = area_map;
+ Map<ObjectID, AreaState> bmcopy = area_map;
area_map.clear();
//disconnect all monitored stuff
- for (Map<ObjectID,AreaState>::Element *E=bmcopy.front();E;E=E->next()) {
+ for (Map<ObjectID, AreaState>::Element *E = bmcopy.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
Node *node = obj ? obj->cast_to<Node>() : NULL;
@@ -275,22 +256,21 @@ void Area::_clear_monitoring() {
if (!E->get().in_tree)
continue;
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,E->key(),node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape, E->key(), node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
- emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->area_exit, obj);
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_area_exit_tree);
}
}
-
}
void Area::_notification(int p_what) {
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
_clear_monitoring();
}
}
@@ -302,41 +282,38 @@ void Area::set_enable_monitoring(bool p_enable) {
}
ERR_FAIL_COND(locked);
- if (p_enable==monitoring)
+ if (p_enable == monitoring)
return;
- monitoring=p_enable;
+ monitoring = p_enable;
if (monitoring) {
- PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(),this,SceneStringNames::get_singleton()->_body_inout);
- PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(),this,SceneStringNames::get_singleton()->_area_inout);
+ PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_body_inout);
+ PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(), this, SceneStringNames::get_singleton()->_area_inout);
} else {
- PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(),NULL,StringName());
- PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(),NULL,StringName());
+ PhysicsServer::get_singleton()->area_set_monitor_callback(get_rid(), NULL, StringName());
+ PhysicsServer::get_singleton()->area_set_area_monitor_callback(get_rid(), NULL, StringName());
_clear_monitoring();
-
}
}
-
void Area::_area_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,AreaState>::Element *E=area_map.find(p_id);
+ Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_tree);
- E->get().in_tree=true;
- emit_signal(SceneStringNames::get_singleton()->area_enter,node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ E->get().in_tree = true;
+ emit_signal(SceneStringNames::get_singleton()->area_enter, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->area_enter_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_enter_shape, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
-
}
void Area::_area_exit_tree(ObjectID p_id) {
@@ -344,56 +321,51 @@ void Area::_area_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,AreaState>::Element *E=area_map.find(p_id);
+ Map<ObjectID, AreaState>::Element *E = area_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
- E->get().in_tree=false;
- emit_signal(SceneStringNames::get_singleton()->area_exit,node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ E->get().in_tree = false;
+ emit_signal(SceneStringNames::get_singleton()->area_exit, node);
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,p_id,node,E->get().shapes[i].area_shape,E->get().shapes[i].self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape, p_id, node, E->get().shapes[i].area_shape, E->get().shapes[i].self_shape);
}
-
}
-void Area::_area_inout(int p_status,const RID& p_area, int p_instance, int p_area_shape,int p_self_shape) {
-
+void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_area_shape, int p_self_shape) {
- bool area_in = p_status==PhysicsServer::AREA_BODY_ADDED;
- ObjectID objid=p_instance;
+ bool area_in = p_status == PhysicsServer::AREA_BODY_ADDED;
+ ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
Node *node = obj ? obj->cast_to<Node>() : NULL;
- Map<ObjectID,AreaState>::Element *E=area_map.find(objid);
+ Map<ObjectID, AreaState>::Element *E = area_map.find(objid);
ERR_FAIL_COND(!area_in && !E);
- locked=true;
+ locked = true;
if (area_in) {
if (!E) {
- E = area_map.insert(objid,AreaState());
- E->get().rc=0;
- E->get().in_tree=node && node->is_inside_tree();
+ E = area_map.insert(objid, AreaState());
+ E->get().rc = 0;
+ E->get().in_tree = node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_enter,node);
-
+ emit_signal(SceneStringNames::get_singleton()->area_enter, node);
}
}
-
}
E->get().rc++;
if (node)
- E->get().shapes.insert(AreaShapePair(p_area_shape,p_self_shape));
-
+ E->get().shapes.insert(AreaShapePair(p_area_shape, p_self_shape));
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_enter_shape,objid,node,p_area_shape,p_self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_enter_shape, objid, node, p_area_shape, p_self_shape);
}
} else {
@@ -401,36 +373,31 @@ void Area::_area_inout(int p_status,const RID& p_area, int p_instance, int p_are
E->get().rc--;
if (node)
- E->get().shapes.erase(AreaShapePair(p_area_shape,p_self_shape));
+ E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape));
- bool eraseit=false;
+ bool eraseit = false;
- if (E->get().rc==0) {
+ if (E->get().rc == 0) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_area_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_area_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_area_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_area_exit_tree);
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_exit,obj);
+ emit_signal(SceneStringNames::get_singleton()->area_exit, obj);
}
-
}
- eraseit=true;
-
+ eraseit = true;
}
if (!node || E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->area_exit_shape,objid,obj,p_area_shape,p_self_shape);
+ emit_signal(SceneStringNames::get_singleton()->area_exit_shape, objid, obj, p_area_shape, p_self_shape);
}
if (eraseit)
area_map.erase(E);
-
}
- locked=false;
-
-
+ locked = false;
}
bool Area::is_monitoring_enabled() const {
@@ -438,21 +405,19 @@ bool Area::is_monitoring_enabled() const {
return monitoring;
}
-
Array Area::get_overlapping_bodies() const {
- ERR_FAIL_COND_V(!monitoring,Array());
+ ERR_FAIL_COND_V(!monitoring, Array());
Array ret;
ret.resize(body_map.size());
- int idx=0;
- for (const Map<ObjectID,BodyState>::Element *E=body_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (const Map<ObjectID, BodyState>::Element *E = body_map.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
if (!obj) {
- ret.resize( ret.size() -1 ); //ops
+ ret.resize(ret.size() - 1); //ops
} else {
- ret[idx++]=obj;
+ ret[idx++] = obj;
}
-
}
return ret;
@@ -465,12 +430,12 @@ void Area::set_monitorable(bool p_enable) {
}
ERR_FAIL_COND(locked);
- if (p_enable==monitorable)
+ if (p_enable == monitorable)
return;
- monitorable=p_enable;
+ monitorable = p_enable;
- PhysicsServer::get_singleton()->area_set_monitorable(get_rid(),monitorable);
+ PhysicsServer::get_singleton()->area_set_monitorable(get_rid(), monitorable);
}
bool Area::is_monitorable() const {
@@ -478,51 +443,45 @@ bool Area::is_monitorable() const {
return monitorable;
}
-
Array Area::get_overlapping_areas() const {
- ERR_FAIL_COND_V(!monitoring,Array());
+ ERR_FAIL_COND_V(!monitoring, Array());
Array ret;
ret.resize(area_map.size());
- int idx=0;
- for (const Map<ObjectID,AreaState>::Element *E=area_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (const Map<ObjectID, AreaState>::Element *E = area_map.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
if (!obj) {
- ret.resize( ret.size() -1 ); //ops
+ ret.resize(ret.size() - 1); //ops
} else {
- ret[idx++]=obj;
+ ret[idx++] = obj;
}
-
}
return ret;
}
-bool Area::overlaps_area(Node* p_area) const {
+bool Area::overlaps_area(Node *p_area) const {
- ERR_FAIL_NULL_V(p_area,false);
- const Map<ObjectID,AreaState>::Element *E=area_map.find(p_area->get_instance_ID());
+ ERR_FAIL_NULL_V(p_area, false);
+ const Map<ObjectID, AreaState>::Element *E = area_map.find(p_area->get_instance_ID());
if (!E)
return false;
return E->get().in_tree;
-
-
-
}
-bool Area::overlaps_body(Node* p_body) const{
+bool Area::overlaps_body(Node *p_body) const {
- ERR_FAIL_NULL_V(p_body,false);
- const Map<ObjectID,BodyState>::Element *E=body_map.find(p_body->get_instance_ID());
+ ERR_FAIL_NULL_V(p_body, false);
+ const Map<ObjectID, BodyState>::Element *E = body_map.find(p_body->get_instance_ID());
if (!E)
return false;
return E->get().in_tree;
-
}
void Area::set_collision_mask(uint32_t p_mask) {
- collision_mask=p_mask;
- PhysicsServer::get_singleton()->area_set_collision_mask(get_rid(),p_mask);
+ collision_mask = p_mask;
+ PhysicsServer::get_singleton()->area_set_collision_mask(get_rid(), p_mask);
}
uint32_t Area::get_collision_mask() const {
@@ -531,8 +490,8 @@ uint32_t Area::get_collision_mask() const {
}
void Area::set_layer_mask(uint32_t p_mask) {
- layer_mask=p_mask;
- PhysicsServer::get_singleton()->area_set_layer_mask(get_rid(),p_mask);
+ layer_mask = p_mask;
+ PhysicsServer::get_singleton()->area_set_layer_mask(get_rid(), p_mask);
}
uint32_t Area::get_layer_mask() const {
@@ -544,143 +503,134 @@ void Area::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
- mask|=1<<p_bit;
+ mask |= 1 << p_bit;
else
- mask&=~(1<<p_bit);
+ mask &= ~(1 << p_bit);
set_collision_mask(mask);
-
}
-bool Area::get_collision_mask_bit(int p_bit) const{
+bool Area::get_collision_mask_bit(int p_bit) const {
- return get_collision_mask()&(1<<p_bit);
+ return get_collision_mask() & (1 << p_bit);
}
-
void Area::set_layer_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_layer_mask();
if (p_value)
- mask|=1<<p_bit;
+ mask |= 1 << p_bit;
else
- mask&=~(1<<p_bit);
+ mask &= ~(1 << p_bit);
set_layer_mask(mask);
-
}
-bool Area::get_layer_mask_bit(int p_bit) const{
+bool Area::get_layer_mask_bit(int p_bit) const {
- return get_layer_mask()&(1<<p_bit);
+ return get_layer_mask() & (1 << p_bit);
}
-
void Area::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_body_enter_tree","id"),&Area::_body_enter_tree);
- ObjectTypeDB::bind_method(_MD("_body_exit_tree","id"),&Area::_body_exit_tree);
+ ObjectTypeDB::bind_method(_MD("_body_enter_tree", "id"), &Area::_body_enter_tree);
+ ObjectTypeDB::bind_method(_MD("_body_exit_tree", "id"), &Area::_body_exit_tree);
- ObjectTypeDB::bind_method(_MD("_area_enter_tree","id"),&Area::_area_enter_tree);
- ObjectTypeDB::bind_method(_MD("_area_exit_tree","id"),&Area::_area_exit_tree);
+ ObjectTypeDB::bind_method(_MD("_area_enter_tree", "id"), &Area::_area_enter_tree);
+ ObjectTypeDB::bind_method(_MD("_area_exit_tree", "id"), &Area::_area_exit_tree);
- ObjectTypeDB::bind_method(_MD("set_space_override_mode","enable"),&Area::set_space_override_mode);
- ObjectTypeDB::bind_method(_MD("get_space_override_mode"),&Area::get_space_override_mode);
+ ObjectTypeDB::bind_method(_MD("set_space_override_mode", "enable"), &Area::set_space_override_mode);
+ ObjectTypeDB::bind_method(_MD("get_space_override_mode"), &Area::get_space_override_mode);
- ObjectTypeDB::bind_method(_MD("set_gravity_is_point","enable"),&Area::set_gravity_is_point);
- ObjectTypeDB::bind_method(_MD("is_gravity_a_point"),&Area::is_gravity_a_point);
+ ObjectTypeDB::bind_method(_MD("set_gravity_is_point", "enable"), &Area::set_gravity_is_point);
+ ObjectTypeDB::bind_method(_MD("is_gravity_a_point"), &Area::is_gravity_a_point);
- ObjectTypeDB::bind_method(_MD("set_gravity_distance_scale","distance_scale"),&Area::set_gravity_distance_scale);
- ObjectTypeDB::bind_method(_MD("get_gravity_distance_scale"),&Area::get_gravity_distance_scale);
+ ObjectTypeDB::bind_method(_MD("set_gravity_distance_scale", "distance_scale"), &Area::set_gravity_distance_scale);
+ ObjectTypeDB::bind_method(_MD("get_gravity_distance_scale"), &Area::get_gravity_distance_scale);
- ObjectTypeDB::bind_method(_MD("set_gravity_vector","vector"),&Area::set_gravity_vector);
- ObjectTypeDB::bind_method(_MD("get_gravity_vector"),&Area::get_gravity_vector);
+ ObjectTypeDB::bind_method(_MD("set_gravity_vector", "vector"), &Area::set_gravity_vector);
+ ObjectTypeDB::bind_method(_MD("get_gravity_vector"), &Area::get_gravity_vector);
- ObjectTypeDB::bind_method(_MD("set_gravity","gravity"),&Area::set_gravity);
- ObjectTypeDB::bind_method(_MD("get_gravity"),&Area::get_gravity);
+ ObjectTypeDB::bind_method(_MD("set_gravity", "gravity"), &Area::set_gravity);
+ ObjectTypeDB::bind_method(_MD("get_gravity"), &Area::get_gravity);
- ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&Area::set_angular_damp);
- ObjectTypeDB::bind_method(_MD("get_angular_damp"),&Area::get_angular_damp);
+ ObjectTypeDB::bind_method(_MD("set_angular_damp", "angular_damp"), &Area::set_angular_damp);
+ ObjectTypeDB::bind_method(_MD("get_angular_damp"), &Area::get_angular_damp);
- ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&Area::set_linear_damp);
- ObjectTypeDB::bind_method(_MD("get_linear_damp"),&Area::get_linear_damp);
+ ObjectTypeDB::bind_method(_MD("set_linear_damp", "linear_damp"), &Area::set_linear_damp);
+ ObjectTypeDB::bind_method(_MD("get_linear_damp"), &Area::get_linear_damp);
- ObjectTypeDB::bind_method(_MD("set_priority","priority"),&Area::set_priority);
- ObjectTypeDB::bind_method(_MD("get_priority"),&Area::get_priority);
+ ObjectTypeDB::bind_method(_MD("set_priority", "priority"), &Area::set_priority);
+ ObjectTypeDB::bind_method(_MD("get_priority"), &Area::get_priority);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&Area::get_collision_mask);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask", "collision_mask"), &Area::set_collision_mask);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask"), &Area::get_collision_mask);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&Area::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask", "layer_mask"), &Area::set_layer_mask);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask"), &Area::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&Area::set_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&Area::get_collision_mask_bit);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask_bit", "bit", "value"), &Area::set_collision_mask_bit);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask_bit", "bit"), &Area::get_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&Area::set_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&Area::get_layer_mask_bit);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask_bit", "bit", "value"), &Area::set_layer_mask_bit);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask_bit", "bit"), &Area::get_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_monitorable","enable"),&Area::set_monitorable);
- ObjectTypeDB::bind_method(_MD("is_monitorable"),&Area::is_monitorable);
+ ObjectTypeDB::bind_method(_MD("set_monitorable", "enable"), &Area::set_monitorable);
+ ObjectTypeDB::bind_method(_MD("is_monitorable"), &Area::is_monitorable);
+ ObjectTypeDB::bind_method(_MD("set_enable_monitoring", "enable"), &Area::set_enable_monitoring);
+ ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"), &Area::is_monitoring_enabled);
- ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area::set_enable_monitoring);
- ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area::is_monitoring_enabled);
+ ObjectTypeDB::bind_method(_MD("get_overlapping_bodies"), &Area::get_overlapping_bodies);
+ ObjectTypeDB::bind_method(_MD("get_overlapping_areas"), &Area::get_overlapping_areas);
- ObjectTypeDB::bind_method(_MD("get_overlapping_bodies"),&Area::get_overlapping_bodies);
- ObjectTypeDB::bind_method(_MD("get_overlapping_areas"),&Area::get_overlapping_areas);
+ ObjectTypeDB::bind_method(_MD("overlaps_body", "body"), &Area::overlaps_body);
+ ObjectTypeDB::bind_method(_MD("overlaps_area", "area"), &Area::overlaps_area);
- ObjectTypeDB::bind_method(_MD("overlaps_body","body"),&Area::overlaps_body);
- ObjectTypeDB::bind_method(_MD("overlaps_area","area"),&Area::overlaps_area);
+ ObjectTypeDB::bind_method(_MD("_body_inout"), &Area::_body_inout);
+ ObjectTypeDB::bind_method(_MD("_area_inout"), &Area::_area_inout);
- ObjectTypeDB::bind_method(_MD("_body_inout"),&Area::_body_inout);
- ObjectTypeDB::bind_method(_MD("_area_inout"),&Area::_area_inout);
+ ADD_SIGNAL(MethodInfo("body_enter_shape", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
+ ADD_SIGNAL(MethodInfo("body_exit_shape", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape")));
+ ADD_SIGNAL(MethodInfo("body_enter", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("body_exit", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("area_enter_shape", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
+ ADD_SIGNAL(MethodInfo("area_exit_shape", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape")));
+ ADD_SIGNAL(MethodInfo("area_enter", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area")));
+ ADD_SIGNAL(MethodInfo("area_exit", PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area")));
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"area_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
-
- ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
- ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape")));
- ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
- ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_gravity"),_SCS("get_gravity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"linear_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_damp",PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
-
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "space_override", PROPERTY_HINT_ENUM, "Disabled,Combine,Combine-Replace,Replace,Replace-Combine"), _SCS("set_space_override_mode"), _SCS("get_space_override_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gravity_point"), _SCS("set_gravity_is_point"), _SCS("is_gravity_a_point"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_distance_scale", PROPERTY_HINT_RANGE, "0,1024,0.001"), _SCS("set_gravity_distance_scale"), _SCS("get_gravity_distance_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity_vec"), _SCS("set_gravity_vector"), _SCS("get_gravity_vector"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), _SCS("set_gravity"), _SCS("get_gravity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_damp", PROPERTY_HINT_RANGE, "0,1024,0.001"), _SCS("set_linear_damp"), _SCS("get_linear_damp"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_damp", PROPERTY_HINT_RANGE, "0,1024,0.001"), _SCS("set_angular_damp"), _SCS("get_angular_damp"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "priority", PROPERTY_HINT_RANGE, "0,128,1"), _SCS("set_priority"), _SCS("get_priority"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitoring"), _SCS("set_enable_monitoring"), _SCS("is_monitoring_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "monitorable"), _SCS("set_monitorable"), _SCS("is_monitorable"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision/layers", PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision/mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_collision_mask"), _SCS("get_collision_mask"));
}
-Area::Area() : CollisionObject(PhysicsServer::get_singleton()->area_create(),true) {
+Area::Area()
+ : CollisionObject(PhysicsServer::get_singleton()->area_create(), true) {
- space_override=SPACE_OVERRIDE_DISABLED;
+ space_override = SPACE_OVERRIDE_DISABLED;
set_gravity(9.8);
- locked=false;
- set_gravity_vector(Vector3(0,-1,0));
- gravity_is_point=false;
- gravity_distance_scale=0;
- linear_damp=0.1;
- angular_damp=1;
- priority=0;
- monitoring=false;
- collision_mask=1;
- layer_mask=1;
+ locked = false;
+ set_gravity_vector(Vector3(0, -1, 0));
+ gravity_is_point = false;
+ gravity_distance_scale = 0;
+ linear_damp = 0.1;
+ angular_damp = 1;
+ priority = 0;
+ monitoring = false;
+ collision_mask = 1;
+ layer_mask = 1;
set_ray_pickable(false);
set_enable_monitoring(true);
set_monitorable(true);
-
}
Area::~Area() {
-
-
}
diff --git a/scene/3d/area.h b/scene/3d/area.h
index 7ff5755d9..75c66c88b 100644
--- a/scene/3d/area.h
+++ b/scene/3d/area.h
@@ -34,9 +34,9 @@
class Area : public CollisionObject {
- OBJ_TYPE( Area, CollisionObject );
-public:
+ OBJ_TYPE(Area, CollisionObject);
+public:
enum SpaceOverride {
SPACE_OVERRIDE_DISABLED,
SPACE_OVERRIDE_COMBINE,
@@ -44,9 +44,8 @@ public:
SPACE_OVERRIDE_REPLACE,
SPACE_OVERRIDE_REPLACE_COMBINE
};
-private:
-
+private:
SpaceOverride space_override;
Vector3 gravity_vec;
real_t gravity;
@@ -61,8 +60,7 @@ private:
bool monitorable;
bool locked;
-
- void _body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape);
+ void _body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape);
void _body_enter_tree(ObjectID p_id);
void _body_exit_tree(ObjectID p_id);
@@ -71,15 +69,18 @@ private:
int body_shape;
int area_shape;
- bool operator<(const ShapePair& p_sp) const {
- if (body_shape==p_sp.body_shape)
+ bool operator<(const ShapePair &p_sp) const {
+ if (body_shape == p_sp.body_shape)
return area_shape < p_sp.area_shape;
else
return body_shape < p_sp.body_shape;
}
ShapePair() {}
- ShapePair(int p_bs, int p_as) { body_shape=p_bs; area_shape=p_as; }
+ ShapePair(int p_bs, int p_as) {
+ body_shape = p_bs;
+ area_shape = p_as;
+ }
};
struct BodyState {
@@ -89,10 +90,9 @@ private:
VSet<ShapePair> shapes;
};
- Map<ObjectID,BodyState> body_map;
+ Map<ObjectID, BodyState> body_map;
-
- void _area_inout(int p_status,const RID& p_area, int p_instance, int p_area_shape,int p_self_shape);
+ void _area_inout(int p_status, const RID &p_area, int p_instance, int p_area_shape, int p_self_shape);
void _area_enter_tree(ObjectID p_id);
void _area_exit_tree(ObjectID p_id);
@@ -101,15 +101,18 @@ private:
int area_shape;
int self_shape;
- bool operator<(const AreaShapePair& p_sp) const {
- if (area_shape==p_sp.area_shape)
+ bool operator<(const AreaShapePair &p_sp) const {
+ if (area_shape == p_sp.area_shape)
return self_shape < p_sp.self_shape;
else
return area_shape < p_sp.area_shape;
}
AreaShapePair() {}
- AreaShapePair(int p_bs, int p_as) { area_shape=p_bs; self_shape=p_as; }
+ AreaShapePair(int p_bs, int p_as) {
+ area_shape = p_bs;
+ self_shape = p_as;
+ }
};
struct AreaState {
@@ -119,16 +122,14 @@ private:
VSet<AreaShapePair> shapes;
};
- Map<ObjectID,AreaState> area_map;
+ Map<ObjectID, AreaState> area_map;
void _clear_monitoring();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_space_override_mode(SpaceOverride p_mode);
SpaceOverride get_space_override_mode() const;
@@ -138,7 +139,7 @@ public:
void set_gravity_distance_scale(real_t p_scale);
real_t get_gravity_distance_scale() const;
- void set_gravity_vector(const Vector3& p_vec);
+ void set_gravity_vector(const Vector3 &p_vec);
Vector3 get_gravity_vector() const;
void set_gravity(real_t p_gravity);
@@ -174,9 +175,8 @@ public:
Array get_overlapping_bodies() const;
Array get_overlapping_areas() const; //function for script
- bool overlaps_area(Node* p_area) const;
- bool overlaps_body(Node* p_body) const;
-
+ bool overlaps_area(Node *p_area) const;
+ bool overlaps_body(Node *p_body) const;
Area();
~Area();
diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp
index ed1984db2..e39450d7a 100644
--- a/scene/3d/baked_light_instance.cpp
+++ b/scene/3d/baked_light_instance.cpp
@@ -29,26 +29,24 @@
#include "baked_light_instance.h"
#include "scene/scene_string_names.h"
-
RID BakedLightInstance::get_baked_light_instance() const {
if (baked_light.is_null())
return RID();
else
return get_instance();
-
}
-void BakedLightInstance::set_baked_light(const Ref<BakedLight>& p_baked_light) {
+void BakedLightInstance::set_baked_light(const Ref<BakedLight> &p_baked_light) {
- baked_light=p_baked_light;
+ baked_light = p_baked_light;
RID base_rid;
if (baked_light.is_valid())
- base_rid=baked_light->get_rid();
+ base_rid = baked_light->get_rid();
else
- base_rid=RID();
+ base_rid = RID();
set_base(base_rid);
@@ -56,29 +54,28 @@ void BakedLightInstance::set_baked_light(const Ref<BakedLight>& p_baked_light) {
emit_signal(SceneStringNames::get_singleton()->baked_light_changed);
-// for (List<Node*>::Element *E=baked_geometry.front();E;E=E->next()) {
-// VS::get_singleton()->instance_geometry_set_baked_light(E->get()->get_instance(),baked_light.is_valid()?get_instance():RID());
-// }
+ // for (List<Node*>::Element *E=baked_geometry.front();E;E=E->next()) {
+ // VS::get_singleton()->instance_geometry_set_baked_light(E->get()->get_instance(),baked_light.is_valid()?get_instance():RID());
+ // }
}
update_configuration_warning();
}
-Ref<BakedLight> BakedLightInstance::get_baked_light() const{
+Ref<BakedLight> BakedLightInstance::get_baked_light() const {
return baked_light;
}
AABB BakedLightInstance::get_aabb() const {
- return AABB(Vector3(0,0,0),Vector3(1,1,1));
+ return AABB(Vector3(0, 0, 0), Vector3(1, 1, 1));
}
DVector<Face3> BakedLightInstance::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
}
-
String BakedLightInstance::get_configuration_warning() const {
if (get_baked_light().is_null()) {
return TTR("BakedLightInstance does not contain a BakedLight resource.");
@@ -86,42 +83,37 @@ String BakedLightInstance::get_configuration_warning() const {
return String();
}
-
void BakedLightInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_baked_light","baked_light"),&BakedLightInstance::set_baked_light);
- ObjectTypeDB::bind_method(_MD("get_baked_light"),&BakedLightInstance::get_baked_light);
- ObjectTypeDB::bind_method(_MD("get_baked_light_instance"),&BakedLightInstance::get_baked_light_instance);
+ ObjectTypeDB::bind_method(_MD("set_baked_light", "baked_light"), &BakedLightInstance::set_baked_light);
+ ObjectTypeDB::bind_method(_MD("get_baked_light"), &BakedLightInstance::get_baked_light);
+ ObjectTypeDB::bind_method(_MD("get_baked_light_instance"), &BakedLightInstance::get_baked_light_instance);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"baked_light",PROPERTY_HINT_RESOURCE_TYPE,"BakedLight"),_SCS("set_baked_light"),_SCS("get_baked_light"));
- ADD_SIGNAL( MethodInfo("baked_light_changed"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "baked_light", PROPERTY_HINT_RESOURCE_TYPE, "BakedLight"), _SCS("set_baked_light"), _SCS("get_baked_light"));
+ ADD_SIGNAL(MethodInfo("baked_light_changed"));
}
BakedLightInstance::BakedLightInstance() {
-
-
}
/////////////////////////
-
-void BakedLightSampler::set_param(Param p_param,float p_value) {
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
- VS::get_singleton()->baked_light_sampler_set_param(base,VS::BakedLightSamplerParam(p_param),p_value);
+void BakedLightSampler::set_param(Param p_param, float p_value) {
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params[p_param] = p_value;
+ VS::get_singleton()->baked_light_sampler_set_param(base, VS::BakedLightSamplerParam(p_param), p_value);
}
-float BakedLightSampler::get_param(Param p_param) const{
+float BakedLightSampler::get_param(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
-
}
-void BakedLightSampler::set_resolution(int p_resolution){
+void BakedLightSampler::set_resolution(int p_resolution) {
- ERR_FAIL_COND(p_resolution<4 || p_resolution>32);
- resolution=p_resolution;
- VS::get_singleton()->baked_light_sampler_set_resolution(base,resolution);
+ ERR_FAIL_COND(p_resolution < 4 || p_resolution > 32);
+ resolution = p_resolution;
+ VS::get_singleton()->baked_light_sampler_set_resolution(base, resolution);
}
int BakedLightSampler::get_resolution() const {
@@ -131,7 +123,7 @@ int BakedLightSampler::get_resolution() const {
AABB BakedLightSampler::get_aabb() const {
float r = get_param(PARAM_RADIUS);
- return AABB( Vector3(-r,-r,-r),Vector3(r*2,r*2,r*2));
+ return AABB(Vector3(-r, -r, -r), Vector3(r * 2, r * 2, r * 2));
}
DVector<Face3> BakedLightSampler::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
@@ -139,26 +131,24 @@ DVector<Face3> BakedLightSampler::get_faces(uint32_t p_usage_flags) const {
void BakedLightSampler::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&BakedLightSampler::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&BakedLightSampler::get_param);
-
- ObjectTypeDB::bind_method(_MD("set_resolution","resolution"),&BakedLightSampler::set_resolution);
- ObjectTypeDB::bind_method(_MD("get_resolution"),&BakedLightSampler::get_resolution);
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &BakedLightSampler::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &BakedLightSampler::get_param);
+ ObjectTypeDB::bind_method(_MD("set_resolution", "resolution"), &BakedLightSampler::set_resolution);
+ ObjectTypeDB::bind_method(_MD("get_resolution"), &BakedLightSampler::get_resolution);
- BIND_CONSTANT( PARAM_RADIUS );
- BIND_CONSTANT( PARAM_STRENGTH );
- BIND_CONSTANT( PARAM_ATTENUATION );
- BIND_CONSTANT( PARAM_DETAIL_RATIO );
- BIND_CONSTANT( PARAM_MAX );
-
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/radius",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_RADIUS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/strength",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_STRENGTH);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/attenuation",PROPERTY_HINT_EXP_EASING),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0.01,1.0,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
-// ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0,20,1"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"params/resolution",PROPERTY_HINT_RANGE,"4,32,1"),_SCS("set_resolution"),_SCS("get_resolution"));
+ BIND_CONSTANT(PARAM_RADIUS);
+ BIND_CONSTANT(PARAM_STRENGTH);
+ BIND_CONSTANT(PARAM_ATTENUATION);
+ BIND_CONSTANT(PARAM_DETAIL_RATIO);
+ BIND_CONSTANT(PARAM_MAX);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/radius", PROPERTY_HINT_RANGE, "0.01,1024,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_RADIUS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/strength", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_STRENGTH);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/detail_ratio", PROPERTY_HINT_RANGE, "0.01,1.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_DETAIL_RATIO);
+ // ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/detail_ratio",PROPERTY_HINT_RANGE,"0,20,1"),_SCS("set_param"),_SCS("get_param"),PARAM_DETAIL_RATIO);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "params/resolution", PROPERTY_HINT_RANGE, "4,32,1"), _SCS("set_resolution"), _SCS("get_resolution"));
}
BakedLightSampler::BakedLightSampler() {
@@ -166,16 +156,14 @@ BakedLightSampler::BakedLightSampler() {
base = VS::get_singleton()->baked_light_sampler_create();
set_base(base);
- params[PARAM_RADIUS]=1.0;
- params[PARAM_STRENGTH]=1.0;
- params[PARAM_ATTENUATION]=1.0;
- params[PARAM_DETAIL_RATIO]=0.1;
- resolution=16;
-
-
+ params[PARAM_RADIUS] = 1.0;
+ params[PARAM_STRENGTH] = 1.0;
+ params[PARAM_ATTENUATION] = 1.0;
+ params[PARAM_DETAIL_RATIO] = 0.1;
+ resolution = 16;
}
-BakedLightSampler::~BakedLightSampler(){
+BakedLightSampler::~BakedLightSampler() {
VS::get_singleton()->free(base);
}
diff --git a/scene/3d/baked_light_instance.h b/scene/3d/baked_light_instance.h
index a31b0b0da..99bc4b8c1 100644
--- a/scene/3d/baked_light_instance.h
+++ b/scene/3d/baked_light_instance.h
@@ -34,22 +34,18 @@
class BakedLightBaker;
-
class BakedLightInstance : public VisualInstance {
- OBJ_TYPE(BakedLightInstance,VisualInstance);
+ OBJ_TYPE(BakedLightInstance, VisualInstance);
Ref<BakedLight> baked_light;
-
protected:
-
static void _bind_methods();
-public:
-
+public:
RID get_baked_light_instance() const;
- void set_baked_light(const Ref<BakedLight>& baked_light);
+ void set_baked_light(const Ref<BakedLight> &baked_light);
Ref<BakedLight> get_baked_light() const;
virtual AABB get_aabb() const;
@@ -60,36 +56,29 @@ public:
BakedLightInstance();
};
-
-
class BakedLightSampler : public VisualInstance {
- OBJ_TYPE(BakedLightSampler,VisualInstance);
-
+ OBJ_TYPE(BakedLightSampler, VisualInstance);
public:
-
enum Param {
- PARAM_RADIUS=VS::BAKED_LIGHT_SAMPLER_RADIUS,
- PARAM_STRENGTH=VS::BAKED_LIGHT_SAMPLER_STRENGTH,
- PARAM_ATTENUATION=VS::BAKED_LIGHT_SAMPLER_ATTENUATION,
- PARAM_DETAIL_RATIO=VS::BAKED_LIGHT_SAMPLER_DETAIL_RATIO,
- PARAM_MAX=VS::BAKED_LIGHT_SAMPLER_MAX
+ PARAM_RADIUS = VS::BAKED_LIGHT_SAMPLER_RADIUS,
+ PARAM_STRENGTH = VS::BAKED_LIGHT_SAMPLER_STRENGTH,
+ PARAM_ATTENUATION = VS::BAKED_LIGHT_SAMPLER_ATTENUATION,
+ PARAM_DETAIL_RATIO = VS::BAKED_LIGHT_SAMPLER_DETAIL_RATIO,
+ PARAM_MAX = VS::BAKED_LIGHT_SAMPLER_MAX
};
-
-
protected:
-
RID base;
float params[PARAM_MAX];
int resolution;
static void _bind_methods();
-public:
+public:
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- void set_param(Param p_param,float p_value);
+ void set_param(Param p_param, float p_value);
float get_param(Param p_param) const;
void set_resolution(int p_resolution);
@@ -99,7 +88,6 @@ public:
~BakedLightSampler();
};
-VARIANT_ENUM_CAST( BakedLightSampler::Param );
-
+VARIANT_ENUM_CAST(BakedLightSampler::Param);
#endif // BAKED_LIGHT_H
diff --git a/scene/3d/body_shape.cpp b/scene/3d/body_shape.cpp
index 62f41e860..1807e00a4 100644
--- a/scene/3d/body_shape.cpp
+++ b/scene/3d/body_shape.cpp
@@ -27,14 +27,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "body_shape.h"
-#include "servers/visual_server.h"
-#include "scene/resources/sphere_shape.h"
-#include "scene/resources/ray_shape.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/concave_polygon_shape.h"
+#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/plane_shape.h"
+#include "scene/resources/ray_shape.h"
+#include "scene/resources/sphere_shape.h"
+#include "servers/visual_server.h"
//TODO: Implement CylinderShape and HeightMapShape?
#include "mesh_instance.h"
#include "physics_body.h"
@@ -48,7 +48,6 @@ void CollisionShape::_update_body() {
return;
if (get_parent() && get_parent()->cast_to<CollisionObject>())
get_parent()->cast_to<CollisionObject>()->_update_shapes_from_children();
-
}
void CollisionShape::make_convex_from_brothers() {
@@ -57,12 +56,12 @@ void CollisionShape::make_convex_from_brothers() {
if (!p)
return;
- for(int i=0;i<p->get_child_count();i++) {
+ for (int i = 0; i < p->get_child_count(); i++) {
Node *n = p->get_child(i);
if (n->cast_to<MeshInstance>()) {
- MeshInstance *mi=n->cast_to<MeshInstance>();
+ MeshInstance *mi = n->cast_to<MeshInstance>();
Ref<Mesh> m = mi->get_mesh();
if (m.is_valid()) {
@@ -71,7 +70,6 @@ void CollisionShape::make_convex_from_brothers() {
}
}
}
-
}
/*
@@ -302,32 +300,32 @@ void CollisionShape::_update_indicator() {
}
*/
-void CollisionShape::_add_to_collision_object(Object* p_cshape) {
+void CollisionShape::_add_to_collision_object(Object *p_cshape) {
if (unparenting)
return;
- CollisionObject *co=p_cshape->cast_to<CollisionObject>();
+ CollisionObject *co = p_cshape->cast_to<CollisionObject>();
ERR_FAIL_COND(!co);
if (shape.is_valid()) {
- update_shape_index=co->get_shape_count();
- co->add_shape(shape,get_transform());
+ update_shape_index = co->get_shape_count();
+ co->add_shape(shape, get_transform());
if (trigger)
- co->set_shape_as_trigger( co->get_shape_count() -1, true );
+ co->set_shape_as_trigger(co->get_shape_count() - 1, true);
} else {
- update_shape_index=-1;
+ update_shape_index = -1;
}
}
void CollisionShape::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- unparenting=false;
- can_update_body=get_tree()->is_editor_hint();
+ unparenting = false;
+ can_update_body = get_tree()->is_editor_hint();
set_notify_local_transform(!can_update_body);
if (get_tree()->is_debugging_collisions_hint()) {
@@ -337,25 +335,25 @@ void CollisionShape::_notification(int p_what) {
//indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- // VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
+ // VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
if (can_update_body && updating_body) {
_update_body();
}
} break;
case NOTIFICATION_EXIT_TREE: {
- /* if (indicator_instance.is_valid()) {
+ /* if (indicator_instance.is_valid()) {
VisualServer::get_singleton()->free(indicator_instance);
indicator_instance=RID();
}*/
- can_update_body=false;
+ can_update_body = false;
set_notify_local_transform(false);
if (debug_shape) {
debug_shape->queue_delete();
- debug_shape=NULL;
+ debug_shape = NULL;
}
} break;
case NOTIFICATION_UNPARENTED: {
- unparenting=true;
+ unparenting = true;
if (can_update_body && updating_body)
_update_body();
} break;
@@ -365,34 +363,29 @@ void CollisionShape::_notification(int p_what) {
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
- if (!can_update_body && update_shape_index>=0) {
+ if (!can_update_body && update_shape_index >= 0) {
CollisionObject *co = get_parent()->cast_to<CollisionObject>();
if (co) {
- co->set_shape_transform(update_shape_index,get_transform());
+ co->set_shape_transform(update_shape_index, get_transform());
}
}
} break;
-
}
}
-
void CollisionShape::resource_changed(RES res) {
update_gizmo();
-
-
}
void CollisionShape::_set_update_shape_index(int p_index) {
-
- update_shape_index=p_index;
+ update_shape_index = p_index;
}
-int CollisionShape::_get_update_shape_index() const{
+int CollisionShape::_get_update_shape_index() const {
return update_shape_index;
}
@@ -410,45 +403,42 @@ String CollisionShape::get_configuration_warning() const {
return String();
}
-
void CollisionShape::_bind_methods() {
//not sure if this should do anything
- ObjectTypeDB::bind_method(_MD("resource_changed","resource"),&CollisionShape::resource_changed);
- ObjectTypeDB::bind_method(_MD("set_shape","shape"),&CollisionShape::set_shape);
- ObjectTypeDB::bind_method(_MD("get_shape"),&CollisionShape::get_shape);
- ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionShape::_add_to_collision_object);
- ObjectTypeDB::bind_method(_MD("set_trigger","enable"),&CollisionShape::set_trigger);
- ObjectTypeDB::bind_method(_MD("is_trigger"),&CollisionShape::is_trigger);
- ObjectTypeDB::bind_method(_MD("make_convex_from_brothers"),&CollisionShape::make_convex_from_brothers);
- ObjectTypeDB::set_method_flags("CollisionShape","make_convex_from_brothers",METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("_set_update_shape_index","index"),&CollisionShape::_set_update_shape_index);
- ObjectTypeDB::bind_method(_MD("_get_update_shape_index"),&CollisionShape::_get_update_shape_index);
+ ObjectTypeDB::bind_method(_MD("resource_changed", "resource"), &CollisionShape::resource_changed);
+ ObjectTypeDB::bind_method(_MD("set_shape", "shape"), &CollisionShape::set_shape);
+ ObjectTypeDB::bind_method(_MD("get_shape"), &CollisionShape::get_shape);
+ ObjectTypeDB::bind_method(_MD("_add_to_collision_object"), &CollisionShape::_add_to_collision_object);
+ ObjectTypeDB::bind_method(_MD("set_trigger", "enable"), &CollisionShape::set_trigger);
+ ObjectTypeDB::bind_method(_MD("is_trigger"), &CollisionShape::is_trigger);
+ ObjectTypeDB::bind_method(_MD("make_convex_from_brothers"), &CollisionShape::make_convex_from_brothers);
+ ObjectTypeDB::set_method_flags("CollisionShape", "make_convex_from_brothers", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ObjectTypeDB::bind_method(_MD("_set_update_shape_index", "index"), &CollisionShape::_set_update_shape_index);
+ ObjectTypeDB::bind_method(_MD("_get_update_shape_index"), &CollisionShape::_get_update_shape_index);
- ObjectTypeDB::bind_method(_MD("get_collision_object_shape_index"),&CollisionShape::get_collision_object_shape_index);
+ ObjectTypeDB::bind_method(_MD("get_collision_object_shape_index"), &CollisionShape::get_collision_object_shape_index);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"), _SCS("set_shape"), _SCS("get_shape"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"trigger"),_SCS("set_trigger"),_SCS("is_trigger"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "_update_shape_index", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR), _SCS("_set_update_shape_index"), _SCS("_get_update_shape_index"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"), _SCS("set_shape"), _SCS("get_shape"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trigger"), _SCS("set_trigger"), _SCS("is_trigger"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "_update_shape_index", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_update_shape_index"), _SCS("_get_update_shape_index"));
}
-
void CollisionShape::set_shape(const Ref<Shape> &p_shape) {
if (!shape.is_null())
shape->unregister_owner(this);
- shape=p_shape;
+ shape = p_shape;
if (!shape.is_null())
shape->register_owner(this);
update_gizmo();
if (updating_body) {
_update_body();
- } else if (can_update_body && update_shape_index>=0 && is_inside_tree()){
+ } else if (can_update_body && update_shape_index >= 0 && is_inside_tree()) {
CollisionObject *co = get_parent()->cast_to<CollisionObject>();
if (co) {
- co->set_shape(update_shape_index,p_shape);
+ co->set_shape(update_shape_index, p_shape);
}
-
}
}
@@ -457,9 +447,8 @@ Ref<Shape> CollisionShape::get_shape() const {
return shape;
}
-
void CollisionShape::set_updating_body(bool p_update) {
- updating_body=p_update;
+ updating_body = p_update;
}
bool CollisionShape::is_updating_body() const {
@@ -469,31 +458,31 @@ bool CollisionShape::is_updating_body() const {
void CollisionShape::set_trigger(bool p_trigger) {
- trigger=p_trigger;
- if (updating_body) {
- _update_body();
- } else if (can_update_body && update_shape_index>=0 && is_inside_tree()){
- CollisionObject *co = get_parent()->cast_to<CollisionObject>();
- if (co) {
- co->set_shape_as_trigger(update_shape_index,p_trigger);
- }
- }
+ trigger = p_trigger;
+ if (updating_body) {
+ _update_body();
+ } else if (can_update_body && update_shape_index >= 0 && is_inside_tree()) {
+ CollisionObject *co = get_parent()->cast_to<CollisionObject>();
+ if (co) {
+ co->set_shape_as_trigger(update_shape_index, p_trigger);
+ }
+ }
}
-bool CollisionShape::is_trigger() const{
+bool CollisionShape::is_trigger() const {
- return trigger;
+ return trigger;
}
CollisionShape::CollisionShape() {
//indicator = VisualServer::get_singleton()->mesh_create();
- updating_body=true;
- unparenting=false;
- update_shape_index=-1;
- trigger=false;
- can_update_body=false;
- debug_shape=NULL;
+ updating_body = true;
+ unparenting = false;
+ update_shape_index = -1;
+ trigger = false;
+ can_update_body = false;
+ debug_shape = NULL;
}
CollisionShape::~CollisionShape() {
@@ -504,10 +493,9 @@ CollisionShape::~CollisionShape() {
void CollisionShape::_create_debug_shape() {
-
if (debug_shape) {
debug_shape->queue_delete();
- debug_shape=NULL;
+ debug_shape = NULL;
}
Ref<Shape> s = get_shape();
@@ -515,37 +503,35 @@ void CollisionShape::_create_debug_shape() {
if (s.is_null())
return;
-
Ref<Mesh> mesh = s->get_debug_mesh();
- MeshInstance *mi = memnew( MeshInstance );
+ MeshInstance *mi = memnew(MeshInstance);
mi->set_mesh(mesh);
add_child(mi);
- debug_shape=mi;
-
+ debug_shape = mi;
}
#if 0
#include "body_volume.h"
-#include "scene/3d/physics_body.h"
#include "geometry.h"
+#include "scene/3d/physics_body.h"
-#define ADD_TRIANGLE( m_a, m_b, m_c, m_color)\
-{\
- Vector<Vector3> points;\
- points.resize(3);\
- points[0]=m_a;\
- points[1]=m_b;\
- points[2]=m_c;\
- Vector<Color> colors;\
- colors.resize(3);\
- colors[0]=m_color;\
- colors[1]=m_color;\
- colors[2]=m_color;\
- vs->poly_add_primitive(p_indicator,points,Vector<Vector3>(),colors,Vector<Vector3>());\
-}
+#define ADD_TRIANGLE(m_a, m_b, m_c, m_color) \
+ { \
+ Vector<Vector3> points; \
+ points.resize(3); \
+ points[0] = m_a; \
+ points[1] = m_b; \
+ points[2] = m_c; \
+ Vector<Color> colors; \
+ colors.resize(3); \
+ colors[0] = m_color; \
+ colors[1] = m_color; \
+ colors[2] = m_color; \
+ vs->poly_add_primitive(p_indicator, points, Vector<Vector3>(), colors, Vector<Vector3>()); \
+ }
void CollisionShape::_notification(int p_what) {
diff --git a/scene/3d/body_shape.h b/scene/3d/body_shape.h
index 82f03da82..dcf813eed 100644
--- a/scene/3d/body_shape.h
+++ b/scene/3d/body_shape.h
@@ -34,7 +34,7 @@
class CollisionShape : public Spatial {
- OBJ_TYPE( CollisionShape, Spatial );
+ OBJ_TYPE(CollisionShape, Spatial);
OBJ_CATEGORY("3D Physics Nodes");
Ref<Shape> shape;
@@ -50,7 +50,7 @@ class CollisionShape : public Spatial {
RID indicator_instance;
*/
- Node* debug_shape;
+ Node *debug_shape;
void resource_changed(RES res);
@@ -63,7 +63,7 @@ class CollisionShape : public Spatial {
int update_shape_index;
void _update_body();
- void _add_to_collision_object(Object* p_cshape);
+ void _add_to_collision_object(Object *p_cshape);
void _set_update_shape_index(int p_index);
int _get_update_shape_index() const;
@@ -71,12 +71,10 @@ class CollisionShape : public Spatial {
void _create_debug_shape();
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
void make_convex_from_brothers();
void set_shape(const Ref<Shape> &p_shape);
@@ -90,7 +88,6 @@ public:
int get_collision_object_shape_index() const { return _get_update_shape_index(); }
-
String get_configuration_warning() const;
CollisionShape();
@@ -98,4 +95,3 @@ public:
};
#endif // BODY_VOLUME_H
-
diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp
index 9cd7f05d7..388097201 100644
--- a/scene/3d/bone_attachment.cpp
+++ b/scene/3d/bone_attachment.cpp
@@ -28,19 +28,19 @@
/*************************************************************************/
#include "bone_attachment.h"
-bool BoneAttachment::_get(const StringName& p_name,Variant &r_ret) const {
+bool BoneAttachment::_get(const StringName &p_name, Variant &r_ret) const {
- if (String(p_name)=="bone_name") {
+ if (String(p_name) == "bone_name") {
- r_ret=get_bone_name();
+ r_ret = get_bone_name();
return true;
}
return false;
}
-bool BoneAttachment::_set(const StringName& p_name, const Variant& p_value){
+bool BoneAttachment::_set(const StringName &p_name, const Variant &p_value) {
- if (String(p_name)=="bone_name") {
+ if (String(p_name) == "bone_name") {
set_bone_name(p_value);
return true;
@@ -48,40 +48,37 @@ bool BoneAttachment::_set(const StringName& p_name, const Variant& p_value){
return false;
}
-void BoneAttachment::_get_property_list( List<PropertyInfo>* p_list ) const{
+void BoneAttachment::_get_property_list(List<PropertyInfo> *p_list) const {
- Skeleton *parent=NULL;
- if(get_parent())
- parent=get_parent()->cast_to<Skeleton>();
+ Skeleton *parent = NULL;
+ if (get_parent())
+ parent = get_parent()->cast_to<Skeleton>();
if (parent) {
String names;
- for(int i=0;i<parent->get_bone_count();i++) {
- if(i>0)
- names+=",";
- names+=parent->get_bone_name(i);
+ for (int i = 0; i < parent->get_bone_count(); i++) {
+ if (i > 0)
+ names += ",";
+ names += parent->get_bone_name(i);
}
- p_list->push_back(PropertyInfo(Variant::STRING,"bone_name",PROPERTY_HINT_ENUM,names));
+ p_list->push_back(PropertyInfo(Variant::STRING, "bone_name", PROPERTY_HINT_ENUM, names));
} else {
- p_list->push_back(PropertyInfo(Variant::STRING,"bone_name"));
-
+ p_list->push_back(PropertyInfo(Variant::STRING, "bone_name"));
}
-
}
-
void BoneAttachment::_check_bind() {
if (get_parent() && get_parent()->cast_to<Skeleton>()) {
Skeleton *sk = get_parent()->cast_to<Skeleton>();
int idx = sk->find_bone(bone_name);
- if (idx!=-1) {
- sk->bind_child_node_to_bone(idx,this);
+ if (idx != -1) {
+ sk->bind_child_node_to_bone(idx, this);
set_transform(sk->get_bone_global_pose(idx));
- bound=true;
+ bound = true;
}
}
}
@@ -93,33 +90,33 @@ void BoneAttachment::_check_unbind() {
if (get_parent() && get_parent()->cast_to<Skeleton>()) {
Skeleton *sk = get_parent()->cast_to<Skeleton>();
int idx = sk->find_bone(bone_name);
- if (idx!=-1) {
- sk->unbind_child_node_from_bone(idx,this);
+ if (idx != -1) {
+ sk->unbind_child_node_from_bone(idx, this);
}
}
- bound=false;
+ bound = false;
}
}
-void BoneAttachment::set_bone_name(const String& p_name) {
+void BoneAttachment::set_bone_name(const String &p_name) {
if (is_inside_tree())
_check_unbind();
- bone_name=p_name;
+ bone_name = p_name;
if (is_inside_tree())
_check_bind();
}
-String BoneAttachment::get_bone_name() const{
+String BoneAttachment::get_bone_name() const {
return bone_name;
}
void BoneAttachment::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -132,13 +129,11 @@ void BoneAttachment::_notification(int p_what) {
}
}
-BoneAttachment::BoneAttachment()
-{
- bound=false;
-
+BoneAttachment::BoneAttachment() {
+ bound = false;
}
-void BoneAttachment::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_bone_name","bone_name"),&BoneAttachment::set_bone_name);
- ObjectTypeDB::bind_method(_MD("get_bone_name"),&BoneAttachment::get_bone_name);
+void BoneAttachment::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_bone_name", "bone_name"), &BoneAttachment::set_bone_name);
+ ObjectTypeDB::bind_method(_MD("get_bone_name"), &BoneAttachment::get_bone_name);
}
diff --git a/scene/3d/bone_attachment.h b/scene/3d/bone_attachment.h
index 26514acdf..5d512a2d3 100644
--- a/scene/3d/bone_attachment.h
+++ b/scene/3d/bone_attachment.h
@@ -33,25 +33,24 @@
class BoneAttachment : public Spatial {
- OBJ_TYPE(BoneAttachment,Spatial);
+ OBJ_TYPE(BoneAttachment, Spatial);
bool bound;
String bone_name;
void _check_bind();
void _check_unbind();
-protected:
- bool _get(const StringName& p_name,Variant &r_ret) const;
- bool _set(const StringName& p_name, const Variant& p_value);
- void _get_property_list( List<PropertyInfo>* p_list ) const;
+protected:
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
-
- void set_bone_name(const String& p_name);
+ void set_bone_name(const String &p_name);
String get_bone_name() const;
BoneAttachment();
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 8128e8195..187df0380 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -32,10 +32,7 @@
#include "scene/resources/material.h"
#include "scene/resources/surface_tool.h"
-
void Camera::_update_audio_listener_state() {
-
-
}
void Camera::_request_camera_update() {
@@ -45,60 +42,56 @@ void Camera::_request_camera_update() {
void Camera::_update_camera_mode() {
-
- force_change=true;
- switch(mode) {
+ force_change = true;
+ switch (mode) {
case PROJECTION_PERSPECTIVE: {
-
- set_perspective(fov,near,far);
+ set_perspective(fov, near, far);
} break;
case PROJECTION_ORTHOGONAL: {
- set_orthogonal(size,near,far);
+ set_orthogonal(size, near, far);
} break;
-
}
-
}
-bool Camera::_set(const StringName& p_name, const Variant& p_value) {
+bool Camera::_set(const StringName &p_name, const Variant &p_value) {
- bool changed_all=false;
- if (p_name=="projection") {
+ bool changed_all = false;
+ if (p_name == "projection") {
int proj = p_value;
- if (proj==PROJECTION_PERSPECTIVE)
- mode=PROJECTION_PERSPECTIVE;
- if (proj==PROJECTION_ORTHOGONAL)
- mode=PROJECTION_ORTHOGONAL;
+ if (proj == PROJECTION_PERSPECTIVE)
+ mode = PROJECTION_PERSPECTIVE;
+ if (proj == PROJECTION_ORTHOGONAL)
+ mode = PROJECTION_ORTHOGONAL;
- changed_all=true;
- } else if (p_name=="fov" || p_name=="fovy" || p_name=="fovx")
- fov=p_value;
- else if (p_name=="size" || p_name=="sizex" || p_name=="sizey")
- size=p_value;
- else if (p_name=="near")
- near=p_value;
- else if (p_name=="far")
- far=p_value;
- else if (p_name=="keep_aspect")
+ changed_all = true;
+ } else if (p_name == "fov" || p_name == "fovy" || p_name == "fovx")
+ fov = p_value;
+ else if (p_name == "size" || p_name == "sizex" || p_name == "sizey")
+ size = p_value;
+ else if (p_name == "near")
+ near = p_value;
+ else if (p_name == "far")
+ far = p_value;
+ else if (p_name == "keep_aspect")
set_keep_aspect_mode(KeepAspect(int(p_value)));
- else if (p_name=="vaspect")
- set_keep_aspect_mode(p_value?KEEP_WIDTH:KEEP_HEIGHT);
- else if (p_name=="h_offset")
- h_offset=p_value;
- else if (p_name=="v_offset")
- v_offset=p_value;
- else if (p_name=="current") {
+ else if (p_name == "vaspect")
+ set_keep_aspect_mode(p_value ? KEEP_WIDTH : KEEP_HEIGHT);
+ else if (p_name == "h_offset")
+ h_offset = p_value;
+ else if (p_name == "v_offset")
+ v_offset = p_value;
+ else if (p_name == "current") {
if (p_value.operator bool()) {
make_current();
} else {
clear_current();
}
- } else if (p_name=="visible_layers") {
+ } else if (p_name == "visible_layers") {
set_visible_layers(p_value);
- } else if (p_name=="environment") {
+ } else if (p_name == "environment") {
set_environment(p_value);
} else
return false;
@@ -107,117 +100,108 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) {
if (changed_all)
_change_notify();
return true;
-
}
-bool Camera::_get(const StringName& p_name,Variant &r_ret) const {
+bool Camera::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name=="projection") {
- r_ret= mode;
- } else if (p_name=="fov" || p_name=="fovy" || p_name=="fovx")
- r_ret= fov;
- else if (p_name=="size" || p_name=="sizex" || p_name=="sizey")
- r_ret= size;
- else if (p_name=="near")
- r_ret= near;
- else if (p_name=="far")
- r_ret= far;
- else if (p_name=="keep_aspect")
- r_ret= int(keep_aspect);
- else if (p_name=="current") {
+ if (p_name == "projection") {
+ r_ret = mode;
+ } else if (p_name == "fov" || p_name == "fovy" || p_name == "fovx")
+ r_ret = fov;
+ else if (p_name == "size" || p_name == "sizex" || p_name == "sizey")
+ r_ret = size;
+ else if (p_name == "near")
+ r_ret = near;
+ else if (p_name == "far")
+ r_ret = far;
+ else if (p_name == "keep_aspect")
+ r_ret = int(keep_aspect);
+ else if (p_name == "current") {
if (is_inside_tree() && get_tree()->is_node_being_edited(this)) {
- r_ret=current;
+ r_ret = current;
} else {
- r_ret=is_current();
+ r_ret = is_current();
}
- } else if (p_name=="visible_layers") {
- r_ret=get_visible_layers();
- } else if (p_name=="h_offset") {
- r_ret=get_h_offset();
- } else if (p_name=="v_offset") {
- r_ret=get_v_offset();
- } else if (p_name=="environment") {
- r_ret=get_environment();
+ } else if (p_name == "visible_layers") {
+ r_ret = get_visible_layers();
+ } else if (p_name == "h_offset") {
+ r_ret = get_h_offset();
+ } else if (p_name == "v_offset") {
+ r_ret = get_v_offset();
+ } else if (p_name == "environment") {
+ r_ret = get_environment();
} else
return false;
return true;
}
-void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
+void Camera::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo( Variant::INT, "projection", PROPERTY_HINT_ENUM, "Perspective,Orthogonal") );
+ p_list->push_back(PropertyInfo(Variant::INT, "projection", PROPERTY_HINT_ENUM, "Perspective,Orthogonal"));
- switch(mode) {
+ switch (mode) {
case PROJECTION_PERSPECTIVE: {
- p_list->push_back( PropertyInfo( Variant::REAL, "fov" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_NOEDITOR) );
- if (keep_aspect==KEEP_WIDTH)
- p_list->push_back( PropertyInfo( Variant::REAL, "fovx" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_EDITOR) );
+ p_list->push_back(PropertyInfo(Variant::REAL, "fov", PROPERTY_HINT_RANGE, "1,179,0.1", PROPERTY_USAGE_NOEDITOR));
+ if (keep_aspect == KEEP_WIDTH)
+ p_list->push_back(PropertyInfo(Variant::REAL, "fovx", PROPERTY_HINT_RANGE, "1,179,0.1", PROPERTY_USAGE_EDITOR));
else
- p_list->push_back( PropertyInfo( Variant::REAL, "fovy" , PROPERTY_HINT_RANGE, "1,179,0.1",PROPERTY_USAGE_EDITOR) );
-
+ p_list->push_back(PropertyInfo(Variant::REAL, "fovy", PROPERTY_HINT_RANGE, "1,179,0.1", PROPERTY_USAGE_EDITOR));
} break;
case PROJECTION_ORTHOGONAL: {
- p_list->push_back( PropertyInfo( Variant::REAL, "size" , PROPERTY_HINT_RANGE, "1,16384,0.01",PROPERTY_USAGE_NOEDITOR ) );
- if (keep_aspect==KEEP_WIDTH)
- p_list->push_back( PropertyInfo( Variant::REAL, "sizex" , PROPERTY_HINT_RANGE, "0.1,16384,0.01",PROPERTY_USAGE_EDITOR) );
+ p_list->push_back(PropertyInfo(Variant::REAL, "size", PROPERTY_HINT_RANGE, "1,16384,0.01", PROPERTY_USAGE_NOEDITOR));
+ if (keep_aspect == KEEP_WIDTH)
+ p_list->push_back(PropertyInfo(Variant::REAL, "sizex", PROPERTY_HINT_RANGE, "0.1,16384,0.01", PROPERTY_USAGE_EDITOR));
else
- p_list->push_back( PropertyInfo( Variant::REAL, "sizey" , PROPERTY_HINT_RANGE, "0.1,16384,0.01",PROPERTY_USAGE_EDITOR) );
+ p_list->push_back(PropertyInfo(Variant::REAL, "sizey", PROPERTY_HINT_RANGE, "0.1,16384,0.01", PROPERTY_USAGE_EDITOR));
} break;
-
}
- p_list->push_back( PropertyInfo( Variant::REAL, "near" , PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01") );
- p_list->push_back( PropertyInfo( Variant::REAL, "far" , PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01") );
- p_list->push_back( PropertyInfo( Variant::INT, "keep_aspect",PROPERTY_HINT_ENUM,"Keep Width,Keep Height") );
- p_list->push_back( PropertyInfo( Variant::BOOL, "current" ) );
- p_list->push_back( PropertyInfo( Variant::INT, "visible_layers",PROPERTY_HINT_ALL_FLAGS ) );
- p_list->push_back( PropertyInfo( Variant::OBJECT, "environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment" ) );
- p_list->push_back( PropertyInfo( Variant::REAL, "h_offset" ) );
- p_list->push_back( PropertyInfo( Variant::REAL, "v_offset" ) );
-
+ p_list->push_back(PropertyInfo(Variant::REAL, "near", PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "far", PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::INT, "keep_aspect", PROPERTY_HINT_ENUM, "Keep Width,Keep Height"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "current"));
+ p_list->push_back(PropertyInfo(Variant::INT, "visible_layers", PROPERTY_HINT_ALL_FLAGS));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "h_offset"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "v_offset"));
}
void Camera::_update_camera() {
Transform tr = get_camera_transform();
- tr.origin+=tr.basis.get_axis(1)*v_offset;
- tr.origin+=tr.basis.get_axis(0)*h_offset;
- VisualServer::get_singleton()->camera_set_transform( camera, tr );
+ tr.origin += tr.basis.get_axis(1) * v_offset;
+ tr.origin += tr.basis.get_axis(0) * h_offset;
+ VisualServer::get_singleton()->camera_set_transform(camera, tr);
-// here goes listener stuff
-// if (viewport_ptr && is_inside_scene() && is_current())
-// get_viewport()->_camera_transform_changed_notify();
+ // here goes listener stuff
+ // if (viewport_ptr && is_inside_scene() && is_current())
+ // get_viewport()->_camera_transform_changed_notify();
if (is_inside_tree() && is_current()) {
get_viewport()->_camera_transform_changed_notify();
-
}
if (is_current() && get_world().is_valid()) {
get_world()->_update_camera(this);
}
-
-
}
void Camera::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
-
bool first_camera = get_viewport()->_camera_add(this);
if (!get_tree()->is_node_being_edited(this) && (current || first_camera))
make_current();
-
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -228,16 +212,15 @@ void Camera::_notification(int p_what) {
if (!get_tree()->is_node_being_edited(this)) {
if (is_current()) {
clear_current();
- current=true; //keep it true
+ current = true; //keep it true
} else {
- current=false;
+ current = false;
}
}
get_viewport()->_camera_remove(this);
-
} break;
case NOTIFICATION_BECAME_CURRENT: {
if (get_world().is_valid()) {
@@ -249,13 +232,9 @@ void Camera::_notification(int p_what) {
get_world()->_remove_camera(this);
}
} break;
-
-
}
-
}
-
Transform Camera::get_camera_transform() const {
return get_global_transform().orthonormalized();
@@ -263,31 +242,31 @@ Transform Camera::get_camera_transform() const {
void Camera::set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far) {
- if (!force_change && fov==p_fovy_degrees && p_z_near==near && p_z_far==far && mode==PROJECTION_PERSPECTIVE)
+ if (!force_change && fov == p_fovy_degrees && p_z_near == near && p_z_far == far && mode == PROJECTION_PERSPECTIVE)
return;
- fov=p_fovy_degrees;
- near=p_z_near;
- far=p_z_far;
- mode=PROJECTION_PERSPECTIVE;
+ fov = p_fovy_degrees;
+ near = p_z_near;
+ far = p_z_far;
+ mode = PROJECTION_PERSPECTIVE;
- VisualServer::get_singleton()->camera_set_perspective(camera,fov,near,far);
+ VisualServer::get_singleton()->camera_set_perspective(camera, fov, near, far);
update_gizmo();
- force_change=false;
+ force_change = false;
}
void Camera::set_orthogonal(float p_size, float p_z_near, float p_z_far) {
- if (!force_change && size==p_size && p_z_near==near && p_z_far==far && mode==PROJECTION_ORTHOGONAL)
+ if (!force_change && size == p_size && p_z_near == near && p_z_far == far && mode == PROJECTION_ORTHOGONAL)
return;
size = p_size;
- near=p_z_near;
- far=p_z_far;
- mode=PROJECTION_ORTHOGONAL;
- force_change=false;
+ near = p_z_near;
+ far = p_z_far;
+ mode = PROJECTION_ORTHOGONAL;
+ force_change = false;
- VisualServer::get_singleton()->camera_set_orthogonal(camera,size,near,far);
+ VisualServer::get_singleton()->camera_set_orthogonal(camera, size, near, far);
update_gizmo();
}
@@ -298,7 +277,7 @@ RID Camera::get_camera() const {
void Camera::make_current() {
- current=true;
+ current = true;
if (!is_inside_tree())
return;
@@ -308,140 +287,127 @@ void Camera::make_current() {
//get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,camera_group,"_camera_make_current",this);
}
-
-
-
void Camera::clear_current() {
- current=false;
+ current = false;
if (!is_inside_tree())
return;
- if (get_viewport()->get_camera()==this) {
+ if (get_viewport()->get_camera() == this) {
get_viewport()->_camera_set(NULL);
get_viewport()->_camera_make_next_current(this);
}
-
}
bool Camera::is_current() const {
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
- return get_viewport()->get_camera()==this;
+ return get_viewport()->get_camera() == this;
} else
return current;
return false;
}
-
bool Camera::_can_gizmo_scale() const {
return false;
}
-
RES Camera::_get_gizmo_geometry() const {
+ Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
+ Ref<FixedMaterial> mat(memnew(FixedMaterial));
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.5,1.0,0.5) );
+ mat->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(1.0, 0.5, 1.0, 0.5));
mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
+ mat->set_flag(Material::FLAG_DOUBLE_SIDED, true);
+ mat->set_flag(Material::FLAG_UNSHADED, true);
//mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);
- switch(mode) {
+ switch (mode) {
case PROJECTION_PERSPECTIVE: {
+ Vector3 side = Vector3(Math::sin(Math::deg2rad(fov)), 0, -Math::cos(Math::deg2rad(fov)));
+ Vector3 nside = side;
+ nside.x = -nside.x;
+ Vector3 up = Vector3(0, side.x, 0);
+#define ADD_TRIANGLE(m_a, m_b, m_c) \
+ { \
+ surface_tool->add_vertex(m_a); \
+ surface_tool->add_vertex(m_b); \
+ surface_tool->add_vertex(m_b); \
+ surface_tool->add_vertex(m_c); \
+ surface_tool->add_vertex(m_c); \
+ surface_tool->add_vertex(m_a); \
+ }
- Vector3 side=Vector3( Math::sin(Math::deg2rad(fov)), 0, -Math::cos(Math::deg2rad(fov)) );
- Vector3 nside=side;
- nside.x=-nside.x;
- Vector3 up=Vector3(0,side.x,0);
-
-
-#define ADD_TRIANGLE( m_a, m_b, m_c)\
-{\
- surface_tool->add_vertex(m_a);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_a);\
-}
-
- ADD_TRIANGLE( Vector3(), side+up, side-up );
- ADD_TRIANGLE( Vector3(), nside+up, nside-up );
- ADD_TRIANGLE( Vector3(), side+up, nside+up );
- ADD_TRIANGLE( Vector3(), side-up, nside-up );
+ ADD_TRIANGLE(Vector3(), side + up, side - up);
+ ADD_TRIANGLE(Vector3(), nside + up, nside - up);
+ ADD_TRIANGLE(Vector3(), side + up, nside + up);
+ ADD_TRIANGLE(Vector3(), side - up, nside - up);
- side.x*=0.25;
- nside.x*=0.25;
- Vector3 tup( 0, up.y*3/2,side.z);
- ADD_TRIANGLE( tup, side+up, nside+up );
+ side.x *= 0.25;
+ nside.x *= 0.25;
+ Vector3 tup(0, up.y * 3 / 2, side.z);
+ ADD_TRIANGLE(tup, side + up, nside + up);
} break;
case PROJECTION_ORTHOGONAL: {
-#define ADD_QUAD( m_a, m_b, m_c, m_d)\
-{\
- surface_tool->add_vertex(m_a);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_d);\
- surface_tool->add_vertex(m_d);\
- surface_tool->add_vertex(m_a);\
-}
+#define ADD_QUAD(m_a, m_b, m_c, m_d) \
+ { \
+ surface_tool->add_vertex(m_a); \
+ surface_tool->add_vertex(m_b); \
+ surface_tool->add_vertex(m_b); \
+ surface_tool->add_vertex(m_c); \
+ surface_tool->add_vertex(m_c); \
+ surface_tool->add_vertex(m_d); \
+ surface_tool->add_vertex(m_d); \
+ surface_tool->add_vertex(m_a); \
+ }
- float hsize=size*0.5;
- Vector3 right(hsize,0,0);
- Vector3 up(0,hsize,0);
- Vector3 back(0,0,-1.0);
- Vector3 front(0,0,0);
+ float hsize = size * 0.5;
+ Vector3 right(hsize, 0, 0);
+ Vector3 up(0, hsize, 0);
+ Vector3 back(0, 0, -1.0);
+ Vector3 front(0, 0, 0);
- ADD_QUAD( -up-right,-up+right,up+right,up-right);
- ADD_QUAD( -up-right+back,-up+right+back,up+right+back,up-right+back);
- ADD_QUAD( up+right,up+right+back,up-right+back,up-right);
- ADD_QUAD( -up+right,-up+right+back,-up-right+back,-up-right);
+ ADD_QUAD(-up - right, -up + right, up + right, up - right);
+ ADD_QUAD(-up - right + back, -up + right + back, up + right + back, up - right + back);
+ ADD_QUAD(up + right, up + right + back, up - right + back, up - right);
+ ADD_QUAD(-up + right, -up + right + back, -up - right + back, -up - right);
- right.x*=0.25;
- Vector3 tup( 0, up.y*3/2,back.z );
- ADD_TRIANGLE( tup, right+up+back, -right+up+back );
+ right.x *= 0.25;
+ Vector3 tup(0, up.y * 3 / 2, back.z);
+ ADD_TRIANGLE(tup, right + up + back, -right + up + back);
} break;
-
}
return surface_tool->commit();
-
}
-Vector3 Camera::project_ray_normal(const Point2& p_pos) const {
+Vector3 Camera::project_ray_normal(const Point2 &p_pos) const {
Vector3 ray = project_local_ray_normal(p_pos);
return get_camera_transform().basis.xform(ray).normalized();
};
-Vector3 Camera::project_local_ray_normal(const Point2& p_pos) const {
+Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const {
if (!is_inside_tree()) {
ERR_EXPLAIN("Camera is not inside scene.");
- ERR_FAIL_COND_V(!is_inside_tree(),Vector3());
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
}
-
#if 0
Size2 viewport_size = get_viewport()->get_visible_rect().size;
Vector2 cpos = p_pos;
@@ -453,26 +419,25 @@ Vector3 Camera::project_local_ray_normal(const Point2& p_pos) const {
Vector3 ray;
- if (mode==PROJECTION_ORTHOGONAL) {
+ if (mode == PROJECTION_ORTHOGONAL) {
- ray=Vector3(0,0,-1);
+ ray = Vector3(0, 0, -1);
} else {
CameraMatrix cm;
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
- float screen_w,screen_h;
- cm.get_viewport_size(screen_w,screen_h);
- ray=Vector3( ((cpos.x/viewport_size.width)*2.0-1.0)*screen_w, ((1.0-(cpos.y/viewport_size.height))*2.0-1.0)*screen_h,-near).normalized();
+ cm.set_perspective(fov, viewport_size.get_aspect(), near, far, keep_aspect == KEEP_WIDTH);
+ float screen_w, screen_h;
+ cm.get_viewport_size(screen_w, screen_h);
+ ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_w, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_h, -near).normalized();
}
return ray;
};
-
-Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
+Vector3 Camera::project_ray_origin(const Point2 &p_pos) const {
if (!is_inside_tree()) {
ERR_EXPLAIN("Camera is not inside scene.");
- ERR_FAIL_COND_V(!is_inside_tree(),Vector3());
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
}
#if 0
@@ -484,8 +449,8 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
#endif
- ERR_FAIL_COND_V( viewport_size.y == 0, Vector3() );
-// float aspect = viewport_size.x / viewport_size.y;
+ ERR_FAIL_COND_V(viewport_size.y == 0, Vector3());
+ // float aspect = viewport_size.x / viewport_size.y;
if (mode == PROJECTION_PERSPECTIVE) {
@@ -493,91 +458,84 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
} else {
Vector2 pos = cpos / viewport_size;
- float vsize,hsize;
- if (keep_aspect==KEEP_WIDTH) {
- vsize = size/viewport_size.get_aspect();
+ float vsize, hsize;
+ if (keep_aspect == KEEP_WIDTH) {
+ vsize = size / viewport_size.get_aspect();
hsize = size;
} else {
- hsize = size*viewport_size.get_aspect();
+ hsize = size * viewport_size.get_aspect();
vsize = size;
-
}
-
-
Vector3 ray;
- ray.x = pos.x * (hsize) - hsize/2;
- ray.y = (1.0 - pos.y) * (vsize) - vsize/2;
+ ray.x = pos.x * (hsize)-hsize / 2;
+ ray.y = (1.0 - pos.y) * (vsize)-vsize / 2;
ray.z = -near;
ray = get_camera_transform().xform(ray);
return ray;
};
};
-bool Camera::is_position_behind(const Vector3& p_pos) const {
+bool Camera::is_position_behind(const Vector3 &p_pos) const {
Transform t = get_global_transform();
Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized();
- return eyedir.dot(p_pos) < (eyedir.dot(t.origin)+near);
+ return eyedir.dot(p_pos) < (eyedir.dot(t.origin) + near);
}
-Point2 Camera::unproject_position(const Vector3& p_pos) const {
+Point2 Camera::unproject_position(const Vector3 &p_pos) const {
if (!is_inside_tree()) {
ERR_EXPLAIN("Camera is not inside scene.");
- ERR_FAIL_COND_V(!is_inside_tree(),Vector2());
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector2());
}
Size2 viewport_size = get_viewport()->get_visible_rect().size;
CameraMatrix cm;
-
- if (mode==PROJECTION_ORTHOGONAL)
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ if (mode == PROJECTION_ORTHOGONAL)
+ cm.set_orthogonal(size, viewport_size.get_aspect(), near, far, keep_aspect == KEEP_WIDTH);
else
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov, viewport_size.get_aspect(), near, far, keep_aspect == KEEP_WIDTH);
- Plane p(get_camera_transform().xform_inv(p_pos),1.0);
-
- p=cm.xform4(p);
- p.normal/=p.d;
+ Plane p(get_camera_transform().xform_inv(p_pos), 1.0);
+ p = cm.xform4(p);
+ p.normal /= p.d;
Point2 res;
- res.x = (p.normal.x * 0.5 + 0.5) * viewport_size.x;
- res.y = (-p.normal.y * 0.5 + 0.5) * viewport_size.y;
+ res.x = (p.normal.x * 0.5 + 0.5) * viewport_size.x;
+ res.y = (-p.normal.y * 0.5 + 0.5) * viewport_size.y;
return res;
-
}
-Vector3 Camera::project_position(const Point2& p_point) const {
+Vector3 Camera::project_position(const Point2 &p_point) const {
if (!is_inside_tree()) {
ERR_EXPLAIN("Camera is not inside scene.");
- ERR_FAIL_COND_V(!is_inside_tree(),Vector3());
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
}
Size2 viewport_size = get_viewport()->get_visible_rect().size;
CameraMatrix cm;
- if (mode==PROJECTION_ORTHOGONAL)
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ if (mode == PROJECTION_ORTHOGONAL)
+ cm.set_orthogonal(size, viewport_size.get_aspect(), near, far, keep_aspect == KEEP_WIDTH);
else
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_perspective(fov, viewport_size.get_aspect(), near, far, keep_aspect == KEEP_WIDTH);
Size2 vp_size;
- cm.get_viewport_size(vp_size.x,vp_size.y);
+ cm.get_viewport_size(vp_size.x, vp_size.y);
Vector2 point;
- point.x = (p_point.x/viewport_size.x) * 2.0 - 1.0;
- point.y = (1.0-(p_point.y/viewport_size.y)) * 2.0 - 1.0;
- point*=vp_size;
-
- Vector3 p(point.x,point.y,-near);
+ point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0;
+ point.y = (1.0 - (p_point.y / viewport_size.y)) * 2.0 - 1.0;
+ point *= vp_size;
+ Vector3 p(point.x, point.y, -near);
return get_camera_transform().xform(p);
}
@@ -599,13 +557,13 @@ void Camera::_camera_make_current(Node *p_camera) {
}
*/
-void Camera::set_environment(const Ref<Environment>& p_environment) {
+void Camera::set_environment(const Ref<Environment> &p_environment) {
- environment=p_environment;
+ environment = p_environment;
if (environment.is_valid())
- VS::get_singleton()->camera_set_environment(camera,environment->get_rid());
+ VS::get_singleton()->camera_set_environment(camera, environment->get_rid());
else
- VS::get_singleton()->camera_set_environment(camera,RID());
+ VS::get_singleton()->camera_set_environment(camera, RID());
}
Ref<Environment> Camera::get_environment() const {
@@ -613,59 +571,55 @@ Ref<Environment> Camera::get_environment() const {
return environment;
}
-
void Camera::set_keep_aspect_mode(KeepAspect p_aspect) {
- keep_aspect=p_aspect;
- VisualServer::get_singleton()->camera_set_use_vertical_aspect(camera,p_aspect==KEEP_WIDTH);
+ keep_aspect = p_aspect;
+ VisualServer::get_singleton()->camera_set_use_vertical_aspect(camera, p_aspect == KEEP_WIDTH);
_change_notify();
}
-Camera::KeepAspect Camera::get_keep_aspect_mode() const{
+Camera::KeepAspect Camera::get_keep_aspect_mode() const {
return keep_aspect;
}
-
-
void Camera::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("project_ray_normal","screen_point"), &Camera::project_ray_normal);
- ObjectTypeDB::bind_method( _MD("project_local_ray_normal","screen_point"), &Camera::project_local_ray_normal);
- ObjectTypeDB::bind_method( _MD("project_ray_origin","screen_point"), &Camera::project_ray_origin);
- ObjectTypeDB::bind_method( _MD("unproject_position","world_point"), &Camera::unproject_position);
- ObjectTypeDB::bind_method( _MD("is_position_behind","world_point"), &Camera::is_position_behind);
- ObjectTypeDB::bind_method( _MD("project_position","screen_point"), &Camera::project_position);
- ObjectTypeDB::bind_method( _MD("set_perspective","fov","z_near","z_far"),&Camera::set_perspective );
- ObjectTypeDB::bind_method( _MD("set_orthogonal","size","z_near","z_far"),&Camera::set_orthogonal );
- ObjectTypeDB::bind_method( _MD("make_current"),&Camera::make_current );
- ObjectTypeDB::bind_method( _MD("clear_current"),&Camera::clear_current );
- ObjectTypeDB::bind_method( _MD("is_current"),&Camera::is_current );
- ObjectTypeDB::bind_method( _MD("get_camera_transform"),&Camera::get_camera_transform );
- ObjectTypeDB::bind_method( _MD("get_fov"),&Camera::get_fov );
- ObjectTypeDB::bind_method( _MD("get_size"),&Camera::get_size );
- ObjectTypeDB::bind_method( _MD("get_zfar"),&Camera::get_zfar );
- ObjectTypeDB::bind_method( _MD("get_znear"),&Camera::get_znear );
- ObjectTypeDB::bind_method( _MD("get_projection"),&Camera::get_projection );
- ObjectTypeDB::bind_method( _MD("set_h_offset","ofs"),&Camera::set_h_offset );
- ObjectTypeDB::bind_method( _MD("get_h_offset"),&Camera::get_h_offset );
- ObjectTypeDB::bind_method( _MD("set_v_offset","ofs"),&Camera::set_v_offset );
- ObjectTypeDB::bind_method( _MD("get_v_offset"),&Camera::get_v_offset );
- ObjectTypeDB::bind_method( _MD("set_visible_layers","mask"),&Camera::set_visible_layers );
- ObjectTypeDB::bind_method( _MD("get_visible_layers"),&Camera::get_visible_layers );
- ObjectTypeDB::bind_method( _MD("set_environment","env:Environment"),&Camera::set_environment );
- ObjectTypeDB::bind_method( _MD("get_environment:Environment"),&Camera::get_environment );
- ObjectTypeDB::bind_method( _MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode );
- ObjectTypeDB::bind_method( _MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode );
+ ObjectTypeDB::bind_method(_MD("project_ray_normal", "screen_point"), &Camera::project_ray_normal);
+ ObjectTypeDB::bind_method(_MD("project_local_ray_normal", "screen_point"), &Camera::project_local_ray_normal);
+ ObjectTypeDB::bind_method(_MD("project_ray_origin", "screen_point"), &Camera::project_ray_origin);
+ ObjectTypeDB::bind_method(_MD("unproject_position", "world_point"), &Camera::unproject_position);
+ ObjectTypeDB::bind_method(_MD("is_position_behind", "world_point"), &Camera::is_position_behind);
+ ObjectTypeDB::bind_method(_MD("project_position", "screen_point"), &Camera::project_position);
+ ObjectTypeDB::bind_method(_MD("set_perspective", "fov", "z_near", "z_far"), &Camera::set_perspective);
+ ObjectTypeDB::bind_method(_MD("set_orthogonal", "size", "z_near", "z_far"), &Camera::set_orthogonal);
+ ObjectTypeDB::bind_method(_MD("make_current"), &Camera::make_current);
+ ObjectTypeDB::bind_method(_MD("clear_current"), &Camera::clear_current);
+ ObjectTypeDB::bind_method(_MD("is_current"), &Camera::is_current);
+ ObjectTypeDB::bind_method(_MD("get_camera_transform"), &Camera::get_camera_transform);
+ ObjectTypeDB::bind_method(_MD("get_fov"), &Camera::get_fov);
+ ObjectTypeDB::bind_method(_MD("get_size"), &Camera::get_size);
+ ObjectTypeDB::bind_method(_MD("get_zfar"), &Camera::get_zfar);
+ ObjectTypeDB::bind_method(_MD("get_znear"), &Camera::get_znear);
+ ObjectTypeDB::bind_method(_MD("get_projection"), &Camera::get_projection);
+ ObjectTypeDB::bind_method(_MD("set_h_offset", "ofs"), &Camera::set_h_offset);
+ ObjectTypeDB::bind_method(_MD("get_h_offset"), &Camera::get_h_offset);
+ ObjectTypeDB::bind_method(_MD("set_v_offset", "ofs"), &Camera::set_v_offset);
+ ObjectTypeDB::bind_method(_MD("get_v_offset"), &Camera::get_v_offset);
+ ObjectTypeDB::bind_method(_MD("set_visible_layers", "mask"), &Camera::set_visible_layers);
+ ObjectTypeDB::bind_method(_MD("get_visible_layers"), &Camera::get_visible_layers);
+ ObjectTypeDB::bind_method(_MD("set_environment", "env:Environment"), &Camera::set_environment);
+ ObjectTypeDB::bind_method(_MD("get_environment:Environment"), &Camera::get_environment);
+ ObjectTypeDB::bind_method(_MD("set_keep_aspect_mode", "mode"), &Camera::set_keep_aspect_mode);
+ ObjectTypeDB::bind_method(_MD("get_keep_aspect_mode"), &Camera::get_keep_aspect_mode);
//ObjectTypeDB::bind_method( _MD("_camera_make_current"),&Camera::_camera_make_current );
- BIND_CONSTANT( PROJECTION_PERSPECTIVE );
- BIND_CONSTANT( PROJECTION_ORTHOGONAL );
-
- BIND_CONSTANT( KEEP_WIDTH );
- BIND_CONSTANT( KEEP_HEIGHT );
+ BIND_CONSTANT(PROJECTION_PERSPECTIVE);
+ BIND_CONSTANT(PROJECTION_ORTHOGONAL);
+ BIND_CONSTANT(KEEP_WIDTH);
+ BIND_CONSTANT(KEEP_HEIGHT);
}
float Camera::get_fov() const {
@@ -688,7 +642,6 @@ float Camera::get_zfar() const {
return far;
}
-
Camera::Projection Camera::get_projection() const {
return mode;
@@ -696,37 +649,32 @@ Camera::Projection Camera::get_projection() const {
void Camera::set_visible_layers(uint32_t p_layers) {
- layers=p_layers;
- VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
+ layers = p_layers;
+ VisualServer::get_singleton()->camera_set_visible_layers(camera, layers);
}
-uint32_t Camera::get_visible_layers() const{
+uint32_t Camera::get_visible_layers() const {
return layers;
}
-
Vector<Plane> Camera::get_frustum() const {
- ERR_FAIL_COND_V(!is_inside_world(),Vector<Plane>());
+ ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>());
Size2 viewport_size = get_viewport()->get_visible_rect().size;
CameraMatrix cm;
- if (mode==PROJECTION_PERSPECTIVE)
- cm.set_perspective(fov,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ if (mode == PROJECTION_PERSPECTIVE)
+ cm.set_perspective(fov, viewport_size.get_aspect(), near, far, keep_aspect == KEEP_WIDTH);
else
- cm.set_orthogonal(size,viewport_size.get_aspect(),near,far,keep_aspect==KEEP_WIDTH);
+ cm.set_orthogonal(size, viewport_size.get_aspect(), near, far, keep_aspect == KEEP_WIDTH);
return cm.get_projection_planes(get_camera_transform());
-
}
-
-
-
void Camera::set_v_offset(float p_offset) {
- v_offset=p_offset;
+ v_offset = p_offset;
_update_camera();
}
@@ -736,7 +684,7 @@ float Camera::get_v_offset() const {
}
void Camera::set_h_offset(float p_offset) {
- h_offset=p_offset;
+ h_offset = p_offset;
_update_camera();
}
@@ -745,31 +693,26 @@ float Camera::get_h_offset() const {
return h_offset;
}
-
Camera::Camera() {
camera = VisualServer::get_singleton()->camera_create();
- size=1;
- fov=0;
- near=0;
- far=0;
- current=false;
- force_change=false;
- mode=PROJECTION_PERSPECTIVE;
- set_perspective(60.0,0.1,100.0);
- keep_aspect=KEEP_HEIGHT;
- layers=0xfffff;
- v_offset=0;
- h_offset=0;
- VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
+ size = 1;
+ fov = 0;
+ near = 0;
+ far = 0;
+ current = false;
+ force_change = false;
+ mode = PROJECTION_PERSPECTIVE;
+ set_perspective(60.0, 0.1, 100.0);
+ keep_aspect = KEEP_HEIGHT;
+ layers = 0xfffff;
+ v_offset = 0;
+ h_offset = 0;
+ VisualServer::get_singleton()->camera_set_visible_layers(camera, layers);
//active=false;
}
-
Camera::~Camera() {
VisualServer::get_singleton()->free(camera);
-
}
-
-
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 554990997..a348f7664 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -29,7 +29,6 @@
#ifndef CAMERA_H
#define CAMERA_H
-
#include "scene/3d/spatial.h"
#include "scene/main/viewport.h"
#include "scene/resources/environment.h"
@@ -38,7 +37,8 @@
*/
class Camera : public Spatial {
- OBJ_TYPE( Camera, Spatial );
+ OBJ_TYPE(Camera, Spatial);
+
public:
enum Projection {
@@ -52,7 +52,6 @@ public:
};
private:
-
bool force_change;
bool current;
@@ -60,7 +59,7 @@ private:
float fov;
float size;
- float near,far;
+ float near, far;
float v_offset;
float h_offset;
KeepAspect keep_aspect;
@@ -77,29 +76,27 @@ private:
virtual bool _can_gizmo_scale() const;
virtual RES _get_gizmo_geometry() const;
-
//void _camera_make_current(Node *p_camera);
-friend class Viewport;
+ friend class Viewport;
void _update_audio_listener_state();
-protected:
+protected:
void _update_camera();
virtual void _request_camera_update();
void _update_camera_mode();
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
-
enum {
- NOTIFICATION_BECAME_CURRENT=50,
- NOTIFICATION_LOST_CURRENT=51
+ NOTIFICATION_BECAME_CURRENT = 50,
+ NOTIFICATION_LOST_CURRENT = 51
};
void set_perspective(float p_fovy_degrees, float p_z_near, float p_z_far);
@@ -119,39 +116,35 @@ public:
virtual Transform get_camera_transform() const;
- Vector3 project_ray_normal(const Point2& p_point) const;
- Vector3 project_ray_origin(const Point2& p_point) const;
- Vector3 project_local_ray_normal(const Point2& p_point) const;
- Point2 unproject_position(const Vector3& p_pos) const;
- bool is_position_behind(const Vector3& p_pos) const;
- Vector3 project_position(const Point2& p_point) const;
+ Vector3 project_ray_normal(const Point2 &p_point) const;
+ Vector3 project_ray_origin(const Point2 &p_point) const;
+ Vector3 project_local_ray_normal(const Point2 &p_point) const;
+ Point2 unproject_position(const Vector3 &p_pos) const;
+ bool is_position_behind(const Vector3 &p_pos) const;
+ Vector3 project_position(const Point2 &p_point) const;
void set_visible_layers(uint32_t p_layers);
uint32_t get_visible_layers() const;
Vector<Plane> get_frustum() const;
- void set_environment(const Ref<Environment>& p_environment);
+ void set_environment(const Ref<Environment> &p_environment);
Ref<Environment> get_environment() const;
void set_keep_aspect_mode(KeepAspect p_aspect);
KeepAspect get_keep_aspect_mode() const;
-
void set_v_offset(float p_offset);
float get_v_offset() const;
void set_h_offset(float p_offset);
float get_h_offset() const;
-
Camera();
~Camera();
-
};
-
-VARIANT_ENUM_CAST( Camera::Projection );
-VARIANT_ENUM_CAST( Camera::KeepAspect );
+VARIANT_ENUM_CAST(Camera::Projection);
+VARIANT_ENUM_CAST(Camera::KeepAspect);
#endif
diff --git a/scene/3d/character_camera.cpp b/scene/3d/character_camera.cpp
index 97dfa7763..99fb7f25a 100644
--- a/scene/3d/character_camera.cpp
+++ b/scene/3d/character_camera.cpp
@@ -237,7 +237,6 @@ void CharacterCamera::_compute_camera() {
new_pos = character_pos + rel_n * l;
-
#endif
follow_pos=new_pos;
diff --git a/scene/3d/character_camera.h b/scene/3d/character_camera.h
index b30ee4bef..3f4a3c02a 100644
--- a/scene/3d/character_camera.h
+++ b/scene/3d/character_camera.h
@@ -29,7 +29,6 @@
#ifndef CHARACTER_CAMERA_H
#define CHARACTER_CAMERA_H
-
#include "scene/3d/camera.h"
#if 0
class CharacterCamera : public Camera {
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 6186c7e85..d80c48abc 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -27,15 +27,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "collision_object.h"
-#include "servers/physics_server.h"
#include "scene/scene_string_names.h"
+#include "servers/physics_server.h"
void CollisionObject::_update_shapes_from_children() {
shapes.clear();
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- Node* n = get_child(i);
- n->call("_add_to_collision_object",this);
+ Node *n = get_child(i);
+ n->call("_add_to_collision_object", this);
}
_update_shapes();
@@ -43,31 +43,31 @@ void CollisionObject::_update_shapes_from_children() {
void CollisionObject::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
if (area)
- PhysicsServer::get_singleton()->area_set_transform(rid,get_global_transform());
+ PhysicsServer::get_singleton()->area_set_transform(rid, get_global_transform());
else
- PhysicsServer::get_singleton()->body_set_state(rid,PhysicsServer::BODY_STATE_TRANSFORM,get_global_transform());
+ PhysicsServer::get_singleton()->body_set_state(rid, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
RID space = get_world()->get_space();
if (area) {
- PhysicsServer::get_singleton()->area_set_space(rid,space);
+ PhysicsServer::get_singleton()->area_set_space(rid, space);
} else
- PhysicsServer::get_singleton()->body_set_space(rid,space);
+ PhysicsServer::get_singleton()->body_set_space(rid, space);
_update_pickable();
- //get space
+ //get space
};
case NOTIFICATION_TRANSFORM_CHANGED: {
if (area)
- PhysicsServer::get_singleton()->area_set_transform(rid,get_global_transform());
+ PhysicsServer::get_singleton()->area_set_transform(rid, get_global_transform());
else
- PhysicsServer::get_singleton()->body_set_state(rid,PhysicsServer::BODY_STATE_TRANSFORM,get_global_transform());
+ PhysicsServer::get_singleton()->body_set_state(rid, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@@ -78,9 +78,9 @@ void CollisionObject::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
if (area) {
- PhysicsServer::get_singleton()->area_set_space(rid,RID());
+ PhysicsServer::get_singleton()->area_set_space(rid, RID());
} else
- PhysicsServer::get_singleton()->body_set_space(rid,RID());
+ PhysicsServer::get_singleton()->body_set_space(rid, RID());
} break;
}
@@ -96,25 +96,24 @@ void CollisionObject::_update_shapes() {
else
PhysicsServer::get_singleton()->body_clear_shapes(rid);
- for(int i=0;i<shapes.size();i++) {
+ for (int i = 0; i < shapes.size(); i++) {
if (shapes[i].shape.is_null())
continue;
if (area)
- PhysicsServer::get_singleton()->area_add_shape(rid,shapes[i].shape->get_rid(),shapes[i].xform);
+ PhysicsServer::get_singleton()->area_add_shape(rid, shapes[i].shape->get_rid(), shapes[i].xform);
else {
- PhysicsServer::get_singleton()->body_add_shape(rid,shapes[i].shape->get_rid(),shapes[i].xform);
+ PhysicsServer::get_singleton()->body_add_shape(rid, shapes[i].shape->get_rid(), shapes[i].xform);
if (shapes[i].trigger)
- PhysicsServer::get_singleton()->body_set_shape_as_trigger(rid,i,shapes[i].trigger);
+ PhysicsServer::get_singleton()->body_set_shape_as_trigger(rid, i, shapes[i].trigger);
}
}
}
+bool CollisionObject::_set(const StringName &p_name, const Variant &p_value) {
+ String name = p_name;
-bool CollisionObject::_set(const StringName& p_name, const Variant& p_value) {
- String name=p_name;
-
- if (name=="shape_count") {
+ if (name == "shape_count") {
shapes.resize(p_value);
_update_shapes();
@@ -122,40 +121,37 @@ bool CollisionObject::_set(const StringName& p_name, const Variant& p_value) {
} else if (name.begins_with("shapes/")) {
- int idx=name.get_slicec('/',1).to_int();
- String what=name.get_slicec('/',2);
- if (what=="shape")
- set_shape(idx,RefPtr(p_value));
- else if (what=="transform")
- set_shape_transform(idx,p_value);
- else if (what=="trigger")
- set_shape_as_trigger(idx,p_value);
-
+ int idx = name.get_slicec('/', 1).to_int();
+ String what = name.get_slicec('/', 2);
+ if (what == "shape")
+ set_shape(idx, RefPtr(p_value));
+ else if (what == "transform")
+ set_shape_transform(idx, p_value);
+ else if (what == "trigger")
+ set_shape_as_trigger(idx, p_value);
} else
return false;
return true;
-
-
}
-bool CollisionObject::_get(const StringName& p_name,Variant &r_ret) const {
+bool CollisionObject::_get(const StringName &p_name, Variant &r_ret) const {
- String name=p_name;
+ String name = p_name;
- if (name=="shape_count") {
- r_ret= shapes.size();
+ if (name == "shape_count") {
+ r_ret = shapes.size();
} else if (name.begins_with("shapes/")) {
- int idx=name.get_slicec('/',1).to_int();
- String what=name.get_slicec('/',2);
- if (what=="shape")
- r_ret= get_shape(idx);
- else if (what=="transform")
- r_ret= get_shape_transform(idx);
- else if (what=="trigger")
- r_ret= is_shape_set_as_trigger(idx);
+ int idx = name.get_slicec('/', 1).to_int();
+ String what = name.get_slicec('/', 2);
+ if (what == "shape")
+ r_ret = get_shape(idx);
+ else if (what == "transform")
+ r_ret = get_shape_transform(idx);
+ else if (what == "trigger")
+ r_ret = is_shape_set_as_trigger(idx);
} else
return false;
@@ -163,26 +159,24 @@ bool CollisionObject::_get(const StringName& p_name,Variant &r_ret) const {
return true;
}
-void CollisionObject::_get_property_list( List<PropertyInfo> *p_list) const {
+void CollisionObject::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo(Variant::INT,"shape_count",PROPERTY_HINT_RANGE,"0,256,1",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) );
-
- for(int i=0;i<shapes.size();i++) {
- String path="shapes/"+itos(i)+"/";
- p_list->push_back( PropertyInfo(Variant::OBJECT,path+"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) );
- p_list->push_back( PropertyInfo(Variant::TRANSFORM,path+"transform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) );
- p_list->push_back( PropertyInfo(Variant::BOOL,path+"trigger",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR|PROPERTY_USAGE_NO_INSTANCE_STATE) );
+ p_list->push_back(PropertyInfo(Variant::INT, "shape_count", PROPERTY_HINT_RANGE, "0,256,1", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
+ for (int i = 0; i < shapes.size(); i++) {
+ String path = "shapes/" + itos(i) + "/";
+ p_list->push_back(PropertyInfo(Variant::OBJECT, path + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM, path + "transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
+ p_list->push_back(PropertyInfo(Variant::BOOL, path + "trigger", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_NO_INSTANCE_STATE));
}
}
-
-void CollisionObject::_input_event(Node *p_camera, const InputEvent& p_input_event, const Vector3& p_pos, const Vector3& p_normal, int p_shape) {
+void CollisionObject::_input_event(Node *p_camera, const InputEvent &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape) {
if (get_script_instance()) {
- get_script_instance()->call(SceneStringNames::get_singleton()->_input_event,p_camera,p_input_event,p_pos,p_normal,p_shape);
+ get_script_instance()->call(SceneStringNames::get_singleton()->_input_event, p_camera, p_input_event, p_pos, p_normal, p_shape);
}
- emit_signal(SceneStringNames::get_singleton()->input_event,p_camera,p_input_event,p_pos,p_normal,p_shape);
+ emit_signal(SceneStringNames::get_singleton()->input_event, p_camera, p_input_event, p_pos, p_normal, p_shape);
}
void CollisionObject::_mouse_enter() {
@@ -193,14 +187,12 @@ void CollisionObject::_mouse_enter() {
emit_signal(SceneStringNames::get_singleton()->mouse_enter);
}
-
void CollisionObject::_mouse_exit() {
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_mouse_exit);
}
emit_signal(SceneStringNames::get_singleton()->mouse_exit);
-
}
void CollisionObject::_update_pickable() {
@@ -208,16 +200,15 @@ void CollisionObject::_update_pickable() {
return;
bool pickable = ray_pickable && is_inside_tree() && is_visible();
if (area)
- PhysicsServer::get_singleton()->area_set_ray_pickable(rid,pickable);
+ PhysicsServer::get_singleton()->area_set_ray_pickable(rid, pickable);
else
- PhysicsServer::get_singleton()->body_set_ray_pickable(rid,pickable);
+ PhysicsServer::get_singleton()->body_set_ray_pickable(rid, pickable);
}
void CollisionObject::set_ray_pickable(bool p_ray_pickable) {
- ray_pickable=p_ray_pickable;
+ ray_pickable = p_ray_pickable;
_update_pickable();
-
}
bool CollisionObject::is_ray_pickable() const {
@@ -225,80 +216,74 @@ bool CollisionObject::is_ray_pickable() const {
return ray_pickable;
}
-
void CollisionObject::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_shape","shape:Shape","transform"),&CollisionObject::add_shape,DEFVAL(Transform()));
- ObjectTypeDB::bind_method(_MD("get_shape_count"),&CollisionObject::get_shape_count);
- ObjectTypeDB::bind_method(_MD("set_shape","shape_idx","shape:Shape"),&CollisionObject::set_shape);
- ObjectTypeDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
-// ObjectTypeDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
- ObjectTypeDB::bind_method(_MD("set_shape_as_trigger","shape_idx","enable"),&CollisionObject::set_shape_as_trigger);
- ObjectTypeDB::bind_method(_MD("is_shape_set_as_trigger","shape_idx"),&CollisionObject::is_shape_set_as_trigger);
- ObjectTypeDB::bind_method(_MD("get_shape:Shape","shape_idx"),&CollisionObject::get_shape);
- ObjectTypeDB::bind_method(_MD("get_shape_transform","shape_idx"),&CollisionObject::get_shape_transform);
- ObjectTypeDB::bind_method(_MD("remove_shape","shape_idx"),&CollisionObject::remove_shape);
- ObjectTypeDB::bind_method(_MD("clear_shapes"),&CollisionObject::clear_shapes);
- ObjectTypeDB::bind_method(_MD("set_ray_pickable","ray_pickable"),&CollisionObject::set_ray_pickable);
- ObjectTypeDB::bind_method(_MD("is_ray_pickable"),&CollisionObject::is_ray_pickable);
- ObjectTypeDB::bind_method(_MD("set_capture_input_on_drag","enable"),&CollisionObject::set_capture_input_on_drag);
- ObjectTypeDB::bind_method(_MD("get_capture_input_on_drag"),&CollisionObject::get_capture_input_on_drag);
- ObjectTypeDB::bind_method(_MD("get_rid"),&CollisionObject::get_rid);
- BIND_VMETHOD( MethodInfo("_input_event",PropertyInfo(Variant::OBJECT,"camera"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::VECTOR3,"click_pos"),PropertyInfo(Variant::VECTOR3,"click_normal"),PropertyInfo(Variant::INT,"shape_idx")));
+ ObjectTypeDB::bind_method(_MD("add_shape", "shape:Shape", "transform"), &CollisionObject::add_shape, DEFVAL(Transform()));
+ ObjectTypeDB::bind_method(_MD("get_shape_count"), &CollisionObject::get_shape_count);
+ ObjectTypeDB::bind_method(_MD("set_shape", "shape_idx", "shape:Shape"), &CollisionObject::set_shape);
+ ObjectTypeDB::bind_method(_MD("set_shape_transform", "shape_idx", "transform"), &CollisionObject::set_shape_transform);
+ // ObjectTypeDB::bind_method(_MD("set_shape_transform","shape_idx","transform"),&CollisionObject::set_shape_transform);
+ ObjectTypeDB::bind_method(_MD("set_shape_as_trigger", "shape_idx", "enable"), &CollisionObject::set_shape_as_trigger);
+ ObjectTypeDB::bind_method(_MD("is_shape_set_as_trigger", "shape_idx"), &CollisionObject::is_shape_set_as_trigger);
+ ObjectTypeDB::bind_method(_MD("get_shape:Shape", "shape_idx"), &CollisionObject::get_shape);
+ ObjectTypeDB::bind_method(_MD("get_shape_transform", "shape_idx"), &CollisionObject::get_shape_transform);
+ ObjectTypeDB::bind_method(_MD("remove_shape", "shape_idx"), &CollisionObject::remove_shape);
+ ObjectTypeDB::bind_method(_MD("clear_shapes"), &CollisionObject::clear_shapes);
+ ObjectTypeDB::bind_method(_MD("set_ray_pickable", "ray_pickable"), &CollisionObject::set_ray_pickable);
+ ObjectTypeDB::bind_method(_MD("is_ray_pickable"), &CollisionObject::is_ray_pickable);
+ ObjectTypeDB::bind_method(_MD("set_capture_input_on_drag", "enable"), &CollisionObject::set_capture_input_on_drag);
+ ObjectTypeDB::bind_method(_MD("get_capture_input_on_drag"), &CollisionObject::get_capture_input_on_drag);
+ ObjectTypeDB::bind_method(_MD("get_rid"), &CollisionObject::get_rid);
+ BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::INPUT_EVENT, "event"), PropertyInfo(Variant::VECTOR3, "click_pos"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx")));
- ADD_SIGNAL( MethodInfo("input_event",PropertyInfo(Variant::OBJECT,"camera"),PropertyInfo(Variant::INPUT_EVENT,"event"),PropertyInfo(Variant::VECTOR3,"click_pos"),PropertyInfo(Variant::VECTOR3,"click_normal"),PropertyInfo(Variant::INT,"shape_idx")));
- ADD_SIGNAL( MethodInfo("mouse_enter"));
- ADD_SIGNAL( MethodInfo("mouse_exit"));
+ ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::OBJECT, "camera"), PropertyInfo(Variant::INPUT_EVENT, "event"), PropertyInfo(Variant::VECTOR3, "click_pos"), PropertyInfo(Variant::VECTOR3, "click_normal"), PropertyInfo(Variant::INT, "shape_idx")));
+ ADD_SIGNAL(MethodInfo("mouse_enter"));
+ ADD_SIGNAL(MethodInfo("mouse_exit"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"input/ray_pickable"),_SCS("set_ray_pickable"),_SCS("is_ray_pickable"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"input/capture_on_drag"),_SCS("set_capture_input_on_drag"),_SCS("get_capture_input_on_drag"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input/ray_pickable"), _SCS("set_ray_pickable"), _SCS("is_ray_pickable"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "input/capture_on_drag"), _SCS("set_capture_input_on_drag"), _SCS("get_capture_input_on_drag"));
}
-
-void CollisionObject::add_shape(const Ref<Shape>& p_shape, const Transform& p_transform) {
+void CollisionObject::add_shape(const Ref<Shape> &p_shape, const Transform &p_transform) {
ShapeData sdata;
- sdata.shape=p_shape;
- sdata.xform=p_transform;
+ sdata.shape = p_shape;
+ sdata.xform = p_transform;
shapes.push_back(sdata);
_update_shapes();
-
}
int CollisionObject::get_shape_count() const {
return shapes.size();
-
}
-void CollisionObject::set_shape(int p_shape_idx, const Ref<Shape>& p_shape) {
+void CollisionObject::set_shape(int p_shape_idx, const Ref<Shape> &p_shape) {
- ERR_FAIL_INDEX(p_shape_idx,shapes.size());
- shapes[p_shape_idx].shape=p_shape;
+ ERR_FAIL_INDEX(p_shape_idx, shapes.size());
+ shapes[p_shape_idx].shape = p_shape;
_update_shapes();
}
-void CollisionObject::set_shape_transform(int p_shape_idx, const Transform& p_transform) {
+void CollisionObject::set_shape_transform(int p_shape_idx, const Transform &p_transform) {
- ERR_FAIL_INDEX(p_shape_idx,shapes.size());
- shapes[p_shape_idx].xform=p_transform;
+ ERR_FAIL_INDEX(p_shape_idx, shapes.size());
+ shapes[p_shape_idx].xform = p_transform;
_update_shapes();
}
Ref<Shape> CollisionObject::get_shape(int p_shape_idx) const {
- ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Ref<Shape>());
+ ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), Ref<Shape>());
return shapes[p_shape_idx].shape;
-
}
Transform CollisionObject::get_shape_transform(int p_shape_idx) const {
- ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),Transform());
+ ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), Transform());
return shapes[p_shape_idx].xform;
-
}
void CollisionObject::remove_shape(int p_shape_idx) {
- ERR_FAIL_INDEX(p_shape_idx,shapes.size());
+ ERR_FAIL_INDEX(p_shape_idx, shapes.size());
shapes.remove(p_shape_idx);
_update_shapes();
@@ -313,40 +298,37 @@ void CollisionObject::clear_shapes() {
void CollisionObject::set_shape_as_trigger(int p_shape_idx, bool p_trigger) {
- ERR_FAIL_INDEX(p_shape_idx,shapes.size());
- shapes[p_shape_idx].trigger=p_trigger;
- if (!area && rid.is_valid()) {
-
- PhysicsServer::get_singleton()->body_set_shape_as_trigger(rid,p_shape_idx,p_trigger);
+ ERR_FAIL_INDEX(p_shape_idx, shapes.size());
+ shapes[p_shape_idx].trigger = p_trigger;
+ if (!area && rid.is_valid()) {
- }
+ PhysicsServer::get_singleton()->body_set_shape_as_trigger(rid, p_shape_idx, p_trigger);
+ }
}
bool CollisionObject::is_shape_set_as_trigger(int p_shape_idx) const {
- ERR_FAIL_INDEX_V(p_shape_idx,shapes.size(),false);
- return shapes[p_shape_idx].trigger;
+ ERR_FAIL_INDEX_V(p_shape_idx, shapes.size(), false);
+ return shapes[p_shape_idx].trigger;
}
CollisionObject::CollisionObject(RID p_rid, bool p_area) {
- rid=p_rid;
- area=p_area;
- capture_input_on_drag=false;
- ray_pickable=true;
+ rid = p_rid;
+ area = p_area;
+ capture_input_on_drag = false;
+ ray_pickable = true;
if (p_area) {
- PhysicsServer::get_singleton()->area_attach_object_instance_ID(rid,get_instance_ID());
+ PhysicsServer::get_singleton()->area_attach_object_instance_ID(rid, get_instance_ID());
} else {
- PhysicsServer::get_singleton()->body_attach_object_instance_ID(rid,get_instance_ID());
+ PhysicsServer::get_singleton()->body_attach_object_instance_ID(rid, get_instance_ID());
}
-// set_transform_notify(true);
-
+ // set_transform_notify(true);
}
void CollisionObject::set_capture_input_on_drag(bool p_capture) {
- capture_input_on_drag=p_capture;
-
+ capture_input_on_drag = p_capture;
}
bool CollisionObject::get_capture_input_on_drag() const {
@@ -354,12 +336,10 @@ bool CollisionObject::get_capture_input_on_drag() const {
return capture_input_on_drag;
}
-
CollisionObject::CollisionObject() {
-
- capture_input_on_drag=false;
- ray_pickable=true;
+ capture_input_on_drag = false;
+ ray_pickable = true;
//owner=
diff --git a/scene/3d/collision_object.h b/scene/3d/collision_object.h
index c1d08bfc4..c1e467f05 100644
--- a/scene/3d/collision_object.h
+++ b/scene/3d/collision_object.h
@@ -34,7 +34,7 @@
class CollisionObject : public Spatial {
- OBJ_TYPE( CollisionObject, Spatial );
+ OBJ_TYPE(CollisionObject, Spatial);
bool area;
RID rid;
@@ -42,12 +42,11 @@ class CollisionObject : public Spatial {
struct ShapeData {
Transform xform;
Ref<Shape> shape;
- bool trigger;
-
- ShapeData() {
- trigger=false;
- }
+ bool trigger;
+ ShapeData() {
+ trigger = false;
+ }
};
bool capture_input_on_drag;
@@ -57,30 +56,28 @@ class CollisionObject : public Spatial {
void _update_pickable();
void _update_shapes();
-friend class CollisionShape;
-friend class CollisionPolygon;
+ friend class CollisionShape;
+ friend class CollisionPolygon;
void _update_shapes_from_children();
-protected:
+protected:
CollisionObject(RID p_rid, bool p_area);
void _notification(int p_what);
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
-friend class Viewport;
- virtual void _input_event(Node* p_camera,const InputEvent& p_input_event,const Vector3& p_pos, const Vector3& p_normal, int p_shape);
+ friend class Viewport;
+ virtual void _input_event(Node *p_camera, const InputEvent &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape);
virtual void _mouse_enter();
virtual void _mouse_exit();
public:
-
-
- void add_shape(const Ref<Shape>& p_shape, const Transform& p_transform=Transform());
+ void add_shape(const Ref<Shape> &p_shape, const Transform &p_transform = Transform());
int get_shape_count() const;
- void set_shape(int p_shape_idx, const Ref<Shape>& p_shape);
- void set_shape_transform(int p_shape_idx, const Transform& p_transform);
+ void set_shape(int p_shape_idx, const Ref<Shape> &p_shape);
+ void set_shape_transform(int p_shape_idx, const Transform &p_transform);
Ref<Shape> get_shape(int p_shape_idx) const;
Transform get_shape_transform(int p_shape_idx) const;
void remove_shape(int p_shape_idx);
@@ -94,7 +91,6 @@ public:
void set_capture_input_on_drag(bool p_capture);
bool get_capture_input_on_drag() const;
-
_FORCE_INLINE_ RID get_rid() const { return rid; }
CollisionObject();
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp
index 2ee1978c3..6ad75d500 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon.cpp
@@ -40,44 +40,43 @@ void CollisionPolygon::_add_to_collision_object(Object *p_obj) {
CollisionObject *co = p_obj->cast_to<CollisionObject>();
ERR_FAIL_COND(!co);
- if (polygon.size()==0)
+ if (polygon.size() == 0)
return;
- bool solids=build_mode==BUILD_SOLIDS;
+ bool solids = build_mode == BUILD_SOLIDS;
- Vector< Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
- if (decomp.size()==0)
+ Vector<Vector<Vector2> > decomp = Geometry::decompose_polygon(polygon);
+ if (decomp.size() == 0)
return;
if (true || solids) {
//here comes the sun, lalalala
//decompose concave into multiple convex polygons and add them
- shape_from=co->get_shape_count();
- for(int i=0;i<decomp.size();i++) {
- Ref<ConvexPolygonShape> convex = memnew( ConvexPolygonShape );
+ shape_from = co->get_shape_count();
+ for (int i = 0; i < decomp.size(); i++) {
+ Ref<ConvexPolygonShape> convex = memnew(ConvexPolygonShape);
DVector<Vector3> cp;
int cs = decomp[i].size();
- cp.resize(cs*2);
+ cp.resize(cs * 2);
{
DVector<Vector3>::Write w = cp.write();
- int idx=0;
- for(int j=0;j<cs;j++) {
+ int idx = 0;
+ for (int j = 0; j < cs; j++) {
Vector2 d = decomp[i][j];
- w[idx++]=Vector3(d.x,d.y,depth*0.5);
- w[idx++]=Vector3(d.x,d.y,-depth*0.5);
+ w[idx++] = Vector3(d.x, d.y, depth * 0.5);
+ w[idx++] = Vector3(d.x, d.y, -depth * 0.5);
}
}
convex->set_points(cp);
- co->add_shape(convex,get_transform());
-
+ co->add_shape(convex, get_transform());
}
- shape_to=co->get_shape_count()-1;
- if (shape_to<shape_from) {
- shape_from=-1;
- shape_to=-1;
+ shape_to = co->get_shape_count() - 1;
+ if (shape_to < shape_from) {
+ shape_from = -1;
+ shape_to = -1;
}
} else {
@@ -100,9 +99,7 @@ void CollisionPolygon::_add_to_collision_object(Object *p_obj) {
#endif
}
-
//co->add_shape(shape,get_transform());
-
}
void CollisionPolygon::_update_parent() {
@@ -119,29 +116,28 @@ void CollisionPolygon::_update_parent() {
co->_update_shapes_from_children();
}
-void CollisionPolygon::_set_shape_range(const Vector2& p_range) {
+void CollisionPolygon::_set_shape_range(const Vector2 &p_range) {
- shape_from=p_range.x;
- shape_to=p_range.y;
+ shape_from = p_range.x;
+ shape_to = p_range.y;
}
Vector2 CollisionPolygon::_get_shape_range() const {
- return Vector2(shape_from,shape_to);
+ return Vector2(shape_from, shape_to);
}
void CollisionPolygon::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- can_update_body=get_tree()->is_editor_hint();
+ can_update_body = get_tree()->is_editor_hint();
set_notify_local_transform(!can_update_body);
//indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
} break;
case NOTIFICATION_EXIT_TREE: {
- can_update_body=false;
+ can_update_body = false;
set_notify_local_transform(false);
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -154,12 +150,12 @@ void CollisionPolygon::_notification(int p_what) {
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
- if (!can_update_body && shape_from>=0 && shape_to>=0) {
+ if (!can_update_body && shape_from >= 0 && shape_to >= 0) {
CollisionObject *co = get_parent()->cast_to<CollisionObject>();
if (co) {
- for(int i=shape_from;i<=shape_to;i++) {
- co->set_shape_transform(i,get_transform());
+ for (int i = shape_from; i <= shape_to; i++) {
+ co->set_shape_transform(i, get_transform());
}
}
}
@@ -190,31 +186,29 @@ void CollisionPolygon::_notification(int p_what) {
}
}
-void CollisionPolygon::set_polygon(const Vector<Point2>& p_polygon) {
+void CollisionPolygon::set_polygon(const Vector<Point2> &p_polygon) {
- polygon=p_polygon;
+ polygon = p_polygon;
if (can_update_body) {
- for(int i=0;i<polygon.size();i++) {
+ for (int i = 0; i < polygon.size(); i++) {
- Vector3 p1(polygon[i].x,polygon[i].y,depth*0.5);
+ Vector3 p1(polygon[i].x, polygon[i].y, depth * 0.5);
- if (i==0)
- aabb=AABB(p1,Vector3());
+ if (i == 0)
+ aabb = AABB(p1, Vector3());
else
aabb.expand_to(p1);
- Vector3 p2(polygon[i].x,polygon[i].y,-depth*0.5);
+ Vector3 p2(polygon[i].x, polygon[i].y, -depth * 0.5);
aabb.expand_to(p2);
-
-
}
- if (aabb==AABB()) {
+ if (aabb == AABB()) {
- aabb=AABB(Vector3(-1,-1,-1),Vector3(2,2,2));
+ aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
} else {
- aabb.pos-=aabb.size*0.3;
- aabb.size+=aabb.size*0.6;
+ aabb.pos -= aabb.size * 0.3;
+ aabb.size += aabb.size * 0.6;
}
_update_parent();
}
@@ -228,14 +222,14 @@ Vector<Point2> CollisionPolygon::get_polygon() const {
void CollisionPolygon::set_build_mode(BuildMode p_mode) {
- ERR_FAIL_INDEX(p_mode,2);
- build_mode=p_mode;
+ ERR_FAIL_INDEX(p_mode, 2);
+ build_mode = p_mode;
if (!can_update_body)
return;
_update_parent();
}
-CollisionPolygon::BuildMode CollisionPolygon::get_build_mode() const{
+CollisionPolygon::BuildMode CollisionPolygon::get_build_mode() const {
return build_mode;
}
@@ -247,7 +241,7 @@ AABB CollisionPolygon::get_item_rect() const {
void CollisionPolygon::set_depth(float p_depth) {
- depth=p_depth;
+ depth = p_depth;
if (!can_update_body)
return;
_update_parent();
@@ -267,7 +261,6 @@ String CollisionPolygon::get_configuration_warning() const {
if (polygon.empty()) {
return TTR("An empty CollisionPolygon has no effect on collision.");
-
}
return String();
@@ -275,37 +268,36 @@ String CollisionPolygon::get_configuration_warning() const {
void CollisionPolygon::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_add_to_collision_object"),&CollisionPolygon::_add_to_collision_object);
+ ObjectTypeDB::bind_method(_MD("_add_to_collision_object"), &CollisionPolygon::_add_to_collision_object);
- ObjectTypeDB::bind_method(_MD("set_build_mode","build_mode"),&CollisionPolygon::set_build_mode);
- ObjectTypeDB::bind_method(_MD("get_build_mode"),&CollisionPolygon::get_build_mode);
+ ObjectTypeDB::bind_method(_MD("set_build_mode", "build_mode"), &CollisionPolygon::set_build_mode);
+ ObjectTypeDB::bind_method(_MD("get_build_mode"), &CollisionPolygon::get_build_mode);
- ObjectTypeDB::bind_method(_MD("set_depth","depth"),&CollisionPolygon::set_depth);
- ObjectTypeDB::bind_method(_MD("get_depth"),&CollisionPolygon::get_depth);
+ ObjectTypeDB::bind_method(_MD("set_depth", "depth"), &CollisionPolygon::set_depth);
+ ObjectTypeDB::bind_method(_MD("get_depth"), &CollisionPolygon::get_depth);
- ObjectTypeDB::bind_method(_MD("set_polygon","polygon"),&CollisionPolygon::set_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon"),&CollisionPolygon::get_polygon);
+ ObjectTypeDB::bind_method(_MD("set_polygon", "polygon"), &CollisionPolygon::set_polygon);
+ ObjectTypeDB::bind_method(_MD("get_polygon"), &CollisionPolygon::get_polygon);
- ObjectTypeDB::bind_method(_MD("_set_shape_range","shape_range"),&CollisionPolygon::_set_shape_range);
- ObjectTypeDB::bind_method(_MD("_get_shape_range"),&CollisionPolygon::_get_shape_range);
+ ObjectTypeDB::bind_method(_MD("_set_shape_range", "shape_range"), &CollisionPolygon::_set_shape_range);
+ ObjectTypeDB::bind_method(_MD("_get_shape_range"), &CollisionPolygon::_get_shape_range);
- ObjectTypeDB::bind_method(_MD("get_collision_object_first_shape"),&CollisionPolygon::get_collision_object_first_shape);
- ObjectTypeDB::bind_method(_MD("get_collision_object_last_shape"),&CollisionPolygon::get_collision_object_last_shape);
+ ObjectTypeDB::bind_method(_MD("get_collision_object_first_shape"), &CollisionPolygon::get_collision_object_first_shape);
+ ObjectTypeDB::bind_method(_MD("get_collision_object_last_shape"), &CollisionPolygon::get_collision_object_last_shape);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"build_mode",PROPERTY_HINT_ENUM,"Solids,Triangles"),_SCS("set_build_mode"),_SCS("get_build_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"depth"),_SCS("set_depth"),_SCS("get_depth"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"polygon"),_SCS("set_polygon"),_SCS("get_polygon"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"shape_range",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_shape_range"),_SCS("_get_shape_range"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "build_mode", PROPERTY_HINT_ENUM, "Solids,Triangles"), _SCS("set_build_mode"), _SCS("get_build_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "depth"), _SCS("set_depth"), _SCS("get_depth"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "polygon"), _SCS("set_polygon"), _SCS("get_polygon"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "shape_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_shape_range"), _SCS("_get_shape_range"));
}
CollisionPolygon::CollisionPolygon() {
- shape_from=-1;
- shape_to=-1;
- can_update_body=false;
-
- aabb=AABB(Vector3(-1,-1,-1),Vector3(2,2,2));
- build_mode=BUILD_SOLIDS;
- depth=1.0;
+ shape_from = -1;
+ shape_to = -1;
+ can_update_body = false;
+ aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
+ build_mode = BUILD_SOLIDS;
+ depth = 1.0;
}
diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h
index 54853b7c8..9afa601f5 100644
--- a/scene/3d/collision_polygon.h
+++ b/scene/3d/collision_polygon.h
@@ -32,27 +32,22 @@
#include "scene/3d/spatial.h"
#include "scene/resources/shape.h"
-
-
class CollisionPolygon : public Spatial {
- OBJ_TYPE(CollisionPolygon,Spatial);
-public:
+ OBJ_TYPE(CollisionPolygon, Spatial);
+public:
enum BuildMode {
BUILD_SOLIDS,
BUILD_TRIANGLES,
};
protected:
-
-
float depth;
AABB aabb;
BuildMode build_mode;
Vector<Point2> polygon;
-
void _add_to_collision_object(Object *p_obj);
void _update_parent();
@@ -60,22 +55,21 @@ protected:
int shape_from;
int shape_to;
- void _set_shape_range(const Vector2& p_range);
+ void _set_shape_range(const Vector2 &p_range);
Vector2 _get_shape_range() const;
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_build_mode(BuildMode p_mode);
BuildMode get_build_mode() const;
void set_depth(float p_depth);
float get_depth() const;
- void set_polygon(const Vector<Point2>& p_polygon);
+ void set_polygon(const Vector<Point2> &p_polygon);
Vector<Point2> get_polygon() const;
virtual AABB get_item_rect() const;
@@ -88,5 +82,5 @@ public:
CollisionPolygon();
};
-VARIANT_ENUM_CAST( CollisionPolygon::BuildMode );
+VARIANT_ENUM_CAST(CollisionPolygon::BuildMode);
#endif // COLLISION_POLYGON_H
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index d8ee1b8a6..7c8f57983 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -28,68 +28,60 @@
/*************************************************************************/
#include "immediate_geometry.h"
+void ImmediateGeometry::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture> &p_texture) {
-void ImmediateGeometry::begin(Mesh::PrimitiveType p_primitive,const Ref<Texture>& p_texture) {
-
- VS::get_singleton()->immediate_begin(im,(VS::PrimitiveType)p_primitive,p_texture.is_valid()?p_texture->get_rid():RID());
+ VS::get_singleton()->immediate_begin(im, (VS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID());
if (p_texture.is_valid())
cached_textures.push_back(p_texture);
-
}
-void ImmediateGeometry::set_normal(const Vector3& p_normal){
+void ImmediateGeometry::set_normal(const Vector3 &p_normal) {
- VS::get_singleton()->immediate_normal(im,p_normal);
+ VS::get_singleton()->immediate_normal(im, p_normal);
}
-void ImmediateGeometry::set_tangent(const Plane& p_tangent){
-
- VS::get_singleton()->immediate_tangent(im,p_tangent);
+void ImmediateGeometry::set_tangent(const Plane &p_tangent) {
+ VS::get_singleton()->immediate_tangent(im, p_tangent);
}
-void ImmediateGeometry::set_color(const Color& p_color){
-
- VS::get_singleton()->immediate_color(im,p_color);
+void ImmediateGeometry::set_color(const Color &p_color) {
+ VS::get_singleton()->immediate_color(im, p_color);
}
-void ImmediateGeometry::set_uv(const Vector2& p_uv){
-
- VS::get_singleton()->immediate_uv(im,p_uv);
+void ImmediateGeometry::set_uv(const Vector2 &p_uv) {
+ VS::get_singleton()->immediate_uv(im, p_uv);
}
-void ImmediateGeometry::set_uv2(const Vector2& p_uv2){
-
- VS::get_singleton()->immediate_uv2(im,p_uv2);
+void ImmediateGeometry::set_uv2(const Vector2 &p_uv2) {
+ VS::get_singleton()->immediate_uv2(im, p_uv2);
}
-void ImmediateGeometry::add_vertex(const Vector3& p_vertex){
+void ImmediateGeometry::add_vertex(const Vector3 &p_vertex) {
- VS::get_singleton()->immediate_vertex(im,p_vertex);
+ VS::get_singleton()->immediate_vertex(im, p_vertex);
if (empty) {
- aabb.pos=p_vertex;
- aabb.size=Vector3();
- empty=false;
+ aabb.pos = p_vertex;
+ aabb.size = Vector3();
+ empty = false;
} else {
aabb.expand_to(p_vertex);
}
}
-void ImmediateGeometry::end(){
+void ImmediateGeometry::end() {
VS::get_singleton()->immediate_end(im);
-
}
-void ImmediateGeometry::clear(){
+void ImmediateGeometry::clear() {
VS::get_singleton()->immediate_clear(im);
- empty=true;
+ empty = true;
cached_textures.clear();
-
}
AABB ImmediateGeometry::get_aabb() const {
@@ -101,44 +93,41 @@ DVector<Face3> ImmediateGeometry::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
}
-
-
void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) {
- for(int i = 1; i <= p_lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double) (i - 1) / p_lats);
- double z0 = Math::sin(lat0);
- double zr0 = Math::cos(lat0);
+ for (int i = 1; i <= p_lats; i++) {
+ double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats);
+ double z0 = Math::sin(lat0);
+ double zr0 = Math::cos(lat0);
- double lat1 = Math_PI * (-0.5 + (double) i / p_lats);
+ double lat1 = Math_PI * (-0.5 + (double)i / p_lats);
double z1 = Math::sin(lat1);
double zr1 = Math::cos(lat1);
- for(int j = p_lons; j >= 1; j--) {
+ for (int j = p_lons; j >= 1; j--) {
- double lng0 = 2 * Math_PI * (double) (j - 1) / p_lons;
+ double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons;
double x0 = Math::cos(lng0);
double y0 = Math::sin(lng0);
- double lng1 = 2 * Math_PI * (double) (j) / p_lons;
+ double lng1 = 2 * Math_PI * (double)(j) / p_lons;
double x1 = Math::cos(lng1);
double y1 = Math::sin(lng1);
-
- Vector3 v[4]={
- Vector3(x1 * zr0, z0, y1 *zr0),
- Vector3(x1 * zr1, z1, y1 *zr1),
- Vector3(x0 * zr1, z1, y0 *zr1),
- Vector3(x0 * zr0, z0, y0 *zr0)
+ Vector3 v[4] = {
+ Vector3(x1 * zr0, z0, y1 * zr0),
+ Vector3(x1 * zr1, z1, y1 * zr1),
+ Vector3(x0 * zr1, z1, y0 * zr1),
+ Vector3(x0 * zr0, z0, y0 * zr0)
};
-#define ADD_POINT(m_idx)\
- if (p_add_uv) {\
- set_uv(Vector2(Math::atan2(v[m_idx].x,v[m_idx].z)/Math_PI * 0.5+0.5,v[m_idx].y*0.5+0.5));\
- set_tangent(Plane(Vector3(-v[m_idx].z,v[m_idx].y,v[m_idx].x),1)); \
- }\
- set_normal(v[m_idx]);\
- add_vertex(v[m_idx]*p_radius);
+#define ADD_POINT(m_idx) \
+ if (p_add_uv) { \
+ set_uv(Vector2(Math::atan2(v[m_idx].x, v[m_idx].z) / Math_PI * 0.5 + 0.5, v[m_idx].y * 0.5 + 0.5)); \
+ set_tangent(Plane(Vector3(-v[m_idx].z, v[m_idx].y, v[m_idx].x), 1)); \
+ } \
+ set_normal(v[m_idx]); \
+ add_vertex(v[m_idx] * p_radius);
ADD_POINT(0);
ADD_POINT(1);
@@ -149,37 +138,30 @@ void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool
ADD_POINT(0);
}
}
-
}
void ImmediateGeometry::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("begin","primitive","texture:Texture"),&ImmediateGeometry::begin,DEFVAL(Ref<Texture>()));
- ObjectTypeDB::bind_method(_MD("set_normal","normal"),&ImmediateGeometry::set_normal);
- ObjectTypeDB::bind_method(_MD("set_tangent","tangent"),&ImmediateGeometry::set_tangent);
- ObjectTypeDB::bind_method(_MD("set_color","color"),&ImmediateGeometry::set_color);
- ObjectTypeDB::bind_method(_MD("set_uv","uv"),&ImmediateGeometry::set_uv);
- ObjectTypeDB::bind_method(_MD("set_uv2","uv"),&ImmediateGeometry::set_uv2);
- ObjectTypeDB::bind_method(_MD("add_vertex","pos"),&ImmediateGeometry::add_vertex);
- ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius","add_uv"),&ImmediateGeometry::add_sphere,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("end"),&ImmediateGeometry::end);
- ObjectTypeDB::bind_method(_MD("clear"),&ImmediateGeometry::clear);
-
+ ObjectTypeDB::bind_method(_MD("begin", "primitive", "texture:Texture"), &ImmediateGeometry::begin, DEFVAL(Ref<Texture>()));
+ ObjectTypeDB::bind_method(_MD("set_normal", "normal"), &ImmediateGeometry::set_normal);
+ ObjectTypeDB::bind_method(_MD("set_tangent", "tangent"), &ImmediateGeometry::set_tangent);
+ ObjectTypeDB::bind_method(_MD("set_color", "color"), &ImmediateGeometry::set_color);
+ ObjectTypeDB::bind_method(_MD("set_uv", "uv"), &ImmediateGeometry::set_uv);
+ ObjectTypeDB::bind_method(_MD("set_uv2", "uv"), &ImmediateGeometry::set_uv2);
+ ObjectTypeDB::bind_method(_MD("add_vertex", "pos"), &ImmediateGeometry::add_vertex);
+ ObjectTypeDB::bind_method(_MD("add_sphere", "lats", "lons", "radius", "add_uv"), &ImmediateGeometry::add_sphere, DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("end"), &ImmediateGeometry::end);
+ ObjectTypeDB::bind_method(_MD("clear"), &ImmediateGeometry::clear);
}
-
-
ImmediateGeometry::ImmediateGeometry() {
im = VisualServer::get_singleton()->immediate_create();
set_base(im);
- empty=true;
-
+ empty = true;
}
-
ImmediateGeometry::~ImmediateGeometry() {
VisualServer::get_singleton()->free(im);
-
}
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h
index a58743e9c..b91a87cff 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry.h
@@ -34,8 +34,7 @@
class ImmediateGeometry : public GeometryInstance {
- OBJ_TYPE(ImmediateGeometry,GeometryInstance);
-
+ OBJ_TYPE(ImmediateGeometry, GeometryInstance);
RID im;
//a list of texures drawn need to be kept, to avoid references
@@ -43,28 +42,24 @@ class ImmediateGeometry : public GeometryInstance {
List<Ref<Texture> > cached_textures;
bool empty;
AABB aabb;
-protected:
+protected:
static void _bind_methods();
-public:
-
- void begin(Mesh::PrimitiveType p_primitive,const Ref<Texture>& p_texture=Ref<Texture>());
- void set_normal(const Vector3& p_normal);
- void set_tangent(const Plane& p_tangent);
- void set_color(const Color& p_color);
- void set_uv(const Vector2& tex_uv);
- void set_uv2(const Vector2& tex_uv);
+public:
+ void begin(Mesh::PrimitiveType p_primitive, const Ref<Texture> &p_texture = Ref<Texture>());
+ void set_normal(const Vector3 &p_normal);
+ void set_tangent(const Plane &p_tangent);
+ void set_color(const Color &p_color);
+ void set_uv(const Vector2 &tex_uv);
+ void set_uv2(const Vector2 &tex_uv);
- void add_vertex(const Vector3& p_vertex);
+ void add_vertex(const Vector3 &p_vertex);
void end();
void clear();
-
- void add_sphere(int p_lats,int p_lons,float p_radius,bool p_add_uv=true);
-
-
+ void add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv = true);
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp
index 245aefd4d..ae8c9ef37 100644
--- a/scene/3d/interpolated_camera.cpp
+++ b/scene/3d/interpolated_camera.cpp
@@ -28,10 +28,9 @@
/*************************************************************************/
#include "interpolated_camera.h"
-
void InterpolatedCamera::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (get_tree()->is_editor_hint() && enabled)
@@ -48,32 +47,30 @@ void InterpolatedCamera::_notification(int p_what) {
if (!node)
break;
- float delta = speed*get_process_delta_time();
+ float delta = speed * get_process_delta_time();
Transform target_xform = node->get_global_transform();
Transform local_transform = get_global_transform();
- local_transform = local_transform.interpolate_with(target_xform,delta);
+ local_transform = local_transform.interpolate_with(target_xform, delta);
set_global_transform(local_transform);
if (node->cast_to<Camera>()) {
Camera *cam = node->cast_to<Camera>();
- if (cam->get_projection()==get_projection()) {
+ if (cam->get_projection() == get_projection()) {
- float new_near = Math::lerp(get_znear(),cam->get_znear(),delta);
- float new_far = Math::lerp(get_zfar(),cam->get_zfar(),delta);
+ float new_near = Math::lerp(get_znear(), cam->get_znear(), delta);
+ float new_far = Math::lerp(get_zfar(), cam->get_zfar(), delta);
- if (cam->get_projection()==PROJECTION_ORTHOGONAL) {
+ if (cam->get_projection() == PROJECTION_ORTHOGONAL) {
- float size = Math::lerp(get_size(),cam->get_size(),delta);
- set_orthogonal(size,new_near,new_far);
+ float size = Math::lerp(get_size(), cam->get_size(), delta);
+ set_orthogonal(size, new_near, new_far);
} else {
- float fov = Math::lerp(get_fov(),cam->get_fov(),delta);
- set_perspective(fov,new_near,new_far);
+ float fov = Math::lerp(get_fov(), cam->get_fov(), delta);
+ set_perspective(fov, new_near, new_far);
}
}
}
-
-
}
} break;
@@ -89,25 +86,24 @@ void InterpolatedCamera::_set_target(const Object *p_target) {
void InterpolatedCamera::set_target(const Spatial *p_target) {
ERR_FAIL_NULL(p_target);
- target=get_path_to(p_target);
+ target = get_path_to(p_target);
}
+void InterpolatedCamera::set_target_path(const NodePath &p_path) {
-void InterpolatedCamera::set_target_path(const NodePath& p_path){
-
- target=p_path;
+ target = p_path;
}
-NodePath InterpolatedCamera::get_target_path() const{
+NodePath InterpolatedCamera::get_target_path() const {
return target;
}
void InterpolatedCamera::set_interpolation_enabled(bool p_enable) {
- if (enabled==p_enable)
+ if (enabled == p_enable)
return;
- enabled=p_enable;
+ enabled = p_enable;
if (p_enable) {
if (is_inside_tree() && get_tree()->is_editor_hint())
return;
@@ -123,7 +119,7 @@ bool InterpolatedCamera::is_interpolation_enabled() const {
void InterpolatedCamera::set_speed(real_t p_speed) {
- speed=p_speed;
+ speed = p_speed;
}
real_t InterpolatedCamera::get_speed() const {
@@ -131,27 +127,25 @@ real_t InterpolatedCamera::get_speed() const {
return speed;
}
-
void InterpolatedCamera::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_target_path","target_path"),&InterpolatedCamera::set_target_path);
- ObjectTypeDB::bind_method(_MD("get_target_path"),&InterpolatedCamera::get_target_path);
- ObjectTypeDB::bind_method(_MD("set_target","target:Camera"),&InterpolatedCamera::_set_target);
+ ObjectTypeDB::bind_method(_MD("set_target_path", "target_path"), &InterpolatedCamera::set_target_path);
+ ObjectTypeDB::bind_method(_MD("get_target_path"), &InterpolatedCamera::get_target_path);
+ ObjectTypeDB::bind_method(_MD("set_target", "target:Camera"), &InterpolatedCamera::_set_target);
- ObjectTypeDB::bind_method(_MD("set_speed","speed"),&InterpolatedCamera::set_speed);
- ObjectTypeDB::bind_method(_MD("get_speed"),&InterpolatedCamera::get_speed);
+ ObjectTypeDB::bind_method(_MD("set_speed", "speed"), &InterpolatedCamera::set_speed);
+ ObjectTypeDB::bind_method(_MD("get_speed"), &InterpolatedCamera::get_speed);
- ObjectTypeDB::bind_method(_MD("set_interpolation_enabled","target_path"),&InterpolatedCamera::set_interpolation_enabled);
- ObjectTypeDB::bind_method(_MD("is_interpolation_enabled"),&InterpolatedCamera::is_interpolation_enabled);
+ ObjectTypeDB::bind_method(_MD("set_interpolation_enabled", "target_path"), &InterpolatedCamera::set_interpolation_enabled);
+ ObjectTypeDB::bind_method(_MD("is_interpolation_enabled"), &InterpolatedCamera::is_interpolation_enabled);
- ADD_PROPERTY( PropertyInfo(Variant::NODE_PATH,"target"), _SCS("set_target_path"), _SCS("get_target_path") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"speed"), _SCS("set_speed"), _SCS("get_speed") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"), _SCS("set_interpolation_enabled"), _SCS("is_interpolation_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "target"), _SCS("set_target_path"), _SCS("get_target_path"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "speed"), _SCS("set_speed"), _SCS("get_speed"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), _SCS("set_interpolation_enabled"), _SCS("is_interpolation_enabled"));
}
InterpolatedCamera::InterpolatedCamera() {
- enabled=false;
- speed=1;
-
+ enabled = false;
+ speed = 1;
}
diff --git a/scene/3d/interpolated_camera.h b/scene/3d/interpolated_camera.h
index 794a9b15c..23cb8b0a1 100644
--- a/scene/3d/interpolated_camera.h
+++ b/scene/3d/interpolated_camera.h
@@ -33,21 +33,20 @@
class InterpolatedCamera : public Camera {
- OBJ_TYPE(InterpolatedCamera,Camera);
+ OBJ_TYPE(InterpolatedCamera, Camera);
bool enabled;
real_t speed;
NodePath target;
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
void _set_target(const Object *p_target);
public:
-
void set_target(const Spatial *p_target);
- void set_target_path(const NodePath& p_path);
+ void set_target_path(const NodePath &p_path);
NodePath get_target_path() const;
void set_speed(real_t p_speed);
@@ -56,7 +55,6 @@ public:
void set_interpolation_enabled(bool p_enable);
bool is_interpolation_enabled() const;
-
InterpolatedCamera();
};
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index d9e153c4f..b19aeca8c 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -31,8 +31,7 @@
#include "globals.h"
#include "scene/resources/surface_tool.h"
-
-static const char* _light_param_names[VS::LIGHT_PARAM_MAX]={
+static const char *_light_param_names[VS::LIGHT_PARAM_MAX] = {
"params/spot_attenuation",
"params/spot_angle",
"params/radius",
@@ -48,40 +47,36 @@ static const char* _light_param_names[VS::LIGHT_PARAM_MAX]={
void Light::set_parameter(Parameter p_param, float p_value) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
- vars[p_param]=p_value;
- VisualServer::get_singleton()->light_set_param(light,(VisualServer::LightParam)p_param,p_value);
- if (p_param==PARAM_RADIUS || p_param==PARAM_SPOT_ANGLE)
+ vars[p_param] = p_value;
+ VisualServer::get_singleton()->light_set_param(light, (VisualServer::LightParam)p_param, p_value);
+ if (p_param == PARAM_RADIUS || p_param == PARAM_SPOT_ANGLE)
update_gizmo();
_change_notify(_light_param_names[p_param]);
-// _change_notify(_param_names[p_param]);
+ // _change_notify(_param_names[p_param]);
}
float Light::get_parameter(Parameter p_param) const {
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return vars[p_param];
-
}
-void Light::set_color(LightColor p_color, const Color& p_value) {
+void Light::set_color(LightColor p_color, const Color &p_value) {
ERR_FAIL_INDEX(p_color, 3);
- colors[p_color]=p_value;
- VisualServer::get_singleton()->light_set_color(light,(VisualServer::LightColor)p_color,p_value);
+ colors[p_color] = p_value;
+ VisualServer::get_singleton()->light_set_color(light, (VisualServer::LightColor)p_color, p_value);
//_change_notify(_color_names[p_color]);
-
}
Color Light::get_color(LightColor p_color) const {
ERR_FAIL_INDEX_V(p_color, 3, Color());
return colors[p_color];
-
}
-
void Light::set_project_shadows(bool p_enabled) {
- shadows=p_enabled;
+ shadows = p_enabled;
VisualServer::get_singleton()->light_set_shadow(light, p_enabled);
_change_notify("shadow");
}
@@ -90,10 +85,10 @@ bool Light::has_project_shadows() const {
return shadows;
}
-void Light::set_projector(const Ref<Texture>& p_projector) {
+void Light::set_projector(const Ref<Texture> &p_projector) {
- projector=p_projector;
- VisualServer::get_singleton()->light_set_projector(light, projector.is_null()?RID():projector->get_rid());
+ projector = p_projector;
+ VisualServer::get_singleton()->light_set_projector(light, projector.is_null() ? RID() : projector->get_rid());
}
Ref<Texture> Light::get_projector() const {
@@ -101,48 +96,44 @@ Ref<Texture> Light::get_projector() const {
return projector;
}
-
bool Light::_can_gizmo_scale() const {
return false;
}
-
-static void _make_sphere(int p_lats, int p_lons, float p_radius, Ref<SurfaceTool> p_tool) {
-
+static void _make_sphere(int p_lats, int p_lons, float p_radius, Ref<SurfaceTool> p_tool) {
p_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
- for(int i = 1; i <= p_lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double) (i - 1) / p_lats);
- double z0 = Math::sin(lat0);
- double zr0 = Math::cos(lat0);
+ for (int i = 1; i <= p_lats; i++) {
+ double lat0 = Math_PI * (-0.5 + (double)(i - 1) / p_lats);
+ double z0 = Math::sin(lat0);
+ double zr0 = Math::cos(lat0);
- double lat1 = Math_PI * (-0.5 + (double) i / p_lats);
+ double lat1 = Math_PI * (-0.5 + (double)i / p_lats);
double z1 = Math::sin(lat1);
double zr1 = Math::cos(lat1);
- for(int j = p_lons; j >= 1; j--) {
+ for (int j = p_lons; j >= 1; j--) {
- double lng0 = 2 * Math_PI * (double) (j - 1) / p_lons;
+ double lng0 = 2 * Math_PI * (double)(j - 1) / p_lons;
double x0 = Math::cos(lng0);
double y0 = Math::sin(lng0);
- double lng1 = 2 * Math_PI * (double) (j) / p_lons;
+ double lng1 = 2 * Math_PI * (double)(j) / p_lons;
double x1 = Math::cos(lng1);
double y1 = Math::sin(lng1);
-
- Vector3 v[4]={
- Vector3(x1 * zr0, z0, y1 *zr0),
- Vector3(x1 * zr1, z1, y1 *zr1),
- Vector3(x0 * zr1, z1, y0 *zr1),
- Vector3(x0 * zr0, z0, y0 *zr0)
+ Vector3 v[4] = {
+ Vector3(x1 * zr0, z0, y1 * zr0),
+ Vector3(x1 * zr1, z1, y1 * zr1),
+ Vector3(x0 * zr1, z1, y0 * zr1),
+ Vector3(x0 * zr0, z0, y0 * zr0)
};
-#define ADD_POINT(m_idx) \
- p_tool->add_normal(v[m_idx]);\
- p_tool->add_vertex(v[m_idx]*p_radius);
+#define ADD_POINT(m_idx) \
+ p_tool->add_normal(v[m_idx]); \
+ p_tool->add_vertex(v[m_idx] * p_radius);
ADD_POINT(0);
ADD_POINT(1);
@@ -153,76 +144,70 @@ static void _make_sphere(int p_lats, int p_lons, float p_radius, Ref<SurfaceToo
ADD_POINT(0);
}
}
-
}
RES Light::_get_gizmo_geometry() const {
+ Ref<FixedMaterial> mat_area(memnew(FixedMaterial));
- Ref<FixedMaterial> mat_area( memnew( FixedMaterial ));
+ mat_area->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.7, 0.6, 0.0, 0.05));
+ mat_area->set_parameter(FixedMaterial::PARAM_EMISSION, Color(0.7, 0.7, 0.7));
+ mat_area->set_blend_mode(Material::BLEND_MODE_ADD);
+ mat_area->set_flag(Material::FLAG_DOUBLE_SIDED, true);
+ // mat_area->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
- mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.7,0.6,0.0,0.05) );
- mat_area->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.7,0.7,0.7) );
- mat_area->set_blend_mode( Material::BLEND_MODE_ADD );
- mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat_area->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
+ Ref<FixedMaterial> mat_light(memnew(FixedMaterial));
- Ref<FixedMaterial> mat_light( memnew( FixedMaterial ));
+ mat_light->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(1.0, 1.0, 0.8, 0.9));
+ mat_light->set_flag(Material::FLAG_UNSHADED, true);
- mat_light->set_parameter( FixedMaterial::PARAM_DIFFUSE, Color(1.0,1.0,0.8,0.9) );
- mat_light->set_flag(Material::FLAG_UNSHADED,true);
+ Ref<Mesh> mesh;
- Ref< Mesh > mesh;
+ Ref<SurfaceTool> surftool(memnew(SurfaceTool));
- Ref<SurfaceTool> surftool( memnew( SurfaceTool ));
-
- switch(type) {
+ switch (type) {
case VisualServer::LIGHT_DIRECTIONAL: {
+ mat_area->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.9, 0.8, 0.1, 0.8));
+ mat_area->set_blend_mode(Material::BLEND_MODE_MIX);
+ mat_area->set_flag(Material::FLAG_DOUBLE_SIDED, false);
+ mat_area->set_flag(Material::FLAG_UNSHADED, true);
- mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.9,0.8,0.1,0.8) );
- mat_area->set_blend_mode( Material::BLEND_MODE_MIX);
- mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,false);
- mat_area->set_flag(Material::FLAG_UNSHADED,true);
-
- _make_sphere( 5,5,0.6, surftool );
+ _make_sphere(5, 5, 0.6, surftool);
surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
+ mesh = surftool->commit(mesh);
- // float radius=1;
+ // float radius=1;
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
- const int arrow_points=5;
- Vector3 arrow[arrow_points]={
- Vector3(0,0,2),
- Vector3(1,1,2),
- Vector3(1,1,-1),
- Vector3(2,2,-1),
- Vector3(0,0,-3)
+ const int arrow_points = 5;
+ Vector3 arrow[arrow_points] = {
+ Vector3(0, 0, 2),
+ Vector3(1, 1, 2),
+ Vector3(1, 1, -1),
+ Vector3(2, 2, -1),
+ Vector3(0, 0, -3)
};
- int arrow_sides=4;
-
-
- for(int i = 0; i < arrow_sides ; i++) {
-
+ int arrow_sides = 4;
- Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/arrow_sides);
- Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/arrow_sides);
+ for (int i = 0; i < arrow_sides; i++) {
+ Matrix3 ma(Vector3(0, 0, 1), Math_PI * 2 * float(i) / arrow_sides);
+ Matrix3 mb(Vector3(0, 0, 1), Math_PI * 2 * float(i + 1) / arrow_sides);
- for(int j=0;j<arrow_points-1;j++) {
+ for (int j = 0; j < arrow_points - 1; j++) {
- Vector3 points[4]={
+ Vector3 points[4] = {
ma.xform(arrow[j]),
mb.xform(arrow[j]),
- mb.xform(arrow[j+1]),
- ma.xform(arrow[j+1]),
+ mb.xform(arrow[j + 1]),
+ ma.xform(arrow[j + 1]),
};
- Vector3 n = Plane(points[0],points[1],points[2]).normal;
+ Vector3 n = Plane(points[0], points[1], points[2]).normal;
surftool->add_normal(n);
surftool->add_vertex(points[0]);
@@ -237,58 +222,50 @@ RES Light::_get_gizmo_geometry() const {
surftool->add_vertex(points[2]);
surftool->add_normal(n);
surftool->add_vertex(points[3]);
-
-
}
-
-
}
surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
-
-
+ mesh = surftool->commit(mesh);
} break;
case VisualServer::LIGHT_OMNI: {
-
- _make_sphere( 20,20,vars[PARAM_RADIUS], surftool );
+ _make_sphere(20, 20, vars[PARAM_RADIUS], surftool);
surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
- _make_sphere(5,5, 0.1, surftool );
+ mesh = surftool->commit(mesh);
+ _make_sphere(5, 5, 0.1, surftool);
surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
+ mesh = surftool->commit(mesh);
} break;
case VisualServer::LIGHT_SPOT: {
- _make_sphere( 5,5,0.1, surftool );
+ _make_sphere(5, 5, 0.1, surftool);
surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
+ mesh = surftool->commit(mesh);
// make cone
- int points=24;
- float len=vars[PARAM_RADIUS];
- float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;
+ int points = 24;
+ float len = vars[PARAM_RADIUS];
+ float size = Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE])) * len;
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
- for(int i = 0; i < points; i++) {
+ for (int i = 0; i < points; i++) {
- float x0=Math::sin(i * Math_PI * 2 / points);
- float y0=Math::cos(i * Math_PI * 2 / points);
- float x1=Math::sin((i+1) * Math_PI * 2 / points);
- float y1=Math::cos((i+1) * Math_PI * 2 / points);
+ float x0 = Math::sin(i * Math_PI * 2 / points);
+ float y0 = Math::cos(i * Math_PI * 2 / points);
+ float x1 = Math::sin((i + 1) * Math_PI * 2 / points);
+ float y1 = Math::cos((i + 1) * Math_PI * 2 / points);
- Vector3 v1=Vector3(x0*size,y0*size,-len).normalized()*len;
- Vector3 v2=Vector3(x1*size,y1*size,-len).normalized()*len;
+ Vector3 v1 = Vector3(x0 * size, y0 * size, -len).normalized() * len;
+ Vector3 v2 = Vector3(x1 * size, y1 * size, -len).normalized() * len;
- Vector3 v3=Vector3(0,0,0);
- Vector3 v4=Vector3(0,0,v1.z);
-
- Vector3 n = Plane(v1,v2,v3).normal;
+ Vector3 v3 = Vector3(0, 0, 0);
+ Vector3 v4 = Vector3(0, 0, v1.z);
+ Vector3 n = Plane(v1, v2, v3).normal;
surftool->add_normal(n);
surftool->add_vertex(v1);
@@ -297,7 +274,7 @@ RES Light::_get_gizmo_geometry() const {
surftool->add_normal(n);
surftool->add_vertex(v3);
- n=Vector3(0,0,-1);
+ n = Vector3(0, 0, -1);
surftool->add_normal(n);
surftool->add_vertex(v1);
@@ -305,13 +282,10 @@ RES Light::_get_gizmo_geometry() const {
surftool->add_vertex(v2);
surftool->add_normal(n);
surftool->add_vertex(v4);
-
-
}
surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
-
+ mesh = surftool->commit(mesh);
} break;
}
@@ -319,22 +293,21 @@ RES Light::_get_gizmo_geometry() const {
return mesh;
}
-
AABB Light::get_aabb() const {
- if (type==VisualServer::LIGHT_DIRECTIONAL) {
+ if (type == VisualServer::LIGHT_DIRECTIONAL) {
- return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
+ return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
- } else if (type==VisualServer::LIGHT_OMNI) {
+ } else if (type == VisualServer::LIGHT_OMNI) {
- return AABB( Vector3(-1,-1,-1) * vars[PARAM_RADIUS], Vector3(2, 2, 2 ) * vars[PARAM_RADIUS]);
+ return AABB(Vector3(-1, -1, -1) * vars[PARAM_RADIUS], Vector3(2, 2, 2) * vars[PARAM_RADIUS]);
- } else if (type==VisualServer::LIGHT_SPOT) {
+ } else if (type == VisualServer::LIGHT_SPOT) {
- float len=vars[PARAM_RADIUS];
- float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;
- return AABB( Vector3( -size,-size,-len ), Vector3( size*2, size*2, len ) );
+ float len = vars[PARAM_RADIUS];
+ float size = Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE])) * len;
+ return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
}
return AABB();
@@ -345,17 +318,15 @@ DVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
}
-
void Light::set_operator(Operator p_op) {
- ERR_FAIL_INDEX(p_op,2);
- op=p_op;
- VisualServer::get_singleton()->light_set_operator(light,VS::LightOp(op));
-
+ ERR_FAIL_INDEX(p_op, 2);
+ op = p_op;
+ VisualServer::get_singleton()->light_set_operator(light, VS::LightOp(op));
}
void Light::set_bake_mode(BakeMode p_bake_mode) {
- bake_mode=p_bake_mode;
+ bake_mode = p_bake_mode;
}
Light::BakeMode Light::get_bake_mode() const {
@@ -363,49 +334,46 @@ Light::BakeMode Light::get_bake_mode() const {
return bake_mode;
}
-
Light::Operator Light::get_operator() const {
return op;
}
-void Light::approximate_opengl_attenuation(float p_constant, float p_linear, float p_quadratic,float p_radius_treshold) {
+void Light::approximate_opengl_attenuation(float p_constant, float p_linear, float p_quadratic, float p_radius_treshold) {
//this is horrible and must never be used
- float a = p_quadratic * p_radius_treshold;
- float b = p_linear * p_radius_treshold;
- float c = p_constant * p_radius_treshold -1;
-
- float radius=10000;
+ float a = p_quadratic * p_radius_treshold;
+ float b = p_linear * p_radius_treshold;
+ float c = p_constant * p_radius_treshold - 1;
- if(a == 0) { // solve linear
- float d = Math::abs(-c/b);
- if(d<radius)
- radius=d;
+ float radius = 10000;
+ if (a == 0) { // solve linear
+ float d = Math::abs(-c / b);
+ if (d < radius)
+ radius = d;
- } else { // solve quadratic
+ } else { // solve quadratic
// now ad^2 + bd + c = 0, solve quadratic equation:
- float denominator = 2*a;
+ float denominator = 2 * a;
- if(denominator != 0) {
+ if (denominator != 0) {
+ float root = b * b - 4 * a * c;
- float root = b*b - 4*a*c;
-
- if(root >=0) {
+ if (root >= 0) {
root = sqrt(root);
- float solution1 = fabs( (-b + root) / denominator);
- float solution2 = fabs( (-b - root) / denominator);
+ float solution1 = fabs((-b + root) / denominator);
+ float solution2 = fabs((-b - root) / denominator);
- if(solution1 > radius)
+ if (solution1 > radius)
solution1 = radius;
- if(solution2 > radius)
+ if (solution2 > radius)
solution2 = radius;
radius = (solution1 > solution2 ? solution1 : solution2);
@@ -413,7 +381,7 @@ void Light::approximate_opengl_attenuation(float p_constant, float p_linear, flo
}
}
- float energy=1.0;
+ float energy = 1.0;
/*if (p_constant>0)
energy=1.0/p_constant; //energy is this
@@ -421,97 +389,90 @@ void Light::approximate_opengl_attenuation(float p_constant, float p_linear, flo
energy=8.0; // some high number..
*/
- if (radius==10000)
- radius=100; //bug?
-
- set_parameter(PARAM_RADIUS,radius);
- set_parameter(PARAM_ENERGY,energy);
+ if (radius == 10000)
+ radius = 100; //bug?
+ set_parameter(PARAM_RADIUS, radius);
+ set_parameter(PARAM_ENERGY, energy);
}
-
void Light::_update_visibility() {
if (!is_inside_tree())
return;
-
-bool editor_ok=true;
+ bool editor_ok = true;
#ifdef TOOLS_ENABLED
if (editor_only) {
if (!get_tree()->is_editor_hint()) {
- editor_ok=false;
+ editor_ok = false;
} else {
- editor_ok = (get_tree()->get_edited_scene_root() && (this==get_tree()->get_edited_scene_root() || get_owner()==get_tree()->get_edited_scene_root()));
+ editor_ok = (get_tree()->get_edited_scene_root() && (this == get_tree()->get_edited_scene_root() || get_owner() == get_tree()->get_edited_scene_root()));
}
}
#else
if (editor_only) {
- editor_ok=false;
+ editor_ok = false;
}
#endif
- VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible() && enabled && editor_ok);
+ VS::get_singleton()->instance_light_set_enabled(get_instance(), is_visible() && enabled && editor_ok);
_change_notify("geometry/visible");
-
}
-
void Light::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE || p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_VISIBILITY_CHANGED) {
_update_visibility();
}
}
void Light::set_enabled(bool p_enabled) {
- enabled=p_enabled;
+ enabled = p_enabled;
_update_visibility();
}
-bool Light::is_enabled() const{
+bool Light::is_enabled() const {
return enabled;
}
void Light::set_editor_only(bool p_editor_only) {
- editor_only=p_editor_only;
+ editor_only = p_editor_only;
_update_visibility();
}
-bool Light::is_editor_only() const{
+bool Light::is_editor_only() const {
return editor_only;
}
-
void Light::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_parameter","variable","value"), &Light::set_parameter );
- ObjectTypeDB::bind_method(_MD("get_parameter","variable"), &Light::get_parameter );
- ObjectTypeDB::bind_method(_MD("set_color","color","value"), &Light::set_color );
- ObjectTypeDB::bind_method(_MD("get_color","color"), &Light::get_color );
- ObjectTypeDB::bind_method(_MD("set_project_shadows","enable"), &Light::set_project_shadows );
- ObjectTypeDB::bind_method(_MD("has_project_shadows"), &Light::has_project_shadows );
- ObjectTypeDB::bind_method(_MD("set_projector","projector:Texture"), &Light::set_projector );
- ObjectTypeDB::bind_method(_MD("get_projector:Texture"), &Light::get_projector );
- ObjectTypeDB::bind_method(_MD("set_operator","operator"), &Light::set_operator );
- ObjectTypeDB::bind_method(_MD("get_operator"), &Light::get_operator );
- ObjectTypeDB::bind_method(_MD("set_bake_mode","bake_mode"), &Light::set_bake_mode );
- ObjectTypeDB::bind_method(_MD("get_bake_mode"), &Light::get_bake_mode );
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"), &Light::set_enabled );
- ObjectTypeDB::bind_method(_MD("is_enabled"), &Light::is_enabled );
- ObjectTypeDB::bind_method(_MD("set_editor_only","editor_only"), &Light::set_editor_only );
- ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light::is_editor_only );
+ ObjectTypeDB::bind_method(_MD("set_parameter", "variable", "value"), &Light::set_parameter);
+ ObjectTypeDB::bind_method(_MD("get_parameter", "variable"), &Light::get_parameter);
+ ObjectTypeDB::bind_method(_MD("set_color", "color", "value"), &Light::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color", "color"), &Light::get_color);
+ ObjectTypeDB::bind_method(_MD("set_project_shadows", "enable"), &Light::set_project_shadows);
+ ObjectTypeDB::bind_method(_MD("has_project_shadows"), &Light::has_project_shadows);
+ ObjectTypeDB::bind_method(_MD("set_projector", "projector:Texture"), &Light::set_projector);
+ ObjectTypeDB::bind_method(_MD("get_projector:Texture"), &Light::get_projector);
+ ObjectTypeDB::bind_method(_MD("set_operator", "operator"), &Light::set_operator);
+ ObjectTypeDB::bind_method(_MD("get_operator"), &Light::get_operator);
+ ObjectTypeDB::bind_method(_MD("set_bake_mode", "bake_mode"), &Light::set_bake_mode);
+ ObjectTypeDB::bind_method(_MD("get_bake_mode"), &Light::get_bake_mode);
+ ObjectTypeDB::bind_method(_MD("set_enabled", "enabled"), &Light::set_enabled);
+ ObjectTypeDB::bind_method(_MD("is_enabled"), &Light::is_enabled);
+ ObjectTypeDB::bind_method(_MD("set_editor_only", "editor_only"), &Light::set_editor_only);
+ ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light::is_editor_only);
-
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "params/enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "params/editor_only"), _SCS("set_editor_only"), _SCS("is_editor_only"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/bake_mode",PROPERTY_HINT_ENUM,"Disabled,Indirect,Indirect+Shadows,Full"), _SCS("set_bake_mode"), _SCS("get_bake_mode"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/energy", PROPERTY_HINT_EXP_RANGE, "0,64,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ENERGY );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "params/enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "params/editor_only"), _SCS("set_editor_only"), _SCS("is_editor_only"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "params/bake_mode", PROPERTY_HINT_ENUM, "Disabled,Indirect,Indirect+Shadows,Full"), _SCS("set_bake_mode"), _SCS("get_bake_mode"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/energy", PROPERTY_HINT_EXP_RANGE, "0,64,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ENERGY);
/*
if (type == VisualServer::LIGHT_OMNI || type == VisualServer::LIGHT_SPOT) {
ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_RANGE, "0.01,4096,0.01"));
@@ -524,76 +485,67 @@ void Light::_bind_methods() {
}*/
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/diffuse"), _SCS("set_color"), _SCS("get_color"),COLOR_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/specular"), _SCS("set_color"), _SCS("get_color"),COLOR_SPECULAR);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "shadow/shadow"), _SCS("set_project_shadows"), _SCS("has_project_shadows"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/darkening", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_DARKENING );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/z_offset", PROPERTY_HINT_RANGE, "0,128,0.001"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_Z_OFFSET);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/z_slope_scale", PROPERTY_HINT_RANGE, "0,128,0.001"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_Z_SLOPE_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/esm_multiplier", PROPERTY_HINT_RANGE, "1.0,512.0,0.1"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_ESM_MULTIPLIER);
- ADD_PROPERTYI( PropertyInfo( Variant::INT, "shadow/blur_passes", PROPERTY_HINT_RANGE, "0,4,1"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_BLUR_PASSES);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "projector",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_projector"), _SCS("get_projector"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "operator",PROPERTY_HINT_ENUM,"Add,Sub"), _SCS("set_operator"), _SCS("get_operator"));
-
-
- BIND_CONSTANT( PARAM_RADIUS );
- BIND_CONSTANT( PARAM_ENERGY );
- BIND_CONSTANT( PARAM_ATTENUATION );
- BIND_CONSTANT( PARAM_SPOT_ANGLE );
- BIND_CONSTANT( PARAM_SPOT_ATTENUATION );
- BIND_CONSTANT( PARAM_SHADOW_DARKENING );
- BIND_CONSTANT( PARAM_SHADOW_Z_OFFSET );
-
-
- BIND_CONSTANT( COLOR_DIFFUSE );
- BIND_CONSTANT( COLOR_SPECULAR );
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "colors/diffuse"), _SCS("set_color"), _SCS("get_color"), COLOR_DIFFUSE);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "colors/specular"), _SCS("set_color"), _SCS("get_color"), COLOR_SPECULAR);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow/shadow"), _SCS("set_project_shadows"), _SCS("has_project_shadows"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow/darkening", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_DARKENING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow/z_offset", PROPERTY_HINT_RANGE, "0,128,0.001"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_Z_OFFSET);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow/z_slope_scale", PROPERTY_HINT_RANGE, "0,128,0.001"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_Z_SLOPE_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow/esm_multiplier", PROPERTY_HINT_RANGE, "1.0,512.0,0.1"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_ESM_MULTIPLIER);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow/blur_passes", PROPERTY_HINT_RANGE, "0,4,1"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_BLUR_PASSES);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "projector", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_projector"), _SCS("get_projector"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "operator", PROPERTY_HINT_ENUM, "Add,Sub"), _SCS("set_operator"), _SCS("get_operator"));
- BIND_CONSTANT( BAKE_MODE_DISABLED );
- BIND_CONSTANT( BAKE_MODE_INDIRECT );
- BIND_CONSTANT( BAKE_MODE_INDIRECT_AND_SHADOWS );
- BIND_CONSTANT( BAKE_MODE_FULL );
+ BIND_CONSTANT(PARAM_RADIUS);
+ BIND_CONSTANT(PARAM_ENERGY);
+ BIND_CONSTANT(PARAM_ATTENUATION);
+ BIND_CONSTANT(PARAM_SPOT_ANGLE);
+ BIND_CONSTANT(PARAM_SPOT_ATTENUATION);
+ BIND_CONSTANT(PARAM_SHADOW_DARKENING);
+ BIND_CONSTANT(PARAM_SHADOW_Z_OFFSET);
+ BIND_CONSTANT(COLOR_DIFFUSE);
+ BIND_CONSTANT(COLOR_SPECULAR);
+ BIND_CONSTANT(BAKE_MODE_DISABLED);
+ BIND_CONSTANT(BAKE_MODE_INDIRECT);
+ BIND_CONSTANT(BAKE_MODE_INDIRECT_AND_SHADOWS);
+ BIND_CONSTANT(BAKE_MODE_FULL);
}
-
Light::Light(VisualServer::LightType p_type) {
- type=p_type;
- light=VisualServer::get_singleton()->light_create(p_type);
-
- set_parameter(PARAM_SPOT_ATTENUATION,1.0);
- set_parameter(PARAM_SPOT_ANGLE,30.0);
- set_parameter(PARAM_RADIUS,2.0);
- set_parameter(PARAM_ENERGY,1.0);
- set_parameter(PARAM_ATTENUATION,1.0);
- set_parameter(PARAM_SHADOW_DARKENING,0.0);
- set_parameter(PARAM_SHADOW_Z_OFFSET,0.05);
- set_parameter(PARAM_SHADOW_Z_SLOPE_SCALE,0);
- set_parameter(PARAM_SHADOW_ESM_MULTIPLIER,60);
- set_parameter(PARAM_SHADOW_BLUR_PASSES,1);
+ type = p_type;
+ light = VisualServer::get_singleton()->light_create(p_type);
+ set_parameter(PARAM_SPOT_ATTENUATION, 1.0);
+ set_parameter(PARAM_SPOT_ANGLE, 30.0);
+ set_parameter(PARAM_RADIUS, 2.0);
+ set_parameter(PARAM_ENERGY, 1.0);
+ set_parameter(PARAM_ATTENUATION, 1.0);
+ set_parameter(PARAM_SHADOW_DARKENING, 0.0);
+ set_parameter(PARAM_SHADOW_Z_OFFSET, 0.05);
+ set_parameter(PARAM_SHADOW_Z_SLOPE_SCALE, 0);
+ set_parameter(PARAM_SHADOW_ESM_MULTIPLIER, 60);
+ set_parameter(PARAM_SHADOW_BLUR_PASSES, 1);
- set_color( COLOR_DIFFUSE, Color(1,1,1));
- set_color( COLOR_SPECULAR, Color(1,1,1));
+ set_color(COLOR_DIFFUSE, Color(1, 1, 1));
+ set_color(COLOR_SPECULAR, Color(1, 1, 1));
- op=OPERATOR_ADD;
- set_project_shadows( false );
+ op = OPERATOR_ADD;
+ set_project_shadows(false);
set_base(light);
- enabled=true;
- editor_only=false;
- bake_mode=BAKE_MODE_DISABLED;
-
+ enabled = true;
+ editor_only = false;
+ bake_mode = BAKE_MODE_DISABLED;
}
-
Light::Light() {
- type=VisualServer::LIGHT_DIRECTIONAL;
+ type = VisualServer::LIGHT_DIRECTIONAL;
ERR_PRINT("Light shouldn't be instanced dircetly, use the subtypes.");
}
-
Light::~Light() {
if (light.is_valid())
@@ -601,78 +553,70 @@ Light::~Light() {
}
/////////////////////////////////////////
-
void DirectionalLight::set_shadow_mode(ShadowMode p_mode) {
- shadow_mode=p_mode;
- VS::get_singleton()->light_directional_set_shadow_mode(light,(VS::LightDirectionalShadowMode)p_mode);
-
+ shadow_mode = p_mode;
+ VS::get_singleton()->light_directional_set_shadow_mode(light, (VS::LightDirectionalShadowMode)p_mode);
}
-DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const{
+DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const {
return shadow_mode;
}
void DirectionalLight::set_shadow_param(ShadowParam p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,3);
- shadow_param[p_param]=p_value;
- VS::get_singleton()->light_directional_set_shadow_param(light,VS::LightDirectionalShadowParam(p_param),p_value);
+ ERR_FAIL_INDEX(p_param, 3);
+ shadow_param[p_param] = p_value;
+ VS::get_singleton()->light_directional_set_shadow_param(light, VS::LightDirectionalShadowParam(p_param), p_value);
}
float DirectionalLight::get_shadow_param(ShadowParam p_param) const {
- ERR_FAIL_INDEX_V(p_param,3,0);
+ ERR_FAIL_INDEX_V(p_param, 3, 0);
return shadow_param[p_param];
}
void DirectionalLight::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shadow_mode","mode"),&DirectionalLight::set_shadow_mode);
- ObjectTypeDB::bind_method(_MD("get_shadow_mode"),&DirectionalLight::get_shadow_mode);
- ObjectTypeDB::bind_method(_MD("set_shadow_param","param","value"),&DirectionalLight::set_shadow_param);
- ObjectTypeDB::bind_method(_MD("get_shadow_param","param"),&DirectionalLight::get_shadow_param);
+ ObjectTypeDB::bind_method(_MD("set_shadow_mode", "mode"), &DirectionalLight::set_shadow_mode);
+ ObjectTypeDB::bind_method(_MD("get_shadow_mode"), &DirectionalLight::get_shadow_mode);
+ ObjectTypeDB::bind_method(_MD("set_shadow_param", "param", "value"), &DirectionalLight::set_shadow_param);
+ ObjectTypeDB::bind_method(_MD("get_shadow_param", "param"), &DirectionalLight::get_shadow_param);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/mode",PROPERTY_HINT_ENUM,"Orthogonal,Perspective,PSSM 2 Splits,PSSM 4 Splits"),_SCS("set_shadow_mode"),_SCS("get_shadow_mode"));
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/max_distance",PROPERTY_HINT_EXP_RANGE,"0.00,99999,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/split_weight",PROPERTY_HINT_RANGE,"0.01,1.0,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_PSSM_SPLIT_WEIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/zoffset_scale",PROPERTY_HINT_RANGE,"0.01,1024.0,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_PSSM_ZOFFSET_SCALE);
-
- BIND_CONSTANT( SHADOW_ORTHOGONAL );
- BIND_CONSTANT( SHADOW_PERSPECTIVE );
- BIND_CONSTANT( SHADOW_PARALLEL_2_SPLITS );
- BIND_CONSTANT( SHADOW_PARALLEL_4_SPLITS );
- BIND_CONSTANT( SHADOW_PARAM_MAX_DISTANCE );
- BIND_CONSTANT( SHADOW_PARAM_PSSM_SPLIT_WEIGHT );
- BIND_CONSTANT( SHADOW_PARAM_PSSM_ZOFFSET_SCALE );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow/mode", PROPERTY_HINT_ENUM, "Orthogonal,Perspective,PSSM 2 Splits,PSSM 4 Splits"), _SCS("set_shadow_mode"), _SCS("get_shadow_mode"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow/max_distance", PROPERTY_HINT_EXP_RANGE, "0.00,99999,0.01"), _SCS("set_shadow_param"), _SCS("get_shadow_param"), SHADOW_PARAM_MAX_DISTANCE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow/split_weight", PROPERTY_HINT_RANGE, "0.01,1.0,0.01"), _SCS("set_shadow_param"), _SCS("get_shadow_param"), SHADOW_PARAM_PSSM_SPLIT_WEIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow/zoffset_scale", PROPERTY_HINT_RANGE, "0.01,1024.0,0.01"), _SCS("set_shadow_param"), _SCS("get_shadow_param"), SHADOW_PARAM_PSSM_ZOFFSET_SCALE);
+ BIND_CONSTANT(SHADOW_ORTHOGONAL);
+ BIND_CONSTANT(SHADOW_PERSPECTIVE);
+ BIND_CONSTANT(SHADOW_PARALLEL_2_SPLITS);
+ BIND_CONSTANT(SHADOW_PARALLEL_4_SPLITS);
+ BIND_CONSTANT(SHADOW_PARAM_MAX_DISTANCE);
+ BIND_CONSTANT(SHADOW_PARAM_PSSM_SPLIT_WEIGHT);
+ BIND_CONSTANT(SHADOW_PARAM_PSSM_ZOFFSET_SCALE);
}
+DirectionalLight::DirectionalLight()
+ : Light(VisualServer::LIGHT_DIRECTIONAL) {
-DirectionalLight::DirectionalLight() : Light( VisualServer::LIGHT_DIRECTIONAL ) {
-
- shadow_mode=SHADOW_ORTHOGONAL;
- shadow_param[SHADOW_PARAM_MAX_DISTANCE]=0;
- shadow_param[SHADOW_PARAM_PSSM_SPLIT_WEIGHT]=0.5;
- shadow_param[SHADOW_PARAM_PSSM_ZOFFSET_SCALE]=2.0;
-
-
+ shadow_mode = SHADOW_ORTHOGONAL;
+ shadow_param[SHADOW_PARAM_MAX_DISTANCE] = 0;
+ shadow_param[SHADOW_PARAM_PSSM_SPLIT_WEIGHT] = 0.5;
+ shadow_param[SHADOW_PARAM_PSSM_ZOFFSET_SCALE] = 2.0;
}
-
void OmniLight::_bind_methods() {
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_EXP_RANGE, "0.2,4096,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_RADIUS );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ATTENUATION );
-
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/radius", PROPERTY_HINT_EXP_RANGE, "0.2,4096,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_RADIUS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ATTENUATION);
}
void SpotLight::_bind_methods() {
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_EXP_RANGE, "0.2,4096,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_RADIUS );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ATTENUATION );
-
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/spot_angle", PROPERTY_HINT_RANGE, "0.01,89.9,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ANGLE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/spot_attenuation", PROPERTY_HINT_EXP_EASING, "spot_attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ATTENUATION );
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/radius", PROPERTY_HINT_EXP_RANGE, "0.2,4096,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_RADIUS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ATTENUATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/spot_angle", PROPERTY_HINT_RANGE, "0.01,89.9,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ANGLE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/spot_attenuation", PROPERTY_HINT_EXP_EASING, "spot_attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ATTENUATION);
}
diff --git a/scene/3d/light.h b/scene/3d/light.h
index 43ac7be35..0ddc67579 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -29,7 +29,6 @@
#ifndef LIGHT_H
#define LIGHT_H
-
#include "scene/3d/visual_instance.h"
#include "scene/resources/texture.h"
#include "servers/visual_server.h"
@@ -39,30 +38,28 @@
*/
class Light : public VisualInstance {
- OBJ_TYPE( Light, VisualInstance );
+ OBJ_TYPE(Light, VisualInstance);
OBJ_CATEGORY("3D Light Nodes");
public:
-
enum Parameter {
- PARAM_RADIUS=VisualServer::LIGHT_PARAM_RADIUS,
- PARAM_ENERGY=VisualServer::LIGHT_PARAM_ENERGY,
- PARAM_ATTENUATION=VisualServer::LIGHT_PARAM_ATTENUATION,
- PARAM_SPOT_ANGLE=VisualServer::LIGHT_PARAM_SPOT_ANGLE,
- PARAM_SPOT_ATTENUATION=VisualServer::LIGHT_PARAM_SPOT_ATTENUATION,
- PARAM_SHADOW_DARKENING=VisualServer::LIGHT_PARAM_SHADOW_DARKENING,
- PARAM_SHADOW_Z_OFFSET=VisualServer::LIGHT_PARAM_SHADOW_Z_OFFSET,
- PARAM_SHADOW_Z_SLOPE_SCALE=VisualServer::LIGHT_PARAM_SHADOW_Z_SLOPE_SCALE,
- PARAM_SHADOW_ESM_MULTIPLIER=VisualServer::LIGHT_PARAM_SHADOW_ESM_MULTIPLIER,
- PARAM_SHADOW_BLUR_PASSES=VisualServer::LIGHT_PARAM_SHADOW_BLUR_PASSES,
- PARAM_MAX=VisualServer::LIGHT_PARAM_MAX
+ PARAM_RADIUS = VisualServer::LIGHT_PARAM_RADIUS,
+ PARAM_ENERGY = VisualServer::LIGHT_PARAM_ENERGY,
+ PARAM_ATTENUATION = VisualServer::LIGHT_PARAM_ATTENUATION,
+ PARAM_SPOT_ANGLE = VisualServer::LIGHT_PARAM_SPOT_ANGLE,
+ PARAM_SPOT_ATTENUATION = VisualServer::LIGHT_PARAM_SPOT_ATTENUATION,
+ PARAM_SHADOW_DARKENING = VisualServer::LIGHT_PARAM_SHADOW_DARKENING,
+ PARAM_SHADOW_Z_OFFSET = VisualServer::LIGHT_PARAM_SHADOW_Z_OFFSET,
+ PARAM_SHADOW_Z_SLOPE_SCALE = VisualServer::LIGHT_PARAM_SHADOW_Z_SLOPE_SCALE,
+ PARAM_SHADOW_ESM_MULTIPLIER = VisualServer::LIGHT_PARAM_SHADOW_ESM_MULTIPLIER,
+ PARAM_SHADOW_BLUR_PASSES = VisualServer::LIGHT_PARAM_SHADOW_BLUR_PASSES,
+ PARAM_MAX = VisualServer::LIGHT_PARAM_MAX
};
-
enum LightColor {
- COLOR_DIFFUSE=VisualServer::LIGHT_COLOR_DIFFUSE,
- COLOR_SPECULAR=VisualServer::LIGHT_COLOR_SPECULAR
+ COLOR_DIFFUSE = VisualServer::LIGHT_COLOR_DIFFUSE,
+ COLOR_SPECULAR = VisualServer::LIGHT_COLOR_SPECULAR
};
enum BakeMode {
@@ -74,20 +71,17 @@ public:
};
-
enum Operator {
OPERATOR_ADD,
OPERATOR_SUB
};
-private:
-
+private:
Ref<Texture> projector;
float vars[PARAM_MAX];
Color colors[3];
-
BakeMode bake_mode;
VisualServer::LightType type;
bool shadows;
@@ -96,10 +90,9 @@ private:
Operator op;
void _update_visibility();
-// bind helpers
+ // bind helpers
protected:
-
RID light;
virtual bool _can_gizmo_scale() const;
@@ -108,22 +101,21 @@ protected:
static void _bind_methods();
void _notification(int p_what);
-
Light(VisualServer::LightType p_type);
-public:
+public:
VS::LightType get_light_type() const { return type; }
void set_parameter(Parameter p_var, float p_value);
float get_parameter(Parameter p_var) const;
- void set_color(LightColor p_color,const Color& p_value);
+ void set_color(LightColor p_color, const Color &p_value);
Color get_color(LightColor p_color) const;
void set_project_shadows(bool p_enabled);
bool has_project_shadows() const;
- void set_projector(const Ref<Texture>& p_projector);
+ void set_projector(const Ref<Texture> &p_projector);
Ref<Texture> get_projector() const;
void set_operator(Operator p_op);
@@ -141,25 +133,22 @@ public:
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- void approximate_opengl_attenuation(float p_constant, float p_linear, float p_quadratic, float p_radius_treshold=0.5);
+ void approximate_opengl_attenuation(float p_constant, float p_linear, float p_quadratic, float p_radius_treshold = 0.5);
Light();
~Light();
-
};
-VARIANT_ENUM_CAST( Light::Parameter );
-VARIANT_ENUM_CAST( Light::LightColor );
-VARIANT_ENUM_CAST( Light::Operator );
-VARIANT_ENUM_CAST( Light::BakeMode);
-
+VARIANT_ENUM_CAST(Light::Parameter);
+VARIANT_ENUM_CAST(Light::LightColor);
+VARIANT_ENUM_CAST(Light::Operator);
+VARIANT_ENUM_CAST(Light::BakeMode);
class DirectionalLight : public Light {
- OBJ_TYPE( DirectionalLight, Light );
+ OBJ_TYPE(DirectionalLight, Light);
public:
-
enum ShadowMode {
SHADOW_ORTHOGONAL,
SHADOW_PERSPECTIVE,
@@ -175,10 +164,11 @@ public:
private:
ShadowMode shadow_mode;
float shadow_param[3];
+
protected:
static void _bind_methods();
-public:
+public:
void set_shadow_mode(ShadowMode p_mode);
ShadowMode get_shadow_mode() const;
@@ -190,32 +180,31 @@ public:
DirectionalLight();
};
-VARIANT_ENUM_CAST( DirectionalLight::ShadowMode );
-VARIANT_ENUM_CAST( DirectionalLight::ShadowParam );
-
+VARIANT_ENUM_CAST(DirectionalLight::ShadowMode);
+VARIANT_ENUM_CAST(DirectionalLight::ShadowParam);
class OmniLight : public Light {
- OBJ_TYPE( OmniLight, Light );
+ OBJ_TYPE(OmniLight, Light);
+
protected:
static void _bind_methods();
public:
-
-
- OmniLight() : Light( VisualServer::LIGHT_OMNI ) { set_parameter(PARAM_SHADOW_Z_OFFSET,0.001);}
+ OmniLight()
+ : Light(VisualServer::LIGHT_OMNI) { set_parameter(PARAM_SHADOW_Z_OFFSET, 0.001); }
};
class SpotLight : public Light {
- OBJ_TYPE( SpotLight, Light );
+ OBJ_TYPE(SpotLight, Light);
+
protected:
static void _bind_methods();
-public:
-
- SpotLight() : Light( VisualServer::LIGHT_SPOT ) {}
+public:
+ SpotLight()
+ : Light(VisualServer::LIGHT_SPOT) {}
};
-
#endif
diff --git a/scene/3d/listener.cpp b/scene/3d/listener.cpp
index bf42a5c92..8bf9cd448 100644
--- a/scene/3d/listener.cpp
+++ b/scene/3d/listener.cpp
@@ -3,8 +3,6 @@
#include "scene/resources/mesh.h"
void Listener::_update_audio_listener_state() {
-
-
}
void Listener::_request_listener_update() {
@@ -12,53 +10,48 @@ void Listener::_request_listener_update() {
_update_listener();
}
-bool Listener::_set(const StringName& p_name, const Variant& p_value) {
+bool Listener::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == "current") {
if (p_value.operator bool()) {
make_current();
- }
- else {
+ } else {
clear_current();
}
- }
- else
+ } else
return false;
return true;
}
-bool Listener::_get(const StringName& p_name,Variant &r_ret) const {
+bool Listener::_get(const StringName &p_name, Variant &r_ret) const {
if (p_name == "current") {
if (is_inside_tree() && get_tree()->is_node_being_edited(this)) {
r_ret = current;
- }
- else {
+ } else {
r_ret = is_current();
}
- }
- else
+ } else
return false;
return true;
}
-void Listener::_get_property_list( List<PropertyInfo> *p_list) const {
+void Listener::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo( Variant::BOOL, "current" ) );
+ p_list->push_back(PropertyInfo(Variant::BOOL, "current"));
}
void Listener::_update_listener() {
if (is_inside_tree() && is_current()) {
get_viewport()->_listener_transform_changed_notify();
-
}
}
void Listener::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
bool first_listener = get_viewport()->_listener_add(this);
@@ -73,24 +66,19 @@ void Listener::_notification(int p_what) {
if (!get_tree()->is_node_being_edited(this)) {
if (is_current()) {
clear_current();
- current=true; //keep it true
+ current = true; //keep it true
} else {
- current=false;
+ current = false;
}
}
get_viewport()->_listener_remove(this);
-
} break;
-
-
}
-
}
-
Transform Listener::get_listener_transform() const {
return get_global_transform().orthonormalized();
@@ -98,7 +86,7 @@ Transform Listener::get_listener_transform() const {
void Listener::make_current() {
- current=true;
+ current = true;
if (!is_inside_tree())
return;
@@ -106,27 +94,23 @@ void Listener::make_current() {
get_viewport()->_listener_set(this);
}
-
-
-
void Listener::clear_current() {
- current=false;
+ current = false;
if (!is_inside_tree())
return;
- if (get_viewport()->get_listener()==this) {
+ if (get_viewport()->get_listener() == this) {
get_viewport()->_listener_set(NULL);
get_viewport()->_listener_make_next_current(this);
}
-
}
bool Listener::is_current() const {
if (is_inside_tree() && !get_tree()->is_node_being_edited(this)) {
- return get_viewport()->get_listener()==this;
+ return get_viewport()->get_listener() == this;
} else
return current;
@@ -146,22 +130,18 @@ RES Listener::_get_gizmo_geometry() const {
void Listener::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("make_current"),&Listener::make_current );
- ObjectTypeDB::bind_method( _MD("clear_current"),&Listener::clear_current );
- ObjectTypeDB::bind_method( _MD("is_current"),&Listener::is_current );
- ObjectTypeDB::bind_method( _MD("get_listener_transform"),&Listener::get_listener_transform );
+ ObjectTypeDB::bind_method(_MD("make_current"), &Listener::make_current);
+ ObjectTypeDB::bind_method(_MD("clear_current"), &Listener::clear_current);
+ ObjectTypeDB::bind_method(_MD("is_current"), &Listener::is_current);
+ ObjectTypeDB::bind_method(_MD("get_listener_transform"), &Listener::get_listener_transform);
}
Listener::Listener() {
- current=false;
- force_change=false;
+ current = false;
+ force_change = false;
//active=false;
}
-
Listener::~Listener() {
-
}
-
-
diff --git a/scene/3d/listener.h b/scene/3d/listener.h
index bf0281a8e..41b80a147 100644
--- a/scene/3d/listener.h
+++ b/scene/3d/listener.h
@@ -1,15 +1,14 @@
#ifndef LISTENER_H
#define LISTENER_H
-
#include "scene/3d/spatial.h"
#include "scene/main/viewport.h"
class Listener : public Spatial {
OBJ_TYPE(Listener, Spatial);
-private:
+private:
bool force_change;
bool current;
@@ -18,22 +17,21 @@ private:
virtual bool _can_gizmo_scale() const;
virtual RES _get_gizmo_geometry() const;
-friend class Viewport;
+ friend class Viewport;
void _update_audio_listener_state();
-protected:
+protected:
void _update_listener();
virtual void _request_listener_update();
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
-
void make_current();
void clear_current();
bool is_current() const;
@@ -47,7 +45,6 @@ public:
Listener();
~Listener();
-
};
#endif
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index ae8520226..ba22f4275 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -28,12 +28,12 @@
/*************************************************************************/
#include "mesh_instance.h"
-#include "skeleton.h"
-#include "physics_body.h"
#include "body_shape.h"
-#include "scene/scene_string_names.h"
#include "core_string_names.h"
-bool MeshInstance::_set(const StringName& p_name, const Variant& p_value) {
+#include "physics_body.h"
+#include "scene/scene_string_names.h"
+#include "skeleton.h"
+bool MeshInstance::_set(const StringName &p_name, const Variant &p_value) {
//this is not _too_ bad performance wise, really. it only arrives here if the property was not set anywhere else.
//add to it that it's probably found on first call to _set anyway.
@@ -41,97 +41,91 @@ bool MeshInstance::_set(const StringName& p_name, const Variant& p_value) {
if (!get_instance().is_valid())
return false;
-
- Map<StringName,MorphTrack>::Element *E = morph_tracks.find(p_name);
+ Map<StringName, MorphTrack>::Element *E = morph_tracks.find(p_name);
if (E) {
- E->get().value=p_value;
- VisualServer::get_singleton()->instance_set_morph_target_weight(get_instance(),E->get().idx,E->get().value);
+ E->get().value = p_value;
+ VisualServer::get_singleton()->instance_set_morph_target_weight(get_instance(), E->get().idx, E->get().value);
return true;
}
if (p_name.operator String().begins_with("material/")) {
- int idx = p_name.operator String().get_slicec('/',1).to_int();
- if (idx>=materials.size() || idx<0)
+ int idx = p_name.operator String().get_slicec('/', 1).to_int();
+ if (idx >= materials.size() || idx < 0)
return false;
- set_surface_material(idx,p_value);
+ set_surface_material(idx, p_value);
return true;
}
return false;
}
-bool MeshInstance::_get(const StringName& p_name,Variant &r_ret) const {
-
+bool MeshInstance::_get(const StringName &p_name, Variant &r_ret) const {
if (!get_instance().is_valid())
return false;
- const Map<StringName,MorphTrack>::Element *E = morph_tracks.find(p_name);
+ const Map<StringName, MorphTrack>::Element *E = morph_tracks.find(p_name);
if (E) {
r_ret = E->get().value;
return true;
}
if (p_name.operator String().begins_with("material/")) {
- int idx = p_name.operator String().get_slicec('/',1).to_int();
- if (idx>=materials.size() || idx<0)
+ int idx = p_name.operator String().get_slicec('/', 1).to_int();
+ if (idx >= materials.size() || idx < 0)
return false;
- r_ret=materials[idx];
+ r_ret = materials[idx];
return true;
}
return false;
}
-void MeshInstance::_get_property_list( List<PropertyInfo> *p_list) const {
+void MeshInstance::_get_property_list(List<PropertyInfo> *p_list) const {
List<String> ls;
- for(const Map<StringName,MorphTrack>::Element *E=morph_tracks.front();E;E=E->next()) {
+ for (const Map<StringName, MorphTrack>::Element *E = morph_tracks.front(); E; E = E->next()) {
ls.push_back(E->key());
}
ls.sort();
- for(List<String>::Element *E=ls.front();E;E=E->next()) {
- p_list->push_back( PropertyInfo(Variant::REAL,E->get(),PROPERTY_HINT_RANGE,"0,1,0.01"));
+ for (List<String>::Element *E = ls.front(); E; E = E->next()) {
+ p_list->push_back(PropertyInfo(Variant::REAL, E->get(), PROPERTY_HINT_RANGE, "0,1,0.01"));
}
if (mesh.is_valid()) {
- for(int i=0;i<mesh->get_surface_count();i++) {
- p_list->push_back( PropertyInfo(Variant::OBJECT, "material/"+itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Material"));
+ for (int i = 0; i < mesh->get_surface_count(); i++) {
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "material/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Material"));
}
}
}
+void MeshInstance::set_mesh(const Ref<Mesh> &p_mesh) {
-
-
-void MeshInstance::set_mesh(const Ref<Mesh>& p_mesh) {
-
- if (mesh==p_mesh)
+ if (mesh == p_mesh)
return;
if (mesh.is_valid()) {
- mesh->disconnect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_mesh_changed);
+ mesh->disconnect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_mesh_changed);
materials.clear();
}
- mesh=p_mesh;
+ mesh = p_mesh;
morph_tracks.clear();
if (mesh.is_valid()) {
-
- for(int i=0;i<mesh->get_morph_target_count();i++) {
+ for (int i = 0; i < mesh->get_morph_target_count(); i++) {
MorphTrack mt;
- mt.idx=i;
- mt.value=0;
- morph_tracks["morph/"+String(mesh->get_morph_target_name(i))]=mt;
+ mt.idx = i;
+ mt.value = 0;
+ morph_tracks["morph/" + String(mesh->get_morph_target_name(i))] = mt;
}
- mesh->connect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_mesh_changed);
+ mesh->connect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_mesh_changed);
materials.resize(mesh->get_surface_count());
set_base(mesh->get_rid());
@@ -147,14 +141,14 @@ Ref<Mesh> MeshInstance::get_mesh() const {
return mesh;
}
-void MeshInstance::_resolve_skeleton_path(){
+void MeshInstance::_resolve_skeleton_path() {
if (skeleton_path.is_empty())
return;
- Skeleton *skeleton=get_node(skeleton_path)?get_node(skeleton_path)->cast_to<Skeleton>():NULL;
+ Skeleton *skeleton = get_node(skeleton_path) ? get_node(skeleton_path)->cast_to<Skeleton>() : NULL;
if (skeleton)
- VisualServer::get_singleton()->instance_attach_skeleton( get_instance(), skeleton->get_skeleton() );
+ VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), skeleton->get_skeleton());
}
void MeshInstance::set_skeleton_path(const NodePath &p_skeleton) {
@@ -179,7 +173,7 @@ AABB MeshInstance::get_aabb() const {
DVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
- if (!(p_usage_flags&(FACES_SOLID|FACES_ENCLOSING)))
+ if (!(p_usage_flags & (FACES_SOLID | FACES_ENCLOSING)))
return DVector<Face3>();
if (mesh.is_null())
@@ -188,8 +182,7 @@ DVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
return mesh->get_faces();
}
-
-Node* MeshInstance::create_trimesh_collision_node() {
+Node *MeshInstance::create_trimesh_collision_node() {
if (mesh.is_null())
return NULL;
@@ -198,32 +191,28 @@ Node* MeshInstance::create_trimesh_collision_node() {
if (shape.is_null())
return NULL;
- StaticBody * static_body = memnew( StaticBody );
- static_body->add_shape( shape );
+ StaticBody *static_body = memnew(StaticBody);
+ static_body->add_shape(shape);
return static_body;
-
-
}
void MeshInstance::create_trimesh_collision() {
-
- StaticBody* static_body = create_trimesh_collision_node()->cast_to<StaticBody>();
+ StaticBody *static_body = create_trimesh_collision_node()->cast_to<StaticBody>();
ERR_FAIL_COND(!static_body);
- static_body->set_name( String(get_name()) + "_col" );
+ static_body->set_name(String(get_name()) + "_col");
add_child(static_body);
if (get_owner())
- static_body->set_owner( get_owner() );
- CollisionShape *cshape = memnew( CollisionShape );
+ static_body->set_owner(get_owner());
+ CollisionShape *cshape = memnew(CollisionShape);
cshape->set_shape(static_body->get_shape(0));
static_body->add_child(cshape);
if (get_owner())
- cshape->set_owner( get_owner() );
-
+ cshape->set_owner(get_owner());
}
-Node* MeshInstance::create_convex_collision_node() {
+Node *MeshInstance::create_convex_collision_node() {
if (mesh.is_null())
return NULL;
@@ -232,90 +221,77 @@ Node* MeshInstance::create_convex_collision_node() {
if (shape.is_null())
return NULL;
- StaticBody * static_body = memnew( StaticBody );
- static_body->add_shape( shape );
+ StaticBody *static_body = memnew(StaticBody);
+ static_body->add_shape(shape);
return static_body;
-
-
}
void MeshInstance::create_convex_collision() {
-
- StaticBody* static_body = create_convex_collision_node()->cast_to<StaticBody>();
+ StaticBody *static_body = create_convex_collision_node()->cast_to<StaticBody>();
ERR_FAIL_COND(!static_body);
- static_body->set_name( String(get_name()) + "_col" );
+ static_body->set_name(String(get_name()) + "_col");
add_child(static_body);
if (get_owner())
- static_body->set_owner( get_owner() );
- CollisionShape *cshape = memnew( CollisionShape );
+ static_body->set_owner(get_owner());
+ CollisionShape *cshape = memnew(CollisionShape);
cshape->set_shape(static_body->get_shape(0));
static_body->add_child(cshape);
if (get_owner())
- cshape->set_owner( get_owner() );
-
-
+ cshape->set_owner(get_owner());
}
void MeshInstance::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
_resolve_skeleton_path();
}
}
+void MeshInstance::set_surface_material(int p_surface, const Ref<Material> &p_material) {
-void MeshInstance::set_surface_material(int p_surface,const Ref<Material>& p_material) {
+ ERR_FAIL_INDEX(p_surface, materials.size());
- ERR_FAIL_INDEX(p_surface,materials.size());
-
- materials[p_surface]=p_material;
+ materials[p_surface] = p_material;
if (materials[p_surface].is_valid())
- VS::get_singleton()->instance_set_surface_material(get_instance(),p_surface,materials[p_surface]->get_rid());
+ VS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, materials[p_surface]->get_rid());
else
- VS::get_singleton()->instance_set_surface_material(get_instance(),p_surface,RID());
-
+ VS::get_singleton()->instance_set_surface_material(get_instance(), p_surface, RID());
}
Ref<Material> MeshInstance::get_surface_material(int p_surface) const {
- ERR_FAIL_INDEX_V(p_surface,materials.size(),Ref<Material>());
+ ERR_FAIL_INDEX_V(p_surface, materials.size(), Ref<Material>());
return materials[p_surface];
}
-
void MeshInstance::_mesh_changed() {
- materials.resize( mesh->get_surface_count() );
+ materials.resize(mesh->get_surface_count());
}
void MeshInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MeshInstance::set_mesh);
- ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"),&MeshInstance::get_mesh);
- ObjectTypeDB::bind_method(_MD("set_skeleton_path","skeleton_path:NodePath"),&MeshInstance::set_skeleton_path);
- ObjectTypeDB::bind_method(_MD("get_skeleton_path:NodePath"),&MeshInstance::get_skeleton_path);
- ObjectTypeDB::bind_method(_MD("get_aabb"),&MeshInstance::get_aabb);
- ObjectTypeDB::bind_method(_MD("create_trimesh_collision"),&MeshInstance::create_trimesh_collision);
- ObjectTypeDB::set_method_flags("MeshInstance","create_trimesh_collision",METHOD_FLAGS_DEFAULT);
- ObjectTypeDB::bind_method(_MD("create_convex_collision"),&MeshInstance::create_convex_collision);
- ObjectTypeDB::set_method_flags("MeshInstance","create_convex_collision",METHOD_FLAGS_DEFAULT);
- ObjectTypeDB::bind_method(_MD("_mesh_changed"),&MeshInstance::_mesh_changed);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "mesh/mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh" ), _SCS("set_mesh"), _SCS("get_mesh"));
- ADD_PROPERTY( PropertyInfo (Variant::NODE_PATH, "mesh/skeleton"), _SCS("set_skeleton_path"), _SCS("get_skeleton_path"));
+ ObjectTypeDB::bind_method(_MD("set_mesh", "mesh:Mesh"), &MeshInstance::set_mesh);
+ ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"), &MeshInstance::get_mesh);
+ ObjectTypeDB::bind_method(_MD("set_skeleton_path", "skeleton_path:NodePath"), &MeshInstance::set_skeleton_path);
+ ObjectTypeDB::bind_method(_MD("get_skeleton_path:NodePath"), &MeshInstance::get_skeleton_path);
+ ObjectTypeDB::bind_method(_MD("get_aabb"), &MeshInstance::get_aabb);
+ ObjectTypeDB::bind_method(_MD("create_trimesh_collision"), &MeshInstance::create_trimesh_collision);
+ ObjectTypeDB::set_method_flags("MeshInstance", "create_trimesh_collision", METHOD_FLAGS_DEFAULT);
+ ObjectTypeDB::bind_method(_MD("create_convex_collision"), &MeshInstance::create_convex_collision);
+ ObjectTypeDB::set_method_flags("MeshInstance", "create_convex_collision", METHOD_FLAGS_DEFAULT);
+ ObjectTypeDB::bind_method(_MD("_mesh_changed"), &MeshInstance::_mesh_changed);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh/mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), _SCS("set_mesh"), _SCS("get_mesh"));
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "mesh/skeleton"), _SCS("set_skeleton_path"), _SCS("get_skeleton_path"));
}
-MeshInstance::MeshInstance()
-{
- skeleton_path=NodePath("..");
+MeshInstance::MeshInstance() {
+ skeleton_path = NodePath("..");
}
-
MeshInstance::~MeshInstance() {
-
}
-
-
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index 2766fb4c4..6ebd7462c 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -37,7 +37,7 @@
*/
class MeshInstance : public GeometryInstance {
- OBJ_TYPE( MeshInstance, GeometryInstance );
+ OBJ_TYPE(MeshInstance, GeometryInstance);
Ref<Mesh> mesh;
NodePath skeleton_path;
@@ -46,38 +46,40 @@ class MeshInstance : public GeometryInstance {
int idx;
float value;
- MorphTrack() { idx=0; value=0; }
+ MorphTrack() {
+ idx = 0;
+ value = 0;
+ }
};
- Map<StringName,MorphTrack> morph_tracks;
+ Map<StringName, MorphTrack> morph_tracks;
Vector<Ref<Material> > materials;
void _mesh_changed();
void _resolve_skeleton_path();
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_mesh(const Ref<Mesh>& p_mesh);
+public:
+ void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;
- void set_skeleton_path(const NodePath& p_skeleton);
+ void set_skeleton_path(const NodePath &p_skeleton);
NodePath get_skeleton_path();
- void set_surface_material(int p_surface,const Ref<Material>& p_material);
+ void set_surface_material(int p_surface, const Ref<Material> &p_material);
Ref<Material> get_surface_material(int p_surface) const;
- Node* create_trimesh_collision_node();
+ Node *create_trimesh_collision_node();
void create_trimesh_collision();
- Node* create_convex_collision_node();
+ Node *create_convex_collision_node();
void create_convex_collision();
virtual AABB get_aabb() const;
diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp
index a0400035d..a155854cc 100644
--- a/scene/3d/multimesh_instance.cpp
+++ b/scene/3d/multimesh_instance.cpp
@@ -28,27 +28,20 @@
/*************************************************************************/
#include "multimesh_instance.h"
-
-
-
-
void MultiMeshInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_multimesh","multimesh"),&MultiMeshInstance::set_multimesh);
- ObjectTypeDB::bind_method(_MD("get_multimesh"),&MultiMeshInstance::get_multimesh);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"multimesh",PROPERTY_HINT_RESOURCE_TYPE,"MultiMesh"), _SCS("set_multimesh"), _SCS("get_multimesh"));
-
-
+ ObjectTypeDB::bind_method(_MD("set_multimesh", "multimesh"), &MultiMeshInstance::set_multimesh);
+ ObjectTypeDB::bind_method(_MD("get_multimesh"), &MultiMeshInstance::get_multimesh);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multimesh", PROPERTY_HINT_RESOURCE_TYPE, "MultiMesh"), _SCS("set_multimesh"), _SCS("get_multimesh"));
}
-void MultiMeshInstance::set_multimesh(const Ref<MultiMesh>& p_multimesh) {
+void MultiMeshInstance::set_multimesh(const Ref<MultiMesh> &p_multimesh) {
- multimesh=p_multimesh;
+ multimesh = p_multimesh;
if (multimesh.is_valid())
set_base(multimesh->get_rid());
else
set_base(RID());
-
}
Ref<MultiMesh> MultiMeshInstance::get_multimesh() const {
@@ -56,8 +49,6 @@ Ref<MultiMesh> MultiMeshInstance::get_multimesh() const {
return multimesh;
}
-
-
DVector<Face3> MultiMeshInstance::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
@@ -72,10 +63,7 @@ AABB MultiMeshInstance::get_aabb() const {
}
MultiMeshInstance::MultiMeshInstance() {
-
}
MultiMeshInstance::~MultiMeshInstance() {
-
-
}
diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h
index af21274b0..b1f725375 100644
--- a/scene/3d/multimesh_instance.h
+++ b/scene/3d/multimesh_instance.h
@@ -37,21 +37,18 @@
*/
class MultiMeshInstance : public GeometryInstance {
- OBJ_TYPE( MultiMeshInstance, GeometryInstance );
-
+ OBJ_TYPE(MultiMeshInstance, GeometryInstance);
Ref<MultiMesh> multimesh;
-protected:
-
+protected:
static void _bind_methods();
// bind helpers
public:
-
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- void set_multimesh(const Ref<MultiMesh>& p_multimesh);
+ void set_multimesh(const Ref<MultiMesh> &p_multimesh);
Ref<MultiMesh> get_multimesh() const;
virtual AABB get_aabb() const;
@@ -61,4 +58,3 @@ public:
};
#endif // MULTIMESH_INSTANCE_H
-
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp
index 5a73662ac..e3f04ffff 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -31,60 +31,58 @@
void Navigation::_navmesh_link(int p_id) {
ERR_FAIL_COND(!navmesh_map.has(p_id));
- NavMesh &nm=navmesh_map[p_id];
+ NavMesh &nm = navmesh_map[p_id];
ERR_FAIL_COND(nm.linked);
print_line("LINK");
- DVector<Vector3> vertices=nm.navmesh->get_vertices();
+ DVector<Vector3> vertices = nm.navmesh->get_vertices();
int len = vertices.size();
- if (len==0)
+ if (len == 0)
return;
- DVector<Vector3>::Read r=vertices.read();
+ DVector<Vector3>::Read r = vertices.read();
- for(int i=0;i<nm.navmesh->get_polygon_count();i++) {
+ for (int i = 0; i < nm.navmesh->get_polygon_count(); i++) {
//build
- List<Polygon>::Element *P=nm.polygons.push_back(Polygon());
- Polygon &p=P->get();
- p.owner=&nm;
+ List<Polygon>::Element *P = nm.polygons.push_back(Polygon());
+ Polygon &p = P->get();
+ p.owner = &nm;
Vector<int> poly = nm.navmesh->get_polygon(i);
- int plen=poly.size();
- const int *indices=poly.ptr();
- bool valid=true;
+ int plen = poly.size();
+ const int *indices = poly.ptr();
+ bool valid = true;
p.edges.resize(plen);
Vector3 center;
- float sum=0;
+ float sum = 0;
- for(int j=0;j<plen;j++) {
+ for (int j = 0; j < plen; j++) {
int idx = indices[j];
- if (idx<0 || idx>=len) {
- valid=false;
+ if (idx < 0 || idx >= len) {
+ valid = false;
break;
}
Polygon::Edge e;
- Vector3 ep=nm.xform.xform(r[idx]);
- center+=ep;
- e.point=_get_point(ep);
- p.edges[j]=e;
+ Vector3 ep = nm.xform.xform(r[idx]);
+ center += ep;
+ e.point = _get_point(ep);
+ p.edges[j] = e;
- if (j>=2) {
- Vector3 epa = nm.xform.xform(r[indices[j-2]]);
- Vector3 epb = nm.xform.xform(r[indices[j-1]]);
-
- sum+=up.dot((epb-epa).cross(ep-epa));
+ if (j >= 2) {
+ Vector3 epa = nm.xform.xform(r[indices[j - 2]]);
+ Vector3 epb = nm.xform.xform(r[indices[j - 1]]);
+ sum += up.dot((epb - epa).cross(ep - epa));
}
-
}
- p.clockwise=sum>0;
+ p.clockwise = sum > 0;
if (!valid) {
nm.polygons.pop_back();
@@ -93,110 +91,106 @@ void Navigation::_navmesh_link(int p_id) {
}
p.center = center;
- if( plen != 0 ) {
+ if (plen != 0) {
p.center /= plen;
}
-
//connect
- for(int j=0;j<plen;j++) {
+ for (int j = 0; j < plen; j++) {
- int next = (j+1)%plen;
- EdgeKey ek(p.edges[j].point,p.edges[next].point);
+ int next = (j + 1) % plen;
+ EdgeKey ek(p.edges[j].point, p.edges[next].point);
- Map<EdgeKey,Connection>::Element *C=connections.find(ek);
+ Map<EdgeKey, Connection>::Element *C = connections.find(ek);
if (!C) {
Connection c;
- c.A=&p;
- c.A_edge=j;
- c.B=NULL;
- c.B_edge=-1;
- connections[ek]=c;
+ c.A = &p;
+ c.A_edge = j;
+ c.B = NULL;
+ c.B_edge = -1;
+ connections[ek] = c;
} else {
- if (C->get().B!=NULL) {
+ if (C->get().B != NULL) {
ConnectionPending pending;
- pending.polygon=&p;
- pending.edge=j;
- p.edges[j].P=C->get().pending.push_back(pending);
+ pending.polygon = &p;
+ pending.edge = j;
+ p.edges[j].P = C->get().pending.push_back(pending);
continue;
//print_line(String()+_get_vertex(ek.a)+" -> "+_get_vertex(ek.b));
}
//ERR_CONTINUE(C->get().B!=NULL); //wut
- C->get().B=&p;
- C->get().B_edge=j;
- C->get().A->edges[C->get().A_edge].C=&p;
- C->get().A->edges[C->get().A_edge].C_edge=j;
- p.edges[j].C=C->get().A;
- p.edges[j].C_edge=C->get().A_edge;
+ C->get().B = &p;
+ C->get().B_edge = j;
+ C->get().A->edges[C->get().A_edge].C = &p;
+ C->get().A->edges[C->get().A_edge].C_edge = j;
+ p.edges[j].C = C->get().A;
+ p.edges[j].C_edge = C->get().A_edge;
//connection successful.
}
}
}
- nm.linked=true;
-
+ nm.linked = true;
}
-
void Navigation::_navmesh_unlink(int p_id) {
ERR_FAIL_COND(!navmesh_map.has(p_id));
- NavMesh &nm=navmesh_map[p_id];
+ NavMesh &nm = navmesh_map[p_id];
ERR_FAIL_COND(!nm.linked);
print_line("UNLINK");
- for (List<Polygon>::Element *E=nm.polygons.front();E;E=E->next()) {
-
+ for (List<Polygon>::Element *E = nm.polygons.front(); E; E = E->next()) {
- Polygon &p=E->get();
+ Polygon &p = E->get();
int ec = p.edges.size();
- Polygon::Edge *edges=p.edges.ptr();
+ Polygon::Edge *edges = p.edges.ptr();
- for(int i=0;i<ec;i++) {
- int next = (i+1)%ec;
+ for (int i = 0; i < ec; i++) {
+ int next = (i + 1) % ec;
- EdgeKey ek(edges[i].point,edges[next].point);
- Map<EdgeKey,Connection>::Element *C=connections.find(ek);
+ EdgeKey ek(edges[i].point, edges[next].point);
+ Map<EdgeKey, Connection>::Element *C = connections.find(ek);
ERR_CONTINUE(!C);
if (edges[i].P) {
C->get().pending.erase(edges[i].P);
- edges[i].P=NULL;
+ edges[i].P = NULL;
} else if (C->get().B) {
//disconnect
- C->get().B->edges[C->get().B_edge].C=NULL;
- C->get().B->edges[C->get().B_edge].C_edge=-1;
- C->get().A->edges[C->get().A_edge].C=NULL;
- C->get().A->edges[C->get().A_edge].C_edge=-1;
+ C->get().B->edges[C->get().B_edge].C = NULL;
+ C->get().B->edges[C->get().B_edge].C_edge = -1;
+ C->get().A->edges[C->get().A_edge].C = NULL;
+ C->get().A->edges[C->get().A_edge].C_edge = -1;
- if (C->get().A==&E->get()) {
+ if (C->get().A == &E->get()) {
- C->get().A=C->get().B;
- C->get().A_edge=C->get().B_edge;
+ C->get().A = C->get().B;
+ C->get().A_edge = C->get().B_edge;
}
- C->get().B=NULL;
- C->get().B_edge=-1;
+ C->get().B = NULL;
+ C->get().B_edge = -1;
if (C->get().pending.size()) {
//reconnect if something is pending
ConnectionPending cp = C->get().pending.front()->get();
C->get().pending.pop_front();
- C->get().B=cp.polygon;
- C->get().B_edge=cp.edge;
- C->get().A->edges[C->get().A_edge].C=cp.polygon;
- C->get().A->edges[C->get().A_edge].C_edge=cp.edge;
- cp.polygon->edges[cp.edge].C=C->get().A;
- cp.polygon->edges[cp.edge].C_edge=C->get().A_edge;
- cp.polygon->edges[cp.edge].P=NULL;
+ C->get().B = cp.polygon;
+ C->get().B_edge = cp.edge;
+ C->get().A->edges[C->get().A_edge].C = cp.polygon;
+ C->get().A->edges[C->get().A_edge].C_edge = cp.edge;
+ cp.polygon->edges[cp.edge].C = C->get().A;
+ cp.polygon->edges[cp.edge].C_edge = C->get().A_edge;
+ cp.polygon->edges[cp.edge].P = NULL;
}
} else {
@@ -208,76 +202,68 @@ void Navigation::_navmesh_unlink(int p_id) {
nm.polygons.clear();
- nm.linked=false;
-
-
+ nm.linked = false;
}
-
-int Navigation::navmesh_create(const Ref<NavigationMesh>& p_mesh, const Transform& p_xform, Object *p_owner) {
+int Navigation::navmesh_create(const Ref<NavigationMesh> &p_mesh, const Transform &p_xform, Object *p_owner) {
int id = last_id++;
NavMesh nm;
- nm.linked=false;
- nm.navmesh=p_mesh;
- nm.xform=p_xform;
- nm.owner=p_owner;
- navmesh_map[id]=nm;
+ nm.linked = false;
+ nm.navmesh = p_mesh;
+ nm.xform = p_xform;
+ nm.owner = p_owner;
+ navmesh_map[id] = nm;
_navmesh_link(id);
return id;
}
-void Navigation::navmesh_set_transform(int p_id, const Transform& p_xform){
+void Navigation::navmesh_set_transform(int p_id, const Transform &p_xform) {
ERR_FAIL_COND(!navmesh_map.has(p_id));
- NavMesh &nm=navmesh_map[p_id];
- if (nm.xform==p_xform)
+ NavMesh &nm = navmesh_map[p_id];
+ if (nm.xform == p_xform)
return; //bleh
_navmesh_unlink(p_id);
- nm.xform=p_xform;
+ nm.xform = p_xform;
_navmesh_link(p_id);
-
-
-
}
-void Navigation::navmesh_remove(int p_id){
+void Navigation::navmesh_remove(int p_id) {
ERR_FAIL_COND(!navmesh_map.has(p_id));
_navmesh_unlink(p_id);
navmesh_map.erase(p_id);
-
}
-void Navigation::_clip_path(Vector<Vector3>& path, Polygon *from_poly, const Vector3& p_to_point, Polygon* p_to_poly) {
+void Navigation::_clip_path(Vector<Vector3> &path, Polygon *from_poly, const Vector3 &p_to_point, Polygon *p_to_poly) {
- Vector3 from = path[path.size()-1];
+ Vector3 from = path[path.size() - 1];
- if (from.distance_to(p_to_point)<CMP_EPSILON)
+ if (from.distance_to(p_to_point) < CMP_EPSILON)
return;
Plane cut_plane;
- cut_plane.normal = (from-p_to_point).cross(up);
- if (cut_plane.normal==Vector3())
+ cut_plane.normal = (from - p_to_point).cross(up);
+ if (cut_plane.normal == Vector3())
return;
cut_plane.normal.normalize();
cut_plane.d = cut_plane.normal.dot(from);
-
- while(from_poly!=p_to_poly) {
+ while (from_poly != p_to_poly) {
int pe = from_poly->prev_edge;
Vector3 a = _get_vertex(from_poly->edges[pe].point);
- Vector3 b = _get_vertex(from_poly->edges[(pe+1)%from_poly->edges.size()].point);
+ Vector3 b = _get_vertex(from_poly->edges[(pe + 1) % from_poly->edges.size()].point);
- from_poly=from_poly->edges[pe].C;
+ from_poly = from_poly->edges[pe].C;
ERR_FAIL_COND(!from_poly);
- if (a.distance_to(b)>CMP_EPSILON) {
+ if (a.distance_to(b) > CMP_EPSILON) {
Vector3 inters;
- if (cut_plane.intersects_segment(a,b,&inters)) {
- if (inters.distance_to(p_to_point)>CMP_EPSILON && inters.distance_to(path[path.size()-1])>CMP_EPSILON) {
+ if (cut_plane.intersects_segment(a, b, &inters)) {
+ if (inters.distance_to(p_to_point) > CMP_EPSILON && inters.distance_to(path[path.size() - 1]) > CMP_EPSILON) {
path.push_back(inters);
}
}
@@ -285,149 +271,138 @@ void Navigation::_clip_path(Vector<Vector3>& path, Polygon *from_poly, const Vec
}
}
-Vector<Vector3> Navigation::get_simple_path(const Vector3& p_start, const Vector3& p_end, bool p_optimize) {
+Vector<Vector3> Navigation::get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize) {
-
- Polygon *begin_poly=NULL;
- Polygon *end_poly=NULL;
+ Polygon *begin_poly = NULL;
+ Polygon *end_poly = NULL;
Vector3 begin_point;
Vector3 end_point;
- float begin_d=1e20;
- float end_d=1e20;
-
+ float begin_d = 1e20;
+ float end_d = 1e20;
- for (Map<int,NavMesh>::Element*E=navmesh_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navmesh_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
- for(int i=2;i<p.edges.size();i++) {
+ Polygon &p = F->get();
+ for (int i = 2; i < p.edges.size(); i++) {
- Face3 f(_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point));
+ Face3 f(_get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point));
Vector3 spoint = f.get_closest_point_to(p_start);
float dpoint = spoint.distance_to(p_start);
- if (dpoint<begin_d) {
- begin_d=dpoint;
- begin_poly=&p;
- begin_point=spoint;
+ if (dpoint < begin_d) {
+ begin_d = dpoint;
+ begin_poly = &p;
+ begin_point = spoint;
}
spoint = f.get_closest_point_to(p_end);
dpoint = spoint.distance_to(p_end);
- if (dpoint<end_d) {
- end_d=dpoint;
- end_poly=&p;
- end_point=spoint;
+ if (dpoint < end_d) {
+ end_d = dpoint;
+ end_poly = &p;
+ end_point = spoint;
}
}
- p.prev_edge=-1;
+ p.prev_edge = -1;
}
}
-
if (!begin_poly || !end_poly) {
//print_line("No Path Path");
return Vector<Vector3>(); //no path
}
-
- if (begin_poly==end_poly) {
+ if (begin_poly == end_poly) {
Vector<Vector3> path;
path.resize(2);
- path[0]=begin_point;
- path[1]=end_point;
+ path[0] = begin_point;
+ path[1] = end_point;
//print_line("Direct Path");
return path;
}
+ bool found_route = false;
- bool found_route=false;
-
- List<Polygon*> open_list;
+ List<Polygon *> open_list;
- for(int i=0;i<begin_poly->edges.size();i++) {
+ for (int i = 0; i < begin_poly->edges.size(); i++) {
if (begin_poly->edges[i].C) {
- begin_poly->edges[i].C->prev_edge=begin_poly->edges[i].C_edge;
- begin_poly->edges[i].C->distance=begin_poly->center.distance_to(begin_poly->edges[i].C->center);
+ begin_poly->edges[i].C->prev_edge = begin_poly->edges[i].C_edge;
+ begin_poly->edges[i].C->distance = begin_poly->center.distance_to(begin_poly->edges[i].C->center);
open_list.push_back(begin_poly->edges[i].C);
- if (begin_poly->edges[i].C==end_poly) {
- found_route=true;
+ if (begin_poly->edges[i].C == end_poly) {
+ found_route = true;
}
}
}
+ while (!found_route) {
- while(!found_route) {
-
- if (open_list.size()==0) {
- // print_line("NOU OPEN LIST");
+ if (open_list.size() == 0) {
+ // print_line("NOU OPEN LIST");
break;
}
//check open list
- List<Polygon*>::Element *least_cost_poly=NULL;
- float least_cost=1e30;
+ List<Polygon *>::Element *least_cost_poly = NULL;
+ float least_cost = 1e30;
//this could be faster (cache previous results)
- for (List<Polygon*>::Element *E=open_list.front();E;E=E->next()) {
-
- Polygon *p=E->get();
+ for (List<Polygon *>::Element *E = open_list.front(); E; E = E->next()) {
+ Polygon *p = E->get();
- float cost=p->distance;
- cost+=p->center.distance_to(end_point);
+ float cost = p->distance;
+ cost += p->center.distance_to(end_point);
- if (cost<least_cost) {
+ if (cost < least_cost) {
- least_cost_poly=E;
- least_cost=cost;
+ least_cost_poly = E;
+ least_cost = cost;
}
}
-
- Polygon *p=least_cost_poly->get();
+ Polygon *p = least_cost_poly->get();
//open the neighbours for search
- for(int i=0;i<p->edges.size();i++) {
-
+ for (int i = 0; i < p->edges.size(); i++) {
- Polygon::Edge &e=p->edges[i];
+ Polygon::Edge &e = p->edges[i];
if (!e.C)
continue;
float distance = p->center.distance_to(e.C->center) + p->distance;
- if (e.C->prev_edge!=-1) {
+ if (e.C->prev_edge != -1) {
//oh this was visited already, can we win the cost?
- if (e.C->distance>distance) {
+ if (e.C->distance > distance) {
- e.C->prev_edge=e.C_edge;
- e.C->distance=distance;
+ e.C->prev_edge = e.C_edge;
+ e.C->distance = distance;
}
} else {
//add to open neighbours
- e.C->prev_edge=e.C_edge;
- e.C->distance=distance;
+ e.C->prev_edge = e.C_edge;
+ e.C->distance = distance;
open_list.push_back(e.C);
- if (e.C==end_poly) {
+ if (e.C == end_poly) {
//oh my reached end! stop algorithm
- found_route=true;
+ found_route = true;
break;
-
}
-
}
}
@@ -444,174 +419,164 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3& p_start, const Vector
if (p_optimize) {
//string pulling
- Polygon *apex_poly=end_poly;
- Vector3 apex_point=end_point;
- Vector3 portal_left=apex_point;
- Vector3 portal_right=apex_point;
- Polygon *left_poly=end_poly;
- Polygon *right_poly=end_poly;
- Polygon *p=end_poly;
+ Polygon *apex_poly = end_poly;
+ Vector3 apex_point = end_point;
+ Vector3 portal_left = apex_point;
+ Vector3 portal_right = apex_point;
+ Polygon *left_poly = end_poly;
+ Polygon *right_poly = end_poly;
+ Polygon *p = end_poly;
path.push_back(end_point);
- while(p) {
+ while (p) {
Vector3 left;
Vector3 right;
-#define CLOCK_TANGENT(m_a,m_b,m_c) ( ((m_a)-(m_c)).cross((m_a)-(m_b)) )
+#define CLOCK_TANGENT(m_a, m_b, m_c) (((m_a) - (m_c)).cross((m_a) - (m_b)))
- if (p==begin_poly) {
- left=begin_point;
- right=begin_point;
+ if (p == begin_poly) {
+ left = begin_point;
+ right = begin_point;
} else {
int prev = p->prev_edge;
- int prev_n = (p->prev_edge+1)%p->edges.size();
+ int prev_n = (p->prev_edge + 1) % p->edges.size();
left = _get_vertex(p->edges[prev].point);
right = _get_vertex(p->edges[prev_n].point);
//if (CLOCK_TANGENT(apex_point,left,(left+right)*0.5).dot(up) < 0){
if (p->clockwise) {
- SWAP(left,right);
+ SWAP(left, right);
}
}
- bool skip=false;
-
+ bool skip = false;
- if (CLOCK_TANGENT(apex_point,portal_left,left).dot(up) >= 0){
+ if (CLOCK_TANGENT(apex_point, portal_left, left).dot(up) >= 0) {
//process
- if (portal_left==apex_point || CLOCK_TANGENT(apex_point,left,portal_right).dot(up) > 0) {
- left_poly=p;
- portal_left=left;
+ if (portal_left == apex_point || CLOCK_TANGENT(apex_point, left, portal_right).dot(up) > 0) {
+ left_poly = p;
+ portal_left = left;
} else {
- _clip_path(path,apex_poly,portal_right,right_poly);
+ _clip_path(path, apex_poly, portal_right, right_poly);
- apex_point=portal_right;
- p=right_poly;
- left_poly=p;
- apex_poly=p;
- portal_left=apex_point;
- portal_right=apex_point;
+ apex_point = portal_right;
+ p = right_poly;
+ left_poly = p;
+ apex_poly = p;
+ portal_left = apex_point;
+ portal_right = apex_point;
path.push_back(apex_point);
- skip=true;
+ skip = true;
}
}
- if (!skip && CLOCK_TANGENT(apex_point,portal_right,right).dot(up) <= 0){
+ if (!skip && CLOCK_TANGENT(apex_point, portal_right, right).dot(up) <= 0) {
//process
- if (portal_right==apex_point || CLOCK_TANGENT(apex_point,right,portal_left).dot(up) < 0) {
- right_poly=p;
- portal_right=right;
+ if (portal_right == apex_point || CLOCK_TANGENT(apex_point, right, portal_left).dot(up) < 0) {
+ right_poly = p;
+ portal_right = right;
} else {
- _clip_path(path,apex_poly,portal_left,left_poly);
+ _clip_path(path, apex_poly, portal_left, left_poly);
- apex_point=portal_left;
- p=left_poly;
- right_poly=p;
- apex_poly=p;
- portal_right=apex_point;
- portal_left=apex_point;
+ apex_point = portal_left;
+ p = left_poly;
+ right_poly = p;
+ apex_poly = p;
+ portal_right = apex_point;
+ portal_left = apex_point;
path.push_back(apex_point);
}
}
- if (p!=begin_poly)
- p=p->edges[p->prev_edge].C;
+ if (p != begin_poly)
+ p = p->edges[p->prev_edge].C;
else
- p=NULL;
-
+ p = NULL;
}
- if (path[path.size()-1]!=begin_point)
+ if (path[path.size() - 1] != begin_point)
path.push_back(begin_point);
path.invert();
-
-
-
} else {
//midpoints
- Polygon *p=end_poly;
+ Polygon *p = end_poly;
path.push_back(end_point);
- while(true) {
+ while (true) {
int prev = p->prev_edge;
- int prev_n = (p->prev_edge+1)%p->edges.size();
- Vector3 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point))*0.5;
+ int prev_n = (p->prev_edge + 1) % p->edges.size();
+ Vector3 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point)) * 0.5;
path.push_back(point);
p = p->edges[prev].C;
- if (p==begin_poly)
+ if (p == begin_poly)
break;
}
path.push_back(begin_point);
-
path.invert();
}
return path;
}
-
return Vector<Vector3>();
-
}
-Vector3 Navigation::get_closest_point_to_segment(const Vector3& p_from,const Vector3& p_to,const bool& p_use_collision) {
-
+Vector3 Navigation::get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool &p_use_collision) {
- bool use_collision=p_use_collision;
+ bool use_collision = p_use_collision;
Vector3 closest_point;
- float closest_point_d=1e20;
- NavMesh *closest_navmesh=NULL;
+ float closest_point_d = 1e20;
+ NavMesh *closest_navmesh = NULL;
- for (Map<int,NavMesh>::Element*E=navmesh_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navmesh_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
- for(int i=2;i<p.edges.size();i++) {
+ Polygon &p = F->get();
+ for (int i = 2; i < p.edges.size(); i++) {
- Face3 f(_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point));
+ Face3 f(_get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point));
Vector3 inters;
- if (f.intersects_segment(p_from,p_to,&inters)) {
+ if (f.intersects_segment(p_from, p_to, &inters)) {
if (!use_collision) {
- closest_point=inters;
- use_collision=true;
- closest_point_d=p_from.distance_to(inters);
- closest_navmesh=p.owner;
- } else if (closest_point_d > inters.distance_to(p_from)){
+ closest_point = inters;
+ use_collision = true;
+ closest_point_d = p_from.distance_to(inters);
+ closest_navmesh = p.owner;
+ } else if (closest_point_d > inters.distance_to(p_from)) {
- closest_point=inters;
- closest_point_d=p_from.distance_to(inters);
- closest_navmesh=p.owner;
+ closest_point = inters;
+ closest_point_d = p_from.distance_to(inters);
+ closest_navmesh = p.owner;
}
}
}
if (!use_collision) {
- for(int i=0;i<p.edges.size();i++) {
+ for (int i = 0; i < p.edges.size(); i++) {
- Vector3 a,b;
+ Vector3 a, b;
- Geometry::get_closest_points_between_segments(p_from,p_to,_get_vertex(p.edges[i].point),_get_vertex(p.edges[(i+1)%p.edges.size()].point),a,b);
+ Geometry::get_closest_points_between_segments(p_from, p_to, _get_vertex(p.edges[i].point), _get_vertex(p.edges[(i + 1) % p.edges.size()].point), a, b);
float d = a.distance_to(b);
- if (d<closest_point_d) {
+ if (d < closest_point_d) {
- closest_point_d=d;
- closest_point=b;
- closest_navmesh=p.owner;
+ closest_point_d = d;
+ closest_point = b;
+ closest_navmesh = p.owner;
}
-
}
}
}
@@ -624,132 +589,126 @@ Vector3 Navigation::get_closest_point_to_segment(const Vector3& p_from,const Vec
return closest_point;
}
-Vector3 Navigation::get_closest_point(const Vector3& p_point) {
+Vector3 Navigation::get_closest_point(const Vector3 &p_point) {
Vector3 closest_point;
- float closest_point_d=1e20;
+ float closest_point_d = 1e20;
- for (Map<int,NavMesh>::Element*E=navmesh_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navmesh_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
- for(int i=2;i<p.edges.size();i++) {
+ Polygon &p = F->get();
+ for (int i = 2; i < p.edges.size(); i++) {
- Face3 f(_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point));
+ Face3 f(_get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point));
Vector3 inters = f.get_closest_point_to(p_point);
float d = inters.distance_to(p_point);
- if (d<closest_point_d) {
- closest_point=inters;
- closest_point_d=d;
+ if (d < closest_point_d) {
+ closest_point = inters;
+ closest_point_d = d;
}
}
}
}
return closest_point;
-
}
-Vector3 Navigation::get_closest_point_normal(const Vector3& p_point){
+Vector3 Navigation::get_closest_point_normal(const Vector3 &p_point) {
Vector3 closest_point;
Vector3 closest_normal;
- float closest_point_d=1e20;
+ float closest_point_d = 1e20;
- for (Map<int,NavMesh>::Element*E=navmesh_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navmesh_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
- for(int i=2;i<p.edges.size();i++) {
+ Polygon &p = F->get();
+ for (int i = 2; i < p.edges.size(); i++) {
- Face3 f(_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point));
+ Face3 f(_get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point));
Vector3 inters = f.get_closest_point_to(p_point);
float d = inters.distance_to(p_point);
- if (d<closest_point_d) {
- closest_point=inters;
- closest_point_d=d;
- closest_normal=f.get_plane().normal;
+ if (d < closest_point_d) {
+ closest_point = inters;
+ closest_point_d = d;
+ closest_normal = f.get_plane().normal;
}
}
}
}
return closest_normal;
-
}
-
-Object* Navigation::get_closest_point_owner(const Vector3& p_point){
+Object *Navigation::get_closest_point_owner(const Vector3 &p_point) {
Vector3 closest_point;
- Object *owner=NULL;
- float closest_point_d=1e20;
+ Object *owner = NULL;
+ float closest_point_d = 1e20;
- for (Map<int,NavMesh>::Element*E=navmesh_map.front();E;E=E->next()) {
+ for (Map<int, NavMesh>::Element *E = navmesh_map.front(); E; E = E->next()) {
if (!E->get().linked)
continue;
- for(List<Polygon>::Element *F=E->get().polygons.front();F;F=F->next()) {
+ for (List<Polygon>::Element *F = E->get().polygons.front(); F; F = F->next()) {
- Polygon &p=F->get();
- for(int i=2;i<p.edges.size();i++) {
+ Polygon &p = F->get();
+ for (int i = 2; i < p.edges.size(); i++) {
- Face3 f(_get_vertex(p.edges[0].point),_get_vertex(p.edges[i-1].point),_get_vertex(p.edges[i].point));
+ Face3 f(_get_vertex(p.edges[0].point), _get_vertex(p.edges[i - 1].point), _get_vertex(p.edges[i].point));
Vector3 inters = f.get_closest_point_to(p_point);
float d = inters.distance_to(p_point);
- if (d<closest_point_d) {
- closest_point=inters;
- closest_point_d=d;
- owner=E->get().owner;
+ if (d < closest_point_d) {
+ closest_point = inters;
+ closest_point_d = d;
+ owner = E->get().owner;
}
}
}
}
return owner;
-
}
-void Navigation::set_up_vector(const Vector3& p_up) {
+void Navigation::set_up_vector(const Vector3 &p_up) {
-
- up=p_up;
+ up = p_up;
}
-Vector3 Navigation::get_up_vector() const{
+Vector3 Navigation::get_up_vector() const {
return up;
}
-
void Navigation::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("navmesh_create","mesh:NavigationMesh","xform","owner"),&Navigation::navmesh_create,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("navmesh_set_transform","id","xform"),&Navigation::navmesh_set_transform);
- ObjectTypeDB::bind_method(_MD("navmesh_remove","id"),&Navigation::navmesh_remove);
+ ObjectTypeDB::bind_method(_MD("navmesh_create", "mesh:NavigationMesh", "xform", "owner"), &Navigation::navmesh_create, DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("navmesh_set_transform", "id", "xform"), &Navigation::navmesh_set_transform);
+ ObjectTypeDB::bind_method(_MD("navmesh_remove", "id"), &Navigation::navmesh_remove);
- ObjectTypeDB::bind_method(_MD("get_simple_path","start","end","optimize"),&Navigation::get_simple_path,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("get_closest_point_to_segment","start","end","use_collision"),&Navigation::get_closest_point_to_segment,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_closest_point","to_point"),&Navigation::get_closest_point);
- ObjectTypeDB::bind_method(_MD("get_closest_point_normal","to_point"),&Navigation::get_closest_point_normal);
- ObjectTypeDB::bind_method(_MD("get_closest_point_owner","to_point"),&Navigation::get_closest_point_owner);
+ ObjectTypeDB::bind_method(_MD("get_simple_path", "start", "end", "optimize"), &Navigation::get_simple_path, DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("get_closest_point_to_segment", "start", "end", "use_collision"), &Navigation::get_closest_point_to_segment, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_closest_point", "to_point"), &Navigation::get_closest_point);
+ ObjectTypeDB::bind_method(_MD("get_closest_point_normal", "to_point"), &Navigation::get_closest_point_normal);
+ ObjectTypeDB::bind_method(_MD("get_closest_point_owner", "to_point"), &Navigation::get_closest_point_owner);
- ObjectTypeDB::bind_method(_MD("set_up_vector","up"),&Navigation::set_up_vector);
- ObjectTypeDB::bind_method(_MD("get_up_vector"),&Navigation::get_up_vector);
+ ObjectTypeDB::bind_method(_MD("set_up_vector", "up"), &Navigation::set_up_vector);
+ ObjectTypeDB::bind_method(_MD("get_up_vector"), &Navigation::get_up_vector);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"up_vector"),_SCS("set_up_vector"),_SCS("get_up_vector"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "up_vector"), _SCS("set_up_vector"), _SCS("get_up_vector"));
}
Navigation::Navigation() {
- ERR_FAIL_COND( sizeof(Point)!=8 );
- cell_size=0.01; //one centimeter
- last_id=1;
- up=Vector3(0,1,0);
+ ERR_FAIL_COND(sizeof(Point) != 8);
+ cell_size = 0.01; //one centimeter
+ last_id = 1;
+ up = Vector3(0, 1, 0);
}
diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h
index 8bec170a0..7a545c8d8 100644
--- a/scene/3d/navigation.h
+++ b/scene/3d/navigation.h
@@ -29,46 +29,43 @@
#ifndef NAVIGATION_H
#define NAVIGATION_H
-#include "scene/3d/spatial.h"
#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/spatial.h"
class Navigation : public Spatial {
- OBJ_TYPE( Navigation, Spatial);
-
+ OBJ_TYPE(Navigation, Spatial);
union Point {
struct {
- int64_t x:21;
- int64_t y:22;
- int64_t z:21;
+ int64_t x : 21;
+ int64_t y : 22;
+ int64_t z : 21;
};
uint64_t key;
- bool operator<(const Point& p_key) const { return key < p_key.key; }
+ bool operator<(const Point &p_key) const { return key < p_key.key; }
};
-
struct EdgeKey {
Point a;
Point b;
- bool operator<(const EdgeKey& p_key) const {
- return (a.key==p_key.a.key)?(b.key<p_key.b.key):(a.key<p_key.a.key);
+ bool operator<(const EdgeKey &p_key) const {
+ return (a.key == p_key.a.key) ? (b.key < p_key.b.key) : (a.key < p_key.a.key);
};
- EdgeKey(const Point& p_a=Point(),const Point& p_b=Point()) {
- a=p_a;
- b=p_b;
+ EdgeKey(const Point &p_a = Point(), const Point &p_b = Point()) {
+ a = p_a;
+ b = p_b;
if (a.key > b.key) {
- SWAP(a,b);
+ SWAP(a, b);
}
}
};
-
struct NavMesh;
struct Polygon;
@@ -78,7 +75,6 @@ class Navigation : public Spatial {
int edge;
};
-
struct Polygon {
struct Edge {
@@ -86,7 +82,11 @@ class Navigation : public Spatial {
Polygon *C; //connection
int C_edge;
List<ConnectionPending>::Element *P;
- Edge() { C=NULL; C_edge=-1; P=NULL; }
+ Edge() {
+ C = NULL;
+ C_edge = -1;
+ P = NULL;
+ }
};
Vector<Edge> edges;
@@ -97,11 +97,9 @@ class Navigation : public Spatial {
int prev_edge;
bool clockwise;
-
NavMesh *owner;
};
-
struct Connection {
Polygon *A;
@@ -111,11 +109,15 @@ class Navigation : public Spatial {
List<ConnectionPending> pending;
- Connection() { A=NULL; B=NULL; A_edge=-1; B_edge=-1;}
+ Connection() {
+ A = NULL;
+ B = NULL;
+ A_edge = -1;
+ B_edge = -1;
+ }
};
- Map<EdgeKey,Connection> connections;
-
+ Map<EdgeKey, Connection> connections;
struct NavMesh {
@@ -124,62 +126,54 @@ class Navigation : public Spatial {
bool linked;
Ref<NavigationMesh> navmesh;
List<Polygon> polygons;
-
};
+ _FORCE_INLINE_ Point _get_point(const Vector3 &p_pos) const {
-
- _FORCE_INLINE_ Point _get_point(const Vector3& p_pos) const {
-
- int x = int(Math::floor(p_pos.x/cell_size));
- int y = int(Math::floor(p_pos.y/cell_size));
- int z = int(Math::floor(p_pos.z/cell_size));
+ int x = int(Math::floor(p_pos.x / cell_size));
+ int y = int(Math::floor(p_pos.y / cell_size));
+ int z = int(Math::floor(p_pos.z / cell_size));
Point p;
- p.key=0;
- p.x=x;
- p.y=y;
- p.z=z;
+ p.key = 0;
+ p.x = x;
+ p.y = y;
+ p.z = z;
return p;
-
}
- _FORCE_INLINE_ Vector3 _get_vertex(const Point& p_point) const {
+ _FORCE_INLINE_ Vector3 _get_vertex(const Point &p_point) const {
- return Vector3(p_point.x,p_point.y,p_point.z)*cell_size;
+ return Vector3(p_point.x, p_point.y, p_point.z) * cell_size;
}
-
-
void _navmesh_link(int p_id);
void _navmesh_unlink(int p_id);
float cell_size;
- Map<int,NavMesh> navmesh_map;
+ Map<int, NavMesh> navmesh_map;
int last_id;
Vector3 up;
- void _clip_path(Vector<Vector3>& path,Polygon *from_poly, const Vector3& p_to_point, Polygon* p_to_poly);
+ void _clip_path(Vector<Vector3> &path, Polygon *from_poly, const Vector3 &p_to_point, Polygon *p_to_poly);
protected:
-
static void _bind_methods();
public:
-
- void set_up_vector(const Vector3& p_up);
+ void set_up_vector(const Vector3 &p_up);
Vector3 get_up_vector() const;
//API should be as dynamic as possible
- int navmesh_create(const Ref<NavigationMesh>& p_mesh,const Transform& p_xform,Object* p_owner=NULL);
- void navmesh_set_transform(int p_id, const Transform& p_xform);
+ int navmesh_create(const Ref<NavigationMesh> &p_mesh, const Transform &p_xform, Object *p_owner = NULL);
+ void navmesh_set_transform(int p_id, const Transform &p_xform);
void navmesh_remove(int p_id);
- Vector<Vector3> get_simple_path(const Vector3& p_start, const Vector3& p_end,bool p_optimize=true);
- Vector3 get_closest_point_to_segment(const Vector3& p_from,const Vector3& p_to,const bool& p_use_collision=false);
- Vector3 get_closest_point(const Vector3& p_point);
- Vector3 get_closest_point_normal(const Vector3& p_point);
- Object* get_closest_point_owner(const Vector3& p_point);
+ Vector<Vector3> get_simple_path(const Vector3 &p_start, const Vector3 &p_end, bool p_optimize = true);
+ Vector3 get_closest_point_to_segment(const Vector3 &p_from, const Vector3 &p_to, const bool &p_use_collision = false);
+ Vector3 get_closest_point(const Vector3 &p_point);
+ Vector3 get_closest_point_normal(const Vector3 &p_point);
+ Object *get_closest_point_owner(const Vector3 &p_point);
Navigation();
};
diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp
index 25f675ac0..baea75ebe 100644
--- a/scene/3d/navigation_mesh.cpp
+++ b/scene/3d/navigation_mesh.cpp
@@ -27,23 +27,22 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "navigation_mesh.h"
-#include "navigation.h"
#include "mesh_instance.h"
+#include "navigation.h"
-void NavigationMesh::create_from_mesh(const Ref<Mesh>& p_mesh) {
-
+void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
- vertices=DVector<Vector3>();
+ vertices = DVector<Vector3>();
clear_polygons();
- for(int i=0;i<p_mesh->get_surface_count();i++) {
+ for (int i = 0; i < p_mesh->get_surface_count(); i++) {
- if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES)
+ if (p_mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
continue;
Array arr = p_mesh->surface_get_arrays(i);
DVector<Vector3> varr = arr[Mesh::ARRAY_VERTEX];
DVector<int> iarr = arr[Mesh::ARRAY_INDEX];
- if (varr.size()==0 || iarr.size()==0)
+ if (varr.size() == 0 || iarr.size() == 0)
continue;
int from = vertices.size();
@@ -51,34 +50,33 @@ void NavigationMesh::create_from_mesh(const Ref<Mesh>& p_mesh) {
int rlen = iarr.size();
DVector<int>::Read r = iarr.read();
- for(int j=0;j<rlen;j+=3) {
+ for (int j = 0; j < rlen; j += 3) {
Vector<int> vi;
vi.resize(3);
- vi[0]=r[j+0]+from;
- vi[1]=r[j+1]+from;
- vi[2]=r[j+2]+from;
+ vi[0] = r[j + 0] + from;
+ vi[1] = r[j + 1] + from;
+ vi[2] = r[j + 2] + from;
add_polygon(vi);
}
}
}
-void NavigationMesh::set_vertices(const DVector<Vector3>& p_vertices) {
+void NavigationMesh::set_vertices(const DVector<Vector3> &p_vertices) {
- vertices=p_vertices;
+ vertices = p_vertices;
}
-DVector<Vector3> NavigationMesh::get_vertices() const{
+DVector<Vector3> NavigationMesh::get_vertices() const {
return vertices;
}
-
-void NavigationMesh::_set_polygons(const Array& p_array) {
+void NavigationMesh::_set_polygons(const Array &p_array) {
polygons.resize(p_array.size());
- for(int i=0;i<p_array.size();i++) {
- polygons[i].indices=p_array[i];
+ for (int i = 0; i < p_array.size(); i++) {
+ polygons[i].indices = p_array[i];
}
}
@@ -86,31 +84,29 @@ Array NavigationMesh::_get_polygons() const {
Array ret;
ret.resize(polygons.size());
- for(int i=0;i<ret.size();i++) {
- ret[i]=polygons[i].indices;
+ for (int i = 0; i < ret.size(); i++) {
+ ret[i] = polygons[i].indices;
}
return ret;
}
-
-void NavigationMesh::add_polygon(const Vector<int>& p_polygon){
+void NavigationMesh::add_polygon(const Vector<int> &p_polygon) {
Polygon polygon;
- polygon.indices=p_polygon;
+ polygon.indices = p_polygon;
polygons.push_back(polygon);
-
}
-int NavigationMesh::get_polygon_count() const{
+int NavigationMesh::get_polygon_count() const {
return polygons.size();
}
-Vector<int> NavigationMesh::get_polygon(int p_idx){
+Vector<int> NavigationMesh::get_polygon(int p_idx) {
- ERR_FAIL_INDEX_V(p_idx,polygons.size(),Vector<int>());
+ ERR_FAIL_INDEX_V(p_idx, polygons.size(), Vector<int>());
return polygons[p_idx].indices;
}
-void NavigationMesh::clear_polygons(){
+void NavigationMesh::clear_polygons() {
polygons.clear();
}
@@ -120,64 +116,59 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
if (debug_mesh.is_valid())
return debug_mesh;
-
-
DVector<Vector3> vertices = get_vertices();
- DVector<Vector3>::Read vr=vertices.read();
+ DVector<Vector3>::Read vr = vertices.read();
List<Face3> faces;
- for(int i=0;i<get_polygon_count();i++) {
+ for (int i = 0; i < get_polygon_count(); i++) {
Vector<int> p = get_polygon(i);
- for(int j=2;j<p.size();j++) {
+ for (int j = 2; j < p.size(); j++) {
Face3 f;
- f.vertex[0]=vr[p[0]];
- f.vertex[1]=vr[p[j-1]];
- f.vertex[2]=vr[p[j]];
+ f.vertex[0] = vr[p[0]];
+ f.vertex[1] = vr[p[j - 1]];
+ f.vertex[2] = vr[p[j]];
faces.push_back(f);
}
}
-
- Map<_EdgeKey,bool> edge_map;
+ Map<_EdgeKey, bool> edge_map;
DVector<Vector3> tmeshfaces;
- tmeshfaces.resize(faces.size()*3);
+ tmeshfaces.resize(faces.size() * 3);
{
- DVector<Vector3>::Write tw=tmeshfaces.write();
- int tidx=0;
-
+ DVector<Vector3>::Write tw = tmeshfaces.write();
+ int tidx = 0;
- for(List<Face3>::Element *E=faces.front();E;E=E->next()) {
+ for (List<Face3>::Element *E = faces.front(); E; E = E->next()) {
const Face3 &f = E->get();
- for(int j=0;j<3;j++) {
+ for (int j = 0; j < 3; j++) {
- tw[tidx++]=f.vertex[j];
+ tw[tidx++] = f.vertex[j];
_EdgeKey ek;
- ek.from=f.vertex[j].snapped(CMP_EPSILON);
- ek.to=f.vertex[(j+1)%3].snapped(CMP_EPSILON);
- if (ek.from<ek.to)
- SWAP(ek.from,ek.to);
+ ek.from = f.vertex[j].snapped(CMP_EPSILON);
+ ek.to = f.vertex[(j + 1) % 3].snapped(CMP_EPSILON);
+ if (ek.from < ek.to)
+ SWAP(ek.from, ek.to);
- Map<_EdgeKey,bool>::Element *E=edge_map.find(ek);
+ Map<_EdgeKey, bool>::Element *E = edge_map.find(ek);
if (E) {
- E->get()=false;
+ E->get() = false;
} else {
- edge_map[ek]=true;
+ edge_map[ek] = true;
}
-
}
}
}
List<Vector3> lines;
- for(Map<_EdgeKey,bool>::Element *E=edge_map.front();E;E=E->next()) {
+ for (Map<_EdgeKey, bool>::Element *E = edge_map.front(); E; E = E->next()) {
if (E->get()) {
lines.push_back(E->key().from);
@@ -189,58 +180,57 @@ Ref<Mesh> NavigationMesh::get_debug_mesh() {
varr.resize(lines.size());
{
DVector<Vector3>::Write w = varr.write();
- int idx=0;
- for(List<Vector3>::Element *E=lines.front();E;E=E->next()) {
- w[idx++]=E->get();
+ int idx = 0;
+ for (List<Vector3>::Element *E = lines.front(); E; E = E->next()) {
+ w[idx++] = E->get();
}
}
- debug_mesh = Ref<Mesh>( memnew( Mesh ) );
+ debug_mesh = Ref<Mesh>(memnew(Mesh));
Array arr;
arr.resize(Mesh::ARRAY_MAX);
- arr[Mesh::ARRAY_VERTEX]=varr;
+ arr[Mesh::ARRAY_VERTEX] = varr;
- debug_mesh->add_surface(Mesh::PRIMITIVE_LINES,arr);
+ debug_mesh->add_surface(Mesh::PRIMITIVE_LINES, arr);
return debug_mesh;
}
void NavigationMesh::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_vertices","vertices"),&NavigationMesh::set_vertices);
- ObjectTypeDB::bind_method(_MD("get_vertices"),&NavigationMesh::get_vertices);
+ ObjectTypeDB::bind_method(_MD("set_vertices", "vertices"), &NavigationMesh::set_vertices);
+ ObjectTypeDB::bind_method(_MD("get_vertices"), &NavigationMesh::get_vertices);
- ObjectTypeDB::bind_method(_MD("add_polygon","polygon"),&NavigationMesh::add_polygon);
- ObjectTypeDB::bind_method(_MD("get_polygon_count"),&NavigationMesh::get_polygon_count);
- ObjectTypeDB::bind_method(_MD("get_polygon","idx"),&NavigationMesh::get_polygon);
- ObjectTypeDB::bind_method(_MD("clear_polygons"),&NavigationMesh::clear_polygons);
+ ObjectTypeDB::bind_method(_MD("add_polygon", "polygon"), &NavigationMesh::add_polygon);
+ ObjectTypeDB::bind_method(_MD("get_polygon_count"), &NavigationMesh::get_polygon_count);
+ ObjectTypeDB::bind_method(_MD("get_polygon", "idx"), &NavigationMesh::get_polygon);
+ ObjectTypeDB::bind_method(_MD("clear_polygons"), &NavigationMesh::clear_polygons);
- ObjectTypeDB::bind_method(_MD("_set_polygons","polygons"),&NavigationMesh::_set_polygons);
- ObjectTypeDB::bind_method(_MD("_get_polygons"),&NavigationMesh::_get_polygons);
+ ObjectTypeDB::bind_method(_MD("_set_polygons", "polygons"), &NavigationMesh::_set_polygons);
+ ObjectTypeDB::bind_method(_MD("_get_polygons"), &NavigationMesh::_get_polygons);
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"vertices",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_vertices"),_SCS("get_vertices"));
- ADD_PROPERTY(PropertyInfo(Variant::ARRAY,"polygons",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_polygons"),_SCS("_get_polygons"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY, "vertices", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("set_vertices"), _SCS("get_vertices"));
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "polygons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_polygons"), _SCS("_get_polygons"));
}
NavigationMesh::NavigationMesh() {
-
}
void NavigationMeshInstance::set_enabled(bool p_enabled) {
- if (enabled==p_enabled)
+ if (enabled == p_enabled)
return;
- enabled=p_enabled;
+ enabled = p_enabled;
if (!is_inside_tree())
return;
if (!enabled) {
- if (nav_id!=-1) {
+ if (nav_id != -1) {
navigation->navmesh_remove(nav_id);
- nav_id=-1;
+ nav_id = -1;
}
} else {
@@ -248,20 +238,18 @@ void NavigationMeshInstance::set_enabled(bool p_enabled) {
if (navmesh.is_valid()) {
- nav_id = navigation->navmesh_create(navmesh,get_relative_transform(navigation),this);
+ nav_id = navigation->navmesh_create(navmesh, get_relative_transform(navigation), this);
}
}
-
}
if (debug_view) {
- MeshInstance *dm=debug_view->cast_to<MeshInstance>();
+ MeshInstance *dm = debug_view->cast_to<MeshInstance>();
if (is_enabled()) {
- dm->set_material_override( get_tree()->get_debug_navigation_material() );
+ dm->set_material_override(get_tree()->get_debug_navigation_material());
} else {
- dm->set_material_override( get_tree()->get_debug_navigation_disabled_material() );
+ dm->set_material_override(get_tree()->get_debug_navigation_disabled_material());
}
-
}
update_gizmo();
@@ -269,104 +257,96 @@ void NavigationMeshInstance::set_enabled(bool p_enabled) {
bool NavigationMeshInstance::is_enabled() const {
-
return enabled;
}
-
/////////////////////////////
-
void NavigationMeshInstance::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- Spatial *c=this;
- while(c) {
+ Spatial *c = this;
+ while (c) {
- navigation=c->cast_to<Navigation>();
+ navigation = c->cast_to<Navigation>();
if (navigation) {
if (enabled && navmesh.is_valid()) {
- nav_id = navigation->navmesh_create(navmesh,get_relative_transform(navigation),this);
+ nav_id = navigation->navmesh_create(navmesh, get_relative_transform(navigation), this);
}
break;
}
- c=c->get_parent_spatial();
+ c = c->get_parent_spatial();
}
if (navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) {
- MeshInstance *dm = memnew( MeshInstance );
- dm->set_mesh( navmesh->get_debug_mesh() );
+ MeshInstance *dm = memnew(MeshInstance);
+ dm->set_mesh(navmesh->get_debug_mesh());
if (is_enabled()) {
- dm->set_material_override( get_tree()->get_debug_navigation_material() );
+ dm->set_material_override(get_tree()->get_debug_navigation_material());
} else {
- dm->set_material_override( get_tree()->get_debug_navigation_disabled_material() );
+ dm->set_material_override(get_tree()->get_debug_navigation_disabled_material());
}
add_child(dm);
- debug_view=dm;
+ debug_view = dm;
}
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- if (navigation && nav_id!=-1) {
- navigation->navmesh_set_transform(nav_id,get_relative_transform(navigation));
+ if (navigation && nav_id != -1) {
+ navigation->navmesh_set_transform(nav_id, get_relative_transform(navigation));
}
-
-
} break;
case NOTIFICATION_EXIT_TREE: {
if (navigation) {
- if (nav_id!=-1) {
+ if (nav_id != -1) {
navigation->navmesh_remove(nav_id);
- nav_id=-1;
+ nav_id = -1;
}
}
if (debug_view) {
debug_view->queue_delete();
- debug_view=NULL;
+ debug_view = NULL;
}
- navigation=NULL;
+ navigation = NULL;
} break;
}
}
+void NavigationMeshInstance::set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh) {
-void NavigationMeshInstance::set_navigation_mesh(const Ref<NavigationMesh>& p_navmesh) {
-
- if (p_navmesh==navmesh)
+ if (p_navmesh == navmesh)
return;
- if (navigation && nav_id!=-1) {
+ if (navigation && nav_id != -1) {
navigation->navmesh_remove(nav_id);
- nav_id=-1;
+ nav_id = -1;
}
- navmesh=p_navmesh;
+ navmesh = p_navmesh;
if (navigation && navmesh.is_valid() && enabled) {
- nav_id = navigation->navmesh_create(navmesh,get_relative_transform(navigation),this);
+ nav_id = navigation->navmesh_create(navmesh, get_relative_transform(navigation), this);
}
-
+
if (debug_view && navmesh.is_valid()) {
- debug_view->cast_to<MeshInstance>()->set_mesh( navmesh->get_debug_mesh() );
+ debug_view->cast_to<MeshInstance>()->set_mesh(navmesh->get_debug_mesh());
}
-
+
update_gizmo();
update_configuration_warning();
-
}
-Ref<NavigationMesh> NavigationMeshInstance::get_navigation_mesh() const{
+Ref<NavigationMesh> NavigationMeshInstance::get_navigation_mesh() const {
return navmesh;
}
@@ -379,36 +359,34 @@ String NavigationMeshInstance::get_configuration_warning() const {
if (!navmesh.is_valid()) {
return TTR("A NavigationMesh resource must be set or created for this node to work.");
}
- const Spatial *c=this;
- while(c) {
+ const Spatial *c = this;
+ while (c) {
if (c->cast_to<Navigation>())
return String();
- c=c->get_parent()->cast_to<Spatial>();
+ c = c->get_parent()->cast_to<Spatial>();
}
return TTR("NavigationMeshInstance must be a child or grandchild to a Navigation node. It only provides navigation data.");
}
-
void NavigationMeshInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_navigation_mesh","navmesh"),&NavigationMeshInstance::set_navigation_mesh);
- ObjectTypeDB::bind_method(_MD("get_navigation_mesh"),&NavigationMeshInstance::get_navigation_mesh);
+ ObjectTypeDB::bind_method(_MD("set_navigation_mesh", "navmesh"), &NavigationMeshInstance::set_navigation_mesh);
+ ObjectTypeDB::bind_method(_MD("get_navigation_mesh"), &NavigationMeshInstance::get_navigation_mesh);
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&NavigationMeshInstance::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&NavigationMeshInstance::is_enabled);
+ ObjectTypeDB::bind_method(_MD("set_enabled", "enabled"), &NavigationMeshInstance::set_enabled);
+ ObjectTypeDB::bind_method(_MD("is_enabled"), &NavigationMeshInstance::is_enabled);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"navmesh",PROPERTY_HINT_RESOURCE_TYPE,"NavigationMesh"),_SCS("set_navigation_mesh"),_SCS("get_navigation_mesh"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"), _SCS("set_navigation_mesh"), _SCS("get_navigation_mesh"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
}
NavigationMeshInstance::NavigationMeshInstance() {
- debug_view=NULL;
- navigation=NULL;
- nav_id=-1;
- enabled=true;
-
+ debug_view = NULL;
+ navigation = NULL;
+ nav_id = -1;
+ enabled = true;
}
diff --git a/scene/3d/navigation_mesh.h b/scene/3d/navigation_mesh.h
index b26446b74..6d4974ad3 100644
--- a/scene/3d/navigation_mesh.h
+++ b/scene/3d/navigation_mesh.h
@@ -34,9 +34,9 @@
class Mesh;
-class NavigationMesh : public Resource {
+class NavigationMesh : public Resource {
- OBJ_TYPE( NavigationMesh, Resource );
+ OBJ_TYPE(NavigationMesh, Resource);
DVector<Vector3> vertices;
struct Polygon {
@@ -50,25 +50,22 @@ class NavigationMesh : public Resource {
Vector3 from;
Vector3 to;
- bool operator<(const _EdgeKey& p_with) const { return from==p_with.from ? to < p_with.to : from < p_with.from; }
+ bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; }
};
-
protected:
-
static void _bind_methods();
- void _set_polygons(const Array& p_array);
+ void _set_polygons(const Array &p_array);
Array _get_polygons() const;
public:
+ void create_from_mesh(const Ref<Mesh> &p_mesh);
- void create_from_mesh(const Ref<Mesh>& p_mesh);
-
- void set_vertices(const DVector<Vector3>& p_vertices);
+ void set_vertices(const DVector<Vector3> &p_vertices);
DVector<Vector3> get_vertices() const;
- void add_polygon(const Vector<int>& p_polygon);
+ void add_polygon(const Vector<int> &p_polygon);
int get_polygon_count() const;
Vector<int> get_polygon(int p_idx);
void clear_polygons();
@@ -78,12 +75,11 @@ public:
NavigationMesh();
};
-
class Navigation;
class NavigationMeshInstance : public Spatial {
- OBJ_TYPE(NavigationMeshInstance,Spatial);
+ OBJ_TYPE(NavigationMeshInstance, Spatial);
bool enabled;
int nav_id;
@@ -93,17 +89,14 @@ class NavigationMeshInstance : public Spatial {
Node *debug_view;
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
-
-
+public:
void set_enabled(bool p_enabled);
bool is_enabled() const;
- void set_navigation_mesh(const Ref<NavigationMesh>& p_navmesh);
+ void set_navigation_mesh(const Ref<NavigationMesh> &p_navmesh);
Ref<NavigationMesh> get_navigation_mesh() const;
String get_configuration_warning() const;
@@ -111,5 +104,4 @@ public:
NavigationMeshInstance();
};
-
#endif // NAVIGATION_MESH_H
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index c700fed57..18c8d823f 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "particles.h"
-#include "servers/visual_server.h"
#include "scene/resources/surface_tool.h"
+#include "servers/visual_server.h"
/*
static const char* _var_names[Particles::VAR_MAX]={
@@ -47,7 +47,7 @@ static const char* _var_names[Particles::VAR_MAX]={
"vars/height_speed_scale",
};
*/
-static const char* _rand_names[Particles::VAR_MAX]={
+static const char *_rand_names[Particles::VAR_MAX] = {
"rand/lifetime",
"rand/spread",
"rand/gravity",
@@ -64,7 +64,7 @@ static const char* _rand_names[Particles::VAR_MAX]={
"rand/height_speed_scale",
};
-static const Particles::Variable _var_indices[Particles::VAR_MAX]={
+static const Particles::Variable _var_indices[Particles::VAR_MAX] = {
Particles::VAR_LIFETIME,
Particles::VAR_SPREAD,
Particles::VAR_GRAVITY,
@@ -81,23 +81,20 @@ static const Particles::Variable _var_indices[Particles::VAR_MAX]={
Particles::VAR_HEIGHT_SPEED_SCALE,
};
-
-
AABB Particles::get_aabb() const {
- return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
+ return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
}
DVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
}
-
void Particles::set_amount(int p_amount) {
- ERR_FAIL_INDEX(p_amount,1024);
- amount=p_amount;
- VisualServer::get_singleton()->particles_set_amount(particles,p_amount);
+ ERR_FAIL_INDEX(p_amount, 1024);
+ amount = p_amount;
+ VisualServer::get_singleton()->particles_set_amount(particles, p_amount);
}
int Particles::get_amount() const {
@@ -106,8 +103,8 @@ int Particles::get_amount() const {
void Particles::set_emitting(bool p_emitting) {
- emitting=p_emitting;
- VisualServer::get_singleton()->particles_set_emitting(particles,p_emitting);
+ emitting = p_emitting;
+ VisualServer::get_singleton()->particles_set_emitting(particles, p_emitting);
setup_timer();
}
@@ -116,23 +113,21 @@ bool Particles::is_emitting() const {
return emitting;
}
-void Particles::set_visibility_aabb(const AABB& p_aabb) {
+void Particles::set_visibility_aabb(const AABB &p_aabb) {
- visibility_aabb=p_aabb;
- VisualServer::get_singleton()->particles_set_visibility_aabb(particles,p_aabb);
+ visibility_aabb = p_aabb;
+ VisualServer::get_singleton()->particles_set_visibility_aabb(particles, p_aabb);
update_gizmo();
-
}
AABB Particles::get_visibility_aabb() const {
return visibility_aabb;
}
-
-void Particles::set_emission_points(const DVector<Vector3>& p_points) {
+void Particles::set_emission_points(const DVector<Vector3> &p_points) {
using_points = p_points.size();
- VisualServer::get_singleton()->particles_set_emission_points(particles,p_points);
+ VisualServer::get_singleton()->particles_set_emission_points(particles, p_points);
}
DVector<Vector3> Particles::get_emission_points() const {
@@ -141,14 +136,12 @@ DVector<Vector3> Particles::get_emission_points() const {
return DVector<Vector3>();
return VisualServer::get_singleton()->particles_get_emission_points(particles);
-
}
-void Particles::set_emission_half_extents(const Vector3& p_half_extents) {
-
- emission_half_extents=p_half_extents;
- VisualServer::get_singleton()->particles_set_emission_half_extents(particles,p_half_extents);
+void Particles::set_emission_half_extents(const Vector3 &p_half_extents) {
+ emission_half_extents = p_half_extents;
+ VisualServer::get_singleton()->particles_set_emission_half_extents(particles, p_half_extents);
}
Vector3 Particles::get_emission_half_extents() const {
@@ -156,11 +149,10 @@ Vector3 Particles::get_emission_half_extents() const {
return emission_half_extents;
}
-void Particles::set_emission_base_velocity(const Vector3& p_base_velocity) {
-
- emission_base_velocity=p_base_velocity;
- VisualServer::get_singleton()->particles_set_emission_base_velocity(particles,p_base_velocity);
+void Particles::set_emission_base_velocity(const Vector3 &p_base_velocity) {
+ emission_base_velocity = p_base_velocity;
+ VisualServer::get_singleton()->particles_set_emission_base_velocity(particles, p_base_velocity);
}
Vector3 Particles::get_emission_base_velocity() const {
@@ -168,84 +160,76 @@ Vector3 Particles::get_emission_base_velocity() const {
return emission_base_velocity;
}
-void Particles::set_gravity_normal(const Vector3& p_normal) {
+void Particles::set_gravity_normal(const Vector3 &p_normal) {
- gravity_normal=p_normal;
- VisualServer::get_singleton()->particles_set_gravity_normal(particles,p_normal);
+ gravity_normal = p_normal;
+ VisualServer::get_singleton()->particles_set_gravity_normal(particles, p_normal);
}
Vector3 Particles::get_gravity_normal() const {
return gravity_normal;
-
}
-void Particles::set_variable(Variable p_variable,float p_value) {
+void Particles::set_variable(Variable p_variable, float p_value) {
- ERR_FAIL_INDEX(p_variable,VAR_MAX);
- var[p_variable]=p_value;
- VisualServer::get_singleton()->particles_set_variable(particles,(VS::ParticleVariable)p_variable,p_value);
- if (p_variable==VAR_SPREAD)
+ ERR_FAIL_INDEX(p_variable, VAR_MAX);
+ var[p_variable] = p_value;
+ VisualServer::get_singleton()->particles_set_variable(particles, (VS::ParticleVariable)p_variable, p_value);
+ if (p_variable == VAR_SPREAD)
update_gizmo();
}
float Particles::get_variable(Variable p_variable) const {
- ERR_FAIL_INDEX_V(p_variable,VAR_MAX,-1);
+ ERR_FAIL_INDEX_V(p_variable, VAR_MAX, -1);
return var[p_variable];
-
}
-void Particles::set_randomness(Variable p_variable,float p_randomness) {
-
- ERR_FAIL_INDEX(p_variable,VAR_MAX);
- var_random[p_variable]=p_randomness;
- VisualServer::get_singleton()->particles_set_randomness(particles,(VS::ParticleVariable)p_variable,p_randomness);
+void Particles::set_randomness(Variable p_variable, float p_randomness) {
+ ERR_FAIL_INDEX(p_variable, VAR_MAX);
+ var_random[p_variable] = p_randomness;
+ VisualServer::get_singleton()->particles_set_randomness(particles, (VS::ParticleVariable)p_variable, p_randomness);
}
float Particles::get_randomness(Variable p_variable) const {
- ERR_FAIL_INDEX_V(p_variable,VAR_MAX,-1);
+ ERR_FAIL_INDEX_V(p_variable, VAR_MAX, -1);
return var_random[p_variable];
-
}
void Particles::set_color_phase_pos(int p_phase, float p_pos) {
- ERR_FAIL_INDEX(p_phase,VS::MAX_PARTICLE_COLOR_PHASES);
- color_phase[p_phase].pos=p_pos;
- VisualServer::get_singleton()->particles_set_color_phase_pos(particles,p_phase,p_pos);
-
+ ERR_FAIL_INDEX(p_phase, VS::MAX_PARTICLE_COLOR_PHASES);
+ color_phase[p_phase].pos = p_pos;
+ VisualServer::get_singleton()->particles_set_color_phase_pos(particles, p_phase, p_pos);
}
float Particles::get_color_phase_pos(int p_phase) const {
- ERR_FAIL_INDEX_V(p_phase,VS::MAX_PARTICLE_COLOR_PHASES,-1);
+ ERR_FAIL_INDEX_V(p_phase, VS::MAX_PARTICLE_COLOR_PHASES, -1);
return color_phase[p_phase].pos;
}
-void Particles::set_color_phase_color(int p_phase, const Color& p_color) {
-
- ERR_FAIL_INDEX(p_phase,VS::MAX_PARTICLE_COLOR_PHASES);
- color_phase[p_phase].color=p_color;
- VisualServer::get_singleton()->particles_set_color_phase_color(particles,p_phase,p_color);
+void Particles::set_color_phase_color(int p_phase, const Color &p_color) {
+ ERR_FAIL_INDEX(p_phase, VS::MAX_PARTICLE_COLOR_PHASES);
+ color_phase[p_phase].color = p_color;
+ VisualServer::get_singleton()->particles_set_color_phase_color(particles, p_phase, p_color);
}
Color Particles::get_color_phase_color(int p_phase) const {
- ERR_FAIL_INDEX_V(p_phase,VS::MAX_PARTICLE_COLOR_PHASES,Color());
+ ERR_FAIL_INDEX_V(p_phase, VS::MAX_PARTICLE_COLOR_PHASES, Color());
return color_phase[p_phase].color;
-
}
-void Particles::set_material(const Ref<Material>& p_material) {
+void Particles::set_material(const Ref<Material> &p_material) {
- material=p_material;
- if(material.is_null()) {
- VisualServer::get_singleton()->particles_set_material(particles,RID());
+ material = p_material;
+ if (material.is_null()) {
+ VisualServer::get_singleton()->particles_set_material(particles, RID());
} else {
- VisualServer::get_singleton()->particles_set_material(particles,material->get_rid());
+ VisualServer::get_singleton()->particles_set_material(particles, material->get_rid());
}
-
}
void Particles::setup_timer() {
@@ -269,7 +253,6 @@ float Particles::get_emit_timeout() const {
return emit_timeout;
};
-
Ref<Material> Particles::get_material() const {
return material;
@@ -277,8 +260,8 @@ Ref<Material> Particles::get_material() const {
void Particles::set_height_from_velocity(bool p_enable) {
- height_from_velocity=p_enable;
- VisualServer::get_singleton()->particles_set_height_from_velocity(particles,height_from_velocity);
+ height_from_velocity = p_enable;
+ VisualServer::get_singleton()->particles_set_height_from_velocity(particles, height_from_velocity);
}
bool Particles::has_height_from_velocity() const {
@@ -288,11 +271,11 @@ bool Particles::has_height_from_velocity() const {
void Particles::set_color_phases(int p_phases) {
- color_phase_count=p_phases;
- VisualServer::get_singleton()->particles_set_color_phases(particles,p_phases);
+ color_phase_count = p_phases;
+ VisualServer::get_singleton()->particles_set_color_phases(particles, p_phases);
}
-int Particles::get_color_phases() const{
+int Particles::get_color_phases() const {
return color_phase_count;
}
@@ -304,53 +287,51 @@ bool Particles::_can_gizmo_scale() const {
void Particles::set_use_local_coordinates(bool p_use) {
- local_coordinates=p_use;
- VisualServer::get_singleton()->particles_set_use_local_coordinates(particles,local_coordinates);
+ local_coordinates = p_use;
+ VisualServer::get_singleton()->particles_set_use_local_coordinates(particles, local_coordinates);
}
-bool Particles::is_using_local_coordinates() const{
+bool Particles::is_using_local_coordinates() const {
return local_coordinates;
}
-
RES Particles::_get_gizmo_geometry() const {
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
+ Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.0,0.6,0.7,0.2) );
- mat->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
- mat->set_blend_mode( Material::BLEND_MODE_ADD );
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
+ Ref<FixedMaterial> mat(memnew(FixedMaterial));
+ mat->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.0, 0.6, 0.7, 0.2));
+ mat->set_parameter(FixedMaterial::PARAM_EMISSION, Color(0.5, 0.7, 0.8));
+ mat->set_blend_mode(Material::BLEND_MODE_ADD);
+ mat->set_flag(Material::FLAG_DOUBLE_SIDED, true);
+ // mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
surface_tool->set_material(mat);
- int sides=16;
- int sections=24;
+ int sides = 16;
+ int sections = 24;
-// float len=1;
- float deg=Math::deg2rad(var[VAR_SPREAD]*180);
- if (deg==180)
- deg=179.5;
+ // float len=1;
+ float deg = Math::deg2rad(var[VAR_SPREAD] * 180);
+ if (deg == 180)
+ deg = 179.5;
- Vector3 to=Vector3(0,0,-1);
+ Vector3 to = Vector3(0, 0, -1);
- for(int j=0;j<sections;j++) {
+ for (int j = 0; j < sections; j++) {
- Vector3 p1=Matrix3(Vector3(1,0,0),deg*j/sections).xform(to);
- Vector3 p2=Matrix3(Vector3(1,0,0),deg*(j+1)/sections).xform(to);
+ Vector3 p1 = Matrix3(Vector3(1, 0, 0), deg * j / sections).xform(to);
+ Vector3 p2 = Matrix3(Vector3(1, 0, 0), deg * (j + 1) / sections).xform(to);
- for(int i=0;i<sides;i++) {
+ for (int i = 0; i < sides; i++) {
- Vector3 p1r = Matrix3(Vector3(0,0,1),Math_PI*2*float(i)/sides).xform(p1);
- Vector3 p1s = Matrix3(Vector3(0,0,1),Math_PI*2*float(i+1)/sides).xform(p1);
- Vector3 p2s = Matrix3(Vector3(0,0,1),Math_PI*2*float(i+1)/sides).xform(p2);
- Vector3 p2r = Matrix3(Vector3(0,0,1),Math_PI*2*float(i)/sides).xform(p2);
+ Vector3 p1r = Matrix3(Vector3(0, 0, 1), Math_PI * 2 * float(i) / sides).xform(p1);
+ Vector3 p1s = Matrix3(Vector3(0, 0, 1), Math_PI * 2 * float(i + 1) / sides).xform(p1);
+ Vector3 p2s = Matrix3(Vector3(0, 0, 1), Math_PI * 2 * float(i + 1) / sides).xform(p2);
+ Vector3 p2r = Matrix3(Vector3(0, 0, 1), Math_PI * 2 * float(i) / sides).xform(p2);
surface_tool->add_normal(p1r.normalized());
surface_tool->add_vertex(p1r);
@@ -366,135 +347,129 @@ RES Particles::_get_gizmo_geometry() const {
surface_tool->add_normal(p2r.normalized());
surface_tool->add_vertex(p2r);
- if (j==sections-1) {
+ if (j == sections - 1) {
surface_tool->add_normal(p2r.normalized());
surface_tool->add_vertex(p2r);
surface_tool->add_normal(p2s.normalized());
surface_tool->add_vertex(p2s);
- surface_tool->add_normal(Vector3(0,0,1));
+ surface_tool->add_normal(Vector3(0, 0, 1));
surface_tool->add_vertex(Vector3());
}
}
}
-
Ref<Mesh> mesh = surface_tool->commit();
- Ref<FixedMaterial> mat_aabb( memnew( FixedMaterial ));
+ Ref<FixedMaterial> mat_aabb(memnew(FixedMaterial));
- mat_aabb->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.8,0.8,0.9,0.7) );
+ mat_aabb->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.8, 0.8, 0.9, 0.7));
mat_aabb->set_line_width(3);
- mat_aabb->set_flag( Material::FLAG_UNSHADED, true );
+ mat_aabb->set_flag(Material::FLAG_UNSHADED, true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat_aabb);
- for(int i=0;i<12;i++) {
+ for (int i = 0; i < 12; i++) {
- Vector3 f,t;
- visibility_aabb.get_edge(i,f,t);
+ Vector3 f, t;
+ visibility_aabb.get_edge(i, f, t);
surface_tool->add_vertex(f);
surface_tool->add_vertex(t);
}
return surface_tool->commit(mesh);
-
}
-
void Particles::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_amount","amount"),&Particles::set_amount);
- ObjectTypeDB::bind_method(_MD("get_amount"),&Particles::get_amount);
- ObjectTypeDB::bind_method(_MD("set_emitting","enabled"),&Particles::set_emitting);
- ObjectTypeDB::bind_method(_MD("is_emitting"),&Particles::is_emitting);
- ObjectTypeDB::bind_method(_MD("set_visibility_aabb","aabb"),&Particles::set_visibility_aabb);
- ObjectTypeDB::bind_method(_MD("get_visibility_aabb"),&Particles::get_visibility_aabb);
- ObjectTypeDB::bind_method(_MD("set_emission_half_extents","half_extents"),&Particles::set_emission_half_extents);
- ObjectTypeDB::bind_method(_MD("get_emission_half_extents"),&Particles::get_emission_half_extents);
- ObjectTypeDB::bind_method(_MD("set_emission_base_velocity","base_velocity"),&Particles::set_emission_base_velocity);
- ObjectTypeDB::bind_method(_MD("get_emission_base_velocity"),&Particles::get_emission_base_velocity);
- ObjectTypeDB::bind_method(_MD("set_emission_points","points"),&Particles::set_emission_points);
- ObjectTypeDB::bind_method(_MD("get_emission_points"),&Particles::get_emission_points);
- ObjectTypeDB::bind_method(_MD("set_gravity_normal","normal"),&Particles::set_gravity_normal);
- ObjectTypeDB::bind_method(_MD("get_gravity_normal"),&Particles::get_gravity_normal);
- ObjectTypeDB::bind_method(_MD("set_variable","variable","value"),&Particles::set_variable);
- ObjectTypeDB::bind_method(_MD("get_variable","variable"),&Particles::get_variable);
- ObjectTypeDB::bind_method(_MD("set_randomness","variable","randomness"),&Particles::set_randomness);
- ObjectTypeDB::bind_method(_MD("get_randomness","variable"),&Particles::get_randomness);
- ObjectTypeDB::bind_method(_MD("set_color_phase_pos","phase","pos"),&Particles::set_color_phase_pos);
- ObjectTypeDB::bind_method(_MD("get_color_phase_pos","phase"),&Particles::get_color_phase_pos);
- ObjectTypeDB::bind_method(_MD("set_color_phase_color","phase","color"),&Particles::set_color_phase_color);
- ObjectTypeDB::bind_method(_MD("get_color_phase_color","phase"),&Particles::get_color_phase_color);
- ObjectTypeDB::bind_method(_MD("set_material","material:Material"),&Particles::set_material);
- ObjectTypeDB::bind_method(_MD("get_material:Material"),&Particles::get_material);
- ObjectTypeDB::bind_method(_MD("set_emit_timeout","timeout"),&Particles::set_emit_timeout);
- ObjectTypeDB::bind_method(_MD("get_emit_timeout"),&Particles::get_emit_timeout);
- ObjectTypeDB::bind_method(_MD("set_height_from_velocity","enable"),&Particles::set_height_from_velocity);
- ObjectTypeDB::bind_method(_MD("has_height_from_velocity"),&Particles::has_height_from_velocity);
- ObjectTypeDB::bind_method(_MD("set_use_local_coordinates","enable"),&Particles::set_use_local_coordinates);
- ObjectTypeDB::bind_method(_MD("is_using_local_coordinates"),&Particles::is_using_local_coordinates);
-
- ObjectTypeDB::bind_method(_MD("set_color_phases","count"),&Particles::set_color_phases);
- ObjectTypeDB::bind_method(_MD("get_color_phases"),&Particles::get_color_phases);
-
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material" ), _SCS("set_material"), _SCS("get_material") );
+ ObjectTypeDB::bind_method(_MD("set_amount", "amount"), &Particles::set_amount);
+ ObjectTypeDB::bind_method(_MD("get_amount"), &Particles::get_amount);
+ ObjectTypeDB::bind_method(_MD("set_emitting", "enabled"), &Particles::set_emitting);
+ ObjectTypeDB::bind_method(_MD("is_emitting"), &Particles::is_emitting);
+ ObjectTypeDB::bind_method(_MD("set_visibility_aabb", "aabb"), &Particles::set_visibility_aabb);
+ ObjectTypeDB::bind_method(_MD("get_visibility_aabb"), &Particles::get_visibility_aabb);
+ ObjectTypeDB::bind_method(_MD("set_emission_half_extents", "half_extents"), &Particles::set_emission_half_extents);
+ ObjectTypeDB::bind_method(_MD("get_emission_half_extents"), &Particles::get_emission_half_extents);
+ ObjectTypeDB::bind_method(_MD("set_emission_base_velocity", "base_velocity"), &Particles::set_emission_base_velocity);
+ ObjectTypeDB::bind_method(_MD("get_emission_base_velocity"), &Particles::get_emission_base_velocity);
+ ObjectTypeDB::bind_method(_MD("set_emission_points", "points"), &Particles::set_emission_points);
+ ObjectTypeDB::bind_method(_MD("get_emission_points"), &Particles::get_emission_points);
+ ObjectTypeDB::bind_method(_MD("set_gravity_normal", "normal"), &Particles::set_gravity_normal);
+ ObjectTypeDB::bind_method(_MD("get_gravity_normal"), &Particles::get_gravity_normal);
+ ObjectTypeDB::bind_method(_MD("set_variable", "variable", "value"), &Particles::set_variable);
+ ObjectTypeDB::bind_method(_MD("get_variable", "variable"), &Particles::get_variable);
+ ObjectTypeDB::bind_method(_MD("set_randomness", "variable", "randomness"), &Particles::set_randomness);
+ ObjectTypeDB::bind_method(_MD("get_randomness", "variable"), &Particles::get_randomness);
+ ObjectTypeDB::bind_method(_MD("set_color_phase_pos", "phase", "pos"), &Particles::set_color_phase_pos);
+ ObjectTypeDB::bind_method(_MD("get_color_phase_pos", "phase"), &Particles::get_color_phase_pos);
+ ObjectTypeDB::bind_method(_MD("set_color_phase_color", "phase", "color"), &Particles::set_color_phase_color);
+ ObjectTypeDB::bind_method(_MD("get_color_phase_color", "phase"), &Particles::get_color_phase_color);
+ ObjectTypeDB::bind_method(_MD("set_material", "material:Material"), &Particles::set_material);
+ ObjectTypeDB::bind_method(_MD("get_material:Material"), &Particles::get_material);
+ ObjectTypeDB::bind_method(_MD("set_emit_timeout", "timeout"), &Particles::set_emit_timeout);
+ ObjectTypeDB::bind_method(_MD("get_emit_timeout"), &Particles::get_emit_timeout);
+ ObjectTypeDB::bind_method(_MD("set_height_from_velocity", "enable"), &Particles::set_height_from_velocity);
+ ObjectTypeDB::bind_method(_MD("has_height_from_velocity"), &Particles::has_height_from_velocity);
+ ObjectTypeDB::bind_method(_MD("set_use_local_coordinates", "enable"), &Particles::set_use_local_coordinates);
+ ObjectTypeDB::bind_method(_MD("is_using_local_coordinates"), &Particles::is_using_local_coordinates);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "amount", PROPERTY_HINT_RANGE, "1,1024,1" ), _SCS("set_amount"), _SCS("get_amount") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "emitting" ), _SCS("set_emitting"), _SCS("is_emitting") );
- ADD_PROPERTY( PropertyInfo( Variant::_AABB, "visibility" ), _SCS("set_visibility_aabb"), _SCS("get_visibility_aabb") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "emission_extents" ), _SCS("set_emission_half_extents"), _SCS("get_emission_half_extents") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "emission_base_velocity" ), _SCS("set_emission_base_velocity"), _SCS("get_emission_base_velocity") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "emission_points" ), _SCS("set_emission_points"), _SCS("get_emission_points") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "gravity_normal" ), _SCS("set_gravity_normal"), _SCS("get_gravity_normal") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "local_coords" ), _SCS("set_use_local_coordinates"), _SCS("is_using_local_coordinates") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "emit_timeout",PROPERTY_HINT_RANGE,"0,256,0.01"), _SCS("set_emit_timeout"), _SCS("get_emit_timeout") );
+ ObjectTypeDB::bind_method(_MD("set_color_phases", "count"), &Particles::set_color_phases);
+ ObjectTypeDB::bind_method(_MD("get_color_phases"), &Particles::get_color_phases);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), _SCS("set_material"), _SCS("get_material"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/lifetime", PROPERTY_HINT_RANGE,"0.1,60,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LIFETIME );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/spread", PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_SPREAD );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/gravity", PROPERTY_HINT_RANGE,"-48,48,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_GRAVITY );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/linear_vel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LINEAR_VELOCITY );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/angular_vel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_ANGULAR_VELOCITY );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/linear_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LINEAR_ACCELERATION );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/radial_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_DRAG );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/tan_accel", PROPERTY_HINT_RANGE,"-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_TANGENTIAL_ACCELERATION );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/damping", PROPERTY_HINT_RANGE,"0,128,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_DAMPING );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/initial_size", PROPERTY_HINT_RANGE,"0,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_INITIAL_SIZE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/final_size", PROPERTY_HINT_RANGE,"0,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_FINAL_SIZE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/initial_angle",PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_INITIAL_ANGLE );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "vars/height_from_velocity"), _SCS("set_height_from_velocity"), _SCS("has_height_from_velocity") );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/height",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_HEIGHT);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "vars/height_speed_scale",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_HEIGHT_SPEED_SCALE );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "amount", PROPERTY_HINT_RANGE, "1,1024,1"), _SCS("set_amount"), _SCS("get_amount"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), _SCS("set_emitting"), _SCS("is_emitting"));
+ ADD_PROPERTY(PropertyInfo(Variant::_AABB, "visibility"), _SCS("set_visibility_aabb"), _SCS("get_visibility_aabb"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_extents"), _SCS("set_emission_half_extents"), _SCS("get_emission_half_extents"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_base_velocity"), _SCS("set_emission_base_velocity"), _SCS("get_emission_base_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY, "emission_points"), _SCS("set_emission_points"), _SCS("get_emission_points"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "gravity_normal"), _SCS("set_gravity_normal"), _SCS("get_gravity_normal"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), _SCS("set_use_local_coordinates"), _SCS("is_using_local_coordinates"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "emit_timeout", PROPERTY_HINT_RANGE, "0,256,0.01"), _SCS("set_emit_timeout"), _SCS("get_emit_timeout"));
- for(int i=0;i<VAR_MAX;i++)
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, _rand_names[i], PROPERTY_HINT_RANGE,"-16.0,16.0,0.01"),_SCS("set_randomness"), _SCS("get_randomness"),_var_indices[i] );
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/lifetime", PROPERTY_HINT_RANGE, "0.1,60,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LIFETIME);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/spread", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_SPREAD);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/gravity", PROPERTY_HINT_RANGE, "-48,48,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_GRAVITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/linear_vel", PROPERTY_HINT_RANGE, "-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LINEAR_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/angular_vel", PROPERTY_HINT_RANGE, "-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_ANGULAR_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/linear_accel", PROPERTY_HINT_RANGE, "-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_LINEAR_ACCELERATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/radial_accel", PROPERTY_HINT_RANGE, "-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_DRAG);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/tan_accel", PROPERTY_HINT_RANGE, "-100,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_TANGENTIAL_ACCELERATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/damping", PROPERTY_HINT_RANGE, "0,128,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/initial_size", PROPERTY_HINT_RANGE, "0,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_INITIAL_SIZE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/final_size", PROPERTY_HINT_RANGE, "0,100,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_FINAL_SIZE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/initial_angle", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_INITIAL_ANGLE);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vars/height_from_velocity"), _SCS("set_height_from_velocity"), _SCS("has_height_from_velocity"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/height", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_HEIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "vars/height_speed_scale", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_variable"), _SCS("get_variable"), VAR_HEIGHT_SPEED_SCALE);
+ for (int i = 0; i < VAR_MAX; i++)
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, _rand_names[i], PROPERTY_HINT_RANGE, "-16.0,16.0,0.01"), _SCS("set_randomness"), _SCS("get_randomness"), _var_indices[i]);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "color_phases/count",PROPERTY_HINT_RANGE,"0,4,1"), _SCS("set_color_phases"), _SCS("get_color_phases"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "color_phases/count", PROPERTY_HINT_RANGE, "0,4,1"), _SCS("set_color_phases"), _SCS("get_color_phases"));
- for(int i=0;i<VS::MAX_PARTICLE_COLOR_PHASES;i++) {
- String phase="phase_"+itos(i)+"/";
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, phase+"pos", PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_color_phase_pos"),_SCS("get_color_phase_pos"),i );
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, phase+"color"),_SCS("set_color_phase_color"),_SCS("get_color_phase_color"),i );
+ for (int i = 0; i < VS::MAX_PARTICLE_COLOR_PHASES; i++) {
+ String phase = "phase_" + itos(i) + "/";
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, phase + "pos", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_color_phase_pos"), _SCS("get_color_phase_pos"), i);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, phase + "color"), _SCS("set_color_phase_color"), _SCS("get_color_phase_color"), i);
}
- BIND_CONSTANT( VAR_LIFETIME );
- BIND_CONSTANT( VAR_SPREAD );
- BIND_CONSTANT( VAR_GRAVITY );
- BIND_CONSTANT( VAR_LINEAR_VELOCITY );
- BIND_CONSTANT( VAR_ANGULAR_VELOCITY );
- BIND_CONSTANT( VAR_LINEAR_ACCELERATION );
- BIND_CONSTANT( VAR_DRAG );
- BIND_CONSTANT( VAR_TANGENTIAL_ACCELERATION );
- BIND_CONSTANT( VAR_INITIAL_SIZE );
- BIND_CONSTANT( VAR_FINAL_SIZE );
- BIND_CONSTANT( VAR_INITIAL_ANGLE );
- BIND_CONSTANT( VAR_HEIGHT );
- BIND_CONSTANT( VAR_HEIGHT_SPEED_SCALE );
- BIND_CONSTANT( VAR_MAX );
-
+ BIND_CONSTANT(VAR_LIFETIME);
+ BIND_CONSTANT(VAR_SPREAD);
+ BIND_CONSTANT(VAR_GRAVITY);
+ BIND_CONSTANT(VAR_LINEAR_VELOCITY);
+ BIND_CONSTANT(VAR_ANGULAR_VELOCITY);
+ BIND_CONSTANT(VAR_LINEAR_ACCELERATION);
+ BIND_CONSTANT(VAR_DRAG);
+ BIND_CONSTANT(VAR_TANGENTIAL_ACCELERATION);
+ BIND_CONSTANT(VAR_INITIAL_SIZE);
+ BIND_CONSTANT(VAR_FINAL_SIZE);
+ BIND_CONSTANT(VAR_INITIAL_ANGLE);
+ BIND_CONSTANT(VAR_HEIGHT);
+ BIND_CONSTANT(VAR_HEIGHT_SPEED_SCALE);
+ BIND_CONSTANT(VAR_MAX);
}
Particles::Particles() {
@@ -506,54 +481,52 @@ Particles::Particles() {
set_amount(64);
set_emitting(true);
- set_visibility_aabb(AABB( Vector3(-4,-4,-4), Vector3(8,8,8) ) );
+ set_visibility_aabb(AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8)));
- for (int i=0;i<VAR_MAX;i++) {
- set_randomness((Variable)i,0.0);
+ for (int i = 0; i < VAR_MAX; i++) {
+ set_randomness((Variable)i, 0.0);
}
- set_variable( VAR_LIFETIME, 5.0);
- set_variable( VAR_SPREAD, 0.2);
- set_variable( VAR_GRAVITY, 9.8);
- set_variable( VAR_LINEAR_VELOCITY, 0.2);
- set_variable( VAR_ANGULAR_VELOCITY, 0.0);
- set_variable( VAR_LINEAR_ACCELERATION, 0.0);
- set_variable( VAR_DRAG, 0.0);
- set_variable( VAR_TANGENTIAL_ACCELERATION, 0.0);
- set_variable( VAR_DAMPING, 0.0);
- set_variable( VAR_INITIAL_SIZE, 1.0);
- set_variable( VAR_FINAL_SIZE, 1.0);
- set_variable( VAR_INITIAL_ANGLE, 0.0);
- set_variable( VAR_HEIGHT, 1.0);
- set_variable( VAR_HEIGHT_SPEED_SCALE, 0.0);
+ set_variable(VAR_LIFETIME, 5.0);
+ set_variable(VAR_SPREAD, 0.2);
+ set_variable(VAR_GRAVITY, 9.8);
+ set_variable(VAR_LINEAR_VELOCITY, 0.2);
+ set_variable(VAR_ANGULAR_VELOCITY, 0.0);
+ set_variable(VAR_LINEAR_ACCELERATION, 0.0);
+ set_variable(VAR_DRAG, 0.0);
+ set_variable(VAR_TANGENTIAL_ACCELERATION, 0.0);
+ set_variable(VAR_DAMPING, 0.0);
+ set_variable(VAR_INITIAL_SIZE, 1.0);
+ set_variable(VAR_FINAL_SIZE, 1.0);
+ set_variable(VAR_INITIAL_ANGLE, 0.0);
+ set_variable(VAR_HEIGHT, 1.0);
+ set_variable(VAR_HEIGHT_SPEED_SCALE, 0.0);
- color_phase_count=0;
+ color_phase_count = 0;
- set_color_phase_pos(0,0.0);
- set_color_phase_pos(1,1.0);
- set_color_phase_pos(2,1.0);
- set_color_phase_pos(3,1.0);
+ set_color_phase_pos(0, 0.0);
+ set_color_phase_pos(1, 1.0);
+ set_color_phase_pos(2, 1.0);
+ set_color_phase_pos(3, 1.0);
- set_color_phase_color(0,Color(1,1,1));
- set_color_phase_color(1,Color(0,0,0));
- set_color_phase_color(2,Color(0,0,0));
- set_color_phase_color(3,Color(0,0,0));
+ set_color_phase_color(0, Color(1, 1, 1));
+ set_color_phase_color(1, Color(0, 0, 0));
+ set_color_phase_color(2, Color(0, 0, 0));
+ set_color_phase_color(3, Color(0, 0, 0));
- set_gravity_normal(Vector3(0,-1.0,0));
- set_emission_half_extents(Vector3(0.1,0.1,0.1));
+ set_gravity_normal(Vector3(0, -1.0, 0));
+ set_emission_half_extents(Vector3(0.1, 0.1, 0.1));
- height_from_velocity=false;
+ height_from_velocity = false;
Vector<Variant> pars;
pars.push_back(false);
timer->connect("timeout", this, "set_emitting", pars);
set_base(particles);
- local_coordinates=false;
+ local_coordinates = false;
}
-
Particles::~Particles() {
VisualServer::get_singleton()->free(particles);
}
-
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index 21e975138..a5d7d0be9 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -29,10 +29,10 @@
#ifndef VISUALINSTANCEPARTICLES_H
#define VISUALINSTANCEPARTICLES_H
+#include "rid.h"
#include "scene/3d/visual_instance.h"
-#include "scene/resources/material.h"
#include "scene/main/timer.h"
-#include "rid.h"
+#include "scene/resources/material.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -40,27 +40,26 @@
class Particles : public GeometryInstance {
public:
-
enum Variable {
- VAR_LIFETIME=VS::PARTICLE_LIFETIME,
- VAR_SPREAD=VS::PARTICLE_SPREAD,
- VAR_GRAVITY=VS::PARTICLE_GRAVITY,
- VAR_LINEAR_VELOCITY=VS::PARTICLE_LINEAR_VELOCITY,
- VAR_ANGULAR_VELOCITY=VS::PARTICLE_ANGULAR_VELOCITY,
- VAR_LINEAR_ACCELERATION=VS::PARTICLE_LINEAR_ACCELERATION,
- VAR_DRAG=VS::PARTICLE_RADIAL_ACCELERATION,
- VAR_TANGENTIAL_ACCELERATION=VS::PARTICLE_TANGENTIAL_ACCELERATION,
- VAR_DAMPING=VS::PARTICLE_DAMPING,
- VAR_INITIAL_SIZE=VS::PARTICLE_INITIAL_SIZE,
- VAR_FINAL_SIZE=VS::PARTICLE_FINAL_SIZE,
- VAR_INITIAL_ANGLE=VS::PARTICLE_INITIAL_ANGLE,
- VAR_HEIGHT=VS::PARTICLE_HEIGHT,
- VAR_HEIGHT_SPEED_SCALE=VS::PARTICLE_HEIGHT_SPEED_SCALE,
- VAR_MAX=VS::PARTICLE_VAR_MAX
+ VAR_LIFETIME = VS::PARTICLE_LIFETIME,
+ VAR_SPREAD = VS::PARTICLE_SPREAD,
+ VAR_GRAVITY = VS::PARTICLE_GRAVITY,
+ VAR_LINEAR_VELOCITY = VS::PARTICLE_LINEAR_VELOCITY,
+ VAR_ANGULAR_VELOCITY = VS::PARTICLE_ANGULAR_VELOCITY,
+ VAR_LINEAR_ACCELERATION = VS::PARTICLE_LINEAR_ACCELERATION,
+ VAR_DRAG = VS::PARTICLE_RADIAL_ACCELERATION,
+ VAR_TANGENTIAL_ACCELERATION = VS::PARTICLE_TANGENTIAL_ACCELERATION,
+ VAR_DAMPING = VS::PARTICLE_DAMPING,
+ VAR_INITIAL_SIZE = VS::PARTICLE_INITIAL_SIZE,
+ VAR_FINAL_SIZE = VS::PARTICLE_FINAL_SIZE,
+ VAR_INITIAL_ANGLE = VS::PARTICLE_INITIAL_ANGLE,
+ VAR_HEIGHT = VS::PARTICLE_HEIGHT,
+ VAR_HEIGHT_SPEED_SCALE = VS::PARTICLE_HEIGHT_SPEED_SCALE,
+ VAR_MAX = VS::PARTICLE_VAR_MAX
};
private:
- OBJ_TYPE( Particles, GeometryInstance );
+ OBJ_TYPE(Particles, GeometryInstance);
RID particles;
@@ -92,16 +91,13 @@ private:
Ref<Material> material;
- Timer* timer;
+ Timer *timer;
void setup_timer();
protected:
-
static void _bind_methods();
public:
-
-
AABB get_aabb() const;
DVector<Face3> get_faces(uint32_t p_usage_flags) const;
@@ -111,25 +107,25 @@ public:
void set_emitting(bool p_emitting);
bool is_emitting() const;
- void set_visibility_aabb(const AABB& p_aabb);
+ void set_visibility_aabb(const AABB &p_aabb);
AABB get_visibility_aabb() const;
- void set_emission_half_extents(const Vector3& p_half_extents);
+ void set_emission_half_extents(const Vector3 &p_half_extents);
Vector3 get_emission_half_extents() const;
- void set_emission_base_velocity(const Vector3& p_base_velocity);
+ void set_emission_base_velocity(const Vector3 &p_base_velocity);
Vector3 get_emission_base_velocity() const;
- void set_emission_points(const DVector<Vector3>& p_points);
+ void set_emission_points(const DVector<Vector3> &p_points);
DVector<Vector3> get_emission_points() const;
- void set_gravity_normal(const Vector3& p_normal);
+ void set_gravity_normal(const Vector3 &p_normal);
Vector3 get_gravity_normal() const;
- void set_variable(Variable p_variable,float p_value);
+ void set_variable(Variable p_variable, float p_value);
float get_variable(Variable p_variable) const;
- void set_randomness(Variable p_variable,float p_randomness);
+ void set_randomness(Variable p_variable, float p_randomness);
float get_randomness(Variable p_variable) const;
void set_color_phases(int p_phases);
@@ -138,13 +134,13 @@ public:
void set_color_phase_pos(int p_phase, float p_pos);
float get_color_phase_pos(int p_phase) const;
- void set_color_phase_color(int p_phase, const Color& p_color);
+ void set_color_phase_color(int p_phase, const Color &p_color);
Color get_color_phase_color(int p_phase) const;
void set_height_from_velocity(bool p_enable);
bool has_height_from_velocity() const;
- void set_material(const Ref<Material>& p_material);
+ void set_material(const Ref<Material> &p_material);
Ref<Material> get_material() const;
void set_emit_timeout(float p_timeout);
@@ -155,11 +151,9 @@ public:
void start_emitting(float p_time);
-
Particles();
~Particles();
-
};
-VARIANT_ENUM_CAST( Particles::Variable );
+VARIANT_ENUM_CAST(Particles::Variable);
#endif
diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp
index ea2678b2e..bb582f4bf 100644
--- a/scene/3d/path.cpp
+++ b/scene/3d/path.cpp
@@ -52,119 +52,108 @@ void Path::_notification(int p_what) {
void Path::_curve_changed() {
-
if (is_inside_tree() && get_tree()->is_editor_hint())
update_gizmo();
}
-
-void Path::set_curve(const Ref<Curve3D>& p_curve) {
+void Path::set_curve(const Ref<Curve3D> &p_curve) {
if (curve.is_valid()) {
- curve->disconnect("changed",this,"_curve_changed");
+ curve->disconnect("changed", this, "_curve_changed");
}
- curve=p_curve;
+ curve = p_curve;
if (curve.is_valid()) {
- curve->connect("changed",this,"_curve_changed");
+ curve->connect("changed", this, "_curve_changed");
}
_curve_changed();
-
}
-Ref<Curve3D> Path::get_curve() const{
+Ref<Curve3D> Path::get_curve() const {
return curve;
}
void Path::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_curve","curve:Curve3D"),&Path::set_curve);
- ObjectTypeDB::bind_method(_MD("get_curve:Curve3D","curve"),&Path::get_curve);
- ObjectTypeDB::bind_method(_MD("_curve_changed"),&Path::_curve_changed);
+ ObjectTypeDB::bind_method(_MD("set_curve", "curve:Curve3D"), &Path::set_curve);
+ ObjectTypeDB::bind_method(_MD("get_curve:Curve3D", "curve"), &Path::get_curve);
+ ObjectTypeDB::bind_method(_MD("_curve_changed"), &Path::_curve_changed);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), _SCS("set_curve"),_SCS("get_curve"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), _SCS("set_curve"), _SCS("get_curve"));
}
Path::Path() {
- set_curve(Ref<Curve3D>( memnew( Curve3D ))); //create one by default
+ set_curve(Ref<Curve3D>(memnew(Curve3D))); //create one by default
}
-
//////////////
-
void PathFollow::_update_transform() {
-
if (!path)
return;
- Ref<Curve3D> c =path->get_curve();
+ Ref<Curve3D> c = path->get_curve();
if (!c.is_valid())
return;
-
float o = offset;
if (loop)
- o=Math::fposmod(o,c->get_baked_length());
-
- Vector3 pos = c->interpolate_baked(o,cubic);
- Transform t=get_transform();
+ o = Math::fposmod(o, c->get_baked_length());
+ Vector3 pos = c->interpolate_baked(o, cubic);
+ Transform t = get_transform();
- if (rotation_mode!=ROTATION_NONE) {
+ if (rotation_mode != ROTATION_NONE) {
- Vector3 n = (c->interpolate_baked(o+lookahead,cubic)-pos).normalized();
+ Vector3 n = (c->interpolate_baked(o + lookahead, cubic) - pos).normalized();
- if (rotation_mode==ROTATION_Y) {
+ if (rotation_mode == ROTATION_Y) {
- n.y=0;
+ n.y = 0;
n.normalize();
}
- if (n.length()<CMP_EPSILON) {//nothing, use previous
- n=-t.get_basis().get_axis(2).normalized();
+ if (n.length() < CMP_EPSILON) { //nothing, use previous
+ n = -t.get_basis().get_axis(2).normalized();
}
+ Vector3 up = Vector3(0, 1, 0);
- Vector3 up = Vector3(0,1,0);
-
- if (rotation_mode==ROTATION_XYZ) {
+ if (rotation_mode == ROTATION_XYZ) {
float tilt = c->interpolate_baked_tilt(o);
- if (tilt!=0) {
+ if (tilt != 0) {
- Matrix3 rot(-n,tilt); //remember.. lookat will be znegative.. znegative!! we abide by opengl clan.
- up=rot.xform(up);
+ Matrix3 rot(-n, tilt); //remember.. lookat will be znegative.. znegative!! we abide by opengl clan.
+ up = rot.xform(up);
}
}
- t.set_look_at(pos,pos+n,up);
+ t.set_look_at(pos, pos + n, up);
} else {
- t.origin=pos;
+ t.origin = pos;
}
- t.origin+=t.basis.get_axis(0)*h_offset + t.basis.get_axis(1)*v_offset;
+ t.origin += t.basis.get_axis(0) * h_offset + t.basis.get_axis(1) * v_offset;
set_transform(t);
-
}
void PathFollow::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- Node *parent=get_parent();
+ Node *parent = get_parent();
if (parent) {
- path=parent->cast_to<Path>();
+ path = parent->cast_to<Path>();
if (path) {
_update_transform();
}
@@ -173,16 +162,14 @@ void PathFollow::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
- path=NULL;
+ path = NULL;
} break;
}
-
}
void PathFollow::set_cubic_interpolation(bool p_enable) {
- cubic=p_enable;
+ cubic = p_enable;
}
bool PathFollow::get_cubic_interpolation() const {
@@ -190,24 +177,23 @@ bool PathFollow::get_cubic_interpolation() const {
return cubic;
}
+bool PathFollow::_set(const StringName &p_name, const Variant &p_value) {
-bool PathFollow::_set(const StringName& p_name, const Variant& p_value) {
-
- if (p_name==SceneStringNames::get_singleton()->offset) {
+ if (p_name == SceneStringNames::get_singleton()->offset) {
set_offset(p_value);
- } else if (p_name==SceneStringNames::get_singleton()->unit_offset) {
+ } else if (p_name == SceneStringNames::get_singleton()->unit_offset) {
set_unit_offset(p_value);
- } else if (p_name==SceneStringNames::get_singleton()->rotation_mode) {
+ } else if (p_name == SceneStringNames::get_singleton()->rotation_mode) {
set_rotation_mode(RotationMode(p_value.operator int()));
- } else if (p_name==SceneStringNames::get_singleton()->v_offset) {
+ } else if (p_name == SceneStringNames::get_singleton()->v_offset) {
set_v_offset(p_value);
- } else if (p_name==SceneStringNames::get_singleton()->h_offset) {
+ } else if (p_name == SceneStringNames::get_singleton()->h_offset) {
set_h_offset(p_value);
- } else if (String(p_name)=="cubic_interp") {
+ } else if (String(p_name) == "cubic_interp") {
set_cubic_interpolation(p_value);
- } else if (String(p_name)=="loop") {
+ } else if (String(p_name) == "loop") {
set_loop(p_value);
- } else if (String(p_name)=="lookahead") {
+ } else if (String(p_name) == "lookahead") {
set_lookahead(p_value);
} else
return false;
@@ -215,92 +201,87 @@ bool PathFollow::_set(const StringName& p_name, const Variant& p_value) {
return true;
}
-bool PathFollow::_get(const StringName& p_name,Variant &r_ret) const{
+bool PathFollow::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name==SceneStringNames::get_singleton()->offset) {
- r_ret=get_offset();
- } else if (p_name==SceneStringNames::get_singleton()->unit_offset) {
- r_ret=get_unit_offset();
- } else if (p_name==SceneStringNames::get_singleton()->rotation_mode) {
- r_ret=get_rotation_mode();
- } else if (p_name==SceneStringNames::get_singleton()->v_offset) {
- r_ret=get_v_offset();
- } else if (p_name==SceneStringNames::get_singleton()->h_offset) {
- r_ret=get_h_offset();
- } else if (String(p_name)=="cubic_interp") {
- r_ret=cubic;
- } else if (String(p_name)=="loop") {
- r_ret=loop;
- } else if (String(p_name)=="lookahead") {
- r_ret=lookahead;
+ if (p_name == SceneStringNames::get_singleton()->offset) {
+ r_ret = get_offset();
+ } else if (p_name == SceneStringNames::get_singleton()->unit_offset) {
+ r_ret = get_unit_offset();
+ } else if (p_name == SceneStringNames::get_singleton()->rotation_mode) {
+ r_ret = get_rotation_mode();
+ } else if (p_name == SceneStringNames::get_singleton()->v_offset) {
+ r_ret = get_v_offset();
+ } else if (p_name == SceneStringNames::get_singleton()->h_offset) {
+ r_ret = get_h_offset();
+ } else if (String(p_name) == "cubic_interp") {
+ r_ret = cubic;
+ } else if (String(p_name) == "loop") {
+ r_ret = loop;
+ } else if (String(p_name) == "lookahead") {
+ r_ret = lookahead;
} else
return false;
return true;
-
}
-void PathFollow::_get_property_list( List<PropertyInfo> *p_list) const{
+void PathFollow::_get_property_list(List<PropertyInfo> *p_list) const {
- float max=10000;
+ float max = 10000;
if (path && path->get_curve().is_valid())
- max=path->get_curve()->get_baked_length();
- p_list->push_back( PropertyInfo( Variant::REAL, "offset", PROPERTY_HINT_RANGE,"0,"+rtos(max)+",0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE,"0,1,0.0001",PROPERTY_USAGE_EDITOR));
- p_list->push_back( PropertyInfo( Variant::REAL, "h_offset") );
- p_list->push_back( PropertyInfo( Variant::REAL, "v_offset") );
- p_list->push_back( PropertyInfo( Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM,"None,Y,XY,XYZ"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "cubic_interp"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "loop"));
- p_list->push_back( PropertyInfo( Variant::REAL, "lookahead",PROPERTY_HINT_RANGE,"0.001,1024.0,0.001"));
+ max = path->get_curve()->get_baked_length();
+ p_list->push_back(PropertyInfo(Variant::REAL, "offset", PROPERTY_HINT_RANGE, "0," + rtos(max) + ",0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE, "0,1,0.0001", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::REAL, "h_offset"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "v_offset"));
+ p_list->push_back(PropertyInfo(Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM, "None,Y,XY,XYZ"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "cubic_interp"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "loop"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "lookahead", PROPERTY_HINT_RANGE, "0.001,1024.0,0.001"));
}
-
void PathFollow::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&PathFollow::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&PathFollow::get_offset);
-
- ObjectTypeDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow::set_h_offset);
- ObjectTypeDB::bind_method(_MD("get_h_offset"),&PathFollow::get_h_offset);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &PathFollow::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &PathFollow::get_offset);
- ObjectTypeDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow::set_v_offset);
- ObjectTypeDB::bind_method(_MD("get_v_offset"),&PathFollow::get_v_offset);
+ ObjectTypeDB::bind_method(_MD("set_h_offset", "h_offset"), &PathFollow::set_h_offset);
+ ObjectTypeDB::bind_method(_MD("get_h_offset"), &PathFollow::get_h_offset);
- ObjectTypeDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow::set_unit_offset);
- ObjectTypeDB::bind_method(_MD("get_unit_offset"),&PathFollow::get_unit_offset);
+ ObjectTypeDB::bind_method(_MD("set_v_offset", "v_offset"), &PathFollow::set_v_offset);
+ ObjectTypeDB::bind_method(_MD("get_v_offset"), &PathFollow::get_v_offset);
- ObjectTypeDB::bind_method(_MD("set_rotation_mode","rotation_mode"),&PathFollow::set_rotation_mode);
- ObjectTypeDB::bind_method(_MD("get_rotation_mode"),&PathFollow::get_rotation_mode);
+ ObjectTypeDB::bind_method(_MD("set_unit_offset", "unit_offset"), &PathFollow::set_unit_offset);
+ ObjectTypeDB::bind_method(_MD("get_unit_offset"), &PathFollow::get_unit_offset);
- ObjectTypeDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow::set_cubic_interpolation);
- ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow::get_cubic_interpolation);
+ ObjectTypeDB::bind_method(_MD("set_rotation_mode", "rotation_mode"), &PathFollow::set_rotation_mode);
+ ObjectTypeDB::bind_method(_MD("get_rotation_mode"), &PathFollow::get_rotation_mode);
- ObjectTypeDB::bind_method(_MD("set_loop","loop"),&PathFollow::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&PathFollow::has_loop);
+ ObjectTypeDB::bind_method(_MD("set_cubic_interpolation", "enable"), &PathFollow::set_cubic_interpolation);
+ ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"), &PathFollow::get_cubic_interpolation);
- BIND_CONSTANT( ROTATION_NONE );
- BIND_CONSTANT( ROTATION_Y );
- BIND_CONSTANT( ROTATION_XY );
- BIND_CONSTANT( ROTATION_XYZ );
+ ObjectTypeDB::bind_method(_MD("set_loop", "loop"), &PathFollow::set_loop);
+ ObjectTypeDB::bind_method(_MD("has_loop"), &PathFollow::has_loop);
+ BIND_CONSTANT(ROTATION_NONE);
+ BIND_CONSTANT(ROTATION_Y);
+ BIND_CONSTANT(ROTATION_XY);
+ BIND_CONSTANT(ROTATION_XYZ);
}
void PathFollow::set_offset(float p_offset) {
- offset=p_offset;
+ offset = p_offset;
if (path)
_update_transform();
_change_notify("offset");
_change_notify("unit_offset");
-
}
void PathFollow::set_h_offset(float p_h_offset) {
- h_offset=p_h_offset;
+ h_offset = p_h_offset;
if (path)
_update_transform();
-
}
float PathFollow::get_h_offset() const {
@@ -310,10 +291,9 @@ float PathFollow::get_h_offset() const {
void PathFollow::set_v_offset(float p_v_offset) {
- v_offset=p_v_offset;
+ v_offset = p_v_offset;
if (path)
_update_transform();
-
}
float PathFollow::get_v_offset() const {
@@ -321,8 +301,7 @@ float PathFollow::get_v_offset() const {
return v_offset;
}
-
-float PathFollow::get_offset() const{
+float PathFollow::get_offset() const {
return offset;
}
@@ -330,32 +309,30 @@ float PathFollow::get_offset() const{
void PathFollow::set_unit_offset(float p_unit_offset) {
if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
- set_offset(p_unit_offset*path->get_curve()->get_baked_length());
-
+ set_offset(p_unit_offset * path->get_curve()->get_baked_length());
}
-float PathFollow::get_unit_offset() const{
+float PathFollow::get_unit_offset() const {
if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length())
- return get_offset()/path->get_curve()->get_baked_length();
+ return get_offset() / path->get_curve()->get_baked_length();
else
return 0;
}
void PathFollow::set_lookahead(float p_lookahead) {
- lookahead=p_lookahead;
-
+ lookahead = p_lookahead;
}
-float PathFollow::get_lookahead() const{
+float PathFollow::get_lookahead() const {
return lookahead;
}
void PathFollow::set_rotation_mode(RotationMode p_rotation_mode) {
- rotation_mode=p_rotation_mode;
+ rotation_mode = p_rotation_mode;
_update_transform();
}
@@ -366,23 +343,22 @@ PathFollow::RotationMode PathFollow::get_rotation_mode() const {
void PathFollow::set_loop(bool p_loop) {
- loop=p_loop;
+ loop = p_loop;
}
-bool PathFollow::has_loop() const{
+bool PathFollow::has_loop() const {
return loop;
}
-
PathFollow::PathFollow() {
- offset=0;
- h_offset=0;
- v_offset=0;
- path=NULL;
- rotation_mode=ROTATION_XYZ;
- cubic=true;
- loop=true;
- lookahead=0.1;
+ offset = 0;
+ h_offset = 0;
+ v_offset = 0;
+ path = NULL;
+ rotation_mode = ROTATION_XYZ;
+ cubic = true;
+ loop = true;
+ lookahead = 0.1;
}
diff --git a/scene/3d/path.h b/scene/3d/path.h
index 173ac50aa..e7eee6b00 100644
--- a/scene/3d/path.h
+++ b/scene/3d/path.h
@@ -29,36 +29,33 @@
#ifndef PATH_H
#define PATH_H
-#include "scene/resources/curve.h"
#include "scene/3d/spatial.h"
+#include "scene/resources/curve.h"
class Path : public Spatial {
- OBJ_TYPE( Path, Spatial );
+ OBJ_TYPE(Path, Spatial);
Ref<Curve3D> curve;
void _curve_changed();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_curve(const Ref<Curve3D>& p_curve);
+public:
+ void set_curve(const Ref<Curve3D> &p_curve);
Ref<Curve3D> get_curve() const;
-
Path();
};
class PathFollow : public Spatial {
- OBJ_TYPE(PathFollow,Spatial);
-public:
+ OBJ_TYPE(PathFollow, Spatial);
+public:
enum RotationMode {
ROTATION_NONE,
@@ -79,17 +76,15 @@ private:
void _update_transform();
-
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_offset(float p_offset);
float get_offset() const;
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index d68e58d9b..d1cec1d31 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -31,7 +31,7 @@
void PhysicsBody::_notification(int p_what) {
-/*
+ /*
switch(p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -57,11 +57,10 @@ float PhysicsBody::get_inverse_mass() const {
return 0;
}
-
void PhysicsBody::set_layer_mask(uint32_t p_mask) {
- layer_mask=p_mask;
- PhysicsServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask);
+ layer_mask = p_mask;
+ PhysicsServer::get_singleton()->body_set_layer_mask(get_rid(), p_mask);
}
uint32_t PhysicsBody::get_layer_mask() const {
@@ -71,8 +70,8 @@ uint32_t PhysicsBody::get_layer_mask() const {
void PhysicsBody::set_collision_mask(uint32_t p_mask) {
- collision_mask=p_mask;
- PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(),p_mask);
+ collision_mask = p_mask;
+ PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), p_mask);
}
uint32_t PhysicsBody::get_collision_mask() const {
@@ -84,36 +83,33 @@ void PhysicsBody::set_collision_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_collision_mask();
if (p_value)
- mask|=1<<p_bit;
+ mask |= 1 << p_bit;
else
- mask&=~(1<<p_bit);
+ mask &= ~(1 << p_bit);
set_collision_mask(mask);
-
}
-bool PhysicsBody::get_collision_mask_bit(int p_bit) const{
+bool PhysicsBody::get_collision_mask_bit(int p_bit) const {
- return get_collision_mask()&(1<<p_bit);
+ return get_collision_mask() & (1 << p_bit);
}
-
void PhysicsBody::set_layer_mask_bit(int p_bit, bool p_value) {
uint32_t mask = get_layer_mask();
if (p_value)
- mask|=1<<p_bit;
+ mask |= 1 << p_bit;
else
- mask&=~(1<<p_bit);
+ mask &= ~(1 << p_bit);
set_layer_mask(mask);
-
}
-bool PhysicsBody::get_layer_mask_bit(int p_bit) const{
+bool PhysicsBody::get_layer_mask_bit(int p_bit) const {
- return get_layer_mask()&(1<<p_bit);
+ return get_layer_mask() & (1 << p_bit);
}
-void PhysicsBody::add_collision_exception_with(Node* p_node) {
+void PhysicsBody::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
PhysicsBody *physics_body = p_node->cast_to<PhysicsBody>();
@@ -121,11 +117,10 @@ void PhysicsBody::add_collision_exception_with(Node* p_node) {
ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
}
ERR_FAIL_COND(!physics_body);
- PhysicsServer::get_singleton()->body_add_collision_exception(get_rid(),physics_body->get_rid());
-
+ PhysicsServer::get_singleton()->body_add_collision_exception(get_rid(), physics_body->get_rid());
}
-void PhysicsBody::remove_collision_exception_with(Node* p_node) {
+void PhysicsBody::remove_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
PhysicsBody *physics_body = p_node->cast_to<PhysicsBody>();
@@ -133,7 +128,7 @@ void PhysicsBody::remove_collision_exception_with(Node* p_node) {
ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
}
ERR_FAIL_COND(!physics_body);
- PhysicsServer::get_singleton()->body_remove_collision_exception(get_rid(),physics_body->get_rid());
+ PhysicsServer::get_singleton()->body_remove_collision_exception(get_rid(), physics_body->get_rid());
}
void PhysicsBody::_set_layers(uint32_t p_mask) {
@@ -141,80 +136,73 @@ void PhysicsBody::_set_layers(uint32_t p_mask) {
set_collision_mask(p_mask);
}
-uint32_t PhysicsBody::_get_layers() const{
+uint32_t PhysicsBody::_get_layers() const {
return get_layer_mask();
}
void PhysicsBody::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask", "mask"), &PhysicsBody::set_layer_mask);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask"), &PhysicsBody::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody::set_collision_mask);
- ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody::get_collision_mask);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask", "mask"), &PhysicsBody::set_collision_mask);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask"), &PhysicsBody::get_collision_mask);
- ObjectTypeDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody::set_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody::get_collision_mask_bit);
+ ObjectTypeDB::bind_method(_MD("set_collision_mask_bit", "bit", "value"), &PhysicsBody::set_collision_mask_bit);
+ ObjectTypeDB::bind_method(_MD("get_collision_mask_bit", "bit"), &PhysicsBody::get_collision_mask_bit);
- ObjectTypeDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody::set_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody::get_layer_mask_bit);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask_bit", "bit", "value"), &PhysicsBody::set_layer_mask_bit);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask_bit", "bit"), &PhysicsBody::get_layer_mask_bit);
- ObjectTypeDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody::_set_layers);
- ObjectTypeDB::bind_method(_MD("_get_layers"),&PhysicsBody::_get_layers);
+ ObjectTypeDB::bind_method(_MD("_set_layers", "mask"), &PhysicsBody::_set_layers);
+ ObjectTypeDB::bind_method(_MD("_get_layers"), &PhysicsBody::_get_layers);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_ALL_FLAGS, "", 0), _SCS("_set_layers"), _SCS("_get_layers")); //for backwards compat
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision/layers", PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collision/mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_collision_mask"), _SCS("get_collision_mask"));
}
+PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode)
+ : CollisionObject(PhysicsServer::get_singleton()->body_create(p_mode), false) {
-PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) : CollisionObject( PhysicsServer::get_singleton()->body_create(p_mode), false) {
-
- layer_mask=1;
- collision_mask=1;
-
+ layer_mask = 1;
+ collision_mask = 1;
}
+void StaticBody::set_friction(real_t p_friction) {
-void StaticBody::set_friction(real_t p_friction){
-
- ERR_FAIL_COND(p_friction<0 || p_friction>1);
-
- friction=p_friction;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_FRICTION,friction);
+ ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
+ friction = p_friction;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, friction);
}
-real_t StaticBody::get_friction() const{
+real_t StaticBody::get_friction() const {
return friction;
}
-void StaticBody::set_bounce(real_t p_bounce){
+void StaticBody::set_bounce(real_t p_bounce) {
- ERR_FAIL_COND(p_bounce<0 || p_bounce>1);
-
- bounce=p_bounce;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_BOUNCE,bounce);
+ ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
+ bounce = p_bounce;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, bounce);
}
-real_t StaticBody::get_bounce() const{
+real_t StaticBody::get_bounce() const {
return bounce;
}
+void StaticBody::set_constant_linear_velocity(const Vector3 &p_vel) {
-
-void StaticBody::set_constant_linear_velocity(const Vector3& p_vel) {
-
- constant_linear_velocity=p_vel;
- PhysicsServer::get_singleton()->body_set_state(get_rid(),PhysicsServer::BODY_STATE_LINEAR_VELOCITY,constant_linear_velocity);
-
+ constant_linear_velocity = p_vel;
+ PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_LINEAR_VELOCITY, constant_linear_velocity);
}
-void StaticBody::set_constant_angular_velocity(const Vector3& p_vel) {
+void StaticBody::set_constant_angular_velocity(const Vector3 &p_vel) {
- constant_angular_velocity=p_vel;
- PhysicsServer::get_singleton()->body_set_state(get_rid(),PhysicsServer::BODY_STATE_ANGULAR_VELOCITY,constant_angular_velocity);
+ constant_angular_velocity = p_vel;
+ PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_ANGULAR_VELOCITY, constant_angular_velocity);
}
Vector3 StaticBody::get_constant_linear_velocity() const {
@@ -226,69 +214,61 @@ Vector3 StaticBody::get_constant_angular_velocity() const {
return constant_angular_velocity;
}
-
-
void StaticBody::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_constant_linear_velocity","vel"),&StaticBody::set_constant_linear_velocity);
- ObjectTypeDB::bind_method(_MD("set_constant_angular_velocity","vel"),&StaticBody::set_constant_angular_velocity);
- ObjectTypeDB::bind_method(_MD("get_constant_linear_velocity"),&StaticBody::get_constant_linear_velocity);
- ObjectTypeDB::bind_method(_MD("get_constant_angular_velocity"),&StaticBody::get_constant_angular_velocity);
+ ObjectTypeDB::bind_method(_MD("set_constant_linear_velocity", "vel"), &StaticBody::set_constant_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("set_constant_angular_velocity", "vel"), &StaticBody::set_constant_angular_velocity);
+ ObjectTypeDB::bind_method(_MD("get_constant_linear_velocity"), &StaticBody::get_constant_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("get_constant_angular_velocity"), &StaticBody::get_constant_angular_velocity);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&StaticBody::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&StaticBody::get_friction);
+ ObjectTypeDB::bind_method(_MD("set_friction", "friction"), &StaticBody::set_friction);
+ ObjectTypeDB::bind_method(_MD("get_friction"), &StaticBody::get_friction);
- ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&StaticBody::set_bounce);
- ObjectTypeDB::bind_method(_MD("get_bounce"),&StaticBody::get_bounce);
+ ObjectTypeDB::bind_method(_MD("set_bounce", "bounce"), &StaticBody::set_bounce);
+ ObjectTypeDB::bind_method(_MD("get_bounce"), &StaticBody::get_bounce);
- ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody"),&PhysicsBody::add_collision_exception_with);
- ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody"),&PhysicsBody::remove_collision_exception_with);
+ ObjectTypeDB::bind_method(_MD("add_collision_exception_with", "body:PhysicsBody"), &PhysicsBody::add_collision_exception_with);
+ ObjectTypeDB::bind_method(_MD("remove_collision_exception_with", "body:PhysicsBody"), &PhysicsBody::remove_collision_exception_with);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_friction"), _SCS("get_friction"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_bounce"), _SCS("get_bounce"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"constant_linear_velocity"),_SCS("set_constant_linear_velocity"),_SCS("get_constant_linear_velocity"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"constant_angular_velocity"),_SCS("set_constant_angular_velocity"),_SCS("get_constant_angular_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_linear_velocity"), _SCS("set_constant_linear_velocity"), _SCS("get_constant_linear_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity"), _SCS("set_constant_angular_velocity"), _SCS("get_constant_angular_velocity"));
}
-StaticBody::StaticBody() : PhysicsBody(PhysicsServer::BODY_MODE_STATIC) {
+StaticBody::StaticBody()
+ : PhysicsBody(PhysicsServer::BODY_MODE_STATIC) {
- bounce=0;
- friction=1;
+ bounce = 0;
+ friction = 1;
}
StaticBody::~StaticBody() {
-
-
}
-
-
-
void RigidBody::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(p_id);
+ Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(E->get().in_tree);
- E->get().in_tree=true;
+ E->get().in_tree = true;
- contact_monitor->locked=true;
+ contact_monitor->locked = true;
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_enter, node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_enter_shape, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
}
- contact_monitor->locked=false;
-
-
+ contact_monitor->locked = false;
}
void RigidBody::_body_exit_tree(ObjectID p_id) {
@@ -296,58 +276,55 @@ void RigidBody::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
- Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(p_id);
+ Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(p_id);
ERR_FAIL_COND(!E);
ERR_FAIL_COND(!E->get().in_tree);
- E->get().in_tree=false;
+ E->get().in_tree = false;
- contact_monitor->locked=true;
+ contact_monitor->locked = true;
- emit_signal(SceneStringNames::get_singleton()->body_exit,node);
+ emit_signal(SceneStringNames::get_singleton()->body_exit, node);
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,p_id,node,E->get().shapes[i].body_shape,E->get().shapes[i].local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, p_id, node, E->get().shapes[i].body_shape, E->get().shapes[i].local_shape);
}
- contact_monitor->locked=false;
-
+ contact_monitor->locked = false;
}
-void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,int p_local_shape) {
+void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) {
- bool body_in = p_status==1;
- ObjectID objid=p_instance;
+ bool body_in = p_status == 1;
+ ObjectID objid = p_instance;
Object *obj = ObjectDB::get_instance(objid);
Node *node = obj ? obj->cast_to<Node>() : NULL;
- Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(objid);
+ Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid);
ERR_FAIL_COND(!body_in && !E);
if (body_in) {
if (!E) {
- E = contact_monitor->body_map.insert(objid,BodyState());
+ E = contact_monitor->body_map.insert(objid, BodyState());
//E->get().rc=0;
- E->get().in_tree=node && node->is_inside_tree();
+ E->get().in_tree = node && node->is_inside_tree();
if (node) {
- node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid));
- node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
+ node->connect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter,node);
+ emit_signal(SceneStringNames::get_singleton()->body_enter, node);
}
}
-
}
//E->get().rc++;
if (node)
- E->get().shapes.insert(ShapePair(p_body_shape,p_local_shape));
-
+ E->get().shapes.insert(ShapePair(p_body_shape, p_local_shape));
if (E->get().in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_enter_shape, objid, node, p_body_shape, p_local_shape);
}
} else {
@@ -355,31 +332,27 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
//E->get().rc--;
if (node)
- E->get().shapes.erase(ShapePair(p_body_shape,p_local_shape));
+ E->get().shapes.erase(ShapePair(p_body_shape, p_local_shape));
bool in_tree = E->get().in_tree;
if (E->get().shapes.empty()) {
if (node) {
- node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree);
- node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree);
+ node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree);
+ node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (in_tree)
- emit_signal(SceneStringNames::get_singleton()->body_exit,obj);
-
+ emit_signal(SceneStringNames::get_singleton()->body_exit, obj);
}
contact_monitor->body_map.erase(E);
}
if (node && in_tree) {
- emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_local_shape);
+ emit_signal(SceneStringNames::get_singleton()->body_exit_shape, objid, obj, p_body_shape, p_local_shape);
}
-
}
-
}
-
struct _RigidBodyInOut {
ObjectID id;
@@ -389,308 +362,289 @@ struct _RigidBodyInOut {
void RigidBody::_direct_state_changed(Object *p_state) {
- //eh.. fuck
+//eh.. fuck
#ifdef DEBUG_ENABLED
- state=p_state->cast_to<PhysicsDirectBodyState>();
+ state = p_state->cast_to<PhysicsDirectBodyState>();
#else
- state=(PhysicsDirectBodyState*)p_state; //trust it
+ state = (PhysicsDirectBodyState *)p_state; //trust it
#endif
set_ignore_transform_notification(true);
set_global_transform(state->get_transform());
- linear_velocity=state->get_linear_velocity();
- angular_velocity=state->get_angular_velocity();
- if(sleeping!=state->is_sleeping()) {
- sleeping=state->is_sleeping();
+ linear_velocity = state->get_linear_velocity();
+ angular_velocity = state->get_angular_velocity();
+ if (sleeping != state->is_sleeping()) {
+ sleeping = state->is_sleeping();
emit_signal(SceneStringNames::get_singleton()->sleeping_state_changed);
}
if (get_script_instance())
- get_script_instance()->call("_integrate_forces",state);
+ get_script_instance()->call("_integrate_forces", state);
set_ignore_transform_notification(false);
if (contact_monitor) {
- contact_monitor->locked=true;
+ contact_monitor->locked = true;
//untag all
- int rc=0;
- for( Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
+ int rc = 0;
+ for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
- E->get().shapes[i].tagged=false;
+ E->get().shapes[i].tagged = false;
rc++;
}
}
- _RigidBodyInOut *toadd=(_RigidBodyInOut*)alloca(state->get_contact_count()*sizeof(_RigidBodyInOut));
- int toadd_count=0;//state->get_contact_count();
- RigidBody_RemoveAction *toremove=(RigidBody_RemoveAction*)alloca(rc*sizeof(RigidBody_RemoveAction));
- int toremove_count=0;
+ _RigidBodyInOut *toadd = (_RigidBodyInOut *)alloca(state->get_contact_count() * sizeof(_RigidBodyInOut));
+ int toadd_count = 0; //state->get_contact_count();
+ RigidBody_RemoveAction *toremove = (RigidBody_RemoveAction *)alloca(rc * sizeof(RigidBody_RemoveAction));
+ int toremove_count = 0;
//put the ones to add
- for(int i=0;i<state->get_contact_count();i++) {
+ for (int i = 0; i < state->get_contact_count(); i++) {
ObjectID obj = state->get_contact_collider_id(i);
int local_shape = state->get_contact_local_shape(i);
int shape = state->get_contact_collider_shape(i);
-// bool found=false;
+ // bool found=false;
- Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.find(obj);
+ Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(obj);
if (!E) {
- toadd[toadd_count].local_shape=local_shape;
- toadd[toadd_count].id=obj;
- toadd[toadd_count].shape=shape;
+ toadd[toadd_count].local_shape = local_shape;
+ toadd[toadd_count].id = obj;
+ toadd[toadd_count].shape = shape;
toadd_count++;
continue;
}
- ShapePair sp( shape,local_shape );
+ ShapePair sp(shape, local_shape);
int idx = E->get().shapes.find(sp);
- if (idx==-1) {
+ if (idx == -1) {
- toadd[toadd_count].local_shape=local_shape;
- toadd[toadd_count].id=obj;
- toadd[toadd_count].shape=shape;
+ toadd[toadd_count].local_shape = local_shape;
+ toadd[toadd_count].id = obj;
+ toadd[toadd_count].shape = shape;
toadd_count++;
continue;
}
- E->get().shapes[idx].tagged=true;
+ E->get().shapes[idx].tagged = true;
}
//put the ones to remove
- for( Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
+ for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
- for(int i=0;i<E->get().shapes.size();i++) {
+ for (int i = 0; i < E->get().shapes.size(); i++) {
if (!E->get().shapes[i].tagged) {
- toremove[toremove_count].body_id=E->key();
- toremove[toremove_count].pair=E->get().shapes[i];
+ toremove[toremove_count].body_id = E->key();
+ toremove[toremove_count].pair = E->get().shapes[i];
toremove_count++;
}
}
}
-
//process remotions
- for(int i=0;i<toremove_count;i++) {
+ for (int i = 0; i < toremove_count; i++) {
- _body_inout(0,toremove[i].body_id,toremove[i].pair.body_shape,toremove[i].pair.local_shape);
+ _body_inout(0, toremove[i].body_id, toremove[i].pair.body_shape, toremove[i].pair.local_shape);
}
//process aditions
- for(int i=0;i<toadd_count;i++) {
+ for (int i = 0; i < toadd_count; i++) {
- _body_inout(1,toadd[i].id,toadd[i].shape,toadd[i].local_shape);
+ _body_inout(1, toadd[i].id, toadd[i].shape, toadd[i].local_shape);
}
- contact_monitor->locked=false;
-
+ contact_monitor->locked = false;
}
-
-
- state=NULL;
+ state = NULL;
}
void RigidBody::_notification(int p_what) {
-
-
}
void RigidBody::set_mode(Mode p_mode) {
- mode=p_mode;
- switch(p_mode) {
+ mode = p_mode;
+ switch (p_mode) {
case MODE_RIGID: {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(),PhysicsServer::BODY_MODE_RIGID);
+ PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_RIGID);
} break;
case MODE_STATIC: {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(),PhysicsServer::BODY_MODE_STATIC);
+ PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_STATIC);
} break;
case MODE_CHARACTER: {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(),PhysicsServer::BODY_MODE_CHARACTER);
+ PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_CHARACTER);
} break;
case MODE_KINEMATIC: {
- PhysicsServer::get_singleton()->body_set_mode(get_rid(),PhysicsServer::BODY_MODE_KINEMATIC);
+ PhysicsServer::get_singleton()->body_set_mode(get_rid(), PhysicsServer::BODY_MODE_KINEMATIC);
} break;
-
}
}
-RigidBody::Mode RigidBody::get_mode() const{
+RigidBody::Mode RigidBody::get_mode() const {
return mode;
}
-void RigidBody::set_mass(real_t p_mass){
+void RigidBody::set_mass(real_t p_mass) {
- ERR_FAIL_COND(p_mass<=0);
- mass=p_mass;
+ ERR_FAIL_COND(p_mass <= 0);
+ mass = p_mass;
_change_notify("mass");
_change_notify("weight");
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_MASS,mass);
-
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass);
}
-real_t RigidBody::get_mass() const{
+real_t RigidBody::get_mass() const {
return mass;
}
-void RigidBody::set_weight(real_t p_weight){
+void RigidBody::set_weight(real_t p_weight) {
- set_mass(p_weight/9.8);
+ set_mass(p_weight / 9.8);
}
-real_t RigidBody::get_weight() const{
+real_t RigidBody::get_weight() const {
- return mass*9.8;
+ return mass * 9.8;
}
+void RigidBody::set_friction(real_t p_friction) {
-void RigidBody::set_friction(real_t p_friction){
-
- ERR_FAIL_COND(p_friction<0 || p_friction>1);
-
- friction=p_friction;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_FRICTION,friction);
+ ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
+ friction = p_friction;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, friction);
}
-real_t RigidBody::get_friction() const{
+real_t RigidBody::get_friction() const {
return friction;
}
-void RigidBody::set_bounce(real_t p_bounce){
+void RigidBody::set_bounce(real_t p_bounce) {
- ERR_FAIL_COND(p_bounce<0 || p_bounce>1);
-
- bounce=p_bounce;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_BOUNCE,bounce);
+ ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
+ bounce = p_bounce;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_BOUNCE, bounce);
}
-real_t RigidBody::get_bounce() const{
+real_t RigidBody::get_bounce() const {
return bounce;
}
+void RigidBody::set_gravity_scale(real_t p_gravity_scale) {
-void RigidBody::set_gravity_scale(real_t p_gravity_scale){
-
- gravity_scale=p_gravity_scale;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_GRAVITY_SCALE,gravity_scale);
-
+ gravity_scale = p_gravity_scale;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
}
-real_t RigidBody::get_gravity_scale() const{
+real_t RigidBody::get_gravity_scale() const {
return gravity_scale;
}
-void RigidBody::set_linear_damp(real_t p_linear_damp){
-
- ERR_FAIL_COND(p_linear_damp<-1);
- linear_damp=p_linear_damp;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_LINEAR_DAMP,linear_damp);
+void RigidBody::set_linear_damp(real_t p_linear_damp) {
+ ERR_FAIL_COND(p_linear_damp < -1);
+ linear_damp = p_linear_damp;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_LINEAR_DAMP, linear_damp);
}
-real_t RigidBody::get_linear_damp() const{
+real_t RigidBody::get_linear_damp() const {
return linear_damp;
}
-void RigidBody::set_angular_damp(real_t p_angular_damp){
-
- ERR_FAIL_COND(p_angular_damp<-1);
- angular_damp=p_angular_damp;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_ANGULAR_DAMP,angular_damp);
+void RigidBody::set_angular_damp(real_t p_angular_damp) {
+ ERR_FAIL_COND(p_angular_damp < -1);
+ angular_damp = p_angular_damp;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_ANGULAR_DAMP, angular_damp);
}
-real_t RigidBody::get_angular_damp() const{
+real_t RigidBody::get_angular_damp() const {
return angular_damp;
}
-void RigidBody::set_axis_velocity(const Vector3& p_axis) {
+void RigidBody::set_axis_velocity(const Vector3 &p_axis) {
- Vector3 v = state? state->get_linear_velocity() : linear_velocity;
+ Vector3 v = state ? state->get_linear_velocity() : linear_velocity;
Vector3 axis = p_axis.normalized();
- v-=axis*axis.dot(v);
- v+=p_axis;
+ v -= axis * axis.dot(v);
+ v += p_axis;
if (state) {
set_linear_velocity(v);
} else {
- PhysicsServer::get_singleton()->body_set_axis_velocity(get_rid(),p_axis);
- linear_velocity=v;
+ PhysicsServer::get_singleton()->body_set_axis_velocity(get_rid(), p_axis);
+ linear_velocity = v;
}
}
-void RigidBody::set_linear_velocity(const Vector3& p_velocity){
+void RigidBody::set_linear_velocity(const Vector3 &p_velocity) {
- linear_velocity=p_velocity;
+ linear_velocity = p_velocity;
if (state)
state->set_linear_velocity(linear_velocity);
else
- PhysicsServer::get_singleton()->body_set_state(get_rid(),PhysicsServer::BODY_STATE_LINEAR_VELOCITY,linear_velocity);
-
+ PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
}
-Vector3 RigidBody::get_linear_velocity() const{
+Vector3 RigidBody::get_linear_velocity() const {
return linear_velocity;
}
-void RigidBody::set_angular_velocity(const Vector3& p_velocity){
+void RigidBody::set_angular_velocity(const Vector3 &p_velocity) {
- angular_velocity=p_velocity;
+ angular_velocity = p_velocity;
if (state)
state->set_angular_velocity(angular_velocity);
else
- PhysicsServer::get_singleton()->body_set_state(get_rid(),PhysicsServer::BODY_STATE_ANGULAR_VELOCITY,angular_velocity);
+ PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
}
-Vector3 RigidBody::get_angular_velocity() const{
+Vector3 RigidBody::get_angular_velocity() const {
return angular_velocity;
}
-void RigidBody::set_use_custom_integrator(bool p_enable){
+void RigidBody::set_use_custom_integrator(bool p_enable) {
- if (custom_integrator==p_enable)
+ if (custom_integrator == p_enable)
return;
- custom_integrator=p_enable;
- PhysicsServer::get_singleton()->body_set_omit_force_integration(get_rid(),p_enable);
-
-
+ custom_integrator = p_enable;
+ PhysicsServer::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
}
-bool RigidBody::is_using_custom_integrator(){
+bool RigidBody::is_using_custom_integrator() {
return custom_integrator;
}
void RigidBody::set_sleeping(bool p_sleeping) {
- sleeping=p_sleeping;
- PhysicsServer::get_singleton()->body_set_state(get_rid(),PhysicsServer::BODY_STATE_SLEEPING,sleeping);
-
+ sleeping = p_sleeping;
+ PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_SLEEPING, sleeping);
}
void RigidBody::set_can_sleep(bool p_active) {
- can_sleep=p_active;
- PhysicsServer::get_singleton()->body_set_state(get_rid(),PhysicsServer::BODY_STATE_CAN_SLEEP,p_active);
+ can_sleep = p_active;
+ PhysicsServer::get_singleton()->body_set_state(get_rid(), PhysicsServer::BODY_STATE_CAN_SLEEP, p_active);
}
bool RigidBody::is_able_to_sleep() const {
@@ -705,36 +659,34 @@ bool RigidBody::is_sleeping() const {
void RigidBody::set_max_contacts_reported(int p_amount) {
- max_contacts_reported=p_amount;
- PhysicsServer::get_singleton()->body_set_max_contacts_reported(get_rid(),p_amount);
+ max_contacts_reported = p_amount;
+ PhysicsServer::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
}
-int RigidBody::get_max_contacts_reported() const{
+int RigidBody::get_max_contacts_reported() const {
return max_contacts_reported;
}
-void RigidBody::apply_impulse(const Vector3& p_pos, const Vector3& p_impulse) {
+void RigidBody::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
- PhysicsServer::get_singleton()->body_apply_impulse(get_rid(),p_pos,p_impulse);
+ PhysicsServer::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
}
void RigidBody::set_use_continuous_collision_detection(bool p_enable) {
- ccd=p_enable;
- PhysicsServer::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(),p_enable);
+ ccd = p_enable;
+ PhysicsServer::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable);
}
bool RigidBody::is_using_continuous_collision_detection() const {
-
return ccd;
}
-
void RigidBody::set_contact_monitor(bool p_enabled) {
- if (p_enabled==is_contact_monitor_enabled())
+ if (p_enabled == is_contact_monitor_enabled())
return;
if (!p_enabled) {
@@ -744,31 +696,29 @@ void RigidBody::set_contact_monitor(bool p_enabled) {
}
ERR_FAIL_COND(contact_monitor->locked);
- for(Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
+ for (Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
//clean up mess
}
- memdelete( contact_monitor );
- contact_monitor=NULL;
+ memdelete(contact_monitor);
+ contact_monitor = NULL;
} else {
- contact_monitor = memnew( ContactMonitor );
- contact_monitor->locked=false;
-
+ contact_monitor = memnew(ContactMonitor);
+ contact_monitor->locked = false;
}
-
}
bool RigidBody::is_contact_monitor_enabled() const {
- return contact_monitor!=NULL;
+ return contact_monitor != NULL;
}
void RigidBody::set_axis_lock(AxisLock p_lock) {
- axis_lock=p_lock;
- PhysicsServer::get_singleton()->body_set_axis_lock(get_rid(),PhysicsServer::BodyAxisLock(axis_lock));
+ axis_lock = p_lock;
+ PhysicsServer::get_singleton()->body_set_axis_lock(get_rid(), PhysicsServer::BodyAxisLock(axis_lock));
}
RigidBody::AxisLock RigidBody::get_axis_lock() const {
@@ -776,166 +726,159 @@ RigidBody::AxisLock RigidBody::get_axis_lock() const {
return axis_lock;
}
-
Array RigidBody::get_colliding_bodies() const {
- ERR_FAIL_COND_V(!contact_monitor,Array());
+ ERR_FAIL_COND_V(!contact_monitor, Array());
Array ret;
ret.resize(contact_monitor->body_map.size());
- int idx=0;
- for (const Map<ObjectID,BodyState>::Element *E=contact_monitor->body_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (const Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.front(); E; E = E->next()) {
Object *obj = ObjectDB::get_instance(E->key());
if (!obj) {
- ret.resize( ret.size() -1 ); //ops
+ ret.resize(ret.size() - 1); //ops
} else {
- ret[idx++]=obj;
+ ret[idx++] = obj;
}
-
}
return ret;
}
-
void RigidBody::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&RigidBody::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&RigidBody::get_mode);
+ ObjectTypeDB::bind_method(_MD("set_mode", "mode"), &RigidBody::set_mode);
+ ObjectTypeDB::bind_method(_MD("get_mode"), &RigidBody::get_mode);
- ObjectTypeDB::bind_method(_MD("set_mass","mass"),&RigidBody::set_mass);
- ObjectTypeDB::bind_method(_MD("get_mass"),&RigidBody::get_mass);
+ ObjectTypeDB::bind_method(_MD("set_mass", "mass"), &RigidBody::set_mass);
+ ObjectTypeDB::bind_method(_MD("get_mass"), &RigidBody::get_mass);
- ObjectTypeDB::bind_method(_MD("set_weight","weight"),&RigidBody::set_weight);
- ObjectTypeDB::bind_method(_MD("get_weight"),&RigidBody::get_weight);
+ ObjectTypeDB::bind_method(_MD("set_weight", "weight"), &RigidBody::set_weight);
+ ObjectTypeDB::bind_method(_MD("get_weight"), &RigidBody::get_weight);
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&RigidBody::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&RigidBody::get_friction);
+ ObjectTypeDB::bind_method(_MD("set_friction", "friction"), &RigidBody::set_friction);
+ ObjectTypeDB::bind_method(_MD("get_friction"), &RigidBody::get_friction);
- ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&RigidBody::set_bounce);
- ObjectTypeDB::bind_method(_MD("get_bounce"),&RigidBody::get_bounce);
+ ObjectTypeDB::bind_method(_MD("set_bounce", "bounce"), &RigidBody::set_bounce);
+ ObjectTypeDB::bind_method(_MD("get_bounce"), &RigidBody::get_bounce);
- ObjectTypeDB::bind_method(_MD("set_linear_velocity","linear_velocity"),&RigidBody::set_linear_velocity);
- ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&RigidBody::get_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("set_linear_velocity", "linear_velocity"), &RigidBody::set_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("get_linear_velocity"), &RigidBody::get_linear_velocity);
- ObjectTypeDB::bind_method(_MD("set_angular_velocity","angular_velocity"),&RigidBody::set_angular_velocity);
- ObjectTypeDB::bind_method(_MD("get_angular_velocity"),&RigidBody::get_angular_velocity);
+ ObjectTypeDB::bind_method(_MD("set_angular_velocity", "angular_velocity"), &RigidBody::set_angular_velocity);
+ ObjectTypeDB::bind_method(_MD("get_angular_velocity"), &RigidBody::get_angular_velocity);
- ObjectTypeDB::bind_method(_MD("set_gravity_scale","gravity_scale"),&RigidBody::set_gravity_scale);
- ObjectTypeDB::bind_method(_MD("get_gravity_scale"),&RigidBody::get_gravity_scale);
+ ObjectTypeDB::bind_method(_MD("set_gravity_scale", "gravity_scale"), &RigidBody::set_gravity_scale);
+ ObjectTypeDB::bind_method(_MD("get_gravity_scale"), &RigidBody::get_gravity_scale);
- ObjectTypeDB::bind_method(_MD("set_linear_damp","linear_damp"),&RigidBody::set_linear_damp);
- ObjectTypeDB::bind_method(_MD("get_linear_damp"),&RigidBody::get_linear_damp);
+ ObjectTypeDB::bind_method(_MD("set_linear_damp", "linear_damp"), &RigidBody::set_linear_damp);
+ ObjectTypeDB::bind_method(_MD("get_linear_damp"), &RigidBody::get_linear_damp);
- ObjectTypeDB::bind_method(_MD("set_angular_damp","angular_damp"),&RigidBody::set_angular_damp);
- ObjectTypeDB::bind_method(_MD("get_angular_damp"),&RigidBody::get_angular_damp);
+ ObjectTypeDB::bind_method(_MD("set_angular_damp", "angular_damp"), &RigidBody::set_angular_damp);
+ ObjectTypeDB::bind_method(_MD("get_angular_damp"), &RigidBody::get_angular_damp);
+ ObjectTypeDB::bind_method(_MD("set_max_contacts_reported", "amount"), &RigidBody::set_max_contacts_reported);
+ ObjectTypeDB::bind_method(_MD("get_max_contacts_reported"), &RigidBody::get_max_contacts_reported);
- ObjectTypeDB::bind_method(_MD("set_max_contacts_reported","amount"),&RigidBody::set_max_contacts_reported);
- ObjectTypeDB::bind_method(_MD("get_max_contacts_reported"),&RigidBody::get_max_contacts_reported);
+ ObjectTypeDB::bind_method(_MD("set_use_custom_integrator", "enable"), &RigidBody::set_use_custom_integrator);
+ ObjectTypeDB::bind_method(_MD("is_using_custom_integrator"), &RigidBody::is_using_custom_integrator);
- ObjectTypeDB::bind_method(_MD("set_use_custom_integrator","enable"),&RigidBody::set_use_custom_integrator);
- ObjectTypeDB::bind_method(_MD("is_using_custom_integrator"),&RigidBody::is_using_custom_integrator);
+ ObjectTypeDB::bind_method(_MD("set_contact_monitor", "enabled"), &RigidBody::set_contact_monitor);
+ ObjectTypeDB::bind_method(_MD("is_contact_monitor_enabled"), &RigidBody::is_contact_monitor_enabled);
- ObjectTypeDB::bind_method(_MD("set_contact_monitor","enabled"),&RigidBody::set_contact_monitor);
- ObjectTypeDB::bind_method(_MD("is_contact_monitor_enabled"),&RigidBody::is_contact_monitor_enabled);
+ ObjectTypeDB::bind_method(_MD("set_use_continuous_collision_detection", "enable"), &RigidBody::set_use_continuous_collision_detection);
+ ObjectTypeDB::bind_method(_MD("is_using_continuous_collision_detection"), &RigidBody::is_using_continuous_collision_detection);
- ObjectTypeDB::bind_method(_MD("set_use_continuous_collision_detection","enable"),&RigidBody::set_use_continuous_collision_detection);
- ObjectTypeDB::bind_method(_MD("is_using_continuous_collision_detection"),&RigidBody::is_using_continuous_collision_detection);
+ ObjectTypeDB::bind_method(_MD("set_axis_velocity", "axis_velocity"), &RigidBody::set_axis_velocity);
+ ObjectTypeDB::bind_method(_MD("apply_impulse", "pos", "impulse"), &RigidBody::apply_impulse);
- ObjectTypeDB::bind_method(_MD("set_axis_velocity","axis_velocity"),&RigidBody::set_axis_velocity);
- ObjectTypeDB::bind_method(_MD("apply_impulse","pos","impulse"),&RigidBody::apply_impulse);
+ ObjectTypeDB::bind_method(_MD("set_sleeping", "sleeping"), &RigidBody::set_sleeping);
+ ObjectTypeDB::bind_method(_MD("is_sleeping"), &RigidBody::is_sleeping);
- ObjectTypeDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody::set_sleeping);
- ObjectTypeDB::bind_method(_MD("is_sleeping"),&RigidBody::is_sleeping);
+ ObjectTypeDB::bind_method(_MD("set_can_sleep", "able_to_sleep"), &RigidBody::set_can_sleep);
+ ObjectTypeDB::bind_method(_MD("is_able_to_sleep"), &RigidBody::is_able_to_sleep);
- ObjectTypeDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody::set_can_sleep);
- ObjectTypeDB::bind_method(_MD("is_able_to_sleep"),&RigidBody::is_able_to_sleep);
+ ObjectTypeDB::bind_method(_MD("_direct_state_changed"), &RigidBody::_direct_state_changed);
+ ObjectTypeDB::bind_method(_MD("_body_enter_tree"), &RigidBody::_body_enter_tree);
+ ObjectTypeDB::bind_method(_MD("_body_exit_tree"), &RigidBody::_body_exit_tree);
- ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&RigidBody::_direct_state_changed);
- ObjectTypeDB::bind_method(_MD("_body_enter_tree"),&RigidBody::_body_enter_tree);
- ObjectTypeDB::bind_method(_MD("_body_exit_tree"),&RigidBody::_body_exit_tree);
+ ObjectTypeDB::bind_method(_MD("set_axis_lock", "axis_lock"), &RigidBody::set_axis_lock);
+ ObjectTypeDB::bind_method(_MD("get_axis_lock"), &RigidBody::get_axis_lock);
- ObjectTypeDB::bind_method(_MD("set_axis_lock","axis_lock"),&RigidBody::set_axis_lock);
- ObjectTypeDB::bind_method(_MD("get_axis_lock"),&RigidBody::get_axis_lock);
+ ObjectTypeDB::bind_method(_MD("get_colliding_bodies"), &RigidBody::get_colliding_bodies);
- ObjectTypeDB::bind_method(_MD("get_colliding_bodies"),&RigidBody::get_colliding_bodies);
+ BIND_VMETHOD(MethodInfo("_integrate_forces", PropertyInfo(Variant::OBJECT, "state:PhysicsDirectBodyState")));
- BIND_VMETHOD(MethodInfo("_integrate_forces",PropertyInfo(Variant::OBJECT,"state:PhysicsDirectBodyState")));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Rigid,Static,Character,Kinematic"), _SCS("set_mode"), _SCS("get_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), _SCS("set_mass"), _SCS("get_mass"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "weight", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", PROPERTY_USAGE_EDITOR), _SCS("set_weight"), _SCS("get_weight"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_friction"), _SCS("get_friction"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_bounce"), _SCS("get_bounce"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), _SCS("set_gravity_scale"), _SCS("get_gravity_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), _SCS("set_use_custom_integrator"), _SCS("is_using_custom_integrator"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "continuous_cd"), _SCS("set_use_continuous_collision_detection"), _SCS("is_using_continuous_collision_detection"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "contacts_reported"), _SCS("set_max_contacts_reported"), _SCS("get_max_contacts_reported"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "contact_monitor"), _SCS("set_contact_monitor"), _SCS("is_contact_monitor_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), _SCS("set_sleeping"), _SCS("is_sleeping"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "can_sleep"), _SCS("set_can_sleep"), _SCS("is_able_to_sleep"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "axis_lock", PROPERTY_HINT_ENUM, "Disabled,Lock X,Lock Y,Lock Z"), _SCS("set_axis_lock"), _SCS("get_axis_lock"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "velocity/linear"), _SCS("set_linear_velocity"), _SCS("get_linear_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "velocity/angular"), _SCS("set_angular_velocity"), _SCS("get_angular_velocity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "damp_override/linear", PROPERTY_HINT_RANGE, "-1,128,0.01"), _SCS("set_linear_damp"), _SCS("get_linear_damp"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "damp_override/angular", PROPERTY_HINT_RANGE, "-1,128,0.01"), _SCS("set_angular_damp"), _SCS("get_angular_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Rigid,Static,Character,Kinematic"),_SCS("set_mode"),_SCS("get_mode"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"mass",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01"),_SCS("set_mass"),_SCS("get_mass"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"weight",PROPERTY_HINT_EXP_RANGE,"0.01,65535,0.01",PROPERTY_USAGE_EDITOR),_SCS("set_weight"),_SCS("get_weight"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_scale",PROPERTY_HINT_RANGE,"-128,128,0.01"),_SCS("set_gravity_scale"),_SCS("get_gravity_scale"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"custom_integrator"),_SCS("set_use_custom_integrator"),_SCS("is_using_custom_integrator"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"continuous_cd"),_SCS("set_use_continuous_collision_detection"),_SCS("is_using_continuous_collision_detection"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"contacts_reported"),_SCS("set_max_contacts_reported"),_SCS("get_max_contacts_reported"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),_SCS("set_contact_monitor"),_SCS("is_contact_monitor_enabled"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),_SCS("set_sleeping"),_SCS("is_sleeping"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"axis_lock",PROPERTY_HINT_ENUM,"Disabled,Lock X,Lock Y,Lock Z"),_SCS("set_axis_lock"),_SCS("get_axis_lock"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"velocity/linear"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"velocity/angular"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/linear",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_linear_damp"),_SCS("get_linear_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"damp_override/angular",PROPERTY_HINT_RANGE,"-1,128,0.01"),_SCS("set_angular_damp"),_SCS("get_angular_damp"));
+ ADD_SIGNAL(MethodInfo("body_enter_shape", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
+ ADD_SIGNAL(MethodInfo("body_exit_shape", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "local_shape")));
+ ADD_SIGNAL(MethodInfo("body_enter", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("body_exit", PropertyInfo(Variant::OBJECT, "body")));
+ ADD_SIGNAL(MethodInfo("sleeping_state_changed"));
- ADD_SIGNAL( MethodInfo("body_enter_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
- ADD_SIGNAL( MethodInfo("body_exit_shape",PropertyInfo(Variant::INT,"body_id"),PropertyInfo(Variant::OBJECT,"body"),PropertyInfo(Variant::INT,"body_shape"),PropertyInfo(Variant::INT,"local_shape")));
- ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body")));
- ADD_SIGNAL( MethodInfo("sleeping_state_changed"));
-
- BIND_CONSTANT( MODE_STATIC );
- BIND_CONSTANT( MODE_KINEMATIC );
- BIND_CONSTANT( MODE_RIGID );
- BIND_CONSTANT( MODE_CHARACTER );
+ BIND_CONSTANT(MODE_STATIC);
+ BIND_CONSTANT(MODE_KINEMATIC);
+ BIND_CONSTANT(MODE_RIGID);
+ BIND_CONSTANT(MODE_CHARACTER);
}
-RigidBody::RigidBody() : PhysicsBody(PhysicsServer::BODY_MODE_RIGID) {
+RigidBody::RigidBody()
+ : PhysicsBody(PhysicsServer::BODY_MODE_RIGID) {
- mode=MODE_RIGID;
+ mode = MODE_RIGID;
- bounce=0;
- mass=1;
- friction=1;
- max_contacts_reported=0;
- state=NULL;
+ bounce = 0;
+ mass = 1;
+ friction = 1;
+ max_contacts_reported = 0;
+ state = NULL;
- gravity_scale=1;
- linear_damp=-1;
- angular_damp=-1;
+ gravity_scale = 1;
+ linear_damp = -1;
+ angular_damp = -1;
//angular_velocity=0;
- sleeping=false;
- ccd=false;
+ sleeping = false;
+ ccd = false;
- custom_integrator=false;
- contact_monitor=NULL;
- can_sleep=true;
+ custom_integrator = false;
+ contact_monitor = NULL;
+ can_sleep = true;
axis_lock = AXIS_LOCK_DISABLED;
- PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(),this,"_direct_state_changed");
+ PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
}
RigidBody::~RigidBody() {
if (contact_monitor)
- memdelete( contact_monitor );
-
-
-
+ memdelete(contact_monitor);
}
//////////////////////////////////////////////////////
//////////////////////////
-
Variant KinematicBody::_get_collider() const {
- ObjectID oid=get_collider();
- if (oid==0)
+ ObjectID oid = get_collider();
+ if (oid == 0)
return Variant();
Object *obj = ObjectDB::get_instance(oid);
if (!obj)
@@ -949,10 +892,9 @@ Variant KinematicBody::_get_collider() const {
return obj;
}
-
bool KinematicBody::_ignores_mode(PhysicsServer::BodyMode p_mode) const {
- switch(p_mode) {
+ switch (p_mode) {
case PhysicsServer::BODY_MODE_STATIC: return !collide_static;
case PhysicsServer::BODY_MODE_KINEMATIC: return !collide_kinematic;
case PhysicsServer::BODY_MODE_RIGID: return !collide_rigid;
@@ -962,7 +904,7 @@ bool KinematicBody::_ignores_mode(PhysicsServer::BodyMode p_mode) const {
return true;
}
-Vector3 KinematicBody::move(const Vector3& p_motion) {
+Vector3 KinematicBody::move(const Vector3 &p_motion) {
//give me back regular physics engine logic
//this is madness
@@ -971,34 +913,32 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
//this took about a week to get right..
//but is it right? who knows at this point..
-
- colliding=false;
- ERR_FAIL_COND_V(!is_inside_tree(),Vector3());
+ colliding = false;
+ ERR_FAIL_COND_V(!is_inside_tree(), Vector3());
PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(get_world()->get_space());
- ERR_FAIL_COND_V(!dss,Vector3());
- const int max_shapes=32;
- Vector3 sr[max_shapes*2];
+ ERR_FAIL_COND_V(!dss, Vector3());
+ const int max_shapes = 32;
+ Vector3 sr[max_shapes * 2];
int res_shapes;
Set<RID> exclude;
exclude.insert(get_rid());
-
//recover first
- int recover_attempts=4;
+ int recover_attempts = 4;
- bool collided=false;
- uint32_t mask=0;
+ bool collided = false;
+ uint32_t mask = 0;
if (collide_static)
- mask|=PhysicsDirectSpaceState::TYPE_MASK_STATIC_BODY;
+ mask |= PhysicsDirectSpaceState::TYPE_MASK_STATIC_BODY;
if (collide_kinematic)
- mask|=PhysicsDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
+ mask |= PhysicsDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
if (collide_rigid)
- mask|=PhysicsDirectSpaceState::TYPE_MASK_RIGID_BODY;
+ mask |= PhysicsDirectSpaceState::TYPE_MASK_RIGID_BODY;
if (collide_character)
- mask|=PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
+ mask |= PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-// print_line("motion: "+p_motion+" margin: "+rtos(margin));
+ // print_line("motion: "+p_motion+" margin: "+rtos(margin));
//print_line("margin: "+rtos(margin));
@@ -1008,31 +948,28 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
do {
//motion recover
- for(int i=0;i<get_shape_count();i++) {
+ for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_set_as_trigger(i))
continue;
- if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),m,sr,max_shapes,res_shapes,exclude,get_layer_mask(),mask)) {
- collided=true;
+ if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), m, sr, max_shapes, res_shapes, exclude, get_layer_mask(), mask)) {
+ collided = true;
}
-
}
-
-
if (!collided)
break;
//print_line("have to recover");
Vector3 recover_motion;
- bool all_outside=true;
- for(int j=0;j<8;j++) {
- for(int i=0;i<res_shapes;i++) {
+ bool all_outside = true;
+ for (int j = 0; j < 8; j++) {
+ for (int i = 0; i < res_shapes; i++) {
- Vector3 a = sr[i*2+0];
- Vector3 b = sr[i*2+1];
- //print_line(String()+a+" -> "+b);
+ Vector3 a = sr[i * 2 + 0];
+ Vector3 b = sr[i * 2 + 1];
+//print_line(String()+a+" -> "+b);
#if 0
float d = a.distance_to(b);
@@ -1043,29 +980,27 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
recover_motion+=(b-a)*0.2;
#else
float dist = a.distance_to(b);
- if (dist>CMP_EPSILON) {
- Vector3 norm = (b-a).normalized();
- if (dist>margin*0.5)
- all_outside=false;
+ if (dist > CMP_EPSILON) {
+ Vector3 norm = (b - a).normalized();
+ if (dist > margin * 0.5)
+ all_outside = false;
float adv = norm.dot(recover_motion);
//print_line(itos(i)+" dist: "+rtos(dist)+" adv: "+rtos(adv));
- recover_motion+=norm*MAX(dist-adv,0)*0.4;
+ recover_motion += norm * MAX(dist - adv, 0) * 0.4;
}
#endif
-
}
}
-
- if (recover_motion==Vector3()) {
- collided=false;
+ if (recover_motion == Vector3()) {
+ collided = false;
break;
}
//print_line("**** RECOVER: "+recover_motion);
Transform gt = get_global_transform();
- gt.origin+=recover_motion;
+ gt.origin += recover_motion;
set_global_transform(gt);
recover_attempts--;
@@ -1075,131 +1010,125 @@ Vector3 KinematicBody::move(const Vector3& p_motion) {
} while (recover_attempts);
-
//move second
float safe = 1.0;
float unsafe = 1.0;
- int best_shape=-1;
+ int best_shape = -1;
PhysicsDirectSpaceState::ShapeRestInfo rest;
//print_line("pos: "+get_global_transform().origin);
//print_line("motion: "+p_motion);
-
- for(int i=0;i<get_shape_count();i++) {
-
+ for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_set_as_trigger(i))
continue;
- float lsafe,lunsafe;
+ float lsafe, lunsafe;
PhysicsDirectSpaceState::ShapeRestInfo lrest;
- bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion,0, lsafe,lunsafe,exclude,get_layer_mask(),mask,&lrest);
+ bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion, 0, lsafe, lunsafe, exclude, get_layer_mask(), mask, &lrest);
//print_line("shape: "+itos(i)+" travel:"+rtos(ltravel));
if (!valid) {
- safe=0;
- unsafe=0;
- best_shape=i; //sadly it's the best
+ safe = 0;
+ unsafe = 0;
+ best_shape = i; //sadly it's the best
//print_line("initial stuck");
break;
}
- if (lsafe==1.0) {
+ if (lsafe == 1.0) {
//print_line("initial free");
continue;
}
if (lsafe < safe) {
//print_line("initial at "+rtos(lsafe));
- safe=lsafe;
- safe=MAX(0,lsafe-0.01);
- unsafe=lunsafe;
- best_shape=i;
- rest=lrest;
+ safe = lsafe;
+ safe = MAX(0, lsafe - 0.01);
+ unsafe = lunsafe;
+ best_shape = i;
+ rest = lrest;
}
}
-
//print_line("best shape: "+itos(best_shape)+" motion "+p_motion);
- if (safe>=1) {
+ if (safe >= 1) {
//not collided
- colliding=false;
+ colliding = false;
} else {
- colliding=true;
+ colliding = true;
- if (true || (safe==0 && unsafe==0)) { //use it always because it's more precise than GJK
+ if (true || (safe == 0 && unsafe == 0)) { //use it always because it's more precise than GJK
//no advance, use rest info from collision
Transform ugt = get_global_transform();
- ugt.origin+=p_motion*unsafe;
+ ugt.origin += p_motion * unsafe;
PhysicsDirectSpaceState::ShapeRestInfo rest_info;
- bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), m,&rest,exclude,get_layer_mask(),mask);
+ bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt * get_shape_transform(best_shape), m, &rest, exclude, get_layer_mask(), mask);
if (!c2) {
//should not happen, but floating point precision is so weird..
- colliding=false;
+ colliding = false;
}
- // print_line("Rest Travel: "+rest.normal);
-
+ // print_line("Rest Travel: "+rest.normal);
}
if (colliding) {
- collision=rest.point;
- normal=rest.normal;
- collider=rest.collider_id;
- collider_vel=rest.linear_velocity;
- collider_shape=rest.shape;
+ collision = rest.point;
+ normal = rest.normal;
+ collider = rest.collider_id;
+ collider_vel = rest.linear_velocity;
+ collider_shape = rest.shape;
}
}
- Vector3 motion=p_motion*safe;
+ Vector3 motion = p_motion * safe;
//if (colliding)
// motion+=normal*0.001;
Transform gt = get_global_transform();
- gt.origin+=motion;
+ gt.origin += motion;
set_global_transform(gt);
- return p_motion-motion;
-
+ return p_motion - motion;
}
-Vector3 KinematicBody::move_to(const Vector3& p_position) {
+Vector3 KinematicBody::move_to(const Vector3 &p_position) {
- return move(p_position-get_global_transform().origin);
+ return move(p_position - get_global_transform().origin);
}
-bool KinematicBody::can_teleport_to(const Vector3& p_position) {
+bool KinematicBody::can_teleport_to(const Vector3 &p_position) {
- ERR_FAIL_COND_V(!is_inside_tree(),false);
+ ERR_FAIL_COND_V(!is_inside_tree(), false);
PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(get_world()->get_space());
- ERR_FAIL_COND_V(!dss,false);
+ ERR_FAIL_COND_V(!dss, false);
- uint32_t mask=0;
+ uint32_t mask = 0;
if (collide_static)
- mask|=PhysicsDirectSpaceState::TYPE_MASK_STATIC_BODY;
+ mask |= PhysicsDirectSpaceState::TYPE_MASK_STATIC_BODY;
if (collide_kinematic)
- mask|=PhysicsDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
+ mask |= PhysicsDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
if (collide_rigid)
- mask|=PhysicsDirectSpaceState::TYPE_MASK_RIGID_BODY;
+ mask |= PhysicsDirectSpaceState::TYPE_MASK_RIGID_BODY;
if (collide_character)
- mask|=PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
+ mask |= PhysicsDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
- Transform xform=get_global_transform();
- xform.origin=p_position;
+ Transform xform = get_global_transform();
+ xform.origin = p_position;
Set<RID> exclude;
exclude.insert(get_rid());
- for(int i=0;i<get_shape_count();i++) {
+ for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_set_as_trigger(i))
continue;
- bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i),0,NULL,1,exclude,get_layer_mask(),mask);
+ bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i), 0, NULL, 1, exclude, get_layer_mask(), mask);
if (col)
return false;
}
@@ -1209,21 +1138,19 @@ bool KinematicBody::can_teleport_to(const Vector3& p_position) {
bool KinematicBody::is_colliding() const {
- ERR_FAIL_COND_V(!is_inside_tree(),false);
+ ERR_FAIL_COND_V(!is_inside_tree(), false);
return colliding;
}
Vector3 KinematicBody::get_collision_pos() const {
- ERR_FAIL_COND_V(!colliding,Vector3());
+ ERR_FAIL_COND_V(!colliding, Vector3());
return collision;
-
}
Vector3 KinematicBody::get_collision_normal() const {
- ERR_FAIL_COND_V(!colliding,Vector3());
+ ERR_FAIL_COND_V(!colliding, Vector3());
return normal;
-
}
Vector3 KinematicBody::get_collider_velocity() const {
@@ -1233,18 +1160,17 @@ Vector3 KinematicBody::get_collider_velocity() const {
ObjectID KinematicBody::get_collider() const {
- ERR_FAIL_COND_V(!colliding,0);
+ ERR_FAIL_COND_V(!colliding, 0);
return collider;
}
int KinematicBody::get_collider_shape() const {
- ERR_FAIL_COND_V(!colliding,-1);
+ ERR_FAIL_COND_V(!colliding, -1);
return collider_shape;
-
}
void KinematicBody::set_collide_with_static_bodies(bool p_enable) {
- collide_static=p_enable;
+ collide_static = p_enable;
}
bool KinematicBody::can_collide_with_static_bodies() const {
@@ -1253,19 +1179,16 @@ bool KinematicBody::can_collide_with_static_bodies() const {
void KinematicBody::set_collide_with_rigid_bodies(bool p_enable) {
- collide_rigid=p_enable;
-
+ collide_rigid = p_enable;
}
bool KinematicBody::can_collide_with_rigid_bodies() const {
-
return collide_rigid;
}
void KinematicBody::set_collide_with_kinematic_bodies(bool p_enable) {
- collide_kinematic=p_enable;
-
+ collide_kinematic = p_enable;
}
bool KinematicBody::can_collide_with_kinematic_bodies() const {
@@ -1274,7 +1197,7 @@ bool KinematicBody::can_collide_with_kinematic_bodies() const {
void KinematicBody::set_collide_with_character_bodies(bool p_enable) {
- collide_character=p_enable;
+ collide_character = p_enable;
}
bool KinematicBody::can_collide_with_character_bodies() const {
@@ -1283,70 +1206,63 @@ bool KinematicBody::can_collide_with_character_bodies() const {
void KinematicBody::set_collision_margin(float p_margin) {
- margin=p_margin;
+ margin = p_margin;
}
-float KinematicBody::get_collision_margin() const{
+float KinematicBody::get_collision_margin() const {
return margin;
}
void KinematicBody::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("move", "rel_vec"), &KinematicBody::move);
+ ObjectTypeDB::bind_method(_MD("move_to", "position"), &KinematicBody::move_to);
- ObjectTypeDB::bind_method(_MD("move","rel_vec"),&KinematicBody::move);
- ObjectTypeDB::bind_method(_MD("move_to","position"),&KinematicBody::move_to);
-
- ObjectTypeDB::bind_method(_MD("can_teleport_to","position"),&KinematicBody::can_teleport_to);
-
- ObjectTypeDB::bind_method(_MD("is_colliding"),&KinematicBody::is_colliding);
-
- ObjectTypeDB::bind_method(_MD("get_collision_pos"),&KinematicBody::get_collision_pos);
- ObjectTypeDB::bind_method(_MD("get_collision_normal"),&KinematicBody::get_collision_normal);
- ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&KinematicBody::get_collider_velocity);
- ObjectTypeDB::bind_method(_MD("get_collider:Variant"),&KinematicBody::_get_collider);
- ObjectTypeDB::bind_method(_MD("get_collider_shape"),&KinematicBody::get_collider_shape);
+ ObjectTypeDB::bind_method(_MD("can_teleport_to", "position"), &KinematicBody::can_teleport_to);
+ ObjectTypeDB::bind_method(_MD("is_colliding"), &KinematicBody::is_colliding);
- ObjectTypeDB::bind_method(_MD("set_collide_with_static_bodies","enable"),&KinematicBody::set_collide_with_static_bodies);
- ObjectTypeDB::bind_method(_MD("can_collide_with_static_bodies"),&KinematicBody::can_collide_with_static_bodies);
+ ObjectTypeDB::bind_method(_MD("get_collision_pos"), &KinematicBody::get_collision_pos);
+ ObjectTypeDB::bind_method(_MD("get_collision_normal"), &KinematicBody::get_collision_normal);
+ ObjectTypeDB::bind_method(_MD("get_collider_velocity"), &KinematicBody::get_collider_velocity);
+ ObjectTypeDB::bind_method(_MD("get_collider:Variant"), &KinematicBody::_get_collider);
+ ObjectTypeDB::bind_method(_MD("get_collider_shape"), &KinematicBody::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("set_collide_with_kinematic_bodies","enable"),&KinematicBody::set_collide_with_kinematic_bodies);
- ObjectTypeDB::bind_method(_MD("can_collide_with_kinematic_bodies"),&KinematicBody::can_collide_with_kinematic_bodies);
+ ObjectTypeDB::bind_method(_MD("set_collide_with_static_bodies", "enable"), &KinematicBody::set_collide_with_static_bodies);
+ ObjectTypeDB::bind_method(_MD("can_collide_with_static_bodies"), &KinematicBody::can_collide_with_static_bodies);
- ObjectTypeDB::bind_method(_MD("set_collide_with_rigid_bodies","enable"),&KinematicBody::set_collide_with_rigid_bodies);
- ObjectTypeDB::bind_method(_MD("can_collide_with_rigid_bodies"),&KinematicBody::can_collide_with_rigid_bodies);
+ ObjectTypeDB::bind_method(_MD("set_collide_with_kinematic_bodies", "enable"), &KinematicBody::set_collide_with_kinematic_bodies);
+ ObjectTypeDB::bind_method(_MD("can_collide_with_kinematic_bodies"), &KinematicBody::can_collide_with_kinematic_bodies);
- ObjectTypeDB::bind_method(_MD("set_collide_with_character_bodies","enable"),&KinematicBody::set_collide_with_character_bodies);
- ObjectTypeDB::bind_method(_MD("can_collide_with_character_bodies"),&KinematicBody::can_collide_with_character_bodies);
+ ObjectTypeDB::bind_method(_MD("set_collide_with_rigid_bodies", "enable"), &KinematicBody::set_collide_with_rigid_bodies);
+ ObjectTypeDB::bind_method(_MD("can_collide_with_rigid_bodies"), &KinematicBody::can_collide_with_rigid_bodies);
- ObjectTypeDB::bind_method(_MD("set_collision_margin","pixels"),&KinematicBody::set_collision_margin);
- ObjectTypeDB::bind_method(_MD("get_collision_margin","pixels"),&KinematicBody::get_collision_margin);
-
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/static"),_SCS("set_collide_with_static_bodies"),_SCS("can_collide_with_static_bodies"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/kinematic"),_SCS("set_collide_with_kinematic_bodies"),_SCS("can_collide_with_kinematic_bodies"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/rigid"),_SCS("set_collide_with_rigid_bodies"),_SCS("can_collide_with_rigid_bodies"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collide_with/character"),_SCS("set_collide_with_character_bodies"),_SCS("can_collide_with_character_bodies"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/margin",PROPERTY_HINT_RANGE,"0.001,256,0.001"),_SCS("set_collision_margin"),_SCS("get_collision_margin"));
+ ObjectTypeDB::bind_method(_MD("set_collide_with_character_bodies", "enable"), &KinematicBody::set_collide_with_character_bodies);
+ ObjectTypeDB::bind_method(_MD("can_collide_with_character_bodies"), &KinematicBody::can_collide_with_character_bodies);
+ ObjectTypeDB::bind_method(_MD("set_collision_margin", "pixels"), &KinematicBody::set_collision_margin);
+ ObjectTypeDB::bind_method(_MD("get_collision_margin", "pixels"), &KinematicBody::get_collision_margin);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with/static"), _SCS("set_collide_with_static_bodies"), _SCS("can_collide_with_static_bodies"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with/kinematic"), _SCS("set_collide_with_kinematic_bodies"), _SCS("can_collide_with_kinematic_bodies"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with/rigid"), _SCS("set_collide_with_rigid_bodies"), _SCS("can_collide_with_rigid_bodies"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with/character"), _SCS("set_collide_with_character_bodies"), _SCS("can_collide_with_character_bodies"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), _SCS("set_collision_margin"), _SCS("get_collision_margin"));
}
-KinematicBody::KinematicBody() : PhysicsBody(PhysicsServer::BODY_MODE_KINEMATIC){
+KinematicBody::KinematicBody()
+ : PhysicsBody(PhysicsServer::BODY_MODE_KINEMATIC) {
- collide_static=true;
- collide_rigid=true;
- collide_kinematic=true;
- collide_character=true;
+ collide_static = true;
+ collide_rigid = true;
+ collide_kinematic = true;
+ collide_character = true;
- colliding=false;
- collider=0;
- margin=0.001;
- collider_shape=0;
+ colliding = false;
+ collider = 0;
+ margin = 0.001;
+ collider_shape = 0;
}
-KinematicBody::~KinematicBody() {
-
-
+KinematicBody::~KinematicBody() {
}
-
-
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 1bb85929f..9b9efbe4b 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -33,10 +33,9 @@
#include "servers/physics_server.h"
#include "vset.h"
-
class PhysicsBody : public CollisionObject {
- OBJ_TYPE(PhysicsBody,CollisionObject);
+ OBJ_TYPE(PhysicsBody, CollisionObject);
uint32_t layer_mask;
uint32_t collision_mask;
@@ -45,12 +44,11 @@ class PhysicsBody : public CollisionObject {
uint32_t _get_layers() const;
protected:
-
static void _bind_methods();
void _notification(int p_what);
PhysicsBody(PhysicsServer::BodyMode p_mode);
-public:
+public:
virtual Vector3 get_linear_velocity() const;
virtual Vector3 get_angular_velocity() const;
virtual float get_inverse_mass() const;
@@ -67,18 +65,15 @@ public:
void set_collision_mask_bit(int p_bit, bool p_value);
bool get_collision_mask_bit(int p_bit) const;
- void add_collision_exception_with(Node* p_node); //must be physicsbody
- void remove_collision_exception_with(Node* p_node);
-
-
+ void add_collision_exception_with(Node *p_node); //must be physicsbody
+ void remove_collision_exception_with(Node *p_node);
PhysicsBody();
-
};
class StaticBody : public PhysicsBody {
- OBJ_TYPE(StaticBody,PhysicsBody);
+ OBJ_TYPE(StaticBody, PhysicsBody);
Vector3 constant_linear_velocity;
Vector3 constant_angular_velocity;
@@ -86,37 +81,31 @@ class StaticBody : public PhysicsBody {
real_t bounce;
real_t friction;
-
protected:
-
static void _bind_methods();
public:
-
-
void set_friction(real_t p_friction);
real_t get_friction() const;
void set_bounce(real_t p_bounce);
real_t get_bounce() const;
-
- void set_constant_linear_velocity(const Vector3& p_vel);
- void set_constant_angular_velocity(const Vector3& p_vel);
+ void set_constant_linear_velocity(const Vector3 &p_vel);
+ void set_constant_angular_velocity(const Vector3 &p_vel);
Vector3 get_constant_linear_velocity() const;
Vector3 get_constant_angular_velocity() const;
StaticBody();
~StaticBody();
-
};
class RigidBody : public PhysicsBody {
- OBJ_TYPE(RigidBody,PhysicsBody);
-public:
+ OBJ_TYPE(RigidBody, PhysicsBody);
+public:
enum Mode {
MODE_RIGID,
MODE_STATIC,
@@ -132,7 +121,6 @@ public:
};
private:
-
bool can_sleep;
PhysicsDirectBodyState *state;
Mode mode;
@@ -142,7 +130,7 @@ private:
real_t friction;
Vector3 linear_velocity;
- Vector3 angular_velocity;
+ Vector3 angular_velocity;
real_t gravity_scale;
real_t linear_damp;
real_t angular_damp;
@@ -152,33 +140,32 @@ private:
AxisLock axis_lock;
-
int max_contacts_reported;
bool custom_integrator;
-
struct ShapePair {
int body_shape;
int local_shape;
bool tagged;
- bool operator<(const ShapePair& p_sp) const {
- if (body_shape==p_sp.body_shape)
+ bool operator<(const ShapePair &p_sp) const {
+ if (body_shape == p_sp.body_shape)
return local_shape < p_sp.local_shape;
else
return body_shape < p_sp.body_shape;
}
ShapePair() {}
- ShapePair(int p_bs, int p_ls) { body_shape=p_bs; local_shape=p_ls; }
+ ShapePair(int p_bs, int p_ls) {
+ body_shape = p_bs;
+ local_shape = p_ls;
+ }
};
struct RigidBody_RemoveAction {
-
ObjectID body_id;
ShapePair pair;
-
};
struct BodyState {
@@ -190,33 +177,28 @@ private:
struct ContactMonitor {
bool locked;
- Map<ObjectID,BodyState> body_map;
-
+ Map<ObjectID, BodyState> body_map;
};
-
ContactMonitor *contact_monitor;
void _body_enter_tree(ObjectID p_id);
void _body_exit_tree(ObjectID p_id);
-
- void _body_inout(int p_status, ObjectID p_instance, int p_body_shape,int p_local_shape);
+ void _body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape);
void _direct_state_changed(Object *p_state);
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_mode(Mode p_mode);
Mode get_mode() const;
void set_mass(real_t p_mass);
real_t get_mass() const;
- virtual float get_inverse_mass() const { return 1.0/mass; }
+ virtual float get_inverse_mass() const { return 1.0 / mass; }
void set_weight(real_t p_weight);
real_t get_weight() const;
@@ -227,13 +209,13 @@ public:
void set_bounce(real_t p_bounce);
real_t get_bounce() const;
- void set_linear_velocity(const Vector3& p_velocity);
+ void set_linear_velocity(const Vector3 &p_velocity);
Vector3 get_linear_velocity() const;
- void set_axis_velocity(const Vector3& p_axis);
+ void set_axis_velocity(const Vector3 &p_axis);
- void set_angular_velocity(const Vector3&p_velocity);
- Vector3 get_angular_velocity() const;
+ void set_angular_velocity(const Vector3 &p_velocity);
+ Vector3 get_angular_velocity() const;
void set_gravity_scale(real_t p_gravity_scale);
real_t get_gravity_scale() const;
@@ -244,7 +226,6 @@ public:
void set_angular_damp(real_t p_angular_damp);
real_t get_angular_damp() const;
-
void set_use_custom_integrator(bool p_enable);
bool is_using_custom_integrator();
@@ -268,23 +249,18 @@ public:
Array get_colliding_bodies() const;
- void apply_impulse(const Vector3& p_pos, const Vector3& p_impulse);
+ void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
RigidBody();
~RigidBody();
-
};
VARIANT_ENUM_CAST(RigidBody::Mode);
VARIANT_ENUM_CAST(RigidBody::AxisLock);
-
-
-
-
class KinematicBody : public PhysicsBody {
- OBJ_TYPE(KinematicBody,PhysicsBody);
+ OBJ_TYPE(KinematicBody, PhysicsBody);
float margin;
bool collide_static;
@@ -299,26 +275,24 @@ class KinematicBody : public PhysicsBody {
ObjectID collider;
int collider_shape;
-
-
Variant _get_collider() const;
_FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const;
-protected:
+protected:
static void _bind_methods();
-public:
+public:
enum {
SLIDE_FLAG_FLOOR,
SLIDE_FLAG_WALL,
SLIDE_FLAG_ROOF
};
- Vector3 move(const Vector3& p_motion);
- Vector3 move_to(const Vector3& p_position);
+ Vector3 move(const Vector3 &p_motion);
+ Vector3 move_to(const Vector3 &p_position);
- bool can_teleport_to(const Vector3& p_position);
+ bool can_teleport_to(const Vector3 &p_position);
bool is_colliding() const;
Vector3 get_collision_pos() const;
Vector3 get_collision_normal() const;
@@ -343,7 +317,6 @@ public:
KinematicBody();
~KinematicBody();
-
};
#endif // PHYSICS_BODY__H
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index d9fed63e1..d2d73df5b 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -28,101 +28,89 @@
/*************************************************************************/
#include "physics_joint.h"
-
-
void Joint::_update_joint(bool p_only_free) {
-
if (joint.is_valid()) {
if (ba.is_valid() && bb.is_valid()) {
if (exclude_from_collision)
- PhysicsServer::get_singleton()->body_add_collision_exception(ba,bb);
+ PhysicsServer::get_singleton()->body_add_collision_exception(ba, bb);
else
- PhysicsServer::get_singleton()->body_remove_collision_exception(ba,bb);
-
+ PhysicsServer::get_singleton()->body_remove_collision_exception(ba, bb);
}
PhysicsServer::get_singleton()->free(joint);
- joint=RID();
- ba=RID();
- bb=RID();
+ joint = RID();
+ ba = RID();
+ bb = RID();
}
if (p_only_free || !is_inside_tree())
return;
- Node *node_a = has_node( get_node_a() ) ? get_node( get_node_a() ) : (Node*)NULL;
- Node *node_b = has_node( get_node_b() ) ? get_node( get_node_b() ) : (Node*)NULL;
+ Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
+ Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
if (!node_a && !node_b)
return;
- PhysicsBody *body_a=node_a ? node_a->cast_to<PhysicsBody>() : (PhysicsBody*)NULL;
- PhysicsBody *body_b=node_b ? node_b->cast_to<PhysicsBody>() : (PhysicsBody*)NULL;
+ PhysicsBody *body_a = node_a ? node_a->cast_to<PhysicsBody>() : (PhysicsBody *)NULL;
+ PhysicsBody *body_b = node_b ? node_b->cast_to<PhysicsBody>() : (PhysicsBody *)NULL;
if (!body_a && !body_b)
return;
if (!body_a) {
- SWAP(body_a,body_b);
+ SWAP(body_a, body_b);
} else if (body_b) {
//add a collision exception between both
- PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
}
- joint = _configure_joint(body_a,body_b);
+ joint = _configure_joint(body_a, body_b);
if (joint.is_valid())
- PhysicsServer::get_singleton()->joint_set_solver_priority(joint,solver_priority);
+ PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
if (body_b && joint.is_valid()) {
- ba=body_a->get_rid();
- bb=body_b->get_rid();
- PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
-
+ ba = body_a->get_rid();
+ bb = body_b->get_rid();
+ PhysicsServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
}
-
}
+void Joint::set_node_a(const NodePath &p_node_a) {
-void Joint::set_node_a(const NodePath& p_node_a) {
-
-
- if (a==p_node_a)
+ if (a == p_node_a)
return;
- a=p_node_a;
+ a = p_node_a;
_update_joint();
}
-NodePath Joint::get_node_a() const{
+NodePath Joint::get_node_a() const {
return a;
}
-void Joint::set_node_b(const NodePath& p_node_b){
+void Joint::set_node_b(const NodePath &p_node_b) {
- if (b==p_node_b)
+ if (b == p_node_b)
return;
- b=p_node_b;
+ b = p_node_b;
_update_joint();
-
}
-NodePath Joint::get_node_b() const{
-
+NodePath Joint::get_node_b() const {
return b;
}
-
void Joint::set_solver_priority(int p_priority) {
- solver_priority=p_priority;
+ solver_priority = p_priority;
if (joint.is_valid())
- PhysicsServer::get_singleton()->joint_set_solver_priority(joint,solver_priority);
-
+ PhysicsServer::get_singleton()->joint_set_solver_priority(joint, solver_priority);
}
int Joint::get_solver_priority() const {
@@ -130,10 +118,9 @@ int Joint::get_solver_priority() const {
return solver_priority;
}
-
void Joint::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
_update_joint();
@@ -142,94 +129,82 @@ void Joint::_notification(int p_what) {
if (joint.is_valid()) {
_update_joint(true);
//PhysicsServer::get_singleton()->free(joint);
- joint=RID();
+ joint = RID();
}
} break;
-
}
-
}
-
void Joint::set_exclude_nodes_from_collision(bool p_enable) {
- if (exclude_from_collision==p_enable)
+ if (exclude_from_collision == p_enable)
return;
- exclude_from_collision=p_enable;
+ exclude_from_collision = p_enable;
_update_joint();
}
-bool Joint::get_exclude_nodes_from_collision() const{
+bool Joint::get_exclude_nodes_from_collision() const {
return exclude_from_collision;
}
void Joint::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_node_a", "node"), &Joint::set_node_a);
+ ObjectTypeDB::bind_method(_MD("get_node_a"), &Joint::get_node_a);
- ObjectTypeDB::bind_method( _MD("set_node_a","node"), &Joint::set_node_a );
- ObjectTypeDB::bind_method( _MD("get_node_a"), &Joint::get_node_a );
-
- ObjectTypeDB::bind_method( _MD("set_node_b","node"), &Joint::set_node_b );
- ObjectTypeDB::bind_method( _MD("get_node_b"), &Joint::get_node_b );
-
- ObjectTypeDB::bind_method( _MD("set_solver_priority","priority"), &Joint::set_solver_priority );
- ObjectTypeDB::bind_method( _MD("get_solver_priority"), &Joint::get_solver_priority );
-
- ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint::set_exclude_nodes_from_collision );
- ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision );
-
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "solver/priority",PROPERTY_HINT_RANGE,"1,8,1"), _SCS("set_solver_priority"),_SCS("get_solver_priority") );
+ ObjectTypeDB::bind_method(_MD("set_node_b", "node"), &Joint::set_node_b);
+ ObjectTypeDB::bind_method(_MD("get_node_b"), &Joint::get_node_b);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") );
+ ObjectTypeDB::bind_method(_MD("set_solver_priority", "priority"), &Joint::set_solver_priority);
+ ObjectTypeDB::bind_method(_MD("get_solver_priority"), &Joint::get_solver_priority);
+ ObjectTypeDB::bind_method(_MD("set_exclude_nodes_from_collision", "enable"), &Joint::set_exclude_nodes_from_collision);
+ ObjectTypeDB::bind_method(_MD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision);
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "nodes/node_a"), _SCS("set_node_a"), _SCS("get_node_a"));
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "nodes/node_b"), _SCS("set_node_b"), _SCS("get_node_b"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "solver/priority", PROPERTY_HINT_RANGE, "1,8,1"), _SCS("set_solver_priority"), _SCS("get_solver_priority"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"), _SCS("get_exclude_nodes_from_collision"));
}
-
-
Joint::Joint() {
- exclude_from_collision=true;
- solver_priority=1;
+ exclude_from_collision = true;
+ solver_priority = 1;
}
-
///////////////////////////////////
void PinJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&PinJoint::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&PinJoint::get_param);
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &PinJoint::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &PinJoint::get_param);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_BIAS );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/damping",PROPERTY_HINT_RANGE,"0.01,8.0,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_DAMPING );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/impulse_clamp",PROPERTY_HINT_RANGE,"0.0,64.0,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_IMPULSE_CLAMP );
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_BIAS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/damping", PROPERTY_HINT_RANGE, "0.01,8.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/impulse_clamp", PROPERTY_HINT_RANGE, "0.0,64.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_IMPULSE_CLAMP);
- BIND_CONSTANT( PARAM_BIAS );
- BIND_CONSTANT( PARAM_DAMPING );
- BIND_CONSTANT( PARAM_IMPULSE_CLAMP );
+ BIND_CONSTANT(PARAM_BIAS);
+ BIND_CONSTANT(PARAM_DAMPING);
+ BIND_CONSTANT(PARAM_IMPULSE_CLAMP);
}
-void PinJoint::set_param(Param p_param,float p_value){
+void PinJoint::set_param(Param p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,3);
- params[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, 3);
+ params[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->pin_joint_set_param(get_joint(),PhysicsServer::PinJointParam(p_param),p_value);
+ PhysicsServer::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer::PinJointParam(p_param), p_value);
}
-float PinJoint::get_param(Param p_param) const{
+float PinJoint::get_param(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,3,0);
+ ERR_FAIL_INDEX_V(p_param, 3, 0);
return params[p_param];
}
-
-RID PinJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
-
+RID PinJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
Vector3 pinpos = get_global_transform().origin;
Vector3 local_a = body_a->get_global_transform().affine_inverse().xform(pinpos);
@@ -238,37 +213,29 @@ RID PinJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
if (body_b)
local_b = body_b->get_global_transform().affine_inverse().xform(pinpos);
else
- local_b=pinpos;
+ local_b = pinpos;
- RID j = PhysicsServer::get_singleton()->joint_create_pin(body_a->get_rid(),local_a,body_b?body_b->get_rid():RID(),local_b);
- for(int i=0;i<3;i++) {
- PhysicsServer::get_singleton()->pin_joint_set_param(j,PhysicsServer::PinJointParam(i),params[i]);
+ RID j = PhysicsServer::get_singleton()->joint_create_pin(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ for (int i = 0; i < 3; i++) {
+ PhysicsServer::get_singleton()->pin_joint_set_param(j, PhysicsServer::PinJointParam(i), params[i]);
}
return j;
}
-
PinJoint::PinJoint() {
- params[PARAM_BIAS]=0.3;
- params[PARAM_DAMPING]=1;
- params[PARAM_IMPULSE_CLAMP]=0;
-
+ params[PARAM_BIAS] = 0.3;
+ params[PARAM_DAMPING] = 1;
+ params[PARAM_IMPULSE_CLAMP] = 0;
}
-
-
-
/////////////////////////////////////////////////
-
-
///////////////////////////////////
-
void HingeJoint::_set_upper_limit(float p_limit) {
- set_param(PARAM_LIMIT_UPPER,Math::deg2rad(p_limit));
+ set_param(PARAM_LIMIT_UPPER, Math::deg2rad(p_limit));
}
float HingeJoint::_get_upper_limit() const {
@@ -278,95 +245,87 @@ float HingeJoint::_get_upper_limit() const {
void HingeJoint::_set_lower_limit(float p_limit) {
- set_param(PARAM_LIMIT_LOWER,Math::deg2rad(p_limit));
-
+ set_param(PARAM_LIMIT_LOWER, Math::deg2rad(p_limit));
}
float HingeJoint::_get_lower_limit() const {
return Math::rad2deg(get_param(PARAM_LIMIT_LOWER));
-
}
-
void HingeJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&HingeJoint::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&HingeJoint::get_param);
-
- ObjectTypeDB::bind_method(_MD("set_flag","flag","enabled"),&HingeJoint::set_flag);
- ObjectTypeDB::bind_method(_MD("get_flag","flag"),&HingeJoint::get_flag);
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &HingeJoint::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &HingeJoint::get_param);
- ObjectTypeDB::bind_method(_MD("_set_upper_limit","upper_limit"),&HingeJoint::_set_upper_limit);
- ObjectTypeDB::bind_method(_MD("_get_upper_limit"),&HingeJoint::_get_upper_limit);
+ ObjectTypeDB::bind_method(_MD("set_flag", "flag", "enabled"), &HingeJoint::set_flag);
+ ObjectTypeDB::bind_method(_MD("get_flag", "flag"), &HingeJoint::get_flag);
- ObjectTypeDB::bind_method(_MD("_set_lower_limit","lower_limit"),&HingeJoint::_set_lower_limit);
- ObjectTypeDB::bind_method(_MD("_get_lower_limit"),&HingeJoint::_get_lower_limit);
+ ObjectTypeDB::bind_method(_MD("_set_upper_limit", "upper_limit"), &HingeJoint::_set_upper_limit);
+ ObjectTypeDB::bind_method(_MD("_get_upper_limit"), &HingeJoint::_get_upper_limit);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"params/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_BIAS );
+ ObjectTypeDB::bind_method(_MD("_set_lower_limit", "lower_limit"), &HingeJoint::_set_lower_limit);
+ ObjectTypeDB::bind_method(_MD("_get_lower_limit"), &HingeJoint::_get_lower_limit);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"angular_limit/enable"),_SCS("set_flag"),_SCS("get_flag"), FLAG_USE_LIMIT );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/upper",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_upper_limit"),_SCS("_get_upper_limit") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/lower",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_lower_limit"),_SCS("_get_lower_limit") );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/bias",PROPERTY_HINT_RANGE,"0.01,0.99,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LIMIT_BIAS );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LIMIT_SOFTNESS );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/relaxation",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LIMIT_RELAXATION );
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_BIAS);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"motor/enable"),_SCS("set_flag"),_SCS("get_flag"), FLAG_ENABLE_MOTOR );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"motor/target_velocity",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_MOTOR_TARGET_VELOCITY );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"motor/max_impulse",PROPERTY_HINT_RANGE,"0.01,1024,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_MOTOR_MAX_IMPULSE);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit/enable"), _SCS("set_flag"), _SCS("get_flag"), FLAG_USE_LIMIT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit/upper", PROPERTY_HINT_RANGE, "-180,180,0.1"), _SCS("_set_upper_limit"), _SCS("_get_upper_limit"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit/lower", PROPERTY_HINT_RANGE, "-180,180,0.1"), _SCS("_set_lower_limit"), _SCS("_get_lower_limit"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LIMIT_BIAS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit/relaxation", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LIMIT_RELAXATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "motor/enable"), _SCS("set_flag"), _SCS("get_flag"), FLAG_ENABLE_MOTOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "motor/target_velocity", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_MOTOR_TARGET_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "motor/max_impulse", PROPERTY_HINT_RANGE, "0.01,1024,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_MOTOR_MAX_IMPULSE);
- BIND_CONSTANT( PARAM_BIAS );
- BIND_CONSTANT( PARAM_LIMIT_UPPER );
- BIND_CONSTANT( PARAM_LIMIT_LOWER );
- BIND_CONSTANT( PARAM_LIMIT_BIAS );
- BIND_CONSTANT( PARAM_LIMIT_SOFTNESS );
- BIND_CONSTANT( PARAM_LIMIT_RELAXATION );
- BIND_CONSTANT( PARAM_MOTOR_TARGET_VELOCITY );
- BIND_CONSTANT( PARAM_MOTOR_MAX_IMPULSE );
- BIND_CONSTANT( PARAM_MAX );
-
- BIND_CONSTANT( FLAG_USE_LIMIT );
- BIND_CONSTANT( FLAG_ENABLE_MOTOR );
- BIND_CONSTANT( FLAG_MAX );
+ BIND_CONSTANT(PARAM_BIAS);
+ BIND_CONSTANT(PARAM_LIMIT_UPPER);
+ BIND_CONSTANT(PARAM_LIMIT_LOWER);
+ BIND_CONSTANT(PARAM_LIMIT_BIAS);
+ BIND_CONSTANT(PARAM_LIMIT_SOFTNESS);
+ BIND_CONSTANT(PARAM_LIMIT_RELAXATION);
+ BIND_CONSTANT(PARAM_MOTOR_TARGET_VELOCITY);
+ BIND_CONSTANT(PARAM_MOTOR_MAX_IMPULSE);
+ BIND_CONSTANT(PARAM_MAX);
+ BIND_CONSTANT(FLAG_USE_LIMIT);
+ BIND_CONSTANT(FLAG_ENABLE_MOTOR);
+ BIND_CONSTANT(FLAG_MAX);
}
-void HingeJoint::set_param(Param p_param,float p_value){
+void HingeJoint::set_param(Param p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_param(get_joint(),PhysicsServer::HingeJointParam(p_param),p_value);
+ PhysicsServer::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer::HingeJointParam(p_param), p_value);
update_gizmo();
-
}
-float HingeJoint::get_param(Param p_param) const{
+float HingeJoint::get_param(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
+void HingeJoint::set_flag(Flag p_flag, bool p_value) {
-void HingeJoint::set_flag(Flag p_flag,bool p_value){
-
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags[p_flag]=p_value;
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ flags[p_flag] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->hinge_joint_set_flag(get_joint(),PhysicsServer::HingeJointFlag(p_flag),p_value);
+ PhysicsServer::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer::HingeJointFlag(p_flag), p_value);
update_gizmo();
}
-bool HingeJoint::get_flag(Flag p_flag) const{
+bool HingeJoint::get_flag(Flag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags[p_flag];
}
-RID HingeJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
-
+RID HingeJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
Transform gt = get_global_transform();
Transform ainv = body_a->get_global_transform().affine_inverse();
@@ -382,48 +341,39 @@ RID HingeJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
local_b.orthonormalize();
- RID j = PhysicsServer::get_singleton()->joint_create_hinge(body_a->get_rid(),local_a,body_b?body_b->get_rid():RID(),local_b);
- for(int i=0;i<PARAM_MAX;i++) {
- PhysicsServer::get_singleton()->hinge_joint_set_param(j,PhysicsServer::HingeJointParam(i),params[i]);
+ RID j = PhysicsServer::get_singleton()->joint_create_hinge(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ for (int i = 0; i < PARAM_MAX; i++) {
+ PhysicsServer::get_singleton()->hinge_joint_set_param(j, PhysicsServer::HingeJointParam(i), params[i]);
}
- for(int i=0;i<FLAG_MAX;i++) {
- set_flag(Flag(i),flags[i]);
- PhysicsServer::get_singleton()->hinge_joint_set_flag(j,PhysicsServer::HingeJointFlag(i),flags[i]);
+ for (int i = 0; i < FLAG_MAX; i++) {
+ set_flag(Flag(i), flags[i]);
+ PhysicsServer::get_singleton()->hinge_joint_set_flag(j, PhysicsServer::HingeJointFlag(i), flags[i]);
}
return j;
}
-
HingeJoint::HingeJoint() {
- params[PARAM_BIAS]=0.3;
- params[PARAM_LIMIT_UPPER]=Math_PI*0.5;
- params[PARAM_LIMIT_LOWER]=-Math_PI*0.5;
- params[PARAM_LIMIT_BIAS]=0.3;
- params[PARAM_LIMIT_SOFTNESS]=0.9;
- params[PARAM_LIMIT_RELAXATION]=1.0;
- params[PARAM_MOTOR_TARGET_VELOCITY]=1;
- params[PARAM_MOTOR_MAX_IMPULSE]=1;
-
-
- flags[FLAG_USE_LIMIT]=false;
- flags[FLAG_ENABLE_MOTOR]=false;
+ params[PARAM_BIAS] = 0.3;
+ params[PARAM_LIMIT_UPPER] = Math_PI * 0.5;
+ params[PARAM_LIMIT_LOWER] = -Math_PI * 0.5;
+ params[PARAM_LIMIT_BIAS] = 0.3;
+ params[PARAM_LIMIT_SOFTNESS] = 0.9;
+ params[PARAM_LIMIT_RELAXATION] = 1.0;
+ params[PARAM_MOTOR_TARGET_VELOCITY] = 1;
+ params[PARAM_MOTOR_MAX_IMPULSE] = 1;
+ flags[FLAG_USE_LIMIT] = false;
+ flags[FLAG_ENABLE_MOTOR] = false;
}
-
-
-
/////////////////////////////////////////////////
-
//////////////////////////////////
-
-
void SliderJoint::_set_upper_limit_angular(float p_limit_angular) {
- set_param(PARAM_ANGULAR_LIMIT_UPPER,Math::deg2rad(p_limit_angular));
+ set_param(PARAM_ANGULAR_LIMIT_UPPER, Math::deg2rad(p_limit_angular));
}
float SliderJoint::_get_upper_limit_angular() const {
@@ -433,100 +383,91 @@ float SliderJoint::_get_upper_limit_angular() const {
void SliderJoint::_set_lower_limit_angular(float p_limit_angular) {
- set_param(PARAM_ANGULAR_LIMIT_LOWER,Math::deg2rad(p_limit_angular));
-
+ set_param(PARAM_ANGULAR_LIMIT_LOWER, Math::deg2rad(p_limit_angular));
}
float SliderJoint::_get_lower_limit_angular() const {
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_LOWER));
-
}
-
void SliderJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SliderJoint::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&SliderJoint::get_param);
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &SliderJoint::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &SliderJoint::get_param);
+ ObjectTypeDB::bind_method(_MD("_set_upper_limit_angular", "upper_limit_angular"), &SliderJoint::_set_upper_limit_angular);
+ ObjectTypeDB::bind_method(_MD("_get_upper_limit_angular"), &SliderJoint::_get_upper_limit_angular);
- ObjectTypeDB::bind_method(_MD("_set_upper_limit_angular","upper_limit_angular"),&SliderJoint::_set_upper_limit_angular);
- ObjectTypeDB::bind_method(_MD("_get_upper_limit_angular"),&SliderJoint::_get_upper_limit_angular);
+ ObjectTypeDB::bind_method(_MD("_set_lower_limit_angular", "lower_limit_angular"), &SliderJoint::_set_lower_limit_angular);
+ ObjectTypeDB::bind_method(_MD("_get_lower_limit_angular"), &SliderJoint::_get_lower_limit_angular);
- ObjectTypeDB::bind_method(_MD("_set_lower_limit_angular","lower_limit_angular"),&SliderJoint::_set_lower_limit_angular);
- ObjectTypeDB::bind_method(_MD("_get_lower_limit_angular"),&SliderJoint::_get_lower_limit_angular);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit/upper_distance", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_LIMIT_UPPER);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit/lower_distance", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_LIMIT_LOWER);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_LIMIT_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_LIMIT_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_motion/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_MOTION_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_motion/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_MOTION_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_motion/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_MOTION_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_ortho/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_ortho/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_ortho/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_DAMPING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.1"), _SCS("_set_upper_limit_angular"), _SCS("_get_upper_limit_angular"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.1"), _SCS("_set_lower_limit_angular"), _SCS("_get_lower_limit_angular"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_LIMIT_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_LIMIT_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motion/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_MOTION_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motion/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_MOTION_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motion/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_MOTION_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_ortho/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_ortho/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_ortho/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/upper_distance",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_UPPER);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/lower_distance",PROPERTY_HINT_RANGE,"-1024,1024,0.01"),_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_LOWER);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_limit/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_LIMIT_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_MOTION_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_MOTION_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_motion/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_MOTION_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"linear_ortho/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_LINEAR_ORTHOGONAL_DAMPING);
+ BIND_CONSTANT(PARAM_LINEAR_LIMIT_UPPER);
+ BIND_CONSTANT(PARAM_LINEAR_LIMIT_LOWER);
+ BIND_CONSTANT(PARAM_LINEAR_LIMIT_SOFTNESS);
+ BIND_CONSTANT(PARAM_LINEAR_LIMIT_RESTITUTION);
+ BIND_CONSTANT(PARAM_LINEAR_LIMIT_DAMPING);
+ BIND_CONSTANT(PARAM_LINEAR_MOTION_SOFTNESS);
+ BIND_CONSTANT(PARAM_LINEAR_MOTION_RESTITUTION);
+ BIND_CONSTANT(PARAM_LINEAR_MOTION_DAMPING);
+ BIND_CONSTANT(PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
+ BIND_CONSTANT(PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
+ BIND_CONSTANT(PARAM_LINEAR_ORTHOGONAL_DAMPING);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_upper_limit_angular"),_SCS("_get_upper_limit_angular") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"angular_limit/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_lower_limit_angular"),_SCS("_get_lower_limit_angular") );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_LIMIT_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_limit/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_LIMIT_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_MOTION_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_MOTION_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_motion/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_MOTION_DAMPING);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/restitution",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"angular_ortho/damping",PROPERTY_HINT_RANGE,"0,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_ANGULAR_ORTHOGONAL_DAMPING);
+ BIND_CONSTANT(PARAM_ANGULAR_LIMIT_UPPER);
+ BIND_CONSTANT(PARAM_ANGULAR_LIMIT_LOWER);
+ BIND_CONSTANT(PARAM_ANGULAR_LIMIT_SOFTNESS);
+ BIND_CONSTANT(PARAM_ANGULAR_LIMIT_RESTITUTION);
+ BIND_CONSTANT(PARAM_ANGULAR_LIMIT_DAMPING);
+ BIND_CONSTANT(PARAM_ANGULAR_MOTION_SOFTNESS);
+ BIND_CONSTANT(PARAM_ANGULAR_MOTION_RESTITUTION);
+ BIND_CONSTANT(PARAM_ANGULAR_MOTION_DAMPING);
+ BIND_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
+ BIND_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
+ BIND_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_DAMPING);
-
- BIND_CONSTANT( PARAM_LINEAR_LIMIT_UPPER);
- BIND_CONSTANT( PARAM_LINEAR_LIMIT_LOWER);
- BIND_CONSTANT( PARAM_LINEAR_LIMIT_SOFTNESS);
- BIND_CONSTANT( PARAM_LINEAR_LIMIT_RESTITUTION);
- BIND_CONSTANT( PARAM_LINEAR_LIMIT_DAMPING);
- BIND_CONSTANT( PARAM_LINEAR_MOTION_SOFTNESS);
- BIND_CONSTANT( PARAM_LINEAR_MOTION_RESTITUTION);
- BIND_CONSTANT( PARAM_LINEAR_MOTION_DAMPING);
- BIND_CONSTANT( PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
- BIND_CONSTANT( PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
- BIND_CONSTANT( PARAM_LINEAR_ORTHOGONAL_DAMPING);
-
- BIND_CONSTANT( PARAM_ANGULAR_LIMIT_UPPER);
- BIND_CONSTANT( PARAM_ANGULAR_LIMIT_LOWER);
- BIND_CONSTANT( PARAM_ANGULAR_LIMIT_SOFTNESS);
- BIND_CONSTANT( PARAM_ANGULAR_LIMIT_RESTITUTION);
- BIND_CONSTANT( PARAM_ANGULAR_LIMIT_DAMPING);
- BIND_CONSTANT( PARAM_ANGULAR_MOTION_SOFTNESS);
- BIND_CONSTANT( PARAM_ANGULAR_MOTION_RESTITUTION);
- BIND_CONSTANT( PARAM_ANGULAR_MOTION_DAMPING);
- BIND_CONSTANT( PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
- BIND_CONSTANT( PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
- BIND_CONSTANT( PARAM_ANGULAR_ORTHOGONAL_DAMPING);
-
- BIND_CONSTANT( PARAM_MAX);
+ BIND_CONSTANT(PARAM_MAX);
}
-void SliderJoint::set_param(Param p_param,float p_value){
+void SliderJoint::set_param(Param p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->slider_joint_set_param(get_joint(),PhysicsServer::SliderJointParam(p_param),p_value);
+ PhysicsServer::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer::SliderJointParam(p_param), p_value);
update_gizmo();
-
}
-float SliderJoint::get_param(Param p_param) const{
+float SliderJoint::get_param(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
-
-RID SliderJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
-
+RID SliderJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
Transform gt = get_global_transform();
Transform ainv = body_a->get_global_transform().affine_inverse();
@@ -542,53 +483,46 @@ RID SliderJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
local_b.orthonormalize();
- RID j = PhysicsServer::get_singleton()->joint_create_slider(body_a->get_rid(),local_a,body_b?body_b->get_rid():RID(),local_b);
- for(int i=0;i<PARAM_MAX;i++) {
- PhysicsServer::get_singleton()->slider_joint_set_param(j,PhysicsServer::SliderJointParam(i),params[i]);
+ RID j = PhysicsServer::get_singleton()->joint_create_slider(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ for (int i = 0; i < PARAM_MAX; i++) {
+ PhysicsServer::get_singleton()->slider_joint_set_param(j, PhysicsServer::SliderJointParam(i), params[i]);
}
return j;
}
-
SliderJoint::SliderJoint() {
+ params[PARAM_LINEAR_LIMIT_UPPER] = 1.0;
+ params[PARAM_LINEAR_LIMIT_LOWER] = -1.0;
+ params[PARAM_LINEAR_LIMIT_SOFTNESS] = 1.0;
+ params[PARAM_LINEAR_LIMIT_RESTITUTION] = 0.7;
+ params[PARAM_LINEAR_LIMIT_DAMPING] = 1.0;
+ params[PARAM_LINEAR_MOTION_SOFTNESS] = 1.0;
+ params[PARAM_LINEAR_MOTION_RESTITUTION] = 0.7;
+ params[PARAM_LINEAR_MOTION_DAMPING] = 0; //1.0;
+ params[PARAM_LINEAR_ORTHOGONAL_SOFTNESS] = 1.0;
+ params[PARAM_LINEAR_ORTHOGONAL_RESTITUTION] = 0.7;
+ params[PARAM_LINEAR_ORTHOGONAL_DAMPING] = 1.0;
-
- params[ PARAM_LINEAR_LIMIT_UPPER ]=1.0;
- params[ PARAM_LINEAR_LIMIT_LOWER ]=-1.0;
- params[ PARAM_LINEAR_LIMIT_SOFTNESS ]=1.0;
- params[ PARAM_LINEAR_LIMIT_RESTITUTION]=0.7;
- params[ PARAM_LINEAR_LIMIT_DAMPING]=1.0;
- params[ PARAM_LINEAR_MOTION_SOFTNESS ]=1.0;
- params[ PARAM_LINEAR_MOTION_RESTITUTION]=0.7;
- params[ PARAM_LINEAR_MOTION_DAMPING]=0;//1.0;
- params[ PARAM_LINEAR_ORTHOGONAL_SOFTNESS ]=1.0;
- params[ PARAM_LINEAR_ORTHOGONAL_RESTITUTION]=0.7;
- params[ PARAM_LINEAR_ORTHOGONAL_DAMPING]=1.0;
-
- params[ PARAM_ANGULAR_LIMIT_UPPER ]=0 ;
- params[ PARAM_ANGULAR_LIMIT_LOWER ]=0 ;
- params[ PARAM_ANGULAR_LIMIT_SOFTNESS ]=1.0;
- params[ PARAM_ANGULAR_LIMIT_RESTITUTION]=0.7;
- params[ PARAM_ANGULAR_LIMIT_DAMPING]=0;//1.0;
- params[ PARAM_ANGULAR_MOTION_SOFTNESS ]=1.0;
- params[ PARAM_ANGULAR_MOTION_RESTITUTION]=0.7;
- params[ PARAM_ANGULAR_MOTION_DAMPING]=1.0;
- params[ PARAM_ANGULAR_ORTHOGONAL_SOFTNESS ]=1.0;
- params[ PARAM_ANGULAR_ORTHOGONAL_RESTITUTION]=0.7;
- params[ PARAM_ANGULAR_ORTHOGONAL_DAMPING]=1.0;
+ params[PARAM_ANGULAR_LIMIT_UPPER] = 0;
+ params[PARAM_ANGULAR_LIMIT_LOWER] = 0;
+ params[PARAM_ANGULAR_LIMIT_SOFTNESS] = 1.0;
+ params[PARAM_ANGULAR_LIMIT_RESTITUTION] = 0.7;
+ params[PARAM_ANGULAR_LIMIT_DAMPING] = 0; //1.0;
+ params[PARAM_ANGULAR_MOTION_SOFTNESS] = 1.0;
+ params[PARAM_ANGULAR_MOTION_RESTITUTION] = 0.7;
+ params[PARAM_ANGULAR_MOTION_DAMPING] = 1.0;
+ params[PARAM_ANGULAR_ORTHOGONAL_SOFTNESS] = 1.0;
+ params[PARAM_ANGULAR_ORTHOGONAL_RESTITUTION] = 0.7;
+ params[PARAM_ANGULAR_ORTHOGONAL_DAMPING] = 1.0;
}
-
-
//////////////////////////////////
-
-
void ConeTwistJoint::_set_swing_span(float p_limit_angular) {
- set_param(PARAM_SWING_SPAN,Math::deg2rad(p_limit_angular));
+ set_param(PARAM_SWING_SPAN, Math::deg2rad(p_limit_angular));
}
float ConeTwistJoint::_get_swing_span() const {
@@ -598,64 +532,56 @@ float ConeTwistJoint::_get_swing_span() const {
void ConeTwistJoint::_set_twist_span(float p_limit_angular) {
- set_param(PARAM_TWIST_SPAN,Math::deg2rad(p_limit_angular));
-
+ set_param(PARAM_TWIST_SPAN, Math::deg2rad(p_limit_angular));
}
float ConeTwistJoint::_get_twist_span() const {
return Math::rad2deg(get_param(PARAM_TWIST_SPAN));
-
}
-
void ConeTwistJoint::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&ConeTwistJoint::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&ConeTwistJoint::get_param);
-
-
- ObjectTypeDB::bind_method(_MD("_set_swing_span","swing_span"),&ConeTwistJoint::_set_swing_span);
- ObjectTypeDB::bind_method(_MD("_get_swing_span"),&ConeTwistJoint::_get_swing_span);
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &ConeTwistJoint::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &ConeTwistJoint::get_param);
- ObjectTypeDB::bind_method(_MD("_set_twist_span","twist_span"),&ConeTwistJoint::_set_twist_span);
- ObjectTypeDB::bind_method(_MD("_get_twist_span"),&ConeTwistJoint::_get_twist_span);
+ ObjectTypeDB::bind_method(_MD("_set_swing_span", "swing_span"), &ConeTwistJoint::_set_swing_span);
+ ObjectTypeDB::bind_method(_MD("_get_swing_span"), &ConeTwistJoint::_get_swing_span);
+ ObjectTypeDB::bind_method(_MD("_set_twist_span", "twist_span"), &ConeTwistJoint::_set_twist_span);
+ ObjectTypeDB::bind_method(_MD("_get_twist_span"), &ConeTwistJoint::_get_twist_span);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"swing_span",PROPERTY_HINT_RANGE,"-180,180,0.1"),_SCS("_set_swing_span"),_SCS("_get_swing_span") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"twist_span",PROPERTY_HINT_RANGE,"-40000,40000,0.1"),_SCS("_set_twist_span"),_SCS("_get_twist_span") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "swing_span", PROPERTY_HINT_RANGE, "-180,180,0.1"), _SCS("_set_swing_span"), _SCS("_get_swing_span"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "twist_span", PROPERTY_HINT_RANGE, "-40000,40000,0.1"), _SCS("_set_twist_span"), _SCS("_get_twist_span"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "bias", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_BIAS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "relaxation", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_RELAXATION);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bias",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_BIAS );
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"softness",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_SOFTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"relaxation",PROPERTY_HINT_RANGE,"0.01,16.0,0.01") ,_SCS("set_param"),_SCS("get_param"), PARAM_RELAXATION);
-
- BIND_CONSTANT( PARAM_SWING_SPAN );
- BIND_CONSTANT( PARAM_TWIST_SPAN );
- BIND_CONSTANT( PARAM_BIAS );
- BIND_CONSTANT( PARAM_SOFTNESS );
- BIND_CONSTANT( PARAM_RELAXATION );
- BIND_CONSTANT( PARAM_MAX );
+ BIND_CONSTANT(PARAM_SWING_SPAN);
+ BIND_CONSTANT(PARAM_TWIST_SPAN);
+ BIND_CONSTANT(PARAM_BIAS);
+ BIND_CONSTANT(PARAM_SOFTNESS);
+ BIND_CONSTANT(PARAM_RELAXATION);
+ BIND_CONSTANT(PARAM_MAX);
}
-void ConeTwistJoint::set_param(Param p_param,float p_value){
+void ConeTwistJoint::set_param(Param p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(get_joint(),PhysicsServer::ConeTwistJointParam(p_param),p_value);
+ PhysicsServer::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer::ConeTwistJointParam(p_param), p_value);
update_gizmo();
}
-float ConeTwistJoint::get_param(Param p_param) const{
+float ConeTwistJoint::get_param(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
-
-RID ConeTwistJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
-
+RID ConeTwistJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
Transform gt = get_global_transform();
//Vector3 cone_twistpos = gt.origin;
@@ -674,311 +600,285 @@ RID ConeTwistJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
local_b.orthonormalize();
- RID j = PhysicsServer::get_singleton()->joint_create_cone_twist(body_a->get_rid(),local_a,body_b?body_b->get_rid():RID(),local_b);
- for(int i=0;i<PARAM_MAX;i++) {
- PhysicsServer::get_singleton()->cone_twist_joint_set_param(j,PhysicsServer::ConeTwistJointParam(i),params[i]);
+ RID j = PhysicsServer::get_singleton()->joint_create_cone_twist(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ for (int i = 0; i < PARAM_MAX; i++) {
+ PhysicsServer::get_singleton()->cone_twist_joint_set_param(j, PhysicsServer::ConeTwistJointParam(i), params[i]);
}
return j;
}
-
ConeTwistJoint::ConeTwistJoint() {
-
- params[ PARAM_SWING_SPAN ]=Math_PI*0.25;
- params[ PARAM_TWIST_SPAN ]=Math_PI;
- params[ PARAM_BIAS ]=0.3;
- params[ PARAM_SOFTNESS ]=0.8;
- params[ PARAM_RELAXATION ]=1.0;
-
+ params[PARAM_SWING_SPAN] = Math_PI * 0.25;
+ params[PARAM_TWIST_SPAN] = Math_PI;
+ params[PARAM_BIAS] = 0.3;
+ params[PARAM_SOFTNESS] = 0.8;
+ params[PARAM_RELAXATION] = 1.0;
}
/////////////////////////////////////////////////////////////////////
-
void Generic6DOFJoint::_set_angular_hi_limit_x(float p_limit_angular) {
- set_param_x(PARAM_ANGULAR_UPPER_LIMIT,Math::deg2rad(p_limit_angular));
+ set_param_x(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_hi_limit_x() const{
+float Generic6DOFJoint::_get_angular_hi_limit_x() const {
return Math::rad2deg(get_param_x(PARAM_ANGULAR_UPPER_LIMIT));
-
}
void Generic6DOFJoint::_set_angular_lo_limit_x(float p_limit_angular) {
- set_param_x(PARAM_ANGULAR_LOWER_LIMIT,Math::deg2rad(p_limit_angular));
+ set_param_x(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_lo_limit_x() const{
+float Generic6DOFJoint::_get_angular_lo_limit_x() const {
return Math::rad2deg(get_param_x(PARAM_ANGULAR_LOWER_LIMIT));
-
}
-
void Generic6DOFJoint::_set_angular_hi_limit_y(float p_limit_angular) {
- set_param_y(PARAM_ANGULAR_UPPER_LIMIT,Math::deg2rad(p_limit_angular));
+ set_param_y(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_hi_limit_y() const{
+float Generic6DOFJoint::_get_angular_hi_limit_y() const {
return Math::rad2deg(get_param_y(PARAM_ANGULAR_UPPER_LIMIT));
-
}
void Generic6DOFJoint::_set_angular_lo_limit_y(float p_limit_angular) {
- set_param_y(PARAM_ANGULAR_LOWER_LIMIT,Math::deg2rad(p_limit_angular));
+ set_param_y(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_lo_limit_y() const{
+float Generic6DOFJoint::_get_angular_lo_limit_y() const {
return Math::rad2deg(get_param_y(PARAM_ANGULAR_LOWER_LIMIT));
-
}
-
void Generic6DOFJoint::_set_angular_hi_limit_z(float p_limit_angular) {
- set_param_z(PARAM_ANGULAR_UPPER_LIMIT,Math::deg2rad(p_limit_angular));
+ set_param_z(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_hi_limit_z() const{
+float Generic6DOFJoint::_get_angular_hi_limit_z() const {
return Math::rad2deg(get_param_z(PARAM_ANGULAR_UPPER_LIMIT));
-
}
void Generic6DOFJoint::_set_angular_lo_limit_z(float p_limit_angular) {
- set_param_z(PARAM_ANGULAR_LOWER_LIMIT,Math::deg2rad(p_limit_angular));
+ set_param_z(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
}
-float Generic6DOFJoint::_get_angular_lo_limit_z() const{
+float Generic6DOFJoint::_get_angular_lo_limit_z() const {
return Math::rad2deg(get_param_z(PARAM_ANGULAR_LOWER_LIMIT));
-
}
+void Generic6DOFJoint::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_x", "angle"), &Generic6DOFJoint::_set_angular_hi_limit_x);
+ ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_x"), &Generic6DOFJoint::_get_angular_hi_limit_x);
-void Generic6DOFJoint::_bind_methods(){
-
+ ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_x", "angle"), &Generic6DOFJoint::_set_angular_lo_limit_x);
+ ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_x"), &Generic6DOFJoint::_get_angular_lo_limit_x);
- ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_x","angle"),&Generic6DOFJoint::_set_angular_hi_limit_x);
- ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_x"),&Generic6DOFJoint::_get_angular_hi_limit_x);
+ ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_y", "angle"), &Generic6DOFJoint::_set_angular_hi_limit_y);
+ ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_y"), &Generic6DOFJoint::_get_angular_hi_limit_y);
- ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_x","angle"),&Generic6DOFJoint::_set_angular_lo_limit_x);
- ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_x"),&Generic6DOFJoint::_get_angular_lo_limit_x);
+ ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_y", "angle"), &Generic6DOFJoint::_set_angular_lo_limit_y);
+ ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_y"), &Generic6DOFJoint::_get_angular_lo_limit_y);
- ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_y","angle"),&Generic6DOFJoint::_set_angular_hi_limit_y);
- ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_y"),&Generic6DOFJoint::_get_angular_hi_limit_y);
+ ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_z", "angle"), &Generic6DOFJoint::_set_angular_hi_limit_z);
+ ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_z"), &Generic6DOFJoint::_get_angular_hi_limit_z);
- ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_y","angle"),&Generic6DOFJoint::_set_angular_lo_limit_y);
- ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_y"),&Generic6DOFJoint::_get_angular_lo_limit_y);
+ ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_z", "angle"), &Generic6DOFJoint::_set_angular_lo_limit_z);
+ ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_z"), &Generic6DOFJoint::_get_angular_lo_limit_z);
- ObjectTypeDB::bind_method(_MD("_set_angular_hi_limit_z","angle"),&Generic6DOFJoint::_set_angular_hi_limit_z);
- ObjectTypeDB::bind_method(_MD("_get_angular_hi_limit_z"),&Generic6DOFJoint::_get_angular_hi_limit_z);
+ ObjectTypeDB::bind_method(_MD("set_param_x", "param", "value"), &Generic6DOFJoint::set_param_x);
+ ObjectTypeDB::bind_method(_MD("get_param_x", "param"), &Generic6DOFJoint::get_param_x);
- ObjectTypeDB::bind_method(_MD("_set_angular_lo_limit_z","angle"),&Generic6DOFJoint::_set_angular_lo_limit_z);
- ObjectTypeDB::bind_method(_MD("_get_angular_lo_limit_z"),&Generic6DOFJoint::_get_angular_lo_limit_z);
+ ObjectTypeDB::bind_method(_MD("set_param_y", "param", "value"), &Generic6DOFJoint::set_param_y);
+ ObjectTypeDB::bind_method(_MD("get_param_y", "param"), &Generic6DOFJoint::get_param_y);
- ObjectTypeDB::bind_method(_MD("set_param_x","param","value"),&Generic6DOFJoint::set_param_x);
- ObjectTypeDB::bind_method(_MD("get_param_x","param"),&Generic6DOFJoint::get_param_x);
+ ObjectTypeDB::bind_method(_MD("set_param_z", "param", "value"), &Generic6DOFJoint::set_param_z);
+ ObjectTypeDB::bind_method(_MD("get_param_z", "param"), &Generic6DOFJoint::get_param_z);
- ObjectTypeDB::bind_method(_MD("set_param_y","param","value"),&Generic6DOFJoint::set_param_y);
- ObjectTypeDB::bind_method(_MD("get_param_y","param"),&Generic6DOFJoint::get_param_y);
+ ObjectTypeDB::bind_method(_MD("set_flag_x", "flag", "value"), &Generic6DOFJoint::set_flag_x);
+ ObjectTypeDB::bind_method(_MD("get_flag_x", "flag"), &Generic6DOFJoint::get_flag_x);
- ObjectTypeDB::bind_method(_MD("set_param_z","param","value"),&Generic6DOFJoint::set_param_z);
- ObjectTypeDB::bind_method(_MD("get_param_z","param"),&Generic6DOFJoint::get_param_z);
+ ObjectTypeDB::bind_method(_MD("set_flag_y", "flag", "value"), &Generic6DOFJoint::set_flag_y);
+ ObjectTypeDB::bind_method(_MD("get_flag_y", "flag"), &Generic6DOFJoint::get_flag_y);
- ObjectTypeDB::bind_method(_MD("set_flag_x","flag","value"),&Generic6DOFJoint::set_flag_x);
- ObjectTypeDB::bind_method(_MD("get_flag_x","flag"),&Generic6DOFJoint::get_flag_x);
+ ObjectTypeDB::bind_method(_MD("set_flag_z", "flag", "value"), &Generic6DOFJoint::set_flag_z);
+ ObjectTypeDB::bind_method(_MD("get_flag_z", "flag"), &Generic6DOFJoint::get_flag_z);
- ObjectTypeDB::bind_method(_MD("set_flag_y","flag","value"),&Generic6DOFJoint::set_flag_y);
- ObjectTypeDB::bind_method(_MD("get_flag_y","flag"),&Generic6DOFJoint::get_flag_y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_limit_x/enabled"), _SCS("set_flag_x"), _SCS("get_flag_x"), FLAG_ENABLE_LINEAR_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_x/upper_distance"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_LINEAR_UPPER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_x/lower_distance"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_LINEAR_LOWER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_x/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_LINEAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_x/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_LINEAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_x/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_LINEAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_x/enabled"), _SCS("set_flag_x"), _SCS("get_flag_x"), FLAG_ENABLE_ANGULAR_LIMIT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit_x/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), _SCS("_set_angular_hi_limit_x"), _SCS("_get_angular_hi_limit_x"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit_x/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), _SCS("_set_angular_lo_limit_x"), _SCS("_get_angular_lo_limit_x"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_x/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_ANGULAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_x/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_ANGULAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_x/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_ANGULAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_x/force_limit"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_ANGULAR_FORCE_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_x/erp"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_ANGULAR_ERP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_motor_x/enabled"), _SCS("set_flag_x"), _SCS("get_flag_x"), FLAG_ENABLE_MOTOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motor_x/target_velocity"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motor_x/force_limit"), _SCS("set_param_x"), _SCS("get_param_x"), PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
- ObjectTypeDB::bind_method(_MD("set_flag_z","flag","value"),&Generic6DOFJoint::set_flag_z);
- ObjectTypeDB::bind_method(_MD("get_flag_z","flag"),&Generic6DOFJoint::get_flag_z);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_limit_y/enabled"), _SCS("set_flag_y"), _SCS("get_flag_y"), FLAG_ENABLE_LINEAR_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_y/upper_distance"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_LINEAR_UPPER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_y/lower_distance"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_LINEAR_LOWER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_y/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_LINEAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_y/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_LINEAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_y/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_LINEAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_y/enabled"), _SCS("set_flag_y"), _SCS("get_flag_y"), FLAG_ENABLE_ANGULAR_LIMIT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit_y/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), _SCS("_set_angular_hi_limit_y"), _SCS("_get_angular_hi_limit_y"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit_y/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), _SCS("_set_angular_lo_limit_y"), _SCS("_get_angular_lo_limit_y"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_y/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_ANGULAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_y/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_ANGULAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_y/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_ANGULAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_y/force_limit"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_ANGULAR_FORCE_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_y/erp"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_ANGULAR_ERP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_motor_y/enabled"), _SCS("set_flag_y"), _SCS("get_flag_y"), FLAG_ENABLE_MOTOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motor_y/target_velocity"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motor_y/force_limit"), _SCS("set_param_y"), _SCS("get_param_y"), PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_limit_z/enabled"), _SCS("set_flag_z"), _SCS("get_flag_z"), FLAG_ENABLE_LINEAR_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_z/upper_distance"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_LINEAR_UPPER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_z/lower_distance"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_LINEAR_LOWER_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_z/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_LINEAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_z/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_LINEAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "linear_limit_z/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_LINEAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_z/enabled"), _SCS("set_flag_z"), _SCS("get_flag_z"), FLAG_ENABLE_ANGULAR_LIMIT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit_z/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), _SCS("_set_angular_hi_limit_z"), _SCS("_get_angular_hi_limit_z"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_limit_z/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), _SCS("_set_angular_lo_limit_z"), _SCS("_get_angular_lo_limit_z"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_z/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_ANGULAR_LIMIT_SOFTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_z/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_ANGULAR_RESTITUTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_z/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_ANGULAR_DAMPING);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_z/force_limit"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_ANGULAR_FORCE_LIMIT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_limit_z/erp"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_ANGULAR_ERP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_motor_z/enabled"), _SCS("set_flag_z"), _SCS("get_flag_z"), FLAG_ENABLE_MOTOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motor_z/target_velocity"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "angular_motor_z/force_limit"), _SCS("set_param_z"), _SCS("get_param_z"), PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_x/enabled"),_SCS("set_flag_x"),_SCS("get_flag_x"),FLAG_ENABLE_LINEAR_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/upper_distance"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_UPPER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/lower_distance"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_LOWER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_x/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_LINEAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_x/enabled"),_SCS("set_flag_x"),_SCS("get_flag_x"),FLAG_ENABLE_ANGULAR_LIMIT);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_x/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_hi_limit_x"),_SCS("_get_angular_hi_limit_x"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_x/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_lo_limit_x"),_SCS("_get_angular_lo_limit_x"));
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/force_limit"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_FORCE_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_x/erp"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_ERP);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_x/enabled"),_SCS("set_flag_x"),_SCS("get_flag_x"),FLAG_ENABLE_MOTOR);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_x/target_velocity"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_x/force_limit"),_SCS("set_param_x"),_SCS("get_param_x"),PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
+ BIND_CONSTANT(PARAM_LINEAR_LOWER_LIMIT);
+ BIND_CONSTANT(PARAM_LINEAR_UPPER_LIMIT);
+ BIND_CONSTANT(PARAM_LINEAR_LIMIT_SOFTNESS);
+ BIND_CONSTANT(PARAM_LINEAR_RESTITUTION);
+ BIND_CONSTANT(PARAM_LINEAR_DAMPING);
+ BIND_CONSTANT(PARAM_ANGULAR_LOWER_LIMIT);
+ BIND_CONSTANT(PARAM_ANGULAR_UPPER_LIMIT);
+ BIND_CONSTANT(PARAM_ANGULAR_LIMIT_SOFTNESS);
+ BIND_CONSTANT(PARAM_ANGULAR_DAMPING);
+ BIND_CONSTANT(PARAM_ANGULAR_RESTITUTION);
+ BIND_CONSTANT(PARAM_ANGULAR_FORCE_LIMIT);
+ BIND_CONSTANT(PARAM_ANGULAR_ERP);
+ BIND_CONSTANT(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
+ BIND_CONSTANT(PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
+ BIND_CONSTANT(PARAM_MAX);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_y/enabled"),_SCS("set_flag_y"),_SCS("get_flag_y"),FLAG_ENABLE_LINEAR_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/upper_distance"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_UPPER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/lower_distance"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_LOWER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_y/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_LINEAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_y/enabled"),_SCS("set_flag_y"),_SCS("get_flag_y"),FLAG_ENABLE_ANGULAR_LIMIT);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_y/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_hi_limit_y"),_SCS("_get_angular_hi_limit_y"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_y/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_lo_limit_y"),_SCS("_get_angular_lo_limit_y"));
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/force_limit"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_FORCE_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_y/erp"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_ERP);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_y/enabled"),_SCS("set_flag_y"),_SCS("get_flag_y"),FLAG_ENABLE_MOTOR);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_y/target_velocity"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_y/force_limit"),_SCS("set_param_y"),_SCS("get_param_y"),PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
-
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"linear_limit_z/enabled"),_SCS("set_flag_z"),_SCS("get_flag_z"),FLAG_ENABLE_LINEAR_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/upper_distance"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_UPPER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/lower_distance"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_LOWER_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"linear_limit_z/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_LINEAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_limit_z/enabled"),_SCS("set_flag_z"),_SCS("get_flag_z"),FLAG_ENABLE_ANGULAR_LIMIT);
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_z/upper_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_hi_limit_z"),_SCS("_get_angular_hi_limit_z"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"angular_limit_z/lower_angle",PROPERTY_HINT_RANGE,"-180,180,0.01"),_SCS("_set_angular_lo_limit_z"),_SCS("_get_angular_lo_limit_z"));
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/softness",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_LIMIT_SOFTNESS);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/restitution",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_RESTITUTION);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/damping",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_DAMPING);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/force_limit"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_FORCE_LIMIT);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_limit_z/erp"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_ERP);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"angular_motor_z/enabled"),_SCS("set_flag_z"),_SCS("get_flag_z"),FLAG_ENABLE_MOTOR);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_z/target_velocity"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL,"angular_motor_z/force_limit"),_SCS("set_param_z"),_SCS("get_param_z"),PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
-
-
- BIND_CONSTANT( PARAM_LINEAR_LOWER_LIMIT);
- BIND_CONSTANT( PARAM_LINEAR_UPPER_LIMIT);
- BIND_CONSTANT( PARAM_LINEAR_LIMIT_SOFTNESS);
- BIND_CONSTANT( PARAM_LINEAR_RESTITUTION);
- BIND_CONSTANT( PARAM_LINEAR_DAMPING);
- BIND_CONSTANT( PARAM_ANGULAR_LOWER_LIMIT);
- BIND_CONSTANT( PARAM_ANGULAR_UPPER_LIMIT);
- BIND_CONSTANT( PARAM_ANGULAR_LIMIT_SOFTNESS);
- BIND_CONSTANT( PARAM_ANGULAR_DAMPING);
- BIND_CONSTANT( PARAM_ANGULAR_RESTITUTION);
- BIND_CONSTANT( PARAM_ANGULAR_FORCE_LIMIT);
- BIND_CONSTANT( PARAM_ANGULAR_ERP);
- BIND_CONSTANT( PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
- BIND_CONSTANT( PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
- BIND_CONSTANT( PARAM_MAX);
-
- BIND_CONSTANT( FLAG_ENABLE_LINEAR_LIMIT);
- BIND_CONSTANT( FLAG_ENABLE_ANGULAR_LIMIT);
- BIND_CONSTANT( FLAG_ENABLE_MOTOR);
- BIND_CONSTANT( FLAG_MAX );
+ BIND_CONSTANT(FLAG_ENABLE_LINEAR_LIMIT);
+ BIND_CONSTANT(FLAG_ENABLE_ANGULAR_LIMIT);
+ BIND_CONSTANT(FLAG_ENABLE_MOTOR);
+ BIND_CONSTANT(FLAG_MAX);
}
+void Generic6DOFJoint::set_param_x(Param p_param, float p_value) {
-void Generic6DOFJoint::set_param_x(Param p_param,float p_value){
-
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params_x[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params_x[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(),Vector3::AXIS_X,PhysicsServer::G6DOFJointAxisParam(p_param),p_value);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisParam(p_param), p_value);
update_gizmo();
}
-float Generic6DOFJoint::get_param_x(Param p_param) const{
+float Generic6DOFJoint::get_param_x(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_x[p_param];
}
-void Generic6DOFJoint::set_param_y(Param p_param,float p_value){
+void Generic6DOFJoint::set_param_y(Param p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params_y[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params_y[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(),Vector3::AXIS_Y,PhysicsServer::G6DOFJointAxisParam(p_param),p_value);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisParam(p_param), p_value);
update_gizmo();
-
}
-float Generic6DOFJoint::get_param_y(Param p_param) const{
+float Generic6DOFJoint::get_param_y(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_y[p_param];
}
+void Generic6DOFJoint::set_param_z(Param p_param, float p_value) {
-void Generic6DOFJoint::set_param_z(Param p_param,float p_value){
-
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params_z[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params_z[p_param] = p_value;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(),Vector3::AXIS_Z,PhysicsServer::G6DOFJointAxisParam(p_param),p_value);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisParam(p_param), p_value);
update_gizmo();
}
-float Generic6DOFJoint::get_param_z(Param p_param) const{
+float Generic6DOFJoint::get_param_z(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params_z[p_param];
}
+void Generic6DOFJoint::set_flag_x(Flag p_flag, bool p_enabled) {
-void Generic6DOFJoint::set_flag_x(Flag p_flag,bool p_enabled){
-
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags_x[p_flag]=p_enabled;
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ flags_x[p_flag] = p_enabled;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(),Vector3::AXIS_X,PhysicsServer::G6DOFJointAxisFlag(p_flag),p_enabled);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled);
update_gizmo();
-
}
-bool Generic6DOFJoint::get_flag_x(Flag p_flag) const{
+bool Generic6DOFJoint::get_flag_x(Flag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_x[p_flag];
-
}
-void Generic6DOFJoint::set_flag_y(Flag p_flag,bool p_enabled){
+void Generic6DOFJoint::set_flag_y(Flag p_flag, bool p_enabled) {
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags_y[p_flag]=p_enabled;
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ flags_y[p_flag] = p_enabled;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(),Vector3::AXIS_Y,PhysicsServer::G6DOFJointAxisFlag(p_flag),p_enabled);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled);
update_gizmo();
}
-bool Generic6DOFJoint::get_flag_y(Flag p_flag) const{
+bool Generic6DOFJoint::get_flag_y(Flag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_y[p_flag];
-
}
-void Generic6DOFJoint::set_flag_z(Flag p_flag,bool p_enabled){
+void Generic6DOFJoint::set_flag_z(Flag p_flag, bool p_enabled) {
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags_z[p_flag]=p_enabled;
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ flags_z[p_flag] = p_enabled;
if (get_joint().is_valid())
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(),Vector3::AXIS_Z,PhysicsServer::G6DOFJointAxisFlag(p_flag),p_enabled);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisFlag(p_flag), p_enabled);
update_gizmo();
}
-bool Generic6DOFJoint::get_flag_z(Flag p_flag) const{
+bool Generic6DOFJoint::get_flag_z(Flag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags_z[p_flag];
-
}
-RID Generic6DOFJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b) {
-
+RID Generic6DOFJoint::_configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) {
Transform gt = get_global_transform();
//Vector3 cone_twistpos = gt.origin;
@@ -997,87 +897,81 @@ RID Generic6DOFJoint::_configure_joint(PhysicsBody *body_a,PhysicsBody *body_b)
local_b.orthonormalize();
- RID j = PhysicsServer::get_singleton()->joint_create_generic_6dof(body_a->get_rid(),local_a,body_b?body_b->get_rid():RID(),local_b);
- for(int i=0;i<PARAM_MAX;i++) {
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j,Vector3::AXIS_X,PhysicsServer::G6DOFJointAxisParam(i),params_x[i]);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j,Vector3::AXIS_Y,PhysicsServer::G6DOFJointAxisParam(i),params_y[i]);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j,Vector3::AXIS_Z,PhysicsServer::G6DOFJointAxisParam(i),params_z[i]);
+ RID j = PhysicsServer::get_singleton()->joint_create_generic_6dof(body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
+ for (int i = 0; i < PARAM_MAX; i++) {
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisParam(i), params_x[i]);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisParam(i), params_y[i]);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_param(j, Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisParam(i), params_z[i]);
}
- for(int i=0;i<FLAG_MAX;i++) {
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j,Vector3::AXIS_X,PhysicsServer::G6DOFJointAxisFlag(i),flags_x[i]);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j,Vector3::AXIS_Y,PhysicsServer::G6DOFJointAxisFlag(i),flags_y[i]);
- PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j,Vector3::AXIS_Z,PhysicsServer::G6DOFJointAxisFlag(i),flags_z[i]);
+ for (int i = 0; i < FLAG_MAX; i++) {
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_X, PhysicsServer::G6DOFJointAxisFlag(i), flags_x[i]);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Y, PhysicsServer::G6DOFJointAxisFlag(i), flags_y[i]);
+ PhysicsServer::get_singleton()->generic_6dof_joint_set_flag(j, Vector3::AXIS_Z, PhysicsServer::G6DOFJointAxisFlag(i), flags_z[i]);
}
return j;
}
-
Generic6DOFJoint::Generic6DOFJoint() {
- set_param_x( PARAM_LINEAR_LOWER_LIMIT,0);
- set_param_x( PARAM_LINEAR_UPPER_LIMIT,0);
- set_param_x( PARAM_LINEAR_LIMIT_SOFTNESS,0.7);
- set_param_x( PARAM_LINEAR_RESTITUTION,0.5);
- set_param_x( PARAM_LINEAR_DAMPING,1.0);
- set_param_x( PARAM_ANGULAR_LOWER_LIMIT,0);
- set_param_x( PARAM_ANGULAR_UPPER_LIMIT,0);
- set_param_x( PARAM_ANGULAR_LIMIT_SOFTNESS,0.5f);
- set_param_x( PARAM_ANGULAR_DAMPING,1.0f);
- set_param_x( PARAM_ANGULAR_RESTITUTION,0);
- set_param_x( PARAM_ANGULAR_FORCE_LIMIT,0);
- set_param_x( PARAM_ANGULAR_ERP,0.5);
- set_param_x( PARAM_ANGULAR_MOTOR_TARGET_VELOCITY,0);
- set_param_x( PARAM_ANGULAR_MOTOR_FORCE_LIMIT,300);
-
- set_flag_x( FLAG_ENABLE_ANGULAR_LIMIT,true);
- set_flag_x( FLAG_ENABLE_LINEAR_LIMIT,true);
- set_flag_x( FLAG_ENABLE_MOTOR,false);
-
- set_param_y( PARAM_LINEAR_LOWER_LIMIT,0);
- set_param_y( PARAM_LINEAR_UPPER_LIMIT,0);
- set_param_y( PARAM_LINEAR_LIMIT_SOFTNESS,0.7);
- set_param_y( PARAM_LINEAR_RESTITUTION,0.5);
- set_param_y( PARAM_LINEAR_DAMPING,1.0);
- set_param_y( PARAM_ANGULAR_LOWER_LIMIT,0);
- set_param_y( PARAM_ANGULAR_UPPER_LIMIT,0);
- set_param_y( PARAM_ANGULAR_LIMIT_SOFTNESS,0.5f);
- set_param_y( PARAM_ANGULAR_DAMPING,1.0f);
- set_param_y( PARAM_ANGULAR_RESTITUTION,0);
- set_param_y( PARAM_ANGULAR_FORCE_LIMIT,0);
- set_param_y( PARAM_ANGULAR_ERP,0.5);
- set_param_y( PARAM_ANGULAR_MOTOR_TARGET_VELOCITY,0);
- set_param_y( PARAM_ANGULAR_MOTOR_FORCE_LIMIT,300);
+ set_param_x(PARAM_LINEAR_LOWER_LIMIT, 0);
+ set_param_x(PARAM_LINEAR_UPPER_LIMIT, 0);
+ set_param_x(PARAM_LINEAR_LIMIT_SOFTNESS, 0.7);
+ set_param_x(PARAM_LINEAR_RESTITUTION, 0.5);
+ set_param_x(PARAM_LINEAR_DAMPING, 1.0);
+ set_param_x(PARAM_ANGULAR_LOWER_LIMIT, 0);
+ set_param_x(PARAM_ANGULAR_UPPER_LIMIT, 0);
+ set_param_x(PARAM_ANGULAR_LIMIT_SOFTNESS, 0.5f);
+ set_param_x(PARAM_ANGULAR_DAMPING, 1.0f);
+ set_param_x(PARAM_ANGULAR_RESTITUTION, 0);
+ set_param_x(PARAM_ANGULAR_FORCE_LIMIT, 0);
+ set_param_x(PARAM_ANGULAR_ERP, 0.5);
+ set_param_x(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY, 0);
+ set_param_x(PARAM_ANGULAR_MOTOR_FORCE_LIMIT, 300);
- set_flag_y( FLAG_ENABLE_ANGULAR_LIMIT,true);
- set_flag_y( FLAG_ENABLE_LINEAR_LIMIT,true);
- set_flag_y( FLAG_ENABLE_MOTOR,false);
+ set_flag_x(FLAG_ENABLE_ANGULAR_LIMIT, true);
+ set_flag_x(FLAG_ENABLE_LINEAR_LIMIT, true);
+ set_flag_x(FLAG_ENABLE_MOTOR, false);
+ set_param_y(PARAM_LINEAR_LOWER_LIMIT, 0);
+ set_param_y(PARAM_LINEAR_UPPER_LIMIT, 0);
+ set_param_y(PARAM_LINEAR_LIMIT_SOFTNESS, 0.7);
+ set_param_y(PARAM_LINEAR_RESTITUTION, 0.5);
+ set_param_y(PARAM_LINEAR_DAMPING, 1.0);
+ set_param_y(PARAM_ANGULAR_LOWER_LIMIT, 0);
+ set_param_y(PARAM_ANGULAR_UPPER_LIMIT, 0);
+ set_param_y(PARAM_ANGULAR_LIMIT_SOFTNESS, 0.5f);
+ set_param_y(PARAM_ANGULAR_DAMPING, 1.0f);
+ set_param_y(PARAM_ANGULAR_RESTITUTION, 0);
+ set_param_y(PARAM_ANGULAR_FORCE_LIMIT, 0);
+ set_param_y(PARAM_ANGULAR_ERP, 0.5);
+ set_param_y(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY, 0);
+ set_param_y(PARAM_ANGULAR_MOTOR_FORCE_LIMIT, 300);
- set_param_z( PARAM_LINEAR_LOWER_LIMIT,0);
- set_param_z( PARAM_LINEAR_UPPER_LIMIT,0);
- set_param_z( PARAM_LINEAR_LIMIT_SOFTNESS,0.7);
- set_param_z( PARAM_LINEAR_RESTITUTION,0.5);
- set_param_z( PARAM_LINEAR_DAMPING,1.0);
- set_param_z( PARAM_ANGULAR_LOWER_LIMIT,0);
- set_param_z( PARAM_ANGULAR_UPPER_LIMIT,0);
- set_param_z( PARAM_ANGULAR_LIMIT_SOFTNESS,0.5f);
- set_param_z( PARAM_ANGULAR_DAMPING,1.0f);
- set_param_z( PARAM_ANGULAR_RESTITUTION,0);
- set_param_z( PARAM_ANGULAR_FORCE_LIMIT,0);
- set_param_z( PARAM_ANGULAR_ERP,0.5);
- set_param_z( PARAM_ANGULAR_MOTOR_TARGET_VELOCITY,0);
- set_param_z( PARAM_ANGULAR_MOTOR_FORCE_LIMIT,300);
+ set_flag_y(FLAG_ENABLE_ANGULAR_LIMIT, true);
+ set_flag_y(FLAG_ENABLE_LINEAR_LIMIT, true);
+ set_flag_y(FLAG_ENABLE_MOTOR, false);
- set_flag_z( FLAG_ENABLE_ANGULAR_LIMIT,true);
- set_flag_z( FLAG_ENABLE_LINEAR_LIMIT,true);
- set_flag_z( FLAG_ENABLE_MOTOR,false);
+ set_param_z(PARAM_LINEAR_LOWER_LIMIT, 0);
+ set_param_z(PARAM_LINEAR_UPPER_LIMIT, 0);
+ set_param_z(PARAM_LINEAR_LIMIT_SOFTNESS, 0.7);
+ set_param_z(PARAM_LINEAR_RESTITUTION, 0.5);
+ set_param_z(PARAM_LINEAR_DAMPING, 1.0);
+ set_param_z(PARAM_ANGULAR_LOWER_LIMIT, 0);
+ set_param_z(PARAM_ANGULAR_UPPER_LIMIT, 0);
+ set_param_z(PARAM_ANGULAR_LIMIT_SOFTNESS, 0.5f);
+ set_param_z(PARAM_ANGULAR_DAMPING, 1.0f);
+ set_param_z(PARAM_ANGULAR_RESTITUTION, 0);
+ set_param_z(PARAM_ANGULAR_FORCE_LIMIT, 0);
+ set_param_z(PARAM_ANGULAR_ERP, 0.5);
+ set_param_z(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY, 0);
+ set_param_z(PARAM_ANGULAR_MOTOR_FORCE_LIMIT, 300);
+ set_flag_z(FLAG_ENABLE_ANGULAR_LIMIT, true);
+ set_flag_z(FLAG_ENABLE_LINEAR_LIMIT, true);
+ set_flag_z(FLAG_ENABLE_MOTOR, false);
}
-
-
-
#if 0
void PhysicsJoint::_set(const String& p_name, const Variant& p_value) {
diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h
index a66d8bda4..b299d5e55 100644
--- a/scene/3d/physics_joint.h
+++ b/scene/3d/physics_joint.h
@@ -29,15 +29,14 @@
#ifndef PHYSICS_JOINT_H
#define PHYSICS_JOINT_H
-#include "scene/3d/spatial.h"
#include "scene/3d/physics_body.h"
-
+#include "scene/3d/spatial.h"
class Joint : public Spatial {
- OBJ_TYPE(Joint,Spatial);
+ OBJ_TYPE(Joint, Spatial);
- RID ba,bb;
+ RID ba, bb;
RID joint;
@@ -47,22 +46,20 @@ class Joint : public Spatial {
int solver_priority;
bool exclude_from_collision;
-
protected:
-
- void _update_joint(bool p_only_free=false);
+ void _update_joint(bool p_only_free = false);
void _notification(int p_what);
- virtual RID _configure_joint(PhysicsBody *body_a,PhysicsBody *body_b)=0;
+ virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b) = 0;
static void _bind_methods();
-public:
- void set_node_a(const NodePath& p_node_a);
+public:
+ void set_node_a(const NodePath &p_node_a);
NodePath get_node_a() const;
- void set_node_b(const NodePath& p_node_b);
+ void set_node_b(const NodePath &p_node_b);
NodePath get_node_b() const;
void set_solver_priority(int p_priority);
@@ -73,31 +70,28 @@ public:
RID get_joint() const { return joint; }
Joint();
-
};
///////////////////////////////////////////
-
class PinJoint : public Joint {
- OBJ_TYPE(PinJoint,Joint);
-public:
+ OBJ_TYPE(PinJoint, Joint);
+public:
enum Param {
- PARAM_BIAS=PhysicsServer::PIN_JOINT_BIAS,
- PARAM_DAMPING=PhysicsServer::PIN_JOINT_DAMPING,
- PARAM_IMPULSE_CLAMP=PhysicsServer::PIN_JOINT_IMPULSE_CLAMP
+ PARAM_BIAS = PhysicsServer::PIN_JOINT_BIAS,
+ PARAM_DAMPING = PhysicsServer::PIN_JOINT_DAMPING,
+ PARAM_IMPULSE_CLAMP = PhysicsServer::PIN_JOINT_IMPULSE_CLAMP
};
protected:
-
float params[3];
virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
static void _bind_methods();
-public:
- void set_param(Param p_param,float p_value);
+public:
+ void set_param(Param p_param, float p_value);
float get_param(Param p_param) const;
PinJoint();
@@ -105,34 +99,30 @@ public:
VARIANT_ENUM_CAST(PinJoint::Param);
-
class HingeJoint : public Joint {
- OBJ_TYPE(HingeJoint,Joint);
-public:
+ OBJ_TYPE(HingeJoint, Joint);
+public:
enum Param {
- PARAM_BIAS=PhysicsServer::HINGE_JOINT_BIAS,
- PARAM_LIMIT_UPPER=PhysicsServer::HINGE_JOINT_LIMIT_UPPER,
- PARAM_LIMIT_LOWER=PhysicsServer::HINGE_JOINT_LIMIT_LOWER,
- PARAM_LIMIT_BIAS=PhysicsServer::HINGE_JOINT_LIMIT_BIAS,
- PARAM_LIMIT_SOFTNESS=PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS,
- PARAM_LIMIT_RELAXATION=PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION,
- PARAM_MOTOR_TARGET_VELOCITY=PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY,
- PARAM_MOTOR_MAX_IMPULSE=PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE,
- PARAM_MAX=PhysicsServer::HINGE_JOINT_MAX
+ PARAM_BIAS = PhysicsServer::HINGE_JOINT_BIAS,
+ PARAM_LIMIT_UPPER = PhysicsServer::HINGE_JOINT_LIMIT_UPPER,
+ PARAM_LIMIT_LOWER = PhysicsServer::HINGE_JOINT_LIMIT_LOWER,
+ PARAM_LIMIT_BIAS = PhysicsServer::HINGE_JOINT_LIMIT_BIAS,
+ PARAM_LIMIT_SOFTNESS = PhysicsServer::HINGE_JOINT_LIMIT_SOFTNESS,
+ PARAM_LIMIT_RELAXATION = PhysicsServer::HINGE_JOINT_LIMIT_RELAXATION,
+ PARAM_MOTOR_TARGET_VELOCITY = PhysicsServer::HINGE_JOINT_MOTOR_TARGET_VELOCITY,
+ PARAM_MOTOR_MAX_IMPULSE = PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE,
+ PARAM_MAX = PhysicsServer::HINGE_JOINT_MAX
};
enum Flag {
- FLAG_USE_LIMIT=PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT,
- FLAG_ENABLE_MOTOR=PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR,
- FLAG_MAX=PhysicsServer::HINGE_JOINT_FLAG_MAX
+ FLAG_USE_LIMIT = PhysicsServer::HINGE_JOINT_FLAG_USE_LIMIT,
+ FLAG_ENABLE_MOTOR = PhysicsServer::HINGE_JOINT_FLAG_ENABLE_MOTOR,
+ FLAG_MAX = PhysicsServer::HINGE_JOINT_FLAG_MAX
};
-
-
protected:
-
float params[PARAM_MAX];
bool flags[FLAG_MAX];
virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
@@ -145,11 +135,10 @@ protected:
float _get_lower_limit() const;
public:
-
- void set_param(Param p_param,float p_value);
+ void set_param(Param p_param, float p_value);
float get_param(Param p_param) const;
- void set_flag(Flag p_flag,bool p_value);
+ void set_flag(Flag p_flag, bool p_value);
bool get_flag(Flag p_flag) const;
HingeJoint();
@@ -158,44 +147,40 @@ public:
VARIANT_ENUM_CAST(HingeJoint::Param);
VARIANT_ENUM_CAST(HingeJoint::Flag);
-
class SliderJoint : public Joint {
- OBJ_TYPE(SliderJoint,Joint);
-public:
+ OBJ_TYPE(SliderJoint, Joint);
+public:
enum Param {
- PARAM_LINEAR_LIMIT_UPPER=PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER,
- PARAM_LINEAR_LIMIT_LOWER=PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER,
- PARAM_LINEAR_LIMIT_SOFTNESS=PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
- PARAM_LINEAR_LIMIT_RESTITUTION=PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
- PARAM_LINEAR_LIMIT_DAMPING=PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
- PARAM_LINEAR_MOTION_SOFTNESS=PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
- PARAM_LINEAR_MOTION_RESTITUTION=PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
- PARAM_LINEAR_MOTION_DAMPING=PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING,
- PARAM_LINEAR_ORTHOGONAL_SOFTNESS=PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
- PARAM_LINEAR_ORTHOGONAL_RESTITUTION=PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
- PARAM_LINEAR_ORTHOGONAL_DAMPING=PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
+ PARAM_LINEAR_LIMIT_UPPER = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_UPPER,
+ PARAM_LINEAR_LIMIT_LOWER = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_LOWER,
+ PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_SOFTNESS,
+ PARAM_LINEAR_LIMIT_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_RESTITUTION,
+ PARAM_LINEAR_LIMIT_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_LIMIT_DAMPING,
+ PARAM_LINEAR_MOTION_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_SOFTNESS,
+ PARAM_LINEAR_MOTION_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_RESTITUTION,
+ PARAM_LINEAR_MOTION_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_MOTION_DAMPING,
+ PARAM_LINEAR_ORTHOGONAL_SOFTNESS = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_SOFTNESS,
+ PARAM_LINEAR_ORTHOGONAL_RESTITUTION = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_RESTITUTION,
+ PARAM_LINEAR_ORTHOGONAL_DAMPING = PhysicsServer::SLIDER_JOINT_LINEAR_ORTHOGONAL_DAMPING,
- PARAM_ANGULAR_LIMIT_UPPER=PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
- PARAM_ANGULAR_LIMIT_LOWER=PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
- PARAM_ANGULAR_LIMIT_SOFTNESS=PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
- PARAM_ANGULAR_LIMIT_RESTITUTION=PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
- PARAM_ANGULAR_LIMIT_DAMPING=PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
- PARAM_ANGULAR_MOTION_SOFTNESS=PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
- PARAM_ANGULAR_MOTION_RESTITUTION=PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
- PARAM_ANGULAR_MOTION_DAMPING=PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
- PARAM_ANGULAR_ORTHOGONAL_SOFTNESS=PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
- PARAM_ANGULAR_ORTHOGONAL_RESTITUTION=PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
- PARAM_ANGULAR_ORTHOGONAL_DAMPING=PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
- PARAM_MAX=PhysicsServer::SLIDER_JOINT_MAX
+ PARAM_ANGULAR_LIMIT_UPPER = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_UPPER,
+ PARAM_ANGULAR_LIMIT_LOWER = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_LOWER,
+ PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_SOFTNESS,
+ PARAM_ANGULAR_LIMIT_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_RESTITUTION,
+ PARAM_ANGULAR_LIMIT_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_LIMIT_DAMPING,
+ PARAM_ANGULAR_MOTION_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_SOFTNESS,
+ PARAM_ANGULAR_MOTION_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_RESTITUTION,
+ PARAM_ANGULAR_MOTION_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_MOTION_DAMPING,
+ PARAM_ANGULAR_ORTHOGONAL_SOFTNESS = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_SOFTNESS,
+ PARAM_ANGULAR_ORTHOGONAL_RESTITUTION = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_RESTITUTION,
+ PARAM_ANGULAR_ORTHOGONAL_DAMPING = PhysicsServer::SLIDER_JOINT_ANGULAR_ORTHOGONAL_DAMPING,
+ PARAM_MAX = PhysicsServer::SLIDER_JOINT_MAX
};
protected:
-
-
-
void _set_upper_limit_angular(float p_limit_angular);
float _get_upper_limit_angular() const;
@@ -205,25 +190,21 @@ protected:
float params[PARAM_MAX];
virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
static void _bind_methods();
-public:
- void set_param(Param p_param,float p_value);
+public:
+ void set_param(Param p_param, float p_value);
float get_param(Param p_param) const;
SliderJoint();
};
-
VARIANT_ENUM_CAST(SliderJoint::Param);
-
-
-
class ConeTwistJoint : public Joint {
- OBJ_TYPE(ConeTwistJoint,Joint);
-public:
+ OBJ_TYPE(ConeTwistJoint, Joint);
+public:
enum Param {
PARAM_SWING_SPAN,
@@ -235,8 +216,6 @@ public:
};
protected:
-
-
void _set_swing_span(float p_limit_angular);
float _get_swing_span() const;
@@ -246,53 +225,48 @@ protected:
float params[PARAM_MAX];
virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
static void _bind_methods();
-public:
- void set_param(Param p_param,float p_value);
+public:
+ void set_param(Param p_param, float p_value);
float get_param(Param p_param) const;
ConeTwistJoint();
};
-
VARIANT_ENUM_CAST(ConeTwistJoint::Param);
-
class Generic6DOFJoint : public Joint {
- OBJ_TYPE(Generic6DOFJoint,Joint);
-public:
+ OBJ_TYPE(Generic6DOFJoint, Joint);
+public:
enum Param {
- PARAM_LINEAR_LOWER_LIMIT=PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT,
- PARAM_LINEAR_UPPER_LIMIT=PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT,
- PARAM_LINEAR_LIMIT_SOFTNESS=PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
- PARAM_LINEAR_RESTITUTION=PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION,
- PARAM_LINEAR_DAMPING=PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING,
- PARAM_ANGULAR_LOWER_LIMIT=PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
- PARAM_ANGULAR_UPPER_LIMIT=PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
- PARAM_ANGULAR_LIMIT_SOFTNESS=PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
- PARAM_ANGULAR_DAMPING=PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING,
- PARAM_ANGULAR_RESTITUTION=PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION,
- PARAM_ANGULAR_FORCE_LIMIT=PhysicsServer::G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
- PARAM_ANGULAR_ERP=PhysicsServer::G6DOF_JOINT_ANGULAR_ERP,
- PARAM_ANGULAR_MOTOR_TARGET_VELOCITY=PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
- PARAM_ANGULAR_MOTOR_FORCE_LIMIT=PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
- PARAM_MAX=PhysicsServer::G6DOF_JOINT_MAX,
+ PARAM_LINEAR_LOWER_LIMIT = PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT,
+ PARAM_LINEAR_UPPER_LIMIT = PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT,
+ PARAM_LINEAR_LIMIT_SOFTNESS = PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS,
+ PARAM_LINEAR_RESTITUTION = PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION,
+ PARAM_LINEAR_DAMPING = PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING,
+ PARAM_ANGULAR_LOWER_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT,
+ PARAM_ANGULAR_UPPER_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT,
+ PARAM_ANGULAR_LIMIT_SOFTNESS = PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS,
+ PARAM_ANGULAR_DAMPING = PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING,
+ PARAM_ANGULAR_RESTITUTION = PhysicsServer::G6DOF_JOINT_ANGULAR_RESTITUTION,
+ PARAM_ANGULAR_FORCE_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_FORCE_LIMIT,
+ PARAM_ANGULAR_ERP = PhysicsServer::G6DOF_JOINT_ANGULAR_ERP,
+ PARAM_ANGULAR_MOTOR_TARGET_VELOCITY = PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY,
+ PARAM_ANGULAR_MOTOR_FORCE_LIMIT = PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT,
+ PARAM_MAX = PhysicsServer::G6DOF_JOINT_MAX,
};
enum Flag {
- FLAG_ENABLE_LINEAR_LIMIT=PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
- FLAG_ENABLE_ANGULAR_LIMIT=PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
- FLAG_ENABLE_MOTOR=PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR,
- FLAG_MAX=PhysicsServer::G6DOF_JOINT_FLAG_MAX
+ FLAG_ENABLE_LINEAR_LIMIT = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT,
+ FLAG_ENABLE_ANGULAR_LIMIT = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT,
+ FLAG_ENABLE_MOTOR = PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR,
+ FLAG_MAX = PhysicsServer::G6DOF_JOINT_FLAG_MAX
};
-
protected:
-
-
void _set_angular_hi_limit_x(float p_limit_angular);
float _get_angular_hi_limit_x() const;
@@ -320,34 +294,32 @@ protected:
virtual RID _configure_joint(PhysicsBody *body_a, PhysicsBody *body_b);
static void _bind_methods();
-public:
- void set_param_x(Param p_param,float p_value);
+public:
+ void set_param_x(Param p_param, float p_value);
float get_param_x(Param p_param) const;
- void set_param_y(Param p_param,float p_value);
+ void set_param_y(Param p_param, float p_value);
float get_param_y(Param p_param) const;
- void set_param_z(Param p_param,float p_value);
+ void set_param_z(Param p_param, float p_value);
float get_param_z(Param p_param) const;
- void set_flag_x(Flag p_flag,bool p_enabled);
+ void set_flag_x(Flag p_flag, bool p_enabled);
bool get_flag_x(Flag p_flag) const;
- void set_flag_y(Flag p_flag,bool p_enabled);
+ void set_flag_y(Flag p_flag, bool p_enabled);
bool get_flag_y(Flag p_flag) const;
- void set_flag_z(Flag p_flag,bool p_enabled);
+ void set_flag_z(Flag p_flag, bool p_enabled);
bool get_flag_z(Flag p_flag) const;
Generic6DOFJoint();
};
-
VARIANT_ENUM_CAST(Generic6DOFJoint::Param);
VARIANT_ENUM_CAST(Generic6DOFJoint::Flag);
-
#if 0
class PhysicsJoint : public Spatial {
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index 0630e6a1d..df9c4f6f8 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -27,31 +27,31 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "portal.h"
-#include "servers/visual_server.h"
-#include "scene/resources/surface_tool.h"
#include "globals.h"
+#include "scene/resources/surface_tool.h"
+#include "servers/visual_server.h"
-bool Portal::_set(const StringName& p_name, const Variant& p_value) {
+bool Portal::_set(const StringName &p_name, const Variant &p_value) {
- if (p_name=="shape") {
- DVector<float> src_coords=p_value;
+ if (p_name == "shape") {
+ DVector<float> src_coords = p_value;
Vector<Point2> points;
int src_coords_size = src_coords.size();
- ERR_FAIL_COND_V(src_coords_size%2,false);
- points.resize(src_coords_size/2);
- for (int i=0;i<points.size();i++) {
+ ERR_FAIL_COND_V(src_coords_size % 2, false);
+ points.resize(src_coords_size / 2);
+ for (int i = 0; i < points.size(); i++) {
- points[i].x=src_coords[i*2+0];
- points[i].y=src_coords[i*2+1];
+ points[i].x = src_coords[i * 2 + 0];
+ points[i].y = src_coords[i * 2 + 1];
set_shape(points);
}
- } else if (p_name=="enabled") {
+ } else if (p_name == "enabled") {
set_enabled(p_value);
- } else if (p_name=="disable_distance") {
+ } else if (p_name == "disable_distance") {
set_disable_distance(p_value);
- } else if (p_name=="disabled_color") {
+ } else if (p_name == "disabled_color") {
set_disabled_color(p_value);
- } else if (p_name=="connect_range") {
+ } else if (p_name == "connect_range") {
set_connect_range(p_value);
} else
return false;
@@ -59,54 +59,53 @@ bool Portal::_set(const StringName& p_name, const Variant& p_value) {
return true;
}
-bool Portal::_get(const StringName& p_name,Variant &r_ret) const {
+bool Portal::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name=="shape") {
- Vector<Point2> points=get_shape();
+ if (p_name == "shape") {
+ Vector<Point2> points = get_shape();
DVector<float> dst_coords;
- dst_coords.resize(points.size()*2);
+ dst_coords.resize(points.size() * 2);
- for (int i=0;i<points.size();i++) {
+ for (int i = 0; i < points.size(); i++) {
- dst_coords.set(i*2+0,points[i].x);
- dst_coords.set(i*2+1,points[i].y);
+ dst_coords.set(i * 2 + 0, points[i].x);
+ dst_coords.set(i * 2 + 1, points[i].y);
}
- r_ret= dst_coords;
- } else if (p_name=="enabled") {
- r_ret= is_enabled();
- } else if (p_name=="disable_distance") {
- r_ret= get_disable_distance();
- } else if (p_name=="disabled_color") {
- r_ret= get_disabled_color();
- } else if (p_name=="connect_range") {
- r_ret= get_connect_range();
+ r_ret = dst_coords;
+ } else if (p_name == "enabled") {
+ r_ret = is_enabled();
+ } else if (p_name == "disable_distance") {
+ r_ret = get_disable_distance();
+ } else if (p_name == "disabled_color") {
+ r_ret = get_disabled_color();
+ } else if (p_name == "connect_range") {
+ r_ret = get_connect_range();
} else
return false;
return true;
}
-void Portal::_get_property_list( List<PropertyInfo> *p_list) const {
+void Portal::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo( Variant::REAL_ARRAY, "shape" ) );
- p_list->push_back( PropertyInfo( Variant::BOOL, "enabled" ) );
- p_list->push_back( PropertyInfo( Variant::REAL, "disable_distance",PROPERTY_HINT_RANGE,"0,4096,0.01" ) );
- p_list->push_back( PropertyInfo( Variant::COLOR, "disabled_color") );
- p_list->push_back( PropertyInfo( Variant::REAL, "connect_range",PROPERTY_HINT_RANGE,"0.1,4096,0.01" ) );
+ p_list->push_back(PropertyInfo(Variant::REAL_ARRAY, "shape"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "enabled"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "disable_distance", PROPERTY_HINT_RANGE, "0,4096,0.01"));
+ p_list->push_back(PropertyInfo(Variant::COLOR, "disabled_color"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "connect_range", PROPERTY_HINT_RANGE, "0.1,4096,0.01"));
}
-
RES Portal::_get_gizmo_geometry() const {
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
+ Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
+ Ref<FixedMaterial> mat(memnew(FixedMaterial));
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.8,0.8,0.7) );
+ mat->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(1.0, 0.8, 0.8, 0.7));
mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
-// mat->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER,true);
+ mat->set_flag(Material::FLAG_DOUBLE_SIDED, true);
+ mat->set_flag(Material::FLAG_UNSHADED, true);
+ // mat->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);
@@ -114,68 +113,63 @@ RES Portal::_get_gizmo_geometry() const {
Vector<Point2> shape = get_shape();
Vector2 center;
- for (int i=0;i<shape.size();i++) {
+ for (int i = 0; i < shape.size(); i++) {
- int n=(i+1)%shape.size();
+ int n = (i + 1) % shape.size();
Vector<Vector3> points;
- surface_tool->add_vertex( Vector3( shape[i].x, shape[i].y,0 ));
- surface_tool->add_vertex( Vector3( shape[n].x, shape[n].y,0 ));
- center+=shape[i];
-
+ surface_tool->add_vertex(Vector3(shape[i].x, shape[i].y, 0));
+ surface_tool->add_vertex(Vector3(shape[n].x, shape[n].y, 0));
+ center += shape[i];
}
- if (shape.size()>0) {
+ if (shape.size() > 0) {
- center/=shape.size();
+ center /= shape.size();
Vector<Vector3> points;
- surface_tool->add_vertex( Vector3( center.x, center.y,0 ));
- surface_tool->add_vertex( Vector3( center.x, center.y,1.0 ));
+ surface_tool->add_vertex(Vector3(center.x, center.y, 0));
+ surface_tool->add_vertex(Vector3(center.x, center.y, 1.0));
}
return surface_tool->commit();
}
-
-
AABB Portal::get_aabb() const {
return aabb;
}
DVector<Face3> Portal::get_faces(uint32_t p_usage_flags) const {
- if (!(p_usage_flags&FACES_ENCLOSING))
+ if (!(p_usage_flags & FACES_ENCLOSING))
return DVector<Face3>();
Vector<Point2> shape = get_shape();
- if (shape.size()==0)
+ if (shape.size() == 0)
return DVector<Face3>();
Vector2 center;
- for (int i=0;i<shape.size();i++) {
-
- center+=shape[i];
+ for (int i = 0; i < shape.size(); i++) {
+ center += shape[i];
}
DVector<Face3> ret;
- center/=shape.size();
+ center /= shape.size();
- for (int i=0;i<shape.size();i++) {
+ for (int i = 0; i < shape.size(); i++) {
- int n=(i+1)%shape.size();
+ int n = (i + 1) % shape.size();
Face3 f;
- f.vertex[0]=Vector3( center.x, center.y, 0 );
- f.vertex[1]=Vector3( shape[i].x, shape[i].y, 0 );
- f.vertex[2]=Vector3( shape[n].x, shape[n].y, 0 );
+ f.vertex[0] = Vector3(center.x, center.y, 0);
+ f.vertex[1] = Vector3(shape[i].x, shape[i].y, 0);
+ f.vertex[2] = Vector3(shape[n].x, shape[n].y, 0);
ret.push_back(f);
}
return ret;
}
-void Portal::set_shape(const Vector<Point2>& p_shape) {
-
+void Portal::set_shape(const Vector<Point2> &p_shape) {
VisualServer::get_singleton()->portal_set_shape(portal, p_shape);
update_gizmo();
@@ -188,8 +182,8 @@ Vector<Point2> Portal::get_shape() const {
void Portal::set_connect_range(float p_range) {
- connect_range=p_range;
- VisualServer::get_singleton()->portal_set_connect_range(portal,p_range);
+ connect_range = p_range;
+ VisualServer::get_singleton()->portal_set_connect_range(portal, p_range);
}
float Portal::get_connect_range() const {
@@ -197,35 +191,31 @@ float Portal::get_connect_range() const {
return connect_range;
}
-
void Portal::set_enabled(bool p_enabled) {
- enabled=p_enabled;
- VisualServer::get_singleton()->portal_set_enabled(portal,enabled);
+ enabled = p_enabled;
+ VisualServer::get_singleton()->portal_set_enabled(portal, enabled);
}
bool Portal::is_enabled() const {
-
return enabled;
}
void Portal::set_disable_distance(float p_distance) {
- disable_distance=p_distance;
- VisualServer::get_singleton()->portal_set_disable_distance(portal,disable_distance);
-
+ disable_distance = p_distance;
+ VisualServer::get_singleton()->portal_set_disable_distance(portal, disable_distance);
}
float Portal::get_disable_distance() const {
-
return disable_distance;
}
-void Portal::set_disabled_color(const Color& p_disabled_color) {
+void Portal::set_disabled_color(const Color &p_disabled_color) {
- disabled_color=p_disabled_color;
- VisualServer::get_singleton()->portal_set_disabled_color(portal,disabled_color);
+ disabled_color = p_disabled_color;
+ VisualServer::get_singleton()->portal_set_disabled_color(portal, disabled_color);
}
Color Portal::get_disabled_color() const {
@@ -235,47 +225,40 @@ Color Portal::get_disabled_color() const {
void Portal::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shape","points"),&Portal::set_shape);
- ObjectTypeDB::bind_method(_MD("get_shape"),&Portal::get_shape);
+ ObjectTypeDB::bind_method(_MD("set_shape", "points"), &Portal::set_shape);
+ ObjectTypeDB::bind_method(_MD("get_shape"), &Portal::get_shape);
- ObjectTypeDB::bind_method(_MD("set_enabled","enable"),&Portal::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&Portal::is_enabled);
+ ObjectTypeDB::bind_method(_MD("set_enabled", "enable"), &Portal::set_enabled);
+ ObjectTypeDB::bind_method(_MD("is_enabled"), &Portal::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_disable_distance","distance"),&Portal::set_disable_distance);
- ObjectTypeDB::bind_method(_MD("get_disable_distance"),&Portal::get_disable_distance);
+ ObjectTypeDB::bind_method(_MD("set_disable_distance", "distance"), &Portal::set_disable_distance);
+ ObjectTypeDB::bind_method(_MD("get_disable_distance"), &Portal::get_disable_distance);
- ObjectTypeDB::bind_method(_MD("set_disabled_color","color"),&Portal::set_disabled_color);
- ObjectTypeDB::bind_method(_MD("get_disabled_color"),&Portal::get_disabled_color);
-
- ObjectTypeDB::bind_method(_MD("set_connect_range","range"),&Portal::set_connect_range);
- ObjectTypeDB::bind_method(_MD("get_connect_range"),&Portal::get_connect_range);
+ ObjectTypeDB::bind_method(_MD("set_disabled_color", "color"), &Portal::set_disabled_color);
+ ObjectTypeDB::bind_method(_MD("get_disabled_color"), &Portal::get_disabled_color);
+ ObjectTypeDB::bind_method(_MD("set_connect_range", "range"), &Portal::set_connect_range);
+ ObjectTypeDB::bind_method(_MD("get_connect_range"), &Portal::get_connect_range);
}
Portal::Portal() {
portal = VisualServer::get_singleton()->portal_create();
- Vector< Point2 > points;
- points.push_back( Point2( -1, 1 ) );
- points.push_back( Point2( 1, 1 ) );
- points.push_back( Point2( 1, -1 ) );
- points.push_back( Point2( -1, -1 ) );
+ Vector<Point2> points;
+ points.push_back(Point2(-1, 1));
+ points.push_back(Point2(1, 1));
+ points.push_back(Point2(1, -1));
+ points.push_back(Point2(-1, -1));
set_shape(points); // default shape
-
set_connect_range(0.8);
set_disable_distance(50);
set_enabled(true);
set_base(portal);
-
-
}
-
Portal::~Portal() {
VisualServer::get_singleton()->free(portal);
}
-
-
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 9443ffca9..f2f110916 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -34,14 +34,11 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-
/* Portal Logic:
If a portal is placed next (very close to) a similar, opposing portal, they automatically connect,
otherwise, a portal connects to the parent room
*/
-
-
class Portal : public VisualInstance {
OBJ_TYPE(Portal, VisualInstance);
@@ -58,15 +55,13 @@ class Portal : public VisualInstance {
virtual RES _get_gizmo_geometry() const;
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
@@ -76,10 +71,10 @@ public:
void set_disable_distance(float p_distance);
float get_disable_distance() const;
- void set_disabled_color(const Color& p_disabled_color);
+ void set_disabled_color(const Color &p_disabled_color);
Color get_disabled_color() const;
- void set_shape(const Vector<Point2>& p_shape);
+ void set_shape(const Vector<Point2> &p_shape);
Vector<Point2> get_shape() const;
void set_connect_range(float p_range);
@@ -87,7 +82,6 @@ public:
Portal();
~Portal();
-
};
#endif
diff --git a/scene/3d/position_3d.cpp b/scene/3d/position_3d.cpp
index c08d2609b..ae46e00f3 100644
--- a/scene/3d/position_3d.cpp
+++ b/scene/3d/position_3d.cpp
@@ -31,36 +31,34 @@
RES Position3D::_get_gizmo_geometry() const {
-
- Ref<Mesh> mesh = memnew( Mesh );
+ Ref<Mesh> mesh = memnew(Mesh);
DVector<Vector3> cursor_points;
DVector<Color> cursor_colors;
float cs = 0.25;
- cursor_points.push_back(Vector3(+cs,0,0));
- cursor_points.push_back(Vector3(-cs,0,0));
- cursor_points.push_back(Vector3(0,+cs,0));
- cursor_points.push_back(Vector3(0,-cs,0));
- cursor_points.push_back(Vector3(0,0,+cs));
- cursor_points.push_back(Vector3(0,0,-cs));
- cursor_colors.push_back(Color(1,0.5,0.5,1));
- cursor_colors.push_back(Color(1,0.5,0.5,1));
- cursor_colors.push_back(Color(0.5,1,0.5,1));
- cursor_colors.push_back(Color(0.5,1,0.5,1));
- cursor_colors.push_back(Color(0.5,0.5,1,1));
- cursor_colors.push_back(Color(0.5,0.5,1,1));
+ cursor_points.push_back(Vector3(+cs, 0, 0));
+ cursor_points.push_back(Vector3(-cs, 0, 0));
+ cursor_points.push_back(Vector3(0, +cs, 0));
+ cursor_points.push_back(Vector3(0, -cs, 0));
+ cursor_points.push_back(Vector3(0, 0, +cs));
+ cursor_points.push_back(Vector3(0, 0, -cs));
+ cursor_colors.push_back(Color(1, 0.5, 0.5, 1));
+ cursor_colors.push_back(Color(1, 0.5, 0.5, 1));
+ cursor_colors.push_back(Color(0.5, 1, 0.5, 1));
+ cursor_colors.push_back(Color(0.5, 1, 0.5, 1));
+ cursor_colors.push_back(Color(0.5, 0.5, 1, 1));
+ cursor_colors.push_back(Color(0.5, 0.5, 1, 1));
- Ref<FixedMaterial> mat = memnew( FixedMaterial );
- mat->set_flag(Material::FLAG_UNSHADED,true);
+ Ref<FixedMaterial> mat = memnew(FixedMaterial);
+ mat->set_flag(Material::FLAG_UNSHADED, true);
mat->set_line_width(3);
Array d;
- d[Mesh::ARRAY_VERTEX]=cursor_points;
- d[Mesh::ARRAY_COLOR]=cursor_colors;
- mesh->add_surface(Mesh::PRIMITIVE_LINES,d);
- mesh->surface_set_material(0,mat);
+ d[Mesh::ARRAY_VERTEX] = cursor_points;
+ d[Mesh::ARRAY_COLOR] = cursor_colors;
+ mesh->add_surface(Mesh::PRIMITIVE_LINES, d);
+ mesh->surface_set_material(0, mat);
return mesh;
}
-Position3D::Position3D()
-{
+Position3D::Position3D() {
}
diff --git a/scene/3d/position_3d.h b/scene/3d/position_3d.h
index 1c2afe9ee..9a710dbc0 100644
--- a/scene/3d/position_3d.h
+++ b/scene/3d/position_3d.h
@@ -31,14 +31,13 @@
#include "scene/3d/spatial.h"
-class Position3D : public Spatial {
+class Position3D : public Spatial {
- OBJ_TYPE(Position3D,Spatial);
+ OBJ_TYPE(Position3D, Spatial);
virtual RES _get_gizmo_geometry() const;
public:
-
Position3D();
};
diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp
index 0553d2eaa..28837256c 100644
--- a/scene/3d/proximity_group.cpp
+++ b/scene/3d/proximity_group.cpp
@@ -47,7 +47,7 @@ void ProximityGroup::clear_groups() {
E = E->next();
};
- for (int i=0; i<num; i++) {
+ for (int i = 0; i < num; i++) {
groups.erase(remove_list[i]);
};
@@ -74,7 +74,7 @@ void ProximityGroup::update_groups() {
clear_groups();
};
-void ProximityGroup::add_groups(int* p_cell, String p_base, int p_depth) {
+void ProximityGroup::add_groups(int *p_cell, String p_base, int p_depth) {
p_base = p_base + "|";
if (grid_radius[p_depth] == 0) {
@@ -89,7 +89,7 @@ void ProximityGroup::add_groups(int* p_cell, String p_base, int p_depth) {
int start = p_cell[p_depth] - grid_radius[p_depth];
int end = p_cell[p_depth] + grid_radius[p_depth];
- for (int i=start; i<=end; i++) {
+ for (int i = start; i <= end; i++) {
String gname = p_base + itos(i);
if (p_depth == 2) {
@@ -102,7 +102,7 @@ void ProximityGroup::add_groups(int* p_cell, String p_base, int p_depth) {
void ProximityGroup::_new_group(StringName p_name) {
- const Map<StringName, uint32_t>::Element* E = groups.find(p_name);
+ const Map<StringName, uint32_t>::Element *E = groups.find(p_name);
if (!E) {
add_to_group(p_name);
};
@@ -119,13 +119,13 @@ void ProximityGroup::_notification(int what) {
switch (what) {
- case NOTIFICATION_EXIT_TREE:
- ++group_version;
- clear_groups();
- break;
- case NOTIFICATION_TRANSFORM_CHANGED:
- update_groups();
- break;
+ case NOTIFICATION_EXIT_TREE:
+ ++group_version;
+ clear_groups();
+ break;
+ case NOTIFICATION_TRANSFORM_CHANGED:
+ update_groups();
+ break;
};
};
@@ -138,7 +138,6 @@ void ProximityGroup::broadcast(String p_name, Variant p_params) {
get_tree()->call_group(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params);
E = E->next();
};
-
};
void ProximityGroup::_proximity_group_broadcast(String p_name, Variant p_params) {
@@ -152,13 +151,12 @@ void ProximityGroup::_proximity_group_broadcast(String p_name, Variant p_params)
};
};
-
void ProximityGroup::set_dispatch_mode(int p_mode) {
dispatch_mode = (DispatchMode)p_mode;
};
-void ProximityGroup::set_grid_radius(const Vector3& p_radius) {
+void ProximityGroup::set_grid_radius(const Vector3 &p_radius) {
grid_radius = p_radius;
};
@@ -168,31 +166,28 @@ Vector3 ProximityGroup::get_grid_radius() const {
return grid_radius;
};
-
void ProximityGroup::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_group_name","name"), &ProximityGroup::set_group_name);
- ObjectTypeDB::bind_method(_MD("broadcast","name", "parameters"), &ProximityGroup::broadcast);
- ObjectTypeDB::bind_method(_MD("set_dispatch_mode","mode"), &ProximityGroup::set_dispatch_mode);
- ObjectTypeDB::bind_method(_MD("_proximity_group_broadcast","name","params"), &ProximityGroup::_proximity_group_broadcast);
- ObjectTypeDB::bind_method(_MD("set_grid_radius","radius"), &ProximityGroup::set_grid_radius);
+ ObjectTypeDB::bind_method(_MD("set_group_name", "name"), &ProximityGroup::set_group_name);
+ ObjectTypeDB::bind_method(_MD("broadcast", "name", "parameters"), &ProximityGroup::broadcast);
+ ObjectTypeDB::bind_method(_MD("set_dispatch_mode", "mode"), &ProximityGroup::set_dispatch_mode);
+ ObjectTypeDB::bind_method(_MD("_proximity_group_broadcast", "name", "params"), &ProximityGroup::_proximity_group_broadcast);
+ ObjectTypeDB::bind_method(_MD("set_grid_radius", "radius"), &ProximityGroup::set_grid_radius);
ObjectTypeDB::bind_method(_MD("get_grid_radius"), &ProximityGroup::get_grid_radius);
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3, "grid_radius"), _SCS("set_grid_radius"), _SCS("get_grid_radius"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "grid_radius"), _SCS("set_grid_radius"), _SCS("get_grid_radius"));
- ADD_SIGNAL( MethodInfo("broadcast", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::ARRAY, "parameters")) );
+ ADD_SIGNAL(MethodInfo("broadcast", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::ARRAY, "parameters")));
};
-
ProximityGroup::ProximityGroup() {
group_version = 0;
dispatch_mode = MODE_PROXY;
grid_radius = Vector3(1, 1, 1);
-
};
-ProximityGroup::~ProximityGroup() {
+ProximityGroup::~ProximityGroup(){
};
diff --git a/scene/3d/proximity_group.h b/scene/3d/proximity_group.h
index 9a6cbd5de..26580dc31 100644
--- a/scene/3d/proximity_group.h
+++ b/scene/3d/proximity_group.h
@@ -33,7 +33,7 @@
class ProximityGroup : public Spatial {
- OBJ_TYPE( ProximityGroup, Spatial );
+ OBJ_TYPE(ProximityGroup, Spatial);
OBJ_CATEGORY("3D");
public:
@@ -57,7 +57,7 @@ public:
Vector3 grid_radius;
uint32_t group_version;
- void add_groups(int* p_cell, String p_base, int p_depth);
+ void add_groups(int *p_cell, String p_base, int p_depth);
void _new_group(StringName p_name);
void _proximity_group_broadcast(String p_name, Variant p_params);
@@ -65,12 +65,11 @@ public:
static void _bind_methods();
public:
-
void set_group_name(String p_group_name);
void broadcast(String p_name, Variant p_params);
void set_dispatch_mode(int p_mode);
- void set_grid_radius(const Vector3& p_radius);
+ void set_grid_radius(const Vector3 &p_radius);
Vector3 get_grid_radius() const;
ProximityGroup();
@@ -78,4 +77,3 @@ public:
};
#endif
-
diff --git a/scene/3d/quad.cpp b/scene/3d/quad.cpp
index 519757ba0..0892415bf 100644
--- a/scene/3d/quad.cpp
+++ b/scene/3d/quad.cpp
@@ -35,39 +35,36 @@ void Quad::_update() {
return;
Vector3 normal;
- normal[axis]=1.0;
-
- const int axis_order_1[3]={1,2,0};
- const int axis_order_2[3]={2,0,1};
- const int a1=axis_order_1[axis];
- const int a2=axis_order_2[axis];
-
+ normal[axis] = 1.0;
+ const int axis_order_1[3] = { 1, 2, 0 };
+ const int axis_order_2[3] = { 2, 0, 1 };
+ const int a1 = axis_order_1[axis];
+ const int a2 = axis_order_2[axis];
DVector<Vector3> points;
points.resize(4);
DVector<Vector3>::Write pointsw = points.write();
- Vector2 s2 = size*0.5;
+ Vector2 s2 = size * 0.5;
Vector2 o = offset;
if (!centered)
- o+=s2;
-
- pointsw[0][a1]=-s2.x+offset.x;
- pointsw[0][a2]=s2.y+offset.y;
+ o += s2;
- pointsw[1][a1]=s2.x+offset.x;
- pointsw[1][a2]=s2.y+offset.y;
+ pointsw[0][a1] = -s2.x + offset.x;
+ pointsw[0][a2] = s2.y + offset.y;
- pointsw[2][a1]=s2.x+offset.x;
- pointsw[2][a2]=-s2.y+offset.y;
+ pointsw[1][a1] = s2.x + offset.x;
+ pointsw[1][a2] = s2.y + offset.y;
- pointsw[3][a1]=-s2.x+offset.x;
- pointsw[3][a2]=-s2.y+offset.y;
+ pointsw[2][a1] = s2.x + offset.x;
+ pointsw[2][a2] = -s2.y + offset.y;
+ pointsw[3][a1] = -s2.x + offset.x;
+ pointsw[3][a2] = -s2.y + offset.y;
- aabb=AABB(pointsw[0],Vector3());
- for(int i=1;i<4;i++)
+ aabb = AABB(pointsw[0], Vector3());
+ for (int i = 1; i < 4; i++)
aabb.expand_to(pointsw[i]);
pointsw = DVector<Vector3>::Write();
@@ -76,21 +73,19 @@ void Quad::_update() {
normals.resize(4);
DVector<Vector3>::Write normalsw = normals.write();
- for(int i=0;i<4;i++)
- normalsw[i]=normal;
-
- normalsw=DVector<Vector3>::Write();
-
+ for (int i = 0; i < 4; i++)
+ normalsw[i] = normal;
+ normalsw = DVector<Vector3>::Write();
DVector<Vector2> uvs;
uvs.resize(4);
DVector<Vector2>::Write uvsw = uvs.write();
- uvsw[0]=Vector2(0,0);
- uvsw[1]=Vector2(1,0);
- uvsw[2]=Vector2(1,1);
- uvsw[3]=Vector2(0,1);
+ uvsw[0] = Vector2(0, 0);
+ uvsw[1] = Vector2(1, 0);
+ uvsw[2] = Vector2(1, 1);
+ uvsw[3] = Vector2(0, 1);
uvsw = DVector<Vector2>::Write();
@@ -98,90 +93,86 @@ void Quad::_update() {
indices.resize(6);
DVector<int>::Write indicesw = indices.write();
- indicesw[0]=0;
- indicesw[1]=1;
- indicesw[2]=2;
- indicesw[3]=2;
- indicesw[4]=3;
- indicesw[5]=0;
+ indicesw[0] = 0;
+ indicesw[1] = 1;
+ indicesw[2] = 2;
+ indicesw[3] = 2;
+ indicesw[4] = 3;
+ indicesw[5] = 0;
- indicesw=DVector<int>::Write();
+ indicesw = DVector<int>::Write();
Array arr;
arr.resize(VS::ARRAY_MAX);
- arr[VS::ARRAY_VERTEX]=points;
- arr[VS::ARRAY_NORMAL]=normals;
- arr[VS::ARRAY_TEX_UV]=uvs;
- arr[VS::ARRAY_INDEX]=indices;
-
+ arr[VS::ARRAY_VERTEX] = points;
+ arr[VS::ARRAY_NORMAL] = normals;
+ arr[VS::ARRAY_TEX_UV] = uvs;
+ arr[VS::ARRAY_INDEX] = indices;
if (configured) {
- VS::get_singleton()->mesh_remove_surface(mesh,0);
+ VS::get_singleton()->mesh_remove_surface(mesh, 0);
} else {
- configured=true;
+ configured = true;
}
- VS::get_singleton()->mesh_add_surface(mesh,VS::PRIMITIVE_TRIANGLES,arr);
+ VS::get_singleton()->mesh_add_surface(mesh, VS::PRIMITIVE_TRIANGLES, arr);
- pending_update=false;
+ pending_update = false;
}
-
void Quad::set_axis(Vector3::Axis p_axis) {
- axis=p_axis;
+ axis = p_axis;
_update();
}
-Vector3::Axis Quad::get_axis() const{
+Vector3::Axis Quad::get_axis() const {
return axis;
}
-void Quad::set_size(const Vector2& p_size){
+void Quad::set_size(const Vector2 &p_size) {
- size=p_size;
+ size = p_size;
_update();
}
-Vector2 Quad::get_size() const{
+Vector2 Quad::get_size() const {
return size;
}
-void Quad::set_offset(const Vector2& p_offset){
+void Quad::set_offset(const Vector2 &p_offset) {
- offset=p_offset;
+ offset = p_offset;
_update();
}
-Vector2 Quad::get_offset() const{
+Vector2 Quad::get_offset() const {
return offset;
}
-void Quad::set_centered(bool p_enabled){
+void Quad::set_centered(bool p_enabled) {
- centered=p_enabled;
+ centered = p_enabled;
_update();
}
-bool Quad::is_centered() const{
+bool Quad::is_centered() const {
return centered;
}
void Quad::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (pending_update)
_update();
-
} break;
case NOTIFICATION_EXIT_TREE: {
- pending_update=true;
-
+ pending_update = true;
} break;
}
@@ -197,38 +188,36 @@ AABB Quad::get_aabb() const {
return aabb;
}
-void Quad::_bind_methods(){
+void Quad::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_axis","axis"),&Quad::set_axis);
- ObjectTypeDB::bind_method(_MD("get_axis"),&Quad::get_axis);
+ ObjectTypeDB::bind_method(_MD("set_axis", "axis"), &Quad::set_axis);
+ ObjectTypeDB::bind_method(_MD("get_axis"), &Quad::get_axis);
- ObjectTypeDB::bind_method(_MD("set_size","size"),&Quad::set_size);
- ObjectTypeDB::bind_method(_MD("get_size"),&Quad::get_size);
+ ObjectTypeDB::bind_method(_MD("set_size", "size"), &Quad::set_size);
+ ObjectTypeDB::bind_method(_MD("get_size"), &Quad::get_size);
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&Quad::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&Quad::is_centered);
+ ObjectTypeDB::bind_method(_MD("set_centered", "centered"), &Quad::set_centered);
+ ObjectTypeDB::bind_method(_MD("is_centered"), &Quad::is_centered);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Quad::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&Quad::get_offset);
-
- ADD_PROPERTY( PropertyInfo( Variant::INT, "quad/axis", PROPERTY_HINT_ENUM,"X,Y,Z" ), _SCS("set_axis"), _SCS("get_axis"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "quad/size" ), _SCS("set_size"), _SCS("get_size"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "quad/offset" ), _SCS("set_offset"), _SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "quad/centered" ), _SCS("set_centered"), _SCS("is_centered"));
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &Quad::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &Quad::get_offset);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "quad/axis", PROPERTY_HINT_ENUM, "X,Y,Z"), _SCS("set_axis"), _SCS("get_axis"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "quad/size"), _SCS("set_size"), _SCS("get_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "quad/offset"), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "quad/centered"), _SCS("set_centered"), _SCS("is_centered"));
}
Quad::Quad() {
- pending_update=true;
- centered=true;
+ pending_update = true;
+ centered = true;
//offset=0;
- size=Vector2(1,1);
- axis=Vector3::AXIS_Z;
- mesh=VisualServer::get_singleton()->mesh_create();
+ size = Vector2(1, 1);
+ axis = Vector3::AXIS_Z;
+ mesh = VisualServer::get_singleton()->mesh_create();
set_base(mesh);
- configured=false;
-
+ configured = false;
}
Quad::~Quad() {
diff --git a/scene/3d/quad.h b/scene/3d/quad.h
index 92f000914..aa0d1e000 100644
--- a/scene/3d/quad.h
+++ b/scene/3d/quad.h
@@ -29,13 +29,12 @@
#ifndef QUAD_H
#define QUAD_H
-
-#include "scene/3d/visual_instance.h"
#include "rid.h"
+#include "scene/3d/visual_instance.h"
class Quad : public GeometryInstance {
- OBJ_TYPE(Quad,GeometryInstance);
+ OBJ_TYPE(Quad, GeometryInstance);
Vector3::Axis axis;
bool centered;
@@ -50,18 +49,17 @@ class Quad : public GeometryInstance {
void _update();
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_axis(Vector3::Axis p_axis);
Vector3::Axis get_axis() const;
- void set_size(const Vector2& p_sizze);
+ void set_size(const Vector2 &p_sizze);
Vector2 get_size() const;
- void set_offset(const Vector2& p_offset);
+ void set_offset(const Vector2 &p_offset);
Vector2 get_offset() const;
void set_centered(bool p_enabled);
@@ -74,5 +72,4 @@ public:
~Quad();
};
-
#endif // QUAD_H
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index bcc8b001d..ec24acc82 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -28,24 +28,23 @@
/*************************************************************************/
#include "ray_cast.h"
-#include "servers/physics_server.h"
#include "collision_object.h"
-void RayCast::set_cast_to(const Vector3& p_point) {
+#include "servers/physics_server.h"
+void RayCast::set_cast_to(const Vector3 &p_point) {
- cast_to=p_point;
+ cast_to = p_point;
if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
update_gizmo();
-
}
-Vector3 RayCast::get_cast_to() const{
+Vector3 RayCast::get_cast_to() const {
return cast_to;
}
void RayCast::set_layer_mask(uint32_t p_mask) {
- layer_mask=p_mask;
+ layer_mask = p_mask;
}
uint32_t RayCast::get_layer_mask() const {
@@ -55,7 +54,7 @@ uint32_t RayCast::get_layer_mask() const {
void RayCast::set_type_mask(uint32_t p_mask) {
- type_mask=p_mask;
+ type_mask = p_mask;
}
uint32_t RayCast::get_type_mask() const {
@@ -63,13 +62,13 @@ uint32_t RayCast::get_type_mask() const {
return type_mask;
}
-bool RayCast::is_colliding() const{
+bool RayCast::is_colliding() const {
return collided;
}
-Object *RayCast::get_collider() const{
+Object *RayCast::get_collider() const {
- if (against==0)
+ if (against == 0)
return NULL;
return ObjectDB::get_instance(against);
@@ -79,37 +78,32 @@ int RayCast::get_collider_shape() const {
return against_shape;
}
-Vector3 RayCast::get_collision_point() const{
+Vector3 RayCast::get_collision_point() const {
return collision_point;
}
-Vector3 RayCast::get_collision_normal() const{
+Vector3 RayCast::get_collision_normal() const {
return collision_normal;
}
-
void RayCast::set_enabled(bool p_enabled) {
- enabled=p_enabled;
+ enabled = p_enabled;
if (is_inside_tree() && !get_tree()->is_editor_hint())
set_fixed_process(p_enabled);
if (!p_enabled)
- collided=false;
-
+ collided = false;
}
-
bool RayCast::is_enabled() const {
-
return enabled;
}
-
void RayCast::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -118,8 +112,6 @@ void RayCast::_notification(int p_what) {
} else
set_fixed_process(false);
-
-
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -127,7 +119,6 @@ void RayCast::_notification(int p_what) {
set_fixed_process(false);
}
-
} break;
case NOTIFICATION_FIXED_PROCESS: {
@@ -136,35 +127,34 @@ void RayCast::_notification(int p_what) {
_update_raycast_state();
-
} break;
}
}
-void RayCast::_update_raycast_state(){
+void RayCast::_update_raycast_state() {
Ref<World> w3d = get_world();
- ERR_FAIL_COND( w3d.is_null() );
+ ERR_FAIL_COND(w3d.is_null());
PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(w3d->get_space());
- ERR_FAIL_COND( !dss );
+ ERR_FAIL_COND(!dss);
Transform gt = get_global_transform();
Vector3 to = cast_to;
- if (to==Vector3())
- to=Vector3(0,0.01,0);
+ if (to == Vector3())
+ to = Vector3(0, 0.01, 0);
PhysicsDirectSpaceState::RayResult rr;
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude, layer_mask, type_mask)) {
+ if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, layer_mask, type_mask)) {
- collided=true;
- against=rr.collider_id;
- collision_point=rr.position;
- collision_normal=rr.normal;
- against_shape=rr.shape;
+ collided = true;
+ against = rr.collider_id;
+ collision_point = rr.position;
+ collision_normal = rr.normal;
+ against_shape = rr.shape;
} else {
- collided=false;
+ collided = false;
}
}
@@ -172,85 +162,82 @@ void RayCast::force_raycast_update() {
_update_raycast_state();
}
-void RayCast::add_exception_rid(const RID& p_rid) {
+void RayCast::add_exception_rid(const RID &p_rid) {
exclude.insert(p_rid);
}
-void RayCast::add_exception(const Object* p_object){
+void RayCast::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- CollisionObject *co=((Object*)p_object)->cast_to<CollisionObject>();
+ CollisionObject *co = ((Object *)p_object)->cast_to<CollisionObject>();
if (!co)
return;
add_exception_rid(co->get_rid());
}
-void RayCast::remove_exception_rid(const RID& p_rid) {
+void RayCast::remove_exception_rid(const RID &p_rid) {
exclude.erase(p_rid);
}
-void RayCast::remove_exception(const Object* p_object){
+void RayCast::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
- CollisionObject *co=((Object*)p_object)->cast_to<CollisionObject>();
+ CollisionObject *co = ((Object *)p_object)->cast_to<CollisionObject>();
if (!co)
return;
remove_exception_rid(co->get_rid());
}
-
-void RayCast::clear_exceptions(){
+void RayCast::clear_exceptions() {
exclude.clear();
}
-
void RayCast::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_enabled", "enabled"), &RayCast::set_enabled);
+ ObjectTypeDB::bind_method(_MD("is_enabled"), &RayCast::is_enabled);
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&RayCast::set_enabled);
- ObjectTypeDB::bind_method(_MD("is_enabled"),&RayCast::is_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_cast_to","local_point"),&RayCast::set_cast_to);
- ObjectTypeDB::bind_method(_MD("get_cast_to"),&RayCast::get_cast_to);
+ ObjectTypeDB::bind_method(_MD("set_cast_to", "local_point"), &RayCast::set_cast_to);
+ ObjectTypeDB::bind_method(_MD("get_cast_to"), &RayCast::get_cast_to);
- ObjectTypeDB::bind_method(_MD("is_colliding"),&RayCast::is_colliding);
- ObjectTypeDB::bind_method(_MD("force_raycast_update"),&RayCast::force_raycast_update);
+ ObjectTypeDB::bind_method(_MD("is_colliding"), &RayCast::is_colliding);
+ ObjectTypeDB::bind_method(_MD("force_raycast_update"), &RayCast::force_raycast_update);
- ObjectTypeDB::bind_method(_MD("get_collider"),&RayCast::get_collider);
- ObjectTypeDB::bind_method(_MD("get_collider_shape"),&RayCast::get_collider_shape);
- ObjectTypeDB::bind_method(_MD("get_collision_point"),&RayCast::get_collision_point);
- ObjectTypeDB::bind_method(_MD("get_collision_normal"),&RayCast::get_collision_normal);
+ ObjectTypeDB::bind_method(_MD("get_collider"), &RayCast::get_collider);
+ ObjectTypeDB::bind_method(_MD("get_collider_shape"), &RayCast::get_collider_shape);
+ ObjectTypeDB::bind_method(_MD("get_collision_point"), &RayCast::get_collision_point);
+ ObjectTypeDB::bind_method(_MD("get_collision_normal"), &RayCast::get_collision_normal);
- ObjectTypeDB::bind_method(_MD("add_exception_rid","rid"),&RayCast::add_exception_rid);
- ObjectTypeDB::bind_method(_MD("add_exception","node"),&RayCast::add_exception);
+ ObjectTypeDB::bind_method(_MD("add_exception_rid", "rid"), &RayCast::add_exception_rid);
+ ObjectTypeDB::bind_method(_MD("add_exception", "node"), &RayCast::add_exception);
- ObjectTypeDB::bind_method(_MD("remove_exception_rid","rid"),&RayCast::remove_exception_rid);
- ObjectTypeDB::bind_method(_MD("remove_exception","node"),&RayCast::remove_exception);
+ ObjectTypeDB::bind_method(_MD("remove_exception_rid", "rid"), &RayCast::remove_exception_rid);
+ ObjectTypeDB::bind_method(_MD("remove_exception", "node"), &RayCast::remove_exception);
- ObjectTypeDB::bind_method(_MD("clear_exceptions"),&RayCast::clear_exceptions);
+ ObjectTypeDB::bind_method(_MD("clear_exceptions"), &RayCast::clear_exceptions);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&RayCast::set_layer_mask);
- ObjectTypeDB::bind_method(_MD("get_layer_mask"),&RayCast::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask", "mask"), &RayCast::set_layer_mask);
+ ObjectTypeDB::bind_method(_MD("get_layer_mask"), &RayCast::get_layer_mask);
- ObjectTypeDB::bind_method(_MD("set_type_mask","mask"),&RayCast::set_type_mask);
- ObjectTypeDB::bind_method(_MD("get_type_mask"),&RayCast::get_type_mask);
+ ObjectTypeDB::bind_method(_MD("set_type_mask", "mask"), &RayCast::set_type_mask);
+ ObjectTypeDB::bind_method(_MD("get_type_mask"), &RayCast::get_type_mask);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),_SCS("set_type_mask"),_SCS("get_type_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cast_to"), _SCS("set_cast_to"), _SCS("get_cast_to"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "layer_mask", PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "type_mask", PROPERTY_HINT_FLAGS, "Static,Kinematic,Rigid,Character,Area"), _SCS("set_type_mask"), _SCS("get_type_mask"));
}
RayCast::RayCast() {
- enabled=false;
- against=0;
- collided=false;
- against_shape=0;
- layer_mask=1;
- type_mask=PhysicsDirectSpaceState::TYPE_MASK_COLLISION;
- cast_to=Vector3(0,-1,0);
+ enabled = false;
+ against = 0;
+ collided = false;
+ against_shape = 0;
+ layer_mask = 1;
+ type_mask = PhysicsDirectSpaceState::TYPE_MASK_COLLISION;
+ cast_to = Vector3(0, -1, 0);
}
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h
index 83f2d3a18..cac4090e7 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast.h
@@ -33,8 +33,7 @@
class RayCast : public Spatial {
- OBJ_TYPE(RayCast,Spatial);
-
+ OBJ_TYPE(RayCast, Spatial);
bool enabled;
bool collided;
@@ -51,16 +50,15 @@ class RayCast : public Spatial {
uint32_t type_mask;
protected:
-
void _notification(int p_what);
void _update_raycast_state();
static void _bind_methods();
-public:
+public:
void set_enabled(bool p_enabled);
bool is_enabled() const;
- void set_cast_to(const Vector3& p_point);
+ void set_cast_to(const Vector3 &p_point);
Vector3 get_cast_to() const;
void set_layer_mask(uint32_t p_mask);
@@ -76,10 +74,10 @@ public:
Vector3 get_collision_point() const;
Vector3 get_collision_normal() const;
- void add_exception_rid(const RID& p_rid);
- void add_exception(const Object* p_object);
- void remove_exception_rid(const RID& p_rid);
- void remove_exception(const Object* p_object);
+ void add_exception_rid(const RID &p_rid);
+ void add_exception(const Object *p_object);
+ void remove_exception_rid(const RID &p_rid);
+ void remove_exception(const Object *p_object);
void clear_exceptions();
RayCast();
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 3b4eb0b52..8e88aa430 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -34,77 +34,72 @@
#include "globals.h"
#include "scene/resources/surface_tool.h"
-
void Room::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
// go find parent level
- Node *parent_room=get_parent();
- level=0;
+ Node *parent_room = get_parent();
+ level = 0;
- while(parent_room) {
+ while (parent_room) {
Room *r = parent_room->cast_to<Room>();
if (r) {
- level=r->level+1;
+ level = r->level + 1;
break;
}
- parent_room=parent_room->get_parent();
+ parent_room = parent_room->get_parent();
}
-
if (sound_enabled)
- SpatialSoundServer::get_singleton()->room_set_space(sound_room,get_world()->get_sound_space());
+ SpatialSoundServer::get_singleton()->room_set_space(sound_room, get_world()->get_sound_space());
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- SpatialSoundServer::get_singleton()->room_set_transform(sound_room,get_global_transform());
+ SpatialSoundServer::get_singleton()->room_set_transform(sound_room, get_global_transform());
} break;
case NOTIFICATION_EXIT_WORLD: {
if (sound_enabled)
- SpatialSoundServer::get_singleton()->room_set_space(sound_room,RID());
-
+ SpatialSoundServer::get_singleton()->room_set_space(sound_room, RID());
- } break;
+ } break;
}
-
}
-
RES Room::_get_gizmo_geometry() const {
DVector<Face3> faces;
if (!room.is_null())
- faces=room->get_geometry_hint();
+ faces = room->get_geometry_hint();
- int count=faces.size();
- if (count==0)
+ int count = faces.size();
+ if (count == 0)
return RES();
- DVector<Face3>::Read facesr=faces.read();
+ DVector<Face3>::Read facesr = faces.read();
- const Face3* facesptr=facesr.ptr();
+ const Face3 *facesptr = facesr.ptr();
DVector<Vector3> points;
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
+ Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
+ Ref<FixedMaterial> mat(memnew(FixedMaterial));
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.2,0.8,0.9,0.3) );
+ mat->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.2, 0.8, 0.9, 0.3));
mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
+ mat->set_flag(Material::FLAG_DOUBLE_SIDED, true);
+ mat->set_flag(Material::FLAG_UNSHADED, true);
+ // mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);
- for (int i=0;i<count;i++) {
+ for (int i = 0; i < count; i++) {
surface_tool->add_vertex(facesptr[i].vertex[0]);
surface_tool->add_vertex(facesptr[i].vertex[1]);
@@ -114,14 +109,11 @@ RES Room::_get_gizmo_geometry() const {
surface_tool->add_vertex(facesptr[i].vertex[2]);
surface_tool->add_vertex(facesptr[i].vertex[0]);
-
}
return surface_tool->commit();
}
-
-
AABB Room::get_aabb() const {
if (room.is_null())
@@ -132,12 +124,11 @@ AABB Room::get_aabb() const {
DVector<Face3> Room::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
-
}
-void Room::set_room( const Ref<RoomBounds>& p_room ) {
+void Room::set_room(const Ref<RoomBounds> &p_room) {
- room=p_room;
+ room = p_room;
update_gizmo();
if (room.is_valid()) {
@@ -150,14 +141,11 @@ void Room::set_room( const Ref<RoomBounds>& p_room ) {
if (!is_inside_tree())
return;
-
propagate_notification(NOTIFICATION_AREA_CHANGED);
update_gizmo();
if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_bounds(sound_room,room->get_bounds());
-
-
+ SpatialSoundServer::get_singleton()->room_set_bounds(sound_room, room->get_bounds());
}
Ref<RoomBounds> Room::get_room() const {
@@ -165,86 +153,76 @@ Ref<RoomBounds> Room::get_room() const {
return room;
}
-void Room::_parse_node_faces(DVector<Face3> &all_faces,const Node *p_node) const {
+void Room::_parse_node_faces(DVector<Face3> &all_faces, const Node *p_node) const {
- const VisualInstance *vi=p_node->cast_to<VisualInstance>();
+ const VisualInstance *vi = p_node->cast_to<VisualInstance>();
if (vi) {
- DVector<Face3> faces=vi->get_faces(FACES_ENCLOSING);
+ DVector<Face3> faces = vi->get_faces(FACES_ENCLOSING);
if (faces.size()) {
- int old_len=all_faces.size();
- all_faces.resize( all_faces.size() + faces.size() );
- int new_len=all_faces.size();
- DVector<Face3>::Write all_facesw=all_faces.write();
- Face3 * all_facesptr=all_facesw.ptr();
+ int old_len = all_faces.size();
+ all_faces.resize(all_faces.size() + faces.size());
+ int new_len = all_faces.size();
+ DVector<Face3>::Write all_facesw = all_faces.write();
+ Face3 *all_facesptr = all_facesw.ptr();
- DVector<Face3>::Read facesr=faces.read();
- const Face3 * facesptr=facesr.ptr();
+ DVector<Face3>::Read facesr = faces.read();
+ const Face3 *facesptr = facesr.ptr();
- Transform tr=vi->get_relative_transform(this);
+ Transform tr = vi->get_relative_transform(this);
- for(int i=old_len;i<new_len;i++) {
+ for (int i = old_len; i < new_len; i++) {
- Face3 f=facesptr[i-old_len];
- for (int j=0;j<3;j++)
- f.vertex[j]=tr.xform(f.vertex[j]);
- all_facesptr[i]=f;
+ Face3 f = facesptr[i - old_len];
+ for (int j = 0; j < 3; j++)
+ f.vertex[j] = tr.xform(f.vertex[j]);
+ all_facesptr[i] = f;
}
}
}
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- for (int i=0;i<p_node->get_child_count();i++) {
-
- _parse_node_faces(all_faces,p_node->get_child(i));
+ _parse_node_faces(all_faces, p_node->get_child(i));
}
-
}
void Room::compute_room_from_subtree() {
-
DVector<Face3> all_faces;
- _parse_node_faces(all_faces,this);
-
+ _parse_node_faces(all_faces, this);
- if (all_faces.size()==0)
+ if (all_faces.size() == 0)
return;
float error;
- DVector<Face3> wrapped_faces = Geometry::wrap_geometry(all_faces,&error);
+ DVector<Face3> wrapped_faces = Geometry::wrap_geometry(all_faces, &error);
-
- if (wrapped_faces.size()==0)
+ if (wrapped_faces.size() == 0)
return;
- BSP_Tree tree(wrapped_faces,error);
+ BSP_Tree tree(wrapped_faces, error);
- Ref<RoomBounds> room( memnew( RoomBounds ) );
+ Ref<RoomBounds> room(memnew(RoomBounds));
room->set_bounds(tree);
room->set_geometry_hint(wrapped_faces);
set_room(room);
-
}
-
-
void Room::set_simulate_acoustics(bool p_enable) {
- if (sound_enabled==p_enable)
+ if (sound_enabled == p_enable)
return;
- sound_enabled=p_enable;
+ sound_enabled = p_enable;
if (!is_inside_world())
return; //nothing to do
if (sound_enabled)
- SpatialSoundServer::get_singleton()->room_set_space(sound_room,get_world()->get_sound_space());
+ SpatialSoundServer::get_singleton()->room_set_space(sound_room, get_world()->get_sound_space());
else
- SpatialSoundServer::get_singleton()->room_set_space(sound_room,RID());
-
-
+ SpatialSoundServer::get_singleton()->room_set_space(sound_room, RID());
}
void Room::_bounds_changed() {
@@ -257,8 +235,6 @@ bool Room::is_simulating_acoustics() const {
return sound_enabled;
}
-
-
RID Room::get_sound_room() const {
return RID();
@@ -266,34 +242,26 @@ RID Room::get_sound_room() const {
void Room::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_room","room:Room"),&Room::set_room );
- ObjectTypeDB::bind_method(_MD("get_room:Room"),&Room::get_room );
- ObjectTypeDB::bind_method(_MD("compute_room_from_subtree"),&Room::compute_room_from_subtree);
+ ObjectTypeDB::bind_method(_MD("set_room", "room:Room"), &Room::set_room);
+ ObjectTypeDB::bind_method(_MD("get_room:Room"), &Room::get_room);
+ ObjectTypeDB::bind_method(_MD("compute_room_from_subtree"), &Room::compute_room_from_subtree);
+ ObjectTypeDB::bind_method(_MD("set_simulate_acoustics", "enable"), &Room::set_simulate_acoustics);
+ ObjectTypeDB::bind_method(_MD("is_simulating_acoustics"), &Room::is_simulating_acoustics);
-
- ObjectTypeDB::bind_method(_MD("set_simulate_acoustics","enable"),&Room::set_simulate_acoustics );
- ObjectTypeDB::bind_method(_MD("is_simulating_acoustics"),&Room::is_simulating_acoustics );
-
-
-
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "room/room", PROPERTY_HINT_RESOURCE_TYPE, "Area" ), _SCS("set_room"), _SCS("get_room") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "room/simulate_acoustics"), _SCS("set_simulate_acoustics"), _SCS("is_simulating_acoustics") );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "room/room", PROPERTY_HINT_RESOURCE_TYPE, "Area"), _SCS("set_room"), _SCS("get_room"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "room/simulate_acoustics"), _SCS("set_simulate_acoustics"), _SCS("is_simulating_acoustics"));
}
-
Room::Room() {
- sound_enabled=false;
- sound_room=SpatialSoundServer::get_singleton()->room_create();
-
- level=0;
+ sound_enabled = false;
+ sound_room = SpatialSoundServer::get_singleton()->room_create();
+ level = 0;
}
-
Room::~Room() {
SpatialSoundServer::get_singleton()->free(sound_room);
}
-
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index d0c7dd126..5dbd9bd33 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -36,7 +36,6 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-
/* RoomInstance Logic:
a) Instances that belong to the room are drawn only if the room is visible (seen through portal, or player inside)
b) Instances that don't belong to any room are considered to belong to the root room (RID empty)
@@ -44,15 +43,11 @@
*/
-
class Room : public VisualInstance {
- OBJ_TYPE( Room, VisualInstance );
-public:
-
-
-
+ OBJ_TYPE(Room, VisualInstance);
+public:
private:
Ref<RoomBounds> room;
@@ -61,29 +56,26 @@ private:
bool sound_enabled;
int level;
- void _parse_node_faces(DVector<Face3> &all_faces,const Node *p_node) const;
-
+ void _parse_node_faces(DVector<Face3> &all_faces, const Node *p_node) const;
void _bounds_changed();
virtual RES _get_gizmo_geometry() const;
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
enum {
// used to notify portals that the room in which they are has changed.
- NOTIFICATION_AREA_CHANGED=60
+ NOTIFICATION_AREA_CHANGED = 60
};
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- void set_room( const Ref<RoomBounds>& p_room );
+ void set_room(const Ref<RoomBounds> &p_room);
Ref<RoomBounds> get_room() const;
void set_simulate_acoustics(bool p_enable);
@@ -95,8 +87,6 @@ public:
Room();
~Room();
-
};
-
#endif // ROOM_INSTANCE_H
diff --git a/scene/3d/scenario_fx.cpp b/scene/3d/scenario_fx.cpp
index 51d8865e1..4b3878f2a 100644
--- a/scene/3d/scenario_fx.cpp
+++ b/scene/3d/scenario_fx.cpp
@@ -28,49 +28,42 @@
/*************************************************************************/
#include "scenario_fx.h"
-
-
void WorldEnvironment::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_ENTER_WORLD) {
+ if (p_what == NOTIFICATION_ENTER_WORLD) {
if (environment.is_valid()) {
if (get_world()->get_environment().is_valid()) {
WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding.");
}
get_world()->set_environment(environment);
- add_to_group("_world_environment_"+itos(get_world()->get_scenario().get_id()));
-
+ add_to_group("_world_environment_" + itos(get_world()->get_scenario().get_id()));
}
- } else if (p_what==NOTIFICATION_EXIT_WORLD) {
+ } else if (p_what == NOTIFICATION_EXIT_WORLD) {
- if (environment.is_valid() && get_world()->get_environment()==environment) {
+ if (environment.is_valid() && get_world()->get_environment() == environment) {
get_world()->set_environment(Ref<Environment>());
- remove_from_group("_world_environment_"+itos(get_world()->get_scenario().get_id()));
-
+ remove_from_group("_world_environment_" + itos(get_world()->get_scenario().get_id()));
}
}
}
-void WorldEnvironment::set_environment(const Ref<Environment>& p_environment) {
+void WorldEnvironment::set_environment(const Ref<Environment> &p_environment) {
- if (is_inside_world() && environment.is_valid() && get_world()->get_environment()==environment) {
+ if (is_inside_world() && environment.is_valid() && get_world()->get_environment() == environment) {
get_world()->set_environment(Ref<Environment>());
- remove_from_group("_world_environment_"+itos(get_world()->get_scenario().get_id()));
+ remove_from_group("_world_environment_" + itos(get_world()->get_scenario().get_id()));
//clean up
}
-
- environment=p_environment;
+ environment = p_environment;
if (is_inside_world() && environment.is_valid()) {
if (get_world()->get_environment().is_valid()) {
WARN_PRINT("World already has an environment (Another WorldEnvironment?), overriding.");
}
get_world()->set_environment(environment);
- add_to_group("_world_environment_"+itos(get_world()->get_scenario().get_id()));
-
+ add_to_group("_world_environment_" + itos(get_world()->get_scenario().get_id()));
}
update_configuration_warning();
@@ -86,29 +79,22 @@ String WorldEnvironment::get_configuration_warning() const {
if (!is_visible() || !is_inside_tree() || !environment.is_valid())
return String();
- List<Node*> nodes;
- get_tree()->get_nodes_in_group("_world_environment_"+itos(get_world()->get_scenario().get_id()),&nodes);
+ List<Node *> nodes;
+ get_tree()->get_nodes_in_group("_world_environment_" + itos(get_world()->get_scenario().get_id()), &nodes);
- if (nodes.size()>1) {
+ if (nodes.size() > 1) {
return TTR("Only one WorldEnvironment is allowed per scene (or set of instanced scenes).");
}
return String();
}
-
void WorldEnvironment::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&WorldEnvironment::set_environment);
- ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&WorldEnvironment::get_environment);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),_SCS("set_environment"),_SCS("get_environment"));
-
+ ObjectTypeDB::bind_method(_MD("set_environment", "env:Environment"), &WorldEnvironment::set_environment);
+ ObjectTypeDB::bind_method(_MD("get_environment:Environment"), &WorldEnvironment::get_environment);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), _SCS("set_environment"), _SCS("get_environment"));
}
-
WorldEnvironment::WorldEnvironment() {
-
-
}
-
-
diff --git a/scene/3d/scenario_fx.h b/scene/3d/scenario_fx.h
index a11f1acab..98f51bb08 100644
--- a/scene/3d/scenario_fx.h
+++ b/scene/3d/scenario_fx.h
@@ -31,30 +31,27 @@
#include "scene/3d/spatial.h"
-
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
class WorldEnvironment : public Spatial {
- OBJ_TYPE(WorldEnvironment,Spatial );
+ OBJ_TYPE(WorldEnvironment, Spatial);
Ref<Environment> environment;
protected:
-
void _notification(int p_what);
static void _bind_methods();
+
public:
- void set_environment(const Ref<Environment>& p_environment);
+ void set_environment(const Ref<Environment> &p_environment);
Ref<Environment> get_environment() const;
String get_configuration_warning() const;
WorldEnvironment();
-
};
#endif
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index 6ca954190..4d981b98b 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -30,50 +30,48 @@
#include "message_queue.h"
-#include "scene/resources/surface_tool.h"
#include "core/globals.h"
+#include "scene/resources/surface_tool.h"
-
-bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {
+bool Skeleton::_set(const StringName &p_path, const Variant &p_value) {
String path = p_path;
if (!path.begins_with("bones/"))
return false;
- int which=path.get_slicec('/',1).to_int();
- String what=path.get_slicec('/',2);
+ int which = path.get_slicec('/', 1).to_int();
+ String what = path.get_slicec('/', 2);
-
- if (which==bones.size() && what=="name") {
+ if (which == bones.size() && what == "name") {
add_bone(p_value);
return true;
}
- ERR_FAIL_INDEX_V( which, bones.size(), false );
+ ERR_FAIL_INDEX_V(which, bones.size(), false);
- if (what=="parent")
- set_bone_parent(which, p_value );
- else if (what=="rest")
+ if (what == "parent")
+ set_bone_parent(which, p_value);
+ else if (what == "rest")
set_bone_rest(which, p_value);
- else if (what=="enabled")
+ else if (what == "enabled")
set_bone_enabled(which, p_value);
- else if (what=="pose")
+ else if (what == "pose")
set_bone_pose(which, p_value);
- else if (what=="bound_childs") {
- Array children=p_value;
+ else if (what == "bound_childs") {
+ Array children = p_value;
if (is_inside_tree()) {
bones[which].nodes_bound.clear();
- for (int i=0;i<children.size();i++) {
+ for (int i = 0; i < children.size(); i++) {
- NodePath path=children[i];
- ERR_CONTINUE( path.operator String()=="" );
+ NodePath path = children[i];
+ ERR_CONTINUE(path.operator String() == "");
Node *node = get_node(path);
ERR_CONTINUE(!node);
- bind_child_node_to_bone(which,node);
+ bind_child_node_to_bone(which, node);
}
}
} else {
@@ -83,72 +81,70 @@ bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {
return true;
}
-bool Skeleton::_get(const StringName& p_name,Variant &r_ret) const {
+bool Skeleton::_get(const StringName &p_name, Variant &r_ret) const {
- String path=p_name;
+ String path = p_name;
if (!path.begins_with("bones/"))
return false;
- int which=path.get_slicec('/',1).to_int();
- String what=path.get_slicec('/',2);
+ int which = path.get_slicec('/', 1).to_int();
+ String what = path.get_slicec('/', 2);
- ERR_FAIL_INDEX_V( which, bones.size(), false );
+ ERR_FAIL_INDEX_V(which, bones.size(), false);
- if (what=="name")
- r_ret=get_bone_name(which);
- else if (what=="parent")
- r_ret=get_bone_parent(which);
- else if (what=="rest")
- r_ret=get_bone_rest(which);
- else if (what=="enabled")
- r_ret=is_bone_enabled(which);
- else if (what=="pose")
- r_ret=get_bone_pose(which);
- else if (what=="bound_childs") {
+ if (what == "name")
+ r_ret = get_bone_name(which);
+ else if (what == "parent")
+ r_ret = get_bone_parent(which);
+ else if (what == "rest")
+ r_ret = get_bone_rest(which);
+ else if (what == "enabled")
+ r_ret = is_bone_enabled(which);
+ else if (what == "pose")
+ r_ret = get_bone_pose(which);
+ else if (what == "bound_childs") {
Array children;
- for (const List<uint32_t>::Element *E=bones[which].nodes_bound.front();E;E=E->next()) {
+ for (const List<uint32_t>::Element *E = bones[which].nodes_bound.front(); E; E = E->next()) {
- Object *obj=ObjectDB::get_instance(E->get());
+ Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
- Node *node=obj->cast_to<Node>();
+ Node *node = obj->cast_to<Node>();
ERR_CONTINUE(!node);
- NodePath path=get_path_to(node);
+ NodePath path = get_path_to(node);
children.push_back(path);
-
}
- r_ret=children;
+ r_ret = children;
} else
return false;
return true;
-
}
-void Skeleton::_get_property_list( List<PropertyInfo>* p_list ) const {
+void Skeleton::_get_property_list(List<PropertyInfo> *p_list) const {
- for (int i=0;i<bones.size();i++) {
+ for (int i = 0; i < bones.size(); i++) {
- String prep="bones/"+itos(i)+"/";
- p_list->push_back( PropertyInfo( Variant::STRING, prep+"name" ) );
- p_list->push_back( PropertyInfo( Variant::INT, prep+"parent" , PROPERTY_HINT_RANGE,"-1,"+itos(i-1)+",1") );
- p_list->push_back( PropertyInfo( Variant::TRANSFORM, prep+"rest" ) );
- p_list->push_back( PropertyInfo( Variant::BOOL, prep+"enabled" ) );
- p_list->push_back( PropertyInfo( Variant::TRANSFORM, prep+"pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR ) );
- p_list->push_back( PropertyInfo( Variant::ARRAY, prep+"bound_childs" ) );
+ String prep = "bones/" + itos(i) + "/";
+ p_list->push_back(PropertyInfo(Variant::STRING, prep + "name"));
+ p_list->push_back(PropertyInfo(Variant::INT, prep + "parent", PROPERTY_HINT_RANGE, "-1," + itos(i - 1) + ",1"));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "rest"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled"));
+ p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::ARRAY, prep + "bound_childs"));
}
}
void Skeleton::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
if (dirty) {
- dirty=false;
+ dirty = false;
_make_dirty(); // property make it dirty
}
@@ -158,97 +154,95 @@ void Skeleton::_notification(int p_what) {
} break;
case NOTIFICATION_UPDATE_SKELETON: {
+ VisualServer *vs = VisualServer::get_singleton();
+ Bone *bonesptr = &bones[0];
+ int len = bones.size();
- VisualServer *vs=VisualServer::get_singleton();
- Bone *bonesptr=&bones[0];
- int len=bones.size();
-
- vs->skeleton_resize( skeleton, len ); // if same size, nothin really happens
+ vs->skeleton_resize(skeleton, len); // if same size, nothin really happens
// pose changed, rebuild cache of inverses
if (rest_global_inverse_dirty) {
// calculate global rests and invert them
- for (int i=0;i<len;i++) {
- Bone &b=bonesptr[i];
- if (b.parent>=0)
- b.rest_global_inverse=bonesptr[b.parent].rest_global_inverse * b.rest;
+ for (int i = 0; i < len; i++) {
+ Bone &b = bonesptr[i];
+ if (b.parent >= 0)
+ b.rest_global_inverse = bonesptr[b.parent].rest_global_inverse * b.rest;
else
- b.rest_global_inverse=b.rest;
+ b.rest_global_inverse = b.rest;
}
- for (int i=0;i<len;i++) {
- Bone &b=bonesptr[i];
+ for (int i = 0; i < len; i++) {
+ Bone &b = bonesptr[i];
b.rest_global_inverse.affine_invert();
}
- rest_global_inverse_dirty=false;
-
+ rest_global_inverse_dirty = false;
}
- for (int i=0;i<len;i++) {
+ for (int i = 0; i < len; i++) {
- Bone &b=bonesptr[i];
+ Bone &b = bonesptr[i];
if (b.disable_rest) {
if (b.enabled) {
- Transform pose=b.pose;
+ Transform pose = b.pose;
if (b.custom_pose_enable) {
pose = b.custom_pose * pose;
}
- if (b.parent>=0) {
+ if (b.parent >= 0) {
- b.pose_global=bonesptr[b.parent].pose_global * pose;
+ b.pose_global = bonesptr[b.parent].pose_global * pose;
} else {
- b.pose_global=pose;
+ b.pose_global = pose;
}
} else {
- if (b.parent>=0) {
+ if (b.parent >= 0) {
- b.pose_global=bonesptr[b.parent].pose_global;
+ b.pose_global = bonesptr[b.parent].pose_global;
} else {
- b.pose_global=Transform();
+ b.pose_global = Transform();
}
}
} else {
if (b.enabled) {
- Transform pose=b.pose;
+ Transform pose = b.pose;
if (b.custom_pose_enable) {
pose = b.custom_pose * pose;
}
- if (b.parent>=0) {
+ if (b.parent >= 0) {
- b.pose_global=bonesptr[b.parent].pose_global * (b.rest * pose);
+ b.pose_global = bonesptr[b.parent].pose_global * (b.rest * pose);
} else {
- b.pose_global=b.rest * pose;
+ b.pose_global = b.rest * pose;
}
} else {
- if (b.parent>=0) {
+ if (b.parent >= 0) {
- b.pose_global=bonesptr[b.parent].pose_global * b.rest;
+ b.pose_global = bonesptr[b.parent].pose_global * b.rest;
} else {
- b.pose_global=b.rest;
+ b.pose_global = b.rest;
}
}
}
- vs->skeleton_bone_set_transform( skeleton, i, b.pose_global * b.rest_global_inverse );
+ vs->skeleton_bone_set_transform(skeleton, i, b.pose_global * b.rest_global_inverse);
- for(List<uint32_t>::Element *E=b.nodes_bound.front();E;E=E->next()) {
+ for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) {
- Object *obj=ObjectDB::get_instance(E->get());
+ Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
Spatial *sp = obj->cast_to<Spatial>();
ERR_CONTINUE(!sp);
@@ -256,38 +250,35 @@ void Skeleton::_notification(int p_what) {
}
}
- dirty=false;
+ dirty = false;
} break;
}
}
Transform Skeleton::get_bone_transform(int p_bone) const {
- ERR_FAIL_INDEX_V(p_bone,bones.size(),Transform());
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
if (dirty)
- const_cast<Skeleton*>(this)->notification(NOTIFICATION_UPDATE_SKELETON);
+ const_cast<Skeleton *>(this)->notification(NOTIFICATION_UPDATE_SKELETON);
return bones[p_bone].pose_global * bones[p_bone].rest_global_inverse;
}
+void Skeleton::set_bone_global_pose(int p_bone, const Transform &p_pose) {
-void Skeleton::set_bone_global_pose(int p_bone,const Transform& p_pose) {
+ ERR_FAIL_INDEX(p_bone, bones.size());
+ if (bones[p_bone].parent == -1) {
- ERR_FAIL_INDEX(p_bone,bones.size());
- if (bones[p_bone].parent==-1) {
-
- set_bone_pose(p_bone,bones[p_bone].rest_global_inverse * p_pose); //fast
+ set_bone_pose(p_bone, bones[p_bone].rest_global_inverse * p_pose); //fast
} else {
set_bone_pose(p_bone, bones[p_bone].rest.affine_inverse() * (get_bone_global_pose(bones[p_bone].parent).affine_inverse() * p_pose)); //slow
-
}
-
}
Transform Skeleton::get_bone_global_pose(int p_bone) const {
- ERR_FAIL_INDEX_V(p_bone,bones.size(),Transform());
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
if (dirty)
- const_cast<Skeleton*>(this)->notification(NOTIFICATION_UPDATE_SKELETON);
+ const_cast<Skeleton *>(this)->notification(NOTIFICATION_UPDATE_SKELETON);
return bones[p_bone].pose_global;
}
@@ -297,28 +288,28 @@ RID Skeleton::get_skeleton() const {
}
// skeleton creation api
-void Skeleton::add_bone(const String& p_name) {
+void Skeleton::add_bone(const String &p_name) {
- ERR_FAIL_COND( p_name=="" || p_name.find(":")!=-1 || p_name.find("/")!=-1 );
+ ERR_FAIL_COND(p_name == "" || p_name.find(":") != -1 || p_name.find("/") != -1);
- for (int i=0;i<bones.size();i++) {
+ for (int i = 0; i < bones.size(); i++) {
- ERR_FAIL_COND( bones[i].name=="p_name");
+ ERR_FAIL_COND(bones[i].name == "p_name");
}
Bone b;
- b.name=p_name;
+ b.name = p_name;
bones.push_back(b);
- rest_global_inverse_dirty=true;
+ rest_global_inverse_dirty = true;
_make_dirty();
update_gizmo();
}
int Skeleton::find_bone(String p_name) const {
- for (int i=0;i<bones.size();i++) {
+ for (int i = 0; i < bones.size(); i++) {
- if (bones[i].name==p_name)
+ if (bones[i].name == p_name)
return i;
}
@@ -326,7 +317,7 @@ int Skeleton::find_bone(String p_name) const {
}
String Skeleton::get_bone_name(int p_bone) const {
- ERR_FAIL_INDEX_V( p_bone, bones.size(), "" );
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), "");
return bones[p_bone].name;
}
@@ -338,293 +329,265 @@ int Skeleton::get_bone_count() const {
void Skeleton::set_bone_parent(int p_bone, int p_parent) {
- ERR_FAIL_INDEX( p_bone, bones.size() );
- ERR_FAIL_COND( p_parent!=-1 && (p_parent<0 || p_parent>=p_bone));
+ ERR_FAIL_INDEX(p_bone, bones.size());
+ ERR_FAIL_COND(p_parent != -1 && (p_parent < 0 || p_parent >= p_bone));
- bones[p_bone].parent=p_parent;
- rest_global_inverse_dirty=true;
+ bones[p_bone].parent = p_parent;
+ rest_global_inverse_dirty = true;
_make_dirty();
}
void Skeleton::unparent_bone_and_rest(int p_bone) {
- ERR_FAIL_INDEX( p_bone, bones.size() );
+ ERR_FAIL_INDEX(p_bone, bones.size());
- int parent=bones[p_bone].parent;
- while(parent>=0) {
+ int parent = bones[p_bone].parent;
+ while (parent >= 0) {
bones[p_bone].rest = bones[parent].rest * bones[p_bone].rest;
- parent=bones[parent].parent;
+ parent = bones[parent].parent;
}
- bones[p_bone].parent=-1;
- bones[p_bone].rest_global_inverse=bones[p_bone].rest.affine_inverse(); //same thing
+ bones[p_bone].parent = -1;
+ bones[p_bone].rest_global_inverse = bones[p_bone].rest.affine_inverse(); //same thing
_make_dirty();
-
}
void Skeleton::set_bone_disable_rest(int p_bone, bool p_disable) {
- ERR_FAIL_INDEX( p_bone, bones.size() );
- bones[p_bone].disable_rest=p_disable;
-
+ ERR_FAIL_INDEX(p_bone, bones.size());
+ bones[p_bone].disable_rest = p_disable;
}
bool Skeleton::is_bone_rest_disabled(int p_bone) const {
- ERR_FAIL_INDEX_V( p_bone, bones.size(), false );
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), false);
return bones[p_bone].disable_rest;
}
-
int Skeleton::get_bone_parent(int p_bone) const {
- ERR_FAIL_INDEX_V( p_bone, bones.size(), -1 );
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), -1);
return bones[p_bone].parent;
}
-void Skeleton::set_bone_rest(int p_bone, const Transform& p_rest) {
+void Skeleton::set_bone_rest(int p_bone, const Transform &p_rest) {
- ERR_FAIL_INDEX( p_bone, bones.size() );
+ ERR_FAIL_INDEX(p_bone, bones.size());
- bones[p_bone].rest=p_rest;
- rest_global_inverse_dirty=true;
+ bones[p_bone].rest = p_rest;
+ rest_global_inverse_dirty = true;
_make_dirty();
-
}
Transform Skeleton::get_bone_rest(int p_bone) const {
- ERR_FAIL_INDEX_V( p_bone, bones.size(), Transform() );
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].rest;
-
}
void Skeleton::set_bone_enabled(int p_bone, bool p_enabled) {
- ERR_FAIL_INDEX( p_bone, bones.size() );
+ ERR_FAIL_INDEX(p_bone, bones.size());
- bones[p_bone].enabled=p_enabled;
- rest_global_inverse_dirty=true;
+ bones[p_bone].enabled = p_enabled;
+ rest_global_inverse_dirty = true;
_make_dirty();
}
bool Skeleton::is_bone_enabled(int p_bone) const {
- ERR_FAIL_INDEX_V( p_bone, bones.size(), false );
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), false);
return bones[p_bone].enabled;
-
}
-void Skeleton::bind_child_node_to_bone(int p_bone,Node *p_node) {
+void Skeleton::bind_child_node_to_bone(int p_bone, Node *p_node) {
ERR_FAIL_NULL(p_node);
- ERR_FAIL_INDEX( p_bone, bones.size() );
+ ERR_FAIL_INDEX(p_bone, bones.size());
- uint32_t id=p_node->get_instance_ID();
+ uint32_t id = p_node->get_instance_ID();
- for (List<uint32_t>::Element *E=bones[p_bone].nodes_bound.front();E;E=E->next()) {
+ for (List<uint32_t>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) {
- if (E->get()==id)
+ if (E->get() == id)
return; // already here
}
bones[p_bone].nodes_bound.push_back(id);
-
}
-void Skeleton::unbind_child_node_from_bone(int p_bone,Node *p_node) {
+void Skeleton::unbind_child_node_from_bone(int p_bone, Node *p_node) {
ERR_FAIL_NULL(p_node);
- ERR_FAIL_INDEX( p_bone, bones.size() );
+ ERR_FAIL_INDEX(p_bone, bones.size());
- uint32_t id=p_node->get_instance_ID();
+ uint32_t id = p_node->get_instance_ID();
bones[p_bone].nodes_bound.erase(id);
-
}
-void Skeleton::get_bound_child_nodes_to_bone(int p_bone,List<Node*> *p_bound) const {
+void Skeleton::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const {
- ERR_FAIL_INDEX( p_bone, bones.size() );
+ ERR_FAIL_INDEX(p_bone, bones.size());
- for (const List<uint32_t>::Element *E=bones[p_bone].nodes_bound.front();E;E=E->next()) {
+ for (const List<uint32_t>::Element *E = bones[p_bone].nodes_bound.front(); E; E = E->next()) {
- Object *obj=ObjectDB::get_instance(E->get());
+ Object *obj = ObjectDB::get_instance(E->get());
ERR_CONTINUE(!obj);
p_bound->push_back(obj->cast_to<Node>());
}
-
}
void Skeleton::clear_bones() {
bones.clear();
- rest_global_inverse_dirty=true;
+ rest_global_inverse_dirty = true;
_make_dirty();
}
// posing api
-void Skeleton::set_bone_pose(int p_bone, const Transform& p_pose) {
+void Skeleton::set_bone_pose(int p_bone, const Transform &p_pose) {
- ERR_FAIL_INDEX( p_bone, bones.size() );
- ERR_FAIL_COND( !is_inside_tree() );
+ ERR_FAIL_INDEX(p_bone, bones.size());
+ ERR_FAIL_COND(!is_inside_tree());
-
- bones[p_bone].pose=p_pose;
+ bones[p_bone].pose = p_pose;
_make_dirty();
}
Transform Skeleton::get_bone_pose(int p_bone) const {
- ERR_FAIL_INDEX_V( p_bone, bones.size(), Transform() );
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].pose;
-
}
-void Skeleton::set_bone_custom_pose(int p_bone, const Transform& p_custom_pose) {
-
- ERR_FAIL_INDEX( p_bone, bones.size() );
-// ERR_FAIL_COND( !is_inside_scene() );
+void Skeleton::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose) {
+ ERR_FAIL_INDEX(p_bone, bones.size());
+ // ERR_FAIL_COND( !is_inside_scene() );
- bones[p_bone].custom_pose_enable=(p_custom_pose!=Transform());
- bones[p_bone].custom_pose=p_custom_pose;
+ bones[p_bone].custom_pose_enable = (p_custom_pose != Transform());
+ bones[p_bone].custom_pose = p_custom_pose;
_make_dirty();
}
Transform Skeleton::get_bone_custom_pose(int p_bone) const {
- ERR_FAIL_INDEX_V( p_bone, bones.size(), Transform() );
+ ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
return bones[p_bone].custom_pose;
-
}
-
void Skeleton::_make_dirty() {
if (dirty)
return;
if (!is_inside_tree()) {
- dirty=true;
+ dirty = true;
return;
}
- MessageQueue::get_singleton()->push_notification( this, NOTIFICATION_UPDATE_SKELETON );
- dirty=true;
+ MessageQueue::get_singleton()->push_notification(this, NOTIFICATION_UPDATE_SKELETON);
+ dirty = true;
}
-
RES Skeleton::_get_gizmo_geometry() const {
if (!GLOBAL_DEF("debug/draw_skeleton", true))
return RES();
- if (bones.size()==0)
+ if (bones.size() == 0)
return RES();
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
+ Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
+ Ref<FixedMaterial> mat(memnew(FixedMaterial));
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.6,1.0,0.3,0.1) );
+ mat->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.6, 1.0, 0.3, 0.1));
mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
- mat->set_flag(Material::FLAG_ONTOP,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
+ mat->set_flag(Material::FLAG_DOUBLE_SIDED, true);
+ mat->set_flag(Material::FLAG_UNSHADED, true);
+ mat->set_flag(Material::FLAG_ONTOP, true);
+ // mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);
+ const Bone *bonesptr = &bones[0];
+ int len = bones.size();
- const Bone *bonesptr=&bones[0];
- int len=bones.size();
-
- for (int i=0;i<len;i++) {
+ for (int i = 0; i < len; i++) {
- const Bone &b=bonesptr[i];
+ const Bone &b = bonesptr[i];
Transform t;
- if (b.parent<0)
+ if (b.parent < 0)
continue;
- Vector3 v1=(bonesptr[b.parent].pose_global * bonesptr[b.parent].rest_global_inverse).xform(bonesptr[b.parent].rest_global_inverse.affine_inverse().origin);
- Vector3 v2=(b.pose_global * b.rest_global_inverse).xform(b.rest_global_inverse.affine_inverse().origin);
+ Vector3 v1 = (bonesptr[b.parent].pose_global * bonesptr[b.parent].rest_global_inverse).xform(bonesptr[b.parent].rest_global_inverse.affine_inverse().origin);
+ Vector3 v2 = (b.pose_global * b.rest_global_inverse).xform(b.rest_global_inverse.affine_inverse().origin);
surface_tool->add_vertex(v1);
surface_tool->add_vertex(v2);
-
}
return surface_tool->commit();
-
}
void Skeleton::localize_rests() {
- for(int i=bones.size()-1;i>=0;i--) {
+ for (int i = bones.size() - 1; i >= 0; i--) {
- if (bones[i].parent>=0)
- set_bone_rest(i,bones[bones[i].parent].rest.affine_inverse() * bones[i].rest);
+ if (bones[i].parent >= 0)
+ set_bone_rest(i, bones[bones[i].parent].rest.affine_inverse() * bones[i].rest);
}
}
-
-
void Skeleton::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("add_bone", "name"), &Skeleton::add_bone);
+ ObjectTypeDB::bind_method(_MD("find_bone", "name"), &Skeleton::find_bone);
+ ObjectTypeDB::bind_method(_MD("get_bone_name", "bone_idx"), &Skeleton::get_bone_name);
+ ObjectTypeDB::bind_method(_MD("get_bone_parent", "bone_idx"), &Skeleton::get_bone_parent);
+ ObjectTypeDB::bind_method(_MD("set_bone_parent", "bone_idx", "parent_idx"), &Skeleton::set_bone_parent);
+ ObjectTypeDB::bind_method(_MD("get_bone_count"), &Skeleton::get_bone_count);
- ObjectTypeDB::bind_method(_MD("add_bone","name"),&Skeleton::add_bone);
- ObjectTypeDB::bind_method(_MD("find_bone","name"),&Skeleton::find_bone);
- ObjectTypeDB::bind_method(_MD("get_bone_name","bone_idx"),&Skeleton::get_bone_name);
-
- ObjectTypeDB::bind_method(_MD("get_bone_parent","bone_idx"),&Skeleton::get_bone_parent);
- ObjectTypeDB::bind_method(_MD("set_bone_parent","bone_idx","parent_idx"),&Skeleton::set_bone_parent);
-
- ObjectTypeDB::bind_method(_MD("get_bone_count"),&Skeleton::get_bone_count);
+ ObjectTypeDB::bind_method(_MD("unparent_bone_and_rest", "bone_idx"), &Skeleton::unparent_bone_and_rest);
- ObjectTypeDB::bind_method(_MD("unparent_bone_and_rest","bone_idx"),&Skeleton::unparent_bone_and_rest);
+ ObjectTypeDB::bind_method(_MD("get_bone_rest", "bone_idx"), &Skeleton::get_bone_rest);
+ ObjectTypeDB::bind_method(_MD("set_bone_rest", "bone_idx", "rest"), &Skeleton::set_bone_rest);
- ObjectTypeDB::bind_method(_MD("get_bone_rest","bone_idx"),&Skeleton::get_bone_rest);
- ObjectTypeDB::bind_method(_MD("set_bone_rest","bone_idx","rest"),&Skeleton::set_bone_rest);
+ ObjectTypeDB::bind_method(_MD("set_bone_disable_rest", "bone_idx", "disable"), &Skeleton::set_bone_disable_rest);
+ ObjectTypeDB::bind_method(_MD("is_bone_rest_disabled", "bone_idx"), &Skeleton::is_bone_rest_disabled);
- ObjectTypeDB::bind_method(_MD("set_bone_disable_rest","bone_idx","disable"),&Skeleton::set_bone_disable_rest);
- ObjectTypeDB::bind_method(_MD("is_bone_rest_disabled","bone_idx"),&Skeleton::is_bone_rest_disabled);
+ ObjectTypeDB::bind_method(_MD("bind_child_node_to_bone", "bone_idx", "node:Node"), &Skeleton::bind_child_node_to_bone);
+ ObjectTypeDB::bind_method(_MD("unbind_child_node_from_bone", "bone_idx", "node:Node"), &Skeleton::unbind_child_node_from_bone);
+ ObjectTypeDB::bind_method(_MD("get_bound_child_nodes_to_bone", "bone_idx"), &Skeleton::_get_bound_child_nodes_to_bone);
- ObjectTypeDB::bind_method(_MD("bind_child_node_to_bone","bone_idx","node:Node"),&Skeleton::bind_child_node_to_bone);
- ObjectTypeDB::bind_method(_MD("unbind_child_node_from_bone","bone_idx","node:Node"),&Skeleton::unbind_child_node_from_bone);
- ObjectTypeDB::bind_method(_MD("get_bound_child_nodes_to_bone","bone_idx"),&Skeleton::_get_bound_child_nodes_to_bone);
+ ObjectTypeDB::bind_method(_MD("clear_bones"), &Skeleton::clear_bones);
- ObjectTypeDB::bind_method(_MD("clear_bones"),&Skeleton::clear_bones);
+ ObjectTypeDB::bind_method(_MD("get_bone_pose", "bone_idx"), &Skeleton::get_bone_pose);
+ ObjectTypeDB::bind_method(_MD("set_bone_pose", "bone_idx", "pose"), &Skeleton::set_bone_pose);
- ObjectTypeDB::bind_method(_MD("get_bone_pose","bone_idx"),&Skeleton::get_bone_pose);
- ObjectTypeDB::bind_method(_MD("set_bone_pose","bone_idx","pose"),&Skeleton::set_bone_pose);
+ ObjectTypeDB::bind_method(_MD("set_bone_global_pose", "bone_idx", "pose"), &Skeleton::set_bone_global_pose);
+ ObjectTypeDB::bind_method(_MD("get_bone_global_pose", "bone_idx"), &Skeleton::get_bone_global_pose);
- ObjectTypeDB::bind_method(_MD("set_bone_global_pose","bone_idx","pose"),&Skeleton::set_bone_global_pose);
- ObjectTypeDB::bind_method(_MD("get_bone_global_pose","bone_idx"),&Skeleton::get_bone_global_pose);
+ ObjectTypeDB::bind_method(_MD("get_bone_custom_pose", "bone_idx"), &Skeleton::get_bone_custom_pose);
+ ObjectTypeDB::bind_method(_MD("set_bone_custom_pose", "bone_idx", "custom_pose"), &Skeleton::set_bone_custom_pose);
- ObjectTypeDB::bind_method(_MD("get_bone_custom_pose","bone_idx"),&Skeleton::get_bone_custom_pose);
- ObjectTypeDB::bind_method(_MD("set_bone_custom_pose","bone_idx","custom_pose"),&Skeleton::set_bone_custom_pose);
+ ObjectTypeDB::bind_method(_MD("get_bone_transform", "bone_idx"), &Skeleton::get_bone_transform);
- ObjectTypeDB::bind_method(_MD("get_bone_transform","bone_idx"),&Skeleton::get_bone_transform);
-
- BIND_CONSTANT( NOTIFICATION_UPDATE_SKELETON );
+ BIND_CONSTANT(NOTIFICATION_UPDATE_SKELETON);
}
-
-
Skeleton::Skeleton() {
- rest_global_inverse_dirty=true;
- dirty=false;
- skeleton=VisualServer::get_singleton()->skeleton_create();
+ rest_global_inverse_dirty = true;
+ dirty = false;
+ skeleton = VisualServer::get_singleton()->skeleton_create();
}
-
Skeleton::~Skeleton() {
- VisualServer::get_singleton()->free( skeleton );
+ VisualServer::get_singleton()->free(skeleton);
}
-
-
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index ddecafd12..e28f0c46c 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -29,15 +29,15 @@
#ifndef SKELETON_H
#define SKELETON_H
-#include "scene/3d/spatial.h"
#include "rid.h"
+#include "scene/3d/spatial.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class Skeleton : public Spatial {
- OBJ_TYPE( Skeleton, Spatial );
+ OBJ_TYPE(Skeleton, Spatial);
struct Bone {
@@ -58,7 +58,12 @@ class Skeleton : public Spatial {
List<uint32_t> nodes_bound;
- Bone() { parent=-1; enabled=true; custom_pose_enable=false; disable_rest=false; }
+ Bone() {
+ parent = -1;
+ enabled = true;
+ custom_pose_enable = false;
+ disable_rest = false;
+ }
};
bool rest_global_inverse_dirty;
@@ -70,16 +75,16 @@ class Skeleton : public Spatial {
void _make_dirty();
bool dirty;
-//bind helpers
+ //bind helpers
Array _get_bound_child_nodes_to_bone(int p_bone) const {
Array bound;
- List<Node*> childs;
- get_bound_child_nodes_to_bone(p_bone,&childs);
+ List<Node *> childs;
+ get_bound_child_nodes_to_bone(p_bone, &childs);
- for (int i=0;i<childs.size();i++) {
+ for (int i = 0; i < childs.size(); i++) {
- bound.push_back( childs[i] );
+ bound.push_back(childs[i]);
}
return bound;
}
@@ -87,25 +92,22 @@ class Skeleton : public Spatial {
virtual RES _get_gizmo_geometry() const;
protected:
-
- bool _get(const StringName& p_name,Variant &r_ret) const;
- bool _set(const StringName& p_name, const Variant& p_value);
- void _get_property_list( List<PropertyInfo>* p_list ) const;
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
-
enum {
- NOTIFICATION_UPDATE_SKELETON=50
+ NOTIFICATION_UPDATE_SKELETON = 50
};
-
RID get_skeleton() const;
// skeleton creation api
- void add_bone(const String&p_name);
+ void add_bone(const String &p_name);
int find_bone(String p_name) const;
String get_bone_name(int p_bone) const;
@@ -119,35 +121,34 @@ public:
int get_bone_count() const;
- void set_bone_rest(int p_bone, const Transform& p_rest);
+ void set_bone_rest(int p_bone, const Transform &p_rest);
Transform get_bone_rest(int p_bone) const;
Transform get_bone_transform(int p_bone) const;
Transform get_bone_global_pose(int p_bone) const;
- void set_bone_global_pose(int p_bone,const Transform& p_pose);
+ void set_bone_global_pose(int p_bone, const Transform &p_pose);
void set_bone_enabled(int p_bone, bool p_enabled);
bool is_bone_enabled(int p_bone) const;
- void bind_child_node_to_bone(int p_bone,Node *p_node);
- void unbind_child_node_from_bone(int p_bone,Node *p_node);
- void get_bound_child_nodes_to_bone(int p_bone,List<Node*> *p_bound) const;
+ void bind_child_node_to_bone(int p_bone, Node *p_node);
+ void unbind_child_node_from_bone(int p_bone, Node *p_node);
+ void get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) const;
void clear_bones();
// posing api
- void set_bone_pose(int p_bone, const Transform& p_pose);
+ void set_bone_pose(int p_bone, const Transform &p_pose);
Transform get_bone_pose(int p_bone) const;
- void set_bone_custom_pose(int p_bone, const Transform& p_custom_pose);
+ void set_bone_custom_pose(int p_bone, const Transform &p_custom_pose);
Transform get_bone_custom_pose(int p_bone) const;
void localize_rests(); // used for loaders and tools
Skeleton();
~Skeleton();
-
};
#endif
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index 09c0e7704..bdc4388a6 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -28,8 +28,8 @@
/*************************************************************************/
#include "spatial.h"
-#include "scene/main/viewport.h"
#include "message_queue.h"
+#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
/*
@@ -66,10 +66,7 @@ future: no idea
*/
-
-
SpatialGizmo::SpatialGizmo() {
-
}
void Spatial::_notify_dirty() {
@@ -80,14 +77,12 @@ void Spatial::_notify_dirty() {
}
}
-
-
void Spatial::_update_local_transform() const {
data.local_transform.basis.set_euler(data.rotation);
data.local_transform.basis.scale(data.scale);
- data.dirty&=~DIRTY_LOCAL;
+ data.dirty &= ~DIRTY_LOCAL;
}
void Spatial::_propagate_transform_changed(Spatial *p_origin) {
@@ -95,53 +90,51 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) {
return;
}
-// if (data.dirty&DIRTY_GLOBAL)
-// return; //already dirty
+ // if (data.dirty&DIRTY_GLOBAL)
+ // return; //already dirty
data.children_lock++;
- for (List<Spatial*>::Element *E=data.children.front();E;E=E->next()) {
+ for (List<Spatial *>::Element *E = data.children.front(); E; E = E->next()) {
if (E->get()->data.toplevel_active)
continue; //don't propagate to a toplevel
E->get()->_propagate_transform_changed(p_origin);
}
-
if (!data.ignore_notification && !xform_change.in_list()) {
get_tree()->xform_change_list.add(&xform_change);
-
}
- data.dirty|=DIRTY_GLOBAL;
+ data.dirty |= DIRTY_GLOBAL;
data.children_lock--;
}
void Spatial::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
Node *p = get_parent();
if (p)
- data.parent=p->cast_to<Spatial>();
+ data.parent = p->cast_to<Spatial>();
if (data.parent)
- data.C=data.parent->data.children.push_back(this);
+ data.C = data.parent->data.children.push_back(this);
else
- data.C=NULL;
+ data.C = NULL;
if (data.toplevel && !get_tree()->is_editor_hint()) {
if (data.parent) {
data.local_transform = data.parent->get_global_transform() * get_transform();
- data.dirty=DIRTY_VECTORS; //global is always dirty upon entering a scene
+ data.dirty = DIRTY_VECTORS; //global is always dirty upon entering a scene
}
- data.toplevel_active=true;
+ data.toplevel_active = true;
}
- data.dirty|=DIRTY_GLOBAL; //global is always dirty upon entering a scene
+ data.dirty |= DIRTY_GLOBAL; //global is always dirty upon entering a scene
_notify_dirty();
notification(NOTIFICATION_ENTER_WORLD);
@@ -149,38 +142,37 @@ void Spatial::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
- notification(NOTIFICATION_EXIT_WORLD,true);
+ notification(NOTIFICATION_EXIT_WORLD, true);
if (xform_change.in_list())
get_tree()->xform_change_list.remove(&xform_change);
if (data.C)
data.parent->data.children.erase(data.C);
- data.parent=NULL;
- data.C=NULL;
- data.toplevel_active=false;
+ data.parent = NULL;
+ data.C = NULL;
+ data.toplevel_active = false;
} break;
case NOTIFICATION_ENTER_WORLD: {
- data.inside_world=true;
- data.viewport=NULL;
+ data.inside_world = true;
+ data.viewport = NULL;
Node *parent = get_parent();
- while(parent && !data.viewport) {
- data.viewport=parent->cast_to<Viewport>();
- parent=parent->get_parent();
+ while (parent && !data.viewport) {
+ data.viewport = parent->cast_to<Viewport>();
+ parent = parent->get_parent();
}
ERR_FAIL_COND(!data.viewport);
-
if (get_script_instance()) {
Variant::CallError err;
- get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world,NULL,0);
+ get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world, NULL, 0);
}
#ifdef TOOLS_ENABLED
if (get_tree()->is_editor_hint()) {
-// get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
- get_tree()->call_group(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
+ // get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this);
+ get_tree()->call_group(0, SceneStringNames::get_singleton()->_spatial_editor_group, SceneStringNames::get_singleton()->_request_gizmo, this);
if (!data.gizmo_disabled) {
if (data.gizmo.is_valid())
@@ -201,15 +193,14 @@ void Spatial::_notification(int p_what) {
if (get_script_instance()) {
Variant::CallError err;
- get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world,NULL,0);
+ get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_world, NULL, 0);
}
- data.viewport=NULL;
- data.inside_world=false;
+ data.viewport = NULL;
+ data.inside_world = false;
} break;
-
case NOTIFICATION_TRANSFORM_CHANGED: {
#ifdef TOOLS_ENABLED
@@ -223,10 +214,10 @@ void Spatial::_notification(int p_what) {
}
}
-void Spatial::set_transform(const Transform& p_transform) {
+void Spatial::set_transform(const Transform &p_transform) {
- data.local_transform=p_transform;
- data.dirty|=DIRTY_VECTORS;
+ data.local_transform = p_transform;
+ data.dirty |= DIRTY_VECTORS;
_change_notify("transform/translation");
_change_notify("transform/rotation");
_change_notify("transform/scale");
@@ -234,23 +225,18 @@ void Spatial::set_transform(const Transform& p_transform) {
if (data.notify_local_transform) {
notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED);
}
-
-
-
}
-void Spatial::set_global_transform(const Transform& p_transform) {
+void Spatial::set_global_transform(const Transform &p_transform) {
Transform xform =
(data.parent && !data.toplevel_active) ?
- data.parent->get_global_transform().affine_inverse() * p_transform :
- p_transform;
+ data.parent->get_global_transform().affine_inverse() * p_transform :
+ p_transform;
set_transform(xform);
-
}
-
Transform Spatial::get_transform() const {
if (data.dirty & DIRTY_LOCAL) {
@@ -273,13 +259,13 @@ Transform Spatial::get_global_transform() const {
if (data.parent && !data.toplevel_active) {
- data.global_transform=data.parent->get_global_transform() * data.local_transform;
+ data.global_transform = data.parent->get_global_transform() * data.local_transform;
} else {
- data.global_transform=data.local_transform;
+ data.global_transform = data.local_transform;
}
- data.dirty&=~DIRTY_GLOBAL;
+ data.dirty &= ~DIRTY_GLOBAL;
}
return data.global_transform;
@@ -319,87 +305,82 @@ void Spatial::remove_child_notify(Node *p_child) {
Spatial *Spatial::get_parent_spatial() const {
return data.parent;
-
}
Transform Spatial::get_relative_transform(const Node *p_parent) const {
- if (p_parent==this)
+ if (p_parent == this)
return Transform();
- ERR_FAIL_COND_V(!data.parent,Transform());
+ ERR_FAIL_COND_V(!data.parent, Transform());
- if (p_parent==data.parent)
+ if (p_parent == data.parent)
return get_transform();
else
return data.parent->get_relative_transform(p_parent) * get_transform();
-
}
-void Spatial::set_translation(const Vector3& p_translation) {
+void Spatial::set_translation(const Vector3 &p_translation) {
- data.local_transform.origin=p_translation;
+ data.local_transform.origin = p_translation;
_propagate_transform_changed(this);
if (data.notify_local_transform) {
notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED);
}
-
}
-void Spatial::set_rotation(const Vector3& p_euler_rad){
+void Spatial::set_rotation(const Vector3 &p_euler_rad) {
- if (data.dirty&DIRTY_VECTORS) {
- data.scale=data.local_transform.basis.get_scale();
- data.dirty&=~DIRTY_VECTORS;
+ if (data.dirty & DIRTY_VECTORS) {
+ data.scale = data.local_transform.basis.get_scale();
+ data.dirty &= ~DIRTY_VECTORS;
}
- data.rotation=p_euler_rad;
- data.dirty|=DIRTY_LOCAL;
+ data.rotation = p_euler_rad;
+ data.dirty |= DIRTY_LOCAL;
_propagate_transform_changed(this);
if (data.notify_local_transform) {
notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED);
}
-
}
-void Spatial::set_rotation_deg(const Vector3& p_euler_deg) {
+void Spatial::set_rotation_deg(const Vector3 &p_euler_deg) {
set_rotation(p_euler_deg * Math_PI / 180.0);
}
-void Spatial::_set_rotation_deg(const Vector3& p_euler_deg) {
+void Spatial::_set_rotation_deg(const Vector3 &p_euler_deg) {
WARN_PRINT("Deprecated method Spatial._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted.");
set_rotation_deg(p_euler_deg);
}
-void Spatial::set_scale(const Vector3& p_scale){
+void Spatial::set_scale(const Vector3 &p_scale) {
- if (data.dirty&DIRTY_VECTORS) {
- data.rotation=data.local_transform.basis.get_euler();
- data.dirty&=~DIRTY_VECTORS;
+ if (data.dirty & DIRTY_VECTORS) {
+ data.rotation = data.local_transform.basis.get_euler();
+ data.dirty &= ~DIRTY_VECTORS;
}
- data.scale=p_scale;
- data.dirty|=DIRTY_LOCAL;
+ data.scale = p_scale;
+ data.dirty |= DIRTY_LOCAL;
_propagate_transform_changed(this);
if (data.notify_local_transform) {
notification(NOTIFICATION_LOCAL_TRANSFORM_CHANGED);
}
-
}
-Vector3 Spatial::get_translation() const{
+Vector3 Spatial::get_translation() const {
return data.local_transform.origin;
}
-Vector3 Spatial::get_rotation() const{
+Vector3 Spatial::get_rotation() const {
- if (data.dirty&DIRTY_VECTORS) {
- data.scale=data.local_transform.basis.get_scale();
- data.rotation=data.local_transform.basis.get_euler();
- data.dirty&=~DIRTY_VECTORS;
+ if (data.dirty & DIRTY_VECTORS) {
+ data.scale = data.local_transform.basis.get_scale();
+ data.rotation = data.local_transform.basis.get_euler();
+ data.dirty &= ~DIRTY_VECTORS;
}
return data.rotation;
@@ -418,18 +399,17 @@ Vector3 Spatial::_get_rotation_deg() const {
return get_rotation_deg();
}
-Vector3 Spatial::get_scale() const{
+Vector3 Spatial::get_scale() const {
- if (data.dirty&DIRTY_VECTORS) {
- data.scale=data.local_transform.basis.get_scale();
- data.rotation=data.local_transform.basis.get_euler();
- data.dirty&=~DIRTY_VECTORS;
+ if (data.dirty & DIRTY_VECTORS) {
+ data.scale = data.local_transform.basis.get_scale();
+ data.rotation = data.local_transform.basis.get_euler();
+ data.dirty &= ~DIRTY_VECTORS;
}
return data.scale;
}
-
void Spatial::update_gizmo() {
#ifdef TOOLS_ENABLED
@@ -439,12 +419,12 @@ void Spatial::update_gizmo() {
return;
if (data.gizmo_dirty)
return;
- data.gizmo_dirty=true;
- MessageQueue::get_singleton()->push_call(this,"_update_gizmo");
+ data.gizmo_dirty = true;
+ MessageQueue::get_singleton()->push_call(this, "_update_gizmo");
#endif
}
-void Spatial::set_gizmo(const Ref<SpatialGizmo>& p_gizmo) {
+void Spatial::set_gizmo(const Ref<SpatialGizmo> &p_gizmo) {
#ifdef TOOLS_ENABLED
@@ -452,7 +432,7 @@ void Spatial::set_gizmo(const Ref<SpatialGizmo>& p_gizmo) {
return;
if (data.gizmo.is_valid() && is_inside_world())
data.gizmo->free();
- data.gizmo=p_gizmo;
+ data.gizmo = p_gizmo;
if (data.gizmo.is_valid() && is_inside_world()) {
data.gizmo->create();
@@ -478,7 +458,7 @@ Ref<SpatialGizmo> Spatial::get_gizmo() const {
void Spatial::_update_gizmo() {
- data.gizmo_dirty=false;
+ data.gizmo_dirty = false;
if (data.gizmo.is_valid()) {
if (is_visible())
data.gizmo->redraw();
@@ -487,19 +467,18 @@ void Spatial::_update_gizmo() {
}
}
-
void Spatial::set_disable_gizmo(bool p_enabled) {
- data.gizmo_disabled=p_enabled;
+ data.gizmo_disabled = p_enabled;
if (!p_enabled && data.gizmo.is_valid())
- data.gizmo=Ref<SpatialGizmo>();
+ data.gizmo = Ref<SpatialGizmo>();
}
#endif
void Spatial::set_as_toplevel(bool p_enabled) {
- if (data.toplevel==p_enabled)
+ if (data.toplevel == p_enabled)
return;
if (is_inside_tree() && !get_tree()->is_editor_hint()) {
@@ -508,30 +487,28 @@ void Spatial::set_as_toplevel(bool p_enabled) {
else if (data.parent)
set_transform(data.parent->get_global_transform().affine_inverse() * get_global_transform());
- data.toplevel=p_enabled;
- data.toplevel_active=p_enabled;
+ data.toplevel = p_enabled;
+ data.toplevel_active = p_enabled;
} else {
- data.toplevel=p_enabled;
+ data.toplevel = p_enabled;
}
-
}
-bool Spatial::is_set_as_toplevel() const{
+bool Spatial::is_set_as_toplevel() const {
return data.toplevel;
}
Ref<World> Spatial::get_world() const {
- ERR_FAIL_COND_V(!is_inside_world(),Ref<World>());
+ ERR_FAIL_COND_V(!is_inside_world(), Ref<World>());
return data.viewport->find_world();
-
}
#ifdef TOOLS_ENABLED
-void Spatial::set_import_transform(const Transform& p_transform) {
- data.import_transform=p_transform;
+void Spatial::set_import_transform(const Transform &p_transform) {
+ data.import_transform = p_transform;
}
Transform Spatial::get_import_transform() const {
@@ -540,7 +517,6 @@ Transform Spatial::get_import_transform() const {
}
#endif
-
void Spatial::_propagate_visibility_changed() {
notification(NOTIFICATION_VISIBILITY_CHANGED);
@@ -551,22 +527,21 @@ void Spatial::_propagate_visibility_changed() {
_update_gizmo();
#endif
- for (List<Spatial*>::Element*E=data.children.front();E;E=E->next()) {
+ for (List<Spatial *>::Element *E = data.children.front(); E; E = E->next()) {
- Spatial *c=E->get();
+ Spatial *c = E->get();
if (!c || !c->data.visible)
continue;
c->_propagate_visibility_changed();
}
}
-
void Spatial::show() {
if (data.visible)
return;
- data.visible=true;
+ data.visible = true;
if (!is_inside_tree())
return;
@@ -577,36 +552,34 @@ void Spatial::show() {
}
}
-void Spatial::hide(){
+void Spatial::hide() {
if (!data.visible)
return;
bool was_visible = is_visible();
- data.visible=false;
+ data.visible = false;
if (!data.parent || was_visible) {
_propagate_visibility_changed();
}
-
}
-bool Spatial::is_visible() const{
+bool Spatial::is_visible() const {
- const Spatial *s=this;
+ const Spatial *s = this;
- while(s) {
+ while (s) {
if (!s->data.visible) {
return false;
}
- s=s->data.parent;
+ s = s->data.parent;
}
return true;
}
-
-bool Spatial::is_hidden() const{
+bool Spatial::is_hidden() const {
return !data.visible;
}
@@ -633,64 +606,57 @@ bool Spatial::_is_visible_() const {
return !is_hidden();
}
-void Spatial::rotate(const Vector3& p_normal,float p_radians) {
+void Spatial::rotate(const Vector3 &p_normal, float p_radians) {
- Transform t =get_transform();
- t.basis.rotate(p_normal,p_radians);
+ Transform t = get_transform();
+ t.basis.rotate(p_normal, p_radians);
set_transform(t);
}
void Spatial::rotate_x(float p_radians) {
- Transform t =get_transform();
- t.basis.rotate(Vector3(1,0,0),p_radians);
+ Transform t = get_transform();
+ t.basis.rotate(Vector3(1, 0, 0), p_radians);
set_transform(t);
-
}
-void Spatial::rotate_y(float p_radians){
+void Spatial::rotate_y(float p_radians) {
- Transform t =get_transform();
- t.basis.rotate(Vector3(0,1,0),p_radians);
+ Transform t = get_transform();
+ t.basis.rotate(Vector3(0, 1, 0), p_radians);
set_transform(t);
-
}
-void Spatial::rotate_z(float p_radians){
+void Spatial::rotate_z(float p_radians) {
- Transform t =get_transform();
- t.basis.rotate(Vector3(0,0,1),p_radians);
+ Transform t = get_transform();
+ t.basis.rotate(Vector3(0, 0, 1), p_radians);
set_transform(t);
-
}
-void Spatial::translate(const Vector3& p_offset){
+void Spatial::translate(const Vector3 &p_offset) {
- Transform t =get_transform();
+ Transform t = get_transform();
t.translate(p_offset);
set_transform(t);
-
}
-void Spatial::scale(const Vector3& p_ratio){
+void Spatial::scale(const Vector3 &p_ratio) {
- Transform t =get_transform();
+ Transform t = get_transform();
t.basis.scale(p_ratio);
set_transform(t);
-
}
-void Spatial::global_rotate(const Vector3& p_normal,float p_radians){
+void Spatial::global_rotate(const Vector3 &p_normal, float p_radians) {
- Matrix3 rotation(p_normal,p_radians);
+ Matrix3 rotation(p_normal, p_radians);
Transform t = get_global_transform();
- t.basis= rotation * t.basis;
+ t.basis = rotation * t.basis;
set_global_transform(t);
-
}
-void Spatial::global_translate(const Vector3& p_offset){
+void Spatial::global_translate(const Vector3 &p_offset) {
Transform t = get_global_transform();
- t.origin+=p_offset;
+ t.origin += p_offset;
set_global_transform(t);
-
}
void Spatial::orthonormalize() {
@@ -698,44 +664,40 @@ void Spatial::orthonormalize() {
Transform t = get_transform();
t.orthonormalize();
set_transform(t);
-
}
void Spatial::set_identity() {
set_transform(Transform());
-
}
-
-void Spatial::look_at(const Vector3& p_target, const Vector3& p_up_normal) {
+void Spatial::look_at(const Vector3 &p_target, const Vector3 &p_up_normal) {
Transform lookat;
- lookat.origin=get_global_transform().origin;
- if (lookat.origin==p_target) {
+ lookat.origin = get_global_transform().origin;
+ if (lookat.origin == p_target) {
ERR_EXPLAIN("Node origin and target are in the same position, look_at() failed");
ERR_FAIL();
}
- if (p_up_normal.cross(p_target-lookat.origin)==Vector3()) {
+ if (p_up_normal.cross(p_target - lookat.origin) == Vector3()) {
ERR_EXPLAIN("Up vector and direction between node origin and target are aligned, look_at() failed");
ERR_FAIL();
}
- lookat=lookat.looking_at(p_target,p_up_normal);
+ lookat = lookat.looking_at(p_target, p_up_normal);
set_global_transform(lookat);
}
-void Spatial::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal) {
+void Spatial::look_at_from_pos(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up_normal) {
Transform lookat;
- lookat.origin=p_pos;
- lookat=lookat.looking_at(p_target,p_up_normal);
+ lookat.origin = p_pos;
+ lookat = lookat.looking_at(p_target, p_up_normal);
set_global_transform(lookat);
-
}
void Spatial::set_notify_local_transform(bool p_enable) {
- data.notify_local_transform=p_enable;
+ data.notify_local_transform = p_enable;
}
bool Spatial::is_local_transform_notification_enabled() const {
@@ -744,118 +706,111 @@ bool Spatial::is_local_transform_notification_enabled() const {
void Spatial::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_transform","local"), &Spatial::set_transform);
+ ObjectTypeDB::bind_method(_MD("set_transform", "local"), &Spatial::set_transform);
ObjectTypeDB::bind_method(_MD("get_transform"), &Spatial::get_transform);
- ObjectTypeDB::bind_method(_MD("set_translation","translation"), &Spatial::set_translation);
+ ObjectTypeDB::bind_method(_MD("set_translation", "translation"), &Spatial::set_translation);
ObjectTypeDB::bind_method(_MD("get_translation"), &Spatial::get_translation);
- ObjectTypeDB::bind_method(_MD("set_rotation","rotation_rad"), &Spatial::set_rotation);
+ ObjectTypeDB::bind_method(_MD("set_rotation", "rotation_rad"), &Spatial::set_rotation);
ObjectTypeDB::bind_method(_MD("get_rotation"), &Spatial::get_rotation);
- ObjectTypeDB::bind_method(_MD("set_rotation_deg","rotation_deg"), &Spatial::set_rotation_deg);
+ ObjectTypeDB::bind_method(_MD("set_rotation_deg", "rotation_deg"), &Spatial::set_rotation_deg);
ObjectTypeDB::bind_method(_MD("get_rotation_deg"), &Spatial::get_rotation_deg);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"), &Spatial::set_scale);
+ ObjectTypeDB::bind_method(_MD("set_scale", "scale"), &Spatial::set_scale);
ObjectTypeDB::bind_method(_MD("get_scale"), &Spatial::get_scale);
- ObjectTypeDB::bind_method(_MD("set_global_transform","global"), &Spatial::set_global_transform);
+ ObjectTypeDB::bind_method(_MD("set_global_transform", "global"), &Spatial::set_global_transform);
ObjectTypeDB::bind_method(_MD("get_global_transform"), &Spatial::get_global_transform);
ObjectTypeDB::bind_method(_MD("get_parent_spatial"), &Spatial::get_parent_spatial);
- ObjectTypeDB::bind_method(_MD("set_ignore_transform_notification","enabled"), &Spatial::set_ignore_transform_notification);
- ObjectTypeDB::bind_method(_MD("set_as_toplevel","enable"), &Spatial::set_as_toplevel);
+ ObjectTypeDB::bind_method(_MD("set_ignore_transform_notification", "enabled"), &Spatial::set_ignore_transform_notification);
+ ObjectTypeDB::bind_method(_MD("set_as_toplevel", "enable"), &Spatial::set_as_toplevel);
ObjectTypeDB::bind_method(_MD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel);
ObjectTypeDB::bind_method(_MD("get_world:World"), &Spatial::get_world);
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_set_rotation_deg","rotation_deg"), &Spatial::_set_rotation_deg);
+ ObjectTypeDB::bind_method(_MD("_set_rotation_deg", "rotation_deg"), &Spatial::_set_rotation_deg);
ObjectTypeDB::bind_method(_MD("_get_rotation_deg"), &Spatial::_get_rotation_deg);
#ifdef TOOLS_ENABLED
ObjectTypeDB::bind_method(_MD("_update_gizmo"), &Spatial::_update_gizmo);
ObjectTypeDB::bind_method(_MD("_set_import_transform"), &Spatial::set_import_transform);
ObjectTypeDB::bind_method(_MD("_get_import_transform"), &Spatial::get_import_transform);
- ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"_import_transform",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_import_transform"),_SCS("_get_import_transform"));
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "_import_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_import_transform"), _SCS("_get_import_transform"));
#endif
ObjectTypeDB::bind_method(_MD("update_gizmo"), &Spatial::update_gizmo);
- ObjectTypeDB::bind_method(_MD("set_gizmo","gizmo:SpatialGizmo"), &Spatial::set_gizmo);
+ ObjectTypeDB::bind_method(_MD("set_gizmo", "gizmo:SpatialGizmo"), &Spatial::set_gizmo);
ObjectTypeDB::bind_method(_MD("get_gizmo:SpatialGizmo"), &Spatial::get_gizmo);
ObjectTypeDB::bind_method(_MD("show"), &Spatial::show);
ObjectTypeDB::bind_method(_MD("hide"), &Spatial::hide);
ObjectTypeDB::bind_method(_MD("is_visible"), &Spatial::is_visible);
ObjectTypeDB::bind_method(_MD("is_hidden"), &Spatial::is_hidden);
- ObjectTypeDB::bind_method(_MD("set_hidden","hidden"), &Spatial::set_hidden);
+ ObjectTypeDB::bind_method(_MD("set_hidden", "hidden"), &Spatial::set_hidden);
ObjectTypeDB::bind_method(_MD("_set_visible_"), &Spatial::_set_visible_);
ObjectTypeDB::bind_method(_MD("_is_visible_"), &Spatial::_is_visible_);
- ObjectTypeDB::bind_method(_MD("set_notify_local_transform","enable"), &Spatial::set_notify_local_transform);
+ ObjectTypeDB::bind_method(_MD("set_notify_local_transform", "enable"), &Spatial::set_notify_local_transform);
ObjectTypeDB::bind_method(_MD("is_local_transform_notification_enabled"), &Spatial::is_local_transform_notification_enabled);
- void rotate(const Vector3& p_normal,float p_radians);
+ void rotate(const Vector3 &p_normal, float p_radians);
void rotate_x(float p_radians);
void rotate_y(float p_radians);
void rotate_z(float p_radians);
- void translate(const Vector3& p_offset);
- void scale(const Vector3& p_ratio);
- void global_rotate(const Vector3& p_normal,float p_radians);
- void global_translate(const Vector3& p_offset);
+ void translate(const Vector3 &p_offset);
+ void scale(const Vector3 &p_ratio);
+ void global_rotate(const Vector3 &p_normal, float p_radians);
+ void global_translate(const Vector3 &p_offset);
- ObjectTypeDB::bind_method( _MD("rotate","normal","radians"),&Spatial::rotate );
- ObjectTypeDB::bind_method( _MD("global_rotate","normal","radians"),&Spatial::global_rotate );
- ObjectTypeDB::bind_method( _MD("rotate_x","radians"),&Spatial::rotate_x );
- ObjectTypeDB::bind_method( _MD("rotate_y","radians"),&Spatial::rotate_y );
- ObjectTypeDB::bind_method( _MD("rotate_z","radians"),&Spatial::rotate_z );
- ObjectTypeDB::bind_method( _MD("translate","offset"),&Spatial::translate );
- ObjectTypeDB::bind_method( _MD("global_translate","offset"),&Spatial::global_translate );
- ObjectTypeDB::bind_method( _MD("orthonormalize"),&Spatial::orthonormalize );
- ObjectTypeDB::bind_method( _MD("set_identity"),&Spatial::set_identity );
+ ObjectTypeDB::bind_method(_MD("rotate", "normal", "radians"), &Spatial::rotate);
+ ObjectTypeDB::bind_method(_MD("global_rotate", "normal", "radians"), &Spatial::global_rotate);
+ ObjectTypeDB::bind_method(_MD("rotate_x", "radians"), &Spatial::rotate_x);
+ ObjectTypeDB::bind_method(_MD("rotate_y", "radians"), &Spatial::rotate_y);
+ ObjectTypeDB::bind_method(_MD("rotate_z", "radians"), &Spatial::rotate_z);
+ ObjectTypeDB::bind_method(_MD("translate", "offset"), &Spatial::translate);
+ ObjectTypeDB::bind_method(_MD("global_translate", "offset"), &Spatial::global_translate);
+ ObjectTypeDB::bind_method(_MD("orthonormalize"), &Spatial::orthonormalize);
+ ObjectTypeDB::bind_method(_MD("set_identity"), &Spatial::set_identity);
- ObjectTypeDB::bind_method( _MD("look_at","target","up"),&Spatial::look_at );
- ObjectTypeDB::bind_method( _MD("look_at_from_pos","pos","target","up"),&Spatial::look_at_from_pos );
+ ObjectTypeDB::bind_method(_MD("look_at", "target", "up"), &Spatial::look_at);
+ ObjectTypeDB::bind_method(_MD("look_at_from_pos", "pos", "target", "up"), &Spatial::look_at_from_pos);
- BIND_CONSTANT( NOTIFICATION_TRANSFORM_CHANGED );
- BIND_CONSTANT( NOTIFICATION_ENTER_WORLD );
- BIND_CONSTANT( NOTIFICATION_EXIT_WORLD );
- BIND_CONSTANT( NOTIFICATION_VISIBILITY_CHANGED );
+ BIND_CONSTANT(NOTIFICATION_TRANSFORM_CHANGED);
+ BIND_CONSTANT(NOTIFICATION_ENTER_WORLD);
+ BIND_CONSTANT(NOTIFICATION_EXIT_WORLD);
+ BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED);
//ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/global",PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR ), _SCS("set_global_transform"), _SCS("get_global_transform") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::TRANSFORM,"transform/local",PROPERTY_HINT_NONE,""), _SCS("set_transform"), _SCS("get_transform") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/translation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_translation"), _SCS("get_translation") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/rotation",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_rotation_deg"), _SCS("get_rotation_deg") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/rotation_rad",PROPERTY_HINT_NONE,"",0), _SCS("set_rotation"), _SCS("get_rotation") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"transform/scale",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR), _SCS("set_scale"), _SCS("get_scale") );
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"), _SCS("_is_visible_") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "transform/local", PROPERTY_HINT_NONE, ""), _SCS("set_transform"), _SCS("get_transform"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "transform/translation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), _SCS("set_translation"), _SCS("get_translation"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "transform/rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), _SCS("set_rotation_deg"), _SCS("get_rotation_deg"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "transform/rotation_rad", PROPERTY_HINT_NONE, "", 0), _SCS("set_rotation"), _SCS("get_rotation"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "transform/scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), _SCS("set_scale"), _SCS("get_scale"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "visibility/visible"), _SCS("_set_visible_"), _SCS("_is_visible_"));
//ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM,"transform/local"), _SCS("set_transform"), _SCS("get_transform") );
- ADD_SIGNAL( MethodInfo("visibility_changed" ) );
-
+ ADD_SIGNAL(MethodInfo("visibility_changed"));
}
+Spatial::Spatial()
+ : xform_change(this) {
-Spatial::Spatial() : xform_change(this)
-{
+ data.dirty = DIRTY_NONE;
+ data.children_lock = 0;
- data.dirty=DIRTY_NONE;
- data.children_lock=0;
-
- data.ignore_notification=false;
- data.toplevel=false;
- data.toplevel_active=false;
- data.scale=Vector3(1,1,1);
- data.viewport=NULL;
- data.inside_world=false;
- data.visible=true;
+ data.ignore_notification = false;
+ data.toplevel = false;
+ data.toplevel_active = false;
+ data.scale = Vector3(1, 1, 1);
+ data.viewport = NULL;
+ data.inside_world = false;
+ data.visible = true;
#ifdef TOOLS_ENABLED
- data.gizmo_disabled=false;
- data.gizmo_dirty=false;
+ data.gizmo_disabled = false;
+ data.gizmo_dirty = false;
#endif
- data.notify_local_transform=false;
- data.parent=NULL;
- data.C=NULL;
-
+ data.notify_local_transform = false;
+ data.parent = NULL;
+ data.C = NULL;
}
-
Spatial::~Spatial() {
-
}
-
-
diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h
index aeffddce4..b583d5bc9 100644
--- a/scene/3d/spatial.h
+++ b/scene/3d/spatial.h
@@ -38,39 +38,34 @@
class SpatialGizmo : public Reference {
- OBJ_TYPE(SpatialGizmo,Reference);
-
+ OBJ_TYPE(SpatialGizmo, Reference);
public:
-
- virtual void create()=0;
- virtual void transform()=0;
- virtual void clear()=0;
- virtual void redraw()=0;
- virtual void free()=0;
+ virtual void create() = 0;
+ virtual void transform() = 0;
+ virtual void clear() = 0;
+ virtual void redraw() = 0;
+ virtual void free() = 0;
SpatialGizmo();
};
-
class Spatial : public Node {
- OBJ_TYPE( Spatial, Node );
+ OBJ_TYPE(Spatial, Node);
OBJ_CATEGORY("3D");
enum TransformDirty {
- DIRTY_NONE=0,
- DIRTY_VECTORS=1,
- DIRTY_LOCAL=2,
- DIRTY_GLOBAL=4
+ DIRTY_NONE = 0,
+ DIRTY_VECTORS = 1,
+ DIRTY_LOCAL = 2,
+ DIRTY_GLOBAL = 4
};
mutable SelfList<Node> xform_change;
struct Data {
-
-
mutable Transform global_transform;
mutable Transform local_transform;
mutable Vector3 rotation;
@@ -80,15 +75,14 @@ class Spatial : public Node {
Viewport *viewport;
-
bool toplevel_active;
bool toplevel;
bool inside_world;
int children_lock;
Spatial *parent;
- List<Spatial*> children;
- List<Spatial*>::Element *C;
+ List<Spatial *> children;
+ List<Spatial *>::Element *C;
bool ignore_notification;
bool notify_local_transform;
@@ -111,15 +105,13 @@ class Spatial : public Node {
void _propagate_transform_changed(Spatial *p_origin);
// Deprecated, should be removed in a future version.
- void _set_rotation_deg(const Vector3& p_euler_deg);
+ void _set_rotation_deg(const Vector3 &p_euler_deg);
Vector3 _get_rotation_deg() const;
void _propagate_visibility_changed();
-
protected:
-
- _FORCE_INLINE_ void set_ignore_transform_notification(bool p_ignore) { data.ignore_notification=p_ignore; }
+ _FORCE_INLINE_ void set_ignore_transform_notification(bool p_ignore) { data.ignore_notification = p_ignore; }
_FORCE_INLINE_ void _update_local_transform() const;
@@ -128,34 +120,33 @@ protected:
void _set_visible_(bool p_visible);
bool _is_visible_() const;
-public:
+public:
enum {
- NOTIFICATION_TRANSFORM_CHANGED=SceneTree::NOTIFICATION_TRANSFORM_CHANGED,
- NOTIFICATION_ENTER_WORLD=41,
- NOTIFICATION_EXIT_WORLD=42,
- NOTIFICATION_VISIBILITY_CHANGED=43,
- NOTIFICATION_LOCAL_TRANSFORM_CHANGED=44,
+ NOTIFICATION_TRANSFORM_CHANGED = SceneTree::NOTIFICATION_TRANSFORM_CHANGED,
+ NOTIFICATION_ENTER_WORLD = 41,
+ NOTIFICATION_EXIT_WORLD = 42,
+ NOTIFICATION_VISIBILITY_CHANGED = 43,
+ NOTIFICATION_LOCAL_TRANSFORM_CHANGED = 44,
};
Spatial *get_parent_spatial() const;
-
Ref<World> get_world() const;
- void set_translation(const Vector3& p_translation);
- void set_rotation(const Vector3& p_euler_rad);
- void set_rotation_deg(const Vector3& p_euler_deg);
- void set_scale(const Vector3& p_scale);
+ void set_translation(const Vector3 &p_translation);
+ void set_rotation(const Vector3 &p_euler_rad);
+ void set_rotation_deg(const Vector3 &p_euler_deg);
+ void set_scale(const Vector3 &p_scale);
Vector3 get_translation() const;
Vector3 get_rotation() const;
Vector3 get_rotation_deg() const;
Vector3 get_scale() const;
- void set_transform(const Transform& p_transform);
- void set_global_transform(const Transform& p_transform);
+ void set_transform(const Transform &p_transform);
+ void set_global_transform(const Transform &p_transform);
Transform get_transform() const;
Transform get_global_transform() const;
@@ -165,24 +156,24 @@ public:
void set_disable_gizmo(bool p_enabled);
void update_gizmo();
- void set_gizmo(const Ref<SpatialGizmo>& p_gizmo);
+ void set_gizmo(const Ref<SpatialGizmo> &p_gizmo);
Ref<SpatialGizmo> get_gizmo() const;
_FORCE_INLINE_ bool is_inside_world() const { return data.inside_world; }
Transform get_relative_transform(const Node *p_parent) const;
- void rotate(const Vector3& p_normal,float p_radians);
+ void rotate(const Vector3 &p_normal, float p_radians);
void rotate_x(float p_radians);
void rotate_y(float p_radians);
void rotate_z(float p_radians);
- void translate(const Vector3& p_offset);
- void scale(const Vector3& p_ratio);
- void global_rotate(const Vector3& p_normal,float p_radians);
- void global_translate(const Vector3& p_offset);
+ void translate(const Vector3 &p_offset);
+ void scale(const Vector3 &p_ratio);
+ void global_rotate(const Vector3 &p_normal, float p_radians);
+ void global_translate(const Vector3 &p_offset);
- void look_at(const Vector3& p_target, const Vector3& p_up_normal);
- void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
+ void look_at(const Vector3 &p_target, const Vector3 &p_up_normal);
+ void look_at_from_pos(const Vector3 &p_pos, const Vector3 &p_target, const Vector3 &p_up_normal);
void set_notify_local_transform(bool p_enable);
bool is_local_transform_notification_enabled() const;
@@ -197,13 +188,12 @@ public:
void set_hidden(bool p_hidden);
#ifdef TOOLS_ENABLED
- void set_import_transform(const Transform& p_transform) ;
+ void set_import_transform(const Transform &p_transform);
Transform get_import_transform() const;
#endif
Spatial();
~Spatial();
-
};
#endif
diff --git a/scene/3d/spatial_indexer.cpp b/scene/3d/spatial_indexer.cpp
index 963fbca5e..9b367d36f 100644
--- a/scene/3d/spatial_indexer.cpp
+++ b/scene/3d/spatial_indexer.cpp
@@ -30,8 +30,8 @@
#if 0
-#include "proximity_area.h"
#include "camera.h"
+#include "proximity_area.h"
#include "scene/scene_string_names.h"
void SpatialIndexer::add_camera(Camera* p_camera) {
diff --git a/scene/3d/spatial_player.cpp b/scene/3d/spatial_player.cpp
index 2bd94aac7..efcfc7fc4 100644
--- a/scene/3d/spatial_player.cpp
+++ b/scene/3d/spatial_player.cpp
@@ -28,29 +28,26 @@
/*************************************************************************/
#include "spatial_player.h"
-#include "servers/audio_server.h"
#include "camera.h"
-#include "servers/spatial_sound_server.h"
#include "scene/resources/surface_tool.h"
-
+#include "servers/audio_server.h"
+#include "servers/spatial_sound_server.h"
void SpatialPlayer::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
//find the sound space
source_rid = SpatialSoundServer::get_singleton()->source_create(get_world()->get_sound_space());
- for(int i=0;i<PARAM_MAX;i++)
- set_param(Param(i),params[i]);
-
+ for (int i = 0; i < PARAM_MAX; i++)
+ set_param(Param(i), params[i]);
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- SpatialSoundServer::get_singleton()->source_set_transform(source_rid,get_global_transform());
+ SpatialSoundServer::get_singleton()->source_set_transform(source_rid, get_global_transform());
} break;
case NOTIFICATION_EXIT_WORLD: {
@@ -60,27 +57,23 @@ void SpatialPlayer::_notification(int p_what) {
} break;
}
-
}
+void SpatialPlayer::set_param(Param p_param, float p_value) {
-void SpatialPlayer::set_param( Param p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
- if (p_param==PARAM_EMISSION_CONE_DEGREES) {
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params[p_param] = p_value;
+ if (p_param == PARAM_EMISSION_CONE_DEGREES) {
update_gizmo();
}
if (source_rid.is_valid())
- SpatialSoundServer::get_singleton()->source_set_param(source_rid,(SpatialSoundServer::SourceParam)p_param,p_value);
-
+ SpatialSoundServer::get_singleton()->source_set_param(source_rid, (SpatialSoundServer::SourceParam)p_param, p_value);
}
-float SpatialPlayer::get_param( Param p_param) const {
+float SpatialPlayer::get_param(Param p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
-
}
bool SpatialPlayer::_can_gizmo_scale() const {
@@ -90,41 +83,40 @@ bool SpatialPlayer::_can_gizmo_scale() const {
RES SpatialPlayer::_get_gizmo_geometry() const {
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
+ Ref<SurfaceTool> surface_tool(memnew(SurfaceTool));
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.0,0.6,0.7,0.05) );
- mat->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
- mat->set_blend_mode( Material::BLEND_MODE_ADD );
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
+ Ref<FixedMaterial> mat(memnew(FixedMaterial));
+ mat->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.0, 0.6, 0.7, 0.05));
+ mat->set_parameter(FixedMaterial::PARAM_EMISSION, Color(0.5, 0.7, 0.8));
+ mat->set_blend_mode(Material::BLEND_MODE_ADD);
+ mat->set_flag(Material::FLAG_DOUBLE_SIDED, true);
+ // mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
surface_tool->set_material(mat);
- int sides=16;
- int sections=24;
+ int sides = 16;
+ int sections = 24;
-// float len=1;
- float deg=Math::deg2rad(params[PARAM_EMISSION_CONE_DEGREES]);
- if (deg==180)
- deg=179.5;
+ // float len=1;
+ float deg = Math::deg2rad(params[PARAM_EMISSION_CONE_DEGREES]);
+ if (deg == 180)
+ deg = 179.5;
- Vector3 to=Vector3(0,0,-1);
+ Vector3 to = Vector3(0, 0, -1);
- for(int j=0;j<sections;j++) {
+ for (int j = 0; j < sections; j++) {
- Vector3 p1=Matrix3(Vector3(1,0,0),deg*j/sections).xform(to);
- Vector3 p2=Matrix3(Vector3(1,0,0),deg*(j+1)/sections).xform(to);
+ Vector3 p1 = Matrix3(Vector3(1, 0, 0), deg * j / sections).xform(to);
+ Vector3 p2 = Matrix3(Vector3(1, 0, 0), deg * (j + 1) / sections).xform(to);
- for(int i=0;i<sides;i++) {
+ for (int i = 0; i < sides; i++) {
- Vector3 p1r = Matrix3(Vector3(0,0,1),Math_PI*2*float(i)/sides).xform(p1);
- Vector3 p1s = Matrix3(Vector3(0,0,1),Math_PI*2*float(i+1)/sides).xform(p1);
- Vector3 p2s = Matrix3(Vector3(0,0,1),Math_PI*2*float(i+1)/sides).xform(p2);
- Vector3 p2r = Matrix3(Vector3(0,0,1),Math_PI*2*float(i)/sides).xform(p2);
+ Vector3 p1r = Matrix3(Vector3(0, 0, 1), Math_PI * 2 * float(i) / sides).xform(p1);
+ Vector3 p1s = Matrix3(Vector3(0, 0, 1), Math_PI * 2 * float(i + 1) / sides).xform(p1);
+ Vector3 p2s = Matrix3(Vector3(0, 0, 1), Math_PI * 2 * float(i + 1) / sides).xform(p2);
+ Vector3 p2r = Matrix3(Vector3(0, 0, 1), Math_PI * 2 * float(i) / sides).xform(p2);
surface_tool->add_normal(p1r.normalized());
surface_tool->add_vertex(p1r);
@@ -140,25 +132,24 @@ RES SpatialPlayer::_get_gizmo_geometry() const {
surface_tool->add_normal(p2r.normalized());
surface_tool->add_vertex(p2r);
- if (j==sections-1) {
+ if (j == sections - 1) {
surface_tool->add_normal(p2r.normalized());
surface_tool->add_vertex(p2r);
surface_tool->add_normal(p2s.normalized());
surface_tool->add_vertex(p2s);
- surface_tool->add_normal(Vector3(0,0,1));
+ surface_tool->add_normal(Vector3(0, 0, 1));
surface_tool->add_vertex(Vector3());
}
}
}
-
Ref<Mesh> mesh = surface_tool->commit();
- Ref<FixedMaterial> mat_speaker( memnew( FixedMaterial ));
+ Ref<FixedMaterial> mat_speaker(memnew(FixedMaterial));
- mat_speaker->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.3,0.3,0.6) );
- mat_speaker->set_parameter( FixedMaterial::PARAM_SPECULAR,Color(0.5,0.5,0.6) );
+ mat_speaker->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.3, 0.3, 0.6));
+ mat_speaker->set_parameter(FixedMaterial::PARAM_SPECULAR, Color(0.5, 0.5, 0.6));
//mat_speaker->set_blend_mode( Material::BLEND_MODE_MIX);
//mat_speaker->set_flag(Material::FLAG_DOUBLE_SIDED,false);
//mat_speaker->set_flag(Material::FLAG_UNSHADED,true);
@@ -166,41 +157,37 @@ RES SpatialPlayer::_get_gizmo_geometry() const {
surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
surface_tool->set_material(mat_speaker);
-// float radius=1;
-
+ // float radius=1;
- const int speaker_points=8;
- Vector3 speaker[speaker_points]={
- Vector3(0,0,1)*0.15,
- Vector3(1,1,1)*0.15,
- Vector3(1,1,0)*0.15,
- Vector3(2,2,-1)*0.15,
- Vector3(1,1,-1)*0.15,
- Vector3(0.8,0.8,-1.2)*0.15,
- Vector3(0.5,0.5,-1.4)*0.15,
- Vector3(0.0,0.0,-1.6)*0.15
+ const int speaker_points = 8;
+ Vector3 speaker[speaker_points] = {
+ Vector3(0, 0, 1) * 0.15,
+ Vector3(1, 1, 1) * 0.15,
+ Vector3(1, 1, 0) * 0.15,
+ Vector3(2, 2, -1) * 0.15,
+ Vector3(1, 1, -1) * 0.15,
+ Vector3(0.8, 0.8, -1.2) * 0.15,
+ Vector3(0.5, 0.5, -1.4) * 0.15,
+ Vector3(0.0, 0.0, -1.6) * 0.15
};
- int speaker_sides=10;
-
+ int speaker_sides = 10;
- for(int i = 0; i < speaker_sides ; i++) {
+ for (int i = 0; i < speaker_sides; i++) {
+ Matrix3 ma(Vector3(0, 0, 1), Math_PI * 2 * float(i) / speaker_sides);
+ Matrix3 mb(Vector3(0, 0, 1), Math_PI * 2 * float(i + 1) / speaker_sides);
- Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/speaker_sides);
- Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/speaker_sides);
+ for (int j = 0; j < speaker_points - 1; j++) {
-
- for(int j=0;j<speaker_points-1;j++) {
-
- Vector3 points[4]={
+ Vector3 points[4] = {
ma.xform(speaker[j]),
mb.xform(speaker[j]),
- mb.xform(speaker[j+1]),
- ma.xform(speaker[j+1]),
+ mb.xform(speaker[j + 1]),
+ ma.xform(speaker[j + 1]),
};
- Vector3 n = -Plane(points[0],points[1],points[2]).normal;
+ Vector3 n = -Plane(points[0], points[1], points[2]).normal;
surface_tool->add_normal(n);
surface_tool->add_vertex(points[0]);
@@ -215,58 +202,45 @@ RES SpatialPlayer::_get_gizmo_geometry() const {
surface_tool->add_vertex(points[3]);
surface_tool->add_normal(n);
surface_tool->add_vertex(points[2]);
-
-
}
-
-
}
-
return surface_tool->commit(mesh);
-
}
-
void SpatialPlayer::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &SpatialPlayer::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &SpatialPlayer::get_param);
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SpatialPlayer::set_param);
- ObjectTypeDB::bind_method(_MD("get_param","param"),&SpatialPlayer::get_param);
-
- BIND_CONSTANT( PARAM_VOLUME_DB );
- BIND_CONSTANT( PARAM_PITCH_SCALE );
- BIND_CONSTANT( PARAM_ATTENUATION_MIN_DISTANCE );
- BIND_CONSTANT( PARAM_ATTENUATION_MAX_DISTANCE );
- BIND_CONSTANT( PARAM_ATTENUATION_DISTANCE_EXP );
- BIND_CONSTANT( PARAM_EMISSION_CONE_DEGREES );
- BIND_CONSTANT( PARAM_EMISSION_CONE_ATTENUATION_DB );
- BIND_CONSTANT( PARAM_MAX );
-
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/volume_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_VOLUME_DB);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/pitch_scale",PROPERTY_HINT_RANGE, "0.001,32,0.001"),_SCS("set_param"),_SCS("get_param"),PARAM_PITCH_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/min_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MIN_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/max_distance",PROPERTY_HINT_RANGE, "0.01,4096,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation/distance_exp",PROPERTY_HINT_EXP_EASING, "attenuation"),_SCS("set_param"),_SCS("get_param"),PARAM_ATTENUATION_DISTANCE_EXP);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/emission_cone/degrees",PROPERTY_HINT_RANGE, "0,180,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_DEGREES);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/emission_cone/attenuation_db",PROPERTY_HINT_RANGE, "-80,24,0.01"),_SCS("set_param"),_SCS("get_param"),PARAM_EMISSION_CONE_ATTENUATION_DB);
+ BIND_CONSTANT(PARAM_VOLUME_DB);
+ BIND_CONSTANT(PARAM_PITCH_SCALE);
+ BIND_CONSTANT(PARAM_ATTENUATION_MIN_DISTANCE);
+ BIND_CONSTANT(PARAM_ATTENUATION_MAX_DISTANCE);
+ BIND_CONSTANT(PARAM_ATTENUATION_DISTANCE_EXP);
+ BIND_CONSTANT(PARAM_EMISSION_CONE_DEGREES);
+ BIND_CONSTANT(PARAM_EMISSION_CONE_ATTENUATION_DB);
+ BIND_CONSTANT(PARAM_MAX);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_VOLUME_DB);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/pitch_scale", PROPERTY_HINT_RANGE, "0.001,32,0.001"), _SCS("set_param"), _SCS("get_param"), PARAM_PITCH_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation/min_distance", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_MIN_DISTANCE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation/max_distance", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_MAX_DISTANCE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation/distance_exp", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_DISTANCE_EXP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/emission_cone/degrees", PROPERTY_HINT_RANGE, "0,180,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_EMISSION_CONE_DEGREES);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/emission_cone/attenuation_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_EMISSION_CONE_ATTENUATION_DB);
}
-
SpatialPlayer::SpatialPlayer() {
- params[PARAM_VOLUME_DB]=0.0;
- params[PARAM_PITCH_SCALE]=1.0;
- params[PARAM_ATTENUATION_MIN_DISTANCE]=1;
- params[PARAM_ATTENUATION_MAX_DISTANCE]=100;
- params[PARAM_ATTENUATION_DISTANCE_EXP]=1.0; //linear (and not really good)
- params[PARAM_EMISSION_CONE_DEGREES]=180.0; //cone disabled
- params[PARAM_EMISSION_CONE_ATTENUATION_DB]=-6.0; //minus 6 db attenuation
-
+ params[PARAM_VOLUME_DB] = 0.0;
+ params[PARAM_PITCH_SCALE] = 1.0;
+ params[PARAM_ATTENUATION_MIN_DISTANCE] = 1;
+ params[PARAM_ATTENUATION_MAX_DISTANCE] = 100;
+ params[PARAM_ATTENUATION_DISTANCE_EXP] = 1.0; //linear (and not really good)
+ params[PARAM_EMISSION_CONE_DEGREES] = 180.0; //cone disabled
+ params[PARAM_EMISSION_CONE_ATTENUATION_DB] = -6.0; //minus 6 db attenuation
}
SpatialPlayer::~SpatialPlayer() {
-
-
}
diff --git a/scene/3d/spatial_player.h b/scene/3d/spatial_player.h
index 258bf5e41..d5e7b1b61 100644
--- a/scene/3d/spatial_player.h
+++ b/scene/3d/spatial_player.h
@@ -29,42 +29,37 @@
#ifndef SPATIAL_PLAYER_H
#define SPATIAL_PLAYER_H
-
#include "scene/3d/spatial.h"
#include "scene/main/node.h"
+#include "scene/main/viewport.h"
#include "scene/resources/sample_library.h"
#include "servers/spatial_sound_server.h"
-#include "scene/main/viewport.h"
class SpatialPlayer : public Spatial {
- OBJ_TYPE(SpatialPlayer,Spatial);
-public:
-
+ OBJ_TYPE(SpatialPlayer, Spatial);
+public:
enum Param {
- PARAM_VOLUME_DB=SpatialSoundServer::SOURCE_PARAM_VOLUME_DB,
- PARAM_PITCH_SCALE=SpatialSoundServer::SOURCE_PARAM_PITCH_SCALE,
- PARAM_ATTENUATION_MIN_DISTANCE=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE,
- PARAM_ATTENUATION_MAX_DISTANCE=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE,
- PARAM_ATTENUATION_DISTANCE_EXP=SpatialSoundServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP,
- PARAM_EMISSION_CONE_DEGREES=SpatialSoundServer::SOURCE_PARAM_EMISSION_CONE_DEGREES,
- PARAM_EMISSION_CONE_ATTENUATION_DB=SpatialSoundServer::SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB,
- PARAM_MAX=SpatialSoundServer::SOURCE_PARAM_MAX
+ PARAM_VOLUME_DB = SpatialSoundServer::SOURCE_PARAM_VOLUME_DB,
+ PARAM_PITCH_SCALE = SpatialSoundServer::SOURCE_PARAM_PITCH_SCALE,
+ PARAM_ATTENUATION_MIN_DISTANCE = SpatialSoundServer::SOURCE_PARAM_ATTENUATION_MIN_DISTANCE,
+ PARAM_ATTENUATION_MAX_DISTANCE = SpatialSoundServer::SOURCE_PARAM_ATTENUATION_MAX_DISTANCE,
+ PARAM_ATTENUATION_DISTANCE_EXP = SpatialSoundServer::SOURCE_PARAM_ATTENUATION_DISTANCE_EXP,
+ PARAM_EMISSION_CONE_DEGREES = SpatialSoundServer::SOURCE_PARAM_EMISSION_CONE_DEGREES,
+ PARAM_EMISSION_CONE_ATTENUATION_DB = SpatialSoundServer::SOURCE_PARAM_EMISSION_CONE_ATTENUATION_DB,
+ PARAM_MAX = SpatialSoundServer::SOURCE_PARAM_MAX
};
private:
-
float params[PARAM_MAX];
RID source_rid;
virtual bool _can_gizmo_scale() const;
virtual RES _get_gizmo_geometry() const;
-
protected:
-
_FORCE_INLINE_ RID get_source_rid() const { return source_rid; }
void _notification(int p_what);
@@ -72,16 +67,12 @@ protected:
static void _bind_methods();
public:
-
- void set_param( Param p_param, float p_value);
- float get_param( Param p_param) const;
-
+ void set_param(Param p_param, float p_value);
+ float get_param(Param p_param) const;
SpatialPlayer();
~SpatialPlayer();
-
-
};
-VARIANT_ENUM_CAST( SpatialPlayer::Param );
+VARIANT_ENUM_CAST(SpatialPlayer::Param);
#endif // SPATIAL_PLAYER_H
diff --git a/scene/3d/spatial_sample_player.cpp b/scene/3d/spatial_sample_player.cpp
index 5a9ee097f..c2860b4f7 100644
--- a/scene/3d/spatial_sample_player.cpp
+++ b/scene/3d/spatial_sample_player.cpp
@@ -28,40 +28,38 @@
/*************************************************************************/
#include "spatial_sample_player.h"
-#include "servers/audio_server.h"
#include "camera.h"
-#include "servers/spatial_sound_server.h"
#include "scene/scene_string_names.h"
+#include "servers/audio_server.h"
+#include "servers/spatial_sound_server.h"
-bool SpatialSamplePlayer::_set(const StringName& p_name, const Variant& p_value) {
+bool SpatialSamplePlayer::_set(const StringName &p_name, const Variant &p_value) {
- String name=p_name;
+ String name = p_name;
- if (name==SceneStringNames::get_singleton()->play_play) {
+ if (name == SceneStringNames::get_singleton()->play_play) {
if (library.is_valid()) {
- String what=p_value;
- if (what=="")
+ String what = p_value;
+ if (what == "")
stop_all();
else
play(what);
- played_back=what;
+ played_back = what;
}
return true;
-
}
return false;
}
-bool SpatialSamplePlayer::_get(const StringName& p_name,Variant &r_ret) const {
-
+bool SpatialSamplePlayer::_get(const StringName &p_name, Variant &r_ret) const {
- String name=p_name;
+ String name = p_name;
- if (name==SceneStringNames::get_singleton()->play_play) {
- r_ret=played_back;
+ if (name == SceneStringNames::get_singleton()->play_play) {
+ r_ret = played_back;
return true;
}
@@ -70,39 +68,35 @@ bool SpatialSamplePlayer::_get(const StringName& p_name,Variant &r_ret) const {
void SpatialSamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const {
- String en="";
+ String en = "";
if (library.is_valid()) {
List<StringName> samples;
- Ref<SampleLibrary> ncl=library;
+ Ref<SampleLibrary> ncl = library;
ncl->get_sample_list(&samples);
- for (List<StringName>::Element *E=samples.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = samples.front(); E; E = E->next()) {
- en+=",";
- en+=E->get();
+ en += ",";
+ en += E->get();
}
}
- p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
-
+ p_list->push_back(PropertyInfo(Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en, PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
}
void SpatialSamplePlayer::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
- SpatialSoundServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony);
-
+ SpatialSoundServer::get_singleton()->source_set_polyphony(get_source_rid(), polyphony);
} break;
}
-
}
-void SpatialSamplePlayer::set_sample_library(const Ref<SampleLibrary>& p_library) {
+void SpatialSamplePlayer::set_sample_library(const Ref<SampleLibrary> &p_library) {
- library=p_library;
+ library = p_library;
_change_notify();
update_configuration_warning();
}
@@ -114,11 +108,10 @@ Ref<SampleLibrary> SpatialSamplePlayer::get_sample_library() const {
void SpatialSamplePlayer::set_polyphony(int p_voice_count) {
- ERR_FAIL_COND(p_voice_count<0 || p_voice_count>64);
- polyphony=p_voice_count;
+ ERR_FAIL_COND(p_voice_count < 0 || p_voice_count > 64);
+ polyphony = p_voice_count;
if (get_source_rid().is_valid())
- SpatialSoundServer::get_singleton()->source_set_polyphony(get_source_rid(),polyphony);
-
+ SpatialSoundServer::get_singleton()->source_set_polyphony(get_source_rid(), polyphony);
}
int SpatialSamplePlayer::get_polyphony() const {
@@ -126,7 +119,7 @@ int SpatialSamplePlayer::get_polyphony() const {
return polyphony;
}
-SpatialSamplePlayer::VoiceID SpatialSamplePlayer::play(const String& p_sample,int p_voice) {
+SpatialSamplePlayer::VoiceID SpatialSamplePlayer::play(const String &p_sample, int p_voice) {
if (!get_source_rid().is_valid())
return INVALID_VOICE;
@@ -138,13 +131,11 @@ SpatialSamplePlayer::VoiceID SpatialSamplePlayer::play(const String& p_sample,in
float vol_change = library->sample_get_volume_db(p_sample);
float pitch_change = library->sample_get_pitch_scale(p_sample);
- VoiceID vid = SpatialSoundServer::get_singleton()->source_play_sample(get_source_rid(),sample->get_rid(),sample->get_mix_rate()*pitch_change,p_voice);
+ VoiceID vid = SpatialSoundServer::get_singleton()->source_play_sample(get_source_rid(), sample->get_rid(), sample->get_mix_rate() * pitch_change, p_voice);
if (vol_change)
- SpatialSoundServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),vid,vol_change);
+ SpatialSoundServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(), vid, vol_change);
return vid;
-
-
}
//voices
void SpatialSamplePlayer::voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale) {
@@ -152,32 +143,28 @@ void SpatialSamplePlayer::voice_set_pitch_scale(VoiceID p_voice, float p_pitch_s
if (!get_source_rid().is_valid())
return;
- SpatialSoundServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(),p_voice,p_pitch_scale);
-
+ SpatialSoundServer::get_singleton()->source_voice_set_pitch_scale(get_source_rid(), p_voice, p_pitch_scale);
}
void SpatialSamplePlayer::voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db) {
if (!get_source_rid().is_valid())
return;
- SpatialSoundServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(),p_voice,p_volume_db);
-
+ SpatialSoundServer::get_singleton()->source_voice_set_volume_scale_db(get_source_rid(), p_voice, p_volume_db);
}
bool SpatialSamplePlayer::is_voice_active(VoiceID p_voice) const {
if (!get_source_rid().is_valid())
return false;
- return SpatialSoundServer::get_singleton()->source_is_voice_active(get_source_rid(),p_voice);
-
+ return SpatialSoundServer::get_singleton()->source_is_voice_active(get_source_rid(), p_voice);
}
void SpatialSamplePlayer::stop_voice(VoiceID p_voice) {
if (!get_source_rid().is_valid())
return;
- SpatialSoundServer::get_singleton()->source_stop_voice(get_source_rid(),p_voice);
-
+ SpatialSoundServer::get_singleton()->source_stop_voice(get_source_rid(), p_voice);
}
void SpatialSamplePlayer::stop_all() {
@@ -185,9 +172,9 @@ void SpatialSamplePlayer::stop_all() {
if (!get_source_rid().is_valid())
return;
- for(int i=0;i<polyphony;i++) {
+ for (int i = 0; i < polyphony; i++) {
- SpatialSoundServer::get_singleton()->source_stop_voice(get_source_rid(),i);
+ SpatialSoundServer::get_singleton()->source_stop_voice(get_source_rid(), i);
}
}
@@ -200,42 +187,34 @@ String SpatialSamplePlayer::get_configuration_warning() const {
return String();
}
-
void SpatialSamplePlayer::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_sample_library", "library:SampleLibrary"), &SpatialSamplePlayer::set_sample_library);
+ ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"), &SpatialSamplePlayer::get_sample_library);
- ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SpatialSamplePlayer::set_sample_library);
- ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SpatialSamplePlayer::get_sample_library);
-
- ObjectTypeDB::bind_method(_MD("set_polyphony","voices"),&SpatialSamplePlayer::set_polyphony);
- ObjectTypeDB::bind_method(_MD("get_polyphony"),&SpatialSamplePlayer::get_polyphony);
+ ObjectTypeDB::bind_method(_MD("set_polyphony", "voices"), &SpatialSamplePlayer::set_polyphony);
+ ObjectTypeDB::bind_method(_MD("get_polyphony"), &SpatialSamplePlayer::get_polyphony);
- ObjectTypeDB::bind_method(_MD("play","sample","voice"),&SpatialSamplePlayer::play,DEFVAL(NEXT_VOICE));
+ ObjectTypeDB::bind_method(_MD("play", "sample", "voice"), &SpatialSamplePlayer::play, DEFVAL(NEXT_VOICE));
//voices,DEV
- ObjectTypeDB::bind_method(_MD("voice_set_pitch_scale","voice","ratio"),&SpatialSamplePlayer::voice_set_pitch_scale);
- ObjectTypeDB::bind_method(_MD("voice_set_volume_scale_db","voice","db"),&SpatialSamplePlayer::voice_set_volume_scale_db);
+ ObjectTypeDB::bind_method(_MD("voice_set_pitch_scale", "voice", "ratio"), &SpatialSamplePlayer::voice_set_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("voice_set_volume_scale_db", "voice", "db"), &SpatialSamplePlayer::voice_set_volume_scale_db);
- ObjectTypeDB::bind_method(_MD("is_voice_active","voice"),&SpatialSamplePlayer::is_voice_active);
- ObjectTypeDB::bind_method(_MD("stop_voice","voice"),&SpatialSamplePlayer::stop_voice);
- ObjectTypeDB::bind_method(_MD("stop_all"),&SpatialSamplePlayer::stop_all);
-
- BIND_CONSTANT( INVALID_VOICE );
- BIND_CONSTANT( NEXT_VOICE );
-
- ADD_PROPERTY( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,64,1"),_SCS("set_polyphony"),_SCS("get_polyphony"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE,"SampleLibrary"),_SCS("set_sample_library"),_SCS("get_sample_library"));
+ ObjectTypeDB::bind_method(_MD("is_voice_active", "voice"), &SpatialSamplePlayer::is_voice_active);
+ ObjectTypeDB::bind_method(_MD("stop_voice", "voice"), &SpatialSamplePlayer::stop_voice);
+ ObjectTypeDB::bind_method(_MD("stop_all"), &SpatialSamplePlayer::stop_all);
+ BIND_CONSTANT(INVALID_VOICE);
+ BIND_CONSTANT(NEXT_VOICE);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,64,1"), _SCS("set_polyphony"), _SCS("get_polyphony"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary"), _SCS("set_sample_library"), _SCS("get_sample_library"));
}
-
SpatialSamplePlayer::SpatialSamplePlayer() {
- polyphony=1;
-
+ polyphony = 1;
}
SpatialSamplePlayer::~SpatialSamplePlayer() {
-
-
}
diff --git a/scene/3d/spatial_sample_player.h b/scene/3d/spatial_sample_player.h
index 772256bc1..fafb78a27 100644
--- a/scene/3d/spatial_sample_player.h
+++ b/scene/3d/spatial_sample_player.h
@@ -35,41 +35,38 @@
class SpatialSamplePlayer : public SpatialPlayer {
- OBJ_TYPE(SpatialSamplePlayer,SpatialPlayer);
-public:
+ OBJ_TYPE(SpatialSamplePlayer, SpatialPlayer);
+public:
enum {
- INVALID_VOICE=SpatialSoundServer::SOURCE_INVALID_VOICE,
- NEXT_VOICE=SpatialSoundServer::SOURCE_NEXT_VOICE
+ INVALID_VOICE = SpatialSoundServer::SOURCE_INVALID_VOICE,
+ NEXT_VOICE = SpatialSoundServer::SOURCE_NEXT_VOICE
};
typedef int VoiceID;
-
private:
-
Ref<SampleLibrary> library;
int polyphony;
String played_back;
-protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
-
- void set_sample_library(const Ref<SampleLibrary>& p_library);
+ void set_sample_library(const Ref<SampleLibrary> &p_library);
Ref<SampleLibrary> get_sample_library() const;
void set_polyphony(int p_voice_count);
int get_polyphony() const;
- VoiceID play(const String& p_sample,int p_voice=NEXT_VOICE);
+ VoiceID play(const String &p_sample, int p_voice = NEXT_VOICE);
//voices
void voice_set_pitch_scale(VoiceID p_voice, float p_pitch_scale);
void voice_set_volume_scale_db(VoiceID p_voice, float p_volume_db);
@@ -82,9 +79,6 @@ public:
SpatialSamplePlayer();
~SpatialSamplePlayer();
-
-
};
-
#endif // SPATIAL_SAMPLE_PLAYER_H
diff --git a/scene/3d/spatial_stream_player.cpp b/scene/3d/spatial_stream_player.cpp
index 3027a7641..e698ba0c3 100644
--- a/scene/3d/spatial_stream_player.cpp
+++ b/scene/3d/spatial_stream_player.cpp
@@ -28,40 +28,37 @@
/*************************************************************************/
#include "spatial_stream_player.h"
-
-
int SpatialStreamPlayer::InternalStream::get_channel_count() const {
return player->sp_get_channel_count();
}
-void SpatialStreamPlayer::InternalStream::set_mix_rate(int p_rate){
+void SpatialStreamPlayer::InternalStream::set_mix_rate(int p_rate) {
return player->sp_set_mix_rate(p_rate);
}
-bool SpatialStreamPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){
+bool SpatialStreamPlayer::InternalStream::mix(int32_t *p_buffer, int p_frames) {
- return player->sp_mix(p_buffer,p_frames);
+ return player->sp_mix(p_buffer, p_frames);
}
-void SpatialStreamPlayer::InternalStream::update(){
+void SpatialStreamPlayer::InternalStream::update() {
player->sp_update();
}
-
int SpatialStreamPlayer::sp_get_channel_count() const {
return playback->get_channels();
}
-void SpatialStreamPlayer::sp_set_mix_rate(int p_rate){
+void SpatialStreamPlayer::sp_set_mix_rate(int p_rate) {
- server_mix_rate=p_rate;
+ server_mix_rate = p_rate;
}
-bool SpatialStreamPlayer::sp_mix(int32_t *p_buffer,int p_frames) {
+bool SpatialStreamPlayer::sp_mix(int32_t *p_buffer, int p_frames) {
if (resampler.is_ready() && !paused) {
- return resampler.mix(p_buffer,p_frames);
+ return resampler.mix(p_buffer, p_frames);
}
return false;
@@ -76,7 +73,7 @@ void SpatialStreamPlayer::sp_update() {
//stream depleted data, but there's still audio in the ringbuffer
//check that all this audio has been flushed before stopping the stream
int to_mix = resampler.get_total() - resampler.get_todo();
- if (to_mix==0) {
+ if (to_mix == 0) {
stop();
return;
}
@@ -84,17 +81,15 @@ void SpatialStreamPlayer::sp_update() {
return;
}
- int todo =resampler.get_todo();
- int wrote = playback->mix(resampler.get_write_buffer(),todo);
+ int todo = resampler.get_todo();
+ int wrote = playback->mix(resampler.get_write_buffer(), todo);
resampler.write(wrote);
}
}
-
-
void SpatialStreamPlayer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -109,20 +104,18 @@ void SpatialStreamPlayer::_notification(int p_what) {
}
}
-
-
void SpatialStreamPlayer::set_stream(const Ref<AudioStream> &p_stream) {
stop();
- stream=p_stream;
+ stream = p_stream;
if (!stream.is_null()) {
- playback=stream->instance_playback();
+ playback = stream->instance_playback();
playback->set_loop(loops);
playback->set_loop_restart_time(loop_point);
AudioServer::get_singleton()->lock();
- resampler.setup(playback->get_channels(),playback->get_mix_rate(),server_mix_rate,buffering_ms,playback->get_minimum_buffer_size());
+ resampler.setup(playback->get_channels(), playback->get_mix_rate(), server_mix_rate, buffering_ms, playback->get_minimum_buffer_size());
AudioServer::get_singleton()->unlock();
} else {
AudioServer::get_singleton()->lock();
@@ -137,7 +130,6 @@ Ref<AudioStream> SpatialStreamPlayer::get_stream() const {
return stream;
}
-
void SpatialStreamPlayer::play(float p_from_offset) {
ERR_FAIL_COND(!is_inside_tree());
@@ -151,13 +143,12 @@ void SpatialStreamPlayer::play(float p_from_offset) {
//feed the ringbuffer as long as no update callback is going on
sp_update();
- SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(),&internal_stream);
-
-// AudioServer::get_singleton()->stream_set_active(stream_rid,true);
-// AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
-// if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
-// set_idle_process(true);
+ SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(), &internal_stream);
+ // AudioServer::get_singleton()->stream_set_active(stream_rid,true);
+ // AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
+ // if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
+ // set_idle_process(true);
}
void SpatialStreamPlayer::stop() {
@@ -169,7 +160,7 @@ void SpatialStreamPlayer::stop() {
_THREAD_SAFE_METHOD_
//AudioServer::get_singleton()->stream_set_active(stream_rid,false);
- SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(),NULL);
+ SpatialSoundServer::get_singleton()->source_set_audio_stream(get_source_rid(), NULL);
playback->stop();
resampler.flush();
//set_idle_process(false);
@@ -185,11 +176,10 @@ bool SpatialStreamPlayer::is_playing() const {
void SpatialStreamPlayer::set_loop(bool p_enable) {
- loops=p_enable;
+ loops = p_enable;
if (playback.is_null())
return;
playback->set_loop(loops);
-
}
bool SpatialStreamPlayer::has_loop() const {
@@ -198,9 +188,9 @@ bool SpatialStreamPlayer::has_loop() const {
void SpatialStreamPlayer::set_volume(float p_vol) {
- volume=p_vol;
+ volume = p_vol;
if (stream_rid.is_valid())
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
+ AudioServer::get_singleton()->stream_set_volume_scale(stream_rid, volume);
}
float SpatialStreamPlayer::get_volume() const {
@@ -210,7 +200,7 @@ float SpatialStreamPlayer::get_volume() const {
void SpatialStreamPlayer::set_loop_restart_time(float p_secs) {
- loop_point=p_secs;
+ loop_point = p_secs;
if (playback.is_valid())
playback->set_loop_restart_time(p_secs);
}
@@ -220,10 +210,9 @@ float SpatialStreamPlayer::get_loop_restart_time() const {
return loop_point;
}
-
void SpatialStreamPlayer::set_volume_db(float p_db) {
- if (p_db<-79)
+ if (p_db < -79)
set_volume(0);
else
set_volume(Math::db2linear(p_db));
@@ -231,35 +220,31 @@ void SpatialStreamPlayer::set_volume_db(float p_db) {
float SpatialStreamPlayer::get_volume_db() const {
- if (volume==0)
+ if (volume == 0)
return -80;
else
return Math::linear2db(volume);
}
-
-String SpatialStreamPlayer::get_stream_name() const {
+String SpatialStreamPlayer::get_stream_name() const {
if (stream.is_null())
return "<No Stream>";
return stream->get_name();
-
}
-int SpatialStreamPlayer::get_loop_count() const {
+int SpatialStreamPlayer::get_loop_count() const {
if (playback.is_null())
return 0;
return playback->get_loop_count();
-
}
-float SpatialStreamPlayer::get_pos() const {
+float SpatialStreamPlayer::get_pos() const {
if (playback.is_null())
return 0;
return playback->get_pos();
-
}
float SpatialStreamPlayer::get_length() const {
@@ -273,12 +258,11 @@ void SpatialStreamPlayer::seek_pos(float p_time) {
if (playback.is_null())
return;
return playback->seek_pos(p_time);
-
}
void SpatialStreamPlayer::set_autoplay(bool p_enable) {
- autoplay=p_enable;
+ autoplay = p_enable;
}
bool SpatialStreamPlayer::has_autoplay() const {
@@ -288,7 +272,7 @@ bool SpatialStreamPlayer::has_autoplay() const {
void SpatialStreamPlayer::set_paused(bool p_paused) {
- paused=p_paused;
+ paused = p_paused;
//if (stream.is_valid())
// stream->set_paused(p_paused);
}
@@ -300,104 +284,97 @@ bool SpatialStreamPlayer::is_paused() const {
void SpatialStreamPlayer::_set_play(bool p_play) {
- _play=p_play;
+ _play = p_play;
if (is_inside_tree()) {
- if(_play)
+ if (_play)
play();
else
stop();
}
-
}
-bool SpatialStreamPlayer::_get_play() const{
+bool SpatialStreamPlayer::_get_play() const {
return _play;
}
void SpatialStreamPlayer::set_buffering_msec(int p_msec) {
- buffering_ms=p_msec;
+ buffering_ms = p_msec;
}
-int SpatialStreamPlayer::get_buffering_msec() const{
+int SpatialStreamPlayer::get_buffering_msec() const {
return buffering_ms;
}
-
-
void SpatialStreamPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:AudioStream"),&SpatialStreamPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:AudioStream"),&SpatialStreamPlayer::get_stream);
+ ObjectTypeDB::bind_method(_MD("set_stream", "stream:AudioStream"), &SpatialStreamPlayer::set_stream);
+ ObjectTypeDB::bind_method(_MD("get_stream:AudioStream"), &SpatialStreamPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play","offset"),&SpatialStreamPlayer::play,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("stop"),&SpatialStreamPlayer::stop);
+ ObjectTypeDB::bind_method(_MD("play", "offset"), &SpatialStreamPlayer::play, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("stop"), &SpatialStreamPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&SpatialStreamPlayer::is_playing);
+ ObjectTypeDB::bind_method(_MD("is_playing"), &SpatialStreamPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&SpatialStreamPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&SpatialStreamPlayer::is_paused);
+ ObjectTypeDB::bind_method(_MD("set_paused", "paused"), &SpatialStreamPlayer::set_paused);
+ ObjectTypeDB::bind_method(_MD("is_paused"), &SpatialStreamPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&SpatialStreamPlayer::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&SpatialStreamPlayer::has_loop);
+ ObjectTypeDB::bind_method(_MD("set_loop", "enabled"), &SpatialStreamPlayer::set_loop);
+ ObjectTypeDB::bind_method(_MD("has_loop"), &SpatialStreamPlayer::has_loop);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&SpatialStreamPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&SpatialStreamPlayer::get_volume);
+ ObjectTypeDB::bind_method(_MD("set_volume", "volume"), &SpatialStreamPlayer::set_volume);
+ ObjectTypeDB::bind_method(_MD("get_volume"), &SpatialStreamPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&SpatialStreamPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&SpatialStreamPlayer::get_volume_db);
+ ObjectTypeDB::bind_method(_MD("set_volume_db", "db"), &SpatialStreamPlayer::set_volume_db);
+ ObjectTypeDB::bind_method(_MD("get_volume_db"), &SpatialStreamPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&SpatialStreamPlayer::set_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&SpatialStreamPlayer::get_buffering_msec);
+ ObjectTypeDB::bind_method(_MD("set_buffering_msec", "msec"), &SpatialStreamPlayer::set_buffering_msec);
+ ObjectTypeDB::bind_method(_MD("get_buffering_msec"), &SpatialStreamPlayer::get_buffering_msec);
- ObjectTypeDB::bind_method(_MD("set_loop_restart_time","secs"),&SpatialStreamPlayer::set_loop_restart_time);
- ObjectTypeDB::bind_method(_MD("get_loop_restart_time"),&SpatialStreamPlayer::get_loop_restart_time);
+ ObjectTypeDB::bind_method(_MD("set_loop_restart_time", "secs"), &SpatialStreamPlayer::set_loop_restart_time);
+ ObjectTypeDB::bind_method(_MD("get_loop_restart_time"), &SpatialStreamPlayer::get_loop_restart_time);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&SpatialStreamPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_loop_count"),&SpatialStreamPlayer::get_loop_count);
+ ObjectTypeDB::bind_method(_MD("get_stream_name"), &SpatialStreamPlayer::get_stream_name);
+ ObjectTypeDB::bind_method(_MD("get_loop_count"), &SpatialStreamPlayer::get_loop_count);
- ObjectTypeDB::bind_method(_MD("get_pos"),&SpatialStreamPlayer::get_pos);
- ObjectTypeDB::bind_method(_MD("seek_pos","time"),&SpatialStreamPlayer::seek_pos);
+ ObjectTypeDB::bind_method(_MD("get_pos"), &SpatialStreamPlayer::get_pos);
+ ObjectTypeDB::bind_method(_MD("seek_pos", "time"), &SpatialStreamPlayer::seek_pos);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&SpatialStreamPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&SpatialStreamPlayer::has_autoplay);
+ ObjectTypeDB::bind_method(_MD("set_autoplay", "enabled"), &SpatialStreamPlayer::set_autoplay);
+ ObjectTypeDB::bind_method(_MD("has_autoplay"), &SpatialStreamPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("get_length"),&SpatialStreamPlayer::get_length);
+ ObjectTypeDB::bind_method(_MD("get_length"), &SpatialStreamPlayer::get_length);
- ObjectTypeDB::bind_method(_MD("_set_play","play"),&SpatialStreamPlayer::_set_play);
- ObjectTypeDB::bind_method(_MD("_get_play"),&SpatialStreamPlayer::_get_play);
+ ObjectTypeDB::bind_method(_MD("_set_play", "play"), &SpatialStreamPlayer::_set_play);
+ ObjectTypeDB::bind_method(_MD("_get_play"), &SpatialStreamPlayer::_get_play);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), _SCS("set_stream"), _SCS("get_stream"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "stream/loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "stream/buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec"));
}
-
SpatialStreamPlayer::SpatialStreamPlayer() {
- volume=1;
- loops=false;
- paused=false;
- autoplay=false;
- _play=false;
- server_mix_rate=1;
- internal_stream.player=this;
- stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
- buffering_ms=500;
- loop_point=0;
-
+ volume = 1;
+ loops = false;
+ paused = false;
+ autoplay = false;
+ _play = false;
+ server_mix_rate = 1;
+ internal_stream.player = this;
+ stream_rid = AudioServer::get_singleton()->audio_stream_create(&internal_stream);
+ buffering_ms = 500;
+ loop_point = 0;
}
SpatialStreamPlayer::~SpatialStreamPlayer() {
AudioServer::get_singleton()->free(stream_rid);
resampler.clear();
-
-
}
diff --git a/scene/3d/spatial_stream_player.h b/scene/3d/spatial_stream_player.h
index d89f0006d..b1367667d 100644
--- a/scene/3d/spatial_stream_player.h
+++ b/scene/3d/spatial_stream_player.h
@@ -29,13 +29,13 @@
#ifndef SPATIAL_STREAM_PLAYER_H
#define SPATIAL_STREAM_PLAYER_H
-#include "scene/resources/audio_stream.h"
#include "scene/3d/spatial_player.h"
+#include "scene/resources/audio_stream.h"
#include "servers/audio/audio_rb_resampler.h"
class SpatialStreamPlayer : public SpatialPlayer {
- OBJ_TYPE(SpatialStreamPlayer,SpatialPlayer);
+ OBJ_TYPE(SpatialStreamPlayer, SpatialPlayer);
_THREAD_SAFE_CLASS_
@@ -43,18 +43,17 @@ class SpatialStreamPlayer : public SpatialPlayer {
SpatialStreamPlayer *player;
virtual int get_channel_count() const;
virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames);
+ virtual bool mix(int32_t *p_buffer, int p_frames);
virtual void update();
};
-
InternalStream internal_stream;
Ref<AudioStreamPlayback> playback;
Ref<AudioStream> stream;
int sp_get_channel_count() const;
void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate
- bool sp_mix(int32_t *p_buffer,int p_frames);
+ bool sp_mix(int32_t *p_buffer, int p_frames);
void sp_update();
int server_mix_rate;
@@ -72,16 +71,17 @@ class SpatialStreamPlayer : public SpatialPlayer {
bool _play;
void _set_play(bool p_play);
bool _get_play() const;
+
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_stream(const Ref<AudioStream> &p_stream);
Ref<AudioStream> get_stream() const;
- void play(float p_from_offset=0);
+ void play(float p_from_offset = 0);
void stop();
bool is_playing() const;
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 6bc72125a..0e5386c09 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -27,9 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "sprite_3d.h"
-#include "scene/scene_string_names.h"
#include "core_string_names.h"
-
+#include "scene/scene_string_names.h"
Color SpriteBase3D::_get_color_accum() {
@@ -37,15 +36,15 @@ Color SpriteBase3D::_get_color_accum() {
return color_accum;
if (parent_sprite)
- color_accum=parent_sprite->_get_color_accum();
+ color_accum = parent_sprite->_get_color_accum();
else
- color_accum=Color(1,1,1,1);
+ color_accum = Color(1, 1, 1, 1);
- color_accum.r*=modulate.r;
- color_accum.g*=modulate.g;
- color_accum.b*=modulate.b;
- color_accum.a*=modulate.a;
- color_dirty=false;
+ color_accum.r *= modulate.r;
+ color_accum.g *= modulate.g;
+ color_accum.b *= modulate.b;
+ color_accum.a *= modulate.a;
+ color_dirty = false;
return color_accum;
}
@@ -54,10 +53,10 @@ void SpriteBase3D::_propagate_color_changed() {
if (color_dirty)
return;
- color_dirty=true;
+ color_dirty = true;
_queue_update();
- for (List<SpriteBase3D*>::Element *E=children.front();E;E=E->next()) {
+ for (List<SpriteBase3D *>::Element *E = children.front(); E; E = E->next()) {
E->get()->_propagate_color_changed();
}
@@ -65,40 +64,36 @@ void SpriteBase3D::_propagate_color_changed() {
void SpriteBase3D::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
if (!pending_update)
_im_update();
- Node *parent=get_parent();
+ Node *parent = get_parent();
if (parent) {
- parent_sprite=parent->cast_to<SpriteBase3D>();
+ parent_sprite = parent->cast_to<SpriteBase3D>();
if (parent_sprite) {
- pI=parent_sprite->children.push_back(this);
+ pI = parent_sprite->children.push_back(this);
}
}
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
-
+ if (p_what == NOTIFICATION_EXIT_TREE) {
if (parent_sprite) {
parent_sprite->children.erase(pI);
- pI=NULL;
- parent_sprite=NULL;
+ pI = NULL;
+ parent_sprite = NULL;
}
}
-
}
-
void SpriteBase3D::set_centered(bool p_center) {
- centered=p_center;
+ centered = p_center;
_queue_update();
-
}
bool SpriteBase3D::is_centered() const {
@@ -106,11 +101,10 @@ bool SpriteBase3D::is_centered() const {
return centered;
}
-void SpriteBase3D::set_offset(const Point2& p_offset) {
+void SpriteBase3D::set_offset(const Point2 &p_offset) {
- offset=p_offset;
+ offset = p_offset;
_queue_update();
-
}
Point2 SpriteBase3D::get_offset() const {
@@ -119,7 +113,7 @@ Point2 SpriteBase3D::get_offset() const {
void SpriteBase3D::set_flip_h(bool p_flip) {
- hflip=p_flip;
+ hflip = p_flip;
_queue_update();
}
bool SpriteBase3D::is_flipped_h() const {
@@ -129,7 +123,7 @@ bool SpriteBase3D::is_flipped_h() const {
void SpriteBase3D::set_flip_v(bool p_flip) {
- vflip=p_flip;
+ vflip = p_flip;
_queue_update();
}
bool SpriteBase3D::is_flipped_v() const {
@@ -137,24 +131,21 @@ bool SpriteBase3D::is_flipped_v() const {
return vflip;
}
+void SpriteBase3D::set_modulate(const Color &p_color) {
-
-void SpriteBase3D::set_modulate(const Color& p_color) {
-
- modulate=p_color;
+ modulate = p_color;
_propagate_color_changed();
_queue_update();
}
-Color SpriteBase3D::get_modulate() const{
+Color SpriteBase3D::get_modulate() const {
return modulate;
}
-
void SpriteBase3D::set_pixel_size(float p_amount) {
- pixel_size=p_amount;
+ pixel_size = p_amount;
_queue_update();
}
float SpriteBase3D::get_pixel_size() const {
@@ -164,7 +155,7 @@ float SpriteBase3D::get_pixel_size() const {
void SpriteBase3D::set_opacity(float p_amount) {
- opacity=p_amount;
+ opacity = p_amount;
_queue_update();
}
float SpriteBase3D::get_opacity() const {
@@ -172,10 +163,9 @@ float SpriteBase3D::get_opacity() const {
return opacity;
}
-
void SpriteBase3D::set_axis(Vector3::Axis p_axis) {
- axis=p_axis;
+ axis = p_axis;
_queue_update();
}
Vector3::Axis SpriteBase3D::get_axis() const {
@@ -183,30 +173,24 @@ Vector3::Axis SpriteBase3D::get_axis() const {
return axis;
}
-
-
void SpriteBase3D::_im_update() {
-
_draw();
-
- pending_update=false;
+ pending_update = false;
//texture->draw_rect_region(ci,dst_rect,src_rect,modulate);
-
}
-void SpriteBase3D::_queue_update(){
+void SpriteBase3D::_queue_update() {
- if (pending_update)
+ if (pending_update)
return;
- pending_update=true;
+ pending_update = true;
call_deferred(SceneStringNames::get_singleton()->_im_update);
}
-
AABB SpriteBase3D::get_aabb() const {
return aabb;
@@ -214,134 +198,118 @@ AABB SpriteBase3D::get_aabb() const {
DVector<Face3> SpriteBase3D::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
-
}
-void SpriteBase3D::set_draw_flag(DrawFlags p_flag,bool p_enable) {
+void SpriteBase3D::set_draw_flag(DrawFlags p_flag, bool p_enable) {
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags[p_flag]=p_enable;
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ flags[p_flag] = p_enable;
_queue_update();
}
-bool SpriteBase3D::get_draw_flag(DrawFlags p_flag) const{
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+bool SpriteBase3D::get_draw_flag(DrawFlags p_flag) const {
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags[p_flag];
}
-void SpriteBase3D::set_alpha_cut_mode(AlphaCutMode p_mode){
+void SpriteBase3D::set_alpha_cut_mode(AlphaCutMode p_mode) {
- ERR_FAIL_INDEX(p_mode,3);
- alpha_cut=p_mode;
+ ERR_FAIL_INDEX(p_mode, 3);
+ alpha_cut = p_mode;
_queue_update();
-
}
-SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const{
+SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const {
return alpha_cut;
}
-
void SpriteBase3D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_centered", "centered"), &SpriteBase3D::set_centered);
+ ObjectTypeDB::bind_method(_MD("is_centered"), &SpriteBase3D::is_centered);
- ObjectTypeDB::bind_method(_MD("set_centered","centered"),&SpriteBase3D::set_centered);
- ObjectTypeDB::bind_method(_MD("is_centered"),&SpriteBase3D::is_centered);
-
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&SpriteBase3D::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&SpriteBase3D::get_offset);
-
- ObjectTypeDB::bind_method(_MD("set_flip_h","flip_h"),&SpriteBase3D::set_flip_h);
- ObjectTypeDB::bind_method(_MD("is_flipped_h"),&SpriteBase3D::is_flipped_h);
-
- ObjectTypeDB::bind_method(_MD("set_flip_v","flip_v"),&SpriteBase3D::set_flip_v);
- ObjectTypeDB::bind_method(_MD("is_flipped_v"),&SpriteBase3D::is_flipped_v);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &SpriteBase3D::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &SpriteBase3D::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_flip_h", "flip_h"), &SpriteBase3D::set_flip_h);
+ ObjectTypeDB::bind_method(_MD("is_flipped_h"), &SpriteBase3D::is_flipped_h);
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&SpriteBase3D::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&SpriteBase3D::get_modulate);
+ ObjectTypeDB::bind_method(_MD("set_flip_v", "flip_v"), &SpriteBase3D::set_flip_v);
+ ObjectTypeDB::bind_method(_MD("is_flipped_v"), &SpriteBase3D::is_flipped_v);
- ObjectTypeDB::bind_method(_MD("set_opacity","opacity"),&SpriteBase3D::set_opacity);
- ObjectTypeDB::bind_method(_MD("get_opacity"),&SpriteBase3D::get_opacity);
+ ObjectTypeDB::bind_method(_MD("set_modulate", "modulate"), &SpriteBase3D::set_modulate);
+ ObjectTypeDB::bind_method(_MD("get_modulate"), &SpriteBase3D::get_modulate);
- ObjectTypeDB::bind_method(_MD("set_pixel_size","pixel_size"),&SpriteBase3D::set_pixel_size);
- ObjectTypeDB::bind_method(_MD("get_pixel_size"),&SpriteBase3D::get_pixel_size);
+ ObjectTypeDB::bind_method(_MD("set_opacity", "opacity"), &SpriteBase3D::set_opacity);
+ ObjectTypeDB::bind_method(_MD("get_opacity"), &SpriteBase3D::get_opacity);
- ObjectTypeDB::bind_method(_MD("set_axis","axis"),&SpriteBase3D::set_axis);
- ObjectTypeDB::bind_method(_MD("get_axis"),&SpriteBase3D::get_axis);
+ ObjectTypeDB::bind_method(_MD("set_pixel_size", "pixel_size"), &SpriteBase3D::set_pixel_size);
+ ObjectTypeDB::bind_method(_MD("get_pixel_size"), &SpriteBase3D::get_pixel_size);
- ObjectTypeDB::bind_method(_MD("set_draw_flag","flag","enabled"),&SpriteBase3D::set_draw_flag);
- ObjectTypeDB::bind_method(_MD("get_draw_flag","flag"),&SpriteBase3D::get_draw_flag);
+ ObjectTypeDB::bind_method(_MD("set_axis", "axis"), &SpriteBase3D::set_axis);
+ ObjectTypeDB::bind_method(_MD("get_axis"), &SpriteBase3D::get_axis);
- ObjectTypeDB::bind_method(_MD("set_alpha_cut_mode","mode"),&SpriteBase3D::set_alpha_cut_mode);
- ObjectTypeDB::bind_method(_MD("get_alpha_cut_mode"),&SpriteBase3D::get_alpha_cut_mode);
+ ObjectTypeDB::bind_method(_MD("set_draw_flag", "flag", "enabled"), &SpriteBase3D::set_draw_flag);
+ ObjectTypeDB::bind_method(_MD("get_draw_flag", "flag"), &SpriteBase3D::get_draw_flag);
- ObjectTypeDB::bind_method(_MD("get_item_rect"),&SpriteBase3D::get_item_rect);
+ ObjectTypeDB::bind_method(_MD("set_alpha_cut_mode", "mode"), &SpriteBase3D::set_alpha_cut_mode);
+ ObjectTypeDB::bind_method(_MD("get_alpha_cut_mode"), &SpriteBase3D::get_alpha_cut_mode);
- ObjectTypeDB::bind_method(_MD("_queue_update"),&SpriteBase3D::_queue_update);
- ObjectTypeDB::bind_method(_MD("_im_update"),&SpriteBase3D::_im_update);
+ ObjectTypeDB::bind_method(_MD("get_item_rect"), &SpriteBase3D::get_item_rect);
+ ObjectTypeDB::bind_method(_MD("_queue_update"), &SpriteBase3D::_queue_update);
+ ObjectTypeDB::bind_method(_MD("_im_update"), &SpriteBase3D::_im_update);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_h"), _SCS("set_flip_h"),_SCS("is_flipped_h"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flip_v"), _SCS("set_flip_v"),_SCS("is_flipped_v"));
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "opacity",PROPERTY_HINT_RANGE,"0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "pixel_size",PROPERTY_HINT_RANGE,"0.0001,128,0.0001"), _SCS("set_pixel_size"),_SCS("get_pixel_size"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "axis",PROPERTY_HINT_ENUM,"X-Axis,Y-Axis,Z-Axis"), _SCS("set_axis"),_SCS("get_axis"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "flags/transparent"), _SCS("set_draw_flag"),_SCS("get_draw_flag"),FLAG_TRANSPARENT);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "flags/shaded"), _SCS("set_draw_flag"),_SCS("get_draw_flag"),FLAG_SHADED);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "flags/alpha_cut",PROPERTY_HINT_ENUM,"Disabled,Discard,Opaque Pre-Pass"), _SCS("set_alpha_cut_mode"),_SCS("get_alpha_cut_mode"));
-
-
- BIND_CONSTANT( FLAG_TRANSPARENT );
- BIND_CONSTANT( FLAG_SHADED );
- BIND_CONSTANT( FLAG_MAX );
-
- BIND_CONSTANT( ALPHA_CUT_DISABLED );
- BIND_CONSTANT( ALPHA_CUT_DISCARD );
- BIND_CONSTANT( ALPHA_CUT_OPAQUE_PREPASS );
-
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), _SCS("set_centered"), _SCS("is_centered"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_h"), _SCS("set_flip_h"), _SCS("is_flipped_h"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_v"), _SCS("set_flip_v"), _SCS("is_flipped_v"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "opacity", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"), _SCS("get_opacity"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "pixel_size", PROPERTY_HINT_RANGE, "0.0001,128,0.0001"), _SCS("set_pixel_size"), _SCS("get_pixel_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "axis", PROPERTY_HINT_ENUM, "X-Axis,Y-Axis,Z-Axis"), _SCS("set_axis"), _SCS("get_axis"));
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags/transparent"), _SCS("set_draw_flag"), _SCS("get_draw_flag"), FLAG_TRANSPARENT);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags/shaded"), _SCS("set_draw_flag"), _SCS("get_draw_flag"), FLAG_SHADED);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "flags/alpha_cut", PROPERTY_HINT_ENUM, "Disabled,Discard,Opaque Pre-Pass"), _SCS("set_alpha_cut_mode"), _SCS("get_alpha_cut_mode"));
+ BIND_CONSTANT(FLAG_TRANSPARENT);
+ BIND_CONSTANT(FLAG_SHADED);
+ BIND_CONSTANT(FLAG_MAX);
+ BIND_CONSTANT(ALPHA_CUT_DISABLED);
+ BIND_CONSTANT(ALPHA_CUT_DISCARD);
+ BIND_CONSTANT(ALPHA_CUT_OPAQUE_PREPASS);
}
-
-
-
SpriteBase3D::SpriteBase3D() {
- color_dirty=true;
- centered=true;
- hflip=false;
- vflip=false;
- parent_sprite=NULL;
- pI=NULL;
+ color_dirty = true;
+ centered = true;
+ hflip = false;
+ vflip = false;
+ parent_sprite = NULL;
+ pI = NULL;
- for(int i=0;i<FLAG_MAX;i++)
- flags[i]=i==FLAG_TRANSPARENT;
+ for (int i = 0; i < FLAG_MAX; i++)
+ flags[i] = i == FLAG_TRANSPARENT;
- axis=Vector3::AXIS_Z;
- pixel_size=0.01;
- modulate=Color(1,1,1,1);
- pending_update=false;
- opacity=1.0;
+ axis = Vector3::AXIS_Z;
+ pixel_size = 0.01;
+ modulate = Color(1, 1, 1, 1);
+ pending_update = false;
+ opacity = 1.0;
immediate = VisualServer::get_singleton()->immediate_create();
set_base(immediate);
}
-
SpriteBase3D::~SpriteBase3D() {
VisualServer::get_singleton()->free(immediate);
}
-
///////////////////////////////////////////
-
void Sprite3D::_draw() {
RID immediate = get_immediate();
@@ -350,7 +318,7 @@ void Sprite3D::_draw() {
if (!texture.is_valid())
return; //no texuture no life
Vector2 tsize = texture->get_size();
- if (tsize.x==0 || tsize.y==0)
+ if (tsize.x == 0 || tsize.y == 0)
return;
Size2i s;
@@ -358,130 +326,122 @@ void Sprite3D::_draw() {
if (region) {
- s=region_rect.size;
- src_rect=region_rect;
+ s = region_rect.size;
+ src_rect = region_rect;
} else {
s = texture->get_size();
- s=s/Size2i(hframes,vframes);
-
- src_rect.size=s;
- src_rect.pos.x+=(frame%hframes)*s.x;
- src_rect.pos.y+=(frame/hframes)*s.y;
+ s = s / Size2i(hframes, vframes);
+ src_rect.size = s;
+ src_rect.pos.x += (frame % hframes) * s.x;
+ src_rect.pos.y += (frame / hframes) * s.y;
}
- Point2i ofs=get_offset();
+ Point2i ofs = get_offset();
if (is_centered())
- ofs-=s/2;
-
- Rect2i dst_rect(ofs,s);
+ ofs -= s / 2;
+ Rect2i dst_rect(ofs, s);
Rect2 final_rect;
Rect2 final_src_rect;
- if (!texture->get_rect_region(dst_rect,src_rect,final_rect,final_src_rect))
+ if (!texture->get_rect_region(dst_rect, src_rect, final_rect, final_src_rect))
return;
-
- if (final_rect.size.x==0 || final_rect.size.y==0)
+ if (final_rect.size.x == 0 || final_rect.size.y == 0)
return;
- Color color=_get_color_accum();
- color.a*=get_opacity();
+ Color color = _get_color_accum();
+ color.a *= get_opacity();
- float pixel_size=get_pixel_size();
+ float pixel_size = get_pixel_size();
- Vector2 vertices[4]={
+ Vector2 vertices[4] = {
- (final_rect.pos+Vector2(0,final_rect.size.y)) * pixel_size,
- (final_rect.pos+final_rect.size) * pixel_size,
- (final_rect.pos+Vector2(final_rect.size.x,0)) * pixel_size,
+ (final_rect.pos + Vector2(0, final_rect.size.y)) * pixel_size,
+ (final_rect.pos + final_rect.size) * pixel_size,
+ (final_rect.pos + Vector2(final_rect.size.x, 0)) * pixel_size,
final_rect.pos * pixel_size,
-
};
- Vector2 uvs[4]={
+ Vector2 uvs[4] = {
final_src_rect.pos / tsize,
- (final_src_rect.pos+Vector2(final_src_rect.size.x,0)) / tsize,
- (final_src_rect.pos+final_src_rect.size) / tsize,
- (final_src_rect.pos+Vector2(0,final_src_rect.size.y)) / tsize,
+ (final_src_rect.pos + Vector2(final_src_rect.size.x, 0)) / tsize,
+ (final_src_rect.pos + final_src_rect.size) / tsize,
+ (final_src_rect.pos + Vector2(0, final_src_rect.size.y)) / tsize,
};
if (is_flipped_h()) {
- SWAP(uvs[0],uvs[1]);
- SWAP(uvs[2],uvs[3]);
+ SWAP(uvs[0], uvs[1]);
+ SWAP(uvs[2], uvs[3]);
}
if (is_flipped_v()) {
- SWAP(uvs[0],uvs[3]);
- SWAP(uvs[1],uvs[2]);
+ SWAP(uvs[0], uvs[3]);
+ SWAP(uvs[1], uvs[2]);
}
-
Vector3 normal;
int axis = get_axis();
- normal[axis]=1.0;
+ normal[axis] = 1.0;
- RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED),get_draw_flag(FLAG_TRANSPARENT),get_alpha_cut_mode()==ALPHA_CUT_DISCARD,get_alpha_cut_mode()==ALPHA_CUT_OPAQUE_PREPASS);
- VS::get_singleton()->immediate_set_material(immediate,mat);
+ RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS);
+ VS::get_singleton()->immediate_set_material(immediate, mat);
- VS::get_singleton()->immediate_begin(immediate,VS::PRIMITIVE_TRIANGLE_FAN,texture->get_rid());
+ VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid());
int x_axis = ((axis + 1) % 3);
int y_axis = ((axis + 2) % 3);
- if (axis!=Vector3::AXIS_Z) {
- SWAP(x_axis,y_axis);
+ if (axis != Vector3::AXIS_Z) {
+ SWAP(x_axis, y_axis);
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
//uvs[i] = Vector2(1.0,1.0)-uvs[i];
//SWAP(vertices[i].x,vertices[i].y);
- if (axis==Vector3::AXIS_Y) {
- vertices[i].y = - vertices[i].y;
- } else if (axis==Vector3::AXIS_X) {
- vertices[i].x = - vertices[i].x;
+ if (axis == Vector3::AXIS_Y) {
+ vertices[i].y = -vertices[i].y;
+ } else if (axis == Vector3::AXIS_X) {
+ vertices[i].x = -vertices[i].x;
}
}
}
AABB aabb;
- for(int i=0;i<4;i++) {
- VS::get_singleton()->immediate_normal(immediate,normal);
- VS::get_singleton()->immediate_color(immediate,color);
- VS::get_singleton()->immediate_uv(immediate,uvs[i]);
+ for (int i = 0; i < 4; i++) {
+ VS::get_singleton()->immediate_normal(immediate, normal);
+ VS::get_singleton()->immediate_color(immediate, color);
+ VS::get_singleton()->immediate_uv(immediate, uvs[i]);
Vector3 vtx;
- vtx[x_axis]=vertices[i][0];
- vtx[y_axis]=vertices[i][1];
- VS::get_singleton()->immediate_vertex(immediate,vtx);
- if (i==0) {
- aabb.pos=vtx;
- aabb.size=Vector3();
+ vtx[x_axis] = vertices[i][0];
+ vtx[y_axis] = vertices[i][1];
+ VS::get_singleton()->immediate_vertex(immediate, vtx);
+ if (i == 0) {
+ aabb.pos = vtx;
+ aabb.size = Vector3();
} else {
aabb.expand_to(vtx);
}
}
set_aabb(aabb);
VS::get_singleton()->immediate_end(immediate);
-
-
}
-void Sprite3D::set_texture(const Ref<Texture>& p_texture) {
+void Sprite3D::set_texture(const Ref<Texture> &p_texture) {
- if (p_texture==texture)
+ if (p_texture == texture)
return;
if (texture.is_valid()) {
- texture->disconnect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_queue_update);
+ texture->disconnect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_queue_update);
}
- texture=p_texture;
+ texture = p_texture;
if (texture.is_valid()) {
texture->set_flags(texture->get_flags()); //remove repeat from texture, it looks bad in sprites
- texture->connect(CoreStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_queue_update);
+ texture->connect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_queue_update);
}
_queue_update();
-
}
Ref<Texture> Sprite3D::get_texture() const {
@@ -491,22 +451,22 @@ Ref<Texture> Sprite3D::get_texture() const {
void Sprite3D::set_region(bool p_region) {
- if (p_region==region)
+ if (p_region == region)
return;
- region=p_region;
+ region = p_region;
_queue_update();
}
-bool Sprite3D::is_region() const{
+bool Sprite3D::is_region() const {
return region;
}
-void Sprite3D::set_region_rect(const Rect2& p_region_rect) {
+void Sprite3D::set_region_rect(const Rect2 &p_region_rect) {
- bool changed=region_rect!=p_region_rect;
- region_rect=p_region_rect;
+ bool changed = region_rect != p_region_rect;
+ region_rect = p_region_rect;
if (region && changed) {
_queue_update();
}
@@ -519,14 +479,13 @@ Rect2 Sprite3D::get_region_rect() const {
void Sprite3D::set_frame(int p_frame) {
- ERR_FAIL_INDEX(p_frame,vframes*hframes);
+ ERR_FAIL_INDEX(p_frame, vframes * hframes);
if (frame != p_frame)
- frame=p_frame;
+ frame = p_frame;
_queue_update();
emit_signal(SceneStringNames::get_singleton()->frame_changed);
-
}
int Sprite3D::get_frame() const {
@@ -536,8 +495,8 @@ int Sprite3D::get_frame() const {
void Sprite3D::set_vframes(int p_amount) {
- ERR_FAIL_COND(p_amount<1);
- vframes=p_amount;
+ ERR_FAIL_COND(p_amount < 1);
+ vframes = p_amount;
_queue_update();
_change_notify("frame");
}
@@ -548,8 +507,8 @@ int Sprite3D::get_vframes() const {
void Sprite3D::set_hframes(int p_amount) {
- ERR_FAIL_COND(p_amount<1);
- hframes=p_amount;
+ ERR_FAIL_COND(p_amount < 1);
+ hframes = p_amount;
_queue_update();
_change_notify("frame");
}
@@ -561,7 +520,7 @@ int Sprite3D::get_hframes() const {
Rect2 Sprite3D::get_item_rect() const {
if (texture.is_null())
- return Rect2(0,0,1,1);
+ return Rect2(0, 0, 1, 1);
//if (texture.is_null())
// return CanvasItem::get_item_rect();
@@ -569,72 +528,68 @@ Rect2 Sprite3D::get_item_rect() const {
if (region) {
- s=region_rect.size;
+ s = region_rect.size;
} else {
s = texture->get_size();
- s=s/Point2(hframes,vframes);
+ s = s / Point2(hframes, vframes);
}
- Point2i ofs=get_offset();
+ Point2i ofs = get_offset();
if (is_centered())
- ofs-=s/2;
+ ofs -= s / 2;
- if (s==Size2(0,0))
- s=Size2(1,1);
+ if (s == Size2(0, 0))
+ s = Size2(1, 1);
- return Rect2(ofs,s);
+ return Rect2(ofs, s);
}
+void Sprite3D::_validate_property(PropertyInfo &property) const {
-void Sprite3D::_validate_property(PropertyInfo& property) const {
-
- if (property.name=="frame") {
+ if (property.name == "frame") {
- property.hint=PROPERTY_HINT_SPRITE_FRAME;
+ property.hint = PROPERTY_HINT_SPRITE_FRAME;
- property.hint_string="0,"+itos(vframes*hframes-1)+",1";
+ property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
}
}
void Sprite3D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&Sprite3D::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&Sprite3D::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_texture", "texture:Texture"), &Sprite3D::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture"), &Sprite3D::get_texture);
- ObjectTypeDB::bind_method(_MD("set_region","enabled"),&Sprite3D::set_region);
- ObjectTypeDB::bind_method(_MD("is_region"),&Sprite3D::is_region);
+ ObjectTypeDB::bind_method(_MD("set_region", "enabled"), &Sprite3D::set_region);
+ ObjectTypeDB::bind_method(_MD("is_region"), &Sprite3D::is_region);
- ObjectTypeDB::bind_method(_MD("set_region_rect","rect"),&Sprite3D::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&Sprite3D::get_region_rect);
+ ObjectTypeDB::bind_method(_MD("set_region_rect", "rect"), &Sprite3D::set_region_rect);
+ ObjectTypeDB::bind_method(_MD("get_region_rect"), &Sprite3D::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&Sprite3D::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&Sprite3D::get_frame);
+ ObjectTypeDB::bind_method(_MD("set_frame", "frame"), &Sprite3D::set_frame);
+ ObjectTypeDB::bind_method(_MD("get_frame"), &Sprite3D::get_frame);
- ObjectTypeDB::bind_method(_MD("set_vframes","vframes"),&Sprite3D::set_vframes);
- ObjectTypeDB::bind_method(_MD("get_vframes"),&Sprite3D::get_vframes);
+ ObjectTypeDB::bind_method(_MD("set_vframes", "vframes"), &Sprite3D::set_vframes);
+ ObjectTypeDB::bind_method(_MD("get_vframes"), &Sprite3D::get_vframes);
- ObjectTypeDB::bind_method(_MD("set_hframes","hframes"),&Sprite3D::set_hframes);
- ObjectTypeDB::bind_method(_MD("get_hframes"),&Sprite3D::get_hframes);
+ ObjectTypeDB::bind_method(_MD("set_hframes", "hframes"), &Sprite3D::set_hframes);
+ ObjectTypeDB::bind_method(_MD("get_hframes"), &Sprite3D::get_hframes);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "vframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_vframes"),_SCS("get_vframes"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "hframes",PROPERTY_HINT_RANGE,"1,16384,1"), _SCS("set_hframes"),_SCS("get_hframes"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region"));
- ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), _SCS("set_vframes"), _SCS("get_vframes"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), _SCS("set_hframes"), _SCS("get_hframes"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"), _SCS("get_frame"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "region"), _SCS("set_region"), _SCS("is_region"));
+ ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), _SCS("set_region_rect"), _SCS("get_region_rect"));
ADD_SIGNAL(MethodInfo("frame_changed"));
-
}
Sprite3D::Sprite3D() {
-
- region=false;
- frame=0;
- vframes=1;
- hframes=1;
-
+ region = false;
+ frame = 0;
+ vframes = 1;
+ hframes = 1;
}
////////////////////////////////////////
@@ -850,22 +805,18 @@ AnimatedSprite3D::AnimatedSprite3D() {
frame=0;
}
-
-
#endif
-
void AnimatedSprite3D::_draw() {
RID immediate = get_immediate();
VS::get_singleton()->immediate_clear(immediate);
-
if (frames.is_null()) {
return;
}
- if (frame<0) {
+ if (frame < 0) {
return;
}
@@ -873,195 +824,185 @@ void AnimatedSprite3D::_draw() {
return;
}
-
- Ref<Texture> texture = frames->get_frame(animation,frame);
+ Ref<Texture> texture = frames->get_frame(animation, frame);
if (!texture.is_valid())
return; //no texuture no life
Vector2 tsize = texture->get_size();
- if (tsize.x==0 || tsize.y==0)
+ if (tsize.x == 0 || tsize.y == 0)
return;
- Size2i s=tsize;
+ Size2i s = tsize;
Rect2i src_rect;
- src_rect.size=s;
+ src_rect.size = s;
- Point2i ofs=get_offset();
+ Point2i ofs = get_offset();
if (is_centered())
- ofs-=s/2;
-
- Rect2i dst_rect(ofs,s);
+ ofs -= s / 2;
+ Rect2i dst_rect(ofs, s);
Rect2 final_rect;
Rect2 final_src_rect;
- if (!texture->get_rect_region(dst_rect,src_rect,final_rect,final_src_rect))
+ if (!texture->get_rect_region(dst_rect, src_rect, final_rect, final_src_rect))
return;
-
- if (final_rect.size.x==0 || final_rect.size.y==0)
+ if (final_rect.size.x == 0 || final_rect.size.y == 0)
return;
- Color color=_get_color_accum();
- color.a*=get_opacity();
+ Color color = _get_color_accum();
+ color.a *= get_opacity();
- float pixel_size=get_pixel_size();
+ float pixel_size = get_pixel_size();
- Vector2 vertices[4]={
+ Vector2 vertices[4] = {
- (final_rect.pos+Vector2(0,final_rect.size.y)) * pixel_size,
- (final_rect.pos+final_rect.size) * pixel_size,
- (final_rect.pos+Vector2(final_rect.size.x,0)) * pixel_size,
+ (final_rect.pos + Vector2(0, final_rect.size.y)) * pixel_size,
+ (final_rect.pos + final_rect.size) * pixel_size,
+ (final_rect.pos + Vector2(final_rect.size.x, 0)) * pixel_size,
final_rect.pos * pixel_size,
-
};
- Vector2 uvs[4]={
+ Vector2 uvs[4] = {
final_src_rect.pos / tsize,
- (final_src_rect.pos+Vector2(final_src_rect.size.x,0)) / tsize,
- (final_src_rect.pos+final_src_rect.size) / tsize,
- (final_src_rect.pos+Vector2(0,final_src_rect.size.y)) / tsize,
+ (final_src_rect.pos + Vector2(final_src_rect.size.x, 0)) / tsize,
+ (final_src_rect.pos + final_src_rect.size) / tsize,
+ (final_src_rect.pos + Vector2(0, final_src_rect.size.y)) / tsize,
};
if (is_flipped_h()) {
- SWAP(uvs[0],uvs[1]);
- SWAP(uvs[2],uvs[3]);
+ SWAP(uvs[0], uvs[1]);
+ SWAP(uvs[2], uvs[3]);
}
if (is_flipped_v()) {
- SWAP(uvs[0],uvs[3]);
- SWAP(uvs[1],uvs[2]);
+ SWAP(uvs[0], uvs[3]);
+ SWAP(uvs[1], uvs[2]);
}
-
Vector3 normal;
int axis = get_axis();
- normal[axis]=1.0;
+ normal[axis] = 1.0;
- RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED),get_draw_flag(FLAG_TRANSPARENT),get_alpha_cut_mode()==ALPHA_CUT_DISCARD,get_alpha_cut_mode()==ALPHA_CUT_OPAQUE_PREPASS);
- VS::get_singleton()->immediate_set_material(immediate,mat);
+ RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS);
+ VS::get_singleton()->immediate_set_material(immediate, mat);
- VS::get_singleton()->immediate_begin(immediate,VS::PRIMITIVE_TRIANGLE_FAN,texture->get_rid());
+ VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid());
int x_axis = ((axis + 1) % 3);
int y_axis = ((axis + 2) % 3);
- if (axis!=Vector3::AXIS_Z) {
- SWAP(x_axis,y_axis);
+ if (axis != Vector3::AXIS_Z) {
+ SWAP(x_axis, y_axis);
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
//uvs[i] = Vector2(1.0,1.0)-uvs[i];
//SWAP(vertices[i].x,vertices[i].y);
- if (axis==Vector3::AXIS_Y) {
- vertices[i].y = - vertices[i].y;
- } else if (axis==Vector3::AXIS_X) {
- vertices[i].x = - vertices[i].x;
+ if (axis == Vector3::AXIS_Y) {
+ vertices[i].y = -vertices[i].y;
+ } else if (axis == Vector3::AXIS_X) {
+ vertices[i].x = -vertices[i].x;
}
}
}
AABB aabb;
- for(int i=0;i<4;i++) {
- VS::get_singleton()->immediate_normal(immediate,normal);
- VS::get_singleton()->immediate_color(immediate,color);
- VS::get_singleton()->immediate_uv(immediate,uvs[i]);
+ for (int i = 0; i < 4; i++) {
+ VS::get_singleton()->immediate_normal(immediate, normal);
+ VS::get_singleton()->immediate_color(immediate, color);
+ VS::get_singleton()->immediate_uv(immediate, uvs[i]);
Vector3 vtx;
- vtx[x_axis]=vertices[i][0];
- vtx[y_axis]=vertices[i][1];
- VS::get_singleton()->immediate_vertex(immediate,vtx);
- if (i==0) {
- aabb.pos=vtx;
- aabb.size=Vector3();
+ vtx[x_axis] = vertices[i][0];
+ vtx[y_axis] = vertices[i][1];
+ VS::get_singleton()->immediate_vertex(immediate, vtx);
+ if (i == 0) {
+ aabb.pos = vtx;
+ aabb.size = Vector3();
} else {
aabb.expand_to(vtx);
}
}
set_aabb(aabb);
VS::get_singleton()->immediate_end(immediate);
-
}
-
-
-void AnimatedSprite3D::_validate_property(PropertyInfo& property) const {
+void AnimatedSprite3D::_validate_property(PropertyInfo &property) const {
if (!frames.is_valid())
return;
- if (property.name=="animation") {
+ if (property.name == "animation") {
- property.hint=PROPERTY_HINT_ENUM;
+ property.hint = PROPERTY_HINT_ENUM;
List<StringName> names;
frames->get_animation_list(&names);
names.sort_custom<StringName::AlphCompare>();
- bool current_found=false;
+ bool current_found = false;
- for (List<StringName>::Element *E=names.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
if (E->prev()) {
- property.hint_string+=",";
+ property.hint_string += ",";
}
- property.hint_string+=String(E->get());
- if (animation==E->get()) {
- current_found=true;
+ property.hint_string += String(E->get());
+ if (animation == E->get()) {
+ current_found = true;
}
}
if (!current_found) {
- if (property.hint_string==String()) {
- property.hint_string=String(animation);
+ if (property.hint_string == String()) {
+ property.hint_string = String(animation);
} else {
- property.hint_string=String(animation)+","+property.hint_string;
+ property.hint_string = String(animation) + "," + property.hint_string;
}
}
}
+ if (property.name == "frame") {
- if (property.name=="frame") {
-
- property.hint=PROPERTY_HINT_RANGE;
+ property.hint = PROPERTY_HINT_RANGE;
if (frames->has_animation(animation)) {
- property.hint_string="0,"+itos(frames->get_frame_count(animation)-1)+",1";
+ property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1";
} else {
- property.hint_string="0,0,0";
+ property.hint_string = "0,0,0";
}
}
-
}
void AnimatedSprite3D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_PROCESS: {
if (frames.is_null())
return;
if (!frames->has_animation(animation))
return;
- if (frame<0)
+ if (frame < 0)
return;
float speed = frames->get_animation_speed(animation);
- if (speed==0)
+ if (speed == 0)
return; //do nothing
float remaining = get_process_delta_time();
- while(remaining) {
+ while (remaining) {
- if (timeout<=0) {
+ if (timeout <= 0) {
- timeout=1.0/speed;
+ timeout = 1.0 / speed;
int fc = frames->get_frame_count(animation);
- if (frame>=fc-1) {
+ if (frame >= fc - 1) {
if (frames->get_animation_loop(animation)) {
- frame=0;
+ frame = 0;
} else {
- frame=fc-1;
+ frame = fc - 1;
}
} else {
frame++;
@@ -1071,9 +1012,9 @@ void AnimatedSprite3D::_notification(int p_what) {
_change_notify("frame");
}
- float to_process = MIN(timeout,remaining);
- remaining-=to_process;
- timeout-=to_process;
+ float to_process = MIN(timeout, remaining);
+ remaining -= to_process;
+ timeout -= to_process;
}
} break;
#if 0
@@ -1134,30 +1075,26 @@ void AnimatedSprite3D::_notification(int p_what) {
} break;
#endif
}
-
}
void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
if (frames.is_valid())
- frames->disconnect("changed",this,"_res_changed");
- frames=p_frames;
+ frames->disconnect("changed", this, "_res_changed");
+ frames = p_frames;
if (frames.is_valid())
- frames->connect("changed",this,"_res_changed");
+ frames->connect("changed", this, "_res_changed");
if (!frames.is_valid()) {
- frame=0;
+ frame = 0;
} else {
set_frame(frame);
}
-
-
_change_notify();
_reset_timeout();
_queue_update();
update_configuration_warning();
-
}
Ref<SpriteFrames> AnimatedSprite3D::get_sprite_frames() const {
@@ -1173,55 +1110,48 @@ void AnimatedSprite3D::set_frame(int p_frame) {
if (frames->has_animation(animation)) {
int limit = frames->get_frame_count(animation);
- if (p_frame>=limit)
- p_frame=limit-1;
-
+ if (p_frame >= limit)
+ p_frame = limit - 1;
}
- if (p_frame<0)
- p_frame=0;
+ if (p_frame < 0)
+ p_frame = 0;
-
- if (frame==p_frame)
+ if (frame == p_frame)
return;
- frame=p_frame;
+ frame = p_frame;
_reset_timeout();
_queue_update();
_change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
-
-
-
}
int AnimatedSprite3D::get_frame() const {
return frame;
}
-
-
Rect2 AnimatedSprite3D::get_item_rect() const {
- if (!frames.is_valid() || !frames->has_animation(animation) || frame<0 || frame>=frames->get_frame_count(animation)) {
- return Rect2(0,0,1,1);
+ if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) {
+ return Rect2(0, 0, 1, 1);
}
Ref<Texture> t;
if (animation)
- t = frames->get_frame(animation,frame);
+ t = frames->get_frame(animation, frame);
if (t.is_null())
- return Rect2(0,0,1,1);
+ return Rect2(0, 0, 1, 1);
Size2i s = t->get_size();
- Point2 ofs=offset;
+ Point2 ofs = offset;
if (centered)
- ofs-=s/2;
+ ofs -= s / 2;
- if (s==Size2(0,0))
- s=Size2(1,1);
+ if (s == Size2(0, 0))
+ s = Size2(1, 1);
- return Rect2(ofs,s);
+ return Rect2(ofs, s);
}
void AnimatedSprite3D::_res_changed() {
@@ -1234,9 +1164,9 @@ void AnimatedSprite3D::_res_changed() {
void AnimatedSprite3D::_set_playing(bool p_playing) {
- if (playing==p_playing)
+ if (playing == p_playing)
return;
- playing=p_playing;
+ playing = p_playing;
_reset_timeout();
set_process(playing);
}
@@ -1246,14 +1176,14 @@ bool AnimatedSprite3D::_is_playing() const {
return playing;
}
-void AnimatedSprite3D::play(const StringName& p_animation) {
+void AnimatedSprite3D::play(const StringName &p_animation) {
if (p_animation)
set_animation(p_animation);
_set_playing(true);
}
-void AnimatedSprite3D::stop(){
+void AnimatedSprite3D::stop() {
_set_playing(false);
}
@@ -1270,29 +1200,28 @@ void AnimatedSprite3D::_reset_timeout() {
if (frames.is_valid() && frames->has_animation(animation)) {
float speed = frames->get_animation_speed(animation);
- if (speed>0) {
- timeout=1.0/speed;
+ if (speed > 0) {
+ timeout = 1.0 / speed;
} else {
- timeout=0;
+ timeout = 0;
}
} else {
- timeout=0;
+ timeout = 0;
}
-
}
-void AnimatedSprite3D::set_animation(const StringName& p_animation){
+void AnimatedSprite3D::set_animation(const StringName &p_animation) {
- if (animation==p_animation)
+ if (animation == p_animation)
return;
- animation=p_animation;
+ animation = p_animation;
_reset_timeout();
set_frame(0);
_change_notify();
_queue_update();
}
-StringName AnimatedSprite3D::get_animation() const{
+StringName AnimatedSprite3D::get_animation() const {
return animation;
}
@@ -1308,44 +1237,36 @@ String AnimatedSprite3D::get_configuration_warning() const {
void AnimatedSprite3D::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_sprite_frames", "sprite_frames:SpriteFrames"), &AnimatedSprite3D::set_sprite_frames);
+ ObjectTypeDB::bind_method(_MD("get_sprite_frames:SpriteFrames"), &AnimatedSprite3D::get_sprite_frames);
- ObjectTypeDB::bind_method(_MD("set_sprite_frames","sprite_frames:SpriteFrames"),&AnimatedSprite3D::set_sprite_frames);
- ObjectTypeDB::bind_method(_MD("get_sprite_frames:SpriteFrames"),&AnimatedSprite3D::get_sprite_frames);
+ ObjectTypeDB::bind_method(_MD("set_animation", "animation"), &AnimatedSprite3D::set_animation);
+ ObjectTypeDB::bind_method(_MD("get_animation"), &AnimatedSprite3D::get_animation);
- ObjectTypeDB::bind_method(_MD("set_animation","animation"),&AnimatedSprite3D::set_animation);
- ObjectTypeDB::bind_method(_MD("get_animation"),&AnimatedSprite3D::get_animation);
+ ObjectTypeDB::bind_method(_MD("_set_playing", "playing"), &AnimatedSprite3D::_set_playing);
+ ObjectTypeDB::bind_method(_MD("_is_playing"), &AnimatedSprite3D::_is_playing);
- ObjectTypeDB::bind_method(_MD("_set_playing","playing"),&AnimatedSprite3D::_set_playing);
- ObjectTypeDB::bind_method(_MD("_is_playing"),&AnimatedSprite3D::_is_playing);
+ ObjectTypeDB::bind_method(_MD("play", "anim"), &AnimatedSprite3D::play, DEFVAL(StringName()));
+ ObjectTypeDB::bind_method(_MD("stop"), &AnimatedSprite3D::stop);
+ ObjectTypeDB::bind_method(_MD("is_playing"), &AnimatedSprite3D::is_playing);
- ObjectTypeDB::bind_method(_MD("play","anim"),&AnimatedSprite3D::play,DEFVAL(StringName()));
- ObjectTypeDB::bind_method(_MD("stop"),&AnimatedSprite3D::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&AnimatedSprite3D::is_playing);
+ ObjectTypeDB::bind_method(_MD("set_frame", "frame"), &AnimatedSprite3D::set_frame);
+ ObjectTypeDB::bind_method(_MD("get_frame"), &AnimatedSprite3D::get_frame);
-
- ObjectTypeDB::bind_method(_MD("set_frame","frame"),&AnimatedSprite3D::set_frame);
- ObjectTypeDB::bind_method(_MD("get_frame"),&AnimatedSprite3D::get_frame);
-
- ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite3D::_res_changed);
+ ObjectTypeDB::bind_method(_MD("_res_changed"), &AnimatedSprite3D::_res_changed);
ADD_SIGNAL(MethodInfo("frame_changed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
- ADD_PROPERTY( PropertyInfo( Variant::STRING, "animation"), _SCS("set_animation"),_SCS("get_animation"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"),_SCS("get_frame"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "playing"), _SCS("_set_playing"),_SCS("_is_playing"));
-
-
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), _SCS("set_sprite_frames"), _SCS("get_sprite_frames"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), _SCS("set_animation"), _SCS("get_animation"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "frame", PROPERTY_HINT_SPRITE_FRAME), _SCS("set_frame"), _SCS("get_frame"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "playing"), _SCS("_set_playing"), _SCS("_is_playing"));
}
AnimatedSprite3D::AnimatedSprite3D() {
- frame=0;
- playing=false;
- animation="default";
- timeout=0;
-
-
+ frame = 0;
+ playing = false;
+ animation = "default";
+ timeout = 0;
}
-
-
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index 15f35ebe5..8574f5436 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -29,15 +29,14 @@
#ifndef SPRITE_3D_H
#define SPRITE_3D_H
-#include "scene/3d/visual_instance.h"
#include "scene/2d/animated_sprite.h"
-
+#include "scene/3d/visual_instance.h"
class SpriteBase3D : public GeometryInstance {
- OBJ_TYPE(SpriteBase3D,GeometryInstance);
-public:
+ OBJ_TYPE(SpriteBase3D, GeometryInstance);
+public:
enum DrawFlags {
FLAG_TRANSPARENT,
FLAG_SHADED,
@@ -52,14 +51,12 @@ public:
};
private:
-
-
bool color_dirty;
Color color_accum;
SpriteBase3D *parent_sprite;
- List<SpriteBase3D*> children;
- List<SpriteBase3D*>::Element *pI;
+ List<SpriteBase3D *> children;
+ List<SpriteBase3D *>::Element *pI;
bool centered;
Point2 offset;
@@ -67,7 +64,6 @@ private:
bool hflip;
bool vflip;
-
Color modulate;
float opacity;
@@ -82,24 +78,22 @@ private:
bool pending_update;
void _im_update();
-
void _propagate_color_changed();
protected:
-
Color _get_color_accum();
void _notification(int p_what);
static void _bind_methods();
- virtual void _draw()=0;
- _FORCE_INLINE_ void set_aabb(const AABB& p_aabb) { aabb=p_aabb; }
- _FORCE_INLINE_ RID& get_immediate() { return immediate; }
+ virtual void _draw() = 0;
+ _FORCE_INLINE_ void set_aabb(const AABB &p_aabb) { aabb = p_aabb; }
+ _FORCE_INLINE_ RID &get_immediate() { return immediate; }
void _queue_update();
-public:
+public:
void set_centered(bool p_center);
bool is_centered() const;
- void set_offset(const Point2& p_offset);
+ void set_offset(const Point2 &p_offset);
Point2 get_offset() const;
void set_flip_h(bool p_flip);
@@ -111,10 +105,10 @@ public:
void set_region(bool p_region);
bool is_region() const;
- void set_region_rect(const Rect2& p_region_rect);
+ void set_region_rect(const Rect2 &p_region_rect);
Rect2 get_region_rect() const;
- void set_modulate(const Color& p_color);
+ void set_modulate(const Color &p_color);
Color get_modulate() const;
void set_opacity(float p_amount);
@@ -126,13 +120,13 @@ public:
void set_axis(Vector3::Axis p_amount);
Vector3::Axis get_axis() const;
- void set_draw_flag(DrawFlags p_flag,bool p_enable);
+ void set_draw_flag(DrawFlags p_flag, bool p_enable);
bool get_draw_flag(DrawFlags p_flag) const;
void set_alpha_cut_mode(AlphaCutMode p_mode);
AlphaCutMode get_alpha_cut_mode() const;
- virtual Rect2 get_item_rect() const=0;
+ virtual Rect2 get_item_rect() const = 0;
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
@@ -141,13 +135,11 @@ public:
~SpriteBase3D();
};
-
class Sprite3D : public SpriteBase3D {
- OBJ_TYPE(Sprite3D,SpriteBase3D);
+ OBJ_TYPE(Sprite3D, SpriteBase3D);
Ref<Texture> texture;
-
bool region;
Rect2 region_rect;
@@ -155,22 +147,21 @@ class Sprite3D : public SpriteBase3D {
int vframes;
int hframes;
+
protected:
virtual void _draw();
static void _bind_methods();
- virtual void _validate_property(PropertyInfo& property) const;
-public:
-
+ virtual void _validate_property(PropertyInfo &property) const;
-
- void set_texture(const Ref<Texture>& p_texture);
+public:
+ void set_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_texture() const;
void set_region(bool p_region);
bool is_region() const;
- void set_region_rect(const Rect2& p_region_rect);
+ void set_region_rect(const Rect2 &p_region_rect);
Rect2 get_region_rect() const;
void set_frame(int p_frame);
@@ -185,7 +176,7 @@ public:
virtual Rect2 get_item_rect() const;
Sprite3D();
-// ~Sprite3D();
+ // ~Sprite3D();
};
#if 0
@@ -219,12 +210,9 @@ public:
};
#endif
-
-
-
class AnimatedSprite3D : public SpriteBase3D {
- OBJ_TYPE(AnimatedSprite3D,SpriteBase3D);
+ OBJ_TYPE(AnimatedSprite3D, SpriteBase3D);
Ref<SpriteFrames> frames;
bool playing;
@@ -247,39 +235,32 @@ class AnimatedSprite3D : public SpriteBase3D {
void _set_playing(bool p_playing);
bool _is_playing() const;
-
protected:
-
virtual void _draw();
static void _bind_methods();
void _notification(int p_what);
- virtual void _validate_property(PropertyInfo& property) const;
+ virtual void _validate_property(PropertyInfo &property) const;
public:
-
-
-
void set_sprite_frames(const Ref<SpriteFrames> &p_frames);
Ref<SpriteFrames> get_sprite_frames() const;
- void play(const StringName& p_animation=StringName());
+ void play(const StringName &p_animation = StringName());
void stop();
bool is_playing() const;
- void set_animation(const StringName& p_animation);
+ void set_animation(const StringName &p_animation);
StringName get_animation() const;
void set_frame(int p_frame);
int get_frame() const;
-
virtual Rect2 get_item_rect() const;
virtual String get_configuration_warning() const;
AnimatedSprite3D();
};
-
VARIANT_ENUM_CAST(SpriteBase3D::DrawFlags);
VARIANT_ENUM_CAST(SpriteBase3D::AlphaCutMode);
#endif // SPRITE_3D_H
diff --git a/scene/3d/test_cube.cpp b/scene/3d/test_cube.cpp
index bd99de417..4d8942b17 100644
--- a/scene/3d/test_cube.cpp
+++ b/scene/3d/test_cube.cpp
@@ -29,25 +29,19 @@
#include "test_cube.h"
#include "servers/visual_server.h"
-
-
AABB TestCube::get_aabb() const {
- return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
+ return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
}
DVector<Face3> TestCube::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
}
-
TestCube::TestCube() {
set_base(VisualServer::get_singleton()->get_test_cube());
}
-
TestCube::~TestCube() {
}
-
-
diff --git a/scene/3d/test_cube.h b/scene/3d/test_cube.h
index 177882dc4..e90509a19 100644
--- a/scene/3d/test_cube.h
+++ b/scene/3d/test_cube.h
@@ -29,29 +29,24 @@
#ifndef TEST_CUBE_H
#define TEST_CUBE_H
-
-#include "scene/3d/visual_instance.h"
#include "rid.h"
-
+#include "scene/3d/visual_instance.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class TestCube : public GeometryInstance {
- OBJ_TYPE( TestCube, GeometryInstance );
+ OBJ_TYPE(TestCube, GeometryInstance);
RID instance;
-
public:
-
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
TestCube();
~TestCube();
-
};
#endif
diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp
index f66ad03f6..6cc9e9d92 100644
--- a/scene/3d/vehicle_body.cpp
+++ b/scene/3d/vehicle_body.cpp
@@ -30,78 +30,70 @@
#define ROLLING_INFLUENCE_FIX
-class btVehicleJacobianEntry
-{
+class btVehicleJacobianEntry {
public:
-
- Vector3 m_linearJointAxis;
- Vector3 m_aJ;
- Vector3 m_bJ;
- Vector3 m_0MinvJt;
- Vector3 m_1MinvJt;
+ Vector3 m_linearJointAxis;
+ Vector3 m_aJ;
+ Vector3 m_bJ;
+ Vector3 m_0MinvJt;
+ Vector3 m_1MinvJt;
//Optimization: can be stored in the w/last component of one of the vectors
- real_t m_Adiag;
+ real_t m_Adiag;
real_t getDiagonal() const { return m_Adiag; }
- btVehicleJacobianEntry() {};
- //constraint between two different rigidbodies
- btVehicleJacobianEntry(
- const Matrix3& world2A,
- const Matrix3& world2B,
- const Vector3& rel_pos1,
- const Vector3& rel_pos2,
- const Vector3& jointAxis,
- const Vector3& inertiaInvA,
+ btVehicleJacobianEntry(){};
+ //constraint between two different rigidbodies
+ btVehicleJacobianEntry(
+ const Matrix3 &world2A,
+ const Matrix3 &world2B,
+ const Vector3 &rel_pos1,
+ const Vector3 &rel_pos2,
+ const Vector3 &jointAxis,
+ const Vector3 &inertiaInvA,
const real_t massInvA,
- const Vector3& inertiaInvB,
+ const Vector3 &inertiaInvB,
const real_t massInvB)
- :m_linearJointAxis(jointAxis)
- {
- m_aJ = world2A.xform(rel_pos1.cross(m_linearJointAxis));
- m_bJ = world2B.xform(rel_pos2.cross(-m_linearJointAxis));
- m_0MinvJt = inertiaInvA * m_aJ;
- m_1MinvJt = inertiaInvB * m_bJ;
- m_Adiag = massInvA + m_0MinvJt.dot(m_aJ) + massInvB + m_1MinvJt.dot(m_bJ);
-
- //btAssert(m_Adiag > real_t(0.0));
- }
-
- real_t getRelativeVelocity(const Vector3& linvelA,const Vector3& angvelA,const Vector3& linvelB,const Vector3& angvelB)
- {
- Vector3 linrel = linvelA - linvelB;
- Vector3 angvela = angvelA * m_aJ;
- Vector3 angvelb = angvelB * m_bJ;
- linrel *= m_linearJointAxis;
- angvela += angvelb;
- angvela += linrel;
- real_t rel_vel2 = angvela[0]+angvela[1]+angvela[2];
- return rel_vel2 + CMP_EPSILON;
- }
+ : m_linearJointAxis(jointAxis) {
+ m_aJ = world2A.xform(rel_pos1.cross(m_linearJointAxis));
+ m_bJ = world2B.xform(rel_pos2.cross(-m_linearJointAxis));
+ m_0MinvJt = inertiaInvA * m_aJ;
+ m_1MinvJt = inertiaInvB * m_bJ;
+ m_Adiag = massInvA + m_0MinvJt.dot(m_aJ) + massInvB + m_1MinvJt.dot(m_bJ);
+ //btAssert(m_Adiag > real_t(0.0));
+ }
+ real_t getRelativeVelocity(const Vector3 &linvelA, const Vector3 &angvelA, const Vector3 &linvelB, const Vector3 &angvelB) {
+ Vector3 linrel = linvelA - linvelB;
+ Vector3 angvela = angvelA * m_aJ;
+ Vector3 angvelb = angvelB * m_bJ;
+ linrel *= m_linearJointAxis;
+ angvela += angvelb;
+ angvela += linrel;
+ real_t rel_vel2 = angvela[0] + angvela[1] + angvela[2];
+ return rel_vel2 + CMP_EPSILON;
+ }
};
void VehicleWheel::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
if (!get_parent())
return;
VehicleBody *cb = get_parent()->cast_to<VehicleBody>();
if (!cb)
return;
- body=cb;
- local_xform=get_transform();
+ body = cb;
+ local_xform = get_transform();
cb->wheels.push_back(this);
m_chassisConnectionPointCS = get_transform().origin;
m_wheelDirectionCS = -get_transform().basis.get_axis(Vector3::AXIS_Y).normalized();
m_wheelAxleCS = get_transform().basis.get_axis(Vector3::AXIS_X).normalized();
-
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
if (!get_parent())
return;
@@ -109,34 +101,27 @@ void VehicleWheel::_notification(int p_what) {
if (!cb)
return;
cb->wheels.erase(this);
- body=NULL;
+ body = NULL;
}
-
}
-
void VehicleWheel::_update(PhysicsDirectBodyState *s) {
-
-
if (m_raycastInfo.m_isInContact)
{
- real_t project= m_raycastInfo.m_contactNormalWS.dot( m_raycastInfo.m_wheelDirectionWS );
- Vector3 chassis_velocity_at_contactPoint;
+ real_t project = m_raycastInfo.m_contactNormalWS.dot(m_raycastInfo.m_wheelDirectionWS);
+ Vector3 chassis_velocity_at_contactPoint;
Vector3 relpos = m_raycastInfo.m_contactPointWS - s->get_transform().origin;
chassis_velocity_at_contactPoint = s->get_linear_velocity() +
- (s->get_angular_velocity()).cross(relpos);// * mPos);
+ (s->get_angular_velocity()).cross(relpos); // * mPos);
- real_t projVel = m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint );
- if ( project >= real_t(-0.1))
- {
+ real_t projVel = m_raycastInfo.m_contactNormalWS.dot(chassis_velocity_at_contactPoint);
+ if (project >= real_t(-0.1)) {
m_suspensionRelativeVelocity = real_t(0.0);
m_clippedInvContactDotSuspension = real_t(1.0) / real_t(0.1);
- }
- else
- {
+ } else {
real_t inv = real_t(-1.) / project;
m_suspensionRelativeVelocity = projVel * inv;
m_clippedInvContactDotSuspension = inv;
@@ -144,7 +129,7 @@ void VehicleWheel::_update(PhysicsDirectBodyState *s) {
}
- else // Not in contact : position wheel in a nice (rest length) position
+ else // Not in contact : position wheel in a nice (rest length) position
{
m_raycastInfo.m_suspensionLength = m_suspensionRestLength;
m_suspensionRelativeVelocity = real_t(0.0);
@@ -155,156 +140,147 @@ void VehicleWheel::_update(PhysicsDirectBodyState *s) {
void VehicleWheel::set_radius(float p_radius) {
- m_wheelRadius=p_radius;
+ m_wheelRadius = p_radius;
update_gizmo();
}
-float VehicleWheel::get_radius() const{
+float VehicleWheel::get_radius() const {
return m_wheelRadius;
}
-void VehicleWheel::set_suspension_rest_length(float p_length){
+void VehicleWheel::set_suspension_rest_length(float p_length) {
- m_suspensionRestLength=p_length;
+ m_suspensionRestLength = p_length;
update_gizmo();
}
-float VehicleWheel::get_suspension_rest_length() const{
+float VehicleWheel::get_suspension_rest_length() const {
return m_suspensionRestLength;
}
-void VehicleWheel::set_suspension_travel(float p_length){
+void VehicleWheel::set_suspension_travel(float p_length) {
- m_maxSuspensionTravelCm=p_length/0.01;
+ m_maxSuspensionTravelCm = p_length / 0.01;
}
-float VehicleWheel::get_suspension_travel() const{
+float VehicleWheel::get_suspension_travel() const {
- return m_maxSuspensionTravelCm*0.01;
+ return m_maxSuspensionTravelCm * 0.01;
}
-void VehicleWheel::set_suspension_stiffness(float p_value){
+void VehicleWheel::set_suspension_stiffness(float p_value) {
- m_suspensionStiffness=p_value;
+ m_suspensionStiffness = p_value;
}
-float VehicleWheel::get_suspension_stiffness() const{
+float VehicleWheel::get_suspension_stiffness() const {
return m_suspensionStiffness;
}
-void VehicleWheel::set_suspension_max_force(float p_value){
+void VehicleWheel::set_suspension_max_force(float p_value) {
- m_maxSuspensionForce=p_value;
+ m_maxSuspensionForce = p_value;
}
-float VehicleWheel::get_suspension_max_force() const{
+float VehicleWheel::get_suspension_max_force() const {
return m_maxSuspensionForce;
}
-void VehicleWheel::set_damping_compression(float p_value){
+void VehicleWheel::set_damping_compression(float p_value) {
- m_wheelsDampingCompression=p_value;
+ m_wheelsDampingCompression = p_value;
}
-float VehicleWheel::get_damping_compression() const{
+float VehicleWheel::get_damping_compression() const {
return m_wheelsDampingCompression;
}
-void VehicleWheel::set_damping_relaxation(float p_value){
+void VehicleWheel::set_damping_relaxation(float p_value) {
- m_wheelsDampingRelaxation=p_value;
+ m_wheelsDampingRelaxation = p_value;
}
-float VehicleWheel::get_damping_relaxation() const{
+float VehicleWheel::get_damping_relaxation() const {
return m_wheelsDampingRelaxation;
}
void VehicleWheel::set_friction_slip(float p_value) {
- m_frictionSlip=p_value;
+ m_frictionSlip = p_value;
}
-float VehicleWheel::get_friction_slip() const{
+float VehicleWheel::get_friction_slip() const {
return m_frictionSlip;
}
-
void VehicleWheel::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_radius", "length"), &VehicleWheel::set_radius);
+ ObjectTypeDB::bind_method(_MD("get_radius"), &VehicleWheel::get_radius);
- ObjectTypeDB::bind_method(_MD("set_radius","length"),&VehicleWheel::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&VehicleWheel::get_radius);
-
- ObjectTypeDB::bind_method(_MD("set_suspension_rest_length","length"),&VehicleWheel::set_suspension_rest_length);
- ObjectTypeDB::bind_method(_MD("get_suspension_rest_length"),&VehicleWheel::get_suspension_rest_length);
-
- ObjectTypeDB::bind_method(_MD("set_suspension_travel","length"),&VehicleWheel::set_suspension_travel);
- ObjectTypeDB::bind_method(_MD("get_suspension_travel"),&VehicleWheel::get_suspension_travel);
-
- ObjectTypeDB::bind_method(_MD("set_suspension_stiffness","length"),&VehicleWheel::set_suspension_stiffness);
- ObjectTypeDB::bind_method(_MD("get_suspension_stiffness"),&VehicleWheel::get_suspension_stiffness);
+ ObjectTypeDB::bind_method(_MD("set_suspension_rest_length", "length"), &VehicleWheel::set_suspension_rest_length);
+ ObjectTypeDB::bind_method(_MD("get_suspension_rest_length"), &VehicleWheel::get_suspension_rest_length);
- ObjectTypeDB::bind_method(_MD("set_suspension_max_force","length"),&VehicleWheel::set_suspension_max_force);
- ObjectTypeDB::bind_method(_MD("get_suspension_max_force"),&VehicleWheel::get_suspension_max_force);
+ ObjectTypeDB::bind_method(_MD("set_suspension_travel", "length"), &VehicleWheel::set_suspension_travel);
+ ObjectTypeDB::bind_method(_MD("get_suspension_travel"), &VehicleWheel::get_suspension_travel);
+ ObjectTypeDB::bind_method(_MD("set_suspension_stiffness", "length"), &VehicleWheel::set_suspension_stiffness);
+ ObjectTypeDB::bind_method(_MD("get_suspension_stiffness"), &VehicleWheel::get_suspension_stiffness);
- ObjectTypeDB::bind_method(_MD("set_damping_compression","length"),&VehicleWheel::set_damping_compression);
- ObjectTypeDB::bind_method(_MD("get_damping_compression"),&VehicleWheel::get_damping_compression);
+ ObjectTypeDB::bind_method(_MD("set_suspension_max_force", "length"), &VehicleWheel::set_suspension_max_force);
+ ObjectTypeDB::bind_method(_MD("get_suspension_max_force"), &VehicleWheel::get_suspension_max_force);
- ObjectTypeDB::bind_method(_MD("set_damping_relaxation","length"),&VehicleWheel::set_damping_relaxation);
- ObjectTypeDB::bind_method(_MD("get_damping_relaxation"),&VehicleWheel::get_damping_relaxation);
+ ObjectTypeDB::bind_method(_MD("set_damping_compression", "length"), &VehicleWheel::set_damping_compression);
+ ObjectTypeDB::bind_method(_MD("get_damping_compression"), &VehicleWheel::get_damping_compression);
- ObjectTypeDB::bind_method(_MD("set_use_as_traction","enable"),&VehicleWheel::set_use_as_traction);
- ObjectTypeDB::bind_method(_MD("is_used_as_traction"),&VehicleWheel::is_used_as_traction);
+ ObjectTypeDB::bind_method(_MD("set_damping_relaxation", "length"), &VehicleWheel::set_damping_relaxation);
+ ObjectTypeDB::bind_method(_MD("get_damping_relaxation"), &VehicleWheel::get_damping_relaxation);
- ObjectTypeDB::bind_method(_MD("set_use_as_steering","enable"),&VehicleWheel::set_use_as_steering);
- ObjectTypeDB::bind_method(_MD("is_used_as_steering"),&VehicleWheel::is_used_as_steering);
+ ObjectTypeDB::bind_method(_MD("set_use_as_traction", "enable"), &VehicleWheel::set_use_as_traction);
+ ObjectTypeDB::bind_method(_MD("is_used_as_traction"), &VehicleWheel::is_used_as_traction);
- ObjectTypeDB::bind_method(_MD("set_friction_slip","length"),&VehicleWheel::set_friction_slip);
- ObjectTypeDB::bind_method(_MD("get_friction_slip"),&VehicleWheel::get_friction_slip);
+ ObjectTypeDB::bind_method(_MD("set_use_as_steering", "enable"), &VehicleWheel::set_use_as_steering);
+ ObjectTypeDB::bind_method(_MD("is_used_as_steering"), &VehicleWheel::is_used_as_steering);
+ ObjectTypeDB::bind_method(_MD("set_friction_slip", "length"), &VehicleWheel::set_friction_slip);
+ ObjectTypeDB::bind_method(_MD("get_friction_slip"), &VehicleWheel::get_friction_slip);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"type/traction"),_SCS("set_use_as_traction"),_SCS("is_used_as_traction"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"type/steering"),_SCS("set_use_as_steering"),_SCS("is_used_as_steering"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel/radius"),_SCS("set_radius"),_SCS("get_radius"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel/rest_length"),_SCS("set_suspension_rest_length"),_SCS("get_suspension_rest_length"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"wheel/friction_slip"),_SCS("set_friction_slip"),_SCS("get_friction_slip"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension/travel"),_SCS("set_suspension_travel"),_SCS("get_suspension_travel"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension/stiffness"),_SCS("set_suspension_stiffness"),_SCS("get_suspension_stiffness"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"suspension/max_force"),_SCS("set_suspension_max_force"),_SCS("get_suspension_max_force"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping/compression"),_SCS("set_damping_compression"),_SCS("get_damping_compression"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL,"damping/relaxation"),_SCS("set_damping_relaxation"),_SCS("get_damping_relaxation"));
-
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "type/traction"), _SCS("set_use_as_traction"), _SCS("is_used_as_traction"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "type/steering"), _SCS("set_use_as_steering"), _SCS("is_used_as_steering"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "wheel/radius"), _SCS("set_radius"), _SCS("get_radius"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "wheel/rest_length"), _SCS("set_suspension_rest_length"), _SCS("get_suspension_rest_length"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "wheel/friction_slip"), _SCS("set_friction_slip"), _SCS("get_friction_slip"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "suspension/travel"), _SCS("set_suspension_travel"), _SCS("get_suspension_travel"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "suspension/stiffness"), _SCS("set_suspension_stiffness"), _SCS("get_suspension_stiffness"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "suspension/max_force"), _SCS("set_suspension_max_force"), _SCS("get_suspension_max_force"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "damping/compression"), _SCS("set_damping_compression"), _SCS("get_damping_compression"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "damping/relaxation"), _SCS("set_damping_relaxation"), _SCS("get_damping_relaxation"));
}
-
void VehicleWheel::set_use_as_traction(bool p_enable) {
- engine_traction=p_enable;
+ engine_traction = p_enable;
}
-bool VehicleWheel::is_used_as_traction() const{
+bool VehicleWheel::is_used_as_traction() const {
return engine_traction;
}
+void VehicleWheel::set_use_as_steering(bool p_enabled) {
-void VehicleWheel::set_use_as_steering(bool p_enabled){
-
- steers=p_enabled;
+ steers = p_enabled;
}
-bool VehicleWheel::is_used_as_steering() const{
+bool VehicleWheel::is_used_as_steering() const {
return steers;
}
-
VehicleWheel::VehicleWheel() {
-
- steers=false;
- engine_traction=false;
+ steers = false;
+ engine_traction = false;
m_steering = real_t(0.);
//m_engineForce = real_t(0.);
@@ -314,7 +290,7 @@ VehicleWheel::VehicleWheel() {
m_rollInfluence = real_t(0.1);
m_suspensionRestLength = 0.15;
- m_wheelRadius = 0.5;//0.28;
+ m_wheelRadius = 0.5; //0.28;
m_suspensionStiffness = 5.88;
m_wheelsDampingCompression = 0.83;
m_wheelsDampingRelaxation = 0.88;
@@ -323,15 +299,14 @@ VehicleWheel::VehicleWheel() {
m_maxSuspensionTravelCm = 500;
m_maxSuspensionForce = 6000;
- m_suspensionRelativeVelocity=0;
- m_clippedInvContactDotSuspension=1.0;
- m_raycastInfo.m_isInContact=false;
+ m_suspensionRelativeVelocity = 0;
+ m_clippedInvContactDotSuspension = 1.0;
+ m_raycastInfo.m_isInContact = false;
- body=NULL;
+ body = NULL;
}
-
-void VehicleBody::_update_wheel_transform(VehicleWheel& wheel ,PhysicsDirectBodyState *s) {
+void VehicleBody::_update_wheel_transform(VehicleWheel &wheel, PhysicsDirectBodyState *s) {
wheel.m_raycastInfo.m_isInContact = false;
@@ -341,112 +316,99 @@ void VehicleBody::_update_wheel_transform(VehicleWheel& wheel ,PhysicsDirectBody
// getRigidBody()->getMotionState()->getWorldTransform(chassisTrans);
//}
- wheel.m_raycastInfo.m_hardPointWS = chassisTrans.xform( wheel.m_chassisConnectionPointCS );
+ wheel.m_raycastInfo.m_hardPointWS = chassisTrans.xform(wheel.m_chassisConnectionPointCS);
//wheel.m_raycastInfo.m_hardPointWS+=s->get_linear_velocity()*s->get_step();
- wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.get_basis().xform( wheel.m_wheelDirectionCS).normalized();
- wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.get_basis().xform( wheel.m_wheelAxleCS ).normalized();
+ wheel.m_raycastInfo.m_wheelDirectionWS = chassisTrans.get_basis().xform(wheel.m_wheelDirectionCS).normalized();
+ wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.get_basis().xform(wheel.m_wheelAxleCS).normalized();
}
-void VehicleBody::_update_wheel(int p_idx,PhysicsDirectBodyState *s) {
+void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) {
- VehicleWheel& wheel = *wheels[p_idx];
- _update_wheel_transform(wheel,s);
+ VehicleWheel &wheel = *wheels[p_idx];
+ _update_wheel_transform(wheel, s);
Vector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS;
- const Vector3& right = wheel.m_raycastInfo.m_wheelAxleWS;
+ const Vector3 &right = wheel.m_raycastInfo.m_wheelAxleWS;
Vector3 fwd = up.cross(right);
fwd = fwd.normalized();
-// up = right.cross(fwd);
-// up.normalize();
+ // up = right.cross(fwd);
+ // up.normalize();
//rotate around steering over de wheelAxleWS
- real_t steering = wheel.steers?m_steeringValue:0.0;
+ real_t steering = wheel.steers ? m_steeringValue : 0.0;
//print_line(itos(p_idx)+": "+rtos(steering));
- Matrix3 steeringMat(up,steering);
+ Matrix3 steeringMat(up, steering);
- Matrix3 rotatingMat(right,-wheel.m_rotation);
+ Matrix3 rotatingMat(right, -wheel.m_rotation);
-// if (p_idx==1)
-// print_line("steeringMat " +steeringMat);
+ // if (p_idx==1)
+ // print_line("steeringMat " +steeringMat);
Matrix3 basis2(
- right[0],up[0],fwd[0],
- right[1],up[1],fwd[1],
- right[2],up[2],fwd[2]
- );
+ right[0], up[0], fwd[0],
+ right[1], up[1], fwd[1],
+ right[2], up[2], fwd[2]);
wheel.m_worldTransform.set_basis(steeringMat * rotatingMat * basis2);
//wheel.m_worldTransform.set_basis(basis2 * (steeringMat * rotatingMat));
wheel.m_worldTransform.set_origin(
- wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength
- );
-
+ wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength);
}
+real_t VehicleBody::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
-real_t VehicleBody::_ray_cast(int p_idx,PhysicsDirectBodyState *s) {
-
-
- VehicleWheel& wheel = *wheels[p_idx];
-
- _update_wheel_transform(wheel,s);
+ VehicleWheel &wheel = *wheels[p_idx];
+ _update_wheel_transform(wheel, s);
real_t depth = -1;
- real_t raylen = wheel.m_suspensionRestLength+wheel.m_wheelRadius;
+ real_t raylen = wheel.m_suspensionRestLength + wheel.m_wheelRadius;
Vector3 rayvector = wheel.m_raycastInfo.m_wheelDirectionWS * (raylen);
Vector3 source = wheel.m_raycastInfo.m_hardPointWS;
wheel.m_raycastInfo.m_contactPointWS = source + rayvector;
- const Vector3& target = wheel.m_raycastInfo.m_contactPointWS;
- source-=wheel.m_wheelRadius * wheel.m_raycastInfo.m_wheelDirectionWS;
+ const Vector3 &target = wheel.m_raycastInfo.m_contactPointWS;
+ source -= wheel.m_wheelRadius * wheel.m_raycastInfo.m_wheelDirectionWS;
real_t param = real_t(0.);
-
PhysicsDirectSpaceState::RayResult rr;
+ PhysicsDirectSpaceState *ss = s->get_space_state();
- PhysicsDirectSpaceState *ss=s->get_space_state();
-
- bool col = ss->intersect_ray(source,target,rr,exclude);
-
+ bool col = ss->intersect_ray(source, target, rr, exclude);
wheel.m_raycastInfo.m_groundObject = 0;
- if (col)
- {
+ if (col) {
//print_line("WHEEL "+itos(p_idx)+" FROM "+source+" TO: "+target);
//print_line("WHEEL "+itos(p_idx)+" COLLIDE? "+itos(col));
- param = source.distance_to(rr.position)/source.distance_to(target);
+ param = source.distance_to(rr.position) / source.distance_to(target);
depth = raylen * param;
- wheel.m_raycastInfo.m_contactNormalWS = rr.normal;
+ wheel.m_raycastInfo.m_contactNormalWS = rr.normal;
wheel.m_raycastInfo.m_isInContact = true;
if (rr.collider)
- wheel.m_raycastInfo.m_groundObject=rr.collider->cast_to<PhysicsBody>();
-
+ wheel.m_raycastInfo.m_groundObject = rr.collider->cast_to<PhysicsBody>();
- real_t hitDistance = param*raylen;
+ real_t hitDistance = param * raylen;
wheel.m_raycastInfo.m_suspensionLength = hitDistance - wheel.m_wheelRadius;
//clamp on max suspension travel
- real_t minSuspensionLength = wheel.m_suspensionRestLength - wheel.m_maxSuspensionTravelCm*real_t(0.01);
- real_t maxSuspensionLength = wheel.m_suspensionRestLength+ wheel.m_maxSuspensionTravelCm*real_t(0.01);
- if (wheel.m_raycastInfo.m_suspensionLength < minSuspensionLength)
- {
+ real_t minSuspensionLength = wheel.m_suspensionRestLength - wheel.m_maxSuspensionTravelCm * real_t(0.01);
+ real_t maxSuspensionLength = wheel.m_suspensionRestLength + wheel.m_maxSuspensionTravelCm * real_t(0.01);
+ if (wheel.m_raycastInfo.m_suspensionLength < minSuspensionLength) {
wheel.m_raycastInfo.m_suspensionLength = minSuspensionLength;
}
- if (wheel.m_raycastInfo.m_suspensionLength > maxSuspensionLength)
- {
+ if (wheel.m_raycastInfo.m_suspensionLength > maxSuspensionLength) {
wheel.m_raycastInfo.m_suspensionLength = maxSuspensionLength;
}
wheel.m_raycastInfo.m_contactPointWS = rr.position;
- real_t denominator= wheel.m_raycastInfo.m_contactNormalWS.dot( wheel.m_raycastInfo.m_wheelDirectionWS );
+ real_t denominator = wheel.m_raycastInfo.m_contactNormalWS.dot(wheel.m_raycastInfo.m_wheelDirectionWS);
Vector3 chassis_velocity_at_contactPoint;
//Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS-getRigidBody()->getCenterOfMassPosition();
@@ -454,72 +416,58 @@ real_t VehicleBody::_ray_cast(int p_idx,PhysicsDirectBodyState *s) {
//chassis_velocity_at_contactPoint = getRigidBody()->getVelocityInLocalPoint(relpos);
chassis_velocity_at_contactPoint = s->get_linear_velocity() +
- (s->get_angular_velocity()).cross(wheel.m_raycastInfo.m_contactPointWS-s->get_transform().origin);// * mPos);
-
+ (s->get_angular_velocity()).cross(wheel.m_raycastInfo.m_contactPointWS - s->get_transform().origin); // * mPos);
- real_t projVel = wheel.m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint );
+ real_t projVel = wheel.m_raycastInfo.m_contactNormalWS.dot(chassis_velocity_at_contactPoint);
- if ( denominator >= real_t(-0.1))
- {
+ if (denominator >= real_t(-0.1)) {
wheel.m_suspensionRelativeVelocity = real_t(0.0);
wheel.m_clippedInvContactDotSuspension = real_t(1.0) / real_t(0.1);
- }
- else
- {
+ } else {
real_t inv = real_t(-1.) / denominator;
wheel.m_suspensionRelativeVelocity = projVel * inv;
wheel.m_clippedInvContactDotSuspension = inv;
}
- } else
- {
+ } else {
wheel.m_raycastInfo.m_isInContact = false;
//put wheel info as in rest position
wheel.m_raycastInfo.m_suspensionLength = wheel.m_suspensionRestLength;
wheel.m_suspensionRelativeVelocity = real_t(0.0);
- wheel.m_raycastInfo.m_contactNormalWS = - wheel.m_raycastInfo.m_wheelDirectionWS;
+ wheel.m_raycastInfo.m_contactNormalWS = -wheel.m_raycastInfo.m_wheelDirectionWS;
wheel.m_clippedInvContactDotSuspension = real_t(1.0);
}
return depth;
}
-
-void VehicleBody::_update_suspension(PhysicsDirectBodyState *s)
-{
+void VehicleBody::_update_suspension(PhysicsDirectBodyState *s) {
real_t chassisMass = mass;
- for (int w_it=0; w_it<wheels.size(); w_it++)
- {
- VehicleWheel& wheel_info = *wheels[w_it];
-
+ for (int w_it = 0; w_it < wheels.size(); w_it++) {
+ VehicleWheel &wheel_info = *wheels[w_it];
- if ( wheel_info.m_raycastInfo.m_isInContact )
- {
+ if (wheel_info.m_raycastInfo.m_isInContact) {
real_t force;
// Spring
{
- real_t susp_length = wheel_info.m_suspensionRestLength;
- real_t current_length = wheel_info.m_raycastInfo.m_suspensionLength;
+ real_t susp_length = wheel_info.m_suspensionRestLength;
+ real_t current_length = wheel_info.m_raycastInfo.m_suspensionLength;
real_t length_diff = (susp_length - current_length);
- force = wheel_info.m_suspensionStiffness
- * length_diff * wheel_info.m_clippedInvContactDotSuspension;
+ force = wheel_info.m_suspensionStiffness * length_diff * wheel_info.m_clippedInvContactDotSuspension;
}
// Damper
{
real_t projected_rel_vel = wheel_info.m_suspensionRelativeVelocity;
{
- real_t susp_damping;
- if ( projected_rel_vel < real_t(0.0) )
- {
+ real_t susp_damping;
+ if (projected_rel_vel < real_t(0.0)) {
susp_damping = wheel_info.m_wheelsDampingCompression;
- }
- else
- {
+ } else {
susp_damping = wheel_info.m_wheelsDampingRelaxation;
}
force -= susp_damping * projected_rel_vel;
@@ -528,30 +476,23 @@ void VehicleBody::_update_suspension(PhysicsDirectBodyState *s)
// RESULT
wheel_info.m_wheelsSuspensionForce = force * chassisMass;
- if (wheel_info.m_wheelsSuspensionForce < real_t(0.))
- {
+ if (wheel_info.m_wheelsSuspensionForce < real_t(0.)) {
wheel_info.m_wheelsSuspensionForce = real_t(0.);
}
- }
- else
- {
+ } else {
wheel_info.m_wheelsSuspensionForce = real_t(0.0);
}
}
-
}
-
//bilateral constraint between two dynamic objects
-void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3& pos1,
- PhysicsBody* body2, const Vector3& pos2, const Vector3& normal,real_t& impulse)
-{
+void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1,
+ PhysicsBody *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse) {
real_t normalLenSqr = normal.length_squared();
//ERR_FAIL_COND( normalLenSqr < real_t(1.1));
- if (normalLenSqr > real_t(1.1))
- {
+ if (normalLenSqr > real_t(1.1)) {
impulse = real_t(0.);
return;
}
@@ -562,16 +503,16 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
rel_pos2 = pos2 - body2->get_global_transform().origin;
//this jacobian entry could be re-used for all iterations
- Vector3 vel1 = s->get_linear_velocity() + (s->get_angular_velocity()).cross(rel_pos1);// * mPos);
+ Vector3 vel1 = s->get_linear_velocity() + (s->get_angular_velocity()).cross(rel_pos1); // * mPos);
Vector3 vel2;
if (body2)
- vel2=body2->get_linear_velocity() + body2->get_angular_velocity().cross(rel_pos2);
+ vel2 = body2->get_linear_velocity() + body2->get_angular_velocity().cross(rel_pos2);
Vector3 vel = vel1 - vel2;
Matrix3 b2trans;
- float b2invmass=0;
+ float b2invmass = 0;
Vector3 b2lv;
Vector3 b2av;
Vector3 b2invinertia; //todo
@@ -583,24 +524,21 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
b2av = body2->get_angular_velocity();
}
-
-
btVehicleJacobianEntry jac(s->get_transform().basis.transposed(),
- b2trans,
- rel_pos1,
- rel_pos2,
- normal,
- s->get_inverse_inertia(),
- 1.0/mass,
- b2invinertia,
- b2invmass);
+ b2trans,
+ rel_pos1,
+ rel_pos2,
+ normal,
+ s->get_inverse_inertia(),
+ 1.0 / mass,
+ b2invinertia,
+ b2invmass);
real_t rel_vel = jac.getRelativeVelocity(
- s->get_linear_velocity(),
- s->get_transform().basis.transposed().xform(s->get_angular_velocity()),
- b2lv,
- b2trans.xform(b2av));
-
+ s->get_linear_velocity(),
+ s->get_transform().basis.transposed().xform(s->get_angular_velocity()),
+ b2lv,
+ b2trans.xform(b2av));
rel_vel = normal.dot(vel);
@@ -608,32 +546,28 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
real_t contactDamping = real_t(0.4);
#define ONLY_USE_LINEAR_MASS
#ifdef ONLY_USE_LINEAR_MASS
- real_t massTerm = real_t(1.) / ((1.0/mass) + b2invmass);
- impulse = - contactDamping * rel_vel * massTerm;
+ real_t massTerm = real_t(1.) / ((1.0 / mass) + b2invmass);
+ impulse = -contactDamping * rel_vel * massTerm;
#else
real_t velocityImpulse = -contactDamping * rel_vel * jacDiagABInv;
impulse = velocityImpulse;
#endif
-
}
-
-
-VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState *s,PhysicsBody* body1,const Vector3& frictionPosWorld,const Vector3& frictionDirectionWorld, real_t maxImpulse)
- :m_s(s),
- m_body1(body1),
- m_frictionPositionWorld(frictionPosWorld),
- m_frictionDirectionWorld(frictionDirectionWorld),
- m_maxImpulse(maxImpulse)
-{
- float denom0=0;
- float denom1=0;
+VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse)
+ : m_s(s),
+ m_body1(body1),
+ m_frictionPositionWorld(frictionPosWorld),
+ m_frictionDirectionWorld(frictionDirectionWorld),
+ m_maxImpulse(maxImpulse) {
+ float denom0 = 0;
+ float denom1 = 0;
{
Vector3 r0 = frictionPosWorld - s->get_transform().origin;
Vector3 c0 = (r0).cross(frictionDirectionWorld);
Vector3 vec = s->get_inverse_inertia_tensor().xform_inv(c0).cross(r0);
- denom0= s->get_inverse_mass() + frictionDirectionWorld.dot(vec);
+ denom0 = s->get_inverse_mass() + frictionDirectionWorld.dot(vec);
}
/* TODO: Why is this code unused?
@@ -647,30 +581,28 @@ VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirec
}
*/
- real_t relaxation = 1.f;
- m_jacDiagABInv = relaxation/(denom0+denom1);
+ real_t relaxation = 1.f;
+ m_jacDiagABInv = relaxation / (denom0 + denom1);
}
+real_t VehicleBody::_calc_rolling_friction(btVehicleWheelContactPoint &contactPoint) {
-real_t VehicleBody::_calc_rolling_friction(btVehicleWheelContactPoint& contactPoint) {
-
- real_t j1=0.f;
+ real_t j1 = 0.f;
- const Vector3& contactPosWorld = contactPoint.m_frictionPositionWorld;
+ const Vector3 &contactPosWorld = contactPoint.m_frictionPositionWorld;
Vector3 rel_pos1 = contactPosWorld - contactPoint.m_s->get_transform().origin;
Vector3 rel_pos2;
if (contactPoint.m_body1)
rel_pos2 = contactPosWorld - contactPoint.m_body1->get_global_transform().origin;
- real_t maxImpulse = contactPoint.m_maxImpulse;
+ real_t maxImpulse = contactPoint.m_maxImpulse;
- Vector3 vel1 = contactPoint.m_s->get_linear_velocity() + (contactPoint.m_s->get_angular_velocity()).cross(rel_pos1);// * mPos);
+ Vector3 vel1 = contactPoint.m_s->get_linear_velocity() + (contactPoint.m_s->get_angular_velocity()).cross(rel_pos1); // * mPos);
Vector3 vel2;
if (contactPoint.m_body1) {
- vel2=contactPoint.m_body1->get_linear_velocity() + contactPoint.m_body1->get_angular_velocity().cross(rel_pos2);
-
+ vel2 = contactPoint.m_body1->get_linear_velocity() + contactPoint.m_body1->get_angular_velocity().cross(rel_pos2);
}
Vector3 vel = vel1 - vel2;
@@ -680,10 +612,9 @@ real_t VehicleBody::_calc_rolling_friction(btVehicleWheelContactPoint& contactPo
// calculate j that moves us to zero relative velocity
j1 = -vrel * contactPoint.m_jacDiagABInv;
- return CLAMP(j1,-maxImpulse,maxImpulse);
+ return CLAMP(j1, -maxImpulse, maxImpulse);
}
-
static const real_t sideFrictionStiffness2 = real_t(1.0);
void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
@@ -699,37 +630,31 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
int numWheelsOnGround = 0;
-
//collapse all those loops into one!
- for (int i=0;i<wheels.size();i++)
- {
- VehicleWheel& wheelInfo = *wheels[i];
+ for (int i = 0; i < wheels.size(); i++) {
+ VehicleWheel &wheelInfo = *wheels[i];
if (wheelInfo.m_raycastInfo.m_isInContact)
numWheelsOnGround++;
m_sideImpulse[i] = real_t(0.);
m_forwardImpulse[i] = real_t(0.);
-
}
{
- for (int i=0;i<wheels.size();i++)
- {
+ for (int i = 0; i < wheels.size(); i++) {
- VehicleWheel& wheelInfo = *wheels[i];
+ VehicleWheel &wheelInfo = *wheels[i];
-
- if (wheelInfo.m_raycastInfo.m_isInContact)
- {
+ if (wheelInfo.m_raycastInfo.m_isInContact) {
//const btTransform& wheelTrans = getWheelTransformWS( i );
- Matrix3 wheelBasis0 = wheelInfo.m_worldTransform.basis;//get_global_transform().basis;
+ Matrix3 wheelBasis0 = wheelInfo.m_worldTransform.basis; //get_global_transform().basis;
m_axle[i] = wheelBasis0.get_axis(Vector3::AXIS_X);
//m_axle[i] = wheelInfo.m_raycastInfo.m_wheelAxleWS;
- const Vector3& surfNormalWS = wheelInfo.m_raycastInfo.m_contactNormalWS;
+ const Vector3 &surfNormalWS = wheelInfo.m_raycastInfo.m_contactNormalWS;
real_t proj = m_axle[i].dot(surfNormalWS);
m_axle[i] -= surfNormalWS * proj;
m_axle[i] = m_axle[i].normalized();
@@ -737,14 +662,11 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
m_forwardWS[i] = surfNormalWS.cross(m_axle[i]);
m_forwardWS[i].normalize();
-
_resolve_single_bilateral(s, wheelInfo.m_raycastInfo.m_contactPointWS,
- wheelInfo.m_raycastInfo.m_groundObject, wheelInfo.m_raycastInfo.m_contactPointWS,
- m_axle[i],m_sideImpulse[i]);
+ wheelInfo.m_raycastInfo.m_groundObject, wheelInfo.m_raycastInfo.m_contactPointWS,
+ m_axle[i], m_sideImpulse[i]);
m_sideImpulse[i] *= sideFrictionStiffness2;
-
-
}
}
}
@@ -754,57 +676,46 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
bool sliding = false;
{
- for (int wheel =0;wheel <wheels.size();wheel++)
- {
- VehicleWheel& wheelInfo = *wheels[wheel];
-
+ for (int wheel = 0; wheel < wheels.size(); wheel++) {
+ VehicleWheel &wheelInfo = *wheels[wheel];
//class btRigidBody* groundObject = (class btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject;
- real_t rollingFriction = 0.f;
+ real_t rollingFriction = 0.f;
- if (wheelInfo.m_raycastInfo.m_isInContact)
- {
- if (engine_force != 0.f)
- {
- rollingFriction = -engine_force* s->get_step();
- } else
- {
+ if (wheelInfo.m_raycastInfo.m_isInContact) {
+ if (engine_force != 0.f) {
+ rollingFriction = -engine_force * s->get_step();
+ } else {
real_t defaultRollingFrictionImpulse = 0.f;
- float cbrake = MAX(wheelInfo.m_brake,brake);
+ float cbrake = MAX(wheelInfo.m_brake, brake);
real_t maxImpulse = cbrake ? cbrake : defaultRollingFrictionImpulse;
- btVehicleWheelContactPoint contactPt(s,wheelInfo.m_raycastInfo.m_groundObject,wheelInfo.m_raycastInfo.m_contactPointWS,m_forwardWS[wheel],maxImpulse);
+ btVehicleWheelContactPoint contactPt(s, wheelInfo.m_raycastInfo.m_groundObject, wheelInfo.m_raycastInfo.m_contactPointWS, m_forwardWS[wheel], maxImpulse);
rollingFriction = _calc_rolling_friction(contactPt);
}
}
//switch between active rolling (throttle), braking and non-active rolling friction (no throttle/break)
-
-
-
m_forwardImpulse[wheel] = real_t(0.);
- wheelInfo.m_skidInfo= real_t(1.);
+ wheelInfo.m_skidInfo = real_t(1.);
- if (wheelInfo.m_raycastInfo.m_isInContact)
- {
- wheelInfo.m_skidInfo= real_t(1.);
+ if (wheelInfo.m_raycastInfo.m_isInContact) {
+ wheelInfo.m_skidInfo = real_t(1.);
real_t maximp = wheelInfo.m_wheelsSuspensionForce * s->get_step() * wheelInfo.m_frictionSlip;
real_t maximpSide = maximp;
real_t maximpSquared = maximp * maximpSide;
+ m_forwardImpulse[wheel] = rollingFriction; //wheelInfo.m_engineForce* timeStep;
- m_forwardImpulse[wheel] = rollingFriction;//wheelInfo.m_engineForce* timeStep;
+ real_t x = (m_forwardImpulse[wheel]) * fwdFactor;
+ real_t y = (m_sideImpulse[wheel]) * sideFactor;
- real_t x = (m_forwardImpulse[wheel] ) * fwdFactor;
- real_t y = (m_sideImpulse[wheel] ) * sideFactor;
+ real_t impulseSquared = (x * x + y * y);
- real_t impulseSquared = (x*x + y*y);
-
- if (impulseSquared > maximpSquared)
- {
+ if (impulseSquared > maximpSquared) {
sliding = true;
real_t factor = maximp / Math::sqrt(impulseSquared);
@@ -812,22 +723,14 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
wheelInfo.m_skidInfo *= factor;
}
}
-
}
}
-
-
-
- if (sliding)
- {
- for (int wheel = 0;wheel < wheels.size(); wheel++)
- {
- if (m_sideImpulse[wheel] != real_t(0.))
- {
- if (wheels[wheel]->m_skidInfo< real_t(1.))
- {
- m_forwardImpulse[wheel] *= wheels[wheel]->m_skidInfo;
+ if (sliding) {
+ for (int wheel = 0; wheel < wheels.size(); wheel++) {
+ if (m_sideImpulse[wheel] != real_t(0.)) {
+ if (wheels[wheel]->m_skidInfo < real_t(1.)) {
+ m_forwardImpulse[wheel] *= wheels[wheel]->m_skidInfo;
m_sideImpulse[wheel] *= wheels[wheel]->m_skidInfo;
}
}
@@ -836,36 +739,32 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
// apply the impulses
{
- for (int wheel = 0;wheel<wheels.size(); wheel++)
- {
- VehicleWheel& wheelInfo = *wheels[wheel];
+ for (int wheel = 0; wheel < wheels.size(); wheel++) {
+ VehicleWheel &wheelInfo = *wheels[wheel];
Vector3 rel_pos = wheelInfo.m_raycastInfo.m_contactPointWS -
- s->get_transform().origin;
+ s->get_transform().origin;
- if (m_forwardImpulse[wheel] != real_t(0.))
- {
- s->apply_impulse(rel_pos,m_forwardWS[wheel]*(m_forwardImpulse[wheel]));
+ if (m_forwardImpulse[wheel] != real_t(0.)) {
+ s->apply_impulse(rel_pos, m_forwardWS[wheel] * (m_forwardImpulse[wheel]));
}
- if (m_sideImpulse[wheel] != real_t(0.))
- {
- PhysicsBody* groundObject = wheelInfo.m_raycastInfo.m_groundObject;
+ if (m_sideImpulse[wheel] != real_t(0.)) {
+ PhysicsBody *groundObject = wheelInfo.m_raycastInfo.m_groundObject;
Vector3 rel_pos2;
if (groundObject) {
- rel_pos2=wheelInfo.m_raycastInfo.m_contactPointWS - groundObject->get_global_transform().origin;
+ rel_pos2 = wheelInfo.m_raycastInfo.m_contactPointWS - groundObject->get_global_transform().origin;
}
-
Vector3 sideImp = m_axle[wheel] * m_sideImpulse[wheel];
#if defined ROLLING_INFLUENCE_FIX // fix. It only worked if car's up was along Y - VT.
- Vector3 vChassisWorldUp = s->get_transform().basis.transposed()[1];//getRigidBody()->getCenterOfMassTransform().getBasis().getColumn(m_indexUpAxis);
- rel_pos -= vChassisWorldUp * (vChassisWorldUp.dot(rel_pos) * (1.f-wheelInfo.m_rollInfluence));
+ Vector3 vChassisWorldUp = s->get_transform().basis.transposed()[1]; //getRigidBody()->getCenterOfMassTransform().getBasis().getColumn(m_indexUpAxis);
+ rel_pos -= vChassisWorldUp * (vChassisWorldUp.dot(rel_pos) * (1.f - wheelInfo.m_rollInfluence));
#else
rel_pos[1] *= wheelInfo.m_rollInfluence; //?
#endif
- s->apply_impulse(rel_pos,sideImp);
+ s->apply_impulse(rel_pos, sideImp);
//apply friction impulse on the ground
//todo
@@ -873,74 +772,62 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
}
}
}
-
-
}
-
void VehicleBody::_direct_state_changed(Object *p_state) {
-
PhysicsDirectBodyState *s = p_state->cast_to<PhysicsDirectBodyState>();
set_ignore_transform_notification(true);
set_global_transform(s->get_transform());
set_ignore_transform_notification(false);
-
float step = s->get_step();
- for(int i=0;i<wheels.size();i++) {
+ for (int i = 0; i < wheels.size(); i++) {
- _update_wheel(i,s);
+ _update_wheel(i, s);
}
+ for (int i = 0; i < wheels.size(); i++) {
- for(int i=0;i<wheels.size();i++) {
-
- _ray_cast(i,s);
+ _ray_cast(i, s);
wheels[i]->set_transform(s->get_transform().inverse() * wheels[i]->m_worldTransform);
}
_update_suspension(s);
- for(int i=0;i<wheels.size();i++) {
+ for (int i = 0; i < wheels.size(); i++) {
//apply suspension force
- VehicleWheel& wheel = *wheels[i];
+ VehicleWheel &wheel = *wheels[i];
real_t suspensionForce = wheel.m_wheelsSuspensionForce;
- if (suspensionForce > wheel.m_maxSuspensionForce)
- {
+ if (suspensionForce > wheel.m_maxSuspensionForce) {
suspensionForce = wheel.m_maxSuspensionForce;
}
Vector3 impulse = wheel.m_raycastInfo.m_contactNormalWS * suspensionForce * step;
Vector3 relpos = wheel.m_raycastInfo.m_contactPointWS - s->get_transform().origin;
- s->apply_impulse(relpos,impulse);
+ s->apply_impulse(relpos, impulse);
//getRigidBody()->applyImpulse(impulse, relpos);
-
}
-
_update_friction(s);
-
- for (int i=0;i<wheels.size();i++)
- {
- VehicleWheel& wheel = *wheels[i];
+ for (int i = 0; i < wheels.size(); i++) {
+ VehicleWheel &wheel = *wheels[i];
Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - s->get_transform().origin;
- Vector3 vel = s->get_linear_velocity() + (s->get_angular_velocity()).cross(relpos);// * mPos);
+ Vector3 vel = s->get_linear_velocity() + (s->get_angular_velocity()).cross(relpos); // * mPos);
- if (wheel.m_raycastInfo.m_isInContact)
- {
- const Transform& chassisWorldTransform = s->get_transform();
+ if (wheel.m_raycastInfo.m_isInContact) {
+ const Transform &chassisWorldTransform = s->get_transform();
- Vector3 fwd (
- chassisWorldTransform.basis[0][Vector3::AXIS_Z],
- chassisWorldTransform.basis[1][Vector3::AXIS_Z],
- chassisWorldTransform.basis[2][Vector3::AXIS_Z]);
+ Vector3 fwd(
+ chassisWorldTransform.basis[0][Vector3::AXIS_Z],
+ chassisWorldTransform.basis[1][Vector3::AXIS_Z],
+ chassisWorldTransform.basis[2][Vector3::AXIS_Z]);
real_t proj = fwd.dot(wheel.m_raycastInfo.m_contactNormalWS);
fwd -= wheel.m_raycastInfo.m_contactNormalWS * proj;
@@ -950,124 +837,113 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
wheel.m_deltaRotation = (proj2 * step) / (wheel.m_wheelRadius);
wheel.m_rotation += wheel.m_deltaRotation;
- } else
- {
+ } else {
wheel.m_rotation += wheel.m_deltaRotation;
}
- wheel.m_deltaRotation *= real_t(0.99);//damping of rotation when not in contact
-
+ wheel.m_deltaRotation *= real_t(0.99); //damping of rotation when not in contact
}
linear_velocity = s->get_linear_velocity();
}
void VehicleBody::set_mass(real_t p_mass) {
- mass=p_mass;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_MASS,mass);
+ mass = p_mass;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_MASS, mass);
}
-real_t VehicleBody::get_mass() const{
+real_t VehicleBody::get_mass() const {
return mass;
}
-
void VehicleBody::set_friction(real_t p_friction) {
- friction=p_friction;
- PhysicsServer::get_singleton()->body_set_param(get_rid(),PhysicsServer::BODY_PARAM_FRICTION,friction);
+ friction = p_friction;
+ PhysicsServer::get_singleton()->body_set_param(get_rid(), PhysicsServer::BODY_PARAM_FRICTION, friction);
}
-real_t VehicleBody::get_friction() const{
+real_t VehicleBody::get_friction() const {
return friction;
}
void VehicleBody::set_engine_force(float p_force) {
- engine_force=p_force;
+ engine_force = p_force;
}
-float VehicleBody::get_engine_force() const{
+float VehicleBody::get_engine_force() const {
return engine_force;
}
-void VehicleBody::set_brake(float p_brake){
+void VehicleBody::set_brake(float p_brake) {
- brake=p_brake;
+ brake = p_brake;
}
-float VehicleBody::get_brake() const{
+float VehicleBody::get_brake() const {
return brake;
}
-void VehicleBody::set_steering(float p_steering){
+void VehicleBody::set_steering(float p_steering) {
- m_steeringValue=p_steering;
+ m_steeringValue = p_steering;
}
-float VehicleBody::get_steering() const{
+float VehicleBody::get_steering() const {
return m_steeringValue;
}
-Vector3 VehicleBody::get_linear_velocity() const
-{
+Vector3 VehicleBody::get_linear_velocity() const {
return linear_velocity;
}
-void VehicleBody::_bind_methods(){
-
- ObjectTypeDB::bind_method(_MD("set_mass","mass"),&VehicleBody::set_mass);
- ObjectTypeDB::bind_method(_MD("get_mass"),&VehicleBody::get_mass);
-
- ObjectTypeDB::bind_method(_MD("set_friction","friction"),&VehicleBody::set_friction);
- ObjectTypeDB::bind_method(_MD("get_friction"),&VehicleBody::get_friction);
+void VehicleBody::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_engine_force","engine_force"),&VehicleBody::set_engine_force);
- ObjectTypeDB::bind_method(_MD("get_engine_force"),&VehicleBody::get_engine_force);
+ ObjectTypeDB::bind_method(_MD("set_mass", "mass"), &VehicleBody::set_mass);
+ ObjectTypeDB::bind_method(_MD("get_mass"), &VehicleBody::get_mass);
- ObjectTypeDB::bind_method(_MD("set_brake","brake"),&VehicleBody::set_brake);
- ObjectTypeDB::bind_method(_MD("get_brake"),&VehicleBody::get_brake);
+ ObjectTypeDB::bind_method(_MD("set_friction", "friction"), &VehicleBody::set_friction);
+ ObjectTypeDB::bind_method(_MD("get_friction"), &VehicleBody::get_friction);
- ObjectTypeDB::bind_method(_MD("set_steering","steering"),&VehicleBody::set_steering);
- ObjectTypeDB::bind_method(_MD("get_steering"),&VehicleBody::get_steering);
+ ObjectTypeDB::bind_method(_MD("set_engine_force", "engine_force"), &VehicleBody::set_engine_force);
+ ObjectTypeDB::bind_method(_MD("get_engine_force"), &VehicleBody::get_engine_force);
- ObjectTypeDB::bind_method(_MD("get_linear_velocity"),&VehicleBody::get_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("set_brake", "brake"), &VehicleBody::set_brake);
+ ObjectTypeDB::bind_method(_MD("get_brake"), &VehicleBody::get_brake);
- ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&VehicleBody::_direct_state_changed);
+ ObjectTypeDB::bind_method(_MD("set_steering", "steering"), &VehicleBody::set_steering);
+ ObjectTypeDB::bind_method(_MD("get_steering"), &VehicleBody::get_steering);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"motion/engine_force",PROPERTY_HINT_RANGE,"0.00,1024.0,0.01"),_SCS("set_engine_force"),_SCS("get_engine_force"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"motion/brake",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_brake"),_SCS("get_brake"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"motion/steering",PROPERTY_HINT_RANGE,"-180,180.0,0.01"),_SCS("set_steering"),_SCS("get_steering"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"body/mass",PROPERTY_HINT_RANGE,"0.01,65536,0.01"),_SCS("set_mass"),_SCS("get_mass"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"body/friction",PROPERTY_HINT_RANGE,"0.01,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
+ ObjectTypeDB::bind_method(_MD("get_linear_velocity"), &VehicleBody::get_linear_velocity);
+ ObjectTypeDB::bind_method(_MD("_direct_state_changed"), &VehicleBody::_direct_state_changed);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "motion/engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01"), _SCS("set_engine_force"), _SCS("get_engine_force"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "motion/brake", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), _SCS("set_brake"), _SCS("get_brake"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "motion/steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), _SCS("set_steering"), _SCS("get_steering"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "body/mass", PROPERTY_HINT_RANGE, "0.01,65536,0.01"), _SCS("set_mass"), _SCS("get_mass"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "body/friction", PROPERTY_HINT_RANGE, "0.01,1,0.01"), _SCS("set_friction"), _SCS("get_friction"));
}
+VehicleBody::VehicleBody()
+ : PhysicsBody(PhysicsServer::BODY_MODE_RIGID) {
-
-VehicleBody::VehicleBody() : PhysicsBody(PhysicsServer::BODY_MODE_RIGID) {
-
-
- m_pitchControl=0;
+ m_pitchControl = 0;
m_currentVehicleSpeedKmHour = real_t(0.);
m_steeringValue = real_t(0.);
- engine_force=0;
- brake=0;
+ engine_force = 0;
+ brake = 0;
+ friction = 1;
-
- friction=1;
-
- ccd=false;
+ ccd = false;
exclude.insert(get_rid());
- PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(),this,"_direct_state_changed");
+ PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed");
set_mass(40);
}
-
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h
index f87a24c44..1be4ea687 100644
--- a/scene/3d/vehicle_body.h
+++ b/scene/3d/vehicle_body.h
@@ -35,20 +35,18 @@ class VehicleBody;
class VehicleWheel : public Spatial {
- OBJ_TYPE(VehicleWheel,Spatial);
-
-friend class VehicleBody;
+ OBJ_TYPE(VehicleWheel, Spatial);
+ friend class VehicleBody;
Transform m_worldTransform;
Transform local_xform;
bool engine_traction;
bool steers;
-
- Vector3 m_chassisConnectionPointCS; //const
- Vector3 m_wheelDirectionCS;//const
- Vector3 m_wheelAxleCS; // const or modified by steering
+ Vector3 m_chassisConnectionPointCS; //const
+ Vector3 m_wheelDirectionCS; //const
+ Vector3 m_wheelAxleCS; // const or modified by steering
real_t m_suspensionRestLength;
real_t m_maxSuspensionTravelCm;
@@ -63,32 +61,31 @@ friend class VehicleBody;
VehicleBody *body;
-// btVector3 m_wheelAxleCS; // const or modified by steering ?
+ // btVector3 m_wheelAxleCS; // const or modified by steering ?
- real_t m_steering;
- real_t m_rotation;
- real_t m_deltaRotation;
- real_t m_rollInfluence;
+ real_t m_steering;
+ real_t m_rotation;
+ real_t m_deltaRotation;
+ real_t m_rollInfluence;
//real_t m_engineForce;
- real_t m_brake;
+ real_t m_brake;
- real_t m_clippedInvContactDotSuspension;
- real_t m_suspensionRelativeVelocity;
+ real_t m_clippedInvContactDotSuspension;
+ real_t m_suspensionRelativeVelocity;
//calculated by suspension
- real_t m_wheelsSuspensionForce;
- real_t m_skidInfo;
-
+ real_t m_wheelsSuspensionForce;
+ real_t m_skidInfo;
struct RaycastInfo {
//set by raycaster
- Vector3 m_contactNormalWS;//contactnormal
- Vector3 m_contactPointWS;//raycast hitpoint
- real_t m_suspensionLength;
- Vector3 m_hardPointWS;//raycast starting point
- Vector3 m_wheelDirectionWS; //direction in worldspace
- Vector3 m_wheelAxleWS; // axle in worldspace
+ Vector3 m_contactNormalWS; //contactnormal
+ Vector3 m_contactPointWS; //raycast hitpoint
+ real_t m_suspensionLength;
+ Vector3 m_hardPointWS; //raycast starting point
+ Vector3 m_wheelDirectionWS; //direction in worldspace
+ Vector3 m_wheelAxleWS; // axle in worldspace
bool m_isInContact;
- PhysicsBody* m_groundObject; //could be general void* ptr
+ PhysicsBody *m_groundObject; //could be general void* ptr
} m_raycastInfo;
void _update(PhysicsDirectBodyState *s);
@@ -98,7 +95,6 @@ protected:
static void _bind_methods();
public:
-
void set_radius(float p_radius);
float get_radius() const;
@@ -130,13 +126,11 @@ public:
bool is_used_as_steering() const;
VehicleWheel();
-
};
-
class VehicleBody : public PhysicsBody {
- OBJ_TYPE(VehicleBody,PhysicsBody);
+ OBJ_TYPE(VehicleBody, PhysicsBody);
real_t mass;
real_t friction;
@@ -145,52 +139,48 @@ class VehicleBody : public PhysicsBody {
float brake;
Vector3 linear_velocity;
- Vector3 angular_velocity;
+ Vector3 angular_velocity;
bool ccd;
- real_t m_pitchControl;
- real_t m_steeringValue;
- real_t m_currentVehicleSpeedKmHour;
+ real_t m_pitchControl;
+ real_t m_steeringValue;
+ real_t m_currentVehicleSpeedKmHour;
Set<RID> exclude;
- Vector<Vector3> m_forwardWS;
- Vector<Vector3> m_axle;
- Vector<real_t> m_forwardImpulse;
- Vector<real_t> m_sideImpulse;
+ Vector<Vector3> m_forwardWS;
+ Vector<Vector3> m_axle;
+ Vector<real_t> m_forwardImpulse;
+ Vector<real_t> m_sideImpulse;
struct btVehicleWheelContactPoint {
PhysicsDirectBodyState *m_s;
- PhysicsBody* m_body1;
- Vector3 m_frictionPositionWorld;
- Vector3 m_frictionDirectionWorld;
- real_t m_jacDiagABInv;
- real_t m_maxImpulse;
+ PhysicsBody *m_body1;
+ Vector3 m_frictionPositionWorld;
+ Vector3 m_frictionDirectionWorld;
+ real_t m_jacDiagABInv;
+ real_t m_maxImpulse;
-
- btVehicleWheelContactPoint(PhysicsDirectBodyState *s,PhysicsBody* body1,const Vector3& frictionPosWorld,const Vector3& frictionDirectionWorld, real_t maxImpulse);
+ btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse);
};
- void _resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3& pos1, PhysicsBody* body2, const Vector3& pos2, const Vector3& normal, real_t& impulse);
- real_t _calc_rolling_friction(btVehicleWheelContactPoint& contactPoint);
+ void _resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1, PhysicsBody *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse);
+ real_t _calc_rolling_friction(btVehicleWheelContactPoint &contactPoint);
void _update_friction(PhysicsDirectBodyState *s);
void _update_suspension(PhysicsDirectBodyState *s);
- real_t _ray_cast(int p_idx,PhysicsDirectBodyState *s);
- void _update_wheel_transform(VehicleWheel& wheel ,PhysicsDirectBodyState *s);
- void _update_wheel(int p_idx,PhysicsDirectBodyState *s);
-
-
+ real_t _ray_cast(int p_idx, PhysicsDirectBodyState *s);
+ void _update_wheel_transform(VehicleWheel &wheel, PhysicsDirectBodyState *s);
+ void _update_wheel(int p_idx, PhysicsDirectBodyState *s);
-friend class VehicleWheel;
- Vector<VehicleWheel*> wheels;
+ friend class VehicleWheel;
+ Vector<VehicleWheel *> wheels;
static void _bind_methods();
void _direct_state_changed(Object *p_state);
-public:
-
+public:
void set_mass(real_t p_mass);
real_t get_mass() const;
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp
index 4ff3a55af..6e7290c7c 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier.cpp
@@ -28,71 +28,64 @@
/*************************************************************************/
#include "visibility_notifier.h"
-#include "scene/scene_string_names.h"
#include "scene/3d/physics_body.h"
#include "scene/animation/animation_player.h"
#include "scene/scene_string_names.h"
+#include "scene/scene_string_names.h"
-void VisibilityNotifier::_enter_camera(Camera* p_camera) {
+void VisibilityNotifier::_enter_camera(Camera *p_camera) {
ERR_FAIL_COND(cameras.has(p_camera));
cameras.insert(p_camera);
- if (cameras.size()==1) {
+ if (cameras.size() == 1) {
emit_signal(SceneStringNames::get_singleton()->enter_screen);
_screen_enter();
}
- emit_signal(SceneStringNames::get_singleton()->enter_camera,p_camera);
-
+ emit_signal(SceneStringNames::get_singleton()->enter_camera, p_camera);
}
-void VisibilityNotifier::_exit_camera(Camera* p_camera){
+void VisibilityNotifier::_exit_camera(Camera *p_camera) {
ERR_FAIL_COND(!cameras.has(p_camera));
cameras.erase(p_camera);
- emit_signal(SceneStringNames::get_singleton()->exit_camera,p_camera);
- if (cameras.size()==0) {
+ emit_signal(SceneStringNames::get_singleton()->exit_camera, p_camera);
+ if (cameras.size() == 0) {
emit_signal(SceneStringNames::get_singleton()->exit_screen);
_screen_exit();
-
}
}
+void VisibilityNotifier::set_aabb(const AABB &p_aabb) {
-void VisibilityNotifier::set_aabb(const AABB& p_aabb){
-
- if (aabb==p_aabb)
+ if (aabb == p_aabb)
return;
- aabb=p_aabb;
+ aabb = p_aabb;
if (is_inside_world()) {
- get_world()->_update_notifier(this,get_global_transform().xform(aabb));
+ get_world()->_update_notifier(this, get_global_transform().xform(aabb));
}
_change_notify("aabb");
update_gizmo();
}
-AABB VisibilityNotifier::get_aabb() const{
+AABB VisibilityNotifier::get_aabb() const {
return aabb;
}
-
void VisibilityNotifier::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
-
- get_world()->_register_notifier(this,get_global_transform().xform(aabb));
+ get_world()->_register_notifier(this, get_global_transform().xform(aabb));
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
-
- get_world()->_update_notifier(this,get_global_transform().xform(aabb));
+ get_world()->_update_notifier(this, get_global_transform().xform(aabb));
} break;
case NOTIFICATION_EXIT_WORLD: {
@@ -101,75 +94,64 @@ void VisibilityNotifier::_notification(int p_what) {
}
}
-
bool VisibilityNotifier::is_on_screen() const {
- return cameras.size()!=0;
+ return cameras.size() != 0;
}
-void VisibilityNotifier::_bind_methods(){
+void VisibilityNotifier::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_aabb","rect"),&VisibilityNotifier::set_aabb);
- ObjectTypeDB::bind_method(_MD("get_aabb"),&VisibilityNotifier::get_aabb);
- ObjectTypeDB::bind_method(_MD("is_on_screen"),&VisibilityNotifier::is_on_screen);
+ ObjectTypeDB::bind_method(_MD("set_aabb", "rect"), &VisibilityNotifier::set_aabb);
+ ObjectTypeDB::bind_method(_MD("get_aabb"), &VisibilityNotifier::get_aabb);
+ ObjectTypeDB::bind_method(_MD("is_on_screen"), &VisibilityNotifier::is_on_screen);
- ADD_PROPERTY( PropertyInfo(Variant::_AABB,"aabb"),_SCS("set_aabb"),_SCS("get_aabb"));
+ ADD_PROPERTY(PropertyInfo(Variant::_AABB, "aabb"), _SCS("set_aabb"), _SCS("get_aabb"));
- ADD_SIGNAL( MethodInfo("enter_camera",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera")) );
- ADD_SIGNAL( MethodInfo("exit_camera",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera")) );
- ADD_SIGNAL( MethodInfo("enter_screen"));
- ADD_SIGNAL( MethodInfo("exit_screen"));
+ ADD_SIGNAL(MethodInfo("enter_camera", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera")));
+ ADD_SIGNAL(MethodInfo("exit_camera", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera")));
+ ADD_SIGNAL(MethodInfo("enter_screen"));
+ ADD_SIGNAL(MethodInfo("exit_screen"));
}
-
VisibilityNotifier::VisibilityNotifier() {
- aabb=AABB(Vector3(-1,-1,-1),Vector3(2,2,2));
-
+ aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
}
-
-
-
-
//////////////////////////////////////
-
void VisibilityEnabler::_screen_enter() {
+ for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
- for(Map<Node*,Variant>::Element *E=nodes.front();E;E=E->next()) {
-
- _change_node_state(E->key(),true);
+ _change_node_state(E->key(), true);
}
- visible=true;
+ visible = true;
}
void VisibilityEnabler::_screen_exit() {
- for(Map<Node*,Variant>::Element *E=nodes.front();E;E=E->next()) {
+ for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
- _change_node_state(E->key(),false);
+ _change_node_state(E->key(), false);
}
- visible=false;
+ visible = false;
}
-void VisibilityEnabler::_find_nodes(Node* p_node) {
-
+void VisibilityEnabler::_find_nodes(Node *p_node) {
- bool add=false;
+ bool add = false;
Variant meta;
if (enabler[ENABLER_FREEZE_BODIES]) {
RigidBody *rb = p_node->cast_to<RigidBody>();
- if (rb && ((rb->get_mode()==RigidBody::MODE_CHARACTER || (rb->get_mode()==RigidBody::MODE_RIGID && !rb->is_able_to_sleep())))) {
+ if (rb && ((rb->get_mode() == RigidBody::MODE_CHARACTER || (rb->get_mode() == RigidBody::MODE_RIGID && !rb->is_able_to_sleep())))) {
-
- add=true;
- meta=rb->get_mode();
+ add = true;
+ meta = rb->get_mode();
}
}
@@ -177,63 +159,58 @@ void VisibilityEnabler::_find_nodes(Node* p_node) {
AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
if (ap) {
- add=true;
+ add = true;
}
}
if (add) {
- p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
- nodes[p_node]=meta;
- _change_node_state(p_node,false);
+ p_node->connect(SceneStringNames::get_singleton()->exit_tree, this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
+ nodes[p_node] = meta;
+ _change_node_state(p_node, false);
}
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
- if (c->get_filename()!=String())
+ if (c->get_filename() != String())
continue; //skip, instance
_find_nodes(c);
}
-
}
-void VisibilityEnabler::_notification(int p_what){
+void VisibilityEnabler::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
if (get_tree()->is_editor_hint())
return;
-
Node *from = this;
//find where current scene starts
- while(from->get_parent() && from->get_filename()==String())
- from=from->get_parent();
+ while (from->get_parent() && from->get_filename() == String())
+ from = from->get_parent();
_find_nodes(from);
-
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
if (get_tree()->is_editor_hint())
return;
-
- for (Map<Node*,Variant>::Element *E=nodes.front();E;E=E->next()) {
+ for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) {
if (!visible)
- _change_node_state(E->key(),true);
- E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed");
+ _change_node_state(E->key(), true);
+ E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree, this, "_node_removed");
}
nodes.clear();
-
}
}
-void VisibilityEnabler::_change_node_state(Node* p_node,bool p_enabled) {
+void VisibilityEnabler::_change_node_state(Node *p_node, bool p_enabled) {
ERR_FAIL_COND(!nodes.has(p_node));
@@ -245,59 +222,52 @@ void VisibilityEnabler::_change_node_state(Node* p_node,bool p_enabled) {
}
{
- AnimationPlayer *ap=p_node->cast_to<AnimationPlayer>();
+ AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
if (ap) {
ap->set_active(p_enabled);
}
}
-
}
-
-void VisibilityEnabler::_node_removed(Node* p_node) {
+void VisibilityEnabler::_node_removed(Node *p_node) {
if (!visible)
- _change_node_state(p_node,true);
- p_node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed");
+ _change_node_state(p_node, true);
+ p_node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, "_node_removed");
nodes.erase(p_node);
-
}
-void VisibilityEnabler::_bind_methods(){
+void VisibilityEnabler::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_enabler","enabler","enabled"),&VisibilityEnabler::set_enabler);
- ObjectTypeDB::bind_method(_MD("is_enabler_enabled","enabler"),&VisibilityEnabler::is_enabler_enabled);
- ObjectTypeDB::bind_method(_MD("_node_removed"),&VisibilityEnabler::_node_removed);
+ ObjectTypeDB::bind_method(_MD("set_enabler", "enabler", "enabled"), &VisibilityEnabler::set_enabler);
+ ObjectTypeDB::bind_method(_MD("is_enabler_enabled", "enabler"), &VisibilityEnabler::is_enabler_enabled);
+ ObjectTypeDB::bind_method(_MD("_node_removed"), &VisibilityEnabler::_node_removed);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/pause_animations"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS );
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"enabler/freeze_bodies"),_SCS("set_enabler"),_SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "enabler/pause_animations"), _SCS("set_enabler"), _SCS("is_enabler_enabled"), ENABLER_PAUSE_ANIMATIONS);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "enabler/freeze_bodies"), _SCS("set_enabler"), _SCS("is_enabler_enabled"), ENABLER_FREEZE_BODIES);
- BIND_CONSTANT( ENABLER_FREEZE_BODIES );
- BIND_CONSTANT( ENABLER_PAUSE_ANIMATIONS );
- BIND_CONSTANT( ENABLER_MAX);
+ BIND_CONSTANT(ENABLER_FREEZE_BODIES);
+ BIND_CONSTANT(ENABLER_PAUSE_ANIMATIONS);
+ BIND_CONSTANT(ENABLER_MAX);
}
-void VisibilityEnabler::set_enabler(Enabler p_enabler,bool p_enable){
-
- ERR_FAIL_INDEX(p_enabler,ENABLER_MAX);
- enabler[p_enabler]=p_enable;
+void VisibilityEnabler::set_enabler(Enabler p_enabler, bool p_enable) {
+ ERR_FAIL_INDEX(p_enabler, ENABLER_MAX);
+ enabler[p_enabler] = p_enable;
}
-bool VisibilityEnabler::is_enabler_enabled(Enabler p_enabler) const{
+bool VisibilityEnabler::is_enabler_enabled(Enabler p_enabler) const {
- ERR_FAIL_INDEX_V(p_enabler,ENABLER_MAX,false);
+ ERR_FAIL_INDEX_V(p_enabler, ENABLER_MAX, false);
return enabler[p_enabler];
-
}
VisibilityEnabler::VisibilityEnabler() {
- for(int i=0;i<ENABLER_MAX;i++)
- enabler[i]=true;
-
- visible=false;
+ for (int i = 0; i < ENABLER_MAX; i++)
+ enabler[i] = true;
+ visible = false;
}
-
diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h
index 6efc492b4..7020192a4 100644
--- a/scene/3d/visibility_notifier.h
+++ b/scene/3d/visibility_notifier.h
@@ -34,39 +34,36 @@
class Camera;
class VisibilityNotifier : public Spatial {
- OBJ_TYPE(VisibilityNotifier,Spatial);
+ OBJ_TYPE(VisibilityNotifier, Spatial);
- Set<Camera*> cameras;
+ Set<Camera *> cameras;
AABB aabb;
protected:
-
virtual void _screen_enter() {}
virtual void _screen_exit() {}
void _notification(int p_what);
static void _bind_methods();
-friend class SpatialIndexer;
+ friend class SpatialIndexer;
- void _enter_camera(Camera* p_camera);
- void _exit_camera(Camera* p_camera);
+ void _enter_camera(Camera *p_camera);
+ void _exit_camera(Camera *p_camera);
public:
-
- void set_aabb(const AABB& p_aabb);
+ void set_aabb(const AABB &p_aabb);
AABB get_aabb() const;
bool is_on_screen() const;
VisibilityNotifier();
};
-
class VisibilityEnabler : public VisibilityNotifier {
- OBJ_TYPE(VisibilityEnabler,VisibilityNotifier);
-public:
+ OBJ_TYPE(VisibilityEnabler, VisibilityNotifier);
+public:
enum Enabler {
ENABLER_PAUSE_ANIMATIONS,
ENABLER_FREEZE_BODIES,
@@ -74,33 +71,29 @@ public:
};
protected:
-
virtual void _screen_enter();
virtual void _screen_exit();
bool visible;
- void _find_nodes(Node* p_node);
+ void _find_nodes(Node *p_node);
- Map<Node*,Variant> nodes;
- void _node_removed(Node* p_node);
+ Map<Node *, Variant> nodes;
+ void _node_removed(Node *p_node);
bool enabler[ENABLER_MAX];
- void _change_node_state(Node* p_node,bool p_enabled);
+ void _change_node_state(Node *p_node, bool p_enabled);
void _notification(int p_what);
static void _bind_methods();
public:
-
- void set_enabler(Enabler p_enabler,bool p_enable);
+ void set_enabler(Enabler p_enabler, bool p_enable);
bool is_enabler_enabled(Enabler p_enabler) const;
VisibilityEnabler();
-
};
VARIANT_ENUM_CAST(VisibilityEnabler::Enabler);
-
#endif // VISIBILITY_NOTIFIER_H
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 155fe96ba..18b688a87 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -28,49 +28,45 @@
/*************************************************************************/
#include "visual_instance.h"
-#include "servers/visual_server.h"
+#include "baked_light_instance.h"
#include "room_instance.h"
#include "scene/scene_string_names.h"
-#include "baked_light_instance.h"
+#include "servers/visual_server.h"
#include "skeleton.h"
AABB VisualInstance::get_transformed_aabb() const {
- return get_global_transform().xform( get_aabb() );
+ return get_global_transform().xform(get_aabb());
}
-
-
void VisualInstance::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
// CHECK ROOM
- Spatial * parent = get_parent_spatial();
- Room *room=NULL;
+ Spatial *parent = get_parent_spatial();
+ Room *room = NULL;
bool is_geom = cast_to<GeometryInstance>();
- while(parent) {
+ while (parent) {
room = parent->cast_to<Room>();
if (room)
break;
if (is_geom && parent->cast_to<BakedLightSampler>()) {
- VS::get_singleton()->instance_geometry_set_baked_light_sampler(get_instance(),parent->cast_to<BakedLightSampler>()->get_instance());
+ VS::get_singleton()->instance_geometry_set_baked_light_sampler(get_instance(), parent->cast_to<BakedLightSampler>()->get_instance());
break;
}
- parent=parent->get_parent_spatial();
+ parent = parent->get_parent_spatial();
}
-
-
if (room) {
- VisualServer::get_singleton()->instance_set_room(instance,room->get_instance());
+ VisualServer::get_singleton()->instance_set_room(instance, room->get_instance());
}
// CHECK SKELETON => moving skeleton attaching logic to MeshInstance
/*
@@ -79,21 +75,20 @@ void VisualInstance::_notification(int p_what) {
VisualServer::get_singleton()->instance_attach_skeleton( instance, skeleton->get_skeleton() );
*/
- VisualServer::get_singleton()->instance_set_scenario( instance, get_world()->get_scenario() );
+ VisualServer::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
Transform gt = get_global_transform();
- VisualServer::get_singleton()->instance_set_transform(instance,gt);
+ VisualServer::get_singleton()->instance_set_transform(instance, gt);
} break;
case NOTIFICATION_EXIT_WORLD: {
- VisualServer::get_singleton()->instance_set_scenario( instance, RID() );
- VisualServer::get_singleton()->instance_set_room(instance,RID());
- VisualServer::get_singleton()->instance_attach_skeleton( instance, RID() );
- VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
-
+ VisualServer::get_singleton()->instance_set_scenario(instance, RID());
+ VisualServer::get_singleton()->instance_set_room(instance, RID());
+ VisualServer::get_singleton()->instance_attach_skeleton(instance, RID());
+ VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID());
} break;
}
@@ -111,8 +106,8 @@ RID VisualInstance::_get_visual_instance_rid() const {
void VisualInstance::set_layer_mask(uint32_t p_mask) {
- layers=p_mask;
- VisualServer::get_singleton()->instance_set_layer_mask(instance,p_mask);
+ layers = p_mask;
+ VisualServer::get_singleton()->instance_set_layer_mask(instance, p_mask);
}
uint32_t VisualInstance::get_layer_mask() const {
@@ -120,75 +115,61 @@ uint32_t VisualInstance::get_layer_mask() const {
return layers;
}
-
void VisualInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_get_visual_instance_rid"),&VisualInstance::_get_visual_instance_rid);
- ObjectTypeDB::bind_method(_MD("set_base","base"), &VisualInstance::set_base);
- ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"), &VisualInstance::set_layer_mask);
+ ObjectTypeDB::bind_method(_MD("_get_visual_instance_rid"), &VisualInstance::_get_visual_instance_rid);
+ ObjectTypeDB::bind_method(_MD("set_base", "base"), &VisualInstance::set_base);
+ ObjectTypeDB::bind_method(_MD("set_layer_mask", "mask"), &VisualInstance::set_layer_mask);
ObjectTypeDB::bind_method(_MD("get_layer_mask"), &VisualInstance::get_layer_mask);
ObjectTypeDB::bind_method(_MD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "layers",PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
-
-
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_ALL_FLAGS), _SCS("set_layer_mask"), _SCS("get_layer_mask"));
}
+void VisualInstance::set_base(const RID &p_base) {
-void VisualInstance::set_base(const RID& p_base) {
-
- VisualServer::get_singleton()->instance_set_base(instance,p_base);
+ VisualServer::get_singleton()->instance_set_base(instance, p_base);
}
-
-VisualInstance::VisualInstance()
-{
+VisualInstance::VisualInstance() {
instance = VisualServer::get_singleton()->instance_create();
- VisualServer::get_singleton()->instance_attach_object_instance_ID( instance, get_instance_ID() );
- layers=1;
+ VisualServer::get_singleton()->instance_attach_object_instance_ID(instance, get_instance_ID());
+ layers = 1;
}
-
VisualInstance::~VisualInstance() {
VisualServer::get_singleton()->free(instance);
}
+void GeometryInstance::set_material_override(const Ref<Material> &p_material) {
-
-
-void GeometryInstance::set_material_override(const Ref<Material>& p_material) {
-
- material_override=p_material;
- VS::get_singleton()->instance_geometry_set_material_override(get_instance(),p_material.is_valid() ? p_material->get_rid() : RID());
+ material_override = p_material;
+ VS::get_singleton()->instance_geometry_set_material_override(get_instance(), p_material.is_valid() ? p_material->get_rid() : RID());
}
-Ref<Material> GeometryInstance::get_material_override() const{
+Ref<Material> GeometryInstance::get_material_override() const {
return material_override;
}
+void GeometryInstance::set_draw_range_begin(float p_dist) {
-
-void GeometryInstance::set_draw_range_begin(float p_dist){
-
- draw_begin=p_dist;
- VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),draw_begin,draw_end);
+ draw_begin = p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(), draw_begin, draw_end);
}
-float GeometryInstance::get_draw_range_begin() const{
+float GeometryInstance::get_draw_range_begin() const {
return draw_begin;
}
-
void GeometryInstance::set_draw_range_end(float p_dist) {
- draw_end=p_dist;
- VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),draw_begin,draw_end);
-
+ draw_end = p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(), draw_begin, draw_end);
}
float GeometryInstance::get_draw_range_end() const {
@@ -198,7 +179,7 @@ float GeometryInstance::get_draw_range_end() const {
void GeometryInstance::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_WORLD) {
+ if (p_what == NOTIFICATION_ENTER_WORLD) {
if (flags[FLAG_USE_BAKED_LIGHT]) {
@@ -207,51 +188,47 @@ void GeometryInstance::_notification(int p_what) {
_update_visibility();
- } else if (p_what==NOTIFICATION_EXIT_WORLD) {
+ } else if (p_what == NOTIFICATION_EXIT_WORLD) {
if (flags[FLAG_USE_BAKED_LIGHT]) {
if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
+ baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed, this, SceneStringNames::get_singleton()->_baked_light_changed);
+ baked_light_instance = NULL;
}
_baked_light_changed();
-
}
-
- } if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ }
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
_update_visibility();
}
-
-
}
void GeometryInstance::_baked_light_changed() {
if (!baked_light_instance)
- VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID());
+ VS::get_singleton()->instance_geometry_set_baked_light(get_instance(), RID());
else
- VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance());
-
+ VS::get_singleton()->instance_geometry_set_baked_light(get_instance(), baked_light_instance->get_baked_light_instance());
}
void GeometryInstance::_find_baked_light() {
- Node *n=get_parent();
- while(n) {
+ Node *n = get_parent();
+ while (n) {
- BakedLightInstance *bl=n->cast_to<BakedLightInstance>();
+ BakedLightInstance *bl = n->cast_to<BakedLightInstance>();
if (bl) {
- baked_light_instance=bl;
- baked_light_instance->connect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
+ baked_light_instance = bl;
+ baked_light_instance->connect(SceneStringNames::get_singleton()->baked_light_changed, this, SceneStringNames::get_singleton()->_baked_light_changed);
_baked_light_changed();
return;
}
- n=n->get_parent();
+ n = n->get_parent();
}
_baked_light_changed();
@@ -263,36 +240,35 @@ void GeometryInstance::_update_visibility() {
return;
_change_notify("geometry/visible");
- VS::get_singleton()->instance_geometry_set_flag(get_instance(),VS::INSTANCE_FLAG_VISIBLE,is_visible() && flags[FLAG_VISIBLE]);
+ VS::get_singleton()->instance_geometry_set_flag(get_instance(), VS::INSTANCE_FLAG_VISIBLE, is_visible() && flags[FLAG_VISIBLE]);
}
-void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
+void GeometryInstance::set_flag(Flags p_flag, bool p_value) {
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- if (p_flag==FLAG_CAST_SHADOW) {
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ if (p_flag == FLAG_CAST_SHADOW) {
if (p_value == true) {
set_cast_shadows_setting(SHADOW_CASTING_SETTING_ON);
- }
- else {
+ } else {
set_cast_shadows_setting(SHADOW_CASTING_SETTING_OFF);
}
}
- if (flags[p_flag]==p_value)
+ if (flags[p_flag] == p_value)
return;
- flags[p_flag]=p_value;
- VS::get_singleton()->instance_geometry_set_flag(get_instance(),(VS::InstanceFlags)p_flag,p_value);
- if (p_flag==FLAG_VISIBLE) {
+ flags[p_flag] = p_value;
+ VS::get_singleton()->instance_geometry_set_flag(get_instance(), (VS::InstanceFlags)p_flag, p_value);
+ if (p_flag == FLAG_VISIBLE) {
_update_visibility();
}
- if (p_flag==FLAG_USE_BAKED_LIGHT) {
+ if (p_flag == FLAG_USE_BAKED_LIGHT) {
if (is_inside_world()) {
if (!p_value) {
if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
+ baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed, this, SceneStringNames::get_singleton()->_baked_light_changed);
+ baked_light_instance = NULL;
}
_baked_light_changed();
} else {
@@ -302,21 +278,19 @@ void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
}
}
-bool GeometryInstance::get_flag(Flags p_flag) const{
+bool GeometryInstance::get_flag(Flags p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
if (p_flag == FLAG_CAST_SHADOW) {
if (shadow_casting_setting == SHADOW_CASTING_SETTING_OFF) {
return false;
- }
- else {
+ } else {
return true;
}
}
return flags[p_flag];
-
}
void GeometryInstance::set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting) {
@@ -333,102 +307,98 @@ GeometryInstance::ShadowCastingSetting GeometryInstance::get_cast_shadows_settin
void GeometryInstance::set_baked_light_texture_id(int p_id) {
- baked_light_texture_id=p_id;
- VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),baked_light_texture_id);
-
+ baked_light_texture_id = p_id;
+ VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(), baked_light_texture_id);
}
-int GeometryInstance::get_baked_light_texture_id() const{
+int GeometryInstance::get_baked_light_texture_id() const {
return baked_light_texture_id;
}
void GeometryInstance::set_extra_cull_margin(float p_margin) {
- ERR_FAIL_COND(p_margin<0);
- extra_cull_margin=p_margin;
- VS::get_singleton()->instance_set_extra_visibility_margin(get_instance(),extra_cull_margin);
+ ERR_FAIL_COND(p_margin < 0);
+ extra_cull_margin = p_margin;
+ VS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin);
}
-float GeometryInstance::get_extra_cull_margin() const{
+float GeometryInstance::get_extra_cull_margin() const {
return extra_cull_margin;
}
void GeometryInstance::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_material_override","material"), &GeometryInstance::set_material_override);
+ ObjectTypeDB::bind_method(_MD("set_material_override", "material"), &GeometryInstance::set_material_override);
ObjectTypeDB::bind_method(_MD("get_material_override"), &GeometryInstance::get_material_override);
- ObjectTypeDB::bind_method(_MD("set_flag","flag","value"), &GeometryInstance::set_flag);
- ObjectTypeDB::bind_method(_MD("get_flag","flag"), &GeometryInstance::get_flag);
+ ObjectTypeDB::bind_method(_MD("set_flag", "flag", "value"), &GeometryInstance::set_flag);
+ ObjectTypeDB::bind_method(_MD("get_flag", "flag"), &GeometryInstance::get_flag);
ObjectTypeDB::bind_method(_MD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance::set_cast_shadows_setting);
ObjectTypeDB::bind_method(_MD("get_cast_shadows_setting"), &GeometryInstance::get_cast_shadows_setting);
- ObjectTypeDB::bind_method(_MD("set_draw_range_begin","mode"), &GeometryInstance::set_draw_range_begin);
+ ObjectTypeDB::bind_method(_MD("set_draw_range_begin", "mode"), &GeometryInstance::set_draw_range_begin);
ObjectTypeDB::bind_method(_MD("get_draw_range_begin"), &GeometryInstance::get_draw_range_begin);
- ObjectTypeDB::bind_method(_MD("set_draw_range_end","mode"), &GeometryInstance::set_draw_range_end);
+ ObjectTypeDB::bind_method(_MD("set_draw_range_end", "mode"), &GeometryInstance::set_draw_range_end);
ObjectTypeDB::bind_method(_MD("get_draw_range_end"), &GeometryInstance::get_draw_range_end);
- ObjectTypeDB::bind_method(_MD("set_baked_light_texture_id","id"), &GeometryInstance::set_baked_light_texture_id);
+ ObjectTypeDB::bind_method(_MD("set_baked_light_texture_id", "id"), &GeometryInstance::set_baked_light_texture_id);
ObjectTypeDB::bind_method(_MD("get_baked_light_texture_id"), &GeometryInstance::get_baked_light_texture_id);
- ObjectTypeDB::bind_method(_MD("set_extra_cull_margin","margin"), &GeometryInstance::set_extra_cull_margin);
+ ObjectTypeDB::bind_method(_MD("set_extra_cull_margin", "margin"), &GeometryInstance::set_extra_cull_margin);
ObjectTypeDB::bind_method(_MD("get_extra_cull_margin"), &GeometryInstance::get_extra_cull_margin);
- ObjectTypeDB::bind_method(_MD("get_aabb"),&GeometryInstance::get_aabb);
+ ObjectTypeDB::bind_method(_MD("get_aabb"), &GeometryInstance::get_aabb);
ObjectTypeDB::bind_method(_MD("_baked_light_changed"), &GeometryInstance::_baked_light_changed);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "geometry/material_override",PROPERTY_HINT_RESOURCE_TYPE,"Material"), _SCS("set_material_override"), _SCS("get_material_override"));
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"), FLAG_VISIBLE);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "geometry/material_override", PROPERTY_HINT_RESOURCE_TYPE, "Material"), _SCS("set_material_override"), _SCS("get_material_override"));
ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry/cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), _SCS("set_cast_shadows_setting"), _SCS("get_cast_shadows_setting"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/receive_shadows"), _SCS("set_flag"), _SCS("get_flag"),FLAG_RECEIVE_SHADOWS);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_begin",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_begin"), _SCS("get_draw_range_begin"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_end",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_end"), _SCS("get_draw_range_end"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "geometry/extra_cull_margin",PROPERTY_HINT_RANGE,"0,16384,0"), _SCS("set_extra_cull_margin"), _SCS("get_extra_cull_margin"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard_y"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD_FIX_Y);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/depth_scale"), _SCS("set_flag"), _SCS("get_flag"),FLAG_DEPH_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible_in_all_rooms"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE_IN_ALL_ROOMS);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/use_baked_light"), _SCS("set_flag"), _SCS("get_flag"),FLAG_USE_BAKED_LIGHT);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/baked_light_tex_id"), _SCS("set_baked_light_texture_id"), _SCS("get_baked_light_texture_id"));
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "geometry/receive_shadows"), _SCS("set_flag"), _SCS("get_flag"), FLAG_RECEIVE_SHADOWS);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry/range_begin", PROPERTY_HINT_RANGE, "0,32768,0.01"), _SCS("set_draw_range_begin"), _SCS("get_draw_range_begin"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry/range_end", PROPERTY_HINT_RANGE, "0,32768,0.01"), _SCS("set_draw_range_end"), _SCS("get_draw_range_end"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "geometry/extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0"), _SCS("set_extra_cull_margin"), _SCS("get_extra_cull_margin"));
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "geometry/billboard"), _SCS("set_flag"), _SCS("get_flag"), FLAG_BILLBOARD);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "geometry/billboard_y"), _SCS("set_flag"), _SCS("get_flag"), FLAG_BILLBOARD_FIX_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "geometry/depth_scale"), _SCS("set_flag"), _SCS("get_flag"), FLAG_DEPH_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "geometry/visible_in_all_rooms"), _SCS("set_flag"), _SCS("get_flag"), FLAG_VISIBLE_IN_ALL_ROOMS);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "geometry/use_baked_light"), _SCS("set_flag"), _SCS("get_flag"), FLAG_USE_BAKED_LIGHT);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry/baked_light_tex_id"), _SCS("set_baked_light_texture_id"), _SCS("get_baked_light_texture_id"));
-// ADD_SIGNAL( MethodInfo("visibility_changed"));
+ // ADD_SIGNAL( MethodInfo("visibility_changed"));
- BIND_CONSTANT(FLAG_VISIBLE );
- BIND_CONSTANT(FLAG_CAST_SHADOW );
- BIND_CONSTANT(FLAG_RECEIVE_SHADOWS );
- BIND_CONSTANT(FLAG_BILLBOARD );
- BIND_CONSTANT(FLAG_BILLBOARD_FIX_Y );
- BIND_CONSTANT(FLAG_DEPH_SCALE );
- BIND_CONSTANT(FLAG_VISIBLE_IN_ALL_ROOMS );
- BIND_CONSTANT(FLAG_MAX );
+ BIND_CONSTANT(FLAG_VISIBLE);
+ BIND_CONSTANT(FLAG_CAST_SHADOW);
+ BIND_CONSTANT(FLAG_RECEIVE_SHADOWS);
+ BIND_CONSTANT(FLAG_BILLBOARD);
+ BIND_CONSTANT(FLAG_BILLBOARD_FIX_Y);
+ BIND_CONSTANT(FLAG_DEPH_SCALE);
+ BIND_CONSTANT(FLAG_VISIBLE_IN_ALL_ROOMS);
+ BIND_CONSTANT(FLAG_MAX);
BIND_CONSTANT(SHADOW_CASTING_SETTING_OFF);
BIND_CONSTANT(SHADOW_CASTING_SETTING_ON);
BIND_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);
BIND_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
-
}
GeometryInstance::GeometryInstance() {
- draw_begin=0;
- draw_end=0;
- for(int i=0;i<FLAG_MAX;i++) {
- flags[i]=false;
+ draw_begin = 0;
+ draw_end = 0;
+ for (int i = 0; i < FLAG_MAX; i++) {
+ flags[i] = false;
}
- flags[FLAG_VISIBLE]=true;
- flags[FLAG_CAST_SHADOW]=true;
- flags[FLAG_RECEIVE_SHADOWS]=true;
- shadow_casting_setting=SHADOW_CASTING_SETTING_ON;
- baked_light_instance=NULL;
- baked_light_texture_id=0;
- extra_cull_margin=0;
- VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
-
-
+ flags[FLAG_VISIBLE] = true;
+ flags[FLAG_CAST_SHADOW] = true;
+ flags[FLAG_RECEIVE_SHADOWS] = true;
+ shadow_casting_setting = SHADOW_CASTING_SETTING_ON;
+ baked_light_instance = NULL;
+ baked_light_texture_id = 0;
+ extra_cull_margin = 0;
+ VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(), 0);
}
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index 1670c4679..9d1921951 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -29,84 +29,77 @@
#ifndef VISUAL_INSTANCE_H
#define VISUAL_INSTANCE_H
-#include "scene/3d/spatial.h"
#include "face3.h"
#include "rid.h"
+#include "scene/3d/spatial.h"
#include "scene/resources/material.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class VisualInstance : public Spatial {
- OBJ_TYPE( VisualInstance, Spatial );
+ OBJ_TYPE(VisualInstance, Spatial);
OBJ_CATEGORY("3D Visual Nodes");
RID instance;
uint32_t layers;
-
RID _get_visual_instance_rid() const;
-
protected:
-
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
enum GetFacesFlags {
- FACES_SOLID=1, // solid geometry
- FACES_ENCLOSING=2,
- FACES_DYNAMIC=4 // dynamic object geometry
+ FACES_SOLID = 1, // solid geometry
+ FACES_ENCLOSING = 2,
+ FACES_DYNAMIC = 4 // dynamic object geometry
};
RID get_instance() const;
- virtual AABB get_aabb() const=0;
- virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const=0;
+ virtual AABB get_aabb() const = 0;
+ virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const = 0;
virtual AABB get_transformed_aabb() const; // helper
- void set_base(const RID& p_base);
+ void set_base(const RID &p_base);
void set_layer_mask(uint32_t p_mask);
uint32_t get_layer_mask() const;
-
VisualInstance();
~VisualInstance();
-
};
class BakedLightInstance;
class GeometryInstance : public VisualInstance {
- OBJ_TYPE( GeometryInstance, VisualInstance );
-public:
+ OBJ_TYPE(GeometryInstance, VisualInstance);
+public:
enum Flags {
- FLAG_VISIBLE=VS::INSTANCE_FLAG_VISIBLE,
- FLAG_CAST_SHADOW=VS::INSTANCE_FLAG_CAST_SHADOW,
- FLAG_RECEIVE_SHADOWS=VS::INSTANCE_FLAG_RECEIVE_SHADOWS,
- FLAG_BILLBOARD=VS::INSTANCE_FLAG_BILLBOARD,
- FLAG_BILLBOARD_FIX_Y=VS::INSTANCE_FLAG_BILLBOARD_FIX_Y,
- FLAG_DEPH_SCALE=VS::INSTANCE_FLAG_DEPH_SCALE,
- FLAG_VISIBLE_IN_ALL_ROOMS=VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
- FLAG_USE_BAKED_LIGHT=VS::INSTANCE_FLAG_USE_BAKED_LIGHT,
- FLAG_MAX=VS::INSTANCE_FLAG_MAX,
+ FLAG_VISIBLE = VS::INSTANCE_FLAG_VISIBLE,
+ FLAG_CAST_SHADOW = VS::INSTANCE_FLAG_CAST_SHADOW,
+ FLAG_RECEIVE_SHADOWS = VS::INSTANCE_FLAG_RECEIVE_SHADOWS,
+ FLAG_BILLBOARD = VS::INSTANCE_FLAG_BILLBOARD,
+ FLAG_BILLBOARD_FIX_Y = VS::INSTANCE_FLAG_BILLBOARD_FIX_Y,
+ FLAG_DEPH_SCALE = VS::INSTANCE_FLAG_DEPH_SCALE,
+ FLAG_VISIBLE_IN_ALL_ROOMS = VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
+ FLAG_USE_BAKED_LIGHT = VS::INSTANCE_FLAG_USE_BAKED_LIGHT,
+ FLAG_MAX = VS::INSTANCE_FLAG_MAX,
};
enum ShadowCastingSetting {
- SHADOW_CASTING_SETTING_OFF=VS::SHADOW_CASTING_SETTING_OFF,
+ SHADOW_CASTING_SETTING_OFF = VS::SHADOW_CASTING_SETTING_OFF,
SHADOW_CASTING_SETTING_ON = VS::SHADOW_CASTING_SETTING_ON,
- SHADOW_CASTING_SETTING_DOUBLE_SIDED=VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED,
- SHADOW_CASTING_SETTING_SHADOWS_ONLY=VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY
+ SHADOW_CASTING_SETTING_DOUBLE_SIDED = VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED,
+ SHADOW_CASTING_SETTING_SHADOWS_ONLY = VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY
};
private:
-
bool flags[FLAG_MAX];
ShadowCastingSetting shadow_casting_setting;
Ref<Material> material_override;
@@ -119,13 +112,13 @@ private:
void _baked_light_changed();
void _update_visibility();
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_flag(Flags p_flag,bool p_value);
+public:
+ void set_flag(Flags p_flag, bool p_value);
bool get_flag(Flags p_flag) const;
void set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting);
@@ -137,7 +130,7 @@ public:
void set_draw_range_end(float p_dist);
float get_draw_range_end() const;
- void set_material_override(const Ref<Material>& p_material);
+ void set_material_override(const Ref<Material> &p_material);
Ref<Material> get_material_override() const;
void set_baked_light_texture_id(int p_id);
@@ -149,8 +142,7 @@ public:
GeometryInstance();
};
-VARIANT_ENUM_CAST( GeometryInstance::Flags );
-VARIANT_ENUM_CAST( GeometryInstance::ShadowCastingSetting );
-
+VARIANT_ENUM_CAST(GeometryInstance::Flags);
+VARIANT_ENUM_CAST(GeometryInstance::ShadowCastingSetting);
#endif
diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp
index b4f0b5501..24e9b9fd1 100644
--- a/scene/animation/animation_cache.cpp
+++ b/scene/animation/animation_cache.cpp
@@ -28,8 +28,6 @@
/*************************************************************************/
#include "animation_cache.h"
-
-
void AnimationCache::_node_exit_tree(Node *p_node) {
//it is one shot, so it disconnects upon arrival
@@ -38,47 +36,41 @@ void AnimationCache::_node_exit_tree(Node *p_node) {
connected_nodes.erase(p_node);
- for(int i=0;i<path_cache.size();i++) {
-
+ for (int i = 0; i < path_cache.size(); i++) {
- if (path_cache[i].node!=p_node)
+ if (path_cache[i].node != p_node)
continue;
- path_cache[i].valid=false; //invalidate path cache
+ path_cache[i].valid = false; //invalidate path cache
}
-
}
void AnimationCache::_animation_changed() {
-
_clear_cache();
}
void AnimationCache::_clear_cache() {
- while(connected_nodes.size()) {
+ while (connected_nodes.size()) {
- connected_nodes.front()->get()->disconnect("exit_tree",this,"_node_exit_tree");
+ connected_nodes.front()->get()->disconnect("exit_tree", this, "_node_exit_tree");
connected_nodes.erase(connected_nodes.front());
}
path_cache.clear();
- cache_valid=false;
- cache_dirty=true;
+ cache_valid = false;
+ cache_dirty = true;
}
-
void AnimationCache::_update_cache() {
- cache_valid=false;
+ cache_valid = false;
ERR_FAIL_COND(!root);
ERR_FAIL_COND(!root->is_inside_tree());
ERR_FAIL_COND(animation.is_null());
- for(int i=0;i<animation->get_track_count();i++) {
-
-
+ for (int i = 0; i < animation->get_track_count(); i++) {
NodePath np = animation->track_get_path(i);
@@ -86,146 +78,127 @@ void AnimationCache::_update_cache() {
if (!node) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Invalid Track Path in Animation: "+np);
+ ERR_EXPLAIN("Invalid Track Path in Animation: " + np);
ERR_CONTINUE(!node);
}
-
Path path;
Ref<Resource> res;
if (np.get_subname_count()) {
-
- if (animation->track_get_type(i)==Animation::TYPE_TRANSFORM) {
+ if (animation->track_get_type(i) == Animation::TYPE_TRANSFORM) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Transform tracks can't have a subpath: "+np);
- ERR_CONTINUE(animation->track_get_type(i)==Animation::TYPE_TRANSFORM);
-
+ ERR_EXPLAIN("Transform tracks can't have a subpath: " + np);
+ ERR_CONTINUE(animation->track_get_type(i) == Animation::TYPE_TRANSFORM);
}
RES res;
- for(int j=0;j<np.get_subname_count();j++) {
- res = j==0 ? node->get(np.get_subname(j)) : res->get(np.get_subname(j));
+ for (int j = 0; j < np.get_subname_count(); j++) {
+ res = j == 0 ? node->get(np.get_subname(j)) : res->get(np.get_subname(j));
if (res.is_null())
break;
-
}
if (res.is_null()) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Invalid Track SubPath in Animation: "+np);
+ ERR_EXPLAIN("Invalid Track SubPath in Animation: " + np);
ERR_CONTINUE(res.is_null());
}
- path.resource=res;
- path.object=res.ptr();
+ path.resource = res;
+ path.object = res.ptr();
} else {
-
- if (animation->track_get_type(i)==Animation::TYPE_TRANSFORM) {
+ if (animation->track_get_type(i) == Animation::TYPE_TRANSFORM) {
StringName property = np.get_property();
String ps = property;
-
Spatial *sp = node->cast_to<Spatial>();
if (!sp) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Transform track not of type Spatial: "+np);
+ ERR_EXPLAIN("Transform track not of type Spatial: " + np);
ERR_CONTINUE(!sp);
}
- if (ps!="") {
+ if (ps != "") {
Skeleton *sk = node->cast_to<Skeleton>();
if (!sk) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton!: "+np);
+ ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton!: " + np);
ERR_CONTINUE(!sk);
}
int idx = sk->find_bone(ps);
- if (idx==-1) {
+ if (idx == -1) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton Bone!: "+np);
- ERR_CONTINUE(idx==-1);
-
+ ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton Bone!: " + np);
+ ERR_CONTINUE(idx == -1);
}
- path.bone_idx=idx;
- path.skeleton=sk;
-
+ path.bone_idx = idx;
+ path.skeleton = sk;
}
- path.spatial=sp;
-
+ path.spatial = sp;
}
- path.node=node;
- path.object=node;
-
+ path.node = node;
+ path.object = node;
}
- if (animation->track_get_type(i)==Animation::TYPE_VALUE) {
+ if (animation->track_get_type(i) == Animation::TYPE_VALUE) {
- if (np.get_property().operator String()=="") {
+ if (np.get_property().operator String() == "") {
path_cache.push_back(Path());
- ERR_EXPLAIN("Value Track lacks property: "+np);
- ERR_CONTINUE(np.get_property().operator String()=="");
-
+ ERR_EXPLAIN("Value Track lacks property: " + np);
+ ERR_CONTINUE(np.get_property().operator String() == "");
}
- path.property=np.get_property();
+ path.property = np.get_property();
- } else if (animation->track_get_type(i)==Animation::TYPE_METHOD) {
+ } else if (animation->track_get_type(i) == Animation::TYPE_METHOD) {
- if (np.get_property().operator String()!="") {
+ if (np.get_property().operator String() != "") {
path_cache.push_back(Path());
- ERR_EXPLAIN("Method Track has property: "+np);
- ERR_CONTINUE(np.get_property().operator String()!="");
-
+ ERR_EXPLAIN("Method Track has property: " + np);
+ ERR_CONTINUE(np.get_property().operator String() != "");
}
-
}
-
- path.valid=true;
+ path.valid = true;
path_cache.push_back(path);
if (!connected_nodes.has(path.node)) {
connected_nodes.insert(path.node);
- path.node->connect("exit_tree",this,"_node_exit_tree",Node::make_binds(path.node),CONNECT_ONESHOT);
+ path.node->connect("exit_tree", this, "_node_exit_tree", Node::make_binds(path.node), CONNECT_ONESHOT);
}
-
-
-
}
-
-
- cache_dirty=false;
- cache_valid=true;
+ cache_dirty = false;
+ cache_valid = true;
}
-void AnimationCache::set_track_transform(int p_idx,const Transform& p_transform) {
+void AnimationCache::set_track_transform(int p_idx, const Transform &p_transform) {
if (cache_dirty)
_update_cache();
ERR_FAIL_COND(!cache_valid);
- ERR_FAIL_INDEX(p_idx,path_cache.size());
+ ERR_FAIL_INDEX(p_idx, path_cache.size());
Path &p = path_cache[p_idx];
if (!p.valid)
return;
@@ -234,47 +207,42 @@ void AnimationCache::set_track_transform(int p_idx,const Transform& p_transform)
ERR_FAIL_COND(!p.spatial);
if (p.skeleton) {
- p.skeleton->set_bone_pose(p.bone_idx,p_transform);
+ p.skeleton->set_bone_pose(p.bone_idx, p_transform);
} else {
p.spatial->set_transform(p_transform);
}
-
}
-void AnimationCache::set_track_value(int p_idx,const Variant& p_value) {
+void AnimationCache::set_track_value(int p_idx, const Variant &p_value) {
if (cache_dirty)
_update_cache();
ERR_FAIL_COND(!cache_valid);
- ERR_FAIL_INDEX(p_idx,path_cache.size());
+ ERR_FAIL_INDEX(p_idx, path_cache.size());
Path &p = path_cache[p_idx];
if (!p.valid)
return;
ERR_FAIL_COND(!p.object);
- p.object->set(p.property,p_value);
+ p.object->set(p.property, p_value);
}
-
-void AnimationCache::call_track(int p_idx,const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error) {
+void AnimationCache::call_track(int p_idx, const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
if (cache_dirty)
_update_cache();
-
ERR_FAIL_COND(!cache_valid);
- ERR_FAIL_INDEX(p_idx,path_cache.size());
+ ERR_FAIL_INDEX(p_idx, path_cache.size());
Path &p = path_cache[p_idx];
if (!p.valid)
return;
ERR_FAIL_COND(!p.object);
- p.object->call(p_method,p_args,p_argcount,r_error);
-
+ p.object->call(p_method, p_args, p_argcount, r_error);
}
-
void AnimationCache::set_all(float p_time, float p_delta) {
if (cache_dirty)
@@ -283,104 +251,100 @@ void AnimationCache::set_all(float p_time, float p_delta) {
ERR_FAIL_COND(!cache_valid);
int tc = animation->get_track_count();
- for(int i=0;i<tc;i++) {
+ for (int i = 0; i < tc; i++) {
- switch(animation->track_get_type(i)) {
+ switch (animation->track_get_type(i)) {
case Animation::TYPE_TRANSFORM: {
- Vector3 loc,scale;
+ Vector3 loc, scale;
Quat rot;
- animation->transform_track_interpolate(i,p_time,&loc,&rot,&scale);
- Transform tr( Matrix3(rot), loc );
+ animation->transform_track_interpolate(i, p_time, &loc, &rot, &scale);
+ Transform tr(Matrix3(rot), loc);
tr.basis.scale(scale);
- set_track_transform(i,tr);
-
+ set_track_transform(i, tr);
} break;
case Animation::TYPE_VALUE: {
- if (animation->value_track_get_update_mode(i)==Animation::UPDATE_CONTINUOUS || (animation->value_track_get_update_mode(i)==Animation::UPDATE_DISCRETE && p_delta==0)) {
- Variant v = animation->value_track_interpolate(i,p_time);
- set_track_value(i,v);
+ if (animation->value_track_get_update_mode(i) == Animation::UPDATE_CONTINUOUS || (animation->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE && p_delta == 0)) {
+ Variant v = animation->value_track_interpolate(i, p_time);
+ set_track_value(i, v);
} else {
List<int> indices;
- animation->value_track_get_key_indices(i,p_time,p_delta,&indices);
+ animation->value_track_get_key_indices(i, p_time, p_delta, &indices);
- for(List<int>::Element *E=indices.front();E;E=E->next()) {
+ for (List<int>::Element *E = indices.front(); E; E = E->next()) {
- Variant v = animation->track_get_key_value(i,E->get());
- set_track_value(i,v);
+ Variant v = animation->track_get_key_value(i, E->get());
+ set_track_value(i, v);
}
-
}
} break;
case Animation::TYPE_METHOD: {
List<int> indices;
- animation->method_track_get_key_indices(i,p_time,p_delta,&indices);
+ animation->method_track_get_key_indices(i, p_time, p_delta, &indices);
- for(List<int>::Element *E=indices.front();E;E=E->next()) {
+ for (List<int>::Element *E = indices.front(); E; E = E->next()) {
- Vector<Variant> args = animation->method_track_get_params(i,E->get());
- StringName name = animation->method_track_get_name(i,E->get());
+ Vector<Variant> args = animation->method_track_get_params(i, E->get());
+ StringName name = animation->method_track_get_name(i, E->get());
Variant::CallError err;
if (!args.size()) {
- call_track(i,name,NULL,0,err);
+ call_track(i, name, NULL, 0, err);
} else {
- Vector<Variant*> argptrs;
+ Vector<Variant *> argptrs;
argptrs.resize(args.size());
- for(int j=0;j<args.size();j++) {
+ for (int j = 0; j < args.size(); j++) {
- argptrs[j]=&args[j];
+ argptrs[j] = &args[j];
}
- call_track(i,name,(const Variant**)&argptrs[0],args.size(),err);
+ call_track(i, name, (const Variant **)&argptrs[0], args.size(), err);
}
-
}
} break;
default: {}
}
}
-
}
-void AnimationCache::set_animation(const Ref<Animation>& p_animation) {
+void AnimationCache::set_animation(const Ref<Animation> &p_animation) {
_clear_cache();
if (animation.is_valid())
- animation->disconnect("changed",this,"_animation_changed");
+ animation->disconnect("changed", this, "_animation_changed");
- animation=p_animation;
+ animation = p_animation;
if (animation.is_valid())
- animation->connect("changed",this,"_animation_changed");
+ animation->connect("changed", this, "_animation_changed");
}
void AnimationCache::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_node_exit_tree"),&AnimationCache::_node_exit_tree);
- ObjectTypeDB::bind_method(_MD("_animation_changed"),&AnimationCache::_animation_changed);
+ ObjectTypeDB::bind_method(_MD("_node_exit_tree"), &AnimationCache::_node_exit_tree);
+ ObjectTypeDB::bind_method(_MD("_animation_changed"), &AnimationCache::_animation_changed);
}
-void AnimationCache::set_root(Node* p_root) {
+void AnimationCache::set_root(Node *p_root) {
_clear_cache();
- root=p_root;
+ root = p_root;
}
AnimationCache::AnimationCache() {
- root=NULL;
- cache_dirty=true;
- cache_valid=false;
+ root = NULL;
+ cache_dirty = true;
+ cache_valid = false;
}
diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h
index d08228f9c..0b1a48c9e 100644
--- a/scene/animation/animation_cache.h
+++ b/scene/animation/animation_cache.h
@@ -29,12 +29,12 @@
#ifndef ANIMATION_CACHE_H
#define ANIMATION_CACHE_H
-#include "scene/resources/animation.h"
#include "scene/3d/skeleton.h"
+#include "scene/resources/animation.h"
class AnimationCache : public Object {
- OBJ_TYPE(AnimationCache,Object);
+ OBJ_TYPE(AnimationCache, Object);
struct Path {
@@ -47,10 +47,17 @@ class AnimationCache : public Object {
int bone_idx;
StringName property;
bool valid;
- Path() { object=NULL; skeleton=NULL; node=NULL; bone_idx=-1; valid=false; spatial=NULL; }
+ Path() {
+ object = NULL;
+ skeleton = NULL;
+ node = NULL;
+ bone_idx = -1;
+ valid = false;
+ spatial = NULL;
+ }
};
- Set<Node*> connected_nodes;
+ Set<Node *> connected_nodes;
Vector<Path> path_cache;
Node *root;
@@ -65,19 +72,17 @@ class AnimationCache : public Object {
void _animation_changed();
protected:
-
static void _bind_methods();
public:
+ void set_track_transform(int p_idx, const Transform &p_transform);
+ void set_track_value(int p_idx, const Variant &p_value);
+ void call_track(int p_idx, const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
- void set_track_transform(int p_idx,const Transform& p_transform);
- void set_track_value(int p_idx,const Variant& p_value);
- void call_track(int p_idx,const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error);
-
- void set_all(float p_time, float p_delta=0);
+ void set_all(float p_time, float p_delta = 0);
- void set_animation(const Ref<Animation>& p_animation);
- void set_root(Node* p_root);
+ void set_animation(const Ref<Animation> &p_animation);
+ void set_root(Node *p_root);
AnimationCache();
};
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 29ed466cb..b285a3526 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -31,111 +31,104 @@
#include "message_queue.h"
#include "scene/scene_string_names.h"
-bool AnimationPlayer::_set(const StringName& p_name, const Variant& p_value) {
+bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) {
- String name=p_name;
+ String name = p_name;
- if (p_name==SceneStringNames::get_singleton()->playback_speed || p_name==SceneStringNames::get_singleton()->speed) { //bw compatibility
+ if (p_name == SceneStringNames::get_singleton()->playback_speed || p_name == SceneStringNames::get_singleton()->speed) { //bw compatibility
set_speed(p_value);
- } else if (p_name==SceneStringNames::get_singleton()->playback_active) {
+ } else if (p_name == SceneStringNames::get_singleton()->playback_active) {
set_active(p_value);
} else if (name.begins_with("playback/play")) {
- String which=p_value;
+ String which = p_value;
-
- if (which=="[stop]")
+ if (which == "[stop]")
stop();
else
play(which);
} else if (name.begins_with("anims/")) {
+ String which = name.get_slicec('/', 1);
- String which=name.get_slicec('/',1);
-
- add_animation(which,p_value);
+ add_animation(which, p_value);
} else if (name.begins_with("next/")) {
+ String which = name.get_slicec('/', 1);
+ animation_set_next(which, p_value);
- String which=name.get_slicec('/',1);
- animation_set_next(which,p_value);
-
- } else if (p_name==SceneStringNames::get_singleton()->blend_times) {
+ } else if (p_name == SceneStringNames::get_singleton()->blend_times) {
- Array array=p_value;
+ Array array = p_value;
int len = array.size();
- ERR_FAIL_COND_V(len%3,false);
+ ERR_FAIL_COND_V(len % 3, false);
+ for (int i = 0; i < len / 3; i++) {
- for(int i=0;i<len/3;i++) {
+ StringName from = array[i * 3 + 0];
+ StringName to = array[i * 3 + 1];
+ float time = array[i * 3 + 2];
- StringName from = array[i*3+0];
- StringName to = array[i*3+1];
- float time = array[i*3+2];
-
- set_blend_time(from,to,time);
+ set_blend_time(from, to, time);
}
- } else if (p_name==SceneStringNames::get_singleton()->autoplay) {
- autoplay=p_value;
+ } else if (p_name == SceneStringNames::get_singleton()->autoplay) {
+ autoplay = p_value;
} else
return false;
return true;
-
}
-bool AnimationPlayer::_get(const StringName& p_name,Variant &r_ret) const {
+bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const {
- String name=p_name;
+ String name = p_name;
- if (name=="playback/speed") { //bw compatibility
+ if (name == "playback/speed") { //bw compatibility
- r_ret=speed_scale;
- } else if (name=="playback/active") {
+ r_ret = speed_scale;
+ } else if (name == "playback/active") {
- r_ret=is_active();
- } else if (name=="playback/play") {
+ r_ret = is_active();
+ } else if (name == "playback/play") {
if (is_active() && is_playing())
- r_ret=playback.assigned;
+ r_ret = playback.assigned;
else
- r_ret="[stop]";
+ r_ret = "[stop]";
} else if (name.begins_with("anims/")) {
- String which=name.get_slicec('/',1);
+ String which = name.get_slicec('/', 1);
- r_ret= get_animation(which).get_ref_ptr();
+ r_ret = get_animation(which).get_ref_ptr();
} else if (name.begins_with("next/")) {
- String which=name.get_slicec('/',1);
-
- r_ret= animation_get_next(which);
+ String which = name.get_slicec('/', 1);
+ r_ret = animation_get_next(which);
- } else if (name=="blend_times") {
+ } else if (name == "blend_times") {
Vector<BlendKey> keys;
- for(Map<BlendKey, float >::Element *E=blend_times.front();E;E=E->next()) {
+ for (Map<BlendKey, float>::Element *E = blend_times.front(); E; E = E->next()) {
keys.ordered_insert(E->key());
}
Array array;
- for(int i=0;i<keys.size();i++) {
+ for (int i = 0; i < keys.size(); i++) {
array.push_back(keys[i].from);
array.push_back(keys[i].to);
array.push_back(blend_times[keys[i]]);
}
- r_ret=array;
- } else if (name=="autoplay") {
- r_ret=autoplay;
-
+ r_ret = array;
+ } else if (name == "autoplay") {
+ r_ret = autoplay;
} else
return false;
@@ -143,26 +136,23 @@ bool AnimationPlayer::_get(const StringName& p_name,Variant &r_ret) const {
return true;
}
-void AnimationPlayer::_get_property_list( List<PropertyInfo> *p_list) const {
-
-
-
+void AnimationPlayer::_get_property_list(List<PropertyInfo> *p_list) const {
List<String> names;
List<PropertyInfo> anim_names;
- for( Map<StringName, AnimationData>::Element *E=animation_set.front();E;E=E->next()) {
+ for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
- anim_names.push_back( PropertyInfo( Variant::OBJECT, "anims/"+String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation",PROPERTY_USAGE_NOEDITOR) );
- if (E->get().next!=StringName())
- anim_names.push_back( PropertyInfo( Variant::STRING, "next/"+String(E->key()), PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR) );
+ anim_names.push_back(PropertyInfo(Variant::OBJECT, "anims/" + String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation", PROPERTY_USAGE_NOEDITOR));
+ if (E->get().next != StringName())
+ anim_names.push_back(PropertyInfo(Variant::STRING, "next/" + String(E->key()), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
names.push_back(E->key());
}
anim_names.sort();
- for( List<PropertyInfo>::Element *E=anim_names.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = anim_names.front(); E; E = E->next()) {
p_list->push_back(E->get());
}
@@ -170,34 +160,30 @@ void AnimationPlayer::_get_property_list( List<PropertyInfo> *p_list) const {
names.sort();
names.push_front("[stop]");
String hint;
- for(List<String>::Element *E=names.front();E;E=E->next()) {
+ for (List<String>::Element *E = names.front(); E; E = E->next()) {
- if (E!=names.front())
- hint+=",";
- hint+=E->get();
+ if (E != names.front())
+ hint += ",";
+ hint += E->get();
}
- p_list->push_back( PropertyInfo( Variant::STRING, "playback/play", PROPERTY_HINT_ENUM, hint,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER) );
- p_list->push_back( PropertyInfo( Variant::BOOL, "playback/active", PROPERTY_HINT_NONE,"" ) );
- p_list->push_back( PropertyInfo( Variant::REAL, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01") );
-
+ p_list->push_back(PropertyInfo(Variant::STRING, "playback/play", PROPERTY_HINT_ENUM, hint, PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "playback/active", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::REAL, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01"));
}
-
-
- p_list->push_back( PropertyInfo( Variant::ARRAY, "blend_times", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR) );
- p_list->push_back( PropertyInfo( Variant::STRING, "autoplay", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR) );
-
+ p_list->push_back(PropertyInfo(Variant::ARRAY, "blend_times", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::STRING, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
}
void AnimationPlayer::advance(float p_time) {
- _animation_process( p_time );
+ _animation_process(p_time);
}
void AnimationPlayer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -218,19 +204,19 @@ void AnimationPlayer::_notification(int p_what) {
}
} break;
case NOTIFICATION_PROCESS: {
- if (animation_process_mode==ANIMATION_PROCESS_FIXED)
+ if (animation_process_mode == ANIMATION_PROCESS_FIXED)
break;
if (processing)
- _animation_process( get_process_delta_time() );
+ _animation_process(get_process_delta_time());
} break;
case NOTIFICATION_FIXED_PROCESS: {
- if (animation_process_mode==ANIMATION_PROCESS_IDLE)
+ if (animation_process_mode == ANIMATION_PROCESS_IDLE)
break;
if (processing)
- _animation_process( get_fixed_process_delta_time() );
+ _animation_process(get_fixed_process_delta_time());
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -240,174 +226,164 @@ void AnimationPlayer::_notification(int p_what) {
}
}
-void AnimationPlayer::_generate_node_caches(AnimationData* p_anim) {
+void AnimationPlayer::_generate_node_caches(AnimationData *p_anim) {
Node *parent = get_node(root);
ERR_FAIL_COND(!parent);
- Animation *a=p_anim->animation.operator->();
+ Animation *a = p_anim->animation.operator->();
- p_anim->node_cache.resize( a->get_track_count() );
+ p_anim->node_cache.resize(a->get_track_count());
- for (int i=0;i<a->get_track_count();i++) {
+ for (int i = 0; i < a->get_track_count(); i++) {
- p_anim->node_cache[i]=NULL;
+ p_anim->node_cache[i] = NULL;
RES resource;
- Node *child = parent->get_node_and_resource(a->track_get_path(i),resource);
+ Node *child = parent->get_node_and_resource(a->track_get_path(i), resource);
if (!child) {
- ERR_EXPLAIN("On Animation: '"+p_anim->name+"', couldn't resolve track: '"+String(a->track_get_path(i))+"'");
+ ERR_EXPLAIN("On Animation: '" + p_anim->name + "', couldn't resolve track: '" + String(a->track_get_path(i)) + "'");
}
ERR_CONTINUE(!child); // couldn't find the child node
- uint32_t id=resource.is_valid()?resource->get_instance_ID():child->get_instance_ID();
- int bone_idx=-1;
+ uint32_t id = resource.is_valid() ? resource->get_instance_ID() : child->get_instance_ID();
+ int bone_idx = -1;
if (a->track_get_path(i).get_property() && child->cast_to<Skeleton>()) {
- bone_idx = child->cast_to<Skeleton>()->find_bone( a->track_get_path(i).get_property() );
- if (bone_idx==-1) {
+ bone_idx = child->cast_to<Skeleton>()->find_bone(a->track_get_path(i).get_property());
+ if (bone_idx == -1) {
continue;
}
}
{
- if (!child->is_connected("exit_tree",this,"_node_removed"))
- child->connect("exit_tree",this,"_node_removed",make_binds(child),CONNECT_ONESHOT);
+ if (!child->is_connected("exit_tree", this, "_node_removed"))
+ child->connect("exit_tree", this, "_node_removed", make_binds(child), CONNECT_ONESHOT);
}
TrackNodeCacheKey key;
- key.id=id;
- key.bone_idx=bone_idx;
-
+ key.id = id;
+ key.bone_idx = bone_idx;
if (node_cache_map.has(key)) {
- p_anim->node_cache[i]=&node_cache_map[key];
+ p_anim->node_cache[i] = &node_cache_map[key];
} else {
+ node_cache_map[key] = TrackNodeCache();
- node_cache_map[key]=TrackNodeCache();
-
- p_anim->node_cache[i]=&node_cache_map[key];
- p_anim->node_cache[i]->path=a->track_get_path(i);
- p_anim->node_cache[i]->node=child;
- p_anim->node_cache[i]->resource=resource;
- p_anim->node_cache[i]->node_2d=child->cast_to<Node2D>();
- if (a->track_get_type(i)==Animation::TYPE_TRANSFORM) {
+ p_anim->node_cache[i] = &node_cache_map[key];
+ p_anim->node_cache[i]->path = a->track_get_path(i);
+ p_anim->node_cache[i]->node = child;
+ p_anim->node_cache[i]->resource = resource;
+ p_anim->node_cache[i]->node_2d = child->cast_to<Node2D>();
+ if (a->track_get_type(i) == Animation::TYPE_TRANSFORM) {
// special cases and caches for transform tracks
// cache spatial
- p_anim->node_cache[i]->spatial=child->cast_to<Spatial>();
+ p_anim->node_cache[i]->spatial = child->cast_to<Spatial>();
// cache skeleton
- p_anim->node_cache[i]->skeleton=child->cast_to<Skeleton>();
+ p_anim->node_cache[i]->skeleton = child->cast_to<Skeleton>();
if (p_anim->node_cache[i]->skeleton) {
- StringName bone_name=a->track_get_path(i).get_property();
- if (bone_name.operator String()!="") {
+ StringName bone_name = a->track_get_path(i).get_property();
+ if (bone_name.operator String() != "") {
- p_anim->node_cache[i]->bone_idx=p_anim->node_cache[i]->skeleton->find_bone(bone_name);
- if (p_anim->node_cache[i]->bone_idx<0) {
+ p_anim->node_cache[i]->bone_idx = p_anim->node_cache[i]->skeleton->find_bone(bone_name);
+ if (p_anim->node_cache[i]->bone_idx < 0) {
// broken track (nonexistent bone)
- p_anim->node_cache[i]->skeleton=NULL;
- p_anim->node_cache[i]->spatial=NULL;
+ p_anim->node_cache[i]->skeleton = NULL;
+ p_anim->node_cache[i]->spatial = NULL;
printf("bone is %ls\n", String(bone_name).c_str());
- ERR_CONTINUE( p_anim->node_cache[i]->bone_idx<0 );
+ ERR_CONTINUE(p_anim->node_cache[i]->bone_idx < 0);
} else {
}
} else {
// no property, just use spatialnode
- p_anim->node_cache[i]->skeleton=NULL;
+ p_anim->node_cache[i]->skeleton = NULL;
}
-
}
}
}
- if (a->track_get_type(i)==Animation::TYPE_VALUE) {
+ if (a->track_get_type(i) == Animation::TYPE_VALUE) {
StringName property = a->track_get_path(i).get_property();
if (!p_anim->node_cache[i]->property_anim.has(property)) {
TrackNodeCache::PropertyAnim pa;
- pa.prop=property;
- pa.object=resource.is_valid()?(Object*)resource.ptr():(Object*)child;
- pa.special=SP_NONE;
- pa.owner=p_anim->node_cache[i];
+ pa.prop = property;
+ pa.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child;
+ pa.special = SP_NONE;
+ pa.owner = p_anim->node_cache[i];
if (false && p_anim->node_cache[i]->node_2d) {
- if (pa.prop==SceneStringNames::get_singleton()->transform_pos)
- pa.special=SP_NODE2D_POS;
- else if (pa.prop==SceneStringNames::get_singleton()->transform_rot)
- pa.special=SP_NODE2D_ROT;
- else if (pa.prop==SceneStringNames::get_singleton()->transform_scale)
- pa.special=SP_NODE2D_SCALE;
+ if (pa.prop == SceneStringNames::get_singleton()->transform_pos)
+ pa.special = SP_NODE2D_POS;
+ else if (pa.prop == SceneStringNames::get_singleton()->transform_rot)
+ pa.special = SP_NODE2D_ROT;
+ else if (pa.prop == SceneStringNames::get_singleton()->transform_scale)
+ pa.special = SP_NODE2D_SCALE;
}
- p_anim->node_cache[i]->property_anim[property]=pa;
+ p_anim->node_cache[i]->property_anim[property] = pa;
}
}
}
}
-
-void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p_time, float p_delta,float p_interp, bool p_allow_discrete) {
+void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float p_time, float p_delta, float p_interp, bool p_allow_discrete) {
if (p_anim->node_cache.size() != p_anim->animation->get_track_count()) {
// animation hasn't been "node-cached"
_generate_node_caches(p_anim);
}
+ ERR_FAIL_COND(p_anim->node_cache.size() != p_anim->animation->get_track_count());
- ERR_FAIL_COND( p_anim->node_cache.size() != p_anim->animation->get_track_count() );
-
-
- Animation *a=p_anim->animation.operator->();
+ Animation *a = p_anim->animation.operator->();
bool can_call = is_inside_tree() && !get_tree()->is_editor_hint();
- for (int i=0;i<a->get_track_count();i++) {
+ for (int i = 0; i < a->get_track_count(); i++) {
- TrackNodeCache *nc=p_anim->node_cache[i];
+ TrackNodeCache *nc = p_anim->node_cache[i];
if (!nc) // no node cache for this track, skip it
continue;
- if (a->track_get_key_count(i)==0)
+ if (a->track_get_key_count(i) == 0)
continue; // do nothing if track is empty
- switch(a->track_get_type(i)) {
+ switch (a->track_get_type(i)) {
case Animation::TYPE_TRANSFORM: {
if (!nc->spatial)
continue;
-
Vector3 loc;
Quat rot;
Vector3 scale;
-
- Error err = a->transform_track_interpolate(i,p_time,&loc,&rot,&scale);
+ Error err = a->transform_track_interpolate(i, p_time, &loc, &rot, &scale);
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
-
- if (err!=OK)
+ if (err != OK)
continue;
- if (nc->accum_pass!=accum_pass) {
- ERR_CONTINUE( cache_update_size >= NODE_CACHE_UPDATE_MAX );
- cache_update[cache_update_size++]=nc;
- nc->accum_pass=accum_pass;
- nc->loc_accum=loc;
- nc->rot_accum=rot;
- nc->scale_accum=scale;
+ if (nc->accum_pass != accum_pass) {
+ ERR_CONTINUE(cache_update_size >= NODE_CACHE_UPDATE_MAX);
+ cache_update[cache_update_size++] = nc;
+ nc->accum_pass = accum_pass;
+ nc->loc_accum = loc;
+ nc->rot_accum = rot;
+ nc->scale_accum = scale;
} else {
- nc->loc_accum=nc->loc_accum.linear_interpolate(loc,p_interp);
- nc->rot_accum=nc->rot_accum.slerp(rot,p_interp);
- nc->scale_accum=nc->scale_accum.linear_interpolate(scale,p_interp);
-
+ nc->loc_accum = nc->loc_accum.linear_interpolate(loc, p_interp);
+ nc->rot_accum = nc->rot_accum.slerp(rot, p_interp);
+ nc->scale_accum = nc->scale_accum.linear_interpolate(scale, p_interp);
}
} break;
@@ -418,80 +394,74 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p
//StringName property=a->track_get_path(i).get_property();
- Map<StringName,TrackNodeCache::PropertyAnim>::Element *E=nc->property_anim.find(a->track_get_path(i).get_property());
+ Map<StringName, TrackNodeCache::PropertyAnim>::Element *E = nc->property_anim.find(a->track_get_path(i).get_property());
ERR_CONTINUE(!E); //should it continue, or create a new one?
TrackNodeCache::PropertyAnim *pa = &E->get();
+ if (a->value_track_get_update_mode(i) == Animation::UPDATE_CONTINUOUS || (p_delta == 0 && a->value_track_get_update_mode(i) == Animation::UPDATE_DISCRETE)) { //delta == 0 means seek
- if (a->value_track_get_update_mode(i)==Animation::UPDATE_CONTINUOUS || (p_delta==0 && a->value_track_get_update_mode(i)==Animation::UPDATE_DISCRETE)) { //delta == 0 means seek
-
-
- Variant value=a->value_track_interpolate(i,p_time);
+ Variant value = a->value_track_interpolate(i, p_time);
//thanks to trigger mode, this should be solved now..
//if (p_delta==0 && value.get_type()==Variant::STRING)
// continue; // doing this with strings is messy, should find another way
- if (pa->accum_pass!=accum_pass) {
- ERR_CONTINUE( cache_update_prop_size >= NODE_CACHE_UPDATE_MAX );
- cache_update_prop[cache_update_prop_size++]=pa;
- pa->value_accum=value;
- pa->accum_pass=accum_pass;
+ if (pa->accum_pass != accum_pass) {
+ ERR_CONTINUE(cache_update_prop_size >= NODE_CACHE_UPDATE_MAX);
+ cache_update_prop[cache_update_prop_size++] = pa;
+ pa->value_accum = value;
+ pa->accum_pass = accum_pass;
} else {
- Variant::interpolate(pa->value_accum,value,p_interp,pa->value_accum);
+ Variant::interpolate(pa->value_accum, value, p_interp, pa->value_accum);
}
-
- } else if (p_allow_discrete && p_delta!=0) {
+ } else if (p_allow_discrete && p_delta != 0) {
List<int> indices;
- a->value_track_get_key_indices(i,p_time,p_delta,&indices);
-
+ a->value_track_get_key_indices(i, p_time, p_delta, &indices);
- for(List<int>::Element *F=indices.front();F;F=F->next()) {
+ for (List<int>::Element *F = indices.front(); F; F = F->next()) {
- Variant value=a->track_get_key_value(i,F->get());
- switch(pa->special) {
+ Variant value = a->track_get_key_value(i, F->get());
+ switch (pa->special) {
case SP_NONE: {
bool valid;
- pa->object->set(pa->prop,value,&valid); //you are not speshul
+ pa->object->set(pa->prop, value, &valid); //you are not speshul
#ifdef DEBUG_ENABLED
if (!valid) {
- ERR_PRINTS("Failed setting track value '"+String(pa->owner->path)+"'. Check if property exists or the type of key is valid");
+ ERR_PRINTS("Failed setting track value '" + String(pa->owner->path) + "'. Check if property exists or the type of key is valid");
}
#endif
} break;
case SP_NODE2D_POS: {
#ifdef DEBUG_ENABLED
- if (value.get_type()!=Variant::VECTOR2) {
- ERR_PRINTS("Position key at time "+rtos(p_time)+" in Animation Track '"+String(pa->owner->path)+"' not of type Vector2()");
+ if (value.get_type() != Variant::VECTOR2) {
+ ERR_PRINTS("Position key at time " + rtos(p_time) + " in Animation Track '" + String(pa->owner->path) + "' not of type Vector2()");
}
#endif
- static_cast<Node2D*>(pa->object)->set_pos(value);
+ static_cast<Node2D *>(pa->object)->set_pos(value);
} break;
case SP_NODE2D_ROT: {
#ifdef DEBUG_ENABLED
if (value.is_num()) {
- ERR_PRINTS("Rotation key at time "+rtos(p_time)+" in Animation Track '"+String(pa->owner->path)+"' not numerical");
+ ERR_PRINTS("Rotation key at time " + rtos(p_time) + " in Animation Track '" + String(pa->owner->path) + "' not numerical");
}
#endif
- static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(value));
+ static_cast<Node2D *>(pa->object)->set_rot(Math::deg2rad(value));
} break;
case SP_NODE2D_SCALE: {
#ifdef DEBUG_ENABLED
- if (value.get_type()!=Variant::VECTOR2) {
- ERR_PRINTS("Scale key at time "+rtos(p_time)+" in Animation Track '"+String(pa->owner->path)+"' not of type Vector2()");
+ if (value.get_type() != Variant::VECTOR2) {
+ ERR_PRINTS("Scale key at time " + rtos(p_time) + " in Animation Track '" + String(pa->owner->path) + "' not of type Vector2()");
}
#endif
- static_cast<Node2D*>(pa->object)->set_scale(value);
+ static_cast<Node2D *>(pa->object)->set_scale(value);
} break;
}
-
}
-
}
} break;
@@ -499,163 +469,150 @@ void AnimationPlayer::_animation_process_animation(AnimationData* p_anim,float p
if (!nc->node)
continue;
- if (p_delta==0)
+ if (p_delta == 0)
continue;
if (!p_allow_discrete)
break;
List<int> indices;
- a->method_track_get_key_indices(i,p_time,p_delta,&indices);
+ a->method_track_get_key_indices(i, p_time, p_delta, &indices);
- for(List<int>::Element *E=indices.front();E;E=E->next()) {
+ for (List<int>::Element *E = indices.front(); E; E = E->next()) {
- StringName method=a->method_track_get_name(i,E->get());
- Vector<Variant> params=a->method_track_get_params(i,E->get());
+ StringName method = a->method_track_get_name(i, E->get());
+ Vector<Variant> params = a->method_track_get_params(i, E->get());
- int s=params.size();
+ int s = params.size();
- ERR_CONTINUE( s > VARIANT_ARG_MAX );
+ ERR_CONTINUE(s > VARIANT_ARG_MAX);
if (can_call) {
MessageQueue::get_singleton()->push_call(
- nc->node,
- method,
- s>=1 ? params[0] : Variant(),
- s>=2 ? params[1] : Variant(),
- s>=3 ? params[2] : Variant(),
- s>=4 ? params[3] : Variant(),
- s>=5 ? params[4] : Variant()
- );
+ nc->node,
+ method,
+ s >= 1 ? params[0] : Variant(),
+ s >= 2 ? params[1] : Variant(),
+ s >= 3 ? params[2] : Variant(),
+ s >= 4 ? params[3] : Variant(),
+ s >= 5 ? params[4] : Variant());
}
}
-
} break;
}
}
}
-void AnimationPlayer::_animation_process_data(PlaybackData &cd,float p_delta,float p_blend) {
+void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, float p_blend) {
- float delta=p_delta*speed_scale*cd.speed_scale;
- bool backwards=delta<0;
- float next_pos=cd.pos+delta;
+ float delta = p_delta * speed_scale * cd.speed_scale;
+ bool backwards = delta < 0;
+ float next_pos = cd.pos + delta;
- float len=cd.from->animation->get_length();
- bool loop=cd.from->animation->has_loop();
+ float len = cd.from->animation->get_length();
+ bool loop = cd.from->animation->has_loop();
if (!loop) {
- if (next_pos<0)
- next_pos=0;
- else if (next_pos>len)
- next_pos=len;
+ if (next_pos < 0)
+ next_pos = 0;
+ else if (next_pos > len)
+ next_pos = len;
// fix delta
- delta=next_pos-cd.pos;
+ delta = next_pos - cd.pos;
if (&cd == &playback.current) {
- if (!backwards && cd.pos < len && next_pos==len /*&& playback.blend.empty()*/) {
+ if (!backwards && cd.pos < len && next_pos == len /*&& playback.blend.empty()*/) {
//playback finished
- end_notify=true;
+ end_notify = true;
}
- if (backwards && cd.pos > 0 && next_pos==0 /*&& playback.blend.empty()*/) {
+ if (backwards && cd.pos > 0 && next_pos == 0 /*&& playback.blend.empty()*/) {
//playback finished
- end_notify=true;
+ end_notify = true;
}
-
}
} else {
- next_pos=Math::fposmod(next_pos,len);
-
+ next_pos = Math::fposmod(next_pos, len);
}
- cd.pos=next_pos;
-
- _animation_process_animation(cd.from,cd.pos,delta,p_blend,&cd == &playback.current);
-
-
+ cd.pos = next_pos;
+ _animation_process_animation(cd.from, cd.pos, delta, p_blend, &cd == &playback.current);
}
void AnimationPlayer::_animation_process2(float p_delta) {
+ Playback &c = playback;
- Playback &c=playback;
-
- float prev_blend=1.0;
+ float prev_blend = 1.0;
accum_pass++;
- int pop_count=1;
- int pop=0; // if >0, then amount of elements to pop from the back
-
+ int pop_count = 1;
+ int pop = 0; // if >0, then amount of elements to pop from the back
- for (List<Blend>::Element *E=c.blend.back();E;E=E->prev(),pop_count++) {
+ for (List<Blend>::Element *E = c.blend.back(); E; E = E->prev(), pop_count++) {
- Blend& b=E->get();
- _animation_process_data(b.data,p_delta,prev_blend);
+ Blend &b = E->get();
+ _animation_process_data(b.data, p_delta, prev_blend);
- prev_blend=1.0-b.blend_left/b.blend_time;
+ prev_blend = 1.0 - b.blend_left / b.blend_time;
- b.blend_left-=Math::absf(speed_scale*p_delta);
+ b.blend_left -= Math::absf(speed_scale * p_delta);
- if (b.blend_left<0) {
+ if (b.blend_left < 0) {
- pop=pop_count;
+ pop = pop_count;
}
}
- while(pop--) {
+ while (pop--) {
c.blend.pop_back();
}
-
- _animation_process_data(c.current,p_delta,prev_blend);
-
+ _animation_process_data(c.current, p_delta, prev_blend);
}
void AnimationPlayer::_animation_update_transforms() {
+ for (int i = 0; i < cache_update_size; i++) {
- for (int i=0;i<cache_update_size;i++) {
-
- TrackNodeCache *nc=cache_update[i];
+ TrackNodeCache *nc = cache_update[i];
- ERR_CONTINUE( nc->accum_pass!=accum_pass );
+ ERR_CONTINUE(nc->accum_pass != accum_pass);
if (nc->spatial) {
Transform t;
- t.origin=nc->loc_accum;
- t.basis=nc->rot_accum;
- t.basis.scale( nc->scale_accum );
+ t.origin = nc->loc_accum;
+ t.basis = nc->rot_accum;
+ t.basis.scale(nc->scale_accum);
- if (nc->skeleton && nc->bone_idx>=0) {
+ if (nc->skeleton && nc->bone_idx >= 0) {
- nc->skeleton->set_bone_pose( nc->bone_idx, t );
+ nc->skeleton->set_bone_pose(nc->bone_idx, t);
} else if (nc->spatial) {
nc->spatial->set_transform(t);
}
}
-
}
- cache_update_size=0;
+ cache_update_size = 0;
- for (int i=0;i<cache_update_prop_size;i++) {
+ for (int i = 0; i < cache_update_prop_size; i++) {
- TrackNodeCache::PropertyAnim *pa=cache_update_prop[i];
+ TrackNodeCache::PropertyAnim *pa = cache_update_prop[i];
- ERR_CONTINUE( pa->accum_pass!=accum_pass );
+ ERR_CONTINUE(pa->accum_pass != accum_pass);
#if 1
-/* switch(pa->special) {
+ /* switch(pa->special) {
case SP_NONE: pa->object->set(pa->prop,pa->value_accum); break; //you are not speshul
@@ -664,63 +621,61 @@ void AnimationPlayer::_animation_update_transforms() {
case SP_NODE2D_SCALE: static_cast<Node2D*>(pa->object)->set_scale(pa->value_accum); break;
}*/
- switch(pa->special) {
+ switch (pa->special) {
case SP_NONE: {
bool valid;
- pa->object->set(pa->prop,pa->value_accum,&valid); //you are not speshul
+ pa->object->set(pa->prop, pa->value_accum, &valid); //you are not speshul
#ifdef DEBUG_ENABLED
if (!valid) {
- ERR_PRINTS("Failed setting key at time "+rtos(playback.current.pos)+" in Animation '"+get_current_animation()+"', Track '"+String(pa->owner->path)+"'. Check if property exists or the type of key is right for the property");
+ ERR_PRINTS("Failed setting key at time " + rtos(playback.current.pos) + " in Animation '" + get_current_animation() + "', Track '" + String(pa->owner->path) + "'. Check if property exists or the type of key is right for the property");
}
#endif
} break;
case SP_NODE2D_POS: {
#ifdef DEBUG_ENABLED
- if (pa->value_accum.get_type()!=Variant::VECTOR2) {
- ERR_PRINTS("Position key at time "+rtos(playback.current.pos)+" in Animation '"+get_current_animation()+"', Track '"+String(pa->owner->path)+"' not of type Vector2()");
+ if (pa->value_accum.get_type() != Variant::VECTOR2) {
+ ERR_PRINTS("Position key at time " + rtos(playback.current.pos) + " in Animation '" + get_current_animation() + "', Track '" + String(pa->owner->path) + "' not of type Vector2()");
}
#endif
- static_cast<Node2D*>(pa->object)->set_pos(pa->value_accum);
+ static_cast<Node2D *>(pa->object)->set_pos(pa->value_accum);
} break;
case SP_NODE2D_ROT: {
#ifdef DEBUG_ENABLED
if (pa->value_accum.is_num()) {
- ERR_PRINTS("Rotation key at time "+rtos(playback.current.pos)+" in Animation '"+get_current_animation()+"', Track '"+String(pa->owner->path)+"' not numerical");
+ ERR_PRINTS("Rotation key at time " + rtos(playback.current.pos) + " in Animation '" + get_current_animation() + "', Track '" + String(pa->owner->path) + "' not numerical");
}
#endif
- static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(pa->value_accum));
+ static_cast<Node2D *>(pa->object)->set_rot(Math::deg2rad(pa->value_accum));
} break;
case SP_NODE2D_SCALE: {
#ifdef DEBUG_ENABLED
- if (pa->value_accum.get_type()!=Variant::VECTOR2) {
- ERR_PRINTS("Scale key at time "+rtos(playback.current.pos)+" in Animation '"+get_current_animation()+"', Track '"+String(pa->owner->path)+"' not of type Vector2()");
+ if (pa->value_accum.get_type() != Variant::VECTOR2) {
+ ERR_PRINTS("Scale key at time " + rtos(playback.current.pos) + " in Animation '" + get_current_animation() + "', Track '" + String(pa->owner->path) + "' not of type Vector2()");
}
#endif
- static_cast<Node2D*>(pa->object)->set_scale(pa->value_accum);
+ static_cast<Node2D *>(pa->object)->set_scale(pa->value_accum);
} break;
}
#else
- pa->object->set(pa->prop,pa->value_accum);
+ pa->object->set(pa->prop, pa->value_accum);
#endif
}
- cache_update_prop_size=0;
+ cache_update_prop_size = 0;
}
void AnimationPlayer::_animation_process(float p_delta) {
-
-
-// bool any_active=false;
+ // bool any_active=false;
if (playback.current.from) {
- end_notify=false;
+ end_notify = false;
_animation_process2(p_delta);
_animation_update_transforms();
if (end_notify) {
@@ -729,13 +684,13 @@ void AnimationPlayer::_animation_process(float p_delta) {
play(queued.front()->get());
String new_name = playback.assigned;
queued.pop_front();
- end_notify=false;
+ end_notify = false;
emit_signal(SceneStringNames::get_singleton()->animation_changed, old, new_name);
} else {
- //stop();
+ //stop();
playing = false;
_set_process(false);
- end_notify=false;
+ end_notify = false;
emit_signal(SceneStringNames::get_singleton()->finished);
}
}
@@ -743,32 +698,30 @@ void AnimationPlayer::_animation_process(float p_delta) {
} else {
_set_process(false);
}
-
}
-
-Error AnimationPlayer::add_animation(const StringName& p_name, const Ref<Animation>& p_animation) {
+Error AnimationPlayer::add_animation(const StringName &p_name, const Ref<Animation> &p_animation) {
#ifdef DEBUG_ENABLED
- ERR_EXPLAIN("Invalid animation name: "+String(p_name));
- ERR_FAIL_COND_V( String(p_name).find("/")!=-1 || String(p_name).find(":")!=-1 || String(p_name).find(",")!=-1 || String(p_name).find("[")!=-1, ERR_INVALID_PARAMETER );
+ ERR_EXPLAIN("Invalid animation name: " + String(p_name));
+ ERR_FAIL_COND_V(String(p_name).find("/") != -1 || String(p_name).find(":") != -1 || String(p_name).find(",") != -1 || String(p_name).find("[") != -1, ERR_INVALID_PARAMETER);
#endif
- ERR_FAIL_COND_V( p_animation.is_null() , ERR_INVALID_PARAMETER );
+ ERR_FAIL_COND_V(p_animation.is_null(), ERR_INVALID_PARAMETER);
//print_line("Add anim: "+String(p_name)+" name: "+p_animation->get_name());
if (animation_set.has(p_name)) {
_unref_anim(animation_set[p_name].animation);
- animation_set[p_name].animation=p_animation;
+ animation_set[p_name].animation = p_animation;
clear_caches();
} else {
AnimationData ad;
- ad.animation=p_animation;
- ad.name=p_name;
- animation_set[p_name]=ad;
+ ad.animation = p_animation;
+ ad.name = p_name;
+ animation_set[p_name] = ad;
}
_ref_anim(p_animation);
@@ -776,9 +729,9 @@ Error AnimationPlayer::add_animation(const StringName& p_name, const Ref<Animati
return OK;
}
-void AnimationPlayer::remove_animation(const StringName& p_name) {
+void AnimationPlayer::remove_animation(const StringName &p_name) {
- ERR_FAIL_COND(!animation_set.has(p_name) );
+ ERR_FAIL_COND(!animation_set.has(p_name));
stop_all();
_unref_anim(animation_set[p_name].animation);
@@ -786,154 +739,140 @@ void AnimationPlayer::remove_animation(const StringName& p_name) {
clear_caches();
_change_notify();
-
}
-void AnimationPlayer::_ref_anim(const Ref<Animation>& p_anim) {
+void AnimationPlayer::_ref_anim(const Ref<Animation> &p_anim) {
if (used_anims.has(p_anim))
used_anims[p_anim]++;
else {
- used_anims[p_anim]=1;
- Ref<Animation>(p_anim)->connect("changed",this,"_animation_changed");
+ used_anims[p_anim] = 1;
+ Ref<Animation>(p_anim)->connect("changed", this, "_animation_changed");
}
-
}
-void AnimationPlayer::_unref_anim(const Ref<Animation>& p_anim) {
+void AnimationPlayer::_unref_anim(const Ref<Animation> &p_anim) {
ERR_FAIL_COND(!used_anims.has(p_anim));
-
- int & n = used_anims[p_anim];
+ int &n = used_anims[p_anim];
n--;
- if (n==0) {
+ if (n == 0) {
- Ref<Animation>(p_anim)->disconnect("changed",this,"_animation_changed");
+ Ref<Animation>(p_anim)->disconnect("changed", this, "_animation_changed");
used_anims.erase(p_anim);
}
-
}
+void AnimationPlayer::rename_animation(const StringName &p_name, const StringName &p_new_name) {
-void AnimationPlayer::rename_animation(const StringName& p_name,const StringName& p_new_name) {
-
-
- ERR_FAIL_COND(!animation_set.has(p_name) );
- ERR_FAIL_COND( String(p_new_name).find("/")!=-1 || String(p_new_name).find(":")!=-1 );
- ERR_FAIL_COND( animation_set.has(p_new_name) );
+ ERR_FAIL_COND(!animation_set.has(p_name));
+ ERR_FAIL_COND(String(p_new_name).find("/") != -1 || String(p_new_name).find(":") != -1);
+ ERR_FAIL_COND(animation_set.has(p_new_name));
//print_line("Rename anim: "+String(p_name)+" name: "+String(p_new_name));
stop_all();
AnimationData ad = animation_set[p_name];
- ad.name=p_new_name;
+ ad.name = p_new_name;
animation_set.erase(p_name);
- animation_set[p_new_name]=ad;
+ animation_set[p_new_name] = ad;
List<BlendKey> to_erase;
- Map<BlendKey,float> to_insert;
- for(Map<BlendKey, float >::Element *E=blend_times.front();E;E=E->next()) {
+ Map<BlendKey, float> to_insert;
+ for (Map<BlendKey, float>::Element *E = blend_times.front(); E; E = E->next()) {
- BlendKey bk=E->key();
- BlendKey new_bk=bk;
- bool erase=false;
- if (bk.from==p_name) {
- new_bk.from=p_new_name;
- erase=true;
+ BlendKey bk = E->key();
+ BlendKey new_bk = bk;
+ bool erase = false;
+ if (bk.from == p_name) {
+ new_bk.from = p_new_name;
+ erase = true;
}
- if (bk.to==p_name) {
- new_bk.to=p_new_name;
- erase=true;
+ if (bk.to == p_name) {
+ new_bk.to = p_new_name;
+ erase = true;
}
if (erase) {
to_erase.push_back(bk);
- to_insert[new_bk]=E->get();
+ to_insert[new_bk] = E->get();
}
}
- while(to_erase.size()) {
+ while (to_erase.size()) {
blend_times.erase(to_erase.front()->get());
to_erase.pop_front();
}
- while(to_insert.size()) {
- blend_times[to_insert.front()->key()]=to_insert.front()->get();
+ while (to_insert.size()) {
+ blend_times[to_insert.front()->key()] = to_insert.front()->get();
to_insert.erase(to_insert.front());
}
- if (autoplay==p_name)
- autoplay=p_new_name;
+ if (autoplay == p_name)
+ autoplay = p_new_name;
clear_caches();
_change_notify();
}
-
-bool AnimationPlayer::has_animation(const StringName& p_name) const {
+bool AnimationPlayer::has_animation(const StringName &p_name) const {
return animation_set.has(p_name);
}
-Ref<Animation> AnimationPlayer::get_animation(const StringName& p_name) const {
+Ref<Animation> AnimationPlayer::get_animation(const StringName &p_name) const {
- ERR_FAIL_COND_V( !animation_set.has(p_name), Ref<Animation>() );
+ ERR_FAIL_COND_V(!animation_set.has(p_name), Ref<Animation>());
- const AnimationData& data = animation_set[p_name];
+ const AnimationData &data = animation_set[p_name];
return data.animation;
-
}
-void AnimationPlayer::get_animation_list( List<StringName> * p_animations) const {
+void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const {
List<String> anims;
- for( Map<StringName, AnimationData>::Element *E=animation_set.front();E;E=E->next()) {
+ for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
anims.push_back(E->key());
}
anims.sort();
- for(List<String>::Element *E=anims.front();E;E=E->next()) {
+ for (List<String>::Element *E = anims.front(); E; E = E->next()) {
p_animations->push_back(E->get());
}
-
}
-void AnimationPlayer::set_blend_time(const StringName& p_animation1, const StringName& p_animation2, float p_time) {
+void AnimationPlayer::set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time) {
- ERR_FAIL_COND(p_time<0);
+ ERR_FAIL_COND(p_time < 0);
BlendKey bk;
- bk.from=p_animation1;
- bk.to=p_animation2;
- if (p_time==0)
+ bk.from = p_animation1;
+ bk.to = p_animation2;
+ if (p_time == 0)
blend_times.erase(bk);
else
- blend_times[bk]=p_time;
-
+ blend_times[bk] = p_time;
}
-
-float AnimationPlayer::get_blend_time( const StringName& p_animation1, const StringName& p_animation2) const {
+float AnimationPlayer::get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const {
BlendKey bk;
- bk.from=p_animation1;
- bk.to=p_animation2;
+ bk.from = p_animation1;
+ bk.to = p_animation2;
if (blend_times.has(bk))
return blend_times[bk];
else
return 0;
-
-
}
-
-void AnimationPlayer::queue(const StringName& p_name) {
+void AnimationPlayer::queue(const StringName &p_name) {
if (!is_playing())
play(p_name);
@@ -945,73 +884,73 @@ void AnimationPlayer::clear_queue() {
queued.clear();
};
-void AnimationPlayer::play_backwards(const StringName& p_name,float p_custom_blend) {
+void AnimationPlayer::play_backwards(const StringName &p_name, float p_custom_blend) {
- play(p_name,p_custom_blend,-1,true);
+ play(p_name, p_custom_blend, -1, true);
}
-void AnimationPlayer::play(const StringName& p_name, float p_custom_blend, float p_custom_scale,bool p_from_end) {
+void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float p_custom_scale, bool p_from_end) {
//printf("animation is %ls\n", String(p_name).c_str());
//ERR_FAIL_COND(!is_inside_scene());
- StringName name=p_name;
+ StringName name = p_name;
- if (String(name)=="")
- name=playback.assigned;
+ if (String(name) == "")
+ name = playback.assigned;
if (!animation_set.has(name)) {
- ERR_EXPLAIN("Animation not found: "+name);
+ ERR_EXPLAIN("Animation not found: " + name);
ERR_FAIL();
}
- Playback &c=playback;
+ Playback &c = playback;
if (c.current.from) {
- float blend_time=0;
+ float blend_time = 0;
// find if it can blend
BlendKey bk;
- bk.from=c.current.from->name;
- bk.to=name;
+ bk.from = c.current.from->name;
+ bk.to = name;
- if (p_custom_blend>=0) {
- blend_time=p_custom_blend;
+ if (p_custom_blend >= 0) {
+ blend_time = p_custom_blend;
} else if (blend_times.has(bk)) {
- blend_time=blend_times[bk];
+ blend_time = blend_times[bk];
} else {
- bk.from="*";
+ bk.from = "*";
if (blend_times.has(bk)) {
- blend_time=blend_times[bk];
+ blend_time = blend_times[bk];
} else {
- bk.from=c.current.from->name;
- bk.to="*";
+ bk.from = c.current.from->name;
+ bk.to = "*";
if (blend_times.has(bk)) {
- blend_time=blend_times[bk];
+ blend_time = blend_times[bk];
}
}
}
- if (p_custom_blend<0 && blend_time==0 && default_blend_time)
- blend_time=default_blend_time;
- if (blend_time>0) {
+ if (p_custom_blend < 0 && blend_time == 0 && default_blend_time)
+ blend_time = default_blend_time;
+ if (blend_time > 0) {
Blend b;
- b.data=c.current;
- b.blend_time=b.blend_left=blend_time;
+ b.data = c.current;
+ b.blend_time = b.blend_left = blend_time;
c.blend.push_back(b);
}
}
- c.current.from=&animation_set[name];
- c.current.pos=p_from_end ? c.current.from->animation->get_length() : 0;
- c.current.speed_scale=p_custom_scale;
- c.assigned=p_name;
+ c.current.from = &animation_set[name];
+ c.current.pos = p_from_end ? c.current.from->animation->get_length() : 0;
+ c.current.speed_scale = p_custom_scale;
+ c.assigned = p_name;
if (!end_notify)
queued.clear();
@@ -1020,20 +959,19 @@ void AnimationPlayer::play(const StringName& p_name, float p_custom_blend, float
emit_signal(SceneStringNames::get_singleton()->animation_started, c.assigned);
- if (is_inside_tree() && get_tree()->is_editor_hint())
+ if (is_inside_tree() && get_tree()->is_editor_hint())
return; // no next in this case
-
- StringName next=animation_get_next(p_name);
- if (next!=StringName() && animation_set.has(next)) {
+ StringName next = animation_get_next(p_name);
+ if (next != StringName() && animation_set.has(next)) {
queue(next);
}
}
bool AnimationPlayer::is_playing() const {
- return playing;
- /*
+ return playing;
+ /*
if (playback.current.from==NULL)
return false;
@@ -1047,30 +985,29 @@ bool AnimationPlayer::is_playing() const {
return true;
*/
}
-void AnimationPlayer::set_current_animation(const String& p_anim) {
+void AnimationPlayer::set_current_animation(const String &p_anim) {
if (is_playing()) {
play(p_anim);
} else {
ERR_FAIL_COND(!animation_set.has(p_anim));
- playback.current.pos=0;
- playback.current.from=&animation_set[p_anim];
- playback.assigned=p_anim;
+ playback.current.pos = 0;
+ playback.current.from = &animation_set[p_anim];
+ playback.assigned = p_anim;
}
}
String AnimationPlayer::get_current_animation() const {
return (playback.assigned);
-
}
void AnimationPlayer::stop(bool p_reset) {
- Playback &c=playback;
+ Playback &c = playback;
c.blend.clear();
if (p_reset) {
- c.current.from=NULL;
+ c.current.from = NULL;
}
_set_process(false);
queued.clear();
@@ -1082,22 +1019,18 @@ void AnimationPlayer::stop_all() {
stop();
_set_process(false); // always process when starting an animation
-
}
void AnimationPlayer::set_speed(float p_speed) {
- speed_scale=p_speed;
-
-
+ speed_scale = p_speed;
}
float AnimationPlayer::get_speed() const {
return speed_scale;
}
-void AnimationPlayer::seek(float p_time,bool p_update) {
-
+void AnimationPlayer::seek(float p_time, bool p_update) {
if (!playback.current.from) {
if (playback.assigned)
@@ -1105,13 +1038,13 @@ void AnimationPlayer::seek(float p_time,bool p_update) {
ERR_FAIL_COND(!playback.current.from);
}
- playback.current.pos=p_time;
+ playback.current.pos = p_time;
if (p_update) {
_animation_process(0);
}
}
-void AnimationPlayer::seek_delta(float p_time,float p_delta) {
+void AnimationPlayer::seek_delta(float p_time, float p_delta) {
if (!playback.current.from) {
if (playback.assigned)
@@ -1119,30 +1052,27 @@ void AnimationPlayer::seek_delta(float p_time,float p_delta) {
ERR_FAIL_COND(!playback.current.from);
}
-
- playback.current.pos=p_time-p_delta;
- if (speed_scale!=0.0)
- p_delta/=speed_scale;
+ playback.current.pos = p_time - p_delta;
+ if (speed_scale != 0.0)
+ p_delta /= speed_scale;
_animation_process(p_delta);
//playback.current.pos=p_time;
-
}
bool AnimationPlayer::is_valid() const {
return (playback.current.from);
-
}
float AnimationPlayer::get_current_animation_pos() const {
- ERR_FAIL_COND_V(!playback.current.from,0);
+ ERR_FAIL_COND_V(!playback.current.from, 0);
return playback.current.pos;
}
float AnimationPlayer::get_current_animation_length() const {
- ERR_FAIL_COND_V(!playback.current.from,0);
+ ERR_FAIL_COND_V(!playback.current.from, 0);
return playback.current.from->animation->get_length();
}
@@ -1158,27 +1088,24 @@ void AnimationPlayer::_node_removed(Node *p_node) {
void AnimationPlayer::clear_caches() {
-
node_cache_map.clear();
- for( Map<StringName, AnimationData>::Element *E=animation_set.front();E;E=E->next()) {
+ for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
E->get().node_cache.clear();
}
- cache_update_size=0;
- cache_update_prop_size=0;
+ cache_update_size = 0;
+ cache_update_prop_size = 0;
}
void AnimationPlayer::set_active(bool p_active) {
- if (active==p_active)
+ if (active == p_active)
return;
- active=p_active;
- _set_process(processing,true);
-
-
+ active = p_active;
+ _set_process(processing, true);
}
bool AnimationPlayer::is_active() const {
@@ -1186,90 +1113,85 @@ bool AnimationPlayer::is_active() const {
return active;
}
-StringName AnimationPlayer::find_animation(const Ref<Animation>& p_animation) const {
+StringName AnimationPlayer::find_animation(const Ref<Animation> &p_animation) const {
- for( Map<StringName, AnimationData>::Element *E=animation_set.front();E;E=E->next()) {
+ for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
- if (E->get().animation==p_animation)
+ if (E->get().animation == p_animation)
return E->key();
}
return "";
}
-void AnimationPlayer::set_autoplay(const String& p_name) {
+void AnimationPlayer::set_autoplay(const String &p_name) {
- autoplay=p_name;
+ autoplay = p_name;
}
-String AnimationPlayer::get_autoplay() const{
+String AnimationPlayer::get_autoplay() const {
return autoplay;
}
void AnimationPlayer::set_animation_process_mode(AnimationProcessMode p_mode) {
- if (animation_process_mode==p_mode)
+ if (animation_process_mode == p_mode)
return;
bool pr = processing;
if (pr)
_set_process(false);
- animation_process_mode=p_mode;
+ animation_process_mode = p_mode;
if (pr)
_set_process(true);
-
}
-AnimationPlayer::AnimationProcessMode AnimationPlayer::get_animation_process_mode() const{
+AnimationPlayer::AnimationProcessMode AnimationPlayer::get_animation_process_mode() const {
return animation_process_mode;
}
+void AnimationPlayer::_set_process(bool p_process, bool p_force) {
-void AnimationPlayer::_set_process(bool p_process,bool p_force) {
-
- if (processing==p_process && !p_force)
+ if (processing == p_process && !p_force)
return;
- switch(animation_process_mode) {
+ switch (animation_process_mode) {
case ANIMATION_PROCESS_FIXED: set_fixed_process(p_process && active); break;
case ANIMATION_PROCESS_IDLE: set_process(p_process && active); break;
}
- processing=p_process;
+ processing = p_process;
}
-void AnimationPlayer::animation_set_next(const StringName& p_animation, const StringName& p_next) {
+void AnimationPlayer::animation_set_next(const StringName &p_animation, const StringName &p_next) {
ERR_FAIL_COND(!animation_set.has(p_animation));
- animation_set[p_animation].next=p_next;
-
+ animation_set[p_animation].next = p_next;
}
-StringName AnimationPlayer::animation_get_next(const StringName& p_animation) const{
+StringName AnimationPlayer::animation_get_next(const StringName &p_animation) const {
if (!animation_set.has(p_animation))
return StringName();
return animation_set[p_animation].next;
-
}
void AnimationPlayer::set_default_blend_time(float p_default) {
- default_blend_time=p_default;
+ default_blend_time = p_default;
}
float AnimationPlayer::get_default_blend_time() const {
- return default_blend_time;
+ return default_blend_time;
}
+void AnimationPlayer::set_root(const NodePath &p_root) {
-void AnimationPlayer::set_root(const NodePath& p_root) {
-
- root=p_root;
+ root = p_root;
clear_caches();
}
@@ -1278,110 +1200,104 @@ NodePath AnimationPlayer::get_root() const {
return root;
}
-void AnimationPlayer::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
+void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
String pf = p_function;
- if (p_function=="play" || p_function=="remove_animation" || p_function=="has_animation" || p_function=="queue") {
+ if (p_function == "play" || p_function == "remove_animation" || p_function == "has_animation" || p_function == "queue") {
List<StringName> al;
get_animation_list(&al);
- for (List<StringName>::Element *E=al.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = al.front(); E; E = E->next()) {
- r_options->push_back("\""+String(E->get())+"\"");
+ r_options->push_back("\"" + String(E->get()) + "\"");
}
}
- Node::get_argument_options(p_function,p_idx,r_options);
+ Node::get_argument_options(p_function, p_idx, r_options);
}
void AnimationPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_node_removed"),&AnimationPlayer::_node_removed);
- ObjectTypeDB::bind_method(_MD("_animation_changed"),&AnimationPlayer::_animation_changed);
+ ObjectTypeDB::bind_method(_MD("_node_removed"), &AnimationPlayer::_node_removed);
+ ObjectTypeDB::bind_method(_MD("_animation_changed"), &AnimationPlayer::_animation_changed);
- ObjectTypeDB::bind_method(_MD("add_animation","name","animation:Animation"),&AnimationPlayer::add_animation);
- ObjectTypeDB::bind_method(_MD("remove_animation","name"),&AnimationPlayer::remove_animation);
- ObjectTypeDB::bind_method(_MD("rename_animation","name","newname"),&AnimationPlayer::rename_animation);
- ObjectTypeDB::bind_method(_MD("has_animation","name"),&AnimationPlayer::has_animation);
- ObjectTypeDB::bind_method(_MD("get_animation:Animation","name"),&AnimationPlayer::get_animation);
- ObjectTypeDB::bind_method(_MD("get_animation_list"),&AnimationPlayer::_get_animation_list);
+ ObjectTypeDB::bind_method(_MD("add_animation", "name", "animation:Animation"), &AnimationPlayer::add_animation);
+ ObjectTypeDB::bind_method(_MD("remove_animation", "name"), &AnimationPlayer::remove_animation);
+ ObjectTypeDB::bind_method(_MD("rename_animation", "name", "newname"), &AnimationPlayer::rename_animation);
+ ObjectTypeDB::bind_method(_MD("has_animation", "name"), &AnimationPlayer::has_animation);
+ ObjectTypeDB::bind_method(_MD("get_animation:Animation", "name"), &AnimationPlayer::get_animation);
+ ObjectTypeDB::bind_method(_MD("get_animation_list"), &AnimationPlayer::_get_animation_list);
ObjectTypeDB::bind_method(_MD("animation_set_next", "anim_from", "anim_to"), &AnimationPlayer::animation_set_next);
ObjectTypeDB::bind_method(_MD("animation_get_next", "anim_from"), &AnimationPlayer::animation_get_next);
- ObjectTypeDB::bind_method(_MD("set_blend_time","anim_from","anim_to","sec"),&AnimationPlayer::set_blend_time);
- ObjectTypeDB::bind_method(_MD("get_blend_time","anim_from","anim_to"),&AnimationPlayer::get_blend_time);
+ ObjectTypeDB::bind_method(_MD("set_blend_time", "anim_from", "anim_to", "sec"), &AnimationPlayer::set_blend_time);
+ ObjectTypeDB::bind_method(_MD("get_blend_time", "anim_from", "anim_to"), &AnimationPlayer::get_blend_time);
- ObjectTypeDB::bind_method(_MD("set_default_blend_time","sec"),&AnimationPlayer::set_default_blend_time);
- ObjectTypeDB::bind_method(_MD("get_default_blend_time"),&AnimationPlayer::get_default_blend_time);
+ ObjectTypeDB::bind_method(_MD("set_default_blend_time", "sec"), &AnimationPlayer::set_default_blend_time);
+ ObjectTypeDB::bind_method(_MD("get_default_blend_time"), &AnimationPlayer::get_default_blend_time);
- ObjectTypeDB::bind_method(_MD("play","name","custom_blend","custom_speed","from_end"),&AnimationPlayer::play,DEFVAL(""),DEFVAL(-1),DEFVAL(1.0),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("play_backwards","name","custom_blend"),&AnimationPlayer::play_backwards,DEFVAL(""),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("stop","reset"),&AnimationPlayer::stop,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("stop_all"),&AnimationPlayer::stop_all);
- ObjectTypeDB::bind_method(_MD("is_playing"),&AnimationPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_current_animation","anim"),&AnimationPlayer::set_current_animation);
- ObjectTypeDB::bind_method(_MD("get_current_animation"),&AnimationPlayer::get_current_animation);
- ObjectTypeDB::bind_method(_MD("queue","name"),&AnimationPlayer::queue);
- ObjectTypeDB::bind_method(_MD("clear_queue"),&AnimationPlayer::clear_queue);
+ ObjectTypeDB::bind_method(_MD("play", "name", "custom_blend", "custom_speed", "from_end"), &AnimationPlayer::play, DEFVAL(""), DEFVAL(-1), DEFVAL(1.0), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("play_backwards", "name", "custom_blend"), &AnimationPlayer::play_backwards, DEFVAL(""), DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("stop", "reset"), &AnimationPlayer::stop, DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("stop_all"), &AnimationPlayer::stop_all);
+ ObjectTypeDB::bind_method(_MD("is_playing"), &AnimationPlayer::is_playing);
+ ObjectTypeDB::bind_method(_MD("set_current_animation", "anim"), &AnimationPlayer::set_current_animation);
+ ObjectTypeDB::bind_method(_MD("get_current_animation"), &AnimationPlayer::get_current_animation);
+ ObjectTypeDB::bind_method(_MD("queue", "name"), &AnimationPlayer::queue);
+ ObjectTypeDB::bind_method(_MD("clear_queue"), &AnimationPlayer::clear_queue);
- ObjectTypeDB::bind_method(_MD("set_active","active"),&AnimationPlayer::set_active);
- ObjectTypeDB::bind_method(_MD("is_active"),&AnimationPlayer::is_active);
+ ObjectTypeDB::bind_method(_MD("set_active", "active"), &AnimationPlayer::set_active);
+ ObjectTypeDB::bind_method(_MD("is_active"), &AnimationPlayer::is_active);
- ObjectTypeDB::bind_method(_MD("set_speed","speed"),&AnimationPlayer::set_speed);
- ObjectTypeDB::bind_method(_MD("get_speed"),&AnimationPlayer::get_speed);
+ ObjectTypeDB::bind_method(_MD("set_speed", "speed"), &AnimationPlayer::set_speed);
+ ObjectTypeDB::bind_method(_MD("get_speed"), &AnimationPlayer::get_speed);
- ObjectTypeDB::bind_method(_MD("set_autoplay","name"),&AnimationPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("get_autoplay"),&AnimationPlayer::get_autoplay);
+ ObjectTypeDB::bind_method(_MD("set_autoplay", "name"), &AnimationPlayer::set_autoplay);
+ ObjectTypeDB::bind_method(_MD("get_autoplay"), &AnimationPlayer::get_autoplay);
- ObjectTypeDB::bind_method(_MD("set_root","path"),&AnimationPlayer::set_root);
- ObjectTypeDB::bind_method(_MD("get_root"),&AnimationPlayer::get_root);
+ ObjectTypeDB::bind_method(_MD("set_root", "path"), &AnimationPlayer::set_root);
+ ObjectTypeDB::bind_method(_MD("get_root"), &AnimationPlayer::get_root);
- ObjectTypeDB::bind_method(_MD("seek","pos_sec","update"),&AnimationPlayer::seek,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_pos"),&AnimationPlayer::get_current_animation_pos);
+ ObjectTypeDB::bind_method(_MD("seek", "pos_sec", "update"), &AnimationPlayer::seek, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_pos"), &AnimationPlayer::get_current_animation_pos);
- ObjectTypeDB::bind_method(_MD("find_animation","animation:Animation"),&AnimationPlayer::find_animation);
+ ObjectTypeDB::bind_method(_MD("find_animation", "animation:Animation"), &AnimationPlayer::find_animation);
- ObjectTypeDB::bind_method(_MD("clear_caches"),&AnimationPlayer::clear_caches);
+ ObjectTypeDB::bind_method(_MD("clear_caches"), &AnimationPlayer::clear_caches);
- ObjectTypeDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationPlayer::set_animation_process_mode);
- ObjectTypeDB::bind_method(_MD("get_animation_process_mode"),&AnimationPlayer::get_animation_process_mode);
+ ObjectTypeDB::bind_method(_MD("set_animation_process_mode", "mode"), &AnimationPlayer::set_animation_process_mode);
+ ObjectTypeDB::bind_method(_MD("get_animation_process_mode"), &AnimationPlayer::get_animation_process_mode);
- ObjectTypeDB::bind_method(_MD("get_current_animation_pos"),&AnimationPlayer::get_current_animation_pos);
- ObjectTypeDB::bind_method(_MD("get_current_animation_length"),&AnimationPlayer::get_current_animation_length);
+ ObjectTypeDB::bind_method(_MD("get_current_animation_pos"), &AnimationPlayer::get_current_animation_pos);
+ ObjectTypeDB::bind_method(_MD("get_current_animation_length"), &AnimationPlayer::get_current_animation_length);
- ObjectTypeDB::bind_method(_MD("advance","delta"),&AnimationPlayer::advance);
+ ObjectTypeDB::bind_method(_MD("advance", "delta"), &AnimationPlayer::advance);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "playback/default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time"));
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root/root"), _SCS("set_root"), _SCS("get_root"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "playback/default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_default_blend_time"), _SCS("get_default_blend_time"));
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "root/root"), _SCS("set_root"), _SCS("get_root"));
+ ADD_SIGNAL(MethodInfo("finished"));
+ ADD_SIGNAL(MethodInfo("animation_changed", PropertyInfo(Variant::STRING, "old_name"), PropertyInfo(Variant::STRING, "new_name")));
+ ADD_SIGNAL(MethodInfo("animation_started", PropertyInfo(Variant::STRING, "name")));
- ADD_SIGNAL( MethodInfo("finished") );
- ADD_SIGNAL( MethodInfo("animation_changed", PropertyInfo(Variant::STRING,"old_name"), PropertyInfo(Variant::STRING,"new_name")) );
- ADD_SIGNAL( MethodInfo("animation_started", PropertyInfo(Variant::STRING,"name")) );
-
- BIND_CONSTANT( ANIMATION_PROCESS_FIXED );
- BIND_CONSTANT( ANIMATION_PROCESS_IDLE );
+ BIND_CONSTANT(ANIMATION_PROCESS_FIXED);
+ BIND_CONSTANT(ANIMATION_PROCESS_IDLE);
}
AnimationPlayer::AnimationPlayer() {
-
- accum_pass=1;
- cache_update_size=0;
- cache_update_prop_size=0;
- speed_scale=1;
- end_notify=false;
- animation_process_mode=ANIMATION_PROCESS_IDLE;
- processing=false;
- default_blend_time=0;
- root=SceneStringNames::get_singleton()->path_pp;
+ accum_pass = 1;
+ cache_update_size = 0;
+ cache_update_prop_size = 0;
+ speed_scale = 1;
+ end_notify = false;
+ animation_process_mode = ANIMATION_PROCESS_IDLE;
+ processing = false;
+ default_blend_time = 0;
+ root = SceneStringNames::get_singleton()->path_pp;
playing = false;
- active=true;
+ active = true;
}
-
-AnimationPlayer::~AnimationPlayer()
-{
+AnimationPlayer::~AnimationPlayer() {
}
-
-
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index 935c4167a..b6796bad9 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -29,35 +29,31 @@
#ifndef ANIMATION_PLAYER_H
#define ANIMATION_PLAYER_H
-
-#include "scene/resources/animation.h"
-#include "scene/3d/spatial.h"
-#include "scene/3d/skeleton.h"
#include "scene/2d/node_2d.h"
+#include "scene/3d/skeleton.h"
+#include "scene/3d/spatial.h"
+#include "scene/resources/animation.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class AnimationPlayer : public Node {
- OBJ_TYPE( AnimationPlayer, Node );
+ OBJ_TYPE(AnimationPlayer, Node);
OBJ_CATEGORY("Animation Nodes");
public:
-
enum AnimationProcessMode {
ANIMATION_PROCESS_FIXED,
ANIMATION_PROCESS_IDLE,
};
private:
-
enum {
- NODE_CACHE_UPDATE_MAX=1024,
- BLEND_FROM_MAX=3
+ NODE_CACHE_UPDATE_MAX = 1024,
+ BLEND_FROM_MAX = 3
};
-
enum SpecialProperty {
SP_NONE,
SP_NODE2D_POS,
@@ -71,8 +67,8 @@ private:
uint32_t id;
RES resource;
Node *node;
- Spatial* spatial;
- Node2D* node_2d;
+ Spatial *spatial;
+ Node2D *node_2d;
Skeleton *skeleton;
int bone_idx;
// accumulated transforms
@@ -90,14 +86,22 @@ private:
Object *object;
Variant value_accum;
uint64_t accum_pass;
- PropertyAnim() { accum_pass=0; object=NULL; }
+ PropertyAnim() {
+ accum_pass = 0;
+ object = NULL;
+ }
};
- Map<StringName,PropertyAnim> property_anim;
-
-
- TrackNodeCache() { skeleton=NULL; spatial=NULL; node=NULL; accum_pass=0; bone_idx=-1; node_2d=NULL; }
+ Map<StringName, PropertyAnim> property_anim;
+ TrackNodeCache() {
+ skeleton = NULL;
+ spatial = NULL;
+ node = NULL;
+ accum_pass = 0;
+ bone_idx = -1;
+ node_2d = NULL;
+ }
};
struct TrackNodeCacheKey {
@@ -105,36 +109,34 @@ private:
uint32_t id;
int bone_idx;
- inline bool operator<(const TrackNodeCacheKey& p_right) const {
+ inline bool operator<(const TrackNodeCacheKey &p_right) const {
- if (id<p_right.id)
+ if (id < p_right.id)
return true;
- else if (id>p_right.id)
+ else if (id > p_right.id)
return false;
else
- return bone_idx<p_right.bone_idx;
+ return bone_idx < p_right.bone_idx;
}
};
- Map<TrackNodeCacheKey,TrackNodeCache> node_cache_map;
+ Map<TrackNodeCacheKey, TrackNodeCache> node_cache_map;
- TrackNodeCache* cache_update[NODE_CACHE_UPDATE_MAX];
+ TrackNodeCache *cache_update[NODE_CACHE_UPDATE_MAX];
int cache_update_size;
- TrackNodeCache::PropertyAnim* cache_update_prop[NODE_CACHE_UPDATE_MAX];
+ TrackNodeCache::PropertyAnim *cache_update_prop[NODE_CACHE_UPDATE_MAX];
int cache_update_prop_size;
- Map<Ref<Animation>,int> used_anims;
+ Map<Ref<Animation>, int> used_anims;
uint64_t accum_pass;
- float speed_scale;
- float default_blend_time;
-
+ float speed_scale;
+ float default_blend_time;
struct AnimationData {
String name;
StringName next;
- Vector<TrackNodeCache*> node_cache;
+ Vector<TrackNodeCache *> node_cache;
Ref<Animation> animation;
-
};
Map<StringName, AnimationData> animation_set;
@@ -142,27 +144,23 @@ private:
StringName from;
StringName to;
- bool operator<(const BlendKey& bk) const { return from==bk.from?String(to)<String(bk.to):String(from)<String(bk.from); }
+ bool operator<(const BlendKey &bk) const { return from == bk.from ? String(to) < String(bk.to) : String(from) < String(bk.from); }
};
-
- Map<BlendKey, float > blend_times;
-
+ Map<BlendKey, float> blend_times;
struct PlaybackData {
- AnimationData* from;
+ AnimationData *from;
float pos;
float speed_scale;
PlaybackData() {
- pos=0;
- speed_scale=1.0;
- from=NULL;
-
+ pos = 0;
+ speed_scale = 1.0;
+ from = NULL;
}
-
};
struct Blend {
@@ -174,8 +172,8 @@ private:
Blend() {
- blend_left=0;
- blend_time=0;
+ blend_left = 0;
+ blend_time = 0;
}
};
@@ -197,75 +195,73 @@ private:
NodePath root;
- void _animation_process_animation(AnimationData* p_anim,float p_time, float p_delta,float p_interp, bool p_allow_discrete=true);
+ void _animation_process_animation(AnimationData *p_anim, float p_time, float p_delta, float p_interp, bool p_allow_discrete = true);
- void _generate_node_caches(AnimationData* p_anim);
- void _animation_process_data(PlaybackData &cd,float p_delta,float p_blend);
+ void _generate_node_caches(AnimationData *p_anim);
+ void _animation_process_data(PlaybackData &cd, float p_delta, float p_blend);
void _animation_process2(float p_delta);
void _animation_update_transforms();
void _animation_process(float p_delta);
void _node_removed(Node *p_node);
-// bind helpers
+ // bind helpers
DVector<String> _get_animation_list() const {
List<StringName> animations;
get_animation_list(&animations);
DVector<String> ret;
- while(animations.size()) {
+ while (animations.size()) {
- ret.push_back( animations.front()->get());
+ ret.push_back(animations.front()->get());
animations.pop_front();
}
return ret;
}
void _animation_changed();
- void _ref_anim(const Ref<Animation>& p_anim);
- void _unref_anim(const Ref<Animation>& p_anim);
+ void _ref_anim(const Ref<Animation> &p_anim);
+ void _unref_anim(const Ref<Animation> &p_anim);
+ void _set_process(bool p_process, bool p_force = false);
- void _set_process(bool p_process,bool p_force=false);
-
- bool playing;
+ bool playing;
protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
+ StringName find_animation(const Ref<Animation> &p_animation) const;
- StringName find_animation(const Ref<Animation>& p_animation) const;
-
- Error add_animation(const StringName& p_name, const Ref<Animation>& p_animation);
- void remove_animation(const StringName& p_name);
- void rename_animation(const StringName& p_name,const StringName& p_new_name);
- bool has_animation(const StringName& p_name) const;
- Ref<Animation> get_animation(const StringName& p_name) const;
- void get_animation_list( List<StringName> * p_animations) const;
+ Error add_animation(const StringName &p_name, const Ref<Animation> &p_animation);
+ void remove_animation(const StringName &p_name);
+ void rename_animation(const StringName &p_name, const StringName &p_new_name);
+ bool has_animation(const StringName &p_name) const;
+ Ref<Animation> get_animation(const StringName &p_name) const;
+ void get_animation_list(List<StringName> *p_animations) const;
- void set_blend_time(const StringName& p_animation1, const StringName& p_animation2, float p_time);
- float get_blend_time( const StringName& p_animation1, const StringName& p_animation2) const;
+ void set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time);
+ float get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const;
- void animation_set_next(const StringName& p_animation, const StringName& p_next);
- StringName animation_get_next(const StringName& p_animation) const;
+ void animation_set_next(const StringName &p_animation, const StringName &p_next);
+ StringName animation_get_next(const StringName &p_animation) const;
- void set_default_blend_time(float p_default);
- float get_default_blend_time() const;
+ void set_default_blend_time(float p_default);
+ float get_default_blend_time() const;
- void play(const StringName& p_name=StringName(),float p_custom_blend=-1,float p_custom_scale=1.0,bool p_from_end=false);
- void play_backwards(const StringName& p_name=StringName(),float p_custom_blend=-1);
- void queue(const StringName& p_name);
+ void play(const StringName &p_name = StringName(), float p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false);
+ void play_backwards(const StringName &p_name = StringName(), float p_custom_blend = -1);
+ void queue(const StringName &p_name);
void clear_queue();
- void stop(bool p_reset=true);
+ void stop(bool p_reset = true);
bool is_playing() const;
String get_current_animation() const;
- void set_current_animation(const String& p_anim);
+ void set_current_animation(const String &p_anim);
void stop_all();
void set_active(bool p_active);
bool is_active() const;
@@ -274,34 +270,30 @@ public:
void set_speed(float p_speed);
float get_speed() const;
- void set_autoplay(const String& pname);
+ void set_autoplay(const String &pname);
String get_autoplay() const;
void set_animation_process_mode(AnimationProcessMode p_mode);
AnimationProcessMode get_animation_process_mode() const;
- void seek(float p_time,bool p_update=false);
- void seek_delta(float p_time,float p_delta);
+ void seek(float p_time, bool p_update = false);
+ void seek_delta(float p_time, float p_delta);
float get_current_animation_pos() const;
float get_current_animation_length() const;
void advance(float p_time);
- void set_root(const NodePath& p_root);
+ void set_root(const NodePath &p_root);
NodePath get_root() const;
void clear_caches(); ///< must be called by hand if an animation was modified after added
- void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
-
+ void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
AnimationPlayer();
~AnimationPlayer();
-
};
-
-VARIANT_ENUM_CAST( AnimationPlayer::AnimationProcessMode );
-
+VARIANT_ENUM_CAST(AnimationPlayer::AnimationProcessMode);
#endif
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index 0c450f40e..992ee7da9 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -31,7 +31,6 @@
#include "scene/scene_string_names.h"
-
void AnimationTreePlayer::set_animation_process_mode(AnimationProcessMode p_mode) {
if (animation_process_mode == p_mode)
@@ -43,322 +42,312 @@ void AnimationTreePlayer::set_animation_process_mode(AnimationProcessMode p_mode
animation_process_mode = p_mode;
if (pr)
_set_process(true);
-
}
-AnimationTreePlayer::AnimationProcessMode AnimationTreePlayer::get_animation_process_mode() const{
+AnimationTreePlayer::AnimationProcessMode AnimationTreePlayer::get_animation_process_mode() const {
return animation_process_mode;
}
-void AnimationTreePlayer::_set_process(bool p_process, bool p_force)
-{
+void AnimationTreePlayer::_set_process(bool p_process, bool p_force) {
if (processing == p_process && !p_force)
return;
switch (animation_process_mode) {
- case ANIMATION_PROCESS_FIXED: set_fixed_process(p_process && active); break;
- case ANIMATION_PROCESS_IDLE: set_process(p_process && active); break;
+ case ANIMATION_PROCESS_FIXED: set_fixed_process(p_process && active); break;
+ case ANIMATION_PROCESS_IDLE: set_process(p_process && active); break;
}
processing = p_process;
}
+bool AnimationTreePlayer::_set(const StringName &p_name, const Variant &p_value) {
-bool AnimationTreePlayer::_set(const StringName& p_name, const Variant& p_value) {
-
- if (String(p_name)=="base_path") {
+ if (String(p_name) == "base_path") {
set_base_path(p_value);
return true;
}
- if (String(p_name)=="master_player") {
+ if (String(p_name) == "master_player") {
set_master_player(p_value);
return true;
}
- if(String(p_name) == SceneStringNames::get_singleton()->playback_active) {
+ if (String(p_name) == SceneStringNames::get_singleton()->playback_active) {
set_active(p_value);
return true;
}
- if (String(p_name)!="data")
+ if (String(p_name) != "data")
return false;
+ Dictionary data = p_value;
- Dictionary data=p_value;
+ Array nodes = data.get_valid("nodes");
- Array nodes=data.get_valid("nodes");
-
- for(int i=0;i<nodes.size();i++) {
+ for (int i = 0; i < nodes.size(); i++) {
Dictionary node = nodes[i];
StringName id = node.get_valid("id");
Point2 pos = node.get_valid("pos");
- NodeType nt=NODE_MAX;
+ NodeType nt = NODE_MAX;
String type = node.get_valid("type");
- if (type=="output")
- nt=NODE_OUTPUT;
- else if (type=="animation")
- nt=NODE_ANIMATION;
- else if (type=="oneshot")
- nt=NODE_ONESHOT;
- else if (type=="mix")
- nt=NODE_MIX;
- else if (type=="blend2")
- nt=NODE_BLEND2;
- else if (type=="blend3")
- nt=NODE_BLEND3;
- else if (type=="blend4")
- nt=NODE_BLEND4;
- else if (type=="timescale")
- nt=NODE_TIMESCALE;
- else if (type=="timeseek")
- nt=NODE_TIMESEEK;
- else if (type=="transition")
- nt=NODE_TRANSITION;
-
- ERR_FAIL_COND_V(nt==NODE_MAX,false);
+ if (type == "output")
+ nt = NODE_OUTPUT;
+ else if (type == "animation")
+ nt = NODE_ANIMATION;
+ else if (type == "oneshot")
+ nt = NODE_ONESHOT;
+ else if (type == "mix")
+ nt = NODE_MIX;
+ else if (type == "blend2")
+ nt = NODE_BLEND2;
+ else if (type == "blend3")
+ nt = NODE_BLEND3;
+ else if (type == "blend4")
+ nt = NODE_BLEND4;
+ else if (type == "timescale")
+ nt = NODE_TIMESCALE;
+ else if (type == "timeseek")
+ nt = NODE_TIMESEEK;
+ else if (type == "transition")
+ nt = NODE_TRANSITION;
- if (nt!=NODE_OUTPUT)
- add_node(nt,id);
- node_set_pos(id,pos);
+ ERR_FAIL_COND_V(nt == NODE_MAX, false);
+ if (nt != NODE_OUTPUT)
+ add_node(nt, id);
+ node_set_pos(id, pos);
- switch(nt) {
+ switch (nt) {
case NODE_OUTPUT: {
} break;
case NODE_ANIMATION: {
if (node.has("from"))
- animation_node_set_master_animation(id,node.get_valid("from"));
+ animation_node_set_master_animation(id, node.get_valid("from"));
else
- animation_node_set_animation(id,node.get_valid("animation"));
- Array filters= node.get_valid("filter");
- for(int i=0;i<filters.size();i++) {
+ animation_node_set_animation(id, node.get_valid("animation"));
+ Array filters = node.get_valid("filter");
+ for (int i = 0; i < filters.size(); i++) {
- animation_node_set_filter_path(id,filters[i],true);
+ animation_node_set_filter_path(id, filters[i], true);
}
- } break;
+ } break;
case NODE_ONESHOT: {
- oneshot_node_set_fadein_time(id,node.get_valid("fade_in"));
- oneshot_node_set_fadeout_time(id,node.get_valid("fade_out"));
- oneshot_node_set_mix_mode(id,node.get_valid("mix"));
- oneshot_node_set_autorestart(id,node.get_valid("autorestart"));
- oneshot_node_set_autorestart_delay(id,node.get_valid("autorestart_delay"));
- oneshot_node_set_autorestart_random_delay(id,node.get_valid("autorestart_random_delay"));
- Array filters= node.get_valid("filter");
- for(int i=0;i<filters.size();i++) {
+ oneshot_node_set_fadein_time(id, node.get_valid("fade_in"));
+ oneshot_node_set_fadeout_time(id, node.get_valid("fade_out"));
+ oneshot_node_set_mix_mode(id, node.get_valid("mix"));
+ oneshot_node_set_autorestart(id, node.get_valid("autorestart"));
+ oneshot_node_set_autorestart_delay(id, node.get_valid("autorestart_delay"));
+ oneshot_node_set_autorestart_random_delay(id, node.get_valid("autorestart_random_delay"));
+ Array filters = node.get_valid("filter");
+ for (int i = 0; i < filters.size(); i++) {
- oneshot_node_set_filter_path(id,filters[i],true);
+ oneshot_node_set_filter_path(id, filters[i], true);
}
} break;
case NODE_MIX: {
- mix_node_set_amount(id,node.get_valid("mix"));
+ mix_node_set_amount(id, node.get_valid("mix"));
} break;
case NODE_BLEND2: {
- blend2_node_set_amount(id,node.get_valid("blend"));
- Array filters= node.get_valid("filter");
- for(int i=0;i<filters.size();i++) {
+ blend2_node_set_amount(id, node.get_valid("blend"));
+ Array filters = node.get_valid("filter");
+ for (int i = 0; i < filters.size(); i++) {
- blend2_node_set_filter_path(id,filters[i],true);
+ blend2_node_set_filter_path(id, filters[i], true);
}
} break;
case NODE_BLEND3: {
- blend3_node_set_amount(id,node.get_valid("blend"));
+ blend3_node_set_amount(id, node.get_valid("blend"));
} break;
case NODE_BLEND4: {
- blend4_node_set_amount(id,node.get_valid("blend"));
+ blend4_node_set_amount(id, node.get_valid("blend"));
} break;
case NODE_TIMESCALE: {
- timescale_node_set_scale(id,node.get_valid("scale"));
+ timescale_node_set_scale(id, node.get_valid("scale"));
} break;
case NODE_TIMESEEK: {
} break;
case NODE_TRANSITION: {
- transition_node_set_xfade_time(id,node.get_valid("xfade"));
+ transition_node_set_xfade_time(id, node.get_valid("xfade"));
Array transitions = node.get_valid("transitions");
- transition_node_set_input_count(id,transitions.size());
+ transition_node_set_input_count(id, transitions.size());
- for(int x=0;x<transitions.size();x++) {
+ for (int x = 0; x < transitions.size(); x++) {
- Dictionary d =transitions[x];
+ Dictionary d = transitions[x];
bool aa = d.get_valid("auto_advance");
- transition_node_set_input_auto_advance(id,x,aa);
-
+ transition_node_set_input_auto_advance(id, x, aa);
}
} break;
default: {};
}
-
}
-
Array connections = data.get_valid("connections");
- ERR_FAIL_COND_V(connections.size()%3,false);
+ ERR_FAIL_COND_V(connections.size() % 3, false);
- int cc=connections.size()/3;
+ int cc = connections.size() / 3;
- for(int i=0;i<cc;i++) {
+ for (int i = 0; i < cc; i++) {
- StringName src = connections[i*3+0];
- StringName dst = connections[i*3+1];
- int dst_in = connections[i*3+2];
- connect(src,dst,dst_in);
+ StringName src = connections[i * 3 + 0];
+ StringName dst = connections[i * 3 + 1];
+ int dst_in = connections[i * 3 + 2];
+ connect(src, dst, dst_in);
}
set_active(data.get_valid("active"));
set_master_player(data.get_valid("master"));
return true;
-
}
-bool AnimationTreePlayer::_get(const StringName& p_name,Variant &r_ret) const {
+bool AnimationTreePlayer::_get(const StringName &p_name, Variant &r_ret) const {
- if (String(p_name)=="base_path") {
- r_ret=base_path;
+ if (String(p_name) == "base_path") {
+ r_ret = base_path;
return true;
}
- if (String(p_name)=="master_player") {
- r_ret=master;
+ if (String(p_name) == "master_player") {
+ r_ret = master;
return true;
}
if (String(p_name) == "playback/active") {
- r_ret=is_active();
+ r_ret = is_active();
return true;
}
- if (String(p_name)!="data")
+ if (String(p_name) != "data")
return false;
Dictionary data;
Array nodes;
- for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
NodeBase *n = node_map[E->key()];
Dictionary node;
- node["id"]=E->key();
- node["pos"]=n->pos;
+ node["id"] = E->key();
+ node["pos"] = n->pos;
- switch(n->type) {
- case NODE_OUTPUT: node["type"]= "output"; break;
- case NODE_ANIMATION: node["type"]= "animation"; break;
- case NODE_ONESHOT: node["type"]= "oneshot"; break;
- case NODE_MIX: node["type"]= "mix"; break;
- case NODE_BLEND2: node["type"]= "blend2"; break;
- case NODE_BLEND3: node["type"]= "blend3"; break;
- case NODE_BLEND4: node["type"]= "blend4"; break;
- case NODE_TIMESCALE: node["type"]= "timescale"; break;
- case NODE_TIMESEEK: node["type"]= "timeseek"; break;
- case NODE_TRANSITION: node["type"]= "transition"; break;
- default: node["type"]= ""; break;
+ switch (n->type) {
+ case NODE_OUTPUT: node["type"] = "output"; break;
+ case NODE_ANIMATION: node["type"] = "animation"; break;
+ case NODE_ONESHOT: node["type"] = "oneshot"; break;
+ case NODE_MIX: node["type"] = "mix"; break;
+ case NODE_BLEND2: node["type"] = "blend2"; break;
+ case NODE_BLEND3: node["type"] = "blend3"; break;
+ case NODE_BLEND4: node["type"] = "blend4"; break;
+ case NODE_TIMESCALE: node["type"] = "timescale"; break;
+ case NODE_TIMESEEK: node["type"] = "timeseek"; break;
+ case NODE_TRANSITION: node["type"] = "transition"; break;
+ default: node["type"] = ""; break;
}
- switch(n->type) {
+ switch (n->type) {
case NODE_OUTPUT: {
} break;
case NODE_ANIMATION: {
- AnimationNode *an = static_cast<AnimationNode*>(n);
- if (master!=NodePath() && an->from!="") {
- node["from"]=an->from;
+ AnimationNode *an = static_cast<AnimationNode *>(n);
+ if (master != NodePath() && an->from != "") {
+ node["from"] = an->from;
} else {
- node["animation"]=an->animation;
+ node["animation"] = an->animation;
}
Array k;
List<NodePath> keys;
an->filter.get_key_list(&keys);
k.resize(keys.size());
- int i=0;
- for(List<NodePath>::Element *E=keys.front();E;E=E->next()) {
- k[i++]=E->get();
+ int i = 0;
+ for (List<NodePath>::Element *E = keys.front(); E; E = E->next()) {
+ k[i++] = E->get();
}
- node["filter"]=k;
- } break;
+ node["filter"] = k;
+ } break;
case NODE_ONESHOT: {
- OneShotNode *osn = static_cast<OneShotNode*>(n);
- node["fade_in"]=osn->fade_in;
- node["fade_out"]=osn->fade_out;
- node["mix"]=osn->mix;
- node["autorestart"]=osn->autorestart;
- node["autorestart_delay"]=osn->autorestart_delay;
- node["autorestart_random_delay"]=osn->autorestart_random_delay;
+ OneShotNode *osn = static_cast<OneShotNode *>(n);
+ node["fade_in"] = osn->fade_in;
+ node["fade_out"] = osn->fade_out;
+ node["mix"] = osn->mix;
+ node["autorestart"] = osn->autorestart;
+ node["autorestart_delay"] = osn->autorestart_delay;
+ node["autorestart_random_delay"] = osn->autorestart_random_delay;
Array k;
List<NodePath> keys;
osn->filter.get_key_list(&keys);
k.resize(keys.size());
- int i=0;
- for(List<NodePath>::Element *E=keys.front();E;E=E->next()) {
- k[i++]=E->get();
+ int i = 0;
+ for (List<NodePath>::Element *E = keys.front(); E; E = E->next()) {
+ k[i++] = E->get();
}
- node["filter"]=k;
+ node["filter"] = k;
} break;
case NODE_MIX: {
- MixNode *mn = static_cast<MixNode*>(n);
- node["mix"]=mn->amount;
+ MixNode *mn = static_cast<MixNode *>(n);
+ node["mix"] = mn->amount;
} break;
case NODE_BLEND2: {
- Blend2Node *bn = static_cast<Blend2Node*>(n);
- node["blend"]=bn->value;
+ Blend2Node *bn = static_cast<Blend2Node *>(n);
+ node["blend"] = bn->value;
Array k;
List<NodePath> keys;
bn->filter.get_key_list(&keys);
k.resize(keys.size());
- int i=0;
- for(List<NodePath>::Element *E=keys.front();E;E=E->next()) {
- k[i++]=E->get();
+ int i = 0;
+ for (List<NodePath>::Element *E = keys.front(); E; E = E->next()) {
+ k[i++] = E->get();
}
- node["filter"]=k;
+ node["filter"] = k;
} break;
case NODE_BLEND3: {
- Blend3Node *bn = static_cast<Blend3Node*>(n);
- node["blend"]=bn->value;
+ Blend3Node *bn = static_cast<Blend3Node *>(n);
+ node["blend"] = bn->value;
} break;
case NODE_BLEND4: {
- Blend4Node *bn = static_cast<Blend4Node*>(n);
- node["blend"]=bn->value;
+ Blend4Node *bn = static_cast<Blend4Node *>(n);
+ node["blend"] = bn->value;
} break;
case NODE_TIMESCALE: {
- TimeScaleNode *tsn = static_cast<TimeScaleNode*>(n);
- node["scale"]=tsn->scale;
+ TimeScaleNode *tsn = static_cast<TimeScaleNode *>(n);
+ node["scale"] = tsn->scale;
} break;
case NODE_TIMESEEK: {
} break;
case NODE_TRANSITION: {
- TransitionNode *tn = static_cast<TransitionNode*>(n);
- node["xfade"]=tn->xfade;
+ TransitionNode *tn = static_cast<TransitionNode *>(n);
+ node["xfade"] = tn->xfade;
Array transitions;
- for(int i=0;i<tn->input_data.size();i++) {
+ for (int i = 0; i < tn->input_data.size(); i++) {
Dictionary d;
- d["auto_advance"]=tn->input_data[i].auto_advance;
+ d["auto_advance"] = tn->input_data[i].auto_advance;
transitions.push_back(d);
-
}
- node["transitions"]=transitions;
+ node["transitions"] = transitions;
} break;
default: {};
@@ -367,39 +356,38 @@ bool AnimationTreePlayer::_get(const StringName& p_name,Variant &r_ret) const {
nodes.push_back(node);
}
- data["nodes"]=nodes;
+ data["nodes"] = nodes;
//connectiosn
List<Connection> connections;
get_connection_list(&connections);
Array connections_arr;
- connections_arr.resize(connections.size()*3);
+ connections_arr.resize(connections.size() * 3);
- int idx=0;
- for (List<Connection>::Element *E=connections.front();E;E=E->next()) {
+ int idx = 0;
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
- connections_arr.set(idx+0,E->get().src_node);
- connections_arr.set(idx+1,E->get().dst_node);
- connections_arr.set(idx+2,E->get().dst_input);
+ connections_arr.set(idx + 0, E->get().src_node);
+ connections_arr.set(idx + 1, E->get().dst_node);
+ connections_arr.set(idx + 2, E->get().dst_input);
- idx+=3;
+ idx += 3;
}
- data["connections"]=connections_arr;
- data["active"]=active;
- data["master"]=master;
+ data["connections"] = connections_arr;
+ data["active"] = active;
+ data["master"] = master;
- r_ret=data;
+ r_ret = data;
return true;
-
}
-void AnimationTreePlayer::_get_property_list( List<PropertyInfo> *p_list) const {
+void AnimationTreePlayer::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo(Variant::NODE_PATH,"base_path" ) );
- p_list->push_back( PropertyInfo(Variant::NODE_PATH,"master_player" ) );
- p_list->push_back( PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_NETWORK) );
+ p_list->push_back(PropertyInfo(Variant::NODE_PATH, "base_path"));
+ p_list->push_back(PropertyInfo(Variant::NODE_PATH, "master_player"));
+ p_list->push_back(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_NETWORK));
}
void AnimationTreePlayer::advance(float p_time) {
@@ -409,7 +397,7 @@ void AnimationTreePlayer::advance(float p_time) {
void AnimationTreePlayer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -421,38 +409,37 @@ void AnimationTreePlayer::_notification(int p_what) {
}
} break;
case NOTIFICATION_READY: {
- dirty_caches=true;
- if (master!=NodePath()) {
+ dirty_caches = true;
+ if (master != NodePath()) {
_update_sources();
}
} break;
case NOTIFICATION_PROCESS: {
- if (animation_process_mode==ANIMATION_PROCESS_FIXED)
+ if (animation_process_mode == ANIMATION_PROCESS_FIXED)
break;
if (processing)
- _process_animation( get_process_delta_time() );
+ _process_animation(get_process_delta_time());
} break;
case NOTIFICATION_FIXED_PROCESS: {
- if (animation_process_mode==ANIMATION_PROCESS_IDLE)
+ if (animation_process_mode == ANIMATION_PROCESS_IDLE)
break;
if (processing)
_process_animation(get_fixed_process_delta_time());
} break;
}
-
}
-void AnimationTreePlayer::_compute_weights(float *p_fallback_weight, HashMap<NodePath,float> *p_weights, float p_coeff, const HashMap<NodePath,bool> *p_filter, float p_filtered_coeff) {
+void AnimationTreePlayer::_compute_weights(float *p_fallback_weight, HashMap<NodePath, float> *p_weights, float p_coeff, const HashMap<NodePath, bool> *p_filter, float p_filtered_coeff) {
if (p_filter != NULL) {
List<NodePath> key_list;
p_filter->get_key_list(&key_list);
- for (List<NodePath>::Element *E = key_list.front();E; E=E->next()) {
+ for (List<NodePath>::Element *E = key_list.front(); E; E = E->next()) {
if ((*p_filter)[E->get()]) {
@@ -463,60 +450,58 @@ void AnimationTreePlayer::_compute_weights(float *p_fallback_weight, HashMap<Nod
}
} else if (p_weights->has(E->get())) {
- (*p_weights)[E->get()] *= p_coeff;
+ (*p_weights)[E->get()] *= p_coeff;
}
}
}
List<NodePath> key_list;
p_weights->get_key_list(&key_list);
-
- for (List<NodePath>::Element *E = key_list.front();E;E=E->next()) {
+
+ for (List<NodePath>::Element *E = key_list.front(); E; E = E->next()) {
if (p_filter == NULL || !p_filter->has(E->get())) {
(*p_weights)[E->get()] *= p_coeff;
}
}
*p_fallback_weight *= p_coeff;
-
}
-
-float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode **r_prev_anim, float p_time, bool p_seek, float p_fallback_weight, HashMap<NodePath,float>* p_weights) {
+float AnimationTreePlayer::_process_node(const StringName &p_node, AnimationNode **r_prev_anim, float p_time, bool p_seek, float p_fallback_weight, HashMap<NodePath, float> *p_weights) {
ERR_FAIL_COND_V(!node_map.has(p_node), 0);
- NodeBase *nb=node_map[p_node];
+ NodeBase *nb = node_map[p_node];
//transform to seconds...
- switch(nb->type) {
+ switch (nb->type) {
case NODE_OUTPUT: {
- NodeOut *on = static_cast<NodeOut*>(nb);
+ NodeOut *on = static_cast<NodeOut *>(nb);
HashMap<NodePath, float> weights;
- return _process_node(on->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, &weights);
+ return _process_node(on->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, &weights);
} break;
case NODE_ANIMATION: {
- AnimationNode *an = static_cast<AnimationNode*>(nb);
+ AnimationNode *an = static_cast<AnimationNode *>(nb);
float rem = 0;
if (!an->animation.is_null()) {
- // float pos = an->time;
-// float delta = p_time;
+ // float pos = an->time;
+ // float delta = p_time;
- // const Animation *a = an->animation.operator->();
+ // const Animation *a = an->animation.operator->();
if (p_seek) {
- an->time=p_time;
- an->step=0;
+ an->time = p_time;
+ an->step = 0;
} else {
- an->time=MAX(0,an->time+p_time);
- an->step=p_time;
+ an->time = MAX(0, an->time + p_time);
+ an->step = p_time;
}
float anim_size = an->animation->get_length();
@@ -524,16 +509,16 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
if (an->animation->has_loop()) {
if (anim_size)
- an->time=Math::fposmod(an->time,anim_size);
+ an->time = Math::fposmod(an->time, anim_size);
} else if (an->time > anim_size) {
- an->time=anim_size;
+ an->time = anim_size;
}
- an->skip=true;
+ an->skip = true;
- for (List<AnimationNode::TrackRef>::Element *E=an->tref.front();E;E=E->next()) {
+ for (List<AnimationNode::TrackRef>::Element *E = an->tref.front(); E; E = E->next()) {
NodePath track_path = an->animation->track_get_path(E->get().local_track);
if (an->filter.has(track_path) && an->filter[track_path]) {
E->get().weight = 0;
@@ -545,114 +530,111 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
E->get().weight = p_fallback_weight;
}
}
- if (E->get().weight>CMP_EPSILON)
- an->skip=false;
+ if (E->get().weight > CMP_EPSILON)
+ an->skip = false;
}
rem = anim_size - an->time;
-
}
-
if (!(*r_prev_anim))
- active_list=an;
+ active_list = an;
else
- (*r_prev_anim)->next=an;
+ (*r_prev_anim)->next = an;
- an->next=NULL;
- *r_prev_anim=an;
+ an->next = NULL;
+ *r_prev_anim = an;
return rem;
-
} break;
case NODE_ONESHOT: {
- OneShotNode *osn = static_cast<OneShotNode*>(nb);
+ OneShotNode *osn = static_cast<OneShotNode *>(nb);
if (!osn->active) {
//make it as if this node doesn't exist, pass input 0 by.
- return _process_node(osn->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, p_weights);
+ return _process_node(osn->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
}
float os_seek = p_seek;
if (p_seek)
- osn->time=p_time;
+ osn->time = p_time;
if (osn->start) {
- osn->time=0;
+ osn->time = 0;
os_seek = true;
}
float blend;
- if (osn->time<osn->fade_in) {
+ if (osn->time < osn->fade_in) {
- if (osn->fade_in>0)
- blend = osn->time/osn->fade_in;
+ if (osn->fade_in > 0)
+ blend = osn->time / osn->fade_in;
else
- blend=0; //wtf
+ blend = 0; //wtf
- } else if (!osn->start && osn->remaining<osn->fade_out) {
+ } else if (!osn->start && osn->remaining < osn->fade_out) {
if (osn->fade_out)
- blend=(osn->remaining/osn->fade_out);
+ blend = (osn->remaining / osn->fade_out);
else
- blend=1.0;
+ blend = 1.0;
} else
- blend=1.0;
+ blend = 1.0;
float main_rem;
float os_rem;
HashMap<NodePath, float> os_weights(*p_weights);
float os_fallback_weight = p_fallback_weight;
- _compute_weights(&p_fallback_weight, p_weights, osn->mix?1.0 : 1.0 - blend, &osn->filter, 1.0);
+ _compute_weights(&p_fallback_weight, p_weights, osn->mix ? 1.0 : 1.0 - blend, &osn->filter, 1.0);
_compute_weights(&os_fallback_weight, &os_weights, blend, &osn->filter, 0.0);
- main_rem = _process_node(osn->inputs[0].node,r_prev_anim,p_time,p_seek, p_fallback_weight, p_weights);
- os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_time,os_seek, os_fallback_weight, &os_weights);
+ main_rem = _process_node(osn->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
+ os_rem = _process_node(osn->inputs[1].node, r_prev_anim, p_time, os_seek, os_fallback_weight, &os_weights);
if (osn->start) {
- osn->remaining=os_rem;
- osn->start=false;
+ osn->remaining = os_rem;
+ osn->start = false;
}
if (!p_seek) {
- osn->time+=p_time;
- osn->remaining=os_rem;
- if (osn->remaining<=0)
- osn->active=false;
+ osn->time += p_time;
+ osn->remaining = os_rem;
+ if (osn->remaining <= 0)
+ osn->active = false;
}
- return MAX(main_rem,osn->remaining);
+ return MAX(main_rem, osn->remaining);
} break;
case NODE_MIX: {
- MixNode *mn = static_cast<MixNode*>(nb);
+ MixNode *mn = static_cast<MixNode *>(nb);
HashMap<NodePath, float> mn_weights(*p_weights);
float mn_fallback_weight = p_fallback_weight;
_compute_weights(&mn_fallback_weight, &mn_weights, mn->amount);
- float rem = _process_node(mn->inputs[0].node,r_prev_anim, p_time,p_seek,p_fallback_weight,p_weights);
- _process_node(mn->inputs[1].node,r_prev_anim,p_time,p_seek,mn_fallback_weight,&mn_weights);
+ float rem = _process_node(mn->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
+ _process_node(mn->inputs[1].node, r_prev_anim, p_time, p_seek, mn_fallback_weight, &mn_weights);
return rem;
} break;
case NODE_BLEND2: {
- Blend2Node *bn = static_cast<Blend2Node*>(nb);
+ Blend2Node *bn = static_cast<Blend2Node *>(nb);
HashMap<NodePath, float> bn_weights(*p_weights);
float bn_fallback_weight = p_fallback_weight;
- _compute_weights(&p_fallback_weight,p_weights, 1.0 - bn->value, &bn->filter, 1.0);
- _compute_weights(&bn_fallback_weight,&bn_weights, bn->value, &bn->filter, 0.0);
- float rem = _process_node(bn->inputs[0].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights);
- _process_node(bn->inputs[1].node,r_prev_anim,p_time,p_seek,bn_fallback_weight,&bn_weights);
+ _compute_weights(&p_fallback_weight, p_weights, 1.0 - bn->value, &bn->filter, 1.0);
+ _compute_weights(&bn_fallback_weight, &bn_weights, bn->value, &bn->filter, 0.0);
+ float rem = _process_node(bn->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
+ _process_node(bn->inputs[1].node, r_prev_anim, p_time, p_seek, bn_fallback_weight, &bn_weights);
return rem;
} break;
case NODE_BLEND3: {
- Blend3Node *bn = static_cast<Blend3Node*>(nb);
+ Blend3Node *bn = static_cast<Blend3Node *>(nb);
float rem;
float blend, lower_blend, upper_blend;
@@ -670,18 +652,18 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
float upper_fallback_weight = p_fallback_weight;
HashMap<NodePath, float> lower_weights(*p_weights);
float lower_fallback_weight = p_fallback_weight;
- _compute_weights(&upper_fallback_weight,&upper_weights, upper_blend);
- _compute_weights(&p_fallback_weight,p_weights, blend);
- _compute_weights(&lower_fallback_weight,&lower_weights, lower_blend);
+ _compute_weights(&upper_fallback_weight, &upper_weights, upper_blend);
+ _compute_weights(&p_fallback_weight, p_weights, blend);
+ _compute_weights(&lower_fallback_weight, &lower_weights, lower_blend);
- rem = _process_node(bn->inputs[1].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights);
- _process_node(bn->inputs[0].node,r_prev_anim,p_time,p_seek,lower_fallback_weight,&lower_weights);
- _process_node(bn->inputs[2].node,r_prev_anim,p_time,p_seek,upper_fallback_weight,&upper_weights);
+ rem = _process_node(bn->inputs[1].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
+ _process_node(bn->inputs[0].node, r_prev_anim, p_time, p_seek, lower_fallback_weight, &lower_weights);
+ _process_node(bn->inputs[2].node, r_prev_anim, p_time, p_seek, upper_fallback_weight, &upper_weights);
return rem;
} break;
case NODE_BLEND4: {
- Blend4Node *bn = static_cast<Blend4Node*>(nb);
+ Blend4Node *bn = static_cast<Blend4Node *>(nb);
HashMap<NodePath, float> weights1(*p_weights);
float fallback_weight1 = p_fallback_weight;
@@ -690,26 +672,26 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
HashMap<NodePath, float> weights3(*p_weights);
float fallback_weight3 = p_fallback_weight;
- _compute_weights(&p_fallback_weight,p_weights, 1.0-bn->value.x);
- _compute_weights(&fallback_weight1,&weights1, bn->value.x);
- _compute_weights(&fallback_weight2,&weights2, 1.0-bn->value.y);
- _compute_weights(&fallback_weight3,&weights3, bn->value.y);
+ _compute_weights(&p_fallback_weight, p_weights, 1.0 - bn->value.x);
+ _compute_weights(&fallback_weight1, &weights1, bn->value.x);
+ _compute_weights(&fallback_weight2, &weights2, 1.0 - bn->value.y);
+ _compute_weights(&fallback_weight3, &weights3, bn->value.y);
- float rem = _process_node(bn->inputs[0].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights);
- _process_node(bn->inputs[1].node,r_prev_anim,p_time,p_seek,fallback_weight1,&weights1);
- float rem2 = _process_node(bn->inputs[2].node,r_prev_anim,p_time,p_seek,fallback_weight2,&weights2);
- _process_node(bn->inputs[3].node,r_prev_anim,p_time,p_seek,fallback_weight3,&weights3);
+ float rem = _process_node(bn->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
+ _process_node(bn->inputs[1].node, r_prev_anim, p_time, p_seek, fallback_weight1, &weights1);
+ float rem2 = _process_node(bn->inputs[2].node, r_prev_anim, p_time, p_seek, fallback_weight2, &weights2);
+ _process_node(bn->inputs[3].node, r_prev_anim, p_time, p_seek, fallback_weight3, &weights3);
- return MAX(rem,rem2);
+ return MAX(rem, rem2);
} break;
case NODE_TIMESCALE: {
- TimeScaleNode *tsn = static_cast<TimeScaleNode*>(nb);
+ TimeScaleNode *tsn = static_cast<TimeScaleNode *>(nb);
float rem;
if (p_seek)
- rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_time,true,p_fallback_weight,p_weights);
+ rem = _process_node(tsn->inputs[0].node, r_prev_anim, p_time, true, p_fallback_weight, p_weights);
else
- rem = _process_node(tsn->inputs[0].node,r_prev_anim,p_time*tsn->scale,false,p_fallback_weight,p_weights);
+ rem = _process_node(tsn->inputs[0].node, r_prev_anim, p_time * tsn->scale, false, p_fallback_weight, p_weights);
if (tsn->scale == 0)
return INFINITY;
else
@@ -718,105 +700,96 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode
} break;
case NODE_TIMESEEK: {
- TimeSeekNode *tsn = static_cast<TimeSeekNode*>(nb);
- if (tsn->seek_pos>=0 && !p_seek) {
+ TimeSeekNode *tsn = static_cast<TimeSeekNode *>(nb);
+ if (tsn->seek_pos >= 0 && !p_seek) {
p_time = tsn->seek_pos;
p_seek = true;
}
- tsn->seek_pos=-1;
+ tsn->seek_pos = -1;
- return _process_node(tsn->inputs[0].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights);
+ return _process_node(tsn->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
- } break;
+ } break;
case NODE_TRANSITION: {
- TransitionNode *tn = static_cast<TransitionNode*>(nb);
+ TransitionNode *tn = static_cast<TransitionNode *>(nb);
HashMap<NodePath, float> prev_weights(*p_weights);
float prev_fallback_weight = p_fallback_weight;
- if (tn->prev<0) { // process current animation, check for transition
+ if (tn->prev < 0) { // process current animation, check for transition
- float rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights);
+ float rem = _process_node(tn->inputs[tn->current].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
if (p_seek)
- tn->time=p_time;
+ tn->time = p_time;
else
- tn->time+=p_time;
+ tn->time += p_time;
if (tn->input_data[tn->current].auto_advance && rem <= tn->xfade) {
- tn->set_current((tn->current+1) % tn->inputs.size());
+ tn->set_current((tn->current + 1) % tn->inputs.size());
}
-
return rem;
- } else { // cross-fading from tn->prev to tn->current
-
+ } else { // cross-fading from tn->prev to tn->current
- float blend = tn->xfade? (tn->prev_xfading/tn->xfade) : 1;
+ float blend = tn->xfade ? (tn->prev_xfading / tn->xfade) : 1;
float rem;
- _compute_weights(&p_fallback_weight,p_weights, 1.0-blend);
- _compute_weights(&prev_fallback_weight,&prev_weights, blend);
+ _compute_weights(&p_fallback_weight, p_weights, 1.0 - blend);
+ _compute_weights(&prev_fallback_weight, &prev_weights, blend);
if (!p_seek && tn->switched) { //just switched, seek to start of current
- rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,0,true,p_fallback_weight,p_weights);
+ rem = _process_node(tn->inputs[tn->current].node, r_prev_anim, 0, true, p_fallback_weight, p_weights);
} else {
- rem = _process_node(tn->inputs[tn->current].node,r_prev_anim,p_time,p_seek,p_fallback_weight,p_weights);
-
+ rem = _process_node(tn->inputs[tn->current].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
}
- tn->switched=false;
+ tn->switched = false;
- if (p_seek) { // don't seek prev animation
- _process_node(tn->inputs[tn->prev].node,r_prev_anim,0,false,prev_fallback_weight,&prev_weights);
- tn->time=p_time;
+ if (p_seek) { // don't seek prev animation
+ _process_node(tn->inputs[tn->prev].node, r_prev_anim, 0, false, prev_fallback_weight, &prev_weights);
+ tn->time = p_time;
} else {
- _process_node(tn->inputs[tn->prev].node,r_prev_anim,p_time,false,prev_fallback_weight,&prev_weights);
- tn->time+=p_time;
- tn->prev_xfading-=p_time;
- if (tn->prev_xfading<0) {
+ _process_node(tn->inputs[tn->prev].node, r_prev_anim, p_time, false, prev_fallback_weight, &prev_weights);
+ tn->time += p_time;
+ tn->prev_xfading -= p_time;
+ if (tn->prev_xfading < 0) {
- tn->prev=-1;
+ tn->prev = -1;
}
-
}
return rem;
}
-
} break;
default: {}
}
-
-
return 0;
}
-
void AnimationTreePlayer::_process_animation(float p_delta) {
- if (last_error!=CONNECT_OK)
+ if (last_error != CONNECT_OK)
return;
if (dirty_caches)
_recompute_caches();
-
- active_list=NULL;
- AnimationNode *prev=NULL;
+ active_list = NULL;
+ AnimationNode *prev = NULL;
if (reset_request) {
- _process_node(out_name,&prev, 0, true);
- reset_request=false;
+ _process_node(out_name, &prev, 0, true);
+ reset_request = false;
} else
- _process_node(out_name,&prev, p_delta);
+ _process_node(out_name, &prev, p_delta);
if (dirty_caches) {
//some animation changed.. ignore this pass
@@ -825,19 +798,17 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
//update the tracks..
-
-
/* STEP 1 CLEAR TRACKS */
- for(TrackMap::Element *E=track_map.front();E;E=E->next()) {
+ for (TrackMap::Element *E = track_map.front(); E; E = E->next()) {
Track &t = E->get();
t.loc.zero();
- t.rot=Quat();
- t.scale.x=0;
- t.scale.y=0;
- t.scale.z=0;
+ t.rot = Quat();
+ t.scale.x = 0;
+ t.scale.y = 0;
+ t.scale.z = 0;
t.value = t.object->get(t.property);
t.value.zero();
@@ -845,634 +816,554 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
t.skip = false;
}
-
/* STEP 2 PROCESS ANIMATIONS */
- AnimationNode *anim_list=active_list;
+ AnimationNode *anim_list = active_list;
Quat empty_rot;
-
- while(anim_list) {
+ while (anim_list) {
if (!anim_list->animation.is_null() && !anim_list->skip) {
//check if animation is meaningful
Animation *a = anim_list->animation.operator->();
- for(List<AnimationNode::TrackRef>::Element *E=anim_list->tref.front();E;E=E->next()) {
-
+ for (List<AnimationNode::TrackRef>::Element *E = anim_list->tref.front(); E; E = E->next()) {
AnimationNode::TrackRef &tr = E->get();
- if (tr.track==NULL || tr.local_track<0 || tr.weight < CMP_EPSILON)
+ if (tr.track == NULL || tr.local_track < 0 || tr.weight < CMP_EPSILON)
continue;
- switch(a->track_get_type(tr.local_track)) {
+ switch (a->track_get_type(tr.local_track)) {
case Animation::TYPE_TRANSFORM: { ///< Transform a node or a bone.
Vector3 loc;
Quat rot;
Vector3 scale;
- a->transform_track_interpolate(tr.local_track,anim_list->time,&loc,&rot,&scale);
-
- tr.track->loc+=loc*tr.weight;
+ a->transform_track_interpolate(tr.local_track, anim_list->time, &loc, &rot, &scale);
- scale.x-=1.0;
- scale.y-=1.0;
- scale.z-=1.0;
- tr.track->scale+=scale*tr.weight;
+ tr.track->loc += loc * tr.weight;
- tr.track->rot = tr.track->rot * empty_rot.slerp(rot,tr.weight);
+ scale.x -= 1.0;
+ scale.y -= 1.0;
+ scale.z -= 1.0;
+ tr.track->scale += scale * tr.weight;
+ tr.track->rot = tr.track->rot * empty_rot.slerp(rot, tr.weight);
} break;
case Animation::TYPE_VALUE: { ///< Set a value in a property, can be interpolated.
- if (a->value_track_get_update_mode(tr.local_track)==Animation::UPDATE_CONTINUOUS) {
- Variant value = a->value_track_interpolate(tr.local_track,anim_list->time);
- Variant::blend(tr.track->value,value,tr.weight,tr.track->value);
+ if (a->value_track_get_update_mode(tr.local_track) == Animation::UPDATE_CONTINUOUS) {
+ Variant value = a->value_track_interpolate(tr.local_track, anim_list->time);
+ Variant::blend(tr.track->value, value, tr.weight, tr.track->value);
} else {
- int index = a->track_find_key(tr.local_track,anim_list->time);
+ int index = a->track_find_key(tr.local_track, anim_list->time);
tr.track->value = a->track_get_key_value(tr.local_track, index);
}
} break;
case Animation::TYPE_METHOD: { ///< Call any method on a specific node.
List<int> indices;
- a->method_track_get_key_indices(tr.local_track,anim_list->time,anim_list->step,&indices);
- for(List<int>::Element *E=indices.front();E;E=E->next()) {
+ a->method_track_get_key_indices(tr.local_track, anim_list->time, anim_list->step, &indices);
+ for (List<int>::Element *E = indices.front(); E; E = E->next()) {
- StringName method = a->method_track_get_name(tr.local_track,E->get());
- Vector<Variant> args=a->method_track_get_params(tr.local_track,E->get());
+ StringName method = a->method_track_get_name(tr.local_track, E->get());
+ Vector<Variant> args = a->method_track_get_params(tr.local_track, E->get());
args.resize(VARIANT_ARG_MAX);
- tr.track->object->call(method,args[0],args[1],args[2],args[3],args[4]);
+ tr.track->object->call(method, args[0], args[1], args[2], args[3], args[4]);
}
} break;
}
-
}
}
- anim_list=anim_list->next;
+ anim_list = anim_list->next;
}
/* STEP 3 APPLY TRACKS */
- for(TrackMap::Element *E=track_map.front();E;E=E->next()) {
+ for (TrackMap::Element *E = track_map.front(); E; E = E->next()) {
Track &t = E->get();
if (t.skip || !t.object)
continue;
- if(t.property) { // value track
- t.object->set(t.property,t.value);
+ if (t.property) { // value track
+ t.object->set(t.property, t.value);
continue;
}
Transform xform;
- xform.basis=t.rot;
- xform.origin=t.loc;
+ xform.basis = t.rot;
+ xform.origin = t.loc;
- t.scale.x+=1.0;
- t.scale.y+=1.0;
- t.scale.z+=1.0;
+ t.scale.x += 1.0;
+ t.scale.y += 1.0;
+ t.scale.z += 1.0;
xform.basis.scale(t.scale);
- if (t.bone_idx>=0) {
+ if (t.bone_idx >= 0) {
if (t.skeleton)
- t.skeleton->set_bone_pose(t.bone_idx,xform);
+ t.skeleton->set_bone_pose(t.bone_idx, xform);
} else if (t.spatial) {
t.spatial->set_transform(xform);
}
}
-
-
-
}
+void AnimationTreePlayer::add_node(NodeType p_type, const StringName &p_node) {
-void AnimationTreePlayer::add_node(NodeType p_type, const StringName& p_node) {
-
- ERR_FAIL_COND( p_type == NODE_OUTPUT );
- ERR_FAIL_COND( node_map.has(p_node));
+ ERR_FAIL_COND(p_type == NODE_OUTPUT);
+ ERR_FAIL_COND(node_map.has(p_node));
- NodeBase *n=NULL;
+ NodeBase *n = NULL;
- switch(p_type) {
+ switch (p_type) {
case NODE_ANIMATION: {
- n = memnew( AnimationNode );
+ n = memnew(AnimationNode);
} break;
case NODE_ONESHOT: {
- n = memnew( OneShotNode );
+ n = memnew(OneShotNode);
} break;
case NODE_MIX: {
- n = memnew( MixNode );
+ n = memnew(MixNode);
} break;
case NODE_BLEND2: {
- n = memnew( Blend2Node );
+ n = memnew(Blend2Node);
} break;
case NODE_BLEND3: {
- n = memnew( Blend3Node );
+ n = memnew(Blend3Node);
} break;
case NODE_BLEND4: {
- n = memnew( Blend4Node );
+ n = memnew(Blend4Node);
} break;
case NODE_TIMESCALE: {
- n = memnew( TimeScaleNode );
-
+ n = memnew(TimeScaleNode);
} break;
case NODE_TIMESEEK: {
- n = memnew( TimeSeekNode );
+ n = memnew(TimeSeekNode);
} break;
case NODE_TRANSITION: {
- n = memnew( TransitionNode );
-
+ n = memnew(TransitionNode);
} break;
default: {}
}
//n->name+=" "+itos(p_node);
- node_map[p_node]=n;
+ node_map[p_node] = n;
}
+StringName AnimationTreePlayer::node_get_input_source(const StringName &p_node, int p_input) const {
-StringName AnimationTreePlayer::node_get_input_source(const StringName& p_node,int p_input) const {
-
- ERR_FAIL_COND_V(!node_map.has(p_node),StringName());
- ERR_FAIL_INDEX_V( p_input,node_map[p_node]->inputs.size(),StringName() );
+ ERR_FAIL_COND_V(!node_map.has(p_node), StringName());
+ ERR_FAIL_INDEX_V(p_input, node_map[p_node]->inputs.size(), StringName());
return node_map[p_node]->inputs[p_input].node;
-
}
+int AnimationTreePlayer::node_get_input_count(const StringName &p_node) const {
-int AnimationTreePlayer::node_get_input_count(const StringName& p_node) const {
-
- ERR_FAIL_COND_V(!node_map.has(p_node),-1);
+ ERR_FAIL_COND_V(!node_map.has(p_node), -1);
return node_map[p_node]->inputs.size();
-
}
-#define GET_NODE( m_type, m_cast )\
- ERR_FAIL_COND(!node_map.has(p_node));\
- ERR_EXPLAIN("Invalid parameter for node type.");\
- ERR_FAIL_COND(node_map[p_node]->type!=m_type);\
- m_cast *n = static_cast<m_cast*>( node_map[p_node] );\
-
-
-
-void AnimationTreePlayer::animation_node_set_animation(const StringName& p_node,const Ref<Animation>& p_animation) {
-
- GET_NODE( NODE_ANIMATION, AnimationNode );
- n->animation=p_animation;
- dirty_caches=true;
+#define GET_NODE(m_type, m_cast) \
+ ERR_FAIL_COND(!node_map.has(p_node)); \
+ ERR_EXPLAIN("Invalid parameter for node type."); \
+ ERR_FAIL_COND(node_map[p_node]->type != m_type); \
+ m_cast *n = static_cast<m_cast *>(node_map[p_node]);
+void AnimationTreePlayer::animation_node_set_animation(const StringName &p_node, const Ref<Animation> &p_animation) {
+ GET_NODE(NODE_ANIMATION, AnimationNode);
+ n->animation = p_animation;
+ dirty_caches = true;
}
-void AnimationTreePlayer::animation_node_set_master_animation(const StringName& p_node,const String& p_master_animation) {
+void AnimationTreePlayer::animation_node_set_master_animation(const StringName &p_node, const String &p_master_animation) {
- GET_NODE( NODE_ANIMATION, AnimationNode );
- n->from=p_master_animation;
- dirty_caches=true;
- if (master!=NodePath())
+ GET_NODE(NODE_ANIMATION, AnimationNode);
+ n->from = p_master_animation;
+ dirty_caches = true;
+ if (master != NodePath())
_update_sources();
-
-
}
-void AnimationTreePlayer::animation_node_set_filter_path(const StringName& p_node,const NodePath& p_track_path,bool p_filter) {
+void AnimationTreePlayer::animation_node_set_filter_path(const StringName &p_node, const NodePath &p_track_path, bool p_filter) {
- GET_NODE( NODE_ANIMATION, AnimationNode );
+ GET_NODE(NODE_ANIMATION, AnimationNode);
if (p_filter)
- n->filter[p_track_path]=true;
+ n->filter[p_track_path] = true;
else
n->filter.erase(p_track_path);
-
}
-void AnimationTreePlayer::animation_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const{
+void AnimationTreePlayer::animation_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const {
- GET_NODE( NODE_ANIMATION, AnimationNode );
+ GET_NODE(NODE_ANIMATION, AnimationNode);
n->filter.get_key_list(r_paths);
}
-void AnimationTreePlayer::oneshot_node_set_fadein_time(const StringName& p_node,float p_time) {
-
- GET_NODE( NODE_ONESHOT, OneShotNode );
- n->fade_in=p_time;
+void AnimationTreePlayer::oneshot_node_set_fadein_time(const StringName &p_node, float p_time) {
+ GET_NODE(NODE_ONESHOT, OneShotNode);
+ n->fade_in = p_time;
}
+void AnimationTreePlayer::oneshot_node_set_fadeout_time(const StringName &p_node, float p_time) {
-void AnimationTreePlayer::oneshot_node_set_fadeout_time(const StringName& p_node,float p_time) {
-
- GET_NODE( NODE_ONESHOT, OneShotNode );
- n->fade_out=p_time;
-
-
+ GET_NODE(NODE_ONESHOT, OneShotNode);
+ n->fade_out = p_time;
}
-void AnimationTreePlayer::oneshot_node_set_mix_mode(const StringName& p_node,bool p_mix) {
+void AnimationTreePlayer::oneshot_node_set_mix_mode(const StringName &p_node, bool p_mix) {
- GET_NODE( NODE_ONESHOT, OneShotNode );
- n->mix=p_mix;
+ GET_NODE(NODE_ONESHOT, OneShotNode);
+ n->mix = p_mix;
}
+void AnimationTreePlayer::oneshot_node_set_autorestart(const StringName &p_node, bool p_active) {
-void AnimationTreePlayer::oneshot_node_set_autorestart(const StringName& p_node,bool p_active) {
-
- GET_NODE( NODE_ONESHOT, OneShotNode );
- n->autorestart=p_active;
-
+ GET_NODE(NODE_ONESHOT, OneShotNode);
+ n->autorestart = p_active;
}
-void AnimationTreePlayer::oneshot_node_set_autorestart_delay(const StringName& p_node,float p_time) {
-
- GET_NODE( NODE_ONESHOT, OneShotNode );
- n->autorestart_delay=p_time;
+void AnimationTreePlayer::oneshot_node_set_autorestart_delay(const StringName &p_node, float p_time) {
+ GET_NODE(NODE_ONESHOT, OneShotNode);
+ n->autorestart_delay = p_time;
}
-void AnimationTreePlayer::oneshot_node_set_autorestart_random_delay(const StringName& p_node,float p_time) {
-
- GET_NODE( NODE_ONESHOT, OneShotNode );
- n->autorestart_random_delay=p_time;
+void AnimationTreePlayer::oneshot_node_set_autorestart_random_delay(const StringName &p_node, float p_time) {
+ GET_NODE(NODE_ONESHOT, OneShotNode);
+ n->autorestart_random_delay = p_time;
}
-void AnimationTreePlayer::oneshot_node_start(const StringName& p_node) {
-
- GET_NODE( NODE_ONESHOT, OneShotNode );
- n->active=true;
- n->start=true;
+void AnimationTreePlayer::oneshot_node_start(const StringName &p_node) {
+ GET_NODE(NODE_ONESHOT, OneShotNode);
+ n->active = true;
+ n->start = true;
}
+void AnimationTreePlayer::oneshot_node_stop(const StringName &p_node) {
-void AnimationTreePlayer::oneshot_node_stop(const StringName& p_node) {
-
- GET_NODE( NODE_ONESHOT, OneShotNode );
- n->active=false;
-
+ GET_NODE(NODE_ONESHOT, OneShotNode);
+ n->active = false;
}
+void AnimationTreePlayer::oneshot_node_set_filter_path(const StringName &p_node, const NodePath &p_filter, bool p_enable) {
-void AnimationTreePlayer::oneshot_node_set_filter_path(const StringName& p_node,const NodePath& p_filter,bool p_enable) {
-
- GET_NODE( NODE_ONESHOT, OneShotNode );
+ GET_NODE(NODE_ONESHOT, OneShotNode);
if (p_enable)
- n->filter[p_filter]=true;
+ n->filter[p_filter] = true;
else
n->filter.erase(p_filter);
-
}
-void AnimationTreePlayer::oneshot_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const{
+void AnimationTreePlayer::oneshot_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const {
- GET_NODE( NODE_ONESHOT, OneShotNode );
+ GET_NODE(NODE_ONESHOT, OneShotNode);
n->filter.get_key_list(r_paths);
}
+void AnimationTreePlayer::mix_node_set_amount(const StringName &p_node, float p_amount) {
-void AnimationTreePlayer::mix_node_set_amount(const StringName& p_node,float p_amount) {
-
- GET_NODE( NODE_MIX, MixNode );
- n->amount=p_amount;
-
+ GET_NODE(NODE_MIX, MixNode);
+ n->amount = p_amount;
}
+void AnimationTreePlayer::blend2_node_set_amount(const StringName &p_node, float p_amount) {
-void AnimationTreePlayer::blend2_node_set_amount(const StringName& p_node,float p_amount) {
-
- GET_NODE( NODE_BLEND2, Blend2Node );
- n->value=p_amount;
-
+ GET_NODE(NODE_BLEND2, Blend2Node);
+ n->value = p_amount;
}
-void AnimationTreePlayer::blend2_node_set_filter_path(const StringName& p_node,const NodePath& p_filter,bool p_enable) {
+void AnimationTreePlayer::blend2_node_set_filter_path(const StringName &p_node, const NodePath &p_filter, bool p_enable) {
- GET_NODE( NODE_BLEND2, Blend2Node );
+ GET_NODE(NODE_BLEND2, Blend2Node);
if (p_enable)
- n->filter[p_filter]=true;
+ n->filter[p_filter] = true;
else
n->filter.erase(p_filter);
-
}
-void AnimationTreePlayer::blend2_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const{
+void AnimationTreePlayer::blend2_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const {
- GET_NODE( NODE_BLEND2, Blend2Node );
+ GET_NODE(NODE_BLEND2, Blend2Node);
n->filter.get_key_list(r_paths);
}
+void AnimationTreePlayer::blend3_node_set_amount(const StringName &p_node, float p_amount) {
-void AnimationTreePlayer::blend3_node_set_amount(const StringName& p_node,float p_amount) {
-
- GET_NODE( NODE_BLEND3, Blend3Node );
- n->value=p_amount;
-
+ GET_NODE(NODE_BLEND3, Blend3Node);
+ n->value = p_amount;
}
-void AnimationTreePlayer::blend4_node_set_amount(const StringName& p_node,const Vector2& p_amount) {
-
- GET_NODE( NODE_BLEND4, Blend4Node );
- n->value=p_amount;
+void AnimationTreePlayer::blend4_node_set_amount(const StringName &p_node, const Vector2 &p_amount) {
+ GET_NODE(NODE_BLEND4, Blend4Node);
+ n->value = p_amount;
}
-void AnimationTreePlayer::timescale_node_set_scale(const StringName& p_node,float p_scale) {
-
-
- GET_NODE( NODE_TIMESCALE, TimeScaleNode );
- n->scale=p_scale;
+void AnimationTreePlayer::timescale_node_set_scale(const StringName &p_node, float p_scale) {
+ GET_NODE(NODE_TIMESCALE, TimeScaleNode);
+ n->scale = p_scale;
}
-void AnimationTreePlayer::timeseek_node_seek(const StringName& p_node,float p_pos) {
-
-
- GET_NODE( NODE_TIMESEEK, TimeSeekNode );
- n->seek_pos=p_pos;
+void AnimationTreePlayer::timeseek_node_seek(const StringName &p_node, float p_pos) {
+ GET_NODE(NODE_TIMESEEK, TimeSeekNode);
+ n->seek_pos = p_pos;
}
-void AnimationTreePlayer::transition_node_set_input_count(const StringName& p_node, int p_inputs) {
-
+void AnimationTreePlayer::transition_node_set_input_count(const StringName &p_node, int p_inputs) {
- GET_NODE( NODE_TRANSITION, TransitionNode );
- ERR_FAIL_COND(p_inputs<1);
+ GET_NODE(NODE_TRANSITION, TransitionNode);
+ ERR_FAIL_COND(p_inputs < 1);
n->inputs.resize(p_inputs);
n->input_data.resize(p_inputs);
- last_error=_cycle_test(out_name);
-
+ last_error = _cycle_test(out_name);
}
-void AnimationTreePlayer::transition_node_set_input_auto_advance(const StringName& p_node, int p_input,bool p_auto_advance) {
+void AnimationTreePlayer::transition_node_set_input_auto_advance(const StringName &p_node, int p_input, bool p_auto_advance) {
- GET_NODE( NODE_TRANSITION, TransitionNode );
- ERR_FAIL_INDEX(p_input,n->input_data.size());
-
- n->input_data[p_input].auto_advance=p_auto_advance;
+ GET_NODE(NODE_TRANSITION, TransitionNode);
+ ERR_FAIL_INDEX(p_input, n->input_data.size());
+ n->input_data[p_input].auto_advance = p_auto_advance;
}
-void AnimationTreePlayer::transition_node_set_xfade_time(const StringName& p_node, float p_time) {
-
+void AnimationTreePlayer::transition_node_set_xfade_time(const StringName &p_node, float p_time) {
- GET_NODE( NODE_TRANSITION, TransitionNode );
- n->xfade=p_time;
+ GET_NODE(NODE_TRANSITION, TransitionNode);
+ n->xfade = p_time;
}
void AnimationTreePlayer::TransitionNode::set_current(int p_current) {
- ERR_FAIL_INDEX(p_current,inputs.size());
+ ERR_FAIL_INDEX(p_current, inputs.size());
- if (current==p_current)
+ if (current == p_current)
return;
- prev=current;
- prev_xfading=xfade;
- prev_time=time;
- time=0;
- current=p_current;
- switched=true;
+ prev = current;
+ prev_xfading = xfade;
+ prev_time = time;
+ time = 0;
+ current = p_current;
+ switched = true;
}
-void AnimationTreePlayer::transition_node_set_current(const StringName& p_node, int p_current) {
+void AnimationTreePlayer::transition_node_set_current(const StringName &p_node, int p_current) {
- GET_NODE( NODE_TRANSITION, TransitionNode );
+ GET_NODE(NODE_TRANSITION, TransitionNode);
n->set_current(p_current);
}
-
-void AnimationTreePlayer::node_set_pos(const StringName& p_node, const Vector2& p_pos) {
+void AnimationTreePlayer::node_set_pos(const StringName &p_node, const Vector2 &p_pos) {
ERR_FAIL_COND(!node_map.has(p_node));
- node_map[p_node]->pos=p_pos;
-
+ node_map[p_node]->pos = p_pos;
}
-AnimationTreePlayer::NodeType AnimationTreePlayer::node_get_type(const StringName& p_node) const {
+AnimationTreePlayer::NodeType AnimationTreePlayer::node_get_type(const StringName &p_node) const {
- ERR_FAIL_COND_V(!node_map.has(p_node),NODE_OUTPUT);
+ ERR_FAIL_COND_V(!node_map.has(p_node), NODE_OUTPUT);
return node_map[p_node]->type;
-
}
-Point2 AnimationTreePlayer::node_get_pos(const StringName& p_node) const {
+Point2 AnimationTreePlayer::node_get_pos(const StringName &p_node) const {
- ERR_FAIL_COND_V(!node_map.has(p_node),Point2());
+ ERR_FAIL_COND_V(!node_map.has(p_node), Point2());
return node_map[p_node]->pos;
-
-
}
-#define GET_NODE_V( m_type, m_cast, m_ret )\
- ERR_FAIL_COND_V(!node_map.has(p_node),m_ret);\
- ERR_EXPLAIN("Invalid parameter for node type.");\
- ERR_FAIL_COND_V(node_map[p_node]->type!=m_type,m_ret);\
- m_cast *n = static_cast<m_cast*>( node_map[p_node] );\
+#define GET_NODE_V(m_type, m_cast, m_ret) \
+ ERR_FAIL_COND_V(!node_map.has(p_node), m_ret); \
+ ERR_EXPLAIN("Invalid parameter for node type."); \
+ ERR_FAIL_COND_V(node_map[p_node]->type != m_type, m_ret); \
+ m_cast *n = static_cast<m_cast *>(node_map[p_node]);
-Ref<Animation> AnimationTreePlayer::animation_node_get_animation(const StringName& p_node) const {
+Ref<Animation> AnimationTreePlayer::animation_node_get_animation(const StringName &p_node) const {
GET_NODE_V(NODE_ANIMATION, AnimationNode, Ref<Animation>());
return n->animation;
-
}
-String AnimationTreePlayer::animation_node_get_master_animation(const StringName& p_node) const {
+String AnimationTreePlayer::animation_node_get_master_animation(const StringName &p_node) const {
GET_NODE_V(NODE_ANIMATION, AnimationNode, String());
return n->from;
-
}
-bool AnimationTreePlayer::animation_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const {
+bool AnimationTreePlayer::animation_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const {
- GET_NODE_V(NODE_ANIMATION, AnimationNode, 0 );
+ GET_NODE_V(NODE_ANIMATION, AnimationNode, 0);
return n->filter.has(p_path);
}
-float AnimationTreePlayer::oneshot_node_get_fadein_time(const StringName& p_node) const {
+float AnimationTreePlayer::oneshot_node_get_fadein_time(const StringName &p_node) const {
-
- GET_NODE_V(NODE_ONESHOT, OneShotNode, 0 );
+ GET_NODE_V(NODE_ONESHOT, OneShotNode, 0);
return n->fade_in;
-
}
-float AnimationTreePlayer::oneshot_node_get_fadeout_time(const StringName& p_node) const {
+float AnimationTreePlayer::oneshot_node_get_fadeout_time(const StringName &p_node) const {
- GET_NODE_V(NODE_ONESHOT, OneShotNode, 0 );
+ GET_NODE_V(NODE_ONESHOT, OneShotNode, 0);
return n->fade_out;
-
}
-bool AnimationTreePlayer::oneshot_node_get_mix_mode(const StringName& p_node) const {
+bool AnimationTreePlayer::oneshot_node_get_mix_mode(const StringName &p_node) const {
- GET_NODE_V(NODE_ONESHOT, OneShotNode, 0 );
+ GET_NODE_V(NODE_ONESHOT, OneShotNode, 0);
return n->mix;
-
}
-bool AnimationTreePlayer::oneshot_node_has_autorestart(const StringName& p_node) const {
+bool AnimationTreePlayer::oneshot_node_has_autorestart(const StringName &p_node) const {
- GET_NODE_V(NODE_ONESHOT, OneShotNode, 0 );
+ GET_NODE_V(NODE_ONESHOT, OneShotNode, 0);
return n->autorestart;
-
}
-float AnimationTreePlayer::oneshot_node_get_autorestart_delay(const StringName& p_node) const {
+float AnimationTreePlayer::oneshot_node_get_autorestart_delay(const StringName &p_node) const {
- GET_NODE_V(NODE_ONESHOT, OneShotNode, 0 );
+ GET_NODE_V(NODE_ONESHOT, OneShotNode, 0);
return n->autorestart_delay;
-
}
-float AnimationTreePlayer::oneshot_node_get_autorestart_random_delay(const StringName& p_node) const {
+float AnimationTreePlayer::oneshot_node_get_autorestart_random_delay(const StringName &p_node) const {
- GET_NODE_V(NODE_ONESHOT, OneShotNode, 0 );
+ GET_NODE_V(NODE_ONESHOT, OneShotNode, 0);
return n->autorestart_random_delay;
-
}
-bool AnimationTreePlayer::oneshot_node_is_active(const StringName& p_node) const {
-
+bool AnimationTreePlayer::oneshot_node_is_active(const StringName &p_node) const {
- GET_NODE_V(NODE_ONESHOT, OneShotNode, 0 );
+ GET_NODE_V(NODE_ONESHOT, OneShotNode, 0);
return n->active;
-
}
-bool AnimationTreePlayer::oneshot_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const {
+bool AnimationTreePlayer::oneshot_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const {
- GET_NODE_V(NODE_ONESHOT, OneShotNode, 0 );
+ GET_NODE_V(NODE_ONESHOT, OneShotNode, 0);
return n->filter.has(p_path);
}
+float AnimationTreePlayer::mix_node_get_amount(const StringName &p_node) const {
-float AnimationTreePlayer::mix_node_get_amount(const StringName& p_node) const {
-
- GET_NODE_V(NODE_MIX, MixNode, 0 );
+ GET_NODE_V(NODE_MIX, MixNode, 0);
return n->amount;
-
}
-float AnimationTreePlayer::blend2_node_get_amount(const StringName& p_node) const {
+float AnimationTreePlayer::blend2_node_get_amount(const StringName &p_node) const {
- GET_NODE_V(NODE_BLEND2, Blend2Node, 0 );
+ GET_NODE_V(NODE_BLEND2, Blend2Node, 0);
return n->value;
-
}
-bool AnimationTreePlayer::blend2_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const {
+bool AnimationTreePlayer::blend2_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const {
- GET_NODE_V(NODE_BLEND2, Blend2Node, 0 );
+ GET_NODE_V(NODE_BLEND2, Blend2Node, 0);
return n->filter.has(p_path);
}
-float AnimationTreePlayer::blend3_node_get_amount(const StringName& p_node) const {
-
+float AnimationTreePlayer::blend3_node_get_amount(const StringName &p_node) const {
- GET_NODE_V(NODE_BLEND3, Blend3Node, 0 );
+ GET_NODE_V(NODE_BLEND3, Blend3Node, 0);
return n->value;
-
}
-Vector2 AnimationTreePlayer::blend4_node_get_amount(const StringName& p_node) const {
+Vector2 AnimationTreePlayer::blend4_node_get_amount(const StringName &p_node) const {
- GET_NODE_V(NODE_BLEND4, Blend4Node, Vector2() );
+ GET_NODE_V(NODE_BLEND4, Blend4Node, Vector2());
return n->value;
-
}
-float AnimationTreePlayer::timescale_node_get_scale(const StringName& p_node) const {
+float AnimationTreePlayer::timescale_node_get_scale(const StringName &p_node) const {
- GET_NODE_V(NODE_TIMESCALE, TimeScaleNode, 0 );
+ GET_NODE_V(NODE_TIMESCALE, TimeScaleNode, 0);
return n->scale;
-
}
-void AnimationTreePlayer::transition_node_delete_input(const StringName& p_node, int p_input) {
+void AnimationTreePlayer::transition_node_delete_input(const StringName &p_node, int p_input) {
GET_NODE(NODE_TRANSITION, TransitionNode);
- ERR_FAIL_INDEX(p_input,n->inputs.size());
+ ERR_FAIL_INDEX(p_input, n->inputs.size());
- if (n->inputs.size()<=1)
+ if (n->inputs.size() <= 1)
return;
-
n->inputs.remove(p_input);
n->input_data.remove(p_input);
- last_error=_cycle_test(out_name);
+ last_error = _cycle_test(out_name);
}
+int AnimationTreePlayer::transition_node_get_input_count(const StringName &p_node) const {
-int AnimationTreePlayer::transition_node_get_input_count(const StringName& p_node) const {
-
- GET_NODE_V(NODE_TRANSITION, TransitionNode, 0 );
+ GET_NODE_V(NODE_TRANSITION, TransitionNode, 0);
return n->inputs.size();
}
-bool AnimationTreePlayer::transition_node_has_input_auto_advance(const StringName& p_node, int p_input) const {
+bool AnimationTreePlayer::transition_node_has_input_auto_advance(const StringName &p_node, int p_input) const {
- GET_NODE_V(NODE_TRANSITION, TransitionNode, false );
- ERR_FAIL_INDEX_V(p_input,n->inputs.size(),false);
+ GET_NODE_V(NODE_TRANSITION, TransitionNode, false);
+ ERR_FAIL_INDEX_V(p_input, n->inputs.size(), false);
return n->input_data[p_input].auto_advance;
-
}
-float AnimationTreePlayer::transition_node_get_xfade_time(const StringName& p_node) const {
+float AnimationTreePlayer::transition_node_get_xfade_time(const StringName &p_node) const {
- GET_NODE_V(NODE_TRANSITION, TransitionNode, 0 );
+ GET_NODE_V(NODE_TRANSITION, TransitionNode, 0);
return n->xfade;
-
}
-int AnimationTreePlayer::transition_node_get_current(const StringName& p_node) const {
+int AnimationTreePlayer::transition_node_get_current(const StringName &p_node) const {
- GET_NODE_V(NODE_TRANSITION, TransitionNode, -1 );
+ GET_NODE_V(NODE_TRANSITION, TransitionNode, -1);
return n->current;
-
}
- /*misc */
+/*misc */
void AnimationTreePlayer::get_node_list(List<StringName> *p_node_list) const {
- for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
- p_node_list->push_back( E->key() );
+ p_node_list->push_back(E->key());
}
}
-void AnimationTreePlayer::remove_node(const StringName& p_node) {
+void AnimationTreePlayer::remove_node(const StringName &p_node) {
- ERR_FAIL_COND( !node_map.has(p_node) );
+ ERR_FAIL_COND(!node_map.has(p_node));
ERR_EXPLAIN("Node 0 (output) can't be removed.");
- ERR_FAIL_COND( p_node == out_name );
+ ERR_FAIL_COND(p_node == out_name);
- for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
NodeBase *nb = E->get();
- for(int i=0;i<nb->inputs.size();i++) {
+ for (int i = 0; i < nb->inputs.size(); i++) {
- if (nb->inputs[i].node==p_node)
- nb->inputs[i].node=StringName();
+ if (nb->inputs[i].node == p_node)
+ nb->inputs[i].node = StringName();
}
}
node_map.erase(p_node);
// compute last error again, just in case
- last_error=_cycle_test(out_name);
- dirty_caches=true;
+ last_error = _cycle_test(out_name);
+ dirty_caches = true;
}
-
-AnimationTreePlayer::ConnectError AnimationTreePlayer::_cycle_test(const StringName& p_at_node) {
+AnimationTreePlayer::ConnectError AnimationTreePlayer::_cycle_test(const StringName &p_at_node) {
ERR_FAIL_COND_V(!node_map.has(p_at_node), CONNECT_INCOMPLETE);
@@ -1480,11 +1371,10 @@ AnimationTreePlayer::ConnectError AnimationTreePlayer::_cycle_test(const StringN
if (nb->cycletest)
return CONNECT_CYCLE;
+ nb->cycletest = true;
- nb->cycletest=true;
-
- for(int i=0;i<nb->inputs.size();i++) {
- if (nb->inputs[i].node==StringName())
+ for (int i = 0; i < nb->inputs.size(); i++) {
+ if (nb->inputs[i].node == StringName())
return CONNECT_INCOMPLETE;
ConnectError _err = _cycle_test(nb->inputs[i].node);
@@ -1495,195 +1385,184 @@ AnimationTreePlayer::ConnectError AnimationTreePlayer::_cycle_test(const StringN
return CONNECT_OK;
}
+Error AnimationTreePlayer::connect(const StringName &p_src_node, const StringName &p_dst_node, int p_dst_input) {
-Error AnimationTreePlayer::connect(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) {
+ ERR_FAIL_COND_V(!node_map.has(p_src_node), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(!node_map.has(p_dst_node), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_src_node == p_dst_node, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V( !node_map.has(p_src_node) , ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V( !node_map.has(p_dst_node) , ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V( p_src_node==p_dst_node , ERR_INVALID_PARAMETER);
-
-// NodeBase *src = node_map[p_src_node];
+ // NodeBase *src = node_map[p_src_node];
NodeBase *dst = node_map[p_dst_node];
- ERR_FAIL_INDEX_V( p_dst_input, dst->inputs.size(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_INDEX_V(p_dst_input, dst->inputs.size(), ERR_INVALID_PARAMETER);
-// int oldval = dst->inputs[p_dst_input].node;
+ // int oldval = dst->inputs[p_dst_input].node;
- for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
NodeBase *nb = E->get();
- for(int i=0;i<nb->inputs.size();i++) {
+ for (int i = 0; i < nb->inputs.size(); i++) {
- if (nb->inputs[i].node==p_src_node)
- nb->inputs[i].node=StringName();
+ if (nb->inputs[i].node == p_src_node)
+ nb->inputs[i].node = StringName();
}
}
- dst->inputs[p_dst_input].node=p_src_node;
+ dst->inputs[p_dst_input].node = p_src_node;
- for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
NodeBase *nb = E->get();
- nb->cycletest=false;
+ nb->cycletest = false;
}
- last_error=_cycle_test(out_name);
+ last_error = _cycle_test(out_name);
if (last_error) {
- if (last_error==CONNECT_INCOMPLETE)
+ if (last_error == CONNECT_INCOMPLETE)
return ERR_UNCONFIGURED;
- else if (last_error==CONNECT_CYCLE)
+ else if (last_error == CONNECT_CYCLE)
return ERR_CYCLIC_LINK;
}
- dirty_caches=true;
+ dirty_caches = true;
return OK;
}
-bool AnimationTreePlayer::is_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input) const {
+bool AnimationTreePlayer::is_connected(const StringName &p_src_node, const StringName &p_dst_node, int p_dst_input) const {
- ERR_FAIL_COND_V( !node_map.has(p_src_node) , false);
- ERR_FAIL_COND_V( !node_map.has(p_dst_node) , false);
- ERR_FAIL_COND_V( p_src_node==p_dst_node , false);
+ ERR_FAIL_COND_V(!node_map.has(p_src_node), false);
+ ERR_FAIL_COND_V(!node_map.has(p_dst_node), false);
+ ERR_FAIL_COND_V(p_src_node == p_dst_node, false);
NodeBase *dst = node_map[p_dst_node];
- return dst->inputs[p_dst_input].node==p_src_node;
-
+ return dst->inputs[p_dst_input].node == p_src_node;
}
-void AnimationTreePlayer::disconnect(const StringName& p_node, int p_input) {
+void AnimationTreePlayer::disconnect(const StringName &p_node, int p_input) {
- ERR_FAIL_COND( !node_map.has(p_node));
+ ERR_FAIL_COND(!node_map.has(p_node));
NodeBase *dst = node_map[p_node];
- ERR_FAIL_INDEX(p_input,dst->inputs.size());
- dst->inputs[p_input].node=StringName();
- last_error=CONNECT_INCOMPLETE;
- dirty_caches=true;
+ ERR_FAIL_INDEX(p_input, dst->inputs.size());
+ dst->inputs[p_input].node = StringName();
+ last_error = CONNECT_INCOMPLETE;
+ dirty_caches = true;
}
+void AnimationTreePlayer::get_connection_list(List<Connection> *p_connections) const {
-void AnimationTreePlayer::get_connection_list( List<Connection> *p_connections) const {
-
- for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
NodeBase *nb = E->get();
- for(int i=0;i<nb->inputs.size();i++) {
+ for (int i = 0; i < nb->inputs.size(); i++) {
- if (nb->inputs[i].node!=StringName()) {
+ if (nb->inputs[i].node != StringName()) {
Connection c;
- c.src_node=nb->inputs[i].node;
- c.dst_node=E->key();
- c.dst_input=i;
+ c.src_node = nb->inputs[i].node;
+ c.dst_node = E->key();
+ c.dst_input = i;
p_connections->push_back(c);
}
}
}
}
-AnimationTreePlayer::Track* AnimationTreePlayer::_find_track(const NodePath& p_path) {
+AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_path) {
- Node *parent=get_node(base_path);
- ERR_FAIL_COND_V(!parent,NULL);
+ Node *parent = get_node(base_path);
+ ERR_FAIL_COND_V(!parent, NULL);
RES resource;
- Node *child=parent->get_node_and_resource(p_path,resource);
+ Node *child = parent->get_node_and_resource(p_path, resource);
if (!child) {
- String err = "Animation track references unknown Node: '"+String(p_path)+"'.";
+ String err = "Animation track references unknown Node: '" + String(p_path) + "'.";
WARN_PRINT(err.ascii().get_data());
return NULL;
}
- ObjectID id=child->get_instance_ID();
+ ObjectID id = child->get_instance_ID();
StringName property;
- int bone_idx=-1;
+ int bone_idx = -1;
if (p_path.get_property()) {
if (child->cast_to<Skeleton>())
- bone_idx = child->cast_to<Skeleton>()->find_bone( p_path.get_property() );
- if (bone_idx==-1)
- property=p_path.get_property();
+ bone_idx = child->cast_to<Skeleton>()->find_bone(p_path.get_property());
+ if (bone_idx == -1)
+ property = p_path.get_property();
}
TrackKey key;
- key.id=id;
- key.bone_idx=bone_idx;
- key.property=property;
+ key.id = id;
+ key.bone_idx = bone_idx;
+ key.property = property;
if (!track_map.has(key)) {
Track tr;
- tr.id=id;
- tr.object=resource.is_valid()?(Object*)resource.ptr():(Object*)child;
- tr.skeleton=child->cast_to<Skeleton>();
- tr.spatial=child->cast_to<Spatial>();
- tr.bone_idx=bone_idx;
- tr.property=property;
+ tr.id = id;
+ tr.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child;
+ tr.skeleton = child->cast_to<Skeleton>();
+ tr.spatial = child->cast_to<Spatial>();
+ tr.bone_idx = bone_idx;
+ tr.property = property;
- track_map[key]=tr;
+ track_map[key] = tr;
}
return &track_map[key];
-
}
void AnimationTreePlayer::_recompute_caches() {
track_map.clear();
_recompute_caches(out_name);
- dirty_caches=false;
+ dirty_caches = false;
}
-void AnimationTreePlayer::_recompute_caches(const StringName& p_node) {
+void AnimationTreePlayer::_recompute_caches(const StringName &p_node) {
- ERR_FAIL_COND( !node_map.has(p_node) );
+ ERR_FAIL_COND(!node_map.has(p_node));
NodeBase *nb = node_map[p_node];
- if (nb->type==NODE_ANIMATION) {
+ if (nb->type == NODE_ANIMATION) {
- AnimationNode *an = static_cast<AnimationNode*>(nb);
+ AnimationNode *an = static_cast<AnimationNode *>(nb);
an->tref.clear();
if (!an->animation.is_null()) {
-
Ref<Animation> a = an->animation;
- for(int i=0;i<an->animation->get_track_count();i++) {
-
+ for (int i = 0; i < an->animation->get_track_count(); i++) {
Track *tr = _find_track(a->track_get_path(i));
if (!tr)
continue;
AnimationNode::TrackRef tref;
- tref.local_track=i;
- tref.track=tr;
- tref.weight=0;
+ tref.local_track = i;
+ tref.track = tr;
+ tref.weight = 0;
an->tref.push_back(tref);
-
}
}
}
- for(int i=0;i<nb->inputs.size();i++) {
+ for (int i = 0; i < nb->inputs.size(); i++) {
_recompute_caches(nb->inputs[i].node);
}
-
}
void AnimationTreePlayer::recompute_caches() {
- dirty_caches=true;
-
+ dirty_caches = true;
}
-
-
- /* playback */
+/* playback */
void AnimationTreePlayer::set_active(bool p_active) {
@@ -1699,7 +1578,6 @@ void AnimationTreePlayer::set_active(bool p_active) {
bool AnimationTreePlayer::is_active() const {
return active;
-
}
AnimationTreePlayer::ConnectError AnimationTreePlayer::get_last_error() const {
@@ -1709,33 +1587,31 @@ AnimationTreePlayer::ConnectError AnimationTreePlayer::get_last_error() const {
void AnimationTreePlayer::reset() {
-
- reset_request=true;
+ reset_request = true;
}
+void AnimationTreePlayer::set_base_path(const NodePath &p_path) {
-void AnimationTreePlayer::set_base_path(const NodePath& p_path) {
-
- base_path=p_path;
+ base_path = p_path;
recompute_caches();
}
-NodePath AnimationTreePlayer::get_base_path() const{
+NodePath AnimationTreePlayer::get_base_path() const {
return base_path;
}
-void AnimationTreePlayer::set_master_player(const NodePath& p_path) {
+void AnimationTreePlayer::set_master_player(const NodePath &p_path) {
- if (p_path==master)
+ if (p_path == master)
return;
- master=p_path;
+ master = p_path;
_update_sources();
recompute_caches();
}
-NodePath AnimationTreePlayer::get_master_player() const{
+NodePath AnimationTreePlayer::get_master_player() const {
return master;
}
@@ -1746,25 +1622,24 @@ DVector<String> AnimationTreePlayer::_get_node_list() {
get_node_list(&nl);
DVector<String> ret;
ret.resize(nl.size());
- int idx=0;
- for(List<StringName>::Element *E=nl.front();E;E=E->next()) {
- ret.set(idx++,E->get());
+ int idx = 0;
+ for (List<StringName>::Element *E = nl.front(); E; E = E->next()) {
+ ret.set(idx++, E->get());
}
return ret;
}
-
void AnimationTreePlayer::_update_sources() {
- if (master==NodePath())
+ if (master == NodePath())
return;
if (!is_inside_tree())
return;
Node *m = get_node(master);
if (!m) {
- master=NodePath();
+ master = NodePath();
ERR_FAIL_COND(!m);
}
@@ -1772,196 +1647,186 @@ void AnimationTreePlayer::_update_sources() {
if (!ap) {
- master=NodePath();
+ master = NodePath();
ERR_FAIL_COND(!ap);
}
- for (Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
- if (E->get()->type==NODE_ANIMATION) {
+ if (E->get()->type == NODE_ANIMATION) {
- AnimationNode *an = static_cast<AnimationNode*>(E->get());
+ AnimationNode *an = static_cast<AnimationNode *>(E->get());
- if (an->from!="") {
+ if (an->from != "") {
an->animation = ap->get_animation(an->from);
}
}
}
-
-
}
-bool AnimationTreePlayer::node_exists(const StringName& p_name) const {
+bool AnimationTreePlayer::node_exists(const StringName &p_name) const {
return (node_map.has(p_name));
}
-Error AnimationTreePlayer::node_rename(const StringName& p_node,const StringName& p_new_name) {
+Error AnimationTreePlayer::node_rename(const StringName &p_node, const StringName &p_new_name) {
- if (p_new_name==p_node)
+ if (p_new_name == p_node)
return OK;
- ERR_FAIL_COND_V(!node_map.has(p_node),ERR_ALREADY_EXISTS);
- ERR_FAIL_COND_V(node_map.has(p_new_name),ERR_ALREADY_EXISTS);
- ERR_FAIL_COND_V(p_new_name==StringName(),ERR_INVALID_DATA);
- ERR_FAIL_COND_V(p_node==out_name,ERR_INVALID_DATA);
- ERR_FAIL_COND_V(p_new_name==out_name,ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(!node_map.has(p_node), ERR_ALREADY_EXISTS);
+ ERR_FAIL_COND_V(node_map.has(p_new_name), ERR_ALREADY_EXISTS);
+ ERR_FAIL_COND_V(p_new_name == StringName(), ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(p_node == out_name, ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(p_new_name == out_name, ERR_INVALID_DATA);
- for(Map<StringName,NodeBase*>::Element *E=node_map.front();E;E=E->next()) {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
NodeBase *nb = E->get();
- for(int i=0;i<nb->inputs.size();i++) {
+ for (int i = 0; i < nb->inputs.size(); i++) {
- if (nb->inputs[i].node==p_node) {
- nb->inputs[i].node=p_new_name;
+ if (nb->inputs[i].node == p_node) {
+ nb->inputs[i].node = p_new_name;
}
}
}
- node_map[p_new_name]=node_map[p_node];
+ node_map[p_new_name] = node_map[p_node];
node_map.erase(p_node);
return OK;
-
}
-
void AnimationTreePlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_node","type","id"),&AnimationTreePlayer::add_node);
-
- ObjectTypeDB::bind_method(_MD("node_exists","node"),&AnimationTreePlayer::node_exists);
- ObjectTypeDB::bind_method(_MD("node_rename","node","new_name"),&AnimationTreePlayer::node_rename);
-
- ObjectTypeDB::bind_method(_MD("node_get_type","id"),&AnimationTreePlayer::node_get_type);
- ObjectTypeDB::bind_method(_MD("node_get_input_count","id"),&AnimationTreePlayer::node_get_input_count);
- ObjectTypeDB::bind_method(_MD("node_get_input_source","id","idx"),&AnimationTreePlayer::node_get_input_source);
+ ObjectTypeDB::bind_method(_MD("add_node", "type", "id"), &AnimationTreePlayer::add_node);
- ObjectTypeDB::bind_method(_MD("animation_node_set_animation","id","animation:Animation"),&AnimationTreePlayer::animation_node_set_animation);
- ObjectTypeDB::bind_method(_MD("animation_node_get_animation:Animation","id"),&AnimationTreePlayer::animation_node_get_animation);
+ ObjectTypeDB::bind_method(_MD("node_exists", "node"), &AnimationTreePlayer::node_exists);
+ ObjectTypeDB::bind_method(_MD("node_rename", "node", "new_name"), &AnimationTreePlayer::node_rename);
- ObjectTypeDB::bind_method(_MD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation);
- ObjectTypeDB::bind_method(_MD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation);
- ObjectTypeDB::bind_method(_MD("animation_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::animation_node_set_filter_path);
+ ObjectTypeDB::bind_method(_MD("node_get_type", "id"), &AnimationTreePlayer::node_get_type);
+ ObjectTypeDB::bind_method(_MD("node_get_input_count", "id"), &AnimationTreePlayer::node_get_input_count);
+ ObjectTypeDB::bind_method(_MD("node_get_input_source", "id", "idx"), &AnimationTreePlayer::node_get_input_source);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time);
- ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time);
+ ObjectTypeDB::bind_method(_MD("animation_node_set_animation", "id", "animation:Animation"), &AnimationTreePlayer::animation_node_set_animation);
+ ObjectTypeDB::bind_method(_MD("animation_node_get_animation:Animation", "id"), &AnimationTreePlayer::animation_node_get_animation);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadeout_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadeout_time);
- ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadeout_time","id"),&AnimationTreePlayer::oneshot_node_get_fadeout_time);
+ ObjectTypeDB::bind_method(_MD("animation_node_set_master_animation", "id", "source"), &AnimationTreePlayer::animation_node_set_master_animation);
+ ObjectTypeDB::bind_method(_MD("animation_node_get_master_animation", "id"), &AnimationTreePlayer::animation_node_get_master_animation);
+ ObjectTypeDB::bind_method(_MD("animation_node_set_filter_path", "id", "path", "enable"), &AnimationTreePlayer::animation_node_set_filter_path);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadein_time", "id", "time_sec"), &AnimationTreePlayer::oneshot_node_set_fadein_time);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadein_time", "id"), &AnimationTreePlayer::oneshot_node_get_fadein_time);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart","id","enable"),&AnimationTreePlayer::oneshot_node_set_autorestart);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart_delay","id","delay_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_delay);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart_random_delay","id","rand_sec"),&AnimationTreePlayer::oneshot_node_set_autorestart_random_delay);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadeout_time", "id", "time_sec"), &AnimationTreePlayer::oneshot_node_set_fadeout_time);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadeout_time", "id"), &AnimationTreePlayer::oneshot_node_get_fadeout_time);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart", "id", "enable"), &AnimationTreePlayer::oneshot_node_set_autorestart);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart_delay", "id", "delay_sec"), &AnimationTreePlayer::oneshot_node_set_autorestart_delay);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_set_autorestart_random_delay", "id", "rand_sec"), &AnimationTreePlayer::oneshot_node_set_autorestart_random_delay);
- ObjectTypeDB::bind_method(_MD("oneshot_node_has_autorestart","id"),&AnimationTreePlayer::oneshot_node_has_autorestart);
- ObjectTypeDB::bind_method(_MD("oneshot_node_get_autorestart_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_delay);
- ObjectTypeDB::bind_method(_MD("oneshot_node_get_autorestart_random_delay","id"),&AnimationTreePlayer::oneshot_node_get_autorestart_random_delay);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_has_autorestart", "id"), &AnimationTreePlayer::oneshot_node_has_autorestart);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_get_autorestart_delay", "id"), &AnimationTreePlayer::oneshot_node_get_autorestart_delay);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_get_autorestart_random_delay", "id"), &AnimationTreePlayer::oneshot_node_get_autorestart_random_delay);
- ObjectTypeDB::bind_method(_MD("oneshot_node_start","id"),&AnimationTreePlayer::oneshot_node_start);
- ObjectTypeDB::bind_method(_MD("oneshot_node_stop","id"),&AnimationTreePlayer::oneshot_node_stop);
- ObjectTypeDB::bind_method(_MD("oneshot_node_is_active","id"),&AnimationTreePlayer::oneshot_node_is_active);
- ObjectTypeDB::bind_method(_MD("oneshot_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::oneshot_node_set_filter_path);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_start", "id"), &AnimationTreePlayer::oneshot_node_start);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_stop", "id"), &AnimationTreePlayer::oneshot_node_stop);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_is_active", "id"), &AnimationTreePlayer::oneshot_node_is_active);
+ ObjectTypeDB::bind_method(_MD("oneshot_node_set_filter_path", "id", "path", "enable"), &AnimationTreePlayer::oneshot_node_set_filter_path);
- ObjectTypeDB::bind_method(_MD("mix_node_set_amount","id","ratio"),&AnimationTreePlayer::mix_node_set_amount);
- ObjectTypeDB::bind_method(_MD("mix_node_get_amount","id"),&AnimationTreePlayer::mix_node_get_amount);
+ ObjectTypeDB::bind_method(_MD("mix_node_set_amount", "id", "ratio"), &AnimationTreePlayer::mix_node_set_amount);
+ ObjectTypeDB::bind_method(_MD("mix_node_get_amount", "id"), &AnimationTreePlayer::mix_node_get_amount);
- ObjectTypeDB::bind_method(_MD("blend2_node_set_amount","id","blend"),&AnimationTreePlayer::blend2_node_set_amount);
- ObjectTypeDB::bind_method(_MD("blend2_node_get_amount","id"),&AnimationTreePlayer::blend2_node_get_amount);
- ObjectTypeDB::bind_method(_MD("blend2_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::blend2_node_set_filter_path);
+ ObjectTypeDB::bind_method(_MD("blend2_node_set_amount", "id", "blend"), &AnimationTreePlayer::blend2_node_set_amount);
+ ObjectTypeDB::bind_method(_MD("blend2_node_get_amount", "id"), &AnimationTreePlayer::blend2_node_get_amount);
+ ObjectTypeDB::bind_method(_MD("blend2_node_set_filter_path", "id", "path", "enable"), &AnimationTreePlayer::blend2_node_set_filter_path);
- ObjectTypeDB::bind_method(_MD("blend3_node_set_amount","id","blend"),&AnimationTreePlayer::blend3_node_set_amount);
- ObjectTypeDB::bind_method(_MD("blend3_node_get_amount","id"),&AnimationTreePlayer::blend3_node_get_amount);
+ ObjectTypeDB::bind_method(_MD("blend3_node_set_amount", "id", "blend"), &AnimationTreePlayer::blend3_node_set_amount);
+ ObjectTypeDB::bind_method(_MD("blend3_node_get_amount", "id"), &AnimationTreePlayer::blend3_node_get_amount);
- ObjectTypeDB::bind_method(_MD("blend4_node_set_amount","id","blend"),&AnimationTreePlayer::blend4_node_set_amount);
- ObjectTypeDB::bind_method(_MD("blend4_node_get_amount","id"),&AnimationTreePlayer::blend4_node_get_amount);
+ ObjectTypeDB::bind_method(_MD("blend4_node_set_amount", "id", "blend"), &AnimationTreePlayer::blend4_node_set_amount);
+ ObjectTypeDB::bind_method(_MD("blend4_node_get_amount", "id"), &AnimationTreePlayer::blend4_node_get_amount);
- ObjectTypeDB::bind_method(_MD("timescale_node_set_scale","id","scale"),&AnimationTreePlayer::timescale_node_set_scale);
- ObjectTypeDB::bind_method(_MD("timescale_node_get_scale","id"),&AnimationTreePlayer::timescale_node_get_scale);
+ ObjectTypeDB::bind_method(_MD("timescale_node_set_scale", "id", "scale"), &AnimationTreePlayer::timescale_node_set_scale);
+ ObjectTypeDB::bind_method(_MD("timescale_node_get_scale", "id"), &AnimationTreePlayer::timescale_node_get_scale);
- ObjectTypeDB::bind_method(_MD("timeseek_node_seek","id","pos_sec"),&AnimationTreePlayer::timeseek_node_seek);
+ ObjectTypeDB::bind_method(_MD("timeseek_node_seek", "id", "pos_sec"), &AnimationTreePlayer::timeseek_node_seek);
- ObjectTypeDB::bind_method(_MD("transition_node_set_input_count","id","count"),&AnimationTreePlayer::transition_node_set_input_count);
- ObjectTypeDB::bind_method(_MD("transition_node_get_input_count","id"),&AnimationTreePlayer::transition_node_get_input_count);
- ObjectTypeDB::bind_method(_MD("transition_node_delete_input","id","input_idx"),&AnimationTreePlayer::transition_node_delete_input);
+ ObjectTypeDB::bind_method(_MD("transition_node_set_input_count", "id", "count"), &AnimationTreePlayer::transition_node_set_input_count);
+ ObjectTypeDB::bind_method(_MD("transition_node_get_input_count", "id"), &AnimationTreePlayer::transition_node_get_input_count);
+ ObjectTypeDB::bind_method(_MD("transition_node_delete_input", "id", "input_idx"), &AnimationTreePlayer::transition_node_delete_input);
- ObjectTypeDB::bind_method(_MD("transition_node_set_input_auto_advance","id","input_idx","enable"),&AnimationTreePlayer::transition_node_set_input_auto_advance);
- ObjectTypeDB::bind_method(_MD("transition_node_has_input_auto_advance","id","input_idx"),&AnimationTreePlayer::transition_node_has_input_auto_advance);
+ ObjectTypeDB::bind_method(_MD("transition_node_set_input_auto_advance", "id", "input_idx", "enable"), &AnimationTreePlayer::transition_node_set_input_auto_advance);
+ ObjectTypeDB::bind_method(_MD("transition_node_has_input_auto_advance", "id", "input_idx"), &AnimationTreePlayer::transition_node_has_input_auto_advance);
- ObjectTypeDB::bind_method(_MD("transition_node_set_xfade_time","id","time_sec"),&AnimationTreePlayer::transition_node_set_xfade_time);
- ObjectTypeDB::bind_method(_MD("transition_node_get_xfade_time","id"),&AnimationTreePlayer::transition_node_get_xfade_time);
+ ObjectTypeDB::bind_method(_MD("transition_node_set_xfade_time", "id", "time_sec"), &AnimationTreePlayer::transition_node_set_xfade_time);
+ ObjectTypeDB::bind_method(_MD("transition_node_get_xfade_time", "id"), &AnimationTreePlayer::transition_node_get_xfade_time);
- ObjectTypeDB::bind_method(_MD("transition_node_set_current","id","input_idx"),&AnimationTreePlayer::transition_node_set_current);
- ObjectTypeDB::bind_method(_MD("transition_node_get_current","id"),&AnimationTreePlayer::transition_node_get_current);
+ ObjectTypeDB::bind_method(_MD("transition_node_set_current", "id", "input_idx"), &AnimationTreePlayer::transition_node_set_current);
+ ObjectTypeDB::bind_method(_MD("transition_node_get_current", "id"), &AnimationTreePlayer::transition_node_get_current);
+ ObjectTypeDB::bind_method(_MD("node_set_pos", "id", "screen_pos"), &AnimationTreePlayer::node_set_pos);
+ ObjectTypeDB::bind_method(_MD("node_get_pos", "id"), &AnimationTreePlayer::node_get_pos);
- ObjectTypeDB::bind_method(_MD("node_set_pos","id","screen_pos"),&AnimationTreePlayer::node_set_pos);
- ObjectTypeDB::bind_method(_MD("node_get_pos","id"),&AnimationTreePlayer::node_get_pos);
+ ObjectTypeDB::bind_method(_MD("remove_node", "id"), &AnimationTreePlayer::remove_node);
+ ObjectTypeDB::bind_method(_MD("connect", "id", "dst_id", "dst_input_idx"), &AnimationTreePlayer::connect);
+ ObjectTypeDB::bind_method(_MD("is_connected", "id", "dst_id", "dst_input_idx"), &AnimationTreePlayer::is_connected);
+ ObjectTypeDB::bind_method(_MD("disconnect", "id", "dst_input_idx"), &AnimationTreePlayer::disconnect);
- ObjectTypeDB::bind_method(_MD("remove_node","id"),&AnimationTreePlayer::remove_node);
- ObjectTypeDB::bind_method(_MD("connect","id","dst_id","dst_input_idx"),&AnimationTreePlayer::connect);
- ObjectTypeDB::bind_method(_MD("is_connected","id","dst_id","dst_input_idx"),&AnimationTreePlayer::is_connected);
- ObjectTypeDB::bind_method(_MD("disconnect","id","dst_input_idx"),&AnimationTreePlayer::disconnect);
+ ObjectTypeDB::bind_method(_MD("set_active", "enabled"), &AnimationTreePlayer::set_active);
+ ObjectTypeDB::bind_method(_MD("is_active"), &AnimationTreePlayer::is_active);
- ObjectTypeDB::bind_method(_MD("set_active","enabled"),&AnimationTreePlayer::set_active);
- ObjectTypeDB::bind_method(_MD("is_active"),&AnimationTreePlayer::is_active);
+ ObjectTypeDB::bind_method(_MD("set_base_path", "path"), &AnimationTreePlayer::set_base_path);
+ ObjectTypeDB::bind_method(_MD("get_base_path"), &AnimationTreePlayer::get_base_path);
- ObjectTypeDB::bind_method(_MD("set_base_path","path"),&AnimationTreePlayer::set_base_path);
- ObjectTypeDB::bind_method(_MD("get_base_path"),&AnimationTreePlayer::get_base_path);
+ ObjectTypeDB::bind_method(_MD("set_master_player", "nodepath"), &AnimationTreePlayer::set_master_player);
+ ObjectTypeDB::bind_method(_MD("get_master_player"), &AnimationTreePlayer::get_master_player);
- ObjectTypeDB::bind_method(_MD("set_master_player","nodepath"),&AnimationTreePlayer::set_master_player);
- ObjectTypeDB::bind_method(_MD("get_master_player"),&AnimationTreePlayer::get_master_player);
+ ObjectTypeDB::bind_method(_MD("get_node_list"), &AnimationTreePlayer::_get_node_list);
- ObjectTypeDB::bind_method(_MD("get_node_list"),&AnimationTreePlayer::_get_node_list);
-
- ObjectTypeDB::bind_method(_MD("set_animation_process_mode","mode"),&AnimationTreePlayer::set_animation_process_mode);
- ObjectTypeDB::bind_method(_MD("get_animation_process_mode"),&AnimationTreePlayer::get_animation_process_mode);
+ ObjectTypeDB::bind_method(_MD("set_animation_process_mode", "mode"), &AnimationTreePlayer::set_animation_process_mode);
+ ObjectTypeDB::bind_method(_MD("get_animation_process_mode"), &AnimationTreePlayer::get_animation_process_mode);
ObjectTypeDB::bind_method(_MD("advance", "delta"), &AnimationTreePlayer::advance);
+ ObjectTypeDB::bind_method(_MD("reset"), &AnimationTreePlayer::reset);
- ObjectTypeDB::bind_method(_MD("reset"),&AnimationTreePlayer::reset);
-
- ObjectTypeDB::bind_method(_MD("recompute_caches"),&AnimationTreePlayer::recompute_caches);
+ ObjectTypeDB::bind_method(_MD("recompute_caches"), &AnimationTreePlayer::recompute_caches);
ADD_PROPERTY(PropertyInfo(Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_animation_process_mode"), _SCS("get_animation_process_mode"));
- BIND_CONSTANT( NODE_OUTPUT );
- BIND_CONSTANT( NODE_ANIMATION );
- BIND_CONSTANT( NODE_ONESHOT );
- BIND_CONSTANT( NODE_MIX );
- BIND_CONSTANT( NODE_BLEND2 );
- BIND_CONSTANT( NODE_BLEND3 );
- BIND_CONSTANT( NODE_BLEND4 );
- BIND_CONSTANT( NODE_TIMESCALE );
- BIND_CONSTANT( NODE_TIMESEEK );
- BIND_CONSTANT( NODE_TRANSITION );
+ BIND_CONSTANT(NODE_OUTPUT);
+ BIND_CONSTANT(NODE_ANIMATION);
+ BIND_CONSTANT(NODE_ONESHOT);
+ BIND_CONSTANT(NODE_MIX);
+ BIND_CONSTANT(NODE_BLEND2);
+ BIND_CONSTANT(NODE_BLEND3);
+ BIND_CONSTANT(NODE_BLEND4);
+ BIND_CONSTANT(NODE_TIMESCALE);
+ BIND_CONSTANT(NODE_TIMESEEK);
+ BIND_CONSTANT(NODE_TRANSITION);
}
-
AnimationTreePlayer::AnimationTreePlayer() {
- active_list=NULL;
- out = memnew( NodeOut ) ;
- out_name="out";
- out->pos=Point2(40,40);
- node_map.insert( out_name , out);
+ active_list = NULL;
+ out = memnew(NodeOut);
+ out_name = "out";
+ out->pos = Point2(40, 40);
+ node_map.insert(out_name, out);
animation_process_mode = ANIMATION_PROCESS_IDLE;
processing = false;
- active=false;
- dirty_caches=true;
- reset_request=true;
- last_error=CONNECT_INCOMPLETE;
- base_path=String("..");
+ active = false;
+ dirty_caches = true;
+ reset_request = true;
+ last_error = CONNECT_INCOMPLETE;
+ base_path = String("..");
}
-
AnimationTreePlayer::~AnimationTreePlayer() {
- while(node_map.size()) {
- memdelete( node_map.front()->get() );
- node_map.erase( node_map.front() );
+ while (node_map.size()) {
+ memdelete(node_map.front()->get());
+ node_map.erase(node_map.front());
}
}
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index 247ac52b8..6109dd28b 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -29,16 +29,14 @@
#ifndef ANIMATION_TREE_PLAYER_H
#define ANIMATION_TREE_PLAYER_H
-
-#include "scene/resources/animation.h"
-#include "scene/3d/spatial.h"
-#include "scene/3d/skeleton.h"
#include "animation_player.h"
-
+#include "scene/3d/skeleton.h"
+#include "scene/3d/spatial.h"
+#include "scene/resources/animation.h"
class AnimationTreePlayer : public Node {
- OBJ_TYPE( AnimationTreePlayer, Node );
+ OBJ_TYPE(AnimationTreePlayer, Node);
OBJ_CATEGORY("Animation Nodes");
public:
@@ -71,10 +69,9 @@ public:
};
private:
-
enum {
- DISCONNECTED=-1,
+ DISCONNECTED = -1,
};
struct TrackKey {
@@ -83,23 +80,22 @@ private:
StringName property;
int bone_idx;
- inline bool operator<(const TrackKey& p_right) const {
+ inline bool operator<(const TrackKey &p_right) const {
- if (id==p_right.id) {
- if (bone_idx==p_right.bone_idx) {
- return property<p_right.property;
+ if (id == p_right.id) {
+ if (bone_idx == p_right.bone_idx) {
+ return property < p_right.property;
} else
- return bone_idx<p_right.bone_idx;
+ return bone_idx < p_right.bone_idx;
} else
- return id<p_right.id;
+ return id < p_right.id;
}
};
-
struct Track {
uint32_t id;
Object *object;
- Spatial* spatial;
+ Spatial *spatial;
Skeleton *skeleton;
int bone_idx;
StringName property;
@@ -113,12 +109,10 @@ private:
bool skip;
};
-
- typedef Map<TrackKey,Track> TrackMap;
+ typedef Map<TrackKey, Track> TrackMap;
TrackMap track_map;
-
struct Input {
StringName node;
@@ -132,23 +126,24 @@ private:
NodeType type;
Point2 pos;
-
Vector<Input> inputs;
NodeBase() { cycletest = false; };
- virtual ~NodeBase() { cycletest=false; }
+ virtual ~NodeBase() { cycletest = false; }
};
struct NodeOut : public NodeBase {
- NodeOut() { type=NODE_OUTPUT; inputs.resize(1); }
+ NodeOut() {
+ type = NODE_OUTPUT;
+ inputs.resize(1);
+ }
};
struct AnimationNode : public NodeBase {
Ref<Animation> animation;
-
struct TrackRef {
int local_track;
Track *track;
@@ -163,13 +158,17 @@ private:
String from;
bool skip;
- HashMap<NodePath,bool> filter;
+ HashMap<NodePath, bool> filter;
- AnimationNode() { type=NODE_ANIMATION; next=NULL; last_version=0; skip=false; }
+ AnimationNode() {
+ type = NODE_ANIMATION;
+ next = NULL;
+ last_version = 0;
+ skip = false;
+ }
};
-
- struct OneShotNode : public NodeBase {
+ struct OneShotNode : public NodeBase {
bool active;
bool start;
@@ -181,52 +180,84 @@ private:
float autorestart_random_delay;
bool mix;
-
float time;
float remaining;
float autorestart_remaining;
- HashMap<NodePath,bool> filter;
+ HashMap<NodePath, bool> filter;
- OneShotNode() { type=NODE_ONESHOT; fade_in=0; fade_out=0; inputs.resize(2); autorestart=false; autorestart_delay=1; autorestart_remaining=0; mix=false; active=false; start=false;}
+ OneShotNode() {
+ type = NODE_ONESHOT;
+ fade_in = 0;
+ fade_out = 0;
+ inputs.resize(2);
+ autorestart = false;
+ autorestart_delay = 1;
+ autorestart_remaining = 0;
+ mix = false;
+ active = false;
+ start = false;
+ }
};
struct MixNode : public NodeBase {
float amount;
- MixNode() { type=NODE_MIX; inputs.resize(2); }
+ MixNode() {
+ type = NODE_MIX;
+ inputs.resize(2);
+ }
};
- struct Blend2Node : public NodeBase {
+ struct Blend2Node : public NodeBase {
float value;
- HashMap<NodePath,bool> filter;
- Blend2Node() { type=NODE_BLEND2; value=0; inputs.resize(2); }
+ HashMap<NodePath, bool> filter;
+ Blend2Node() {
+ type = NODE_BLEND2;
+ value = 0;
+ inputs.resize(2);
+ }
};
struct Blend3Node : public NodeBase {
float value;
- Blend3Node() { type=NODE_BLEND3; value=0; inputs.resize(3); }
+ Blend3Node() {
+ type = NODE_BLEND3;
+ value = 0;
+ inputs.resize(3);
+ }
};
struct Blend4Node : public NodeBase {
Point2 value;
- Blend4Node() { type=NODE_BLEND4; inputs.resize(4); }
+ Blend4Node() {
+ type = NODE_BLEND4;
+ inputs.resize(4);
+ }
};
struct TimeScaleNode : public NodeBase {
float scale;
- TimeScaleNode() { type=NODE_TIMESCALE; scale=1; inputs.resize(1); }
+ TimeScaleNode() {
+ type = NODE_TIMESCALE;
+ scale = 1;
+ inputs.resize(1);
+ }
};
struct TimeSeekNode : public NodeBase {
float seek_pos;
- TimeSeekNode() { type=NODE_TIMESEEK; inputs.resize(1); seek_pos=-1; }
+ TimeSeekNode() {
+ type = NODE_TIMESEEK;
+ inputs.resize(1);
+ seek_pos = -1;
+ }
};
struct TransitionNode : public NodeBase {
@@ -234,7 +265,7 @@ private:
struct InputData {
bool auto_advance;
- InputData() { auto_advance=false; }
+ InputData() { auto_advance = false; }
};
Vector<InputData> input_data;
@@ -244,23 +275,30 @@ private:
int prev;
bool switched;
-
float time;
int current;
float xfade;
- TransitionNode() { type=NODE_TRANSITION; xfade=0; inputs.resize(1); input_data.resize(1); current=0; prev=-1; prev_time=0; prev_xfading=0; switched=false; }
+ TransitionNode() {
+ type = NODE_TRANSITION;
+ xfade = 0;
+ inputs.resize(1);
+ input_data.resize(1);
+ current = 0;
+ prev = -1;
+ prev_time = 0;
+ prev_xfading = 0;
+ switched = false;
+ }
void set_current(int p_current);
};
-
void _update_sources();
StringName out_name;
NodeOut *out;
-
NodePath base_path;
NodePath master;
@@ -270,141 +308,132 @@ private:
bool processing;
bool active;
bool dirty_caches;
- Map<StringName,NodeBase*> node_map;
+ Map<StringName, NodeBase *> node_map;
// return time left to finish animation
- float _process_node(const StringName& p_node,AnimationNode **r_prev_anim,float p_step, bool p_seek=false, float p_fallback_weight = 1.0, HashMap<NodePath,float>* p_weights = NULL);
+ float _process_node(const StringName &p_node, AnimationNode **r_prev_anim, float p_step, bool p_seek = false, float p_fallback_weight = 1.0, HashMap<NodePath, float> *p_weights = NULL);
void _process_animation(float p_delta);
bool reset_request;
ConnectError _cycle_test(const StringName &p_at_node);
- Track* _find_track(const NodePath& p_path);
+ Track *_find_track(const NodePath &p_path);
void _recompute_caches();
- void _recompute_caches(const StringName& p_node);
+ void _recompute_caches(const StringName &p_node);
DVector<String> _get_node_list();
-
- void _compute_weights(float *p_fallback_weight, HashMap<NodePath,float> *p_weights, float p_coeff, const HashMap<NodePath,bool> *p_filter = NULL, float p_filtered_coeff = 0);
-
-protected:
-
+ void _compute_weights(float *p_fallback_weight, HashMap<NodePath, float> *p_weights, float p_coeff, const HashMap<NodePath, bool> *p_filter = NULL, float p_filtered_coeff = 0);
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
-
public:
+ void add_node(NodeType p_type, const StringName &p_node); // nodes must be >0 node 0 is built-in (exit)
+ bool node_exists(const StringName &p_name) const;
-
- void add_node(NodeType p_type, const StringName& p_node); // nodes must be >0 node 0 is built-in (exit)
- bool node_exists(const StringName& p_name) const;
-
- Error node_rename(const StringName& p_node,const StringName& p_new_name);
- int node_get_input_count(const StringName& p_node) const;
- StringName node_get_input_source(const StringName& p_node,int p_input) const;
+ Error node_rename(const StringName &p_node, const StringName &p_new_name);
+ int node_get_input_count(const StringName &p_node) const;
+ StringName node_get_input_source(const StringName &p_node, int p_input) const;
/* ANIMATION NODE */
- void animation_node_set_animation(const StringName& p_node,const Ref<Animation>& p_animation);
- Ref<Animation> animation_node_get_animation(const StringName& p_node) const;
- void animation_node_set_master_animation(const StringName& p_node,const String& p_master_animation);
- String animation_node_get_master_animation(const StringName& p_node) const;
+ void animation_node_set_animation(const StringName &p_node, const Ref<Animation> &p_animation);
+ Ref<Animation> animation_node_get_animation(const StringName &p_node) const;
+ void animation_node_set_master_animation(const StringName &p_node, const String &p_master_animation);
+ String animation_node_get_master_animation(const StringName &p_node) const;
- void animation_node_set_filter_path(const StringName& p_node,const NodePath& p_filter,bool p_enable);
- void animation_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const;
- bool animation_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const;
+ void animation_node_set_filter_path(const StringName &p_node, const NodePath &p_filter, bool p_enable);
+ void animation_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const;
+ bool animation_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const;
/* ONE SHOT NODE */
- void oneshot_node_set_fadein_time(const StringName& p_node,float p_time);
- void oneshot_node_set_fadeout_time(const StringName& p_node,float p_time);
+ void oneshot_node_set_fadein_time(const StringName &p_node, float p_time);
+ void oneshot_node_set_fadeout_time(const StringName &p_node, float p_time);
- float oneshot_node_get_fadein_time(const StringName& p_node) const;
- float oneshot_node_get_fadeout_time(const StringName& p_node) const;
+ float oneshot_node_get_fadein_time(const StringName &p_node) const;
+ float oneshot_node_get_fadeout_time(const StringName &p_node) const;
- void oneshot_node_set_autorestart(const StringName& p_node,bool p_active);
- void oneshot_node_set_autorestart_delay(const StringName& p_node,float p_time);
- void oneshot_node_set_autorestart_random_delay(const StringName& p_node,float p_time);
+ void oneshot_node_set_autorestart(const StringName &p_node, bool p_active);
+ void oneshot_node_set_autorestart_delay(const StringName &p_node, float p_time);
+ void oneshot_node_set_autorestart_random_delay(const StringName &p_node, float p_time);
- bool oneshot_node_has_autorestart(const StringName& p_node) const;
- float oneshot_node_get_autorestart_delay(const StringName& p_node) const;
- float oneshot_node_get_autorestart_random_delay(const StringName& p_node) const;
+ bool oneshot_node_has_autorestart(const StringName &p_node) const;
+ float oneshot_node_get_autorestart_delay(const StringName &p_node) const;
+ float oneshot_node_get_autorestart_random_delay(const StringName &p_node) const;
- void oneshot_node_set_mix_mode(const StringName& p_node,bool p_enabled);
- bool oneshot_node_get_mix_mode(const StringName& p_node) const;
+ void oneshot_node_set_mix_mode(const StringName &p_node, bool p_enabled);
+ bool oneshot_node_get_mix_mode(const StringName &p_node) const;
- void oneshot_node_start(const StringName& p_node);
- void oneshot_node_stop(const StringName& p_node);
- bool oneshot_node_is_active(const StringName& p_node) const;
-
- void oneshot_node_set_filter_path(const StringName& p_node,const NodePath& p_filter,bool p_enable);
- void oneshot_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const;
- bool oneshot_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const;
+ void oneshot_node_start(const StringName &p_node);
+ void oneshot_node_stop(const StringName &p_node);
+ bool oneshot_node_is_active(const StringName &p_node) const;
+ void oneshot_node_set_filter_path(const StringName &p_node, const NodePath &p_filter, bool p_enable);
+ void oneshot_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const;
+ bool oneshot_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const;
/* MIX/BLEND NODES */
- void mix_node_set_amount(const StringName& p_node,float p_amount);
- float mix_node_get_amount(const StringName& p_node) const;
+ void mix_node_set_amount(const StringName &p_node, float p_amount);
+ float mix_node_get_amount(const StringName &p_node) const;
- void blend2_node_set_amount(const StringName& p_node,float p_amount);
- float blend2_node_get_amount(const StringName& p_node) const;
- void blend2_node_set_filter_path(const StringName& p_node,const NodePath& p_filter,bool p_enable);
- void blend2_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const;
- bool blend2_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const;
+ void blend2_node_set_amount(const StringName &p_node, float p_amount);
+ float blend2_node_get_amount(const StringName &p_node) const;
+ void blend2_node_set_filter_path(const StringName &p_node, const NodePath &p_filter, bool p_enable);
+ void blend2_node_set_get_filtered_paths(const StringName &p_node, List<NodePath> *r_paths) const;
+ bool blend2_node_is_path_filtered(const StringName &p_node, const NodePath &p_path) const;
- void blend3_node_set_amount(const StringName& p_node,float p_amount);
- float blend3_node_get_amount(const StringName& p_node) const;
+ void blend3_node_set_amount(const StringName &p_node, float p_amount);
+ float blend3_node_get_amount(const StringName &p_node) const;
- void blend4_node_set_amount(const StringName& p_node,const Point2& p_amount);
- Point2 blend4_node_get_amount(const StringName& p_node) const;
+ void blend4_node_set_amount(const StringName &p_node, const Point2 &p_amount);
+ Point2 blend4_node_get_amount(const StringName &p_node) const;
/* TIMESCALE/TIMESEEK NODES */
- void timescale_node_set_scale(const StringName& p_node,float p_scale);
- float timescale_node_get_scale(const StringName& p_node) const;
+ void timescale_node_set_scale(const StringName &p_node, float p_scale);
+ float timescale_node_get_scale(const StringName &p_node) const;
- void timeseek_node_seek(const StringName& p_node,float p_pos);
+ void timeseek_node_seek(const StringName &p_node, float p_pos);
/* TRANSITION NODE */
- void transition_node_set_input_count(const StringName& p_node, int p_inputs); // used for transition node
- int transition_node_get_input_count(const StringName& p_node) const;
- void transition_node_delete_input(const StringName& p_node, int p_input); // used for transition node
-
- void transition_node_set_input_auto_advance(const StringName& p_node, int p_input,bool p_auto_advance); // used for transition node
- bool transition_node_has_input_auto_advance(const StringName& p_node, int p_input) const;
+ void transition_node_set_input_count(const StringName &p_node, int p_inputs); // used for transition node
+ int transition_node_get_input_count(const StringName &p_node) const;
+ void transition_node_delete_input(const StringName &p_node, int p_input); // used for transition node
- void transition_node_set_xfade_time(const StringName& p_node, float p_time); // used for transition node
- float transition_node_get_xfade_time(const StringName& p_node) const;
+ void transition_node_set_input_auto_advance(const StringName &p_node, int p_input, bool p_auto_advance); // used for transition node
+ bool transition_node_has_input_auto_advance(const StringName &p_node, int p_input) const;
- void transition_node_set_current(const StringName& p_node, int p_current);
- int transition_node_get_current(const StringName& p_node) const;
+ void transition_node_set_xfade_time(const StringName &p_node, float p_time); // used for transition node
+ float transition_node_get_xfade_time(const StringName &p_node) const;
+ void transition_node_set_current(const StringName &p_node, int p_current);
+ int transition_node_get_current(const StringName &p_node) const;
- void node_set_pos(const StringName& p_node, const Vector2& p_pos); //for display
+ void node_set_pos(const StringName &p_node, const Vector2 &p_pos); //for display
/* GETS */
- Point2 node_get_pos(const StringName& p_node) const; //for display
+ Point2 node_get_pos(const StringName &p_node) const; //for display
- NodeType node_get_type(const StringName& p_node) const;
+ NodeType node_get_type(const StringName &p_node) const;
void get_node_list(List<StringName> *p_node_list) const;
- void remove_node(const StringName& p_node);
+ void remove_node(const StringName &p_node);
- Error connect(const StringName& p_src_node,const StringName& p_dst_node, int p_dst_input);
- bool is_connected(const StringName& p_src_node,const StringName& p_dst_node, int p_input) const;
- void disconnect(const StringName& p_src_node, int p_input);
+ Error connect(const StringName &p_src_node, const StringName &p_dst_node, int p_dst_input);
+ bool is_connected(const StringName &p_src_node, const StringName &p_dst_node, int p_input) const;
+ void disconnect(const StringName &p_src_node, int p_input);
- void set_base_path(const NodePath& p_path);
+ void set_base_path(const NodePath &p_path);
NodePath get_base_path() const;
- void set_master_player(const NodePath& p_path);
+ void set_master_player(const NodePath &p_path);
NodePath get_master_player() const;
struct Connection {
@@ -414,7 +443,7 @@ public:
int dst_input;
};
- void get_connection_list( List<Connection> *p_connections) const;
+ void get_connection_list(List<Connection> *p_connections) const;
/* playback */
@@ -436,12 +465,9 @@ public:
AnimationTreePlayer();
~AnimationTreePlayer();
-
};
-VARIANT_ENUM_CAST( AnimationTreePlayer::NodeType );
-VARIANT_ENUM_CAST( AnimationTreePlayer::AnimationProcessMode );
+VARIANT_ENUM_CAST(AnimationTreePlayer::NodeType);
+VARIANT_ENUM_CAST(AnimationTreePlayer::AnimationProcessMode);
#endif // ANIMATION_TREE_PLAYER_H
-
-
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 411912e77..394e152b3 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -29,63 +29,60 @@
#include "tween.h"
#include "method_bind_ext.inc"
-void Tween::_add_pending_command(StringName p_key
- ,const Variant& p_arg1 ,const Variant& p_arg2 ,const Variant& p_arg3 ,const Variant& p_arg4 ,const Variant& p_arg5
- ,const Variant& p_arg6 ,const Variant& p_arg7 ,const Variant& p_arg8 ,const Variant& p_arg9 ,const Variant& p_arg10
-) {
+void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5, const Variant &p_arg6, const Variant &p_arg7, const Variant &p_arg8, const Variant &p_arg9, const Variant &p_arg10) {
pending_commands.push_back(PendingCommand());
- PendingCommand& cmd = pending_commands.back()->get();
+ PendingCommand &cmd = pending_commands.back()->get();
cmd.key = p_key;
- int& count = cmd.args;
- if(p_arg10.get_type() != Variant::NIL)
+ int &count = cmd.args;
+ if (p_arg10.get_type() != Variant::NIL)
count = 10;
- else if(p_arg9.get_type() != Variant::NIL)
+ else if (p_arg9.get_type() != Variant::NIL)
count = 9;
- else if(p_arg8.get_type() != Variant::NIL)
+ else if (p_arg8.get_type() != Variant::NIL)
count = 8;
- else if(p_arg7.get_type() != Variant::NIL)
+ else if (p_arg7.get_type() != Variant::NIL)
count = 7;
- else if(p_arg6.get_type() != Variant::NIL)
+ else if (p_arg6.get_type() != Variant::NIL)
count = 6;
- else if(p_arg5.get_type() != Variant::NIL)
+ else if (p_arg5.get_type() != Variant::NIL)
count = 5;
- else if(p_arg4.get_type() != Variant::NIL)
+ else if (p_arg4.get_type() != Variant::NIL)
count = 4;
- else if(p_arg3.get_type() != Variant::NIL)
+ else if (p_arg3.get_type() != Variant::NIL)
count = 3;
- else if(p_arg2.get_type() != Variant::NIL)
+ else if (p_arg2.get_type() != Variant::NIL)
count = 2;
- else if(p_arg1.get_type() != Variant::NIL)
+ else if (p_arg1.get_type() != Variant::NIL)
count = 1;
- if(count > 0)
+ if (count > 0)
cmd.arg[0] = p_arg1;
- if(count > 1)
+ if (count > 1)
cmd.arg[1] = p_arg2;
- if(count > 2)
+ if (count > 2)
cmd.arg[2] = p_arg3;
- if(count > 3)
+ if (count > 3)
cmd.arg[3] = p_arg4;
- if(count > 4)
+ if (count > 4)
cmd.arg[4] = p_arg5;
- if(count > 5)
+ if (count > 5)
cmd.arg[5] = p_arg6;
- if(count > 6)
+ if (count > 6)
cmd.arg[6] = p_arg7;
- if(count > 7)
+ if (count > 7)
cmd.arg[7] = p_arg8;
- if(count > 8)
+ if (count > 8)
cmd.arg[8] = p_arg9;
- if(count > 9)
+ if (count > 9)
cmd.arg[9] = p_arg10;
}
void Tween::_process_pending_commands() {
- for(List<PendingCommand>::Element *E=pending_commands.front();E;E=E->next()) {
+ for (List<PendingCommand>::Element *E = pending_commands.front(); E; E = E->next()) {
- PendingCommand& cmd = E->get();
+ PendingCommand &cmd = E->get();
Variant::CallError err;
Variant *arg[10] = {
&cmd.arg[0],
@@ -99,41 +96,40 @@ void Tween::_process_pending_commands() {
&cmd.arg[8],
&cmd.arg[9],
};
- this->call(cmd.key, (const Variant **) arg, cmd.args, err);
+ this->call(cmd.key, (const Variant **)arg, cmd.args, err);
}
pending_commands.clear();
}
-bool Tween::_set(const StringName& p_name, const Variant& p_value) {
+bool Tween::_set(const StringName &p_name, const Variant &p_value) {
- String name=p_name;
+ String name = p_name;
- if (name=="playback/speed" || name=="speed") { //bw compatibility
+ if (name == "playback/speed" || name == "speed") { //bw compatibility
set_speed(p_value);
- } else if (name=="playback/active") {
+ } else if (name == "playback/active") {
set_active(p_value);
- } else if (name=="playback/repeat") {
+ } else if (name == "playback/repeat") {
set_repeat(p_value);
-
}
return true;
}
-bool Tween::_get(const StringName& p_name,Variant &r_ret) const {
+bool Tween::_get(const StringName &p_name, Variant &r_ret) const {
- String name=p_name;
+ String name = p_name;
- if (name=="playback/speed") { //bw compatibility
+ if (name == "playback/speed") { //bw compatibility
- r_ret=speed_scale;
- } else if (name=="playback/active") {
+ r_ret = speed_scale;
+ } else if (name == "playback/active") {
- r_ret=is_active();
- } else if(name=="playback/repeat") {
+ r_ret = is_active();
+ } else if (name == "playback/repeat") {
- r_ret=is_repeat();
+ r_ret = is_repeat();
}
return true;
@@ -141,14 +137,14 @@ bool Tween::_get(const StringName& p_name,Variant &r_ret) const {
void Tween::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo( Variant::BOOL, "playback/active", PROPERTY_HINT_NONE,"" ) );
- p_list->push_back( PropertyInfo( Variant::BOOL, "playback/repeat", PROPERTY_HINT_NONE,"" ) );
- p_list->push_back( PropertyInfo( Variant::REAL, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01") );
+ p_list->push_back(PropertyInfo(Variant::BOOL, "playback/active", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "playback/repeat", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::REAL, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01"));
}
void Tween::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -163,19 +159,19 @@ void Tween::_notification(int p_what) {
} break;
case NOTIFICATION_PROCESS: {
- if (tween_process_mode==TWEEN_PROCESS_FIXED)
+ if (tween_process_mode == TWEEN_PROCESS_FIXED)
break;
if (processing)
- _tween_process( get_process_delta_time() );
+ _tween_process(get_process_delta_time());
} break;
case NOTIFICATION_FIXED_PROCESS: {
- if (tween_process_mode==TWEEN_PROCESS_IDLE)
+ if (tween_process_mode == TWEEN_PROCESS_IDLE)
break;
if (processing)
- _tween_process( get_fixed_process_delta_time() );
+ _tween_process(get_fixed_process_delta_time());
} break;
case NOTIFICATION_EXIT_TREE: {
@@ -186,45 +182,45 @@ void Tween::_notification(int p_what) {
void Tween::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("is_active"),&Tween::is_active );
- ObjectTypeDB::bind_method(_MD("set_active","active"),&Tween::set_active );
+ ObjectTypeDB::bind_method(_MD("is_active"), &Tween::is_active);
+ ObjectTypeDB::bind_method(_MD("set_active", "active"), &Tween::set_active);
- ObjectTypeDB::bind_method(_MD("is_repeat"),&Tween::is_repeat );
- ObjectTypeDB::bind_method(_MD("set_repeat","repeat"),&Tween::set_repeat );
+ ObjectTypeDB::bind_method(_MD("is_repeat"), &Tween::is_repeat);
+ ObjectTypeDB::bind_method(_MD("set_repeat", "repeat"), &Tween::set_repeat);
- ObjectTypeDB::bind_method(_MD("set_speed","speed"),&Tween::set_speed);
- ObjectTypeDB::bind_method(_MD("get_speed"),&Tween::get_speed);
+ ObjectTypeDB::bind_method(_MD("set_speed", "speed"), &Tween::set_speed);
+ ObjectTypeDB::bind_method(_MD("get_speed"), &Tween::get_speed);
- ObjectTypeDB::bind_method(_MD("set_tween_process_mode","mode"),&Tween::set_tween_process_mode);
- ObjectTypeDB::bind_method(_MD("get_tween_process_mode"),&Tween::get_tween_process_mode);
+ ObjectTypeDB::bind_method(_MD("set_tween_process_mode", "mode"), &Tween::set_tween_process_mode);
+ ObjectTypeDB::bind_method(_MD("get_tween_process_mode"), &Tween::get_tween_process_mode);
- ObjectTypeDB::bind_method(_MD("start"),&Tween::start );
- ObjectTypeDB::bind_method(_MD("reset","object","key"),&Tween::reset );
- ObjectTypeDB::bind_method(_MD("reset_all"),&Tween::reset_all );
- ObjectTypeDB::bind_method(_MD("stop","object","key"),&Tween::stop );
- ObjectTypeDB::bind_method(_MD("stop_all"),&Tween::stop_all );
- ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume );
- ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all );
- ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove );
- ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all );
- ObjectTypeDB::bind_method(_MD("seek","time"),&Tween::seek );
- ObjectTypeDB::bind_method(_MD("tell"),&Tween::tell );
- ObjectTypeDB::bind_method(_MD("get_runtime"),&Tween::get_runtime );
+ ObjectTypeDB::bind_method(_MD("start"), &Tween::start);
+ ObjectTypeDB::bind_method(_MD("reset", "object", "key"), &Tween::reset);
+ ObjectTypeDB::bind_method(_MD("reset_all"), &Tween::reset_all);
+ ObjectTypeDB::bind_method(_MD("stop", "object", "key"), &Tween::stop);
+ ObjectTypeDB::bind_method(_MD("stop_all"), &Tween::stop_all);
+ ObjectTypeDB::bind_method(_MD("resume", "object", "key"), &Tween::resume);
+ ObjectTypeDB::bind_method(_MD("resume_all"), &Tween::resume_all);
+ ObjectTypeDB::bind_method(_MD("remove", "object", "key"), &Tween::remove);
+ ObjectTypeDB::bind_method(_MD("remove_all"), &Tween::remove_all);
+ ObjectTypeDB::bind_method(_MD("seek", "time"), &Tween::seek);
+ ObjectTypeDB::bind_method(_MD("tell"), &Tween::tell);
+ ObjectTypeDB::bind_method(_MD("get_runtime"), &Tween::get_runtime);
- ObjectTypeDB::bind_method(_MD("interpolate_property","object","property","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_property, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("interpolate_method","object","method","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::interpolate_method, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("interpolate_callback","object","times_in_sec","callback","arg1", "arg2","arg3","arg4","arg5"),&Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
- ObjectTypeDB::bind_method(_MD("interpolate_deferred_callback","object","times_in_sec","callback","arg1","arg2","arg3","arg4","arg5"),&Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()) );
- ObjectTypeDB::bind_method(_MD("follow_property","object","property","initial_val","target","target_property","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_property, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("follow_method","object","method","initial_val","target","target_method","times_in_sec","trans_type","ease_type","delay"),&Tween::follow_method, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("targeting_property","object","property","initial","initial_val","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_property, DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("targeting_method","object","method","initial","initial_method","final_val","times_in_sec","trans_type","ease_type","delay"),&Tween::targeting_method, DEFVAL(0) );
+ ObjectTypeDB::bind_method(_MD("interpolate_property", "object", "property", "initial_val", "final_val", "times_in_sec", "trans_type", "ease_type", "delay"), &Tween::interpolate_property, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("interpolate_method", "object", "method", "initial_val", "final_val", "times_in_sec", "trans_type", "ease_type", "delay"), &Tween::interpolate_method, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("interpolate_callback", "object", "times_in_sec", "callback", "arg1", "arg2", "arg3", "arg4", "arg5"), &Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("interpolate_deferred_callback", "object", "times_in_sec", "callback", "arg1", "arg2", "arg3", "arg4", "arg5"), &Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("follow_property", "object", "property", "initial_val", "target", "target_property", "times_in_sec", "trans_type", "ease_type", "delay"), &Tween::follow_property, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("follow_method", "object", "method", "initial_val", "target", "target_method", "times_in_sec", "trans_type", "ease_type", "delay"), &Tween::follow_method, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("targeting_property", "object", "property", "initial", "initial_val", "final_val", "times_in_sec", "trans_type", "ease_type", "delay"), &Tween::targeting_property, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("targeting_method", "object", "method", "initial", "initial_method", "final_val", "times_in_sec", "trans_type", "ease_type", "delay"), &Tween::targeting_method, DEFVAL(0));
- ADD_SIGNAL( MethodInfo("tween_start", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) );
- ADD_SIGNAL( MethodInfo("tween_step", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key"), PropertyInfo( Variant::REAL,"elapsed"), PropertyInfo( Variant::OBJECT,"value")) );
- ADD_SIGNAL( MethodInfo("tween_complete", PropertyInfo( Variant::OBJECT,"object"), PropertyInfo( Variant::STRING,"key")) );
+ ADD_SIGNAL(MethodInfo("tween_start", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::STRING, "key")));
+ ADD_SIGNAL(MethodInfo("tween_step", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::STRING, "key"), PropertyInfo(Variant::REAL, "elapsed"), PropertyInfo(Variant::OBJECT, "value")));
+ ADD_SIGNAL(MethodInfo("tween_complete", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::STRING, "key")));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "playback/process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_tween_process_mode"), _SCS("get_tween_process_mode"));
BIND_CONSTANT(TWEEN_PROCESS_FIXED);
BIND_CONSTANT(TWEEN_PROCESS_IDLE);
@@ -247,9 +243,9 @@ void Tween::_bind_methods() {
BIND_CONSTANT(EASE_OUT_IN);
}
-Variant& Tween::_get_initial_val(InterpolateData& p_data) {
+Variant &Tween::_get_initial_val(InterpolateData &p_data) {
- switch(p_data.type) {
+ switch (p_data.type) {
case INTER_PROPERTY:
case INTER_METHOD:
case FOLLOW_PROPERTY:
@@ -259,31 +255,30 @@ Variant& Tween::_get_initial_val(InterpolateData& p_data) {
case TARGETING_PROPERTY:
case TARGETING_METHOD: {
- Object *object = ObjectDB::get_instance(p_data.target_id);
- ERR_FAIL_COND_V(object == NULL,p_data.initial_val);
+ Object *object = ObjectDB::get_instance(p_data.target_id);
+ ERR_FAIL_COND_V(object == NULL, p_data.initial_val);
- static Variant initial_val;
- if(p_data.type == TARGETING_PROPERTY) {
+ static Variant initial_val;
+ if (p_data.type == TARGETING_PROPERTY) {
- bool valid = false;
- initial_val = object->get(p_data.target_key, &valid);
- ERR_FAIL_COND_V(!valid,p_data.initial_val);
- } else {
+ bool valid = false;
+ initial_val = object->get(p_data.target_key, &valid);
+ ERR_FAIL_COND_V(!valid, p_data.initial_val);
+ } else {
- Variant::CallError error;
- initial_val = object->call(p_data.target_key, NULL, 0, error);
- ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK,p_data.initial_val);
- }
- return initial_val;
+ Variant::CallError error;
+ initial_val = object->call(p_data.target_key, NULL, 0, error);
+ ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, p_data.initial_val);
}
- break;
+ return initial_val;
+ } break;
}
return p_data.delta_val;
}
-Variant& Tween::_get_delta_val(InterpolateData& p_data) {
+Variant &Tween::_get_delta_val(InterpolateData &p_data) {
- switch(p_data.type) {
+ switch (p_data.type) {
case INTER_PROPERTY:
case INTER_METHOD:
return p_data.delta_val;
@@ -291,72 +286,68 @@ Variant& Tween::_get_delta_val(InterpolateData& p_data) {
case FOLLOW_PROPERTY:
case FOLLOW_METHOD: {
- Object *target = ObjectDB::get_instance(p_data.target_id);
- ERR_FAIL_COND_V(target == NULL,p_data.initial_val);
-
- Variant final_val;
+ Object *target = ObjectDB::get_instance(p_data.target_id);
+ ERR_FAIL_COND_V(target == NULL, p_data.initial_val);
- if(p_data.type == FOLLOW_PROPERTY) {
+ Variant final_val;
- bool valid = false;
- final_val = target->get(p_data.target_key, &valid);
- ERR_FAIL_COND_V(!valid,p_data.initial_val);
- } else {
+ if (p_data.type == FOLLOW_PROPERTY) {
- Variant::CallError error;
- final_val = target->call(p_data.target_key, NULL, 0, error);
- ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK,p_data.initial_val);
- }
+ bool valid = false;
+ final_val = target->get(p_data.target_key, &valid);
+ ERR_FAIL_COND_V(!valid, p_data.initial_val);
+ } else {
- // convert INT to REAL is better for interpolaters
- if(final_val.get_type() == Variant::INT) final_val = final_val.operator real_t();
- _calc_delta_val(p_data.initial_val, final_val, p_data.delta_val);
- return p_data.delta_val;
+ Variant::CallError error;
+ final_val = target->call(p_data.target_key, NULL, 0, error);
+ ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, p_data.initial_val);
}
- break;
+
+ // convert INT to REAL is better for interpolaters
+ if (final_val.get_type() == Variant::INT) final_val = final_val.operator real_t();
+ _calc_delta_val(p_data.initial_val, final_val, p_data.delta_val);
+ return p_data.delta_val;
+ } break;
case TARGETING_PROPERTY:
case TARGETING_METHOD: {
- Variant initial_val = _get_initial_val(p_data);
- // convert INT to REAL is better for interpolaters
- if(initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t();
+ Variant initial_val = _get_initial_val(p_data);
+ // convert INT to REAL is better for interpolaters
+ if (initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t();
- //_calc_delta_val(p_data.initial_val, p_data.final_val, p_data.delta_val);
- _calc_delta_val(initial_val, p_data.final_val, p_data.delta_val);
- return p_data.delta_val;
- }
- break;
+ //_calc_delta_val(p_data.initial_val, p_data.final_val, p_data.delta_val);
+ _calc_delta_val(initial_val, p_data.final_val, p_data.delta_val);
+ return p_data.delta_val;
+ } break;
}
return p_data.initial_val;
}
-Variant Tween::_run_equation(InterpolateData& p_data) {
+Variant Tween::_run_equation(InterpolateData &p_data) {
- Variant& initial_val = _get_initial_val(p_data);
- Variant& delta_val = _get_delta_val(p_data);
+ Variant &initial_val = _get_initial_val(p_data);
+ Variant &delta_val = _get_delta_val(p_data);
Variant result;
-#define APPLY_EQUATION(element)\
+#define APPLY_EQUATION(element) \
r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.times_in_sec);
- switch(initial_val.get_type())
- {
+ switch (initial_val.get_type()) {
- case Variant::BOOL:
- result = ( _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.times_in_sec)) >= 0.5;
- break;
+ case Variant::BOOL:
+ result = (_run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.times_in_sec)) >= 0.5;
+ break;
- case Variant::INT:
- result = (int) _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int) initial_val, (int) delta_val, p_data.times_in_sec);
- break;
+ case Variant::INT:
+ result = (int)_run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int)initial_val, (int)delta_val, p_data.times_in_sec);
+ break;
- case Variant::REAL:
- result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t) initial_val, (real_t) delta_val, p_data.times_in_sec);
- break;
+ case Variant::REAL:
+ result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t)initial_val, (real_t)delta_val, p_data.times_in_sec);
+ break;
- case Variant::VECTOR2:
- {
+ case Variant::VECTOR2: {
Vector2 i = initial_val;
Vector2 d = delta_val;
Vector2 r;
@@ -365,11 +356,9 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
APPLY_EQUATION(y);
result = r;
- }
- break;
+ } break;
- case Variant::VECTOR3:
- {
+ case Variant::VECTOR3: {
Vector3 i = initial_val;
Vector3 d = delta_val;
Vector3 r;
@@ -379,11 +368,9 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
APPLY_EQUATION(z);
result = r;
- }
- break;
+ } break;
- case Variant::MATRIX3:
- {
+ case Variant::MATRIX3: {
Matrix3 i = initial_val;
Matrix3 d = delta_val;
Matrix3 r;
@@ -399,11 +386,9 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
APPLY_EQUATION(elements[2][2]);
result = r;
- }
- break;
+ } break;
- case Variant::MATRIX32:
- {
+ case Variant::MATRIX32: {
Matrix3 i = initial_val;
Matrix3 d = delta_val;
Matrix3 r;
@@ -416,10 +401,8 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
APPLY_EQUATION(elements[2][1]);
result = r;
- }
- break;
- case Variant::QUAT:
- {
+ } break;
+ case Variant::QUAT: {
Quat i = initial_val;
Quat d = delta_val;
Quat r;
@@ -430,10 +413,8 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
APPLY_EQUATION(w);
result = r;
- }
- break;
- case Variant::_AABB:
- {
+ } break;
+ case Variant::_AABB: {
AABB i = initial_val;
AABB d = delta_val;
AABB r;
@@ -446,10 +427,8 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
APPLY_EQUATION(size.z);
result = r;
- }
- break;
- case Variant::TRANSFORM:
- {
+ } break;
+ case Variant::TRANSFORM: {
Transform i = initial_val;
Transform d = delta_val;
Transform r;
@@ -468,10 +447,8 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
APPLY_EQUATION(origin.z);
result = r;
- }
- break;
- case Variant::COLOR:
- {
+ } break;
+ case Variant::COLOR: {
Color i = initial_val;
Color d = delta_val;
Color r;
@@ -482,47 +459,44 @@ Variant Tween::_run_equation(InterpolateData& p_data) {
APPLY_EQUATION(a);
result = r;
- }
- break;
+ } break;
};
#undef APPLY_EQUATION
return result;
}
-bool Tween::_apply_tween_value(InterpolateData& p_data, Variant& value) {
+bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) {
Object *object = ObjectDB::get_instance(p_data.id);
ERR_FAIL_COND_V(object == NULL, false);
- switch(p_data.type) {
+ switch (p_data.type) {
case INTER_PROPERTY:
case FOLLOW_PROPERTY:
- case TARGETING_PROPERTY:
- {
- bool valid = false;
- object->set(p_data.key,value, &valid);
- return valid;
- }
+ case TARGETING_PROPERTY: {
+ bool valid = false;
+ object->set(p_data.key, value, &valid);
+ return valid;
+ }
case INTER_METHOD:
case FOLLOW_METHOD:
- case TARGETING_METHOD:
- {
- Variant::CallError error;
- if (value.get_type() != Variant::NIL) {
- Variant *arg[1] = { &value };
- object->call(p_data.key, (const Variant **) arg, 1, error);
- } else {
- object->call(p_data.key, NULL, 0, error);
- }
-
- if(error.error == Variant::CallError::CALL_OK)
- return true;
- return false;
+ case TARGETING_METHOD: {
+ Variant::CallError error;
+ if (value.get_type() != Variant::NIL) {
+ Variant *arg[1] = { &value };
+ object->call(p_data.key, (const Variant **)arg, 1, error);
+ } else {
+ object->call(p_data.key, NULL, 0, error);
}
+ if (error.error == Variant::CallError::CALL_OK)
+ return true;
+ return false;
+ }
+
case INTER_CALLBACK:
break;
};
@@ -537,118 +511,122 @@ void Tween::_tween_process(float p_delta) {
return;
p_delta *= speed_scale;
- pending_update ++;
+ pending_update++;
// if repeat and all interpolates was finished then reset all interpolates
- if(repeat) {
+ if (repeat) {
bool all_finished = true;
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
- if(!data.finish) {
+ if (!data.finish) {
all_finished = false;
break;
}
}
- if(all_finished)
+ if (all_finished)
reset_all();
}
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
- if(!data.active || data.finish)
+ InterpolateData &data = E->get();
+ if (!data.active || data.finish)
continue;
Object *object = ObjectDB::get_instance(data.id);
- if(object == NULL)
+ if (object == NULL)
continue;
bool prev_delaying = data.elapsed <= data.delay;
data.elapsed += p_delta;
- if(data.elapsed < data.delay)
+ if (data.elapsed < data.delay)
continue;
- else if(prev_delaying) {
+ else if (prev_delaying) {
- emit_signal("tween_start",object,data.key);
+ emit_signal("tween_start", object, data.key);
_apply_tween_value(data, data.initial_val);
}
- if(data.elapsed > (data.delay + data.times_in_sec)) {
+ if (data.elapsed > (data.delay + data.times_in_sec)) {
data.elapsed = data.delay + data.times_in_sec;
data.finish = true;
}
- switch(data.type)
- {
- case INTER_PROPERTY:
- case INTER_METHOD:
- break;
- case INTER_CALLBACK:
- if(data.finish) {
+ switch (data.type) {
+ case INTER_PROPERTY:
+ case INTER_METHOD:
+ break;
+ case INTER_CALLBACK:
+ if (data.finish) {
- Variant::CallError error;
- if (data.call_deferred) {
+ Variant::CallError error;
+ if (data.call_deferred) {
- switch (data.args) {
- case 0:
- object->call_deferred(data.key); break;
- case 1:
- object->call_deferred(data.key, data.arg[0]); break;
- case 2:
- object->call_deferred(data.key, data.arg[0], data.arg[1]); break;
- case 3:
- object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2]); break;
- case 4:
- object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3]); break;
- case 5:
- object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]); break;
- }
+ switch (data.args) {
+ case 0:
+ object->call_deferred(data.key);
+ break;
+ case 1:
+ object->call_deferred(data.key, data.arg[0]);
+ break;
+ case 2:
+ object->call_deferred(data.key, data.arg[0], data.arg[1]);
+ break;
+ case 3:
+ object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2]);
+ break;
+ case 4:
+ object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3]);
+ break;
+ case 5:
+ object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
+ break;
+ }
+ } else {
+ Variant *arg[5] = {
+ &data.arg[0],
+ &data.arg[1],
+ &data.arg[2],
+ &data.arg[3],
+ &data.arg[4],
+ };
+ object->call(data.key, (const Variant **)arg, data.args, error);
+ }
+ if (!repeat)
+ call_deferred("remove", object, data.key);
}
- else {
- Variant *arg[5] = {
- &data.arg[0],
- &data.arg[1],
- &data.arg[2],
- &data.arg[3],
- &data.arg[4],
- };
- object->call(data.key, (const Variant **) arg, data.args, error);
- }
- if (!repeat)
- call_deferred("remove", object, data.key);
- }
- continue;
+ continue;
}
Variant result = _run_equation(data);
- emit_signal("tween_step",object,data.key,data.elapsed,result);
+ emit_signal("tween_step", object, data.key, data.elapsed, result);
_apply_tween_value(data, result);
if (data.finish) {
- emit_signal("tween_complete",object,data.key);
+ emit_signal("tween_complete", object, data.key);
// not repeat mode, remove completed action
if (!repeat)
call_deferred("remove", object, data.key);
}
}
- pending_update --;
+ pending_update--;
}
void Tween::set_tween_process_mode(TweenProcessMode p_mode) {
- if (tween_process_mode==p_mode)
+ if (tween_process_mode == p_mode)
return;
bool pr = processing;
if (pr)
_set_process(false);
- tween_process_mode=p_mode;
+ tween_process_mode = p_mode;
if (pr)
_set_process(true);
}
@@ -658,18 +636,18 @@ Tween::TweenProcessMode Tween::get_tween_process_mode() const {
return tween_process_mode;
}
-void Tween::_set_process(bool p_process,bool p_force) {
+void Tween::_set_process(bool p_process, bool p_force) {
- if (processing==p_process && !p_force)
+ if (processing == p_process && !p_force)
return;
- switch(tween_process_mode) {
+ switch (tween_process_mode) {
case TWEEN_PROCESS_FIXED: set_fixed_process(p_process && active); break;
case TWEEN_PROCESS_IDLE: set_process(p_process && active); break;
}
- processing=p_process;
+ processing = p_process;
}
bool Tween::is_active() const {
@@ -679,11 +657,11 @@ bool Tween::is_active() const {
void Tween::set_active(bool p_active) {
- if (active==p_active)
+ if (active == p_active)
return;
- active=p_active;
- _set_process(processing,true);
+ active = p_active;
+ _set_process(processing, true);
}
bool Tween::is_repeat() const {
@@ -698,7 +676,7 @@ void Tween::set_repeat(bool p_repeat) {
void Tween::set_speed(float p_speed) {
- speed_scale=p_speed;
+ speed_scale = p_speed;
}
float Tween::get_speed() const {
@@ -715,54 +693,54 @@ bool Tween::start() {
bool Tween::reset(Object *p_object, String p_key) {
- pending_update ++;
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ pending_update++;
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
Object *object = ObjectDB::get_instance(data.id);
- if(object == NULL)
+ if (object == NULL)
continue;
- if(object == p_object && data.key == p_key) {
+ if (object == p_object && data.key == p_key) {
data.elapsed = 0;
data.finish = false;
- if(data.delay == 0)
+ if (data.delay == 0)
_apply_tween_value(data, data.initial_val);
}
}
- pending_update --;
+ pending_update--;
return true;
}
bool Tween::reset_all() {
- pending_update ++;
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ pending_update++;
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
data.elapsed = 0;
data.finish = false;
- if(data.delay == 0)
+ if (data.delay == 0)
_apply_tween_value(data, data.initial_val);
}
- pending_update --;
+ pending_update--;
return true;
}
bool Tween::stop(Object *p_object, String p_key) {
- pending_update ++;
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ pending_update++;
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
Object *object = ObjectDB::get_instance(data.id);
- if(object == NULL)
+ if (object == NULL)
continue;
- if(object == p_object && data.key == p_key)
+ if (object == p_object && data.key == p_key)
data.active = false;
}
- pending_update --;
+ pending_update--;
return true;
}
@@ -771,13 +749,13 @@ bool Tween::stop_all() {
set_active(false);
_set_process(false);
- pending_update ++;
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ pending_update++;
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
data.active = false;
}
- pending_update --;
+ pending_update--;
return true;
}
@@ -786,17 +764,17 @@ bool Tween::resume(Object *p_object, String p_key) {
set_active(true);
_set_process(true);
- pending_update ++;
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ pending_update++;
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
Object *object = ObjectDB::get_instance(data.id);
- if(object == NULL)
+ if (object == NULL)
continue;
- if(object == p_object && data.key == p_key)
+ if (object == p_object && data.key == p_key)
data.active = true;
}
- pending_update --;
+ pending_update--;
return true;
}
@@ -805,29 +783,29 @@ bool Tween::resume_all() {
set_active(true);
_set_process(true);
- pending_update ++;
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ pending_update++;
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
data.active = true;
}
- pending_update --;
+ pending_update--;
return true;
}
bool Tween::remove(Object *p_object, String p_key) {
- if(pending_update != 0) {
+ if (pending_update != 0) {
call_deferred("remove", p_object, p_key);
return true;
}
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
Object *object = ObjectDB::get_instance(data.id);
- if(object == NULL)
+ if (object == NULL)
continue;
- if(object == p_object && data.key == p_key) {
+ if (object == p_object && data.key == p_key) {
interpolates.erase(E);
return true;
}
@@ -837,7 +815,7 @@ bool Tween::remove(Object *p_object, String p_key) {
bool Tween::remove_all() {
- if(pending_update != 0) {
+ if (pending_update != 0) {
call_deferred("remove_all");
return true;
}
@@ -849,89 +827,87 @@ bool Tween::remove_all() {
bool Tween::seek(real_t p_time) {
- pending_update ++;
- for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ pending_update++;
+ for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- InterpolateData& data = E->get();
+ InterpolateData &data = E->get();
data.elapsed = p_time;
- if(data.elapsed < data.delay) {
+ if (data.elapsed < data.delay) {
data.finish = false;
continue;
- }
- else if(data.elapsed >= (data.delay + data.times_in_sec)) {
+ } else if (data.elapsed >= (data.delay + data.times_in_sec)) {
data.finish = true;
data.elapsed = (data.delay + data.times_in_sec);
} else
data.finish = false;
- switch(data.type)
- {
- case INTER_PROPERTY:
- case INTER_METHOD:
- break;
- case INTER_CALLBACK:
- continue;
+ switch (data.type) {
+ case INTER_PROPERTY:
+ case INTER_METHOD:
+ break;
+ case INTER_CALLBACK:
+ continue;
}
Variant result = _run_equation(data);
_apply_tween_value(data, result);
}
- pending_update --;
+ pending_update--;
return true;
}
real_t Tween::tell() const {
- pending_update ++;
+ pending_update++;
real_t pos = 0;
- for(const List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- const InterpolateData& data = E->get();
- if(data.elapsed > pos)
+ const InterpolateData &data = E->get();
+ if (data.elapsed > pos)
pos = data.elapsed;
}
- pending_update --;
+ pending_update--;
return pos;
}
real_t Tween::get_runtime() const {
- pending_update ++;
+ pending_update++;
real_t runtime = 0;
- for(const List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
+ for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
- const InterpolateData& data = E->get();
+ const InterpolateData &data = E->get();
real_t t = data.delay + data.times_in_sec;
- if(t > runtime)
+ if (t > runtime)
runtime = t;
}
- pending_update --;
+ pending_update--;
return runtime;
}
-bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final_val, Variant& p_delta_val) {
+bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final_val, Variant &p_delta_val) {
- const Variant& initial_val = p_initial_val;
- const Variant& final_val = p_final_val;
- Variant& delta_val = p_delta_val;
+ const Variant &initial_val = p_initial_val;
+ const Variant &final_val = p_final_val;
+ Variant &delta_val = p_delta_val;
- switch(initial_val.get_type()) {
+ switch (initial_val.get_type()) {
case Variant::BOOL:
//delta_val = p_final_val;
- delta_val = (int) p_final_val - (int) p_initial_val;
+ delta_val = (int)p_final_val - (int)p_initial_val;
break;
case Variant::INT:
- delta_val = (int) final_val - (int) initial_val;
+ delta_val = (int)final_val - (int)initial_val;
break;
case Variant::REAL:
- delta_val = (real_t) final_val - (real_t) initial_val;
+ delta_val = (real_t)final_val - (real_t)initial_val;
break;
case Variant::VECTOR2:
@@ -942,11 +918,10 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final
delta_val = final_val.operator Vector3() - initial_val.operator Vector3();
break;
- case Variant::MATRIX3:
- {
- Matrix3 i = initial_val;
- Matrix3 f = final_val;
- delta_val = Matrix3(f.elements[0][0] - i.elements[0][0],
+ case Variant::MATRIX3: {
+ Matrix3 i = initial_val;
+ Matrix3 f = final_val;
+ delta_val = Matrix3(f.elements[0][0] - i.elements[0][0],
f.elements[0][1] - i.elements[0][1],
f.elements[0][2] - i.elements[0][2],
f.elements[1][0] - i.elements[1][0],
@@ -954,41 +929,34 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final
f.elements[1][2] - i.elements[1][2],
f.elements[2][0] - i.elements[2][0],
f.elements[2][1] - i.elements[2][1],
- f.elements[2][2] - i.elements[2][2]
- );
- }
- break;
+ f.elements[2][2] - i.elements[2][2]);
+ } break;
- case Variant::MATRIX32:
- {
- Matrix32 i = initial_val;
- Matrix32 f = final_val;
- Matrix32 d = Matrix32();
- d[0][0] = f.elements[0][0] - i.elements[0][0];
- d[0][1] = f.elements[0][1] - i.elements[0][1];
- d[1][0] = f.elements[1][0] - i.elements[1][0];
- d[1][1] = f.elements[1][1] - i.elements[1][1];
- d[2][0] = f.elements[2][0] - i.elements[2][0];
- d[2][1] = f.elements[2][1] - i.elements[2][1];
- delta_val = d;
- }
- break;
+ case Variant::MATRIX32: {
+ Matrix32 i = initial_val;
+ Matrix32 f = final_val;
+ Matrix32 d = Matrix32();
+ d[0][0] = f.elements[0][0] - i.elements[0][0];
+ d[0][1] = f.elements[0][1] - i.elements[0][1];
+ d[1][0] = f.elements[1][0] - i.elements[1][0];
+ d[1][1] = f.elements[1][1] - i.elements[1][1];
+ d[2][0] = f.elements[2][0] - i.elements[2][0];
+ d[2][1] = f.elements[2][1] - i.elements[2][1];
+ delta_val = d;
+ } break;
case Variant::QUAT:
delta_val = final_val.operator Quat() - initial_val.operator Quat();
break;
- case Variant::_AABB:
- {
- AABB i = initial_val;
- AABB f = final_val;
- delta_val = AABB(f.pos - i.pos, f.size - i.size);
- }
- break;
- case Variant::TRANSFORM:
- {
- Transform i = initial_val;
- Transform f = final_val;
- Transform d;
- d.set(f.basis.elements[0][0] - i.basis.elements[0][0],
+ case Variant::_AABB: {
+ AABB i = initial_val;
+ AABB f = final_val;
+ delta_val = AABB(f.pos - i.pos, f.size - i.size);
+ } break;
+ case Variant::TRANSFORM: {
+ Transform i = initial_val;
+ Transform f = final_val;
+ Transform d;
+ d.set(f.basis.elements[0][0] - i.basis.elements[0][0],
f.basis.elements[0][1] - i.basis.elements[0][1],
f.basis.elements[0][2] - i.basis.elements[0][2],
f.basis.elements[1][0] - i.basis.elements[1][0],
@@ -999,19 +967,15 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final
f.basis.elements[2][2] - i.basis.elements[2][2],
f.origin.x - i.origin.x,
f.origin.y - i.origin.y,
- f.origin.z - i.origin.z
- );
+ f.origin.z - i.origin.z);
- delta_val = d;
- }
- break;
- case Variant::COLOR:
- {
- Color i = initial_val;
- Color f = final_val;
- delta_val = Color(f.r - i.r, f.g - i.g, f.b - i.b, f.a - i.a);
- }
- break;
+ delta_val = d;
+ } break;
+ case Variant::COLOR: {
+ Color i = initial_val;
+ Color f = final_val;
+ delta_val = Color(f.r - i.r, f.g - i.g, f.b - i.b, f.a - i.a);
+ } break;
default:
ERR_PRINT("Invalid param type, except(int/real/vector2/vector/matrix/matrix32/quat/aabb/transform/color)");
@@ -1020,31 +984,14 @@ bool Tween::_calc_delta_val(const Variant& p_initial_val, const Variant& p_final
return true;
}
-bool Tween::interpolate_property(Object *p_object
- , String p_property
- , Variant p_initial_val
- , Variant p_final_val
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay
-) {
- if(pending_update != 0) {
- _add_pending_command("interpolate_property"
- , p_object
- , p_property
- , p_initial_val
- , p_final_val
- , p_times_in_sec
- , p_trans_type
- , p_ease_type
- , p_delay
- );
+bool Tween::interpolate_property(Object *p_object, String p_property, Variant p_initial_val, Variant p_final_val, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+ if (pending_update != 0) {
+ _add_pending_command("interpolate_property", p_object, p_property, p_initial_val, p_final_val, p_times_in_sec, p_trans_type, p_ease_type, p_delay);
return true;
}
// convert INT to REAL is better for interpolaters
- if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
- if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
+ if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
+ if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
@@ -1055,7 +1002,7 @@ bool Tween::interpolate_property(Object *p_object
ERR_FAIL_COND_V(p_delay < 0, false);
bool prop_valid = false;
- p_object->get(p_property,&prop_valid);
+ p_object->get(p_property, &prop_valid);
ERR_FAIL_COND_V(!prop_valid, false);
InterpolateData data;
@@ -1073,38 +1020,21 @@ bool Tween::interpolate_property(Object *p_object
data.ease_type = p_ease_type;
data.delay = p_delay;
- if(!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
+ if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
return false;
interpolates.push_back(data);
return true;
}
-bool Tween::interpolate_method(Object *p_object
- , String p_method
- , Variant p_initial_val
- , Variant p_final_val
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay
-) {
- if(pending_update != 0) {
- _add_pending_command("interpolate_method"
- , p_object
- , p_method
- , p_initial_val
- , p_final_val
- , p_times_in_sec
- , p_trans_type
- , p_ease_type
- , p_delay
- );
+bool Tween::interpolate_method(Object *p_object, String p_method, Variant p_initial_val, Variant p_final_val, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+ if (pending_update != 0) {
+ _add_pending_command("interpolate_method", p_object, p_method, p_initial_val, p_final_val, p_times_in_sec, p_trans_type, p_ease_type, p_delay);
return true;
}
// convert INT to REAL is better for interpolaters
- if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
- if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
+ if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
+ if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
@@ -1132,30 +1062,17 @@ bool Tween::interpolate_method(Object *p_object
data.ease_type = p_ease_type;
data.delay = p_delay;
- if(!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
+ if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
return false;
interpolates.push_back(data);
return true;
}
-bool Tween::interpolate_callback(Object *p_object
- , real_t p_times_in_sec
- , String p_callback
- , VARIANT_ARG_DECLARE
-) {
+bool Tween::interpolate_callback(Object *p_object, real_t p_times_in_sec, String p_callback, VARIANT_ARG_DECLARE) {
- if(pending_update != 0) {
- _add_pending_command("interpolate_callback"
- , p_object
- , p_times_in_sec
- , p_callback
- , p_arg1
- , p_arg2
- , p_arg3
- , p_arg4
- , p_arg5
- );
+ if (pending_update != 0) {
+ _add_pending_command("interpolate_callback", p_object, p_times_in_sec, p_callback, p_arg1, p_arg2, p_arg3, p_arg4, p_arg5);
return true;
}
@@ -1178,19 +1095,19 @@ bool Tween::interpolate_callback(Object *p_object
data.times_in_sec = p_times_in_sec;
data.delay = 0;
- int args=0;
- if (p_arg5.get_type()!=Variant::NIL)
- args=5;
- else if (p_arg4.get_type()!=Variant::NIL)
- args=4;
- else if (p_arg3.get_type()!=Variant::NIL)
- args=3;
- else if (p_arg2.get_type()!=Variant::NIL)
- args=2;
- else if (p_arg1.get_type()!=Variant::NIL)
- args=1;
+ int args = 0;
+ if (p_arg5.get_type() != Variant::NIL)
+ args = 5;
+ else if (p_arg4.get_type() != Variant::NIL)
+ args = 4;
+ else if (p_arg3.get_type() != Variant::NIL)
+ args = 3;
+ else if (p_arg2.get_type() != Variant::NIL)
+ args = 2;
+ else if (p_arg1.get_type() != Variant::NIL)
+ args = 1;
else
- args=0;
+ args = 0;
data.args = args;
data.arg[0] = p_arg1;
@@ -1199,29 +1116,16 @@ bool Tween::interpolate_callback(Object *p_object
data.arg[3] = p_arg4;
data.arg[4] = p_arg5;
- pending_update ++;
+ pending_update++;
interpolates.push_back(data);
- pending_update --;
+ pending_update--;
return true;
}
-bool Tween::interpolate_deferred_callback(Object *p_object
- , real_t p_times_in_sec
- , String p_callback
- , VARIANT_ARG_DECLARE
-) {
+bool Tween::interpolate_deferred_callback(Object *p_object, real_t p_times_in_sec, String p_callback, VARIANT_ARG_DECLARE) {
- if(pending_update != 0) {
- _add_pending_command("interpolate_deferred_callback"
- , p_object
- , p_times_in_sec
- , p_callback
- , p_arg1
- , p_arg2
- , p_arg3
- , p_arg4
- , p_arg5
- );
+ if (pending_update != 0) {
+ _add_pending_command("interpolate_deferred_callback", p_object, p_times_in_sec, p_callback, p_arg1, p_arg2, p_arg3, p_arg4, p_arg5);
return true;
}
ERR_FAIL_COND_V(p_object == NULL, false);
@@ -1243,19 +1147,19 @@ bool Tween::interpolate_deferred_callback(Object *p_object
data.times_in_sec = p_times_in_sec;
data.delay = 0;
- int args=0;
- if (p_arg5.get_type()!=Variant::NIL)
- args=5;
- else if (p_arg4.get_type()!=Variant::NIL)
- args=4;
- else if (p_arg3.get_type()!=Variant::NIL)
- args=3;
- else if (p_arg2.get_type()!=Variant::NIL)
- args=2;
- else if (p_arg1.get_type()!=Variant::NIL)
- args=1;
+ int args = 0;
+ if (p_arg5.get_type() != Variant::NIL)
+ args = 5;
+ else if (p_arg4.get_type() != Variant::NIL)
+ args = 4;
+ else if (p_arg3.get_type() != Variant::NIL)
+ args = 3;
+ else if (p_arg2.get_type() != Variant::NIL)
+ args = 2;
+ else if (p_arg1.get_type() != Variant::NIL)
+ args = 1;
else
- args=0;
+ args = 0;
data.args = args;
data.arg[0] = p_arg1;
@@ -1264,38 +1168,19 @@ bool Tween::interpolate_deferred_callback(Object *p_object
data.arg[3] = p_arg4;
data.arg[4] = p_arg5;
- pending_update ++;
+ pending_update++;
interpolates.push_back(data);
- pending_update --;
+ pending_update--;
return true;
}
-bool Tween::follow_property(Object *p_object
- , String p_property
- , Variant p_initial_val
- , Object *p_target
- , String p_target_property
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay
-) {
- if(pending_update != 0) {
- _add_pending_command("follow_property"
- , p_object
- , p_property
- , p_initial_val
- , p_target
- , p_target_property
- , p_times_in_sec
- , p_trans_type
- , p_ease_type
- , p_delay
- );
+bool Tween::follow_property(Object *p_object, String p_property, Variant p_initial_val, Object *p_target, String p_target_property, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+ if (pending_update != 0) {
+ _add_pending_command("follow_property", p_object, p_property, p_initial_val, p_target, p_target_property, p_times_in_sec, p_trans_type, p_ease_type, p_delay);
return true;
}
// convert INT to REAL is better for interpolaters
- if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
+ if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
@@ -1307,15 +1192,15 @@ bool Tween::follow_property(Object *p_object
ERR_FAIL_COND_V(p_delay < 0, false);
bool prop_valid = false;
- p_object->get(p_property,&prop_valid);
+ p_object->get(p_property, &prop_valid);
ERR_FAIL_COND_V(!prop_valid, false);
bool target_prop_valid = false;
- Variant target_val = p_target->get(p_target_property,&target_prop_valid);
+ Variant target_val = p_target->get(p_target_property, &target_prop_valid);
ERR_FAIL_COND_V(!target_prop_valid, false);
// convert INT to REAL is better for interpolaters
- if(target_val.get_type() == Variant::INT) target_val = target_val.operator real_t();
+ if (target_val.get_type() == Variant::INT) target_val = target_val.operator real_t();
ERR_FAIL_COND_V(target_val.get_type() != p_initial_val.get_type(), false);
InterpolateData data;
@@ -1338,32 +1223,13 @@ bool Tween::follow_property(Object *p_object
return true;
}
-bool Tween::follow_method(Object *p_object
- , String p_method
- , Variant p_initial_val
- , Object *p_target
- , String p_target_method
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay
-) {
- if(pending_update != 0) {
- _add_pending_command("follow_method"
- , p_object
- , p_method
- , p_initial_val
- , p_target
- , p_target_method
- , p_times_in_sec
- , p_trans_type
- , p_ease_type
- , p_delay
- );
+bool Tween::follow_method(Object *p_object, String p_method, Variant p_initial_val, Object *p_target, String p_target_method, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+ if (pending_update != 0) {
+ _add_pending_command("follow_method", p_object, p_method, p_initial_val, p_target, p_target_method, p_times_in_sec, p_trans_type, p_ease_type, p_delay);
return true;
}
// convert INT to REAL is better for interpolaters
- if(p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
+ if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
@@ -1384,7 +1250,7 @@ bool Tween::follow_method(Object *p_object
ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, false);
// convert INT to REAL is better for interpolaters
- if(target_val.get_type() == Variant::INT) target_val = target_val.operator real_t();
+ if (target_val.get_type() == Variant::INT) target_val = target_val.operator real_t();
ERR_FAIL_COND_V(target_val.get_type() != p_initial_val.get_type(), false);
InterpolateData data;
@@ -1407,32 +1273,13 @@ bool Tween::follow_method(Object *p_object
return true;
}
-bool Tween::targeting_property(Object *p_object
- , String p_property
- , Object *p_initial
- , String p_initial_property
- , Variant p_final_val
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay
-) {
- if(pending_update != 0) {
- _add_pending_command("targeting_property"
- , p_object
- , p_property
- , p_initial
- , p_initial_property
- , p_final_val
- , p_times_in_sec
- , p_trans_type
- , p_ease_type
- , p_delay
- );
+bool Tween::targeting_property(Object *p_object, String p_property, Object *p_initial, String p_initial_property, Variant p_final_val, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+ if (pending_update != 0) {
+ _add_pending_command("targeting_property", p_object, p_property, p_initial, p_initial_property, p_final_val, p_times_in_sec, p_trans_type, p_ease_type, p_delay);
return true;
}
// convert INT to REAL is better for interpolaters
- if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
+ if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
@@ -1444,15 +1291,15 @@ bool Tween::targeting_property(Object *p_object
ERR_FAIL_COND_V(p_delay < 0, false);
bool prop_valid = false;
- p_object->get(p_property,&prop_valid);
+ p_object->get(p_property, &prop_valid);
ERR_FAIL_COND_V(!prop_valid, false);
bool initial_prop_valid = false;
- Variant initial_val = p_initial->get(p_initial_property,&initial_prop_valid);
+ Variant initial_val = p_initial->get(p_initial_property, &initial_prop_valid);
ERR_FAIL_COND_V(!initial_prop_valid, false);
// convert INT to REAL is better for interpolaters
- if(initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t();
+ if (initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t();
ERR_FAIL_COND_V(initial_val.get_type() != p_final_val.get_type(), false);
InterpolateData data;
@@ -1472,40 +1319,20 @@ bool Tween::targeting_property(Object *p_object
data.ease_type = p_ease_type;
data.delay = p_delay;
- if(!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
+ if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
return false;
interpolates.push_back(data);
return true;
}
-
-bool Tween::targeting_method(Object *p_object
- , String p_method
- , Object *p_initial
- , String p_initial_method
- , Variant p_final_val
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay
-) {
- if(pending_update != 0) {
- _add_pending_command("targeting_method"
- , p_object
- , p_method
- , p_initial
- , p_initial_method
- , p_final_val
- , p_times_in_sec
- , p_trans_type
- , p_ease_type
- , p_delay
- );
+bool Tween::targeting_method(Object *p_object, String p_method, Object *p_initial, String p_initial_method, Variant p_final_val, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+ if (pending_update != 0) {
+ _add_pending_command("targeting_method", p_object, p_method, p_initial, p_initial_method, p_final_val, p_times_in_sec, p_trans_type, p_ease_type, p_delay);
return true;
}
// convert INT to REAL is better for interpolaters
- if(p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
+ if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
ERR_FAIL_COND_V(p_object == NULL, false);
ERR_FAIL_COND_V(!ObjectDB::instance_validate(p_object), false);
@@ -1526,7 +1353,7 @@ bool Tween::targeting_method(Object *p_object
ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, false);
// convert INT to REAL is better for interpolaters
- if(initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t();
+ if (initial_val.get_type() == Variant::INT) initial_val = initial_val.operator real_t();
ERR_FAIL_COND_V(initial_val.get_type() != p_final_val.get_type(), false);
InterpolateData data;
@@ -1546,7 +1373,7 @@ bool Tween::targeting_method(Object *p_object
data.ease_type = p_ease_type;
data.delay = p_delay;
- if(!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
+ if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val))
return false;
interpolates.push_back(data);
@@ -1556,14 +1383,13 @@ bool Tween::targeting_method(Object *p_object
Tween::Tween() {
//String autoplay;
- tween_process_mode=TWEEN_PROCESS_IDLE;
- processing=false;
- active=false;
- repeat=false;
- speed_scale=1;
- pending_update=0;
+ tween_process_mode = TWEEN_PROCESS_IDLE;
+ processing = false;
+ active = false;
+ repeat = false;
+ speed_scale = 1;
+ pending_update = 0;
}
Tween::~Tween() {
-
}
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index 023baecbb..7d4728e71 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -31,10 +31,9 @@
#include "scene/main/node.h"
-
class Tween : public Node {
- OBJ_TYPE( Tween, Node );
+ OBJ_TYPE(Tween, Node);
public:
enum TweenProcessMode {
@@ -42,30 +41,30 @@ public:
TWEEN_PROCESS_IDLE,
};
- enum TransitionType {
- TRANS_LINEAR,
- TRANS_SINE,
- TRANS_QUINT,
- TRANS_QUART,
- TRANS_QUAD,
- TRANS_EXPO,
- TRANS_ELASTIC,
- TRANS_CUBIC,
- TRANS_CIRC,
- TRANS_BOUNCE,
- TRANS_BACK,
+ enum TransitionType {
+ TRANS_LINEAR,
+ TRANS_SINE,
+ TRANS_QUINT,
+ TRANS_QUART,
+ TRANS_QUAD,
+ TRANS_EXPO,
+ TRANS_ELASTIC,
+ TRANS_CUBIC,
+ TRANS_CIRC,
+ TRANS_BOUNCE,
+ TRANS_BACK,
TRANS_COUNT,
- };
+ };
- enum EaseType {
- EASE_IN,
- EASE_OUT,
- EASE_IN_OUT,
+ enum EaseType {
+ EASE_IN,
+ EASE_OUT,
+ EASE_IN_OUT,
EASE_OUT_IN,
EASE_COUNT,
- };
+ };
private:
enum InterpolateType {
@@ -117,44 +116,31 @@ private:
};
List<PendingCommand> pending_commands;
- void _add_pending_command(StringName p_key
- ,const Variant& p_arg1=Variant()
- ,const Variant& p_arg2=Variant()
- ,const Variant& p_arg3=Variant()
- ,const Variant& p_arg4=Variant()
- ,const Variant& p_arg5=Variant()
- ,const Variant& p_arg6=Variant()
- ,const Variant& p_arg7=Variant()
- ,const Variant& p_arg8=Variant()
- ,const Variant& p_arg9=Variant()
- ,const Variant& p_arg10=Variant()
- );
+ void _add_pending_command(StringName p_key, const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant(), const Variant &p_arg6 = Variant(), const Variant &p_arg7 = Variant(), const Variant &p_arg8 = Variant(), const Variant &p_arg9 = Variant(), const Variant &p_arg10 = Variant());
void _process_pending_commands();
typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d);
static interpolater interpolaters[TRANS_COUNT][EASE_COUNT];
real_t _run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d);
- Variant& _get_delta_val(InterpolateData& p_data);
- Variant& _get_initial_val(InterpolateData& p_data);
- Variant _run_equation(InterpolateData& p_data);
- bool _calc_delta_val(const Variant& p_initial_val, const Variant& p_final_val, Variant& p_delta_val);
- bool _apply_tween_value(InterpolateData& p_data, Variant& value);
+ Variant &_get_delta_val(InterpolateData &p_data);
+ Variant &_get_initial_val(InterpolateData &p_data);
+ Variant _run_equation(InterpolateData &p_data);
+ bool _calc_delta_val(const Variant &p_initial_val, const Variant &p_final_val, Variant &p_delta_val);
+ bool _apply_tween_value(InterpolateData &p_data, Variant &value);
void _tween_process(float p_delta);
- void _set_process(bool p_process,bool p_force=false);
+ void _set_process(bool p_process, bool p_force = false);
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
-
bool is_active() const;
void set_active(bool p_active);
@@ -181,89 +167,28 @@ public:
real_t tell() const;
real_t get_runtime() const;
- bool interpolate_property(Object *p_node
- , String p_property
- , Variant p_initial_val
- , Variant p_final_val
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay = 0
- );
+ bool interpolate_property(Object *p_node, String p_property, Variant p_initial_val, Variant p_final_val, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool interpolate_method(Object *p_node
- , String p_method
- , Variant p_initial_val
- , Variant p_final_val
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay = 0
- );
+ bool interpolate_method(Object *p_node, String p_method, Variant p_initial_val, Variant p_final_val, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool interpolate_callback(Object *p_object
- , real_t p_times_in_sec
- , String p_callback
- , VARIANT_ARG_DECLARE
- );
+ bool interpolate_callback(Object *p_object, real_t p_times_in_sec, String p_callback, VARIANT_ARG_DECLARE);
- bool interpolate_deferred_callback(Object *p_object
- , real_t p_times_in_sec
- , String p_callback
- , VARIANT_ARG_DECLARE
- );
+ bool interpolate_deferred_callback(Object *p_object, real_t p_times_in_sec, String p_callback, VARIANT_ARG_DECLARE);
- bool follow_property(Object *p_node
- , String p_property
- , Variant p_initial_val
- , Object *p_target
- , String p_target_property
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay = 0
- );
+ bool follow_property(Object *p_node, String p_property, Variant p_initial_val, Object *p_target, String p_target_property, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool follow_method(Object *p_node
- , String p_method
- , Variant p_initial_val
- , Object *p_target
- , String p_target_method
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay = 0
- );
+ bool follow_method(Object *p_node, String p_method, Variant p_initial_val, Object *p_target, String p_target_method, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool targeting_property(Object *p_node
- , String p_property
- , Object *p_initial
- , String p_initial_property
- , Variant p_final_val
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay = 0
- );
+ bool targeting_property(Object *p_node, String p_property, Object *p_initial, String p_initial_property, Variant p_final_val, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool targeting_method(Object *p_node
- , String p_method
- , Object *p_initial
- , String p_initial_method
- , Variant p_final_val
- , real_t p_times_in_sec
- , TransitionType p_trans_type
- , EaseType p_ease_type
- , real_t p_delay = 0
- );
+ bool targeting_method(Object *p_node, String p_method, Object *p_initial, String p_initial_method, Variant p_final_val, real_t p_times_in_sec, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
Tween();
~Tween();
};
-VARIANT_ENUM_CAST( Tween::TweenProcessMode );
-VARIANT_ENUM_CAST( Tween::TransitionType );
-VARIANT_ENUM_CAST( Tween::EaseType );
+VARIANT_ENUM_CAST(Tween::TweenProcessMode);
+VARIANT_ENUM_CAST(Tween::TransitionType);
+VARIANT_ENUM_CAST(Tween::EaseType);
#endif
-
diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp
index 25a27252f..ef55b63ed 100644
--- a/scene/animation/tween_interpolaters.cpp
+++ b/scene/animation/tween_interpolaters.cpp
@@ -34,355 +34,278 @@ const real_t pi = 3.1415926535898;
// linear
///////////////////////////////////////////////////////////////////////////
namespace linear {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- return c * t / d + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * t / d + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- return c * t / d + b;
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ return c * t / d + b;
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- return c * t / d + b;
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ return c * t / d + b;
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return c * t / d + b;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return c * t / d + b;
+}
};
///////////////////////////////////////////////////////////////////////////
// sine
///////////////////////////////////////////////////////////////////////////
namespace sine {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- return -c * cos(t / d * (pi / 2)) + c + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return -c * cos(t / d * (pi / 2)) + c + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- return c * sin(t / d * (pi / 2)) + b;
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ return c * sin(t / d * (pi / 2)) + b;
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- return -c / 2 * (cos(pi * t / d) - 1) + b;
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ return -c / 2 * (cos(pi * t / d) - 1) + b;
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// quint
///////////////////////////////////////////////////////////////////////////
namespace quint {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- return c * pow(t / d, 5) + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * pow(t / d, 5) + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- return c * (pow(t / d - 1, 5) + 1) + b;
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ return c * (pow(t / d - 1, 5) + 1) + b;
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- t = t / d * 2;
- if (t < 1) return c / 2 * pow(t, 5) + b;
- return c / 2 * (pow(t - 2, 5) + 2) + b;
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d * 2;
+ if (t < 1) return c / 2 * pow(t, 5) + b;
+ return c / 2 * (pow(t - 2, 5) + 2) + b;
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// quart
///////////////////////////////////////////////////////////////////////////
namespace quart {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- return c * pow(t / d, 4) + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * pow(t / d, 4) + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- return -c * (pow(t / d - 1, 4) - 1) + b;
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ return -c * (pow(t / d - 1, 4) - 1) + b;
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- t = t / d * 2;
- if (t < 1) return c / 2 * pow(t, 4) + b;
- return -c / 2 * (pow(t - 2, 4) - 2) + b;
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d * 2;
+ if (t < 1) return c / 2 * pow(t, 4) + b;
+ return -c / 2 * (pow(t - 2, 4) - 2) + b;
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// quad
///////////////////////////////////////////////////////////////////////////
namespace quad {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- return c * pow(t / d, 2) + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * pow(t / d, 2) + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- t = t / d;
- return -c * t * (t - 2) + b;
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d;
+ return -c * t * (t - 2) + b;
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- t = t / d * 2;
- if (t < 1) return c / 2 * pow(t, 2) + b;
- return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d * 2;
+ if (t < 1) return c / 2 * pow(t, 2) + b;
+ return -c / 2 * ((t - 1) * (t - 3) - 1) + b;
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// expo
///////////////////////////////////////////////////////////////////////////
namespace expo {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- if (t == 0) return b;
- return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) return b;
+ return c * pow(2, 10 * (t / d - 1)) + b - c * 0.001;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- if (t == d) return b + c;
- return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b;
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ if (t == d) return b + c;
+ return c * 1.001 * (-pow(2, -10 * t / d) + 1) + b;
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- if (t == 0) return b;
- if (t == d) return b + c;
- t = t / d * 2;
- if (t < 1) return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005;
- return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b;
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) return b;
+ if (t == d) return b + c;
+ t = t / d * 2;
+ if (t < 1) return c / 2 * pow(2, 10 * (t - 1)) + b - c * 0.0005;
+ return c / 2 * 1.0005 * (-pow(2, -10 * (t - 1)) + 2) + b;
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// elastic
///////////////////////////////////////////////////////////////////////////
namespace elastic {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- if (t == 0) return b;
- if ((t /= d) == 1) return b + c;
- float p = d * 0.3f;
- float a = c;
- float s = p / 4;
- float postFix = a * pow(2,10 * (t -= 1)); // this is a fix, again, with post-increment operators
- return -(postFix * sin((t * d - s) * (2 * pi) / p )) + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) return b;
+ if ((t /= d) == 1) return b + c;
+ float p = d * 0.3f;
+ float a = c;
+ float s = p / 4;
+ float postFix = a * pow(2, 10 * (t -= 1)); // this is a fix, again, with post-increment operators
+ return -(postFix * sin((t * d - s) * (2 * pi) / p)) + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- if (t == 0) return b;
- if ((t /= d) == 1) return b + c;
- float p = d * 0.3f;
- float a = c;
- float s = p / 4;
- return (a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p ) + c + b);
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) return b;
+ if ((t /= d) == 1) return b + c;
+ float p = d * 0.3f;
+ float a = c;
+ float s = p / 4;
+ return (a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b);
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- if (t == 0) return b;
- if ((t /= d / 2) == 2) return b + c;
- float p = d * (0.3f * 1.5f);
- float a = c;
- float s = p / 4;
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ if (t == 0) return b;
+ if ((t /= d / 2) == 2) return b + c;
+ float p = d * (0.3f * 1.5f);
+ float a = c;
+ float s = p / 4;
- if (t < 1) {
- float postFix = a * pow(2, 10 * (t -= 1)); // postIncrement is evil
- return -0.5f * (postFix * sin((t * d - s) * (2 * pi) / p)) + b;
- }
- float postFix = a * pow(2, -10 * (t -= 1)); // postIncrement is evil
- return postFix * sin((t * d - s) * (2 * pi) / p ) * 0.5f + c + b;
+ if (t < 1) {
+ float postFix = a * pow(2, 10 * (t -= 1)); // postIncrement is evil
+ return -0.5f * (postFix * sin((t * d - s) * (2 * pi) / p)) + b;
}
+ float postFix = a * pow(2, -10 * (t -= 1)); // postIncrement is evil
+ return postFix * sin((t * d - s) * (2 * pi) / p) * 0.5f + c + b;
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// cubic
///////////////////////////////////////////////////////////////////////////
namespace cubic {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- return c * (t /= d) * t * t + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c * (t /= d) * t * t + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- t = t / d - 1;
- return c * (t * t * t + 1) + b;
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ t = t / d - 1;
+ return c * (t * t * t + 1) + b;
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
- return c / 2 * ((t -= 2) * t * t + 2) + b;
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
+ return c / 2 * ((t -= 2) * t * t + 2) + b;
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// circ
///////////////////////////////////////////////////////////////////////////
namespace circ {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- return -c * (sqrt(1 - (t /= d) * t) - 1) + b; // TODO: ehrich: operation with t is undefined
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return -c * (sqrt(1 - (t /= d) * t) - 1) + b; // TODO: ehrich: operation with t is undefined
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- return c * sqrt(1 - (t = t / d - 1) * t) + b; // TODO: ehrich: operation with t is undefined
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ return c * sqrt(1 - (t = t / d - 1) * t) + b; // TODO: ehrich: operation with t is undefined
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- if ((t /= d / 2) < 1) return -c / 2 * (sqrt(1 - t * t) - 1) + b;
- return c / 2 * (sqrt(1 - t * (t -= 2)) + 1) + b; // TODO: ehrich: operation with t is undefined
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ if ((t /= d / 2) < 1) return -c / 2 * (sqrt(1 - t * t) - 1) + b;
+ return c / 2 * (sqrt(1 - t * (t -= 2)) + 1) + b; // TODO: ehrich: operation with t is undefined
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// bounce
///////////////////////////////////////////////////////////////////////////
namespace bounce {
- static real_t out(real_t t, real_t b, real_t c, real_t d);
+static real_t out(real_t t, real_t b, real_t c, real_t d);
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- return c - out(d - t, 0, c, d) + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ return c - out(d - t, 0, c, d) + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- if ((t /= d) < (1 / 2.75f)) {
- return c*(7.5625f*t*t) + b;
- } else if (t < (2/2.75f)) {
- float postFix = t-=(1.5f/2.75f);
- return c*(7.5625f*(postFix)*t + .75f) + b;
- } else if (t < (2.5/2.75)) {
- float postFix = t-=(2.25f/2.75f);
- return c*(7.5625f*(postFix)*t + .9375f) + b;
- } else {
- float postFix = t-=(2.625f/2.75f);
- return c*(7.5625f*(postFix)*t + .984375f) + b;
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ if ((t /= d) < (1 / 2.75f)) {
+ return c * (7.5625f * t * t) + b;
+ } else if (t < (2 / 2.75f)) {
+ float postFix = t -= (1.5f / 2.75f);
+ return c * (7.5625f * (postFix)*t + .75f) + b;
+ } else if (t < (2.5 / 2.75)) {
+ float postFix = t -= (2.25f / 2.75f);
+ return c * (7.5625f * (postFix)*t + .9375f) + b;
+ } else {
+ float postFix = t -= (2.625f / 2.75f);
+ return c * (7.5625f * (postFix)*t + .984375f) + b;
}
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? in(t * 2, b, c / 2, d)
- : out((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? in(t * 2, b, c / 2, d) : out((t * 2) - d, b + c / 2, c / 2, d);
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
///////////////////////////////////////////////////////////////////////////
// back
///////////////////////////////////////////////////////////////////////////
namespace back {
- static real_t in(real_t t, real_t b, real_t c, real_t d)
- {
- float s = 1.70158f;
- float postFix = t /= d;
- return c * (postFix) * t * ((s + 1) * t - s) + b;
- }
+static real_t in(real_t t, real_t b, real_t c, real_t d) {
+ float s = 1.70158f;
+ float postFix = t /= d;
+ return c * (postFix)*t * ((s + 1) * t - s) + b;
+}
- static real_t out(real_t t, real_t b, real_t c, real_t d)
- {
- float s = 1.70158f;
- return c * ((t = t / d- 1) * t * ((s + 1) * t + s) + 1) + b; // TODO: ehrich: operation with t is undefined
- }
+static real_t out(real_t t, real_t b, real_t c, real_t d) {
+ float s = 1.70158f;
+ return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; // TODO: ehrich: operation with t is undefined
+}
- static real_t in_out(real_t t, real_t b, real_t c, real_t d)
- {
- float s = 1.70158f;
- if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525f)) + 1) * t - s)) + b; // TODO: ehrich: operation with s is undefined
- float postFix = t -= 2;
- return c / 2 * ((postFix) * t * (((s *= (1.525f)) + 1) * t + s) + 2) + b; // TODO: ehrich: operation with s is undefined
- }
+static real_t in_out(real_t t, real_t b, real_t c, real_t d) {
+ float s = 1.70158f;
+ if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525f)) + 1) * t - s)) + b; // TODO: ehrich: operation with s is undefined
+ float postFix = t -= 2;
+ return c / 2 * ((postFix)*t * (((s *= (1.525f)) + 1) * t + s) + 2) + b; // TODO: ehrich: operation with s is undefined
+}
- static real_t out_in(real_t t, real_t b, real_t c, real_t d)
- {
- return (t < d / 2)
- ? out(t * 2, b, c / 2, d)
- : in((t * 2) - d, b + c / 2, c / 2, d)
- ;
- }
+static real_t out_in(real_t t, real_t b, real_t c, real_t d) {
+ return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d);
+}
};
Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT] = {
@@ -405,4 +328,3 @@ real_t Tween::_run_equation(TransitionType p_trans_type, EaseType p_ease_type, r
ERR_FAIL_COND_V(cb == NULL, b);
return cb(t, b, c, d);
}
-
diff --git a/scene/audio/event_player.cpp b/scene/audio/event_player.cpp
index fb83b8252..f7b560408 100644
--- a/scene/audio/event_player.cpp
+++ b/scene/audio/event_player.cpp
@@ -28,10 +28,9 @@
/*************************************************************************/
#include "event_player.h"
-
void EventPlayer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -46,14 +45,12 @@ void EventPlayer::_notification(int p_what) {
}
}
-
-
void EventPlayer::set_stream(const Ref<EventStream> &p_stream) {
stop();
- stream=p_stream;
+ stream = p_stream;
if (stream.is_valid())
- playback=stream->instance_playback();
+ playback = stream->instance_playback();
else
playback.unref();
@@ -62,11 +59,9 @@ void EventPlayer::set_stream(const Ref<EventStream> &p_stream) {
playback->set_loop(loops);
playback->set_paused(paused);
playback->set_volume(volume);
- for(int i=0;i<(MIN(MAX_CHANNELS,stream->get_channel_count()));i++)
- playback->set_channel_volume(i,channel_volume[i]);
+ for (int i = 0; i < (MIN(MAX_CHANNELS, stream->get_channel_count())); i++)
+ playback->set_channel_volume(i, channel_volume[i]);
}
-
-
}
Ref<EventStream> EventPlayer::get_stream() const {
@@ -74,7 +69,6 @@ Ref<EventStream> EventPlayer::get_stream() const {
return stream;
}
-
void EventPlayer::play() {
ERR_FAIL_COND(!is_inside_tree());
@@ -90,7 +84,6 @@ void EventPlayer::play() {
AudioServer::get_singleton()->lock();
playback->play();
AudioServer::get_singleton()->unlock();
-
}
void EventPlayer::stop() {
@@ -115,11 +108,10 @@ bool EventPlayer::is_playing() const {
void EventPlayer::set_loop(bool p_enable) {
- loops=p_enable;
+ loops = p_enable;
if (playback.is_null())
return;
playback->set_loop(loops);
-
}
bool EventPlayer::has_loop() const {
@@ -128,7 +120,7 @@ bool EventPlayer::has_loop() const {
void EventPlayer::set_volume(float p_volume) {
- volume=p_volume;
+ volume = p_volume;
if (playback.is_valid())
playback->set_volume(volume);
}
@@ -138,10 +130,9 @@ float EventPlayer::get_volume() const {
return volume;
}
-
void EventPlayer::set_volume_db(float p_db) {
- if (p_db<-79)
+ if (p_db < -79)
set_volume(0);
else
set_volume(Math::db2linear(p_db));
@@ -149,7 +140,7 @@ void EventPlayer::set_volume_db(float p_db) {
float EventPlayer::get_volume_db() const {
- if (volume==0)
+ if (volume == 0)
return -80;
else
return Math::linear2db(volume);
@@ -157,7 +148,7 @@ float EventPlayer::get_volume_db() const {
void EventPlayer::set_pitch_scale(float p_pitch_scale) {
- pitch_scale=p_pitch_scale;
+ pitch_scale = p_pitch_scale;
if (playback.is_valid())
playback->set_pitch_scale(pitch_scale);
}
@@ -169,7 +160,7 @@ float EventPlayer::get_pitch_scale() const {
void EventPlayer::set_tempo_scale(float p_tempo_scale) {
- tempo_scale=p_tempo_scale;
+ tempo_scale = p_tempo_scale;
if (playback.is_valid())
playback->set_tempo_scale(tempo_scale);
}
@@ -179,29 +170,25 @@ float EventPlayer::get_tempo_scale() const {
return tempo_scale;
}
-
-String EventPlayer::get_stream_name() const {
+String EventPlayer::get_stream_name() const {
if (stream.is_null())
return "<No Stream>";
return stream->get_name();
-
}
-int EventPlayer::get_loop_count() const {
+int EventPlayer::get_loop_count() const {
if (playback.is_null())
return 0;
return playback->get_loop_count();
-
}
-float EventPlayer::get_pos() const {
+float EventPlayer::get_pos() const {
if (playback.is_null())
return 0;
return playback->get_pos();
-
}
float EventPlayer::get_length() const {
@@ -215,12 +202,11 @@ void EventPlayer::seek_pos(float p_time) {
if (playback.is_null())
return;
return playback->seek_pos(p_time);
-
}
void EventPlayer::set_autoplay(bool p_enable) {
- autoplay=p_enable;
+ autoplay = p_enable;
}
bool EventPlayer::has_autoplay() const {
@@ -230,7 +216,7 @@ bool EventPlayer::has_autoplay() const {
void EventPlayer::set_paused(bool p_paused) {
- paused=p_paused;
+ paused = p_paused;
if (playback.is_valid())
playback->set_paused(p_paused);
}
@@ -242,34 +228,32 @@ bool EventPlayer::is_paused() const {
void EventPlayer::_set_play(bool p_play) {
- _play=p_play;
+ _play = p_play;
if (is_inside_tree()) {
- if(_play)
+ if (_play)
play();
else
stop();
}
-
}
-bool EventPlayer::_get_play() const{
+bool EventPlayer::_get_play() const {
return _play;
}
-void EventPlayer::set_channel_volume(int p_channel,float p_volume) {
+void EventPlayer::set_channel_volume(int p_channel, float p_volume) {
- ERR_FAIL_INDEX(p_channel,MAX_CHANNELS);
- channel_volume[p_channel]=p_volume;
+ ERR_FAIL_INDEX(p_channel, MAX_CHANNELS);
+ channel_volume[p_channel] = p_volume;
if (playback.is_valid())
- playback->set_channel_volume(p_channel,p_volume);
+ playback->set_channel_volume(p_channel, p_volume);
}
-float EventPlayer::get_channel_volume(int p_channel) const{
+float EventPlayer::get_channel_volume(int p_channel) const {
- ERR_FAIL_INDEX_V(p_channel,MAX_CHANNELS,0);
+ ERR_FAIL_INDEX_V(p_channel, MAX_CHANNELS, 0);
return channel_volume[p_channel];
-
}
float EventPlayer::get_channel_last_note_time(int p_channel) const {
@@ -282,76 +266,72 @@ float EventPlayer::get_channel_last_note_time(int p_channel) const {
void EventPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:EventStream"),&EventPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:EventStream"),&EventPlayer::get_stream);
+ ObjectTypeDB::bind_method(_MD("set_stream", "stream:EventStream"), &EventPlayer::set_stream);
+ ObjectTypeDB::bind_method(_MD("get_stream:EventStream"), &EventPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play"),&EventPlayer::play);
- ObjectTypeDB::bind_method(_MD("stop"),&EventPlayer::stop);
+ ObjectTypeDB::bind_method(_MD("play"), &EventPlayer::play);
+ ObjectTypeDB::bind_method(_MD("stop"), &EventPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&EventPlayer::is_playing);
+ ObjectTypeDB::bind_method(_MD("is_playing"), &EventPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&EventPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&EventPlayer::is_paused);
+ ObjectTypeDB::bind_method(_MD("set_paused", "paused"), &EventPlayer::set_paused);
+ ObjectTypeDB::bind_method(_MD("is_paused"), &EventPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&EventPlayer::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&EventPlayer::has_loop);
+ ObjectTypeDB::bind_method(_MD("set_loop", "enabled"), &EventPlayer::set_loop);
+ ObjectTypeDB::bind_method(_MD("has_loop"), &EventPlayer::has_loop);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&EventPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&EventPlayer::get_volume);
+ ObjectTypeDB::bind_method(_MD("set_volume", "volume"), &EventPlayer::set_volume);
+ ObjectTypeDB::bind_method(_MD("get_volume"), &EventPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_pitch_scale","pitch_scale"),&EventPlayer::set_pitch_scale);
- ObjectTypeDB::bind_method(_MD("get_pitch_scale"),&EventPlayer::get_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("set_pitch_scale", "pitch_scale"), &EventPlayer::set_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("get_pitch_scale"), &EventPlayer::get_pitch_scale);
- ObjectTypeDB::bind_method(_MD("set_tempo_scale","tempo_scale"),&EventPlayer::set_tempo_scale);
- ObjectTypeDB::bind_method(_MD("get_tempo_scale"),&EventPlayer::get_tempo_scale);
+ ObjectTypeDB::bind_method(_MD("set_tempo_scale", "tempo_scale"), &EventPlayer::set_tempo_scale);
+ ObjectTypeDB::bind_method(_MD("get_tempo_scale"), &EventPlayer::get_tempo_scale);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&EventPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&EventPlayer::get_volume_db);
+ ObjectTypeDB::bind_method(_MD("set_volume_db", "db"), &EventPlayer::set_volume_db);
+ ObjectTypeDB::bind_method(_MD("get_volume_db"), &EventPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&EventPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_loop_count"),&EventPlayer::get_loop_count);
+ ObjectTypeDB::bind_method(_MD("get_stream_name"), &EventPlayer::get_stream_name);
+ ObjectTypeDB::bind_method(_MD("get_loop_count"), &EventPlayer::get_loop_count);
- ObjectTypeDB::bind_method(_MD("get_pos"),&EventPlayer::get_pos);
- ObjectTypeDB::bind_method(_MD("seek_pos","time"),&EventPlayer::seek_pos);
+ ObjectTypeDB::bind_method(_MD("get_pos"), &EventPlayer::get_pos);
+ ObjectTypeDB::bind_method(_MD("seek_pos", "time"), &EventPlayer::seek_pos);
- ObjectTypeDB::bind_method(_MD("get_length"),&EventPlayer::get_length);
+ ObjectTypeDB::bind_method(_MD("get_length"), &EventPlayer::get_length);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&EventPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&EventPlayer::has_autoplay);
+ ObjectTypeDB::bind_method(_MD("set_autoplay", "enabled"), &EventPlayer::set_autoplay);
+ ObjectTypeDB::bind_method(_MD("has_autoplay"), &EventPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("set_channel_volume","channel","channel_volume"),&EventPlayer::set_channel_volume);
- ObjectTypeDB::bind_method(_MD("get_channel_volume","channel"),&EventPlayer::get_channel_volume);
- ObjectTypeDB::bind_method(_MD("get_channel_last_note_time","channel"),&EventPlayer::get_channel_last_note_time);
+ ObjectTypeDB::bind_method(_MD("set_channel_volume", "channel", "channel_volume"), &EventPlayer::set_channel_volume);
+ ObjectTypeDB::bind_method(_MD("get_channel_volume", "channel"), &EventPlayer::get_channel_volume);
+ ObjectTypeDB::bind_method(_MD("get_channel_last_note_time", "channel"), &EventPlayer::get_channel_last_note_time);
- ObjectTypeDB::bind_method(_MD("_set_play","play"),&EventPlayer::_set_play);
- ObjectTypeDB::bind_method(_MD("_get_play"),&EventPlayer::_get_play);
+ ObjectTypeDB::bind_method(_MD("_set_play", "play"), &EventPlayer::_set_play);
+ ObjectTypeDB::bind_method(_MD("_get_play"), &EventPlayer::_get_play);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"EventStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/pitch_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_pitch_scale"), _SCS("get_pitch_scale") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/tempo_scale", PROPERTY_HINT_RANGE,"0.001,16,0.001"), _SCS("set_tempo_scale"), _SCS("get_tempo_scale") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE, "EventStream"), _SCS("set_stream"), _SCS("get_stream"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stream/pitch_scale", PROPERTY_HINT_RANGE, "0.001,16,0.001"), _SCS("set_pitch_scale"), _SCS("get_pitch_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stream/tempo_scale", PROPERTY_HINT_RANGE, "0.001,16,0.001"), _SCS("set_tempo_scale"), _SCS("get_tempo_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused"));
}
-
EventPlayer::EventPlayer() {
- volume=1;
- loops=false;
- paused=false;
- autoplay=false;
- _play=false;
- pitch_scale=1.0;
- tempo_scale=1.0;
- for(int i=0;i<MAX_CHANNELS;i++)
- channel_volume[i]=1.0;
-
+ volume = 1;
+ loops = false;
+ paused = false;
+ autoplay = false;
+ _play = false;
+ pitch_scale = 1.0;
+ tempo_scale = 1.0;
+ for (int i = 0; i < MAX_CHANNELS; i++)
+ channel_volume[i] = 1.0;
}
EventPlayer::~EventPlayer() {
-
-
}
diff --git a/scene/audio/event_player.h b/scene/audio/event_player.h
index 2d1402fc8..57cb32564 100644
--- a/scene/audio/event_player.h
+++ b/scene/audio/event_player.h
@@ -29,16 +29,14 @@
#ifndef EVENT_PLAYER_H
#define EVENT_PLAYER_H
-
#include "scene/main/node.h"
#include "scene/resources/event_stream.h"
class EventPlayer : public Node {
- OBJ_TYPE(EventPlayer,Node);
-
+ OBJ_TYPE(EventPlayer, Node);
enum {
- MAX_CHANNELS=256
+ MAX_CHANNELS = 256
};
Ref<EventStreamPlayback> playback;
@@ -55,13 +53,13 @@ class EventPlayer : public Node {
bool _play;
void _set_play(bool p_play);
bool _get_play() const;
+
protected:
void _notification(int p_what);
static void _bind_methods();
public:
-
void set_stream(const Ref<EventStream> &p_stream);
Ref<EventStream> get_stream() const;
@@ -97,7 +95,7 @@ public:
void set_autoplay(bool p_vol);
bool has_autoplay() const;
- void set_channel_volume(int p_channel,float p_volume);
+ void set_channel_volume(int p_channel, float p_volume);
float get_channel_volume(int p_channel) const;
float get_channel_last_note_time(int p_channel) const;
diff --git a/scene/audio/sample_player.cpp b/scene/audio/sample_player.cpp
index 64992081f..dfccc5c7c 100644
--- a/scene/audio/sample_player.cpp
+++ b/scene/audio/sample_player.cpp
@@ -30,107 +30,103 @@
#include "servers/audio_server.h"
+bool SamplePlayer::_set(const StringName &p_name, const Variant &p_value) {
-bool SamplePlayer::_set(const StringName& p_name, const Variant& p_value) {
+ String name = p_name;
- String name=p_name;
-
- if (name=="play/play") {
+ if (name == "play/play") {
if (library.is_valid()) {
- String what=p_value;
- if (what=="")
+ String what = p_value;
+ if (what == "")
stop_all();
else
play(what);
- played_back=what;
+ played_back = what;
}
- } else if (name=="config/samples")
+ } else if (name == "config/samples")
set_sample_library(p_value);
- else if (name=="config/polyphony")
+ else if (name == "config/polyphony")
set_polyphony(p_value);
else if (name.begins_with("default/")) {
- String what=name.right(8);
+ String what = name.right(8);
- if (what=="volume_db")
+ if (what == "volume_db")
set_default_volume_db(p_value);
- else if (what=="pitch_scale")
+ else if (what == "pitch_scale")
set_default_pitch_scale(p_value);
- else if (what=="pan")
- _default.pan=p_value;
- else if (what=="depth")
- _default.depth=p_value;
- else if (what=="height")
- _default.height=p_value;
- else if (what=="filter/type")
- _default.filter_type=FilterType(p_value.operator int());
- else if (what=="filter/cutoff")
- _default.filter_cutoff=p_value;
- else if (what=="filter/resonance")
- _default.filter_resonance=p_value;
- else if (what=="filter/gain")
- _default.filter_gain=p_value;
- else if (what=="reverb_room")
- _default.reverb_room=ReverbRoomType(p_value.operator int());
- else if (what=="reverb_send")
- _default.reverb_send=p_value;
- else if (what=="chorus_send")
- _default.chorus_send=p_value;
+ else if (what == "pan")
+ _default.pan = p_value;
+ else if (what == "depth")
+ _default.depth = p_value;
+ else if (what == "height")
+ _default.height = p_value;
+ else if (what == "filter/type")
+ _default.filter_type = FilterType(p_value.operator int());
+ else if (what == "filter/cutoff")
+ _default.filter_cutoff = p_value;
+ else if (what == "filter/resonance")
+ _default.filter_resonance = p_value;
+ else if (what == "filter/gain")
+ _default.filter_gain = p_value;
+ else if (what == "reverb_room")
+ _default.reverb_room = ReverbRoomType(p_value.operator int());
+ else if (what == "reverb_send")
+ _default.reverb_send = p_value;
+ else if (what == "chorus_send")
+ _default.chorus_send = p_value;
else
return false;
-
} else
return false;
return true;
}
-bool SamplePlayer::_get(const StringName& p_name,Variant &r_ret) const {
-
+bool SamplePlayer::_get(const StringName &p_name, Variant &r_ret) const {
- String name=p_name;
+ String name = p_name;
- if (name=="play/play") {
- r_ret=played_back;
- } else if (name=="config/polyphony") {
- r_ret= get_polyphony();
- } else if (name=="config/samples") {
+ if (name == "play/play") {
+ r_ret = played_back;
+ } else if (name == "config/polyphony") {
+ r_ret = get_polyphony();
+ } else if (name == "config/samples") {
- r_ret= get_sample_library();
+ r_ret = get_sample_library();
} else if (name.begins_with("default/")) {
- String what=name.right(8);
-
- if (what=="volume_db")
- r_ret= get_default_volume_db();
- else if (what=="pitch_scale")
- r_ret= get_default_pitch_scale();
- else if (what=="pan")
- r_ret= _default.pan;
- else if (what=="depth")
- r_ret= _default.depth;
- else if (what=="height")
- r_ret= _default.height;
- else if (what=="filter/type")
- r_ret= _default.filter_type;
- else if (what=="filter/cutoff")
- r_ret= _default.filter_cutoff;
- else if (what=="filter/resonance")
- r_ret= _default.filter_resonance;
- else if (what=="filter/gain")
- r_ret= _default.filter_gain;
- else if (what=="reverb_room")
- r_ret= _default.reverb_room;
- else if (what=="reverb_send")
- r_ret= _default.reverb_send;
- else if (what=="chorus_send")
- r_ret= _default.chorus_send;
- else
- return false;
+ String what = name.right(8);
+ if (what == "volume_db")
+ r_ret = get_default_volume_db();
+ else if (what == "pitch_scale")
+ r_ret = get_default_pitch_scale();
+ else if (what == "pan")
+ r_ret = _default.pan;
+ else if (what == "depth")
+ r_ret = _default.depth;
+ else if (what == "height")
+ r_ret = _default.height;
+ else if (what == "filter/type")
+ r_ret = _default.filter_type;
+ else if (what == "filter/cutoff")
+ r_ret = _default.filter_cutoff;
+ else if (what == "filter/resonance")
+ r_ret = _default.filter_resonance;
+ else if (what == "filter/gain")
+ r_ret = _default.filter_gain;
+ else if (what == "reverb_room")
+ r_ret = _default.reverb_room;
+ else if (what == "reverb_send")
+ r_ret = _default.reverb_send;
+ else if (what == "chorus_send")
+ r_ret = _default.chorus_send;
+ else
+ return false;
} else
return false;
@@ -140,72 +136,66 @@ bool SamplePlayer::_get(const StringName& p_name,Variant &r_ret) const {
void SamplePlayer::_get_property_list(List<PropertyInfo> *p_list) const {
- String en="";
+ String en = "";
if (library.is_valid()) {
List<StringName> samples;
- Ref<SampleLibrary> ncl=library;
+ Ref<SampleLibrary> ncl = library;
ncl->get_sample_list(&samples);
- for (List<StringName>::Element *E=samples.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = samples.front(); E; E = E->next()) {
- en+=",";
- en+=E->get();
+ en += ",";
+ en += E->get();
}
}
- p_list->push_back( PropertyInfo( Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en,PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
- p_list->push_back( PropertyInfo( Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,256,1"));
- p_list->push_back( PropertyInfo( Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/pitch_scale", PROPERTY_HINT_RANGE, "0.01,48,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/depth", PROPERTY_HINT_RANGE, "-1,1,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/height", PROPERTY_HINT_RANGE, "-1,1,0.01"));
- p_list->push_back( PropertyInfo( Variant::INT, "default/filter/type", PROPERTY_HINT_ENUM, "Disabled,Lowpass,Bandpass,Highpass,Notch,Peak,BandLimit,LowShelf,HighShelf"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/cutoff", PROPERTY_HINT_RANGE, "20,16384.0,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/resonance", PROPERTY_HINT_RANGE, "0,4,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/filter/gain", PROPERTY_HINT_RANGE, "0,2,0.01"));
- p_list->push_back( PropertyInfo( Variant::INT, "default/reverb_room", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/reverb_send", PROPERTY_HINT_RANGE, "0,1,0.01"));
- p_list->push_back( PropertyInfo( Variant::REAL, "default/chorus_send", PROPERTY_HINT_RANGE, "0,1,0.01"));
-
-
+ p_list->push_back(PropertyInfo(Variant::STRING, "play/play", PROPERTY_HINT_ENUM, en, PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER));
+ p_list->push_back(PropertyInfo(Variant::INT, "config/polyphony", PROPERTY_HINT_RANGE, "1,256,1"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "config/samples", PROPERTY_HINT_RESOURCE_TYPE, "SampleLibrary"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/pitch_scale", PROPERTY_HINT_RANGE, "0.01,48,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/pan", PROPERTY_HINT_RANGE, "-1,1,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/depth", PROPERTY_HINT_RANGE, "-1,1,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/height", PROPERTY_HINT_RANGE, "-1,1,0.01"));
+ p_list->push_back(PropertyInfo(Variant::INT, "default/filter/type", PROPERTY_HINT_ENUM, "Disabled,Lowpass,Bandpass,Highpass,Notch,Peak,BandLimit,LowShelf,HighShelf"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/filter/cutoff", PROPERTY_HINT_RANGE, "20,16384.0,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/filter/resonance", PROPERTY_HINT_RANGE, "0,4,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/filter/gain", PROPERTY_HINT_RANGE, "0,2,0.01"));
+ p_list->push_back(PropertyInfo(Variant::INT, "default/reverb_room", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/reverb_send", PROPERTY_HINT_RANGE, "0,1,0.01"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "default/chorus_send", PROPERTY_HINT_RANGE, "0,1,0.01"));
}
-
SamplePlayer::Voice::Voice() {
- voice=AudioServer::get_singleton()->voice_create();
+ voice = AudioServer::get_singleton()->voice_create();
clear();
}
-
void SamplePlayer::Voice::clear() {
- check=0;
-
- mix_rate=44100;
- volume=1;
- pan=0;
- pan_depth=0;
- pan_height=0;
- filter_type=FILTER_NONE;
- filter_cutoff=0;
- filter_resonance=0;
- chorus_send=0;
- reverb_room=REVERB_HALL;
- reverb_send=0;
- active=false;
+ check = 0;
+ mix_rate = 44100;
+ volume = 1;
+ pan = 0;
+ pan_depth = 0;
+ pan_height = 0;
+ filter_type = FILTER_NONE;
+ filter_cutoff = 0;
+ filter_resonance = 0;
+ chorus_send = 0;
+ reverb_room = REVERB_HALL;
+ reverb_send = 0;
+ active = false;
}
SamplePlayer::Voice::~Voice() {
AudioServer::get_singleton()->free(voice);
}
-
void SamplePlayer::set_polyphony(int p_voice_count) {
- ERR_FAIL_COND( p_voice_count <1 || p_voice_count >0xFFFE );
+ ERR_FAIL_COND(p_voice_count < 1 || p_voice_count > 0xFFFE);
voices.resize(p_voice_count);
}
@@ -215,11 +205,11 @@ int SamplePlayer::get_polyphony() const {
return voices.size();
}
-SamplePlayer::VoiceID SamplePlayer::play(const String& p_name,bool unique) {
+SamplePlayer::VoiceID SamplePlayer::play(const String &p_name, bool unique) {
if (library.is_null())
return INVALID_VOICE_ID;
- ERR_FAIL_COND_V( !library->has_sample(p_name), INVALID_VOICE_ID );
+ ERR_FAIL_COND_V(!library->has_sample(p_name), INVALID_VOICE_ID);
Ref<Sample> sample = library->get_sample(p_name);
float vol_change = library->sample_get_volume_db(p_name);
@@ -228,56 +218,53 @@ SamplePlayer::VoiceID SamplePlayer::play(const String& p_name,bool unique) {
last_check++;
last_id = (last_id + 1) % voices.size();
- Voice&v = voices[last_id];
+ Voice &v = voices[last_id];
v.clear();
+ v.mix_rate = sample->get_mix_rate() * (_default.pitch_scale * pitch_change);
+ v.sample_mix_rate = sample->get_mix_rate();
+ v.check = last_check;
+ v.volume = Math::db2linear(_default.volume_db + vol_change);
+ v.pan = _default.pan;
+ v.pan_depth = _default.depth;
+ v.pan_height = _default.height;
+ v.filter_type = _default.filter_type;
+ v.filter_cutoff = _default.filter_cutoff;
+ v.filter_resonance = _default.filter_resonance;
+ v.filter_gain = _default.filter_gain;
+ v.chorus_send = _default.chorus_send;
+ v.reverb_room = _default.reverb_room;
+ v.reverb_send = _default.reverb_send;
- v.mix_rate=sample->get_mix_rate()*(_default.pitch_scale*pitch_change);
- v.sample_mix_rate=sample->get_mix_rate();
- v.check=last_check;
- v.volume=Math::db2linear(_default.volume_db+vol_change);
- v.pan=_default.pan;
- v.pan_depth=_default.depth;
- v.pan_height=_default.height;
- v.filter_type=_default.filter_type;
- v.filter_cutoff=_default.filter_cutoff;
- v.filter_resonance=_default.filter_resonance;
- v.filter_gain=_default.filter_gain;
- v.chorus_send=_default.chorus_send;
- v.reverb_room=_default.reverb_room;
- v.reverb_send=_default.reverb_send;
-
- AudioServer::get_singleton()->voice_play(v.voice,sample->get_rid());
- AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate);
- AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume);
- AudioServer::get_singleton()->voice_set_pan(v.voice,v.pan,v.pan_depth,v.pan_height);
- AudioServer::get_singleton()->voice_set_filter(v.voice,(AudioServer::FilterType)v.filter_type,v.filter_cutoff,v.filter_resonance,v.filter_gain);
- AudioServer::get_singleton()->voice_set_chorus(v.voice,v.chorus_send);
- AudioServer::get_singleton()->voice_set_reverb(v.voice,(AudioServer::ReverbRoomType)v.reverb_room,v.reverb_send);
+ AudioServer::get_singleton()->voice_play(v.voice, sample->get_rid());
+ AudioServer::get_singleton()->voice_set_mix_rate(v.voice, v.mix_rate);
+ AudioServer::get_singleton()->voice_set_volume(v.voice, v.volume);
+ AudioServer::get_singleton()->voice_set_pan(v.voice, v.pan, v.pan_depth, v.pan_height);
+ AudioServer::get_singleton()->voice_set_filter(v.voice, (AudioServer::FilterType)v.filter_type, v.filter_cutoff, v.filter_resonance, v.filter_gain);
+ AudioServer::get_singleton()->voice_set_chorus(v.voice, v.chorus_send);
+ AudioServer::get_singleton()->voice_set_reverb(v.voice, (AudioServer::ReverbRoomType)v.reverb_room, v.reverb_send);
- v.active=true;
+ v.active = true;
if (unique) {
- for(int i=0;i<voices.size();i++) {
+ for (int i = 0; i < voices.size(); i++) {
- if (!voices[i].active || uint32_t(i)==last_id)
+ if (!voices[i].active || uint32_t(i) == last_id)
continue;
AudioServer::get_singleton()->voice_stop(voices[i].voice);
voices[i].clear();
}
-
}
- return last_id | (last_check<<16);
+ return last_id | (last_check << 16);
}
void SamplePlayer::stop_all() {
-
- for(int i=0;i<voices.size();i++) {
+ for (int i = 0; i < voices.size(); i++) {
if (!voices[i].active)
continue;
@@ -285,15 +272,14 @@ void SamplePlayer::stop_all() {
AudioServer::get_singleton()->voice_stop(voices[i].voice);
voices[i].clear();
}
-
}
-#define _GET_VOICE\
- uint32_t voice=p_voice&0xFFFF;\
- ERR_FAIL_COND(voice >= (uint32_t)voices.size());\
- Voice &v=voices[voice];\
- if (v.check!=uint32_t(p_voice>>16))\
- return;\
+#define _GET_VOICE \
+ uint32_t voice = p_voice & 0xFFFF; \
+ ERR_FAIL_COND(voice >= (uint32_t)voices.size()); \
+ Voice &v = voices[voice]; \
+ if (v.check != uint32_t(p_voice >> 16)) \
+ return; \
ERR_FAIL_COND(!v.active);
void SamplePlayer::stop(VoiceID p_voice) {
@@ -301,92 +287,81 @@ void SamplePlayer::stop(VoiceID p_voice) {
_GET_VOICE
AudioServer::get_singleton()->voice_stop(v.voice);
- v.active=false;
-
+ v.active = false;
}
void SamplePlayer::set_mix_rate(VoiceID p_voice, int p_mix_rate) {
_GET_VOICE
- v.mix_rate=p_mix_rate;
- AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate);
-
+ v.mix_rate = p_mix_rate;
+ AudioServer::get_singleton()->voice_set_mix_rate(v.voice, v.mix_rate);
}
void SamplePlayer::set_pitch_scale(VoiceID p_voice, float p_pitch_scale) {
_GET_VOICE
- v.mix_rate=v.sample_mix_rate*p_pitch_scale;
- AudioServer::get_singleton()->voice_set_mix_rate(v.voice,v.mix_rate);
-
+ v.mix_rate = v.sample_mix_rate * p_pitch_scale;
+ AudioServer::get_singleton()->voice_set_mix_rate(v.voice, v.mix_rate);
}
void SamplePlayer::set_volume(VoiceID p_voice, float p_volume) {
-
_GET_VOICE
- v.volume=p_volume;
- AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume);
-
+ v.volume = p_volume;
+ AudioServer::get_singleton()->voice_set_volume(v.voice, v.volume);
}
void SamplePlayer::set_volume_db(VoiceID p_voice, float p_db) {
//@TODO handle 0 volume as -80db or something
_GET_VOICE
- v.volume=Math::db2linear(p_db);
- AudioServer::get_singleton()->voice_set_volume(v.voice,v.volume);
-
+ v.volume = Math::db2linear(p_db);
+ AudioServer::get_singleton()->voice_set_volume(v.voice, v.volume);
}
-void SamplePlayer::set_pan(VoiceID p_voice, float p_pan,float p_pan_depth,float p_pan_height) {
+void SamplePlayer::set_pan(VoiceID p_voice, float p_pan, float p_pan_depth, float p_pan_height) {
_GET_VOICE
- v.pan=p_pan;
- v.pan_depth=p_pan_depth;
- v.pan_height=p_pan_height;
-
- AudioServer::get_singleton()->voice_set_pan(v.voice,v.pan,v.pan_depth,v.pan_height);
+ v.pan = p_pan;
+ v.pan_depth = p_pan_depth;
+ v.pan_height = p_pan_height;
+ AudioServer::get_singleton()->voice_set_pan(v.voice, v.pan, v.pan_depth, v.pan_height);
}
-void SamplePlayer::set_filter(VoiceID p_voice,FilterType p_filter,float p_cutoff,float p_resonance,float p_gain) {
+void SamplePlayer::set_filter(VoiceID p_voice, FilterType p_filter, float p_cutoff, float p_resonance, float p_gain) {
_GET_VOICE
- v.filter_type=p_filter;
- v.filter_cutoff=p_cutoff;
- v.filter_resonance=p_resonance;
- v.filter_gain=p_gain;
-
- AudioServer::get_singleton()->voice_set_filter(v.voice,(AudioServer::FilterType)p_filter,p_cutoff,p_resonance);
+ v.filter_type = p_filter;
+ v.filter_cutoff = p_cutoff;
+ v.filter_resonance = p_resonance;
+ v.filter_gain = p_gain;
+ AudioServer::get_singleton()->voice_set_filter(v.voice, (AudioServer::FilterType)p_filter, p_cutoff, p_resonance);
}
-void SamplePlayer::set_chorus(VoiceID p_voice,float p_send) {
+void SamplePlayer::set_chorus(VoiceID p_voice, float p_send) {
_GET_VOICE
- v.chorus_send=p_send;
-
- AudioServer::get_singleton()->voice_set_chorus(v.voice,p_send);
+ v.chorus_send = p_send;
+ AudioServer::get_singleton()->voice_set_chorus(v.voice, p_send);
}
-void SamplePlayer::set_reverb(VoiceID p_voice,ReverbRoomType p_room,float p_send) {
+void SamplePlayer::set_reverb(VoiceID p_voice, ReverbRoomType p_room, float p_send) {
_GET_VOICE
- v.reverb_room=p_room;
- v.reverb_send=p_send;
-
- AudioServer::get_singleton()->voice_set_reverb(v.voice,(AudioServer::ReverbRoomType)p_room,p_send);
+ v.reverb_room = p_room;
+ v.reverb_send = p_send;
+ AudioServer::get_singleton()->voice_set_reverb(v.voice, (AudioServer::ReverbRoomType)p_room, p_send);
}
-#define _GET_VOICE_V(m_ret)\
- uint32_t voice=p_voice&0xFFFF;\
- ERR_FAIL_COND_V(voice >= (uint32_t)voices.size(),m_ret);\
- const Voice &v=voices[voice];\
- if (v.check!=(p_voice>>16))\
- return m_ret;\
- ERR_FAIL_COND_V(!v.active,m_ret);
-
+#define _GET_VOICE_V(m_ret) \
+ uint32_t voice = p_voice & 0xFFFF; \
+ ERR_FAIL_COND_V(voice >= (uint32_t)voices.size(), m_ret); \
+ const Voice &v = voices[voice]; \
+ if (v.check != (p_voice >> 16)) \
+ return m_ret; \
+ ERR_FAIL_COND_V(!v.active, m_ret);
int SamplePlayer::get_mix_rate(VoiceID p_voice) const {
@@ -397,7 +372,7 @@ int SamplePlayer::get_mix_rate(VoiceID p_voice) const {
float SamplePlayer::get_pitch_scale(VoiceID p_voice) const {
_GET_VOICE_V(0);
- return v.sample_mix_rate/(float)v.mix_rate;
+ return v.sample_mix_rate / (float)v.mix_rate;
}
float SamplePlayer::get_volume(VoiceID p_voice) const {
@@ -405,7 +380,6 @@ float SamplePlayer::get_volume(VoiceID p_voice) const {
return v.volume;
}
-
float SamplePlayer::get_volume_db(VoiceID p_voice) const {
_GET_VOICE_V(0);
@@ -419,7 +393,6 @@ float SamplePlayer::get_pan(VoiceID p_voice) const {
}
float SamplePlayer::get_pan_depth(VoiceID p_voice) const {
-
_GET_VOICE_V(0);
return v.pan_depth;
}
@@ -478,26 +451,21 @@ bool SamplePlayer::is_voice_active(VoiceID p_voice) const {
_GET_VOICE_V(false);
return v.active && AudioServer::get_singleton()->voice_is_active(v.voice);
-
}
bool SamplePlayer::is_active() const {
- for(int i=0;i<voices.size();i++) {
+ for (int i = 0; i < voices.size(); i++) {
if (voices[i].active && AudioServer::get_singleton()->voice_is_active(voices[i].voice))
return true;
-
-
}
return false;
}
+void SamplePlayer::set_sample_library(const Ref<SampleLibrary> &p_library) {
-
-void SamplePlayer::set_sample_library(const Ref<SampleLibrary>& p_library) {
-
- library=p_library;
+ library = p_library;
_change_notify();
}
@@ -506,43 +474,39 @@ Ref<SampleLibrary> SamplePlayer::get_sample_library() const {
return library;
}
-
-
void SamplePlayer::set_default_pitch_scale(float p_pitch_scale) {
- _default.pitch_scale=p_pitch_scale;
+ _default.pitch_scale = p_pitch_scale;
}
void SamplePlayer::set_default_volume(float p_volume) {
- _default.volume_db=Math::linear2db(p_volume);
+ _default.volume_db = Math::linear2db(p_volume);
}
void SamplePlayer::set_default_volume_db(float p_db) {
- _default.volume_db=p_db;
+ _default.volume_db = p_db;
}
-void SamplePlayer::set_default_pan(float p_pan,float p_pan_depth,float p_pan_height) {
-
- _default.pan=p_pan;
- _default.depth=p_pan_depth;
- _default.height=p_pan_height;
+void SamplePlayer::set_default_pan(float p_pan, float p_pan_depth, float p_pan_height) {
+ _default.pan = p_pan;
+ _default.depth = p_pan_depth;
+ _default.height = p_pan_height;
}
-void SamplePlayer::set_default_filter(FilterType p_filter,float p_cutoff,float p_resonance,float p_gain) {
+void SamplePlayer::set_default_filter(FilterType p_filter, float p_cutoff, float p_resonance, float p_gain) {
- _default.filter_type=p_filter;
- _default.filter_cutoff=p_cutoff;
- _default.filter_resonance=p_resonance;
- _default.filter_gain=p_gain;
+ _default.filter_type = p_filter;
+ _default.filter_cutoff = p_cutoff;
+ _default.filter_resonance = p_resonance;
+ _default.filter_gain = p_gain;
}
void SamplePlayer::set_default_chorus(float p_send) {
- _default.chorus_send=p_send;
-
+ _default.chorus_send = p_send;
}
-void SamplePlayer::set_default_reverb(ReverbRoomType p_room,float p_send) {
+void SamplePlayer::set_default_reverb(ReverbRoomType p_room, float p_send) {
- _default.reverb_room=p_room;
- _default.reverb_send=p_send;
+ _default.reverb_room = p_room;
+ _default.reverb_send = p_send;
}
float SamplePlayer::get_default_volume() const {
@@ -558,7 +522,6 @@ float SamplePlayer::get_default_pitch_scale() const {
return _default.pitch_scale;
}
-
float SamplePlayer::get_default_pan() const {
return _default.pan;
@@ -611,108 +574,102 @@ String SamplePlayer::get_configuration_warning() const {
void SamplePlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_sample_library","library:SampleLibrary"),&SamplePlayer::set_sample_library );
- ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"),&SamplePlayer::get_sample_library );
-
- ObjectTypeDB::bind_method(_MD("set_polyphony","max_voices"),&SamplePlayer::set_polyphony );
- ObjectTypeDB::bind_method(_MD("get_polyphony"),&SamplePlayer::get_polyphony );
+ ObjectTypeDB::bind_method(_MD("set_sample_library", "library:SampleLibrary"), &SamplePlayer::set_sample_library);
+ ObjectTypeDB::bind_method(_MD("get_sample_library:SampleLibrary"), &SamplePlayer::get_sample_library);
- ObjectTypeDB::bind_method(_MD("play","name","unique"),&SamplePlayer::play, DEFVAL(false) );
- ObjectTypeDB::bind_method(_MD("stop","voice"),&SamplePlayer::stop );
- ObjectTypeDB::bind_method(_MD("stop_all"),&SamplePlayer::stop_all );
+ ObjectTypeDB::bind_method(_MD("set_polyphony", "max_voices"), &SamplePlayer::set_polyphony);
+ ObjectTypeDB::bind_method(_MD("get_polyphony"), &SamplePlayer::get_polyphony);
- ObjectTypeDB::bind_method(_MD("set_mix_rate","voice","hz"),&SamplePlayer::set_mix_rate );
- ObjectTypeDB::bind_method(_MD("set_pitch_scale","voice","ratio"),&SamplePlayer::set_pitch_scale );
- ObjectTypeDB::bind_method(_MD("set_volume","voice","volume"),&SamplePlayer::set_volume );
- ObjectTypeDB::bind_method(_MD("set_volume_db","voice","db"),&SamplePlayer::set_volume_db );
- ObjectTypeDB::bind_method(_MD("set_pan","voice","pan","depth","height"),&SamplePlayer::set_pan,DEFVAL(0),DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("set_filter","voice","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_filter,DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("set_chorus","voice","send"),&SamplePlayer::set_chorus );
- ObjectTypeDB::bind_method(_MD("set_reverb","voice","room_type","send"),&SamplePlayer::set_reverb );
+ ObjectTypeDB::bind_method(_MD("play", "name", "unique"), &SamplePlayer::play, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("stop", "voice"), &SamplePlayer::stop);
+ ObjectTypeDB::bind_method(_MD("stop_all"), &SamplePlayer::stop_all);
- ObjectTypeDB::bind_method(_MD("get_mix_rate","voice"),&SamplePlayer::get_mix_rate );
- ObjectTypeDB::bind_method(_MD("get_pitch_scale","voice"),&SamplePlayer::get_pitch_scale );
- ObjectTypeDB::bind_method(_MD("get_volume","voice"),&SamplePlayer::get_volume );
- ObjectTypeDB::bind_method(_MD("get_volume_db","voice"),&SamplePlayer::get_volume_db );
- ObjectTypeDB::bind_method(_MD("get_pan","voice"),&SamplePlayer::get_pan );
- ObjectTypeDB::bind_method(_MD("get_pan_depth","voice"),&SamplePlayer::get_pan_depth );
- ObjectTypeDB::bind_method(_MD("get_pan_height","voice"),&SamplePlayer::get_pan_height );
- ObjectTypeDB::bind_method(_MD("get_filter_type","voice"),&SamplePlayer::get_filter_type );
- ObjectTypeDB::bind_method(_MD("get_filter_cutoff","voice"),&SamplePlayer::get_filter_cutoff );
- ObjectTypeDB::bind_method(_MD("get_filter_resonance","voice"),&SamplePlayer::get_filter_resonance );
- ObjectTypeDB::bind_method(_MD("get_filter_gain","voice"),&SamplePlayer::get_filter_gain );
- ObjectTypeDB::bind_method(_MD("get_chorus","voice"),&SamplePlayer::get_chorus );
- ObjectTypeDB::bind_method(_MD("get_reverb_room","voice"),&SamplePlayer::get_reverb_room );
- ObjectTypeDB::bind_method(_MD("get_reverb","voice"),&SamplePlayer::get_reverb );
+ ObjectTypeDB::bind_method(_MD("set_mix_rate", "voice", "hz"), &SamplePlayer::set_mix_rate);
+ ObjectTypeDB::bind_method(_MD("set_pitch_scale", "voice", "ratio"), &SamplePlayer::set_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("set_volume", "voice", "volume"), &SamplePlayer::set_volume);
+ ObjectTypeDB::bind_method(_MD("set_volume_db", "voice", "db"), &SamplePlayer::set_volume_db);
+ ObjectTypeDB::bind_method(_MD("set_pan", "voice", "pan", "depth", "height"), &SamplePlayer::set_pan, DEFVAL(0), DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("set_filter", "voice", "type", "cutoff_hz", "resonance", "gain"), &SamplePlayer::set_filter, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("set_chorus", "voice", "send"), &SamplePlayer::set_chorus);
+ ObjectTypeDB::bind_method(_MD("set_reverb", "voice", "room_type", "send"), &SamplePlayer::set_reverb);
- ObjectTypeDB::bind_method(_MD("set_default_pitch_scale","ratio"),&SamplePlayer::set_default_pitch_scale );
- ObjectTypeDB::bind_method(_MD("set_default_volume","volume"),&SamplePlayer::set_default_volume );
- ObjectTypeDB::bind_method(_MD("set_default_volume_db","db"),&SamplePlayer::set_default_volume_db );
- ObjectTypeDB::bind_method(_MD("set_default_pan","pan","depth","height"),&SamplePlayer::set_default_pan,DEFVAL(0),DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("set_default_filter","type","cutoff_hz","resonance","gain"),&SamplePlayer::set_default_filter,DEFVAL(0) );
- ObjectTypeDB::bind_method(_MD("set_default_chorus","send"),&SamplePlayer::set_default_chorus );
- ObjectTypeDB::bind_method(_MD("set_default_reverb","room_type","send"),&SamplePlayer::set_default_reverb );
+ ObjectTypeDB::bind_method(_MD("get_mix_rate", "voice"), &SamplePlayer::get_mix_rate);
+ ObjectTypeDB::bind_method(_MD("get_pitch_scale", "voice"), &SamplePlayer::get_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("get_volume", "voice"), &SamplePlayer::get_volume);
+ ObjectTypeDB::bind_method(_MD("get_volume_db", "voice"), &SamplePlayer::get_volume_db);
+ ObjectTypeDB::bind_method(_MD("get_pan", "voice"), &SamplePlayer::get_pan);
+ ObjectTypeDB::bind_method(_MD("get_pan_depth", "voice"), &SamplePlayer::get_pan_depth);
+ ObjectTypeDB::bind_method(_MD("get_pan_height", "voice"), &SamplePlayer::get_pan_height);
+ ObjectTypeDB::bind_method(_MD("get_filter_type", "voice"), &SamplePlayer::get_filter_type);
+ ObjectTypeDB::bind_method(_MD("get_filter_cutoff", "voice"), &SamplePlayer::get_filter_cutoff);
+ ObjectTypeDB::bind_method(_MD("get_filter_resonance", "voice"), &SamplePlayer::get_filter_resonance);
+ ObjectTypeDB::bind_method(_MD("get_filter_gain", "voice"), &SamplePlayer::get_filter_gain);
+ ObjectTypeDB::bind_method(_MD("get_chorus", "voice"), &SamplePlayer::get_chorus);
+ ObjectTypeDB::bind_method(_MD("get_reverb_room", "voice"), &SamplePlayer::get_reverb_room);
+ ObjectTypeDB::bind_method(_MD("get_reverb", "voice"), &SamplePlayer::get_reverb);
- ObjectTypeDB::bind_method(_MD("get_default_pitch_scale"),&SamplePlayer::get_default_pitch_scale );
- ObjectTypeDB::bind_method(_MD("get_default_volume"),&SamplePlayer::get_default_volume );
- ObjectTypeDB::bind_method(_MD("get_default_volume_db"),&SamplePlayer::get_default_volume_db );
- ObjectTypeDB::bind_method(_MD("get_default_pan"),&SamplePlayer::get_default_pan );
- ObjectTypeDB::bind_method(_MD("get_default_pan_depth"),&SamplePlayer::get_default_pan_depth );
- ObjectTypeDB::bind_method(_MD("get_default_pan_height"),&SamplePlayer::get_default_pan_height );
- ObjectTypeDB::bind_method(_MD("get_default_filter_type"),&SamplePlayer::get_default_filter_type );
- ObjectTypeDB::bind_method(_MD("get_default_filter_cutoff"),&SamplePlayer::get_default_filter_cutoff );
- ObjectTypeDB::bind_method(_MD("get_default_filter_resonance"),&SamplePlayer::get_default_filter_resonance );
- ObjectTypeDB::bind_method(_MD("get_default_filter_gain"),&SamplePlayer::get_default_filter_gain );
- ObjectTypeDB::bind_method(_MD("get_default_chorus"),&SamplePlayer::get_default_chorus );
- ObjectTypeDB::bind_method(_MD("get_default_reverb_room"),&SamplePlayer::get_default_reverb_room );
- ObjectTypeDB::bind_method(_MD("get_default_reverb"),&SamplePlayer::get_default_reverb );
+ ObjectTypeDB::bind_method(_MD("set_default_pitch_scale", "ratio"), &SamplePlayer::set_default_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("set_default_volume", "volume"), &SamplePlayer::set_default_volume);
+ ObjectTypeDB::bind_method(_MD("set_default_volume_db", "db"), &SamplePlayer::set_default_volume_db);
+ ObjectTypeDB::bind_method(_MD("set_default_pan", "pan", "depth", "height"), &SamplePlayer::set_default_pan, DEFVAL(0), DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("set_default_filter", "type", "cutoff_hz", "resonance", "gain"), &SamplePlayer::set_default_filter, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("set_default_chorus", "send"), &SamplePlayer::set_default_chorus);
+ ObjectTypeDB::bind_method(_MD("set_default_reverb", "room_type", "send"), &SamplePlayer::set_default_reverb);
- ObjectTypeDB::bind_method(_MD("is_active"),&SamplePlayer::is_active );
- ObjectTypeDB::bind_method(_MD("is_voice_active","voice"),&SamplePlayer::is_voice_active );
+ ObjectTypeDB::bind_method(_MD("get_default_pitch_scale"), &SamplePlayer::get_default_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("get_default_volume"), &SamplePlayer::get_default_volume);
+ ObjectTypeDB::bind_method(_MD("get_default_volume_db"), &SamplePlayer::get_default_volume_db);
+ ObjectTypeDB::bind_method(_MD("get_default_pan"), &SamplePlayer::get_default_pan);
+ ObjectTypeDB::bind_method(_MD("get_default_pan_depth"), &SamplePlayer::get_default_pan_depth);
+ ObjectTypeDB::bind_method(_MD("get_default_pan_height"), &SamplePlayer::get_default_pan_height);
+ ObjectTypeDB::bind_method(_MD("get_default_filter_type"), &SamplePlayer::get_default_filter_type);
+ ObjectTypeDB::bind_method(_MD("get_default_filter_cutoff"), &SamplePlayer::get_default_filter_cutoff);
+ ObjectTypeDB::bind_method(_MD("get_default_filter_resonance"), &SamplePlayer::get_default_filter_resonance);
+ ObjectTypeDB::bind_method(_MD("get_default_filter_gain"), &SamplePlayer::get_default_filter_gain);
+ ObjectTypeDB::bind_method(_MD("get_default_chorus"), &SamplePlayer::get_default_chorus);
+ ObjectTypeDB::bind_method(_MD("get_default_reverb_room"), &SamplePlayer::get_default_reverb_room);
+ ObjectTypeDB::bind_method(_MD("get_default_reverb"), &SamplePlayer::get_default_reverb);
- BIND_CONSTANT( FILTER_NONE);
- BIND_CONSTANT( FILTER_LOWPASS);
- BIND_CONSTANT( FILTER_BANDPASS);
- BIND_CONSTANT( FILTER_HIPASS);
- BIND_CONSTANT( FILTER_NOTCH);
- BIND_CONSTANT( FILTER_PEAK);
- BIND_CONSTANT( FILTER_BANDLIMIT); ///< cutoff is LP resonace is HP
- BIND_CONSTANT( FILTER_LOW_SHELF);
- BIND_CONSTANT( FILTER_HIGH_SHELF);
+ ObjectTypeDB::bind_method(_MD("is_active"), &SamplePlayer::is_active);
+ ObjectTypeDB::bind_method(_MD("is_voice_active", "voice"), &SamplePlayer::is_voice_active);
- BIND_CONSTANT( REVERB_SMALL );
- BIND_CONSTANT( REVERB_MEDIUM );
- BIND_CONSTANT( REVERB_LARGE );
- BIND_CONSTANT( REVERB_HALL );
+ BIND_CONSTANT(FILTER_NONE);
+ BIND_CONSTANT(FILTER_LOWPASS);
+ BIND_CONSTANT(FILTER_BANDPASS);
+ BIND_CONSTANT(FILTER_HIPASS);
+ BIND_CONSTANT(FILTER_NOTCH);
+ BIND_CONSTANT(FILTER_PEAK);
+ BIND_CONSTANT(FILTER_BANDLIMIT); ///< cutoff is LP resonace is HP
+ BIND_CONSTANT(FILTER_LOW_SHELF);
+ BIND_CONSTANT(FILTER_HIGH_SHELF);
- BIND_CONSTANT( INVALID_VOICE_ID );
+ BIND_CONSTANT(REVERB_SMALL);
+ BIND_CONSTANT(REVERB_MEDIUM);
+ BIND_CONSTANT(REVERB_LARGE);
+ BIND_CONSTANT(REVERB_HALL);
+ BIND_CONSTANT(INVALID_VOICE_ID);
}
-
SamplePlayer::SamplePlayer() {
voices.resize(1);
- _default.pitch_scale=1;
- _default.volume_db=0;
- _default.pan=0;
- _default.depth=0;
- _default.height=0;
- _default.filter_type=FILTER_NONE;
- _default.filter_cutoff=5000;
- _default.filter_resonance=1;
- _default.filter_gain=1;
- _default.chorus_send=0;
- _default.reverb_room=REVERB_LARGE;
- _default.reverb_send=0;
- last_id=0;
- last_check=0;
-
-
+ _default.pitch_scale = 1;
+ _default.volume_db = 0;
+ _default.pan = 0;
+ _default.depth = 0;
+ _default.height = 0;
+ _default.filter_type = FILTER_NONE;
+ _default.filter_cutoff = 5000;
+ _default.filter_resonance = 1;
+ _default.filter_gain = 1;
+ _default.chorus_send = 0;
+ _default.reverb_room = REVERB_LARGE;
+ _default.reverb_send = 0;
+ last_id = 0;
+ last_check = 0;
}
SamplePlayer::~SamplePlayer() {
-
-
}
diff --git a/scene/audio/sample_player.h b/scene/audio/sample_player.h
index 19c373e8b..0f026a085 100644
--- a/scene/audio/sample_player.h
+++ b/scene/audio/sample_player.h
@@ -34,11 +34,10 @@
class SamplePlayer : public Node {
- OBJ_TYPE( SamplePlayer, Node );
+ OBJ_TYPE(SamplePlayer, Node);
OBJ_CATEGORY("Audio Nodes");
-public:
-
+public:
enum FilterType {
FILTER_NONE,
FILTER_LOWPASS,
@@ -61,13 +60,12 @@ public:
enum {
- INVALID_VOICE_ID=0xFFFFFFFF
+ INVALID_VOICE_ID = 0xFFFFFFFF
};
typedef uint32_t VoiceID;
private:
-
Ref<SampleLibrary> library;
struct Voice {
@@ -117,23 +115,22 @@ private:
uint32_t last_id;
uint16_t last_check;
String played_back;
-protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
- void set_sample_library(const Ref<SampleLibrary>& p_library);
+ void set_sample_library(const Ref<SampleLibrary> &p_library);
Ref<SampleLibrary> get_sample_library() const;
void set_polyphony(int p_voice_count);
int get_polyphony() const;
- VoiceID play(const String& p_name,bool unique=false);
+ VoiceID play(const String &p_name, bool unique = false);
void stop(VoiceID p_voice);
void stop_all();
bool is_voice_active(VoiceID) const;
@@ -143,10 +140,10 @@ public:
void set_pitch_scale(VoiceID p_voice, float p_pitch_scale);
void set_volume(VoiceID p_voice, float p_volume);
void set_volume_db(VoiceID p_voice, float p_db);
- void set_pan(VoiceID p_voice, float p_pan,float p_pan_depth=0,float p_pan_height=0);
- void set_filter(VoiceID p_voice,FilterType p_filter,float p_cutoff,float p_resonance,float p_gain);
- void set_chorus(VoiceID p_voice,float p_send);
- void set_reverb(VoiceID p_voice,ReverbRoomType p_room,float p_send);
+ void set_pan(VoiceID p_voice, float p_pan, float p_pan_depth = 0, float p_pan_height = 0);
+ void set_filter(VoiceID p_voice, FilterType p_filter, float p_cutoff, float p_resonance, float p_gain);
+ void set_chorus(VoiceID p_voice, float p_send);
+ void set_reverb(VoiceID p_voice, ReverbRoomType p_room, float p_send);
int get_mix_rate(VoiceID p_voice) const;
float get_pitch_scale(VoiceID p_voice) const;
@@ -164,15 +161,13 @@ public:
ReverbRoomType get_reverb_room(VoiceID p_voice) const;
float get_reverb(VoiceID p_voice) const;
-
-
void set_default_pitch_scale(float p_pitch_scale);
void set_default_volume(float p_volume);
void set_default_volume_db(float p_db);
- void set_default_pan(float p_pan,float p_pan_depth=0,float p_pan_height=0);
- void set_default_filter(FilterType p_filter,float p_cutoff,float p_resonance,float p_gain);
+ void set_default_pan(float p_pan, float p_pan_depth = 0, float p_pan_height = 0);
+ void set_default_filter(FilterType p_filter, float p_cutoff, float p_resonance, float p_gain);
void set_default_chorus(float p_send);
- void set_default_reverb(ReverbRoomType p_room,float p_send);
+ void set_default_reverb(ReverbRoomType p_room, float p_send);
float get_default_volume() const;
float get_default_volume_db() const;
@@ -194,7 +189,7 @@ public:
~SamplePlayer();
};
-VARIANT_ENUM_CAST( SamplePlayer::FilterType );
-VARIANT_ENUM_CAST( SamplePlayer::ReverbRoomType );
+VARIANT_ENUM_CAST(SamplePlayer::FilterType);
+VARIANT_ENUM_CAST(SamplePlayer::ReverbRoomType);
#endif // SAMPLE_PLAYER_H
diff --git a/scene/audio/sound_room_params.cpp b/scene/audio/sound_room_params.cpp
index 5b410bf03..972467613 100644
--- a/scene/audio/sound_room_params.cpp
+++ b/scene/audio/sound_room_params.cpp
@@ -36,30 +36,26 @@ void SoundRoomParams::_update_sound_room() {
if (!room.is_valid())
return;
- for(int i=0;i<PARAM_MAX;i++) {
-
- SpatialSoundServer::get_singleton()->room_set_param(room,SpatialSoundServer::RoomParam(i),params[i]);
+ for (int i = 0; i < PARAM_MAX; i++) {
+ SpatialSoundServer::get_singleton()->room_set_param(room, SpatialSoundServer::RoomParam(i), params[i]);
}
- SpatialSoundServer::get_singleton()->room_set_reverb(room,SpatialSoundServer::RoomReverb(reverb));
- SpatialSoundServer::get_singleton()->room_set_force_params_to_all_sources(room,force_params_for_all_sources);
+ SpatialSoundServer::get_singleton()->room_set_reverb(room, SpatialSoundServer::RoomReverb(reverb));
+ SpatialSoundServer::get_singleton()->room_set_force_params_to_all_sources(room, force_params_for_all_sources);
}
-
void SoundRoomParams::_notification(int p_what) {
-
- switch(p_what) {
-
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
-//#if 0
- Node *n=this;
- Room *room_instance=NULL;
- while(n) {
+ //#if 0
+ Node *n = this;
+ Room *room_instance = NULL;
+ while (n) {
- room_instance=n->cast_to<Room>();
+ room_instance = n->cast_to<Room>();
if (room_instance) {
break;
@@ -67,50 +63,47 @@ void SoundRoomParams::_notification(int p_what) {
if (n->cast_to<Viewport>())
break;
- n=n->get_parent();
+ n = n->get_parent();
}
-
if (room_instance) {
- room=room_instance->get_sound_room();
+ room = room_instance->get_sound_room();
} else {
- room=get_viewport()->find_world()->get_sound_space();
+ room = get_viewport()->find_world()->get_sound_space();
}
_update_sound_room();
-//#endif
+ //#endif
} break;
case NOTIFICATION_EXIT_TREE: {
- room=RID();
+ room = RID();
} break;
}
}
-
void SoundRoomParams::set_param(Params p_param, float p_value) {
- ERR_FAIL_INDEX(p_param,PARAM_MAX);
- params[p_param]=p_value;
+ ERR_FAIL_INDEX(p_param, PARAM_MAX);
+ params[p_param] = p_value;
if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_param(room,SpatialSoundServer::RoomParam(p_param),p_value);
+ SpatialSoundServer::get_singleton()->room_set_param(room, SpatialSoundServer::RoomParam(p_param), p_value);
}
float SoundRoomParams::get_param(Params p_param) const {
- ERR_FAIL_INDEX_V(p_param,PARAM_MAX,0);
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
return params[p_param];
}
-
void SoundRoomParams::set_reverb_mode(Reverb p_mode) {
- ERR_FAIL_INDEX(p_mode,4);
- reverb=p_mode;
+ ERR_FAIL_INDEX(p_mode, 4);
+ reverb = p_mode;
if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_reverb(room,SpatialSoundServer::RoomReverb(p_mode));
+ SpatialSoundServer::get_singleton()->room_set_reverb(room, SpatialSoundServer::RoomReverb(p_mode));
}
SoundRoomParams::Reverb SoundRoomParams::get_reverb_mode() const {
@@ -118,12 +111,11 @@ SoundRoomParams::Reverb SoundRoomParams::get_reverb_mode() const {
return reverb;
}
-
void SoundRoomParams::set_force_params_to_all_sources(bool p_force) {
- force_params_for_all_sources=p_force;
+ force_params_for_all_sources = p_force;
if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_force_params_to_all_sources(room,p_force);
+ SpatialSoundServer::get_singleton()->room_set_force_params_to_all_sources(room, p_force);
}
bool SoundRoomParams::is_forcing_params_to_all_sources() {
@@ -131,50 +123,46 @@ bool SoundRoomParams::is_forcing_params_to_all_sources() {
return force_params_for_all_sources;
}
-
void SoundRoomParams::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_param","param","value"),&SoundRoomParams::set_param );
- ObjectTypeDB::bind_method(_MD("get_param","param"),&SoundRoomParams::get_param );
+ ObjectTypeDB::bind_method(_MD("set_param", "param", "value"), &SoundRoomParams::set_param);
+ ObjectTypeDB::bind_method(_MD("get_param", "param"), &SoundRoomParams::get_param);
- ObjectTypeDB::bind_method(_MD("set_reverb_mode","reverb_mode","value"),&SoundRoomParams::set_reverb_mode );
- ObjectTypeDB::bind_method(_MD("get_reverb_mode","reverb_mode"),&SoundRoomParams::get_reverb_mode );
+ ObjectTypeDB::bind_method(_MD("set_reverb_mode", "reverb_mode", "value"), &SoundRoomParams::set_reverb_mode);
+ ObjectTypeDB::bind_method(_MD("get_reverb_mode", "reverb_mode"), &SoundRoomParams::get_reverb_mode);
- ObjectTypeDB::bind_method(_MD("set_force_params_to_all_sources","enabled"),&SoundRoomParams::set_force_params_to_all_sources );
- ObjectTypeDB::bind_method(_MD("is_forcing_params_to_all_sources"),&SoundRoomParams::is_forcing_params_to_all_sources );
-
-
- ADD_PROPERTY( PropertyInfo( Variant::INT, "reverb/mode", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall"), _SCS("set_reverb_mode"), _SCS("get_reverb_mode") );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/speed_of_scale", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SPEED_OF_SOUND_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/doppler_factor",PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_DOPPLER_FACTOR );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/pitch_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_PITCH_SCALE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/volume_scale_db",PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_VOLUME_SCALE_DB );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/reverb_send",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_REVERB_SEND );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/chorus_send",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_CHORUS_SEND );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_SCALE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_cutoff",PROPERTY_HINT_RANGE, "30,16384,1"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_CUTOFF );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_floor_db",PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_FLOOR_DB );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_hf_ratio_exp",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_RATIO_EXP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation_reverb_scale",PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_REVERB_SCALE );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "force_to_all_sources"),_SCS("set_force_params_to_all_sources"),_SCS("is_forcing_params_to_all_sources") );
+ ObjectTypeDB::bind_method(_MD("set_force_params_to_all_sources", "enabled"), &SoundRoomParams::set_force_params_to_all_sources);
+ ObjectTypeDB::bind_method(_MD("is_forcing_params_to_all_sources"), &SoundRoomParams::is_forcing_params_to_all_sources);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "reverb/mode", PROPERTY_HINT_ENUM, "Small,Medium,Large,Hall"), _SCS("set_reverb_mode"), _SCS("get_reverb_mode"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/speed_of_scale", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_SPEED_OF_SOUND_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/doppler_factor", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_DOPPLER_FACTOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/pitch_scale", PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_PITCH_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/volume_scale_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_VOLUME_SCALE_DB);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/reverb_send", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_REVERB_SEND);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/chorus_send", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_CHORUS_SEND);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation_scale", PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation_hf_cutoff", PROPERTY_HINT_RANGE, "30,16384,1"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_CUTOFF);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation_hf_floor_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_FLOOR_DB);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation_hf_ratio_exp", PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_HF_RATIO_EXP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/attenuation_reverb_scale", PROPERTY_HINT_RANGE, "0.01,32,0.01"), _SCS("set_param"), _SCS("get_param"), PARAM_ATTENUATION_REVERB_SCALE);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "force_to_all_sources"), _SCS("set_force_params_to_all_sources"), _SCS("is_forcing_params_to_all_sources"));
}
-
SoundRoomParams::SoundRoomParams() {
- reverb=REVERB_HALL;
- params[PARAM_SPEED_OF_SOUND_SCALE]=1;
- params[PARAM_DOPPLER_FACTOR]=1.0;
- params[PARAM_PITCH_SCALE]=1.0;
- params[PARAM_VOLUME_SCALE_DB]=0;
- params[PARAM_REVERB_SEND]=0;
- params[PARAM_CHORUS_SEND]=0;
- params[PARAM_ATTENUATION_SCALE]=1.0;
- params[PARAM_ATTENUATION_HF_CUTOFF]=5000;
- params[PARAM_ATTENUATION_HF_FLOOR_DB]=-24.0;
- params[PARAM_ATTENUATION_HF_RATIO_EXP]=1.0;
- params[PARAM_ATTENUATION_REVERB_SCALE]=0.0;
- force_params_for_all_sources=false;
+ reverb = REVERB_HALL;
+ params[PARAM_SPEED_OF_SOUND_SCALE] = 1;
+ params[PARAM_DOPPLER_FACTOR] = 1.0;
+ params[PARAM_PITCH_SCALE] = 1.0;
+ params[PARAM_VOLUME_SCALE_DB] = 0;
+ params[PARAM_REVERB_SEND] = 0;
+ params[PARAM_CHORUS_SEND] = 0;
+ params[PARAM_ATTENUATION_SCALE] = 1.0;
+ params[PARAM_ATTENUATION_HF_CUTOFF] = 5000;
+ params[PARAM_ATTENUATION_HF_FLOOR_DB] = -24.0;
+ params[PARAM_ATTENUATION_HF_RATIO_EXP] = 1.0;
+ params[PARAM_ATTENUATION_REVERB_SCALE] = 0.0;
+ force_params_for_all_sources = false;
}
#endif
diff --git a/scene/audio/sound_room_params.h b/scene/audio/sound_room_params.h
index be4e6c8c8..1f3d848de 100644
--- a/scene/audio/sound_room_params.h
+++ b/scene/audio/sound_room_params.h
@@ -32,28 +32,27 @@
#include "scene/main/node.h"
#include "servers/spatial_sound_server.h"
-
#ifndef _3D_DISABLED
#include "scene/3d/room_instance.h"
class SoundRoomParams : public Node {
- OBJ_TYPE( SoundRoomParams, Node );
-public:
+ OBJ_TYPE(SoundRoomParams, Node);
+public:
enum Params {
- PARAM_SPEED_OF_SOUND_SCALE=SpatialSoundServer::ROOM_PARAM_SPEED_OF_SOUND_SCALE,
- PARAM_DOPPLER_FACTOR=SpatialSoundServer::ROOM_PARAM_DOPPLER_FACTOR,
- PARAM_PITCH_SCALE=SpatialSoundServer::ROOM_PARAM_PITCH_SCALE,
- PARAM_VOLUME_SCALE_DB=SpatialSoundServer::ROOM_PARAM_VOLUME_SCALE_DB,
- PARAM_REVERB_SEND=SpatialSoundServer::ROOM_PARAM_REVERB_SEND,
- PARAM_CHORUS_SEND=SpatialSoundServer::ROOM_PARAM_CHORUS_SEND,
- PARAM_ATTENUATION_SCALE=SpatialSoundServer::ROOM_PARAM_ATTENUATION_SCALE,
- PARAM_ATTENUATION_HF_CUTOFF=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_CUTOFF,
- PARAM_ATTENUATION_HF_FLOOR_DB=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_FLOOR_DB,
- PARAM_ATTENUATION_HF_RATIO_EXP=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_RATIO_EXP,
- PARAM_ATTENUATION_REVERB_SCALE=SpatialSoundServer::ROOM_PARAM_ATTENUATION_REVERB_SCALE,
- PARAM_MAX=SpatialSoundServer::ROOM_PARAM_MAX
+ PARAM_SPEED_OF_SOUND_SCALE = SpatialSoundServer::ROOM_PARAM_SPEED_OF_SOUND_SCALE,
+ PARAM_DOPPLER_FACTOR = SpatialSoundServer::ROOM_PARAM_DOPPLER_FACTOR,
+ PARAM_PITCH_SCALE = SpatialSoundServer::ROOM_PARAM_PITCH_SCALE,
+ PARAM_VOLUME_SCALE_DB = SpatialSoundServer::ROOM_PARAM_VOLUME_SCALE_DB,
+ PARAM_REVERB_SEND = SpatialSoundServer::ROOM_PARAM_REVERB_SEND,
+ PARAM_CHORUS_SEND = SpatialSoundServer::ROOM_PARAM_CHORUS_SEND,
+ PARAM_ATTENUATION_SCALE = SpatialSoundServer::ROOM_PARAM_ATTENUATION_SCALE,
+ PARAM_ATTENUATION_HF_CUTOFF = SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_CUTOFF,
+ PARAM_ATTENUATION_HF_FLOOR_DB = SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_FLOOR_DB,
+ PARAM_ATTENUATION_HF_RATIO_EXP = SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_RATIO_EXP,
+ PARAM_ATTENUATION_REVERB_SCALE = SpatialSoundServer::ROOM_PARAM_ATTENUATION_REVERB_SCALE,
+ PARAM_MAX = SpatialSoundServer::ROOM_PARAM_MAX
};
enum Reverb {
@@ -62,8 +61,8 @@ public:
REVERB_LARGE,
REVERB_HALL
};
-private:
+private:
RID room;
float params[PARAM_MAX];
@@ -71,15 +70,11 @@ private:
bool force_params_for_all_sources;
void _update_sound_room();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
public:
-
-
void set_param(Params p_param, float p_value);
float get_param(Params p_param) const;
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp
index d2f1a9fd0..22203987a 100644
--- a/scene/audio/stream_player.cpp
+++ b/scene/audio/stream_player.cpp
@@ -32,34 +32,33 @@ int StreamPlayer::InternalStream::get_channel_count() const {
return player->sp_get_channel_count();
}
-void StreamPlayer::InternalStream::set_mix_rate(int p_rate){
+void StreamPlayer::InternalStream::set_mix_rate(int p_rate) {
return player->sp_set_mix_rate(p_rate);
}
-bool StreamPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){
+bool StreamPlayer::InternalStream::mix(int32_t *p_buffer, int p_frames) {
- return player->sp_mix(p_buffer,p_frames);
+ return player->sp_mix(p_buffer, p_frames);
}
-void StreamPlayer::InternalStream::update(){
+void StreamPlayer::InternalStream::update() {
player->sp_update();
}
-
int StreamPlayer::sp_get_channel_count() const {
return playback->get_channels();
}
-void StreamPlayer::sp_set_mix_rate(int p_rate){
+void StreamPlayer::sp_set_mix_rate(int p_rate) {
- server_mix_rate=p_rate;
+ server_mix_rate = p_rate;
}
-bool StreamPlayer::sp_mix(int32_t *p_buffer,int p_frames) {
+bool StreamPlayer::sp_mix(int32_t *p_buffer, int p_frames) {
if (resampler.is_ready() && !paused) {
- return resampler.mix(p_buffer,p_frames);
+ return resampler.mix(p_buffer, p_frames);
}
return false;
@@ -74,9 +73,9 @@ void StreamPlayer::sp_update() {
//stream depleted data, but there's still audio in the ringbuffer
//check that all this audio has been flushed before stopping the stream
int to_mix = resampler.get_total() - resampler.get_todo();
- if (to_mix==0) {
+ if (to_mix == 0) {
if (!stop_request) {
- stop_request=true;
+ stop_request = true;
call_deferred("_do_stop");
}
return;
@@ -85,8 +84,8 @@ void StreamPlayer::sp_update() {
return;
}
- int todo =resampler.get_todo();
- int wrote = playback->mix(resampler.get_write_buffer(),todo);
+ int todo = resampler.get_todo();
+ int wrote = playback->mix(resampler.get_write_buffer(), todo);
resampler.write(wrote);
}
}
@@ -98,15 +97,15 @@ void StreamPlayer::_do_stop() {
void StreamPlayer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
//set_idle_process(false); //don't annoy
if (stream.is_valid() && !get_tree()->is_editor_hint()) {
- if (resume_pos>=0) {
+ if (resume_pos >= 0) {
play(resume_pos);
- resume_pos=-1;
+ resume_pos = -1;
} else if (autoplay) {
play();
autoplay = false; //this line fix autoplay issues
@@ -117,27 +116,25 @@ void StreamPlayer::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
if (is_playing()) {
- resume_pos=get_pos();
+ resume_pos = get_pos();
}
stop(); //wathever it may be doing, stop
} break;
}
}
-
-
void StreamPlayer::set_stream(const Ref<AudioStream> &p_stream) {
stop();
- stream=p_stream;
+ stream = p_stream;
if (!stream.is_null()) {
- playback=stream->instance_playback();
+ playback = stream->instance_playback();
playback->set_loop(loops);
playback->set_loop_restart_time(loop_point);
AudioServer::get_singleton()->lock();
- resampler.setup(playback->get_channels(),playback->get_mix_rate(),server_mix_rate,buffering_ms,playback->get_minimum_buffer_size());
+ resampler.setup(playback->get_channels(), playback->get_mix_rate(), server_mix_rate, buffering_ms, playback->get_minimum_buffer_size());
AudioServer::get_singleton()->unlock();
} else {
AudioServer::get_singleton()->lock();
@@ -152,7 +149,6 @@ Ref<AudioStream> StreamPlayer::get_stream() const {
return stream;
}
-
void StreamPlayer::play(float p_from_offset) {
ERR_FAIL_COND(!is_inside_tree());
@@ -165,11 +161,10 @@ void StreamPlayer::play(float p_from_offset) {
playback->play(p_from_offset);
//feed the ringbuffer as long as no update callback is going on
sp_update();
- AudioServer::get_singleton()->stream_set_active(stream_rid,true);
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
-// if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
-// set_idle_process(true);
-
+ AudioServer::get_singleton()->stream_set_active(stream_rid, true);
+ AudioServer::get_singleton()->stream_set_volume_scale(stream_rid, volume);
+ // if (stream->get_update_mode()!=AudioStream::UPDATE_NONE)
+ // set_idle_process(true);
}
void StreamPlayer::stop() {
@@ -180,11 +175,10 @@ void StreamPlayer::stop() {
return;
//_THREAD_SAFE_METHOD_
- AudioServer::get_singleton()->stream_set_active(stream_rid,false);
- stop_request=false;
+ AudioServer::get_singleton()->stream_set_active(stream_rid, false);
+ stop_request = false;
playback->stop();
resampler.flush();
-
//set_idle_process(false);
}
@@ -199,11 +193,10 @@ bool StreamPlayer::is_playing() const {
void StreamPlayer::set_loop(bool p_enable) {
- loops=p_enable;
+ loops = p_enable;
if (playback.is_null())
return;
playback->set_loop(loops);
-
}
bool StreamPlayer::has_loop() const {
@@ -212,9 +205,9 @@ bool StreamPlayer::has_loop() const {
void StreamPlayer::set_volume(float p_vol) {
- volume=p_vol;
+ volume = p_vol;
if (stream_rid.is_valid())
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
+ AudioServer::get_singleton()->stream_set_volume_scale(stream_rid, volume);
}
float StreamPlayer::get_volume() const {
@@ -224,7 +217,7 @@ float StreamPlayer::get_volume() const {
void StreamPlayer::set_loop_restart_time(float p_secs) {
- loop_point=p_secs;
+ loop_point = p_secs;
if (playback.is_valid())
playback->set_loop_restart_time(p_secs);
}
@@ -234,10 +227,9 @@ float StreamPlayer::get_loop_restart_time() const {
return loop_point;
}
-
void StreamPlayer::set_volume_db(float p_db) {
- if (p_db<-79)
+ if (p_db < -79)
set_volume(0);
else
set_volume(Math::db2linear(p_db));
@@ -245,35 +237,31 @@ void StreamPlayer::set_volume_db(float p_db) {
float StreamPlayer::get_volume_db() const {
- if (volume==0)
+ if (volume == 0)
return -80;
else
return Math::linear2db(volume);
}
-
-String StreamPlayer::get_stream_name() const {
+String StreamPlayer::get_stream_name() const {
if (stream.is_null())
return "<No Stream>";
return stream->get_name();
-
}
-int StreamPlayer::get_loop_count() const {
+int StreamPlayer::get_loop_count() const {
if (playback.is_null())
return 0;
return playback->get_loop_count();
-
}
-float StreamPlayer::get_pos() const {
+float StreamPlayer::get_pos() const {
if (playback.is_null())
return 0;
return playback->get_pos();
-
}
float StreamPlayer::get_length() const {
@@ -289,12 +277,11 @@ void StreamPlayer::seek_pos(float p_time) {
//works better...
stop();
playback->play(p_time);
-
}
void StreamPlayer::set_autoplay(bool p_enable) {
- autoplay=p_enable;
+ autoplay = p_enable;
}
bool StreamPlayer::has_autoplay() const {
@@ -304,7 +291,7 @@ bool StreamPlayer::has_autoplay() const {
void StreamPlayer::set_paused(bool p_paused) {
- paused=p_paused;
+ paused = p_paused;
//if (stream.is_valid())
// stream->set_paused(p_paused);
}
@@ -316,109 +303,102 @@ bool StreamPlayer::is_paused() const {
void StreamPlayer::_set_play(bool p_play) {
- _play=p_play;
+ _play = p_play;
if (is_inside_tree()) {
- if(_play)
+ if (_play)
play();
else
stop();
}
-
}
-bool StreamPlayer::_get_play() const{
+bool StreamPlayer::_get_play() const {
return _play;
}
void StreamPlayer::set_buffering_msec(int p_msec) {
- buffering_ms=p_msec;
+ buffering_ms = p_msec;
}
-int StreamPlayer::get_buffering_msec() const{
+int StreamPlayer::get_buffering_msec() const {
return buffering_ms;
}
-
-
void StreamPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:AudioStream"),&StreamPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:AudioStream"),&StreamPlayer::get_stream);
+ ObjectTypeDB::bind_method(_MD("set_stream", "stream:AudioStream"), &StreamPlayer::set_stream);
+ ObjectTypeDB::bind_method(_MD("get_stream:AudioStream"), &StreamPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play","offset"),&StreamPlayer::play,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("stop"),&StreamPlayer::stop);
+ ObjectTypeDB::bind_method(_MD("play", "offset"), &StreamPlayer::play, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("stop"), &StreamPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&StreamPlayer::is_playing);
+ ObjectTypeDB::bind_method(_MD("is_playing"), &StreamPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&StreamPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&StreamPlayer::is_paused);
+ ObjectTypeDB::bind_method(_MD("set_paused", "paused"), &StreamPlayer::set_paused);
+ ObjectTypeDB::bind_method(_MD("is_paused"), &StreamPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&StreamPlayer::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&StreamPlayer::has_loop);
+ ObjectTypeDB::bind_method(_MD("set_loop", "enabled"), &StreamPlayer::set_loop);
+ ObjectTypeDB::bind_method(_MD("has_loop"), &StreamPlayer::has_loop);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&StreamPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&StreamPlayer::get_volume);
+ ObjectTypeDB::bind_method(_MD("set_volume", "volume"), &StreamPlayer::set_volume);
+ ObjectTypeDB::bind_method(_MD("get_volume"), &StreamPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&StreamPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&StreamPlayer::get_volume_db);
+ ObjectTypeDB::bind_method(_MD("set_volume_db", "db"), &StreamPlayer::set_volume_db);
+ ObjectTypeDB::bind_method(_MD("get_volume_db"), &StreamPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&StreamPlayer::set_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&StreamPlayer::get_buffering_msec);
+ ObjectTypeDB::bind_method(_MD("set_buffering_msec", "msec"), &StreamPlayer::set_buffering_msec);
+ ObjectTypeDB::bind_method(_MD("get_buffering_msec"), &StreamPlayer::get_buffering_msec);
- ObjectTypeDB::bind_method(_MD("set_loop_restart_time","secs"),&StreamPlayer::set_loop_restart_time);
- ObjectTypeDB::bind_method(_MD("get_loop_restart_time"),&StreamPlayer::get_loop_restart_time);
+ ObjectTypeDB::bind_method(_MD("set_loop_restart_time", "secs"), &StreamPlayer::set_loop_restart_time);
+ ObjectTypeDB::bind_method(_MD("get_loop_restart_time"), &StreamPlayer::get_loop_restart_time);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&StreamPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_loop_count"),&StreamPlayer::get_loop_count);
+ ObjectTypeDB::bind_method(_MD("get_stream_name"), &StreamPlayer::get_stream_name);
+ ObjectTypeDB::bind_method(_MD("get_loop_count"), &StreamPlayer::get_loop_count);
- ObjectTypeDB::bind_method(_MD("get_pos"),&StreamPlayer::get_pos);
- ObjectTypeDB::bind_method(_MD("seek_pos","time"),&StreamPlayer::seek_pos);
+ ObjectTypeDB::bind_method(_MD("get_pos"), &StreamPlayer::get_pos);
+ ObjectTypeDB::bind_method(_MD("seek_pos", "time"), &StreamPlayer::seek_pos);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&StreamPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&StreamPlayer::has_autoplay);
+ ObjectTypeDB::bind_method(_MD("set_autoplay", "enabled"), &StreamPlayer::set_autoplay);
+ ObjectTypeDB::bind_method(_MD("has_autoplay"), &StreamPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("get_length"),&StreamPlayer::get_length);
+ ObjectTypeDB::bind_method(_MD("get_length"), &StreamPlayer::get_length);
- ObjectTypeDB::bind_method(_MD("_set_play","play"),&StreamPlayer::_set_play);
- ObjectTypeDB::bind_method(_MD("_get_play"),&StreamPlayer::_get_play);
- ObjectTypeDB::bind_method(_MD("_do_stop"),&StreamPlayer::_do_stop);
+ ObjectTypeDB::bind_method(_MD("_set_play", "play"), &StreamPlayer::_set_play);
+ ObjectTypeDB::bind_method(_MD("_get_play"), &StreamPlayer::_get_play);
+ ObjectTypeDB::bind_method(_MD("_do_stop"), &StreamPlayer::_do_stop);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), _SCS("set_stream"), _SCS("get_stream"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stream/loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "stream/buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec"));
ADD_SIGNAL(MethodInfo("finished"));
}
-
StreamPlayer::StreamPlayer() {
- volume=1;
- loops=false;
- paused=false;
- autoplay=false;
- _play=false;
- server_mix_rate=1;
- internal_stream.player=this;
- stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
- buffering_ms=500;
- loop_point=0;
- stop_request=false;
- resume_pos=-1;
-
+ volume = 1;
+ loops = false;
+ paused = false;
+ autoplay = false;
+ _play = false;
+ server_mix_rate = 1;
+ internal_stream.player = this;
+ stream_rid = AudioServer::get_singleton()->audio_stream_create(&internal_stream);
+ buffering_ms = 500;
+ loop_point = 0;
+ stop_request = false;
+ resume_pos = -1;
}
StreamPlayer::~StreamPlayer() {
AudioServer::get_singleton()->free(stream_rid);
resampler.clear();
-
-
}
diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h
index 4e64d2b27..bdbd663ac 100644
--- a/scene/audio/stream_player.h
+++ b/scene/audio/stream_player.h
@@ -29,13 +29,13 @@
#ifndef STREAM_PLAYER_H
#define STREAM_PLAYER_H
-#include "scene/resources/audio_stream.h"
#include "scene/main/node.h"
+#include "scene/resources/audio_stream.h"
#include "servers/audio/audio_rb_resampler.h"
class StreamPlayer : public Node {
- OBJ_TYPE(StreamPlayer,Node);
+ OBJ_TYPE(StreamPlayer, Node);
//_THREAD_SAFE_CLASS_
@@ -43,18 +43,17 @@ class StreamPlayer : public Node {
StreamPlayer *player;
virtual int get_channel_count() const;
virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames);
+ virtual bool mix(int32_t *p_buffer, int p_frames);
virtual void update();
};
-
InternalStream internal_stream;
Ref<AudioStreamPlayback> playback;
Ref<AudioStream> stream;
int sp_get_channel_count() const;
void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate
- bool sp_mix(int32_t *p_buffer,int p_frames);
+ bool sp_mix(int32_t *p_buffer, int p_frames);
void sp_update();
int server_mix_rate;
@@ -76,16 +75,17 @@ class StreamPlayer : public Node {
bool _play;
void _set_play(bool p_play);
bool _get_play() const;
+
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_stream(const Ref<AudioStream> &p_stream);
Ref<AudioStream> get_stream() const;
- void play(float p_from_offset=0);
+ void play(float p_from_offset = 0);
void stop();
bool is_playing() const;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 2dfc89dfd..6861b9d18 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -27,25 +27,24 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "base_button.h"
+#include "button_group.h"
#include "os/keyboard.h"
#include "print_string.h"
-#include "button_group.h"
-#include "scene/scene_string_names.h"
#include "scene/main/viewport.h"
+#include "scene/scene_string_names.h"
void BaseButton::_input_event(InputEvent p_event) {
-
if (status.disabled) // no interaction with disabled button
return;
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &b=p_event.mouse_button;
+ const InputEventMouseButton &b = p_event.mouse_button;
- if ( status.disabled || b.button_index!=1 )
+ if (status.disabled || b.button_index != 1)
return;
if (status.pressing_button)
@@ -59,42 +58,40 @@ void BaseButton::_input_event(InputEvent p_event) {
if (!toggle_mode) { //mouse press attempt
- status.press_attempt=true;
- status.pressing_inside=true;
+ status.press_attempt = true;
+ status.pressing_inside = true;
pressed();
if (get_script_instance()) {
Variant::CallError ce;
- get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
+ get_script_instance()->call(SceneStringNames::get_singleton()->_pressed, NULL, 0, ce);
}
emit_signal("pressed");
} else {
- status.pressed=!status.pressed;
+ status.pressed = !status.pressed;
pressed();
if (get_script_instance()) {
Variant::CallError ce;
- get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
+ get_script_instance()->call(SceneStringNames::get_singleton()->_pressed, NULL, 0, ce);
}
emit_signal("pressed");
toggled(status.pressed);
- emit_signal("toggled",status.pressed);
-
+ emit_signal("toggled", status.pressed);
}
-
} else {
emit_signal("button_up");
if (status.press_attempt && status.pressing_inside) {
-// released();
+ // released();
emit_signal("released");
}
- status.press_attempt=false;
+ status.press_attempt = false;
}
update();
break;
@@ -102,56 +99,52 @@ void BaseButton::_input_event(InputEvent p_event) {
if (b.pressed) {
- status.press_attempt=true;
- status.pressing_inside=true;
+ status.press_attempt = true;
+ status.pressing_inside = true;
emit_signal("button_down");
} else {
emit_signal("button_up");
- if (status.press_attempt &&status.pressing_inside) {
+ if (status.press_attempt && status.pressing_inside) {
if (!toggle_mode) { //mouse press attempt
pressed();
if (get_script_instance()) {
Variant::CallError ce;
- get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
+ get_script_instance()->call(SceneStringNames::get_singleton()->_pressed, NULL, 0, ce);
}
emit_signal("pressed");
} else {
- status.pressed=!status.pressed;
+ status.pressed = !status.pressed;
pressed();
emit_signal("pressed");
toggled(status.pressed);
- emit_signal("toggled",status.pressed);
+ emit_signal("toggled", status.pressed);
if (get_script_instance()) {
- get_script_instance()->call(SceneStringNames::get_singleton()->_toggled,status.pressed);
+ get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, status.pressed);
}
-
-
}
-
}
- status.press_attempt=false;
-
+ status.press_attempt = false;
}
update();
} break;
case InputEvent::MOUSE_MOTION: {
- if (status.press_attempt && status.pressing_button==0) {
- bool last_press_inside=status.pressing_inside;
- status.pressing_inside=has_point(Point2(p_event.mouse_motion.x,p_event.mouse_motion.y));
- if (last_press_inside!=status.pressing_inside)
+ if (status.press_attempt && status.pressing_button == 0) {
+ bool last_press_inside = status.pressing_inside;
+ status.pressing_inside = has_point(Point2(p_event.mouse_motion.x, p_event.mouse_motion.y));
+ if (last_press_inside != status.pressing_inside)
update();
}
} break;
@@ -159,7 +152,6 @@ void BaseButton::_input_event(InputEvent p_event) {
case InputEvent::JOYSTICK_BUTTON:
case InputEvent::KEY: {
-
if (p_event.is_echo()) {
break;
}
@@ -168,7 +160,7 @@ void BaseButton::_input_event(InputEvent p_event) {
break;
}
- if (status.press_attempt && status.pressing_button==0) {
+ if (status.press_attempt && status.pressing_button == 0) {
break;
}
@@ -177,8 +169,8 @@ void BaseButton::_input_event(InputEvent p_event) {
if (p_event.is_pressed()) {
status.pressing_button++;
- status.press_attempt=true;
- status.pressing_inside=true;
+ status.press_attempt = true;
+ status.pressing_inside = true;
emit_signal("button_down");
} else if (status.press_attempt) {
@@ -189,8 +181,8 @@ void BaseButton::_input_event(InputEvent p_event) {
if (status.pressing_button)
break;
- status.press_attempt=false;
- status.pressing_inside=false;
+ status.press_attempt = false;
+ status.pressing_inside = false;
emit_signal("button_up");
@@ -200,92 +192,89 @@ void BaseButton::_input_event(InputEvent p_event) {
emit_signal("pressed");
} else {
- status.pressed=!status.pressed;
+ status.pressed = !status.pressed;
pressed();
emit_signal("pressed");
toggled(status.pressed);
if (get_script_instance()) {
- get_script_instance()->call(SceneStringNames::get_singleton()->_toggled,status.pressed);
+ get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, status.pressed);
}
- emit_signal("toggled",status.pressed);
+ emit_signal("toggled", status.pressed);
}
}
accept_event();
update();
-
}
}
-
}
}
void BaseButton::_notification(int p_what) {
+ if (p_what == NOTIFICATION_MOUSE_ENTER) {
- if (p_what==NOTIFICATION_MOUSE_ENTER) {
-
- status.hovering=true;
+ status.hovering = true;
update();
}
- if (p_what==NOTIFICATION_MOUSE_EXIT) {
- status.hovering=false;
+ if (p_what == NOTIFICATION_MOUSE_EXIT) {
+ status.hovering = false;
update();
}
- if (p_what==NOTIFICATION_DRAG_BEGIN) {
+ if (p_what == NOTIFICATION_DRAG_BEGIN) {
if (status.press_attempt) {
- status.press_attempt=false;
- status.pressing_button=0;
+ status.press_attempt = false;
+ status.pressing_button = 0;
update();
}
}
-
- if (p_what==NOTIFICATION_FOCUS_ENTER) {
-
- status.hovering=true;
+
+ if (p_what == NOTIFICATION_FOCUS_ENTER) {
+
+ status.hovering = true;
update();
}
- if (p_what==NOTIFICATION_FOCUS_EXIT) {
+ if (p_what == NOTIFICATION_FOCUS_EXIT) {
if (status.pressing_button && status.press_attempt) {
- status.press_attempt=false;
- status.pressing_button=0;
- status.hovering=false;
+ status.press_attempt = false;
+ status.pressing_button = 0;
+ status.hovering = false;
update();
} else if (status.hovering) {
- status.hovering=false;
+ status.hovering = false;
update();
}
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
- CanvasItem *ci=this;
- while(ci) {
+ CanvasItem *ci = this;
+ while (ci) {
ButtonGroup *bg = ci->cast_to<ButtonGroup>();
if (bg) {
- group=bg;
+ group = bg;
group->_add_button(this);
}
- ci=ci->get_parent_item();
+ ci = ci->get_parent_item();
}
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
if (group)
group->_remove_button(this);
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible()) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED && !is_visible()) {
if (!toggle_mode) {
status.pressed = false;
@@ -306,11 +295,9 @@ void BaseButton::pressed() {
void BaseButton::toggled(bool p_pressed) {
if (get_script_instance())
- get_script_instance()->call("toggled",p_pressed);
-
+ get_script_instance()->call("toggled", p_pressed);
}
-
void BaseButton::set_disabled(bool p_disabled) {
status.disabled = p_disabled;
@@ -331,21 +318,21 @@ void BaseButton::set_pressed(bool p_pressed) {
if (!toggle_mode)
return;
- if (status.pressed==p_pressed)
+ if (status.pressed == p_pressed)
return;
_change_notify("pressed");
- status.pressed=p_pressed;
+ status.pressed = p_pressed;
update();
}
-bool BaseButton::is_pressing() const{
+bool BaseButton::is_pressing() const {
return status.press_attempt;
}
bool BaseButton::is_pressed() const {
- return toggle_mode?status.pressed:status.press_attempt;
+ return toggle_mode ? status.pressed : status.press_attempt;
}
bool BaseButton::is_hovered() const {
@@ -360,8 +347,7 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
};
//print_line("press attempt: "+itos(status.press_attempt)+" hover: "+itos(status.hovering)+" pressed: "+itos(status.pressed));
- if (status.press_attempt==false && status.hovering && !status.pressed) {
-
+ if (status.press_attempt == false && status.hovering && !status.pressed) {
return DRAW_HOVER;
} else {
@@ -370,12 +356,12 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
bool pressing;
if (status.press_attempt) {
- pressing=status.pressing_inside;
+ pressing = status.pressing_inside;
if (status.pressed)
- pressing=!pressing;
+ pressing = !pressing;
} else {
- pressing=status.pressed;
+ pressing = status.pressed;
}
if (pressing)
@@ -389,7 +375,7 @@ BaseButton::DrawMode BaseButton::get_draw_mode() const {
void BaseButton::set_toggle_mode(bool p_on) {
- toggle_mode=p_on;
+ toggle_mode = p_on;
}
bool BaseButton::is_toggle_mode() const {
@@ -399,7 +385,7 @@ bool BaseButton::is_toggle_mode() const {
void BaseButton::set_click_on_press(bool p_click_on_press) {
- status.click_on_press=p_click_on_press;
+ status.click_on_press = p_click_on_press;
}
bool BaseButton::get_click_on_press() const {
@@ -411,7 +397,7 @@ void BaseButton::set_enabled_focus_mode(FocusMode p_mode) {
enabled_focus_mode = p_mode;
if (!status.disabled) {
- set_focus_mode( p_mode );
+ set_focus_mode(p_mode);
}
}
@@ -420,16 +406,16 @@ Control::FocusMode BaseButton::get_enabled_focus_mode() const {
return enabled_focus_mode;
}
-void BaseButton::set_shortcut(const Ref<ShortCut>& p_shortcut) {
+void BaseButton::set_shortcut(const Ref<ShortCut> &p_shortcut) {
if (shortcut.is_null() == p_shortcut.is_null())
return;
- shortcut=p_shortcut;
+ shortcut = p_shortcut;
set_process_unhandled_input(shortcut.is_valid());
}
-Ref<ShortCut> BaseButton:: get_shortcut() const {
+Ref<ShortCut> BaseButton::get_shortcut() const {
return shortcut;
}
@@ -442,21 +428,21 @@ void BaseButton::_unhandled_input(InputEvent p_event) {
if (is_toggle_mode()) {
set_pressed(!is_pressed());
- emit_signal("toggled",is_pressed());
+ emit_signal("toggled", is_pressed());
}
emit_signal("pressed");
}
}
-String BaseButton::get_tooltip(const Point2& p_pos) const {
+String BaseButton::get_tooltip(const Point2 &p_pos) const {
- String tooltip=Control::get_tooltip(p_pos);
+ String tooltip = Control::get_tooltip(p_pos);
if (shortcut.is_valid() && shortcut->is_valid()) {
- if (tooltip.find("$sc")!=-1) {
- tooltip=tooltip.replace_first("$sc","("+shortcut->get_as_text()+")");
+ if (tooltip.find("$sc") != -1) {
+ tooltip = tooltip.replace_first("$sc", "(" + shortcut->get_as_text() + ")");
} else {
- tooltip+=" ("+shortcut->get_as_text()+")";
+ tooltip += " (" + shortcut->get_as_text() + ")";
}
}
return tooltip;
@@ -464,65 +450,58 @@ String BaseButton::get_tooltip(const Point2& p_pos) const {
void BaseButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&BaseButton::_input_event);
- ObjectTypeDB::bind_method(_MD("_unhandled_input"),&BaseButton::_unhandled_input);
- ObjectTypeDB::bind_method(_MD("set_pressed","pressed"),&BaseButton::set_pressed);
- ObjectTypeDB::bind_method(_MD("is_pressed"),&BaseButton::is_pressed);
- ObjectTypeDB::bind_method(_MD("is_hovered"),&BaseButton::is_hovered);
- ObjectTypeDB::bind_method(_MD("set_toggle_mode","enabled"),&BaseButton::set_toggle_mode);
- ObjectTypeDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode);
- ObjectTypeDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled);
- ObjectTypeDB::bind_method(_MD("is_disabled"),&BaseButton::is_disabled);
- ObjectTypeDB::bind_method(_MD("set_click_on_press","enable"),&BaseButton::set_click_on_press);
- ObjectTypeDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press);
- ObjectTypeDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
- ObjectTypeDB::bind_method(_MD("set_enabled_focus_mode","mode"),&BaseButton::set_enabled_focus_mode);
- ObjectTypeDB::bind_method(_MD("get_enabled_focus_mode"),&BaseButton::get_enabled_focus_mode);
- ObjectTypeDB::bind_method(_MD("set_shortcut","shortcut"),&BaseButton::set_shortcut);
- ObjectTypeDB::bind_method(_MD("get_shortcut"),&BaseButton::get_shortcut);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &BaseButton::_input_event);
+ ObjectTypeDB::bind_method(_MD("_unhandled_input"), &BaseButton::_unhandled_input);
+ ObjectTypeDB::bind_method(_MD("set_pressed", "pressed"), &BaseButton::set_pressed);
+ ObjectTypeDB::bind_method(_MD("is_pressed"), &BaseButton::is_pressed);
+ ObjectTypeDB::bind_method(_MD("is_hovered"), &BaseButton::is_hovered);
+ ObjectTypeDB::bind_method(_MD("set_toggle_mode", "enabled"), &BaseButton::set_toggle_mode);
+ ObjectTypeDB::bind_method(_MD("is_toggle_mode"), &BaseButton::is_toggle_mode);
+ ObjectTypeDB::bind_method(_MD("set_disabled", "disabled"), &BaseButton::set_disabled);
+ ObjectTypeDB::bind_method(_MD("is_disabled"), &BaseButton::is_disabled);
+ ObjectTypeDB::bind_method(_MD("set_click_on_press", "enable"), &BaseButton::set_click_on_press);
+ ObjectTypeDB::bind_method(_MD("get_click_on_press"), &BaseButton::get_click_on_press);
+ ObjectTypeDB::bind_method(_MD("get_draw_mode"), &BaseButton::get_draw_mode);
+ ObjectTypeDB::bind_method(_MD("set_enabled_focus_mode", "mode"), &BaseButton::set_enabled_focus_mode);
+ ObjectTypeDB::bind_method(_MD("get_enabled_focus_mode"), &BaseButton::get_enabled_focus_mode);
+ ObjectTypeDB::bind_method(_MD("set_shortcut", "shortcut"), &BaseButton::set_shortcut);
+ ObjectTypeDB::bind_method(_MD("get_shortcut"), &BaseButton::get_shortcut);
BIND_VMETHOD(MethodInfo("_pressed"));
- BIND_VMETHOD(MethodInfo("_toggled",PropertyInfo(Variant::BOOL,"pressed")));
+ BIND_VMETHOD(MethodInfo("_toggled", PropertyInfo(Variant::BOOL, "pressed")));
- ADD_SIGNAL( MethodInfo("pressed" ) );
- ADD_SIGNAL( MethodInfo("released" ) );
- ADD_SIGNAL( MethodInfo("button_up") );
- ADD_SIGNAL( MethodInfo("button_down") );
- ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
- ADD_PROPERTY( PropertyInfo( Variant::INT,"enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_enabled_focus_mode"), _SCS("get_enabled_focus_mode") );
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shortcut",PROPERTY_HINT_RESOURCE_TYPE,"ShortCut"), _SCS("set_shortcut"), _SCS("get_shortcut"));
-
-
- BIND_CONSTANT( DRAW_NORMAL );
- BIND_CONSTANT( DRAW_PRESSED );
- BIND_CONSTANT( DRAW_HOVER );
- BIND_CONSTANT( DRAW_DISABLED );
+ ADD_SIGNAL(MethodInfo("pressed"));
+ ADD_SIGNAL(MethodInfo("released"));
+ ADD_SIGNAL(MethodInfo("button_up"));
+ ADD_SIGNAL(MethodInfo("button_down"));
+ ADD_SIGNAL(MethodInfo("toggled", PropertyInfo(Variant::BOOL, "pressed")));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), _SCS("set_enabled_focus_mode"), _SCS("get_enabled_focus_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shortcut", PROPERTY_HINT_RESOURCE_TYPE, "ShortCut"), _SCS("set_shortcut"), _SCS("get_shortcut"));
+ BIND_CONSTANT(DRAW_NORMAL);
+ BIND_CONSTANT(DRAW_PRESSED);
+ BIND_CONSTANT(DRAW_HOVER);
+ BIND_CONSTANT(DRAW_DISABLED);
}
BaseButton::BaseButton() {
- toggle_mode=false;
- status.pressed=false;
- status.press_attempt=false;
- status.hovering=false;
- status.pressing_inside=false;
+ toggle_mode = false;
+ status.pressed = false;
+ status.press_attempt = false;
+ status.hovering = false;
+ status.pressing_inside = false;
status.disabled = false;
- status.click_on_press=false;
- status.pressing_button=0;
- set_focus_mode( FOCUS_ALL );
+ status.click_on_press = false;
+ status.pressing_button = 0;
+ set_focus_mode(FOCUS_ALL);
enabled_focus_mode = FOCUS_ALL;
- group=NULL;
-
-
+ group = NULL;
}
-BaseButton::~BaseButton()
-{
+BaseButton::~BaseButton() {
}
-
-
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 1d9702385..efa90853b 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -34,12 +34,11 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-
class ButtonGroup;
class BaseButton : public Control {
- OBJ_TYPE( BaseButton, Control );
+ OBJ_TYPE(BaseButton, Control);
bool toggle_mode;
FocusMode enabled_focus_mode;
@@ -58,15 +57,9 @@ class BaseButton : public Control {
} status;
-
ButtonGroup *group;
-
protected:
-
-
-
-
virtual void pressed();
virtual void toggled(bool p_pressed);
static void _bind_methods();
@@ -75,7 +68,6 @@ protected:
void _notification(int p_what);
public:
-
enum DrawMode {
DRAW_NORMAL,
DRAW_PRESSED,
@@ -104,16 +96,15 @@ public:
void set_enabled_focus_mode(FocusMode p_mode);
FocusMode get_enabled_focus_mode() const;
- void set_shortcut(const Ref<ShortCut>& p_shortcut);
+ void set_shortcut(const Ref<ShortCut> &p_shortcut);
Ref<ShortCut> get_shortcut() const;
- virtual String get_tooltip(const Point2& p_pos) const;
+ virtual String get_tooltip(const Point2 &p_pos) const;
BaseButton();
~BaseButton();
-
};
-VARIANT_ENUM_CAST( BaseButton::DrawMode );
+VARIANT_ENUM_CAST(BaseButton::DrawMode);
#endif
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index 575e3f24b..6ebc22baf 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "box_container.h"
-#include "margin_container.h"
#include "label.h"
+#include "margin_container.h"
struct _MinSizeCache {
@@ -41,110 +41,105 @@ void BoxContainer::_resort() {
/** First pass, determine minimum size AND amount of stretchable elements */
+ Size2i new_size = get_size();
- Size2i new_size=get_size();
+ int sep = get_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer");
- int sep=get_constant("separation");//,vertical?"VBoxContainer":"HBoxContainer");
+ bool first = true;
+ int children_count = 0;
+ int stretch_min = 0;
+ int stretch_avail = 0;
+ float stretch_ratio_total = 0;
+ Map<Control *, _MinSizeCache> min_size_cache;
- bool first=true;
- int children_count=0;
- int stretch_min=0;
- int stretch_avail=0;
- float stretch_ratio_total=0;
- Map<Control*,_MinSizeCache> min_size_cache;
-
- for(int i=0;i<get_child_count();i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
continue;
if (c->is_set_as_toplevel())
continue;
- Size2i size=c->get_combined_minimum_size();
+ Size2i size = c->get_combined_minimum_size();
_MinSizeCache msc;
if (vertical) { /* VERTICAL */
- stretch_min+=size.height;
- msc.min_size=size.height;
- msc.will_stretch=c->get_v_size_flags() & SIZE_EXPAND;
+ stretch_min += size.height;
+ msc.min_size = size.height;
+ msc.will_stretch = c->get_v_size_flags() & SIZE_EXPAND;
} else { /* HORIZONTAL */
- stretch_min+=size.width;
- msc.min_size=size.width;
- msc.will_stretch=c->get_h_size_flags() & SIZE_EXPAND;
+ stretch_min += size.width;
+ msc.min_size = size.width;
+ msc.will_stretch = c->get_h_size_flags() & SIZE_EXPAND;
}
if (msc.will_stretch) {
- stretch_avail+=msc.min_size;
- stretch_ratio_total+=c->get_stretch_ratio();
+ stretch_avail += msc.min_size;
+ stretch_ratio_total += c->get_stretch_ratio();
}
- msc.final_size=msc.min_size;
- min_size_cache[c]=msc;
+ msc.final_size = msc.min_size;
+ min_size_cache[c] = msc;
children_count++;
}
- if (children_count==0)
+ if (children_count == 0)
return;
- int stretch_max = (vertical? new_size.height : new_size.width ) - (children_count-1) * sep;
+ int stretch_max = (vertical ? new_size.height : new_size.width) - (children_count - 1) * sep;
int stretch_diff = stretch_max - stretch_min;
- if (stretch_diff<0) {
+ if (stretch_diff < 0) {
//avoid negative stretch space
- stretch_max=stretch_min;
- stretch_diff=0;
+ stretch_max = stretch_min;
+ stretch_diff = 0;
}
- stretch_avail+=stretch_diff; //available stretch space.
+ stretch_avail += stretch_diff; //available stretch space.
/** Second, pass sucessively to discard elements that can't be stretched, this will run while stretchable
elements exist */
-
bool has_stretched = false;
- while(stretch_ratio_total>0) { // first of all, dont even be here if no stretchable objects exist
+ while (stretch_ratio_total > 0) { // first of all, dont even be here if no stretchable objects exist
has_stretched = true;
- bool refit_successful=true; //assume refit-test will go well
+ bool refit_successful = true; //assume refit-test will go well
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
continue;
if (c->is_set_as_toplevel())
continue;
ERR_FAIL_COND(!min_size_cache.has(c));
- _MinSizeCache &msc=min_size_cache[c];
+ _MinSizeCache &msc = min_size_cache[c];
if (msc.will_stretch) { //wants to stretch
//let's see if it can really stretch
- int final_pixel_size=stretch_avail * c->get_stretch_ratio() / stretch_ratio_total;
- if (final_pixel_size<msc.min_size) {
+ int final_pixel_size = stretch_avail * c->get_stretch_ratio() / stretch_ratio_total;
+ if (final_pixel_size < msc.min_size) {
//if available stretching area is too small for widget,
//then remove it from stretching area
- msc.will_stretch=false;
- stretch_ratio_total-=c->get_stretch_ratio();
- refit_successful=false;
- stretch_avail-=msc.min_size;
- msc.final_size=msc.min_size;
+ msc.will_stretch = false;
+ stretch_ratio_total -= c->get_stretch_ratio();
+ refit_successful = false;
+ stretch_avail -= msc.min_size;
+ msc.final_size = msc.min_size;
break;
} else {
- msc.final_size=final_pixel_size;
+ msc.final_size = final_pixel_size;
}
}
}
if (refit_successful) //uf refit went well, break
break;
-
}
-
/** Final pass, draw and stretch elements **/
-
- int ofs=0;
+ int ofs = 0;
if (!has_stretched) {
switch (align) {
case ALIGN_BEGIN:
@@ -158,70 +153,64 @@ void BoxContainer::_resort() {
}
}
- first=true;
- int idx=0;
+ first = true;
+ int idx = 0;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
continue;
if (c->is_set_as_toplevel())
continue;
- _MinSizeCache &msc=min_size_cache[c];
-
+ _MinSizeCache &msc = min_size_cache[c];
if (first)
- first=false;
+ first = false;
else
- ofs+=sep;
+ ofs += sep;
- int from=ofs;
- int to=ofs+msc.final_size;
+ int from = ofs;
+ int to = ofs + msc.final_size;
-
- if (msc.will_stretch && idx==children_count-1) {
+ if (msc.will_stretch && idx == children_count - 1) {
//adjust so the last one always fits perfect
//compensating for numerical imprecision
- to=vertical?new_size.height:new_size.width;
-
+ to = vertical ? new_size.height : new_size.width;
}
- int size=to-from;
+ int size = to - from;
Rect2 rect;
if (vertical) {
- rect=Rect2(0,from,new_size.width,size);
+ rect = Rect2(0, from, new_size.width, size);
} else {
- rect=Rect2(from,0,size,new_size.height);
-
+ rect = Rect2(from, 0, size, new_size.height);
}
- fit_child_in_rect(c,rect);
+ fit_child_in_rect(c, rect);
- ofs=to;
+ ofs = to;
idx++;
}
-
}
Size2 BoxContainer::get_minimum_size() const {
-
/* Calculate MINIMUM SIZE */
Size2i minimum;
- int sep=get_constant("separation");//,vertical?"VBoxContainer":"HBoxContainer");
+ int sep = get_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer");
- bool first=true;
+ bool first = true;
- for(int i=0;i<get_child_count();i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
@@ -231,27 +220,26 @@ Size2 BoxContainer::get_minimum_size() const {
continue;
}
- Size2i size=c->get_combined_minimum_size();
+ Size2i size = c->get_combined_minimum_size();
if (vertical) { /* VERTICAL */
- if ( size.width > minimum.width ) {
- minimum.width=size.width;
+ if (size.width > minimum.width) {
+ minimum.width = size.width;
}
- minimum.height+=size.height+(first?0:sep);
+ minimum.height += size.height + (first ? 0 : sep);
} else { /* HORIZONTAL */
- if ( size.height > minimum.height ) {
- minimum.height=size.height;
+ if (size.height > minimum.height) {
+ minimum.height = size.height;
}
- minimum.width+=size.width+(first?0:sep);
-
+ minimum.width += size.width + (first ? 0 : sep);
}
- first=false;
+ first = false;
}
return minimum;
@@ -259,7 +247,7 @@ Size2 BoxContainer::get_minimum_size() const {
void BoxContainer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_SORT_CHILDREN: {
@@ -279,7 +267,7 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const {
void BoxContainer::add_spacer(bool p_begin) {
- Control *c = memnew( Control );
+ Control *c = memnew(Control);
c->set_stop_mouse(false);
if (vertical)
c->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -288,37 +276,36 @@ void BoxContainer::add_spacer(bool p_begin) {
add_child(c);
if (p_begin)
- move_child(c,0);
+ move_child(c, 0);
}
BoxContainer::BoxContainer(bool p_vertical) {
- vertical=p_vertical;
+ vertical = p_vertical;
align = ALIGN_BEGIN;
-// set_ignore_mouse(true);
+ // set_ignore_mouse(true);
set_stop_mouse(false);
}
void BoxContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_spacer","begin"),&BoxContainer::add_spacer);
- ObjectTypeDB::bind_method(_MD("get_alignment"),&BoxContainer::get_alignment);
- ObjectTypeDB::bind_method(_MD("set_alignment","alignment"),&BoxContainer::set_alignment);
-
- BIND_CONSTANT( ALIGN_BEGIN );
- BIND_CONSTANT( ALIGN_CENTER );
- BIND_CONSTANT( ALIGN_END );
+ ObjectTypeDB::bind_method(_MD("add_spacer", "begin"), &BoxContainer::add_spacer);
+ ObjectTypeDB::bind_method(_MD("get_alignment"), &BoxContainer::get_alignment);
+ ObjectTypeDB::bind_method(_MD("set_alignment", "alignment"), &BoxContainer::set_alignment);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"alignment", PROPERTY_HINT_ENUM, "Begin,Center,End"), _SCS("set_alignment"),_SCS("get_alignment") );
+ BIND_CONSTANT(ALIGN_BEGIN);
+ BIND_CONSTANT(ALIGN_CENTER);
+ BIND_CONSTANT(ALIGN_END);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "alignment", PROPERTY_HINT_ENUM, "Begin,Center,End"), _SCS("set_alignment"), _SCS("get_alignment"));
}
-MarginContainer* VBoxContainer::add_margin_child(const String& p_label,Control *p_control,bool p_expand) {
+MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control *p_control, bool p_expand) {
- Label *l = memnew( Label );
+ Label *l = memnew(Label);
l->set_text(p_label);
add_child(l);
- MarginContainer *mc = memnew( MarginContainer );
+ MarginContainer *mc = memnew(MarginContainer);
mc->add_child(p_control);
add_child(mc);
if (p_expand)
diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h
index b137a5faa..537750061 100644
--- a/scene/gui/box_container.h
+++ b/scene/gui/box_container.h
@@ -33,10 +33,9 @@
class BoxContainer : public Container {
- OBJ_TYPE(BoxContainer,Container);
+ OBJ_TYPE(BoxContainer, Container);
public:
-
enum AlignMode {
ALIGN_BEGIN,
ALIGN_CENTER,
@@ -48,44 +47,42 @@ private:
AlignMode align;
void _resort();
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- void add_spacer(bool p_begin=false);
+public:
+ void add_spacer(bool p_begin = false);
void set_alignment(AlignMode p_align);
AlignMode get_alignment() const;
virtual Size2 get_minimum_size() const;
- BoxContainer(bool p_vertical=false);
+ BoxContainer(bool p_vertical = false);
};
-
class HBoxContainer : public BoxContainer {
- OBJ_TYPE(HBoxContainer,BoxContainer);
+ OBJ_TYPE(HBoxContainer, BoxContainer);
public:
-
- HBoxContainer() : BoxContainer(false) {}
+ HBoxContainer()
+ : BoxContainer(false) {}
};
-
class MarginContainer;
class VBoxContainer : public BoxContainer {
- OBJ_TYPE(VBoxContainer,BoxContainer);
+ OBJ_TYPE(VBoxContainer, BoxContainer);
public:
+ MarginContainer *add_margin_child(const String &p_label, Control *p_control, bool p_expand = false);
- MarginContainer* add_margin_child(const String& p_label,Control *p_control,bool p_expand=false);
-
- VBoxContainer() : BoxContainer(true) {}
+ VBoxContainer()
+ : BoxContainer(true) {}
};
VARIANT_ENUM_CAST(BoxContainer::AlignMode);
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 8bdf21f85..000eea0ba 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -27,79 +27,76 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "button.h"
-#include "servers/visual_server.h"
#include "print_string.h"
+#include "servers/visual_server.h"
#include "translation.h"
-
Size2 Button::get_minimum_size() const {
- Size2 minsize=get_font("font")->get_string_size( text );
+ Size2 minsize = get_font("font")->get_string_size(text);
if (clip_text)
- minsize.width=0;
+ minsize.width = 0;
Ref<Texture> _icon;
if (icon.is_null() && has_icon("icon"))
- _icon=Control::get_icon("icon");
+ _icon = Control::get_icon("icon");
else
- _icon=icon;
+ _icon = icon;
if (!_icon.is_null()) {
- minsize.height=MAX( minsize.height, _icon->get_height() );
- minsize.width+=_icon->get_width();
- if (text!="")
- minsize.width+=get_constant("hseparation");
+ minsize.height = MAX(minsize.height, _icon->get_height());
+ minsize.width += _icon->get_width();
+ if (text != "")
+ minsize.width += get_constant("hseparation");
}
- return get_stylebox("normal" )->get_minimum_size() + minsize;
-
+ return get_stylebox("normal")->get_minimum_size() + minsize;
}
-
void Button::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
- Size2 size=get_size();
+ Size2 size = get_size();
Color color;
//print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode()));
Ref<StyleBox> style = get_stylebox("normal");
- switch( get_draw_mode() ) {
+ switch (get_draw_mode()) {
case DRAW_NORMAL: {
style = get_stylebox("normal");
if (!flat)
- style->draw( ci, Rect2(Point2(0,0), size) );
- color=get_color("font_color");
+ style->draw(ci, Rect2(Point2(0, 0), size));
+ color = get_color("font_color");
} break;
case DRAW_PRESSED: {
style = get_stylebox("pressed");
- style->draw( ci, Rect2(Point2(0,0), size) );
+ style->draw(ci, Rect2(Point2(0, 0), size));
if (has_color("font_color_pressed"))
- color=get_color("font_color_pressed");
+ color = get_color("font_color_pressed");
else
- color=get_color("font_color");
+ color = get_color("font_color");
} break;
case DRAW_HOVER: {
style = get_stylebox("hover");
- style->draw( ci, Rect2(Point2(0,0), size) );
- color=get_color("font_color_hover");
+ style->draw(ci, Rect2(Point2(0, 0), size));
+ color = get_color("font_color_hover");
} break;
case DRAW_DISABLED: {
style = get_stylebox("disabled");
- style->draw( ci, Rect2(Point2(0,0), size) );
- color=get_color("font_color_disabled");
+ style->draw(ci, Rect2(Point2(0, 0), size));
+ color = get_color("font_color_disabled");
} break;
}
@@ -107,57 +104,53 @@ void Button::_notification(int p_what) {
if (has_focus()) {
Ref<StyleBox> style = get_stylebox("focus");
- style->draw(ci,Rect2(Point2(),size));
+ style->draw(ci, Rect2(Point2(), size));
}
- Ref<Font> font=get_font("font");
+ Ref<Font> font = get_font("font");
Ref<Texture> _icon;
if (icon.is_null() && has_icon("icon"))
- _icon=Control::get_icon("icon");
+ _icon = Control::get_icon("icon");
else
- _icon=icon;
+ _icon = icon;
- Point2 icon_ofs = (!_icon.is_null())?Point2( _icon->get_width() + get_constant("hseparation"), 0):Point2();
- int text_clip=size.width - style->get_minimum_size().width - icon_ofs.width;
- Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size( text ) )/2.0;
+ Point2 icon_ofs = (!_icon.is_null()) ? Point2(_icon->get_width() + get_constant("hseparation"), 0) : Point2();
+ int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width;
+ Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size(text)) / 2.0;
- switch(align) {
+ switch (align) {
case ALIGN_LEFT: {
text_ofs.x = style->get_margin(MARGIN_LEFT) + icon_ofs.x;
- text_ofs.y+=style->get_offset().y;
+ text_ofs.y += style->get_offset().y;
} break;
case ALIGN_CENTER: {
- if (text_ofs.x<0)
- text_ofs.x=0;
- text_ofs+=icon_ofs;
- text_ofs+=style->get_offset();
+ if (text_ofs.x < 0)
+ text_ofs.x = 0;
+ text_ofs += icon_ofs;
+ text_ofs += style->get_offset();
} break;
case ALIGN_RIGHT: {
- text_ofs.x=size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size( text ).x;
- text_ofs.y+=style->get_offset().y;
+ text_ofs.x = size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size(text).x;
+ text_ofs.y += style->get_offset().y;
} break;
}
-
- text_ofs.y+=font->get_ascent();
- font->draw( ci, text_ofs.floor(), text, color,clip_text?text_clip:-1);
+ text_ofs.y += font->get_ascent();
+ font->draw(ci, text_ofs.floor(), text, color, clip_text ? text_clip : -1);
if (!_icon.is_null()) {
- int valign = size.height-style->get_minimum_size().y;
+ int valign = size.height - style->get_minimum_size().y;
- _icon->draw(ci,style->get_offset()+Point2(0, Math::floor( (valign-_icon->get_height())/2.0 ) ),is_disabled()?Color(1,1,1,0.4):Color(1,1,1) );
+ _icon->draw(ci, style->get_offset() + Point2(0, Math::floor((valign - _icon->get_height()) / 2.0)), is_disabled() ? Color(1, 1, 1, 0.4) : Color(1, 1, 1));
}
-
-
-
}
}
-void Button::set_text(const String& p_text) {
+void Button::set_text(const String &p_text) {
- if (text==p_text)
+ if (text == p_text)
return;
- text=XL_MESSAGE(p_text);
+ text = XL_MESSAGE(p_text);
update();
_change_notify("text");
minimum_size_changed();
@@ -167,12 +160,11 @@ String Button::get_text() const {
return text;
}
+void Button::set_icon(const Ref<Texture> &p_icon) {
-void Button::set_icon(const Ref<Texture>& p_icon) {
-
- if (icon==p_icon)
+ if (icon == p_icon)
return;
- icon=p_icon;
+ icon = p_icon;
update();
_change_notify("icon");
minimum_size_changed();
@@ -185,7 +177,7 @@ Ref<Texture> Button::get_icon() const {
void Button::set_flat(bool p_flat) {
- flat=p_flat;
+ flat = p_flat;
update();
_change_notify("flat");
}
@@ -197,7 +189,7 @@ bool Button::is_flat() const {
void Button::set_clip_text(bool p_clip_text) {
- clip_text=p_clip_text;
+ clip_text = p_clip_text;
update();
minimum_size_changed();
}
@@ -209,7 +201,7 @@ bool Button::get_clip_text() const {
void Button::set_text_align(TextAlign p_align) {
- align=p_align;
+ align = p_align;
update();
}
@@ -220,41 +212,36 @@ Button::TextAlign Button::get_text_align() const {
void Button::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_text","text"),&Button::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&Button::get_text);
- ObjectTypeDB::bind_method(_MD("set_button_icon","texture:Texture"),&Button::set_icon);
- ObjectTypeDB::bind_method(_MD("get_button_icon:Texture"),&Button::get_icon);
- ObjectTypeDB::bind_method(_MD("set_flat","enabled"),&Button::set_flat);
- ObjectTypeDB::bind_method(_MD("set_clip_text","enabled"),&Button::set_clip_text);
- ObjectTypeDB::bind_method(_MD("get_clip_text"),&Button::get_clip_text);
- ObjectTypeDB::bind_method(_MD("set_text_align","align"),&Button::set_text_align);
- ObjectTypeDB::bind_method(_MD("get_text_align"),&Button::get_text_align);
- ObjectTypeDB::bind_method(_MD("is_flat"),&Button::is_flat);
-
- BIND_CONSTANT( ALIGN_LEFT );
- BIND_CONSTANT( ALIGN_CENTER );
- BIND_CONSTANT( ALIGN_RIGHT );
+ ObjectTypeDB::bind_method(_MD("set_text", "text"), &Button::set_text);
+ ObjectTypeDB::bind_method(_MD("get_text"), &Button::get_text);
+ ObjectTypeDB::bind_method(_MD("set_button_icon", "texture:Texture"), &Button::set_icon);
+ ObjectTypeDB::bind_method(_MD("get_button_icon:Texture"), &Button::get_icon);
+ ObjectTypeDB::bind_method(_MD("set_flat", "enabled"), &Button::set_flat);
+ ObjectTypeDB::bind_method(_MD("set_clip_text", "enabled"), &Button::set_clip_text);
+ ObjectTypeDB::bind_method(_MD("get_clip_text"), &Button::get_clip_text);
+ ObjectTypeDB::bind_method(_MD("set_text_align", "align"), &Button::set_text_align);
+ ObjectTypeDB::bind_method(_MD("get_text_align"), &Button::get_text_align);
+ ObjectTypeDB::bind_method(_MD("is_flat"), &Button::is_flat);
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL ), _SCS("set_text"),_SCS("get_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_button_icon"),_SCS("get_button_icon") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "clip_text" ), _SCS("set_clip_text"),_SCS("get_clip_text") );
- ADD_PROPERTYNO( PropertyInfo( Variant::INT, "align",PROPERTY_HINT_ENUM,"Left,Center,Right" ), _SCS("set_text_align"),_SCS("get_text_align") );
+ BIND_CONSTANT(ALIGN_LEFT);
+ BIND_CONSTANT(ALIGN_CENTER);
+ BIND_CONSTANT(ALIGN_RIGHT);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"), _SCS("get_text"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_button_icon"), _SCS("get_button_icon"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), _SCS("set_flat"), _SCS("is_flat"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "clip_text"), _SCS("set_clip_text"), _SCS("get_clip_text"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right"), _SCS("set_text_align"), _SCS("get_text_align"));
}
Button::Button(const String &p_text) {
- flat=false;
- clip_text=false;
+ flat = false;
+ clip_text = false;
set_stop_mouse(true);
set_text(p_text);
- align=ALIGN_CENTER;
+ align = ALIGN_CENTER;
}
-
-Button::~Button()
-{
+Button::~Button() {
}
-
-
diff --git a/scene/gui/button.h b/scene/gui/button.h
index 261ed0849..e7b49647a 100644
--- a/scene/gui/button.h
+++ b/scene/gui/button.h
@@ -35,10 +35,9 @@
*/
class Button : public BaseButton {
- OBJ_TYPE( Button, BaseButton );
-public:
-
+ OBJ_TYPE(Button, BaseButton);
+public:
enum TextAlign {
ALIGN_LEFT,
ALIGN_CENTER,
@@ -46,27 +45,24 @@ public:
};
private:
-
bool flat;
String text;
Ref<Texture> icon;
bool clip_text;
TextAlign align;
-
protected:
-
virtual Size2 get_minimum_size() const;
void _notification(int p_what);
static void _bind_methods();
-public:
-//
+public:
+ //
- void set_text(const String& p_text);
+ void set_text(const String &p_text);
String get_text() const;
- void set_icon(const Ref<Texture>& p_icon);
+ void set_icon(const Ref<Texture> &p_icon);
Ref<Texture> get_icon() const;
void set_flat(bool p_flat);
@@ -78,13 +74,10 @@ public:
void set_text_align(TextAlign p_align);
TextAlign get_text_align() const;
-
- Button(const String& p_text=String());
+ Button(const String &p_text = String());
~Button();
-
};
-
VARIANT_ENUM_CAST(Button::TextAlign);
#endif
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp
index 809b1fc54..ba5253b58 100644
--- a/scene/gui/button_array.cpp
+++ b/scene/gui/button_array.cpp
@@ -28,46 +28,44 @@
/*************************************************************************/
#include "button_array.h"
+bool ButtonArray::_set(const StringName &p_name, const Variant &p_value) {
-bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) {
-
- String n=String(p_name);
+ String n = String(p_name);
if (n.begins_with("button/")) {
- String what = n.get_slicec('/',1);
- if (what=="count") {
- int new_size=p_value;
- if (new_size>0 && buttons.size()==0) {
- selected=0;
+ String what = n.get_slicec('/', 1);
+ if (what == "count") {
+ int new_size = p_value;
+ if (new_size > 0 && buttons.size() == 0) {
+ selected = 0;
}
if (new_size < buttons.size()) {
- if (selected>=new_size)
- selected=new_size-1;
+ if (selected >= new_size)
+ selected = new_size - 1;
}
buttons.resize(new_size);
_change_notify();
minimum_size_changed();
- } else if (what=="align") {
+ } else if (what == "align") {
set_align(Align(p_value.operator int()));
- } else if (what=="selected") {
+ } else if (what == "selected") {
set_selected(p_value);
} else if (what == "min_button_size") {
min_button_size = p_value;
} else {
- int idx=what.to_int();
- ERR_FAIL_INDEX_V(idx,buttons.size(),false);
- String f = n.get_slicec('/',2);
- if (f=="text") {
- buttons[idx].text=p_value;
- buttons[idx].xl_text=XL_MESSAGE(p_value);
- } else if (f=="tooltip")
- buttons[idx].tooltip=p_value;
- else if (f=="icon")
- buttons[idx].icon=p_value;
+ int idx = what.to_int();
+ ERR_FAIL_INDEX_V(idx, buttons.size(), false);
+ String f = n.get_slicec('/', 2);
+ if (f == "text") {
+ buttons[idx].text = p_value;
+ buttons[idx].xl_text = XL_MESSAGE(p_value);
+ } else if (f == "tooltip")
+ buttons[idx].tooltip = p_value;
+ else if (f == "icon")
+ buttons[idx].icon = p_value;
else
return false;
-
}
update();
@@ -75,36 +73,34 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) {
}
return false;
-
}
-bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const {
+bool ButtonArray::_get(const StringName &p_name, Variant &r_ret) const {
- String n=String(p_name);
+ String n = String(p_name);
if (n.begins_with("button/")) {
- String what = n.get_slicec('/',1);
- if (what=="count") {
- r_ret=buttons.size();
- } else if (what=="align") {
- r_ret=get_align();
- } else if (what=="selected") {
- r_ret=get_selected();
- } else if (what == "min_button_size"){
+ String what = n.get_slicec('/', 1);
+ if (what == "count") {
+ r_ret = buttons.size();
+ } else if (what == "align") {
+ r_ret = get_align();
+ } else if (what == "selected") {
+ r_ret = get_selected();
+ } else if (what == "min_button_size") {
r_ret = min_button_size;
} else {
- int idx=what.to_int();
- ERR_FAIL_INDEX_V(idx,buttons.size(),false);
- String f = n.get_slicec('/',2);
- if (f=="text")
- r_ret=buttons[idx].text;
- else if (f=="tooltip")
- r_ret=buttons[idx].tooltip;
- else if (f=="icon")
- r_ret=buttons[idx].icon;
+ int idx = what.to_int();
+ ERR_FAIL_INDEX_V(idx, buttons.size(), false);
+ String f = n.get_slicec('/', 2);
+ if (f == "text")
+ r_ret = buttons[idx].text;
+ else if (f == "tooltip")
+ r_ret = buttons[idx].tooltip;
+ else if (f == "icon")
+ r_ret = buttons[idx].icon;
else
return false;
-
}
return true;
@@ -112,24 +108,22 @@ bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const {
return false;
}
-void ButtonArray::_get_property_list( List<PropertyInfo> *p_list) const {
+void ButtonArray::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo( Variant::INT, "button/count",PROPERTY_HINT_RANGE,"0,512,1"));
- p_list->push_back( PropertyInfo( Variant::INT, "button/min_button_size",PROPERTY_HINT_RANGE,"0,1024,1"));
- p_list->push_back( PropertyInfo( Variant::INT, "button/align",PROPERTY_HINT_ENUM,"Begin,Center,End,Fill,Expand"));
- for(int i=0;i<buttons.size();i++) {
- String base="button/"+itos(i)+"/";
- p_list->push_back( PropertyInfo( Variant::STRING, base+"text"));
- p_list->push_back( PropertyInfo( Variant::STRING, base+"tooltip"));
- p_list->push_back( PropertyInfo( Variant::OBJECT, base+"icon",PROPERTY_HINT_RESOURCE_TYPE,"Texture"));
+ p_list->push_back(PropertyInfo(Variant::INT, "button/count", PROPERTY_HINT_RANGE, "0,512,1"));
+ p_list->push_back(PropertyInfo(Variant::INT, "button/min_button_size", PROPERTY_HINT_RANGE, "0,1024,1"));
+ p_list->push_back(PropertyInfo(Variant::INT, "button/align", PROPERTY_HINT_ENUM, "Begin,Center,End,Fill,Expand"));
+ for (int i = 0; i < buttons.size(); i++) {
+ String base = "button/" + itos(i) + "/";
+ p_list->push_back(PropertyInfo(Variant::STRING, base + "text"));
+ p_list->push_back(PropertyInfo(Variant::STRING, base + "tooltip"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, base + "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
}
- if (buttons.size()>0) {
- p_list->push_back( PropertyInfo( Variant::INT, "button/selected",PROPERTY_HINT_RANGE,"0,"+itos(buttons.size()-1)+",1"));
+ if (buttons.size() > 0) {
+ p_list->push_back(PropertyInfo(Variant::INT, "button/selected", PROPERTY_HINT_RANGE, "0," + itos(buttons.size() - 1) + ",1"));
}
-
}
-
Size2 ButtonArray::get_minimum_size() const {
Ref<StyleBox> style_normal = get_stylebox("normal");
@@ -141,54 +135,51 @@ Size2 ButtonArray::get_minimum_size() const {
Size2 minsize;
- for(int i=0;i<buttons.size();i++) {
+ for (int i = 0; i < buttons.size(); i++) {
- Ref<StyleBox> sb = i==selected ? style_selected : style_normal;
- Ref<Font> f = i==selected ? font_selected : font_normal;
+ Ref<StyleBox> sb = i == selected ? style_selected : style_normal;
+ Ref<Font> f = i == selected ? font_selected : font_normal;
Size2 ms;
ms = f->get_string_size(buttons[i].xl_text);
if (buttons[i].icon.is_valid()) {
Size2 bs = buttons[i].icon->get_size();
- ms.height = MAX(ms.height,bs.height);
- ms.width+=bs.width+icon_sep;
+ ms.height = MAX(ms.height, bs.height);
+ ms.width += bs.width + icon_sep;
}
- ms+=sb->get_minimum_size();
+ ms += sb->get_minimum_size();
- buttons[i]._ms_cache=ms[orientation];
-
- minsize[orientation]+=ms[orientation];
- if (i>0)
- minsize[orientation]+=button_sep;
- minsize[!orientation] = MAX(minsize[!orientation],ms[!orientation]);
+ buttons[i]._ms_cache = ms[orientation];
+ minsize[orientation] += ms[orientation];
+ if (i > 0)
+ minsize[orientation] += button_sep;
+ minsize[!orientation] = MAX(minsize[!orientation], ms[!orientation]);
}
return minsize;
-
-
}
void ButtonArray::_notification(int p_what) {
- switch(p_what) {
- case NOTIFICATION_MOUSE_EXIT:{
- hover=-1;
+ switch (p_what) {
+ case NOTIFICATION_MOUSE_EXIT: {
+ hover = -1;
update();
- }break;
- case NOTIFICATION_READY:{
+ } break;
+ case NOTIFICATION_READY: {
MethodInfo mi;
- mi.name="mouse_sub_enter";
+ mi.name = "mouse_sub_enter";
add_user_signal(mi);
- }break;
+ } break;
case NOTIFICATION_DRAW: {
- Size2 size=get_size();
- Size2 minsize=get_combined_minimum_size();
+ Size2 size = get_size();
+ Size2 minsize = get_combined_minimum_size();
Ref<StyleBox> style_normal = get_stylebox("normal");
Ref<StyleBox> style_selected = get_stylebox("selected");
Ref<StyleBox> style_focus = get_stylebox("focus");
@@ -200,188 +191,174 @@ void ButtonArray::_notification(int p_what) {
Color color_normal = get_color("font_color");
Color color_selected = get_color("font_color_selected");
- int sep=button_sep;
- int ofs=0;
- int expand=0;
+ int sep = button_sep;
+ int ofs = 0;
+ int expand = 0;
- switch(align) {
+ switch (align) {
case ALIGN_BEGIN: {
- ofs=0;
+ ofs = 0;
} break;
case ALIGN_CENTER: {
- ofs=Math::floor((size[orientation] - minsize[orientation])/2);
+ ofs = Math::floor((size[orientation] - minsize[orientation]) / 2);
} break;
case ALIGN_END: {
- ofs=Math::floor((size[orientation] - minsize[orientation]));
+ ofs = Math::floor((size[orientation] - minsize[orientation]));
} break;
case ALIGN_FILL: {
- if (buttons.size()>1)
- sep+=Math::floor((size[orientation]- minsize[orientation])/(buttons.size()-1.0));
- ofs=0;
+ if (buttons.size() > 1)
+ sep += Math::floor((size[orientation] - minsize[orientation]) / (buttons.size() - 1.0));
+ ofs = 0;
} break;
case ALIGN_EXPAND_FILL: {
- ofs=0;
- expand=size[orientation] - minsize[orientation];
+ ofs = 0;
+ expand = size[orientation] - minsize[orientation];
} break;
-
-
-
}
- int op_size = orientation==VERTICAL ? size.width : size.height;
-
+ int op_size = orientation == VERTICAL ? size.width : size.height;
- for(int i=0;i<buttons.size();i++) {
+ for (int i = 0; i < buttons.size(); i++) {
int ms = buttons[i]._ms_cache;
- int s=ms;
- if (expand>0) {
- s+=expand/buttons.size();
+ int s = ms;
+ if (expand > 0) {
+ s += expand / buttons.size();
}
- if(min_button_size != -1 && s < min_button_size){
+ if (min_button_size != -1 && s < min_button_size) {
s = min_button_size;
}
Rect2 r;
- r.pos[orientation]=ofs;
- r.pos[!orientation]=0;
- r.size[orientation]=s;
- r.size[!orientation]=op_size;
+ r.pos[orientation] = ofs;
+ r.pos[!orientation] = 0;
+ r.size[orientation] = s;
+ r.size[!orientation] = op_size;
Ref<Font> f;
Color c;
Point2 sbsize;
Point2 sbofs;
- if (i==selected) {
- draw_style_box(style_selected,r);
- sbsize=style_selected->get_minimum_size();
- sbofs=style_selected->get_offset();
- f=font_selected;
- c=color_selected;
+ if (i == selected) {
+ draw_style_box(style_selected, r);
+ sbsize = style_selected->get_minimum_size();
+ sbofs = style_selected->get_offset();
+ f = font_selected;
+ c = color_selected;
if (has_focus())
- draw_style_box(style_focus,r);
+ draw_style_box(style_focus, r);
} else {
- if (hover==i)
- draw_style_box(style_hover,r);
+ if (hover == i)
+ draw_style_box(style_hover, r);
else if (!flat)
- draw_style_box(style_normal,r);
- sbsize=style_normal->get_minimum_size();
- sbofs=style_normal->get_offset();
- f=font_normal;
- c=color_normal;
+ draw_style_box(style_normal, r);
+ sbsize = style_normal->get_minimum_size();
+ sbofs = style_normal->get_offset();
+ f = font_normal;
+ c = color_normal;
}
Size2 ssize = f->get_string_size(buttons[i].xl_text);
if (buttons[i].icon.is_valid()) {
- ssize.x+=buttons[i].icon->get_width();
+ ssize.x += buttons[i].icon->get_width();
}
- Point2 text_ofs=((r.size-ssize-sbsize)/2.0+Point2(0,f->get_ascent())).floor()+sbofs;
+ Point2 text_ofs = ((r.size - ssize - sbsize) / 2.0 + Point2(0, f->get_ascent())).floor() + sbofs;
if (buttons[i].icon.is_valid()) {
- draw_texture(buttons[i].icon,r.pos+Point2(text_ofs.x,Math::floor((r.size.height-buttons[i].icon->get_height())/2.0)));
- text_ofs.x+=buttons[i].icon->get_width()+icon_sep;
-
+ draw_texture(buttons[i].icon, r.pos + Point2(text_ofs.x, Math::floor((r.size.height - buttons[i].icon->get_height()) / 2.0)));
+ text_ofs.x += buttons[i].icon->get_width() + icon_sep;
}
- draw_string(f,text_ofs+r.pos,buttons[i].xl_text,c);
- buttons[i]._pos_cache=ofs;
- buttons[i]._size_cache=s;
+ draw_string(f, text_ofs + r.pos, buttons[i].xl_text, c);
+ buttons[i]._pos_cache = ofs;
+ buttons[i]._size_cache = s;
- ofs+=s;
- ofs+=sep;
+ ofs += s;
+ ofs += sep;
}
} break;
}
}
-
-void ButtonArray::_input_event(const InputEvent& p_event) {
+void ButtonArray::_input_event(const InputEvent &p_event) {
if (
- ( (orientation==HORIZONTAL && p_event.is_action("ui_left") ) ||
- (orientation==VERTICAL && p_event.is_action("ui_up") ) )
- && p_event.is_pressed() && selected>0) {
- set_selected(selected-1);
- accept_event();
- emit_signal("button_selected",selected);
- return;
-
+ ((orientation == HORIZONTAL && p_event.is_action("ui_left")) ||
+ (orientation == VERTICAL && p_event.is_action("ui_up"))) &&
+ p_event.is_pressed() && selected > 0) {
+ set_selected(selected - 1);
+ accept_event();
+ emit_signal("button_selected", selected);
+ return;
}
if (
- ( (orientation==HORIZONTAL && p_event.is_action("ui_right") ) ||
- (orientation==VERTICAL && p_event.is_action("ui_down") ) )
- && p_event.is_pressed() && selected<(buttons.size()-1)) {
- set_selected(selected+1);
- accept_event();
- emit_signal("button_selected",selected);
- return;
-
+ ((orientation == HORIZONTAL && p_event.is_action("ui_right")) ||
+ (orientation == VERTICAL && p_event.is_action("ui_down"))) &&
+ p_event.is_pressed() && selected < (buttons.size() - 1)) {
+ set_selected(selected + 1);
+ accept_event();
+ emit_signal("button_selected", selected);
+ return;
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index == BUTTON_LEFT) {
- int ofs = orientation==HORIZONTAL ? p_event.mouse_button.x: p_event.mouse_button.y;
+ int ofs = orientation == HORIZONTAL ? p_event.mouse_button.x : p_event.mouse_button.y;
- for(int i=0;i<buttons.size();i++) {
+ for (int i = 0; i < buttons.size(); i++) {
- if (ofs>=buttons[i]._pos_cache && ofs<buttons[i]._pos_cache+buttons[i]._size_cache) {
+ if (ofs >= buttons[i]._pos_cache && ofs < buttons[i]._pos_cache + buttons[i]._size_cache) {
set_selected(i);
- emit_signal("button_selected",i);
+ emit_signal("button_selected", i);
return;
}
-
}
}
- if (p_event.type==InputEvent::MOUSE_MOTION) {
+ if (p_event.type == InputEvent::MOUSE_MOTION) {
- int ofs = orientation==HORIZONTAL ? p_event.mouse_motion.x: p_event.mouse_motion.y;
- int new_hover=-1;
- for(int i=0;i<buttons.size();i++) {
+ int ofs = orientation == HORIZONTAL ? p_event.mouse_motion.x : p_event.mouse_motion.y;
+ int new_hover = -1;
+ for (int i = 0; i < buttons.size(); i++) {
- if (ofs>=buttons[i]._pos_cache && ofs<buttons[i]._pos_cache+buttons[i]._size_cache) {
+ if (ofs >= buttons[i]._pos_cache && ofs < buttons[i]._pos_cache + buttons[i]._size_cache) {
- new_hover=i;
+ new_hover = i;
break;
}
-
}
- if (new_hover!=hover) {
- hover=new_hover;
+ if (new_hover != hover) {
+ hover = new_hover;
emit_signal("mouse_sub_enter");
update();
}
}
-
-
}
-String ButtonArray::get_tooltip(const Point2& p_pos) const {
+String ButtonArray::get_tooltip(const Point2 &p_pos) const {
- int ofs = orientation==HORIZONTAL ? p_pos.x: p_pos.y;
- for(int i=0;i<buttons.size();i++) {
+ int ofs = orientation == HORIZONTAL ? p_pos.x : p_pos.y;
+ for (int i = 0; i < buttons.size(); i++) {
- if (ofs>=buttons[i]._pos_cache && ofs<buttons[i]._pos_cache+buttons[i]._size_cache)
+ if (ofs >= buttons[i]._pos_cache && ofs < buttons[i]._pos_cache + buttons[i]._size_cache)
return buttons[i].tooltip;
-
}
return Control::get_tooltip(p_pos);
}
void ButtonArray::set_align(Align p_align) {
- align=p_align;
+ align = p_align;
update();
-
}
ButtonArray::Align ButtonArray::get_align() const {
@@ -391,7 +368,7 @@ ButtonArray::Align ButtonArray::get_align() const {
void ButtonArray::set_flat(bool p_flat) {
- flat=p_flat;
+ flat = p_flat;
update();
}
@@ -400,79 +377,74 @@ bool ButtonArray::is_flat() const {
return flat;
}
-
-void ButtonArray::add_button(const String& p_text,const String& p_tooltip) {
+void ButtonArray::add_button(const String &p_text, const String &p_tooltip) {
Button button;
- button.text=p_text;
- button.xl_text=XL_MESSAGE(p_text);
- button.tooltip=p_tooltip;
+ button.text = p_text;
+ button.xl_text = XL_MESSAGE(p_text);
+ button.tooltip = p_tooltip;
buttons.push_back(button);
update();
- if (selected==-1)
- selected=0;
+ if (selected == -1)
+ selected = 0;
minimum_size_changed();
}
-void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_text,const String& p_tooltip) {
+void ButtonArray::add_icon_button(const Ref<Texture> &p_icon, const String &p_text, const String &p_tooltip) {
Button button;
- button.text=p_text;
- button.xl_text=XL_MESSAGE(p_text);
- button.icon=p_icon;
- button.tooltip=p_tooltip;
+ button.text = p_text;
+ button.xl_text = XL_MESSAGE(p_text);
+ button.icon = p_icon;
+ button.tooltip = p_tooltip;
buttons.push_back(button);
- if (selected==-1)
- selected=0;
+ if (selected == -1)
+ selected = 0;
update();
-
}
-void ButtonArray::set_button_text(int p_button, const String& p_text) {
+void ButtonArray::set_button_text(int p_button, const String &p_text) {
- ERR_FAIL_INDEX(p_button,buttons.size());
- buttons[p_button].text=p_text;
- buttons[p_button].xl_text=XL_MESSAGE(p_text);
+ ERR_FAIL_INDEX(p_button, buttons.size());
+ buttons[p_button].text = p_text;
+ buttons[p_button].xl_text = XL_MESSAGE(p_text);
update();
minimum_size_changed();
-
}
-void ButtonArray::set_button_tooltip(int p_button, const String& p_text) {
-
- ERR_FAIL_INDEX(p_button,buttons.size());
- buttons[p_button].tooltip=p_text;
+void ButtonArray::set_button_tooltip(int p_button, const String &p_text) {
+ ERR_FAIL_INDEX(p_button, buttons.size());
+ buttons[p_button].tooltip = p_text;
}
-void ButtonArray::set_button_icon(int p_button, const Ref<Texture>& p_icon) {
+void ButtonArray::set_button_icon(int p_button, const Ref<Texture> &p_icon) {
- ERR_FAIL_INDEX(p_button,buttons.size());
- buttons[p_button].icon=p_icon;
+ ERR_FAIL_INDEX(p_button, buttons.size());
+ buttons[p_button].icon = p_icon;
update();
minimum_size_changed();
}
String ButtonArray::get_button_text(int p_button) const {
- ERR_FAIL_INDEX_V(p_button,buttons.size(),"");
+ ERR_FAIL_INDEX_V(p_button, buttons.size(), "");
return buttons[p_button].text;
}
String ButtonArray::get_button_tooltip(int p_button) const {
- ERR_FAIL_INDEX_V(p_button,buttons.size(),"");
+ ERR_FAIL_INDEX_V(p_button, buttons.size(), "");
return buttons[p_button].tooltip;
}
Ref<Texture> ButtonArray::get_button_icon(int p_button) const {
- ERR_FAIL_INDEX_V(p_button,buttons.size(),Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_button, buttons.size(), Ref<Texture>());
return buttons[p_button].icon;
-
}
int ButtonArray::get_selected() const {
@@ -487,30 +459,29 @@ int ButtonArray::get_hovered() const {
void ButtonArray::set_selected(int p_selected) {
- ERR_FAIL_INDEX(p_selected,buttons.size());
- selected=p_selected;
+ ERR_FAIL_INDEX(p_selected, buttons.size());
+ selected = p_selected;
update();
-
}
void ButtonArray::erase_button(int p_button) {
- ERR_FAIL_INDEX(p_button,buttons.size());
+ ERR_FAIL_INDEX(p_button, buttons.size());
buttons.remove(p_button);
- if (p_button>=selected)
+ if (p_button >= selected)
selected--;
- if (selected<0)
- selected=0;
- if (selected>=buttons.size())
- selected=buttons.size()-1;
+ if (selected < 0)
+ selected = 0;
+ if (selected >= buttons.size())
+ selected = buttons.size() - 1;
update();
}
-void ButtonArray::clear(){
+void ButtonArray::clear() {
buttons.clear();
- selected=-1;
+ selected = -1;
update();
}
@@ -521,53 +492,50 @@ int ButtonArray::get_button_count() const {
void ButtonArray::get_translatable_strings(List<String> *p_strings) const {
-
- for(int i=0;i<buttons.size();i++) {
+ for (int i = 0; i < buttons.size(); i++) {
p_strings->push_back(buttons[i].text);
p_strings->push_back(buttons[i].tooltip);
}
}
-
void ButtonArray::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_button","text","tooltip"),&ButtonArray::add_button,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("add_icon_button","icon:Texture","text","tooltip"),&ButtonArray::add_icon_button,DEFVAL(""),DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text);
- ObjectTypeDB::bind_method(_MD("set_button_tooltip","button_idx","text"),&ButtonArray::set_button_tooltip);
- ObjectTypeDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon);
- ObjectTypeDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text);
- ObjectTypeDB::bind_method(_MD("get_button_tooltip","button_idx"),&ButtonArray::get_button_tooltip);
- ObjectTypeDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon);
- ObjectTypeDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count);
- ObjectTypeDB::bind_method(_MD("set_flat","enabled"),&ButtonArray::set_flat);
- ObjectTypeDB::bind_method(_MD("is_flat"),&ButtonArray::is_flat);
- ObjectTypeDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected);
- ObjectTypeDB::bind_method(_MD("get_hovered"),&ButtonArray::get_hovered);
- ObjectTypeDB::bind_method(_MD("set_selected","button_idx"),&ButtonArray::set_selected);
- ObjectTypeDB::bind_method(_MD("erase_button","button_idx"),&ButtonArray::erase_button);
- ObjectTypeDB::bind_method(_MD("clear"),&ButtonArray::clear);
-
- ObjectTypeDB::bind_method(_MD("_input_event"),&ButtonArray::_input_event);
+ ObjectTypeDB::bind_method(_MD("add_button", "text", "tooltip"), &ButtonArray::add_button, DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("add_icon_button", "icon:Texture", "text", "tooltip"), &ButtonArray::add_icon_button, DEFVAL(""), DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("set_button_text", "button_idx", "text"), &ButtonArray::set_button_text);
+ ObjectTypeDB::bind_method(_MD("set_button_tooltip", "button_idx", "text"), &ButtonArray::set_button_tooltip);
+ ObjectTypeDB::bind_method(_MD("set_button_icon", "button_idx", "icon:Texture"), &ButtonArray::set_button_icon);
+ ObjectTypeDB::bind_method(_MD("get_button_text", "button_idx"), &ButtonArray::get_button_text);
+ ObjectTypeDB::bind_method(_MD("get_button_tooltip", "button_idx"), &ButtonArray::get_button_tooltip);
+ ObjectTypeDB::bind_method(_MD("get_button_icon:Texture", "button_idx"), &ButtonArray::get_button_icon);
+ ObjectTypeDB::bind_method(_MD("get_button_count"), &ButtonArray::get_button_count);
+ ObjectTypeDB::bind_method(_MD("set_flat", "enabled"), &ButtonArray::set_flat);
+ ObjectTypeDB::bind_method(_MD("is_flat"), &ButtonArray::is_flat);
+ ObjectTypeDB::bind_method(_MD("get_selected"), &ButtonArray::get_selected);
+ ObjectTypeDB::bind_method(_MD("get_hovered"), &ButtonArray::get_hovered);
+ ObjectTypeDB::bind_method(_MD("set_selected", "button_idx"), &ButtonArray::set_selected);
+ ObjectTypeDB::bind_method(_MD("erase_button", "button_idx"), &ButtonArray::erase_button);
+ ObjectTypeDB::bind_method(_MD("clear"), &ButtonArray::clear);
- BIND_CONSTANT( ALIGN_BEGIN );
- BIND_CONSTANT( ALIGN_CENTER );
- BIND_CONSTANT( ALIGN_END );
- BIND_CONSTANT( ALIGN_FILL );
- BIND_CONSTANT( ALIGN_EXPAND_FILL );
+ ObjectTypeDB::bind_method(_MD("_input_event"), &ButtonArray::_input_event);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") );
+ BIND_CONSTANT(ALIGN_BEGIN);
+ BIND_CONSTANT(ALIGN_CENTER);
+ BIND_CONSTANT(ALIGN_END);
+ BIND_CONSTANT(ALIGN_FILL);
+ BIND_CONSTANT(ALIGN_EXPAND_FILL);
- ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::INT,"button_idx")));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), _SCS("set_flat"), _SCS("is_flat"));
+ ADD_SIGNAL(MethodInfo("button_selected", PropertyInfo(Variant::INT, "button_idx")));
}
ButtonArray::ButtonArray(Orientation p_orientation) {
- orientation=p_orientation;
- selected=-1;
+ orientation = p_orientation;
+ selected = -1;
set_focus_mode(FOCUS_ALL);
- hover=-1;
- flat=false;
+ hover = -1;
+ flat = false;
min_button_size = -1;
}
diff --git a/scene/gui/button_array.h b/scene/gui/button_array.h
index d01ac08cc..19835d115 100644
--- a/scene/gui/button_array.h
+++ b/scene/gui/button_array.h
@@ -34,6 +34,7 @@
class ButtonArray : public Control {
OBJ_TYPE(ButtonArray, Control);
+
public:
enum Align {
ALIGN_BEGIN,
@@ -42,8 +43,8 @@ public:
ALIGN_FILL,
ALIGN_EXPAND_FILL
};
-private:
+private:
Orientation orientation;
Align align;
@@ -64,19 +65,17 @@ private:
double min_button_size;
Vector<Button> buttons;
-protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_what);
static void _bind_methods();
public:
-
- void _input_event(const InputEvent& p_event);
-
+ void _input_event(const InputEvent &p_event);
void set_align(Align p_align);
Align get_align() const;
@@ -84,13 +83,12 @@ public:
void set_flat(bool p_flat);
bool is_flat() const;
- void add_button(const String& p_button,const String& p_tooltip="");
- void add_icon_button(const Ref<Texture>& p_icon,const String& p_button="",const String& p_tooltip="");
-
- void set_button_text(int p_button, const String& p_text);
- void set_button_tooltip(int p_button, const String& p_text);
- void set_button_icon(int p_button, const Ref<Texture>& p_icon);
+ void add_button(const String &p_button, const String &p_tooltip = "");
+ void add_icon_button(const Ref<Texture> &p_icon, const String &p_button = "", const String &p_tooltip = "");
+ void set_button_text(int p_button, const String &p_text);
+ void set_button_tooltip(int p_button, const String &p_text);
+ void set_button_icon(int p_button, const Ref<Texture> &p_icon);
String get_button_text(int p_button) const;
String get_button_tooltip(int p_button) const;
@@ -108,25 +106,25 @@ public:
virtual Size2 get_minimum_size() const;
virtual void get_translatable_strings(List<String> *p_strings) const;
- virtual String get_tooltip(const Point2& p_pos) const;
-
+ virtual String get_tooltip(const Point2 &p_pos) const;
- ButtonArray(Orientation p_orientation=HORIZONTAL);
+ ButtonArray(Orientation p_orientation = HORIZONTAL);
};
class HButtonArray : public ButtonArray {
- OBJ_TYPE(HButtonArray,ButtonArray);
-public:
+ OBJ_TYPE(HButtonArray, ButtonArray);
- HButtonArray() : ButtonArray(HORIZONTAL) {};
+public:
+ HButtonArray()
+ : ButtonArray(HORIZONTAL){};
};
class VButtonArray : public ButtonArray {
- OBJ_TYPE(VButtonArray,ButtonArray);
-public:
+ OBJ_TYPE(VButtonArray, ButtonArray);
- VButtonArray() : ButtonArray(VERTICAL) {};
+public:
+ VButtonArray()
+ : ButtonArray(VERTICAL){};
};
-
#endif // BUTTON_ARRAY_H
diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp
index 1c8192d58..b06959cbb 100644
--- a/scene/gui/button_group.cpp
+++ b/scene/gui/button_group.cpp
@@ -34,15 +34,13 @@ void ButtonGroup::_add_button(BaseButton *p_button) {
buttons.insert(p_button);
p_button->set_toggle_mode(true);
p_button->set_click_on_press(true);
- p_button->connect("pressed",this,"_pressed",make_binds(p_button));
-
+ p_button->connect("pressed", this, "_pressed", make_binds(p_button));
}
-void ButtonGroup::_remove_button(BaseButton *p_button){
+void ButtonGroup::_remove_button(BaseButton *p_button) {
buttons.erase(p_button);
- p_button->disconnect("pressed",this,"_pressed");
-
+ p_button->disconnect("pressed", this, "_pressed");
}
void ButtonGroup::set_pressed_button(BaseButton *p_button) {
@@ -53,14 +51,14 @@ void ButtonGroup::set_pressed_button(BaseButton *p_button) {
void ButtonGroup::_pressed(Object *p_button) {
ERR_FAIL_NULL(p_button);
- BaseButton *b=p_button->cast_to<BaseButton>();
+ BaseButton *b = p_button->cast_to<BaseButton>();
ERR_FAIL_COND(!b);
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
- BaseButton *bb=E->get();
- bb->set_pressed( b==bb );
- if (b==bb){
+ BaseButton *bb = E->get();
+ bb->set_pressed(b == bb);
+ if (b == bb) {
emit_signal("button_selected", b);
}
}
@@ -68,7 +66,7 @@ void ButtonGroup::_pressed(Object *p_button) {
Array ButtonGroup::_get_button_list() const {
- List<BaseButton*> b;
+ List<BaseButton *> b;
get_button_list(&b);
b.sort_custom<Node::Comparator>();
@@ -76,19 +74,19 @@ Array ButtonGroup::_get_button_list() const {
Array arr;
arr.resize(b.size());
- int idx=0;
+ int idx = 0;
- for(List<BaseButton*>::Element *E=b.front();E;E=E->next(),idx++) {
+ for (List<BaseButton *>::Element *E = b.front(); E; E = E->next(), idx++) {
- arr[idx]=E->get();
+ arr[idx] = E->get();
}
return arr;
}
-void ButtonGroup::get_button_list(List<BaseButton*> *p_buttons) const {
+void ButtonGroup::get_button_list(List<BaseButton *> *p_buttons) const {
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
p_buttons->push_back(E->get());
}
@@ -96,7 +94,7 @@ void ButtonGroup::get_button_list(List<BaseButton*> *p_buttons) const {
BaseButton *ButtonGroup::get_pressed_button() const {
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
if (E->get()->is_pressed())
return E->get();
@@ -105,40 +103,38 @@ BaseButton *ButtonGroup::get_pressed_button() const {
return NULL;
}
-BaseButton *ButtonGroup::get_focused_button() const{
+BaseButton *ButtonGroup::get_focused_button() const {
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
if (E->get()->has_focus())
return E->get();
}
return NULL;
-
}
int ButtonGroup::get_pressed_button_index() const {
//in tree order, this is bizarre
- ERR_FAIL_COND_V(!is_inside_tree(),0);
+ ERR_FAIL_COND_V(!is_inside_tree(), 0);
BaseButton *pressed = get_pressed_button();
if (!pressed)
return -1;
- List<BaseButton*> blist;
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ List<BaseButton *> blist;
+ for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
blist.push_back(E->get());
-
}
blist.sort_custom<Node::Comparator>();
- int idx=0;
- for(List<BaseButton*>::Element *E=blist.front();E;E=E->next()) {
+ int idx = 0;
+ for (List<BaseButton *>::Element *E = blist.front(); E; E = E->next()) {
- if (E->get()==pressed)
+ if (E->get() == pressed)
return idx;
idx++;
@@ -149,16 +145,16 @@ int ButtonGroup::get_pressed_button_index() const {
void ButtonGroup::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
- ObjectTypeDB::bind_method(_MD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
- ObjectTypeDB::bind_method(_MD("get_focused_button:BaseButton"),&ButtonGroup::get_focused_button);
- ObjectTypeDB::bind_method(_MD("get_button_list"),&ButtonGroup::_get_button_list);
- ObjectTypeDB::bind_method(_MD("_pressed"),&ButtonGroup::_pressed);
- ObjectTypeDB::bind_method(_MD("set_pressed_button","button:BaseButton"),&ButtonGroup::_pressed);
+ ObjectTypeDB::bind_method(_MD("get_pressed_button:BaseButton"), &ButtonGroup::get_pressed_button);
+ ObjectTypeDB::bind_method(_MD("get_pressed_button_index"), &ButtonGroup::get_pressed_button_index);
+ ObjectTypeDB::bind_method(_MD("get_focused_button:BaseButton"), &ButtonGroup::get_focused_button);
+ ObjectTypeDB::bind_method(_MD("get_button_list"), &ButtonGroup::_get_button_list);
+ ObjectTypeDB::bind_method(_MD("_pressed"), &ButtonGroup::_pressed);
+ ObjectTypeDB::bind_method(_MD("set_pressed_button", "button:BaseButton"), &ButtonGroup::_pressed);
- ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::OBJECT,"button",PROPERTY_HINT_RESOURCE_TYPE,"BaseButton")));
+ ADD_SIGNAL(MethodInfo("button_selected", PropertyInfo(Variant::OBJECT, "button", PROPERTY_HINT_RESOURCE_TYPE, "BaseButton")));
}
-ButtonGroup::ButtonGroup() : BoxContainer(true)
-{
+ButtonGroup::ButtonGroup()
+ : BoxContainer(true) {
}
diff --git a/scene/gui/button_group.h b/scene/gui/button_group.h
index 3ec53247e..1ce707a9b 100644
--- a/scene/gui/button_group.h
+++ b/scene/gui/button_group.h
@@ -31,30 +31,27 @@
#include "scene/gui/box_container.h"
-
class BaseButton;
class ButtonGroup : public BoxContainer {
- OBJ_TYPE(ButtonGroup,BoxContainer);
-
-
- Set<BaseButton*> buttons;
+ OBJ_TYPE(ButtonGroup, BoxContainer);
+ Set<BaseButton *> buttons;
Array _get_button_list() const;
void _pressed(Object *p_button);
protected:
-friend class BaseButton;
+ friend class BaseButton;
void _add_button(BaseButton *p_button);
void _remove_button(BaseButton *p_button);
static void _bind_methods();
-public:
- void get_button_list(List<BaseButton*> *p_buttons) const;
+public:
+ void get_button_list(List<BaseButton *> *p_buttons) const;
BaseButton *get_pressed_button() const;
BaseButton *get_focused_button() const;
void set_pressed_button(BaseButton *p_button);
diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp
index 14721cbc2..062b34bfa 100644
--- a/scene/gui/center_container.cpp
+++ b/scene/gui/center_container.cpp
@@ -28,14 +28,12 @@
/*************************************************************************/
#include "center_container.h"
-
Size2 CenterContainer::get_minimum_size() const {
-
if (use_top_left)
return Size2();
Size2 ms;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -45,22 +43,17 @@ Size2 CenterContainer::get_minimum_size() const {
if (c->is_hidden())
continue;
Size2 minsize = c->get_combined_minimum_size();
- ms.width = MAX(ms.width , minsize.width);
- ms.height = MAX(ms.height , minsize.height);
-
-
+ ms.width = MAX(ms.width, minsize.width);
+ ms.height = MAX(ms.height, minsize.height);
}
return ms;
-
}
-
void CenterContainer::set_use_top_left(bool p_enable) {
- use_top_left=p_enable;
+ use_top_left = p_enable;
queue_sort();
-
}
bool CenterContainer::is_using_top_left() const {
@@ -68,13 +61,12 @@ bool CenterContainer::is_using_top_left() const {
return use_top_left;
}
-
void CenterContainer::_notification(int p_what) {
- if (p_what==NOTIFICATION_SORT_CHILDREN) {
+ if (p_what == NOTIFICATION_SORT_CHILDREN) {
Size2 size = get_size();
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -83,22 +75,21 @@ void CenterContainer::_notification(int p_what) {
continue;
Size2 minsize = c->get_combined_minimum_size();
- Point2 ofs = use_top_left ? (-minsize*0.5).floor() : ((size - minsize)/2.0).floor();
- fit_child_in_rect(c,Rect2(ofs,minsize));
-
+ Point2 ofs = use_top_left ? (-minsize * 0.5).floor() : ((size - minsize) / 2.0).floor();
+ fit_child_in_rect(c, Rect2(ofs, minsize));
}
}
}
void CenterContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_use_top_left","enable"),&CenterContainer::set_use_top_left);
- ObjectTypeDB::bind_method(_MD("is_using_top_left"),&CenterContainer::is_using_top_left);
+ ObjectTypeDB::bind_method(_MD("set_use_top_left", "enable"), &CenterContainer::set_use_top_left);
+ ObjectTypeDB::bind_method(_MD("is_using_top_left"), &CenterContainer::is_using_top_left);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"use_top_left"),_SCS("set_use_top_left"),_SCS("is_using_top_left"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_top_left"), _SCS("set_use_top_left"), _SCS("is_using_top_left"));
}
CenterContainer::CenterContainer() {
- use_top_left=false;
+ use_top_left = false;
}
diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h
index 58ea9e587..777f6c68b 100644
--- a/scene/gui/center_container.h
+++ b/scene/gui/center_container.h
@@ -29,20 +29,19 @@
#ifndef CENTER_CONTAINER_H
#define CENTER_CONTAINER_H
-
#include "scene/gui/container.h"
class CenterContainer : public Container {
- OBJ_TYPE( CenterContainer, Container );
+ OBJ_TYPE(CenterContainer, Container);
bool use_top_left;
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_use_top_left(bool p_enable);
bool is_using_top_left() const;
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
index 901386eb4..f58d6d86f 100644
--- a/scene/gui/check_box.cpp
+++ b/scene/gui/check_box.cpp
@@ -28,52 +28,45 @@
/*************************************************************************/
#include "check_box.h"
-#include "servers/visual_server.h"
#include "button_group.h"
-
+#include "servers/visual_server.h"
void CheckBox::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
- RID ci = get_canvas_item();
+ RID ci = get_canvas_item();
- Ref<Texture> on=Control::get_icon(is_radio() ? "radio_checked" : "checked");
- Ref<Texture> off=Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked");
+ Ref<Texture> on = Control::get_icon(is_radio() ? "radio_checked" : "checked");
+ Ref<Texture> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked");
- Vector2 ofs;
- ofs.x = 0;
- ofs.y = int((get_size().height - on->get_height())/2);
+ Vector2 ofs;
+ ofs.x = 0;
+ ofs.y = int((get_size().height - on->get_height()) / 2);
- if (is_pressed())
- on->draw(ci,ofs);
- else
- off->draw(ci,ofs);
-
-
- }
+ if (is_pressed())
+ on->draw(ci, ofs);
+ else
+ off->draw(ci, ofs);
+ }
}
-bool CheckBox::is_radio()
-{
- Node* parent = this;
- do {
- parent = parent->get_parent();
- if (parent->cast_to<ButtonGroup>())
- break;
- } while (parent);
+bool CheckBox::is_radio() {
+ Node *parent = this;
+ do {
+ parent = parent->get_parent();
+ if (parent->cast_to<ButtonGroup>())
+ break;
+ } while (parent);
- return (parent != 0);
+ return (parent != 0);
}
-CheckBox::CheckBox(const String &p_text):
- Button(p_text)
-{
- set_toggle_mode(true);
- set_text_align(ALIGN_LEFT);
-
+CheckBox::CheckBox(const String &p_text)
+ : Button(p_text) {
+ set_toggle_mode(true);
+ set_text_align(ALIGN_LEFT);
}
-CheckBox::~CheckBox()
-{
+CheckBox::~CheckBox() {
}
diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h
index 631d46a9e..53526de30 100644
--- a/scene/gui/check_box.h
+++ b/scene/gui/check_box.h
@@ -29,27 +29,22 @@
#ifndef CHECK_BOX_H
#define CHECK_BOX_H
-
#include "scene/gui/button.h"
/**
@author Mariano Suligoy <marianognu.esyrpg@gmail.com>
*/
class CheckBox : public Button {
- OBJ_TYPE( CheckBox, Button );
-
+ OBJ_TYPE(CheckBox, Button);
protected:
- void _notification(int p_what);
-
- bool is_radio();
+ void _notification(int p_what);
+ bool is_radio();
public:
-
- CheckBox(const String& p_text=String());
- ~CheckBox();
-
+ CheckBox(const String &p_text = String());
+ ~CheckBox();
};
#endif
diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp
index 6404f066e..6b24e0889 100644
--- a/scene/gui/check_button.cpp
+++ b/scene/gui/check_button.cpp
@@ -28,45 +28,34 @@
/*************************************************************************/
#include "check_button.h"
-#include "servers/visual_server.h"
#include "print_string.h"
-
+#include "servers/visual_server.h"
void CheckButton::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
- Ref<Texture> on=Control::get_icon("on");
- Ref<Texture> off=Control::get_icon("off");
+ Ref<Texture> on = Control::get_icon("on");
+ Ref<Texture> off = Control::get_icon("off");
Vector2 ofs;
ofs.x = get_size().width - on->get_width();
- ofs.y = int((get_size().height - on->get_height())/2);
+ ofs.y = int((get_size().height - on->get_height()) / 2);
if (is_pressed())
- on->draw(ci,ofs);
+ on->draw(ci, ofs);
else
- off->draw(ci,ofs);
-
-
+ off->draw(ci, ofs);
}
}
-
CheckButton::CheckButton() {
set_toggle_mode(true);
set_text_align(ALIGN_LEFT);
-
-
}
-
-CheckButton::~CheckButton()
-{
+CheckButton::~CheckButton() {
}
-
-
-
diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h
index aa7190a37..6845209e2 100644
--- a/scene/gui/check_button.h
+++ b/scene/gui/check_button.h
@@ -29,24 +29,20 @@
#ifndef CHECK_BUTTON_H
#define CHECK_BUTTON_H
-
#include "scene/gui/button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class CheckButton : public Button {
- OBJ_TYPE( CheckButton, Button );
-
+ OBJ_TYPE(CheckButton, Button);
protected:
void _notification(int p_what);
public:
-
CheckButton();
~CheckButton();
-
};
#endif
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index b06865268..1c23be8c8 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -28,51 +28,48 @@
/*************************************************************************/
#include "color_picker.h"
-#include "scene/gui/separator.h"
-#include "scene/main/viewport.h"
-#include "os/os.h"
#include "os/input.h"
#include "os/keyboard.h"
+#include "os/os.h"
+#include "scene/gui/separator.h"
+#include "scene/main/viewport.h"
-void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color,float h,float s,float v) {
+void update_material(Ref<CanvasItemMaterial> mat, const Color &p_color, float h, float s, float v) {
if (!mat.is_valid())
return;
Ref<Shader> sdr = mat->get_shader();
if (!sdr.is_valid())
return;
- mat->set_shader_param("R",p_color.r);
- mat->set_shader_param("G",p_color.g);
- mat->set_shader_param("B",p_color.b);
- mat->set_shader_param("H",h);
- mat->set_shader_param("S",s);
- mat->set_shader_param("V",v);
- mat->set_shader_param("A",p_color.a);
+ mat->set_shader_param("R", p_color.r);
+ mat->set_shader_param("G", p_color.g);
+ mat->set_shader_param("B", p_color.b);
+ mat->set_shader_param("H", h);
+ mat->set_shader_param("S", s);
+ mat->set_shader_param("V", v);
+ mat->set_shader_param("A", p_color.a);
}
void ColorPicker::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
uv_material->set_shader(get_shader("uv_editor"));
w_material->set_shader(get_shader("w_editor"));
- update_material(uv_material,color,h,s,v);
- update_material(w_material,color,h,s,v);
+ update_material(uv_material, color, h, s, v);
+ update_material(w_material, color, h, s, v);
_update_controls();
} break;
case NOTIFICATION_ENTER_TREE: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
- update_material(uv_material, color,h,s,v);
- update_material(w_material, color,h,s,v);
+ update_material(uv_material, color, h, s, v);
+ update_material(w_material, color, h, s, v);
uv_edit->get_child(0)->cast_to<Control>()->update();
w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
}
-
-
}
}
@@ -93,34 +90,32 @@ void ColorPicker::_update_controls() {
scroll[3]->hide();
labels[3]->hide();
}
-
}
-void ColorPicker::set_color(const Color& p_color) {
+void ColorPicker::set_color(const Color &p_color) {
- color=p_color;
+ color = p_color;
if (color != last_hsv) {
- h=color.get_h();
- s=color.get_s();
- v=color.get_v();
+ h = color.get_h();
+ s = color.get_s();
+ v = color.get_v();
last_hsv = color;
}
if (!is_inside_tree())
return;
- update_material(uv_material, color,h,s,v);
- update_material(w_material, color,h,s,v);
+ update_material(uv_material, color, h, s, v);
+ update_material(w_material, color, h, s, v);
uv_edit->get_child(0)->cast_to<Control>()->update();
w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
-
}
void ColorPicker::set_edit_alpha(bool p_show) {
- edit_alpha=p_show;
+ edit_alpha = p_show;
_update_controls();
if (!is_inside_tree())
@@ -140,19 +135,18 @@ void ColorPicker::_value_changed(double) {
if (updating)
return;
- for(int i=0;i<4;i++) {
- color.components[i] = scroll[i]->get_val()/(raw_mode_enabled?1.0:255.0);
+ for (int i = 0; i < 4; i++) {
+ color.components[i] = scroll[i]->get_val() / (raw_mode_enabled ? 1.0 : 255.0);
}
set_color(color);
_update_text_value();
- emit_signal("color_changed",color);
-
+ emit_signal("color_changed", color);
}
-void ColorPicker::_html_entered(const String& p_html) {
+void ColorPicker::_html_entered(const String &p_html) {
if (updating)
return;
@@ -163,14 +157,14 @@ void ColorPicker::_html_entered(const String& p_html) {
return;
set_color(color);
- emit_signal("color_changed",color);
+ emit_signal("color_changed", color);
}
void ColorPicker::_update_color() {
- updating=true;
+ updating = true;
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
scroll[i]->set_max(255);
scroll[i]->set_step(0.01);
if (raw_mode_enabled) {
@@ -185,25 +179,23 @@ void ColorPicker::_update_color() {
_update_text_value();
sample->update();
- updating=false;
+ updating = false;
}
-void ColorPicker::_update_presets()
-{
- Size2 size=bt_add_preset->get_size();
- preset->set_custom_minimum_size(Size2(size.width*presets.size(),size.height));
- Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB);
- for (int y=0;y<size.y;y++)
- for (int x=0;x<size.x*presets.size();x++)
- i.put_pixel(x,y,presets[(int)x/size.x]);
+void ColorPicker::_update_presets() {
+ Size2 size = bt_add_preset->get_size();
+ preset->set_custom_minimum_size(Size2(size.width * presets.size(), size.height));
+ Image i(size.x * presets.size(), size.y, false, Image::FORMAT_RGB);
+ for (int y = 0; y < size.y; y++)
+ for (int x = 0; x < size.x * presets.size(); x++)
+ i.put_pixel(x, y, presets[(int)x / size.x]);
Ref<ImageTexture> t;
t.instance();
t->create_from_image(i);
preset->set_texture(t);
}
-void ColorPicker::_text_type_toggled()
-{
+void ColorPicker::_text_type_toggled() {
if (!get_tree()->is_editor_hint())
return;
text_is_constructor = !text_is_constructor;
@@ -222,25 +214,23 @@ Color ColorPicker::get_color() const {
return color;
}
-void ColorPicker::add_preset(const Color &p_color)
-{
+void ColorPicker::add_preset(const Color &p_color) {
if (presets.find(p_color)) {
presets.move_to_back(presets.find(p_color));
} else {
presets.push_back(p_color);
}
_update_presets();
- if (presets.size()==10)
+ if (presets.size() == 10)
bt_add_preset->hide();
}
-
void ColorPicker::set_raw_mode(bool p_enabled) {
- if (raw_mode_enabled==p_enabled)
+ if (raw_mode_enabled == p_enabled)
return;
- raw_mode_enabled=p_enabled;
- if (btn_mode->is_pressed()!=p_enabled)
+ raw_mode_enabled = p_enabled;
+ if (btn_mode->is_pressed() != p_enabled)
btn_mode->set_pressed(p_enabled);
if (!is_inside_tree())
@@ -255,54 +245,52 @@ bool ColorPicker::is_raw_mode() const {
return raw_mode_enabled;
}
-
void ColorPicker::_update_text_value() {
if (text_is_constructor) {
- String t = "Color("+String::num(color.r)+","+String::num(color.g)+","+String::num(color.b);
- if (edit_alpha && color.a<1)
- t+=(","+String::num(color.a)+")") ;
+ String t = "Color(" + String::num(color.r) + "," + String::num(color.g) + "," + String::num(color.b);
+ if (edit_alpha && color.a < 1)
+ t += ("," + String::num(color.a) + ")");
else
- t+=")";
+ t += ")";
c_text->set_text(t);
} else {
- c_text->set_text(color.to_html(edit_alpha && color.a<1));
+ c_text->set_text(color.to_html(edit_alpha && color.a < 1));
}
}
void ColorPicker::_sample_draw() {
- sample->draw_rect(Rect2(Point2(),Size2(256,20)),color);
+ sample->draw_rect(Rect2(Point2(), Size2(256, 20)), color);
}
-void ColorPicker::_hsv_draw(int p_wich,Control* c)
-{
+void ColorPicker::_hsv_draw(int p_wich, Control *c) {
if (!c)
return;
- if (p_wich==0) {
+ if (p_wich == 0) {
int x = CLAMP(c->get_size().x * s, 0, c->get_size().x);
- int y = CLAMP(c->get_size().y-c->get_size().y * v, 0, c->get_size().y);
+ int y = CLAMP(c->get_size().y - c->get_size().y * v, 0, c->get_size().y);
Color col = color;
- col.a=1;
- c->draw_line(Point2(x,0),Point2(x,c->get_size().y),col.inverted());
- c->draw_line(Point2(0, y),Point2(c->get_size().x, y),col.inverted());
- c->draw_line(Point2(x,y),Point2(x,y),Color(1,1,1),2);
- } else if (p_wich==1) {
- int y=c->get_size().y-c->get_size().y*h;
- Color col=Color();
- col.set_hsv(h,1,1);
- c->draw_line(Point2(0,y),Point2(c->get_size().x,y),col.inverted());
+ col.a = 1;
+ c->draw_line(Point2(x, 0), Point2(x, c->get_size().y), col.inverted());
+ c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted());
+ c->draw_line(Point2(x, y), Point2(x, y), Color(1, 1, 1), 2);
+ } else if (p_wich == 1) {
+ int y = c->get_size().y - c->get_size().y * h;
+ Color col = Color();
+ col.set_hsv(h, 1, 1);
+ c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted());
}
}
void ColorPicker::_uv_input(const InputEvent &ev) {
if (ev.type == InputEvent::MOUSE_BUTTON) {
const InputEventMouseButton &bev = ev.mouse_button;
- if (bev.pressed && bev.button_index==BUTTON_LEFT) {
+ if (bev.pressed && bev.button_index == BUTTON_LEFT) {
changing_color = true;
- float x = CLAMP((float)bev.x,0,256);
- float y = CLAMP((float)bev.y,0,256);
- s=x/256;
- v=1.0-y/256.0;
- color.set_hsv(h,s,v,color.a);
+ float x = CLAMP((float)bev.x, 0, 256);
+ float y = CLAMP((float)bev.y, 0, 256);
+ s = x / 256;
+ v = 1.0 - y / 256.0;
+ color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_color(color);
_update_color();
@@ -314,11 +302,11 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
const InputEventMouse &bev = ev.mouse_motion;
if (!changing_color)
return;
- float x = CLAMP((float)bev.x,0,256);
- float y = CLAMP((float)bev.y,0,256);
- s=x/256;
- v=1.0-y/256.0;
- color.set_hsv(h,s,v,color.a);
+ float x = CLAMP((float)bev.x, 0, 256);
+ float y = CLAMP((float)bev.y, 0, 256);
+ s = x / 256;
+ v = 1.0 - y / 256.0;
+ color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_color(color);
_update_color();
@@ -329,14 +317,14 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
void ColorPicker::_w_input(const InputEvent &ev) {
if (ev.type == InputEvent::MOUSE_BUTTON) {
const InputEventMouseButton &bev = ev.mouse_button;
- if (bev.pressed && bev.button_index==BUTTON_LEFT) {
+ if (bev.pressed && bev.button_index == BUTTON_LEFT) {
changing_color = true;
- h=1-((float)bev.y)/256.0;
+ h = 1 - ((float)bev.y) / 256.0;
} else {
changing_color = false;
}
- color.set_hsv(h,s,v,color.a);
+ color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_color(color);
_update_color();
@@ -345,9 +333,9 @@ void ColorPicker::_w_input(const InputEvent &ev) {
const InputEventMouse &bev = ev.mouse_motion;
if (!changing_color)
return;
- float y = CLAMP((float)bev.y,0,256);
- h=1.0-y/256.0;
- color.set_hsv(h,s,v,color.a);
+ float y = CLAMP((float)bev.y, 0, 256);
+ h = 1.0 - y / 256.0;
+ color.set_hsv(h, s, v, color.a);
last_hsv = color;
set_color(color);
_update_color();
@@ -358,11 +346,11 @@ void ColorPicker::_w_input(const InputEvent &ev) {
void ColorPicker::_preset_input(const InputEvent &ev) {
if (ev.type == InputEvent::MOUSE_BUTTON) {
const InputEventMouseButton &bev = ev.mouse_button;
- if (bev.pressed && bev.button_index==BUTTON_LEFT) {
- int index = bev.x/(preset->get_size().x/presets.size());
+ if (bev.pressed && bev.button_index == BUTTON_LEFT) {
+ int index = bev.x / (preset->get_size().x / presets.size());
set_color(presets[index]);
- } else if (bev.pressed && bev.button_index==BUTTON_RIGHT) {
- int index = bev.x/(preset->get_size().x/presets.size());
+ } else if (bev.pressed && bev.button_index == BUTTON_RIGHT) {
+ int index = bev.x / (preset->get_size().x / presets.size());
presets.erase(presets[index]);
_update_presets();
bt_add_preset->show();
@@ -372,36 +360,35 @@ void ColorPicker::_preset_input(const InputEvent &ev) {
} else if (ev.type == InputEvent::MOUSE_MOTION) {
const InputEventMouse &mev = ev.mouse_motion;
int index = mev.x * presets.size();
- if( preset->get_size().x != 0 ) {
+ if (preset->get_size().x != 0) {
index /= preset->get_size().x;
}
- if (index<0 || index >= presets.size())
+ if (index < 0 || index >= presets.size())
return;
- preset->set_tooltip("Color: #"+presets[index].to_html(presets[index].a<1)+"\n"
- "LMB: Set color\n"
- "RMB: Remove preset");
+ preset->set_tooltip("Color: #" + presets[index].to_html(presets[index].a < 1) + "\n"
+ "LMB: Set color\n"
+ "RMB: Remove preset");
}
}
-void ColorPicker::_screen_input(const InputEvent &ev)
-{
- if (ev.type==InputEvent::MOUSE_BUTTON) {
+void ColorPicker::_screen_input(const InputEvent &ev) {
+ if (ev.type == InputEvent::MOUSE_BUTTON) {
const InputEventMouseButton &bev = ev.mouse_button;
- if (bev.button_index==BUTTON_LEFT&&!bev.pressed) {
+ if (bev.button_index == BUTTON_LEFT && !bev.pressed) {
emit_signal("color_changed", color);
screen->hide();
}
- } else if (ev.type==InputEvent::MOUSE_MOTION) {
+ } else if (ev.type == InputEvent::MOUSE_MOTION) {
const InputEventMouse &mev = ev.mouse_motion;
- Viewport *r=get_tree()->get_root();
- if (!r->get_rect().has_point(Point2(mev.global_x,mev.global_y)))
+ Viewport *r = get_tree()->get_root();
+ if (!r->get_rect().has_point(Point2(mev.global_x, mev.global_y)))
return;
- Image img =r->get_screen_capture();
+ Image img = r->get_screen_capture();
if (!img.empty())
- last_capture=img;
- r->queue_screen_capture();
+ last_capture = img;
+ r->queue_screen_capture();
if (!last_capture.empty())
- set_color(last_capture.get_pixel(mev.global_x,mev.global_y));
+ set_color(last_capture.get_pixel(mev.global_x, mev.global_y));
}
}
@@ -409,15 +396,14 @@ void ColorPicker::_add_preset_pressed() {
add_preset(color);
}
-void ColorPicker::_screen_pick_pressed()
-{
- Viewport *r=get_tree()->get_root();
+void ColorPicker::_screen_pick_pressed() {
+ Viewport *r = get_tree()->get_root();
if (!screen) {
- screen=memnew( Control );
+ screen = memnew(Control);
r->add_child(screen);
screen->set_as_toplevel(true);
screen->set_area_as_parent_rect();
- screen->connect("input_event",this,"_screen_input");
+ screen->connect("input_event", this, "_screen_input");
}
screen->raise();
screen->show_modal();
@@ -426,158 +412,155 @@ void ColorPicker::_screen_pick_pressed()
void ColorPicker::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_color","color"),&ColorPicker::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&ColorPicker::get_color);
- ObjectTypeDB::bind_method(_MD("set_raw_mode","mode"),&ColorPicker::set_raw_mode);
- ObjectTypeDB::bind_method(_MD("is_raw_mode"),&ColorPicker::is_raw_mode);
- ObjectTypeDB::bind_method(_MD("set_edit_alpha","show"),&ColorPicker::set_edit_alpha);
- ObjectTypeDB::bind_method(_MD("is_editing_alpha"),&ColorPicker::is_editing_alpha);
+ ObjectTypeDB::bind_method(_MD("set_color", "color"), &ColorPicker::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color"), &ColorPicker::get_color);
+ ObjectTypeDB::bind_method(_MD("set_raw_mode", "mode"), &ColorPicker::set_raw_mode);
+ ObjectTypeDB::bind_method(_MD("is_raw_mode"), &ColorPicker::is_raw_mode);
+ ObjectTypeDB::bind_method(_MD("set_edit_alpha", "show"), &ColorPicker::set_edit_alpha);
+ ObjectTypeDB::bind_method(_MD("is_editing_alpha"), &ColorPicker::is_editing_alpha);
ObjectTypeDB::bind_method(_MD("add_preset"), &ColorPicker::add_preset);
- ObjectTypeDB::bind_method(_MD("_value_changed"),&ColorPicker::_value_changed);
- ObjectTypeDB::bind_method(_MD("_html_entered"),&ColorPicker::_html_entered);
- ObjectTypeDB::bind_method(_MD("_text_type_toggled"),&ColorPicker::_text_type_toggled);
+ ObjectTypeDB::bind_method(_MD("_value_changed"), &ColorPicker::_value_changed);
+ ObjectTypeDB::bind_method(_MD("_html_entered"), &ColorPicker::_html_entered);
+ ObjectTypeDB::bind_method(_MD("_text_type_toggled"), &ColorPicker::_text_type_toggled);
ObjectTypeDB::bind_method(_MD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed);
ObjectTypeDB::bind_method(_MD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed);
- ObjectTypeDB::bind_method(_MD("_sample_draw"),&ColorPicker::_sample_draw);
- ObjectTypeDB::bind_method(_MD("_hsv_draw"),&ColorPicker::_hsv_draw);
- ObjectTypeDB::bind_method(_MD("_uv_input"),&ColorPicker::_uv_input);
- ObjectTypeDB::bind_method(_MD("_w_input"),&ColorPicker::_w_input);
- ObjectTypeDB::bind_method(_MD("_preset_input"),&ColorPicker::_preset_input);
- ObjectTypeDB::bind_method(_MD("_screen_input"),&ColorPicker::_screen_input);
+ ObjectTypeDB::bind_method(_MD("_sample_draw"), &ColorPicker::_sample_draw);
+ ObjectTypeDB::bind_method(_MD("_hsv_draw"), &ColorPicker::_hsv_draw);
+ ObjectTypeDB::bind_method(_MD("_uv_input"), &ColorPicker::_uv_input);
+ ObjectTypeDB::bind_method(_MD("_w_input"), &ColorPicker::_w_input);
+ ObjectTypeDB::bind_method(_MD("_preset_input"), &ColorPicker::_preset_input);
+ ObjectTypeDB::bind_method(_MD("_screen_input"), &ColorPicker::_screen_input);
- ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color")));
+ ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color")));
}
-ColorPicker::ColorPicker() :
- BoxContainer(true) {
+ColorPicker::ColorPicker()
+ : BoxContainer(true) {
- updating=true;
- edit_alpha=true;
+ updating = true;
+ edit_alpha = true;
text_is_constructor = false;
- raw_mode_enabled=false;
- changing_color=false;
- screen=NULL;
+ raw_mode_enabled = false;
+ changing_color = false;
+ screen = NULL;
- HBoxContainer *hb_smpl = memnew( HBoxContainer );
- btn_pick = memnew( ToolButton );
- btn_pick->connect("pressed",this,"_screen_pick_pressed");
+ HBoxContainer *hb_smpl = memnew(HBoxContainer);
+ btn_pick = memnew(ToolButton);
+ btn_pick->connect("pressed", this, "_screen_pick_pressed");
- sample = memnew( TextureFrame );
+ sample = memnew(TextureFrame);
sample->set_h_size_flags(SIZE_EXPAND_FILL);
- sample->connect("draw",this,"_sample_draw");
+ sample->connect("draw", this, "_sample_draw");
hb_smpl->add_child(sample);
hb_smpl->add_child(btn_pick);
add_child(hb_smpl);
- HBoxContainer *hb_edit = memnew( HBoxContainer );
+ HBoxContainer *hb_edit = memnew(HBoxContainer);
- uv_edit= memnew ( TextureFrame );
+ uv_edit = memnew(TextureFrame);
Image i(256, 256, false, Image::FORMAT_RGB);
- for (int y=0;y<256;y++)
- for (int x=0;x<256;x++)
- i.put_pixel(x,y,Color());
+ for (int y = 0; y < 256; y++)
+ for (int x = 0; x < 256; x++)
+ i.put_pixel(x, y, Color());
Ref<ImageTexture> t;
t.instance();
t->create_from_image(i);
uv_edit->set_texture(t);
uv_edit->set_ignore_mouse(false);
- uv_edit->set_custom_minimum_size(Size2(256,256));
+ uv_edit->set_custom_minimum_size(Size2(256, 256));
uv_edit->connect("input_event", this, "_uv_input");
- Control *c= memnew( Control );
+ Control *c = memnew(Control);
uv_edit->add_child(c);
c->set_area_as_parent_rect();
c->set_stop_mouse(false);
- c->set_material(memnew ( CanvasItemMaterial ));
- Vector<Variant> args=Vector<Variant>();
+ c->set_material(memnew(CanvasItemMaterial));
+ Vector<Variant> args = Vector<Variant>();
args.push_back(0);
args.push_back(c);
- c->connect("draw",this,"_hsv_draw",args);
+ c->connect("draw", this, "_hsv_draw", args);
add_child(hb_edit);
- w_edit= memnew( TextureFrame );
+ w_edit = memnew(TextureFrame);
i = Image(15, 256, false, Image::FORMAT_RGB);
- for (int y=0;y<256;y++)
- for (int x=0;x<15;x++)
- i.put_pixel(x,y,Color());
+ for (int y = 0; y < 256; y++)
+ for (int x = 0; x < 15; x++)
+ i.put_pixel(x, y, Color());
Ref<ImageTexture> tw;
tw.instance();
tw->create_from_image(i);
w_edit->set_texture(tw);
w_edit->set_ignore_mouse(false);
- w_edit->set_custom_minimum_size(Size2(15,256));
+ w_edit->set_custom_minimum_size(Size2(15, 256));
w_edit->connect("input_event", this, "_w_input");
- c= memnew( Control );
+ c = memnew(Control);
w_edit->add_child(c);
c->set_area_as_parent_rect();
c->set_stop_mouse(false);
- c->set_material(memnew ( CanvasItemMaterial ));
+ c->set_material(memnew(CanvasItemMaterial));
args.clear();
args.push_back(1);
args.push_back(c);
- c->connect("draw",this,"_hsv_draw",args);
+ c->connect("draw", this, "_hsv_draw", args);
hb_edit->add_child(uv_edit);
- hb_edit->add_child(memnew( VSeparator ));
+ hb_edit->add_child(memnew(VSeparator));
hb_edit->add_child(w_edit);
- VBoxContainer *vbl = memnew( VBoxContainer );
+ VBoxContainer *vbl = memnew(VBoxContainer);
add_child(vbl);
- add_child(memnew( HSeparator ));
+ add_child(memnew(HSeparator));
- VBoxContainer *vbr = memnew( VBoxContainer );
+ VBoxContainer *vbr = memnew(VBoxContainer);
add_child(vbr);
vbr->set_h_size_flags(SIZE_EXPAND_FILL);
- const char* lt[4] = {"R","G","B","A"};
+ const char *lt[4] = { "R", "G", "B", "A" };
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- HBoxContainer *hbc = memnew( HBoxContainer );
+ HBoxContainer *hbc = memnew(HBoxContainer);
- labels[i]=memnew( Label(lt[i]) );
+ labels[i] = memnew(Label(lt[i]));
hbc->add_child(labels[i]);
- scroll[i]=memnew( HSlider );
+ scroll[i] = memnew(HSlider);
hbc->add_child(scroll[i]);
- values[i]=memnew( SpinBox );
+ values[i] = memnew(SpinBox);
scroll[i]->share(values[i]);
hbc->add_child(values[i]);
-
scroll[i]->set_min(0);
scroll[i]->set_page(0);
scroll[i]->set_h_size_flags(SIZE_EXPAND_FILL);
- scroll[i]->connect("value_changed",this,"_value_changed");
+ scroll[i]->connect("value_changed", this, "_value_changed");
vbr->add_child(hbc);
-
}
- HBoxContainer *hhb = memnew( HBoxContainer );
+ HBoxContainer *hhb = memnew(HBoxContainer);
- btn_mode = memnew( CheckButton );
+ btn_mode = memnew(CheckButton);
btn_mode->set_text("RAW Mode");
btn_mode->connect("toggled", this, "set_raw_mode");
hhb->add_child(btn_mode);
vbr->add_child(hhb);
- text_type = memnew( Button );
+ text_type = memnew(Button);
text_type->set_flat(true);
text_type->connect("pressed", this, "_text_type_toggled");
hhb->add_child(text_type);
- c_text = memnew( LineEdit );
+ c_text = memnew(LineEdit);
hhb->add_child(c_text);
- c_text->connect("text_entered",this,"_html_entered");
+ c_text->connect("text_entered", this, "_html_entered");
text_type->set_text("#");
c_text->set_h_size_flags(SIZE_EXPAND_FILL);
-
_update_controls();
//_update_color();
- updating=false;
+ updating = false;
uv_material.instance();
Ref<Shader> s_uv = get_shader("uv_editor");
@@ -591,76 +574,67 @@ ColorPicker::ColorPicker() :
uv_edit->set_material(uv_material);
w_edit->set_material(w_material);
- set_color(Color(1,1,1));
+ set_color(Color(1, 1, 1));
- i.create(256,20,false,Image::FORMAT_RGB);
- for (int y=0;y<20;y++)
- for(int x=0;x<256;x++)
- if ((x/4+y/4)%2)
- i.put_pixel(x,y,Color(1,1,1));
+ i.create(256, 20, false, Image::FORMAT_RGB);
+ for (int y = 0; y < 20; y++)
+ for (int x = 0; x < 256; x++)
+ if ((x / 4 + y / 4) % 2)
+ i.put_pixel(x, y, Color(1, 1, 1));
else
- i.put_pixel(x,y,Color(0.6,0.6,0.6));
+ i.put_pixel(x, y, Color(0.6, 0.6, 0.6));
Ref<ImageTexture> t_smpl;
t_smpl.instance();
t_smpl->create_from_image(i);
sample->set_texture(t_smpl);
- HBoxContainer *bbc = memnew( HBoxContainer );
+ HBoxContainer *bbc = memnew(HBoxContainer);
add_child(bbc);
- preset = memnew( TextureFrame );
+ preset = memnew(TextureFrame);
bbc->add_child(preset);
preset->set_ignore_mouse(false);
preset->connect("input_event", this, "_preset_input");
- bt_add_preset = memnew ( Button );
+ bt_add_preset = memnew(Button);
bt_add_preset->set_icon(get_icon("add_preset"));
bt_add_preset->set_tooltip("Add current color as a preset");
bt_add_preset->connect("pressed", this, "_add_preset_pressed");
bbc->add_child(bt_add_preset);
}
-
-
-
/////////////////
-
-void ColorPickerButton::_color_changed(const Color& p_color) {
+void ColorPickerButton::_color_changed(const Color &p_color) {
update();
- emit_signal("color_changed",p_color);
+ emit_signal("color_changed", p_color);
}
-
void ColorPickerButton::pressed() {
- Size2 ms = Size2(300, picker->get_combined_minimum_size().height+10);
- popup->set_pos(get_global_pos()-Size2(0,ms.height));
+ Size2 ms = Size2(300, picker->get_combined_minimum_size().height + 10);
+ popup->set_pos(get_global_pos() - Size2(0, ms.height));
popup->set_size(ms);
popup->popup();
picker->set_focus_on_line_edit();
-
-
}
void ColorPickerButton::_notification(int p_what) {
+ if (p_what == NOTIFICATION_DRAW) {
- if (p_what==NOTIFICATION_DRAW) {
-
- Ref<StyleBox> normal = get_stylebox("normal" );
- draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_color());
+ Ref<StyleBox> normal = get_stylebox("normal");
+ draw_rect(Rect2(normal->get_offset(), get_size() - normal->get_minimum_size()), picker->get_color());
}
}
-void ColorPickerButton::set_color(const Color& p_color){
-
+void ColorPickerButton::set_color(const Color &p_color) {
picker->set_color(p_color);
update();
}
-Color ColorPickerButton::get_color() const{
+Color ColorPickerButton::get_color() const {
return picker->get_color();
}
@@ -670,37 +644,35 @@ void ColorPickerButton::set_edit_alpha(bool p_show) {
picker->set_edit_alpha(p_show);
}
-bool ColorPickerButton::is_editing_alpha() const{
+bool ColorPickerButton::is_editing_alpha() const {
return picker->is_editing_alpha();
-
}
ColorPicker *ColorPickerButton::get_picker() {
return picker;
}
-void ColorPickerButton::_bind_methods(){
-
- ObjectTypeDB::bind_method(_MD("set_color","color"),&ColorPickerButton::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&ColorPickerButton::get_color);
- ObjectTypeDB::bind_method(_MD("get_picker:ColorPicker"),&ColorPickerButton::get_picker);
- ObjectTypeDB::bind_method(_MD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha);
- ObjectTypeDB::bind_method(_MD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha);
- ObjectTypeDB::bind_method(_MD("_color_changed"),&ColorPickerButton::_color_changed);
+void ColorPickerButton::_bind_methods() {
- ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color")));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"edit_alpha"),_SCS("set_edit_alpha"),_SCS("is_editing_alpha") );
+ ObjectTypeDB::bind_method(_MD("set_color", "color"), &ColorPickerButton::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color"), &ColorPickerButton::get_color);
+ ObjectTypeDB::bind_method(_MD("get_picker:ColorPicker"), &ColorPickerButton::get_picker);
+ ObjectTypeDB::bind_method(_MD("set_edit_alpha", "show"), &ColorPickerButton::set_edit_alpha);
+ ObjectTypeDB::bind_method(_MD("is_editing_alpha"), &ColorPickerButton::is_editing_alpha);
+ ObjectTypeDB::bind_method(_MD("_color_changed"), &ColorPickerButton::_color_changed);
+ ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color")));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), _SCS("set_color"), _SCS("get_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "edit_alpha"), _SCS("set_edit_alpha"), _SCS("is_editing_alpha"));
}
ColorPickerButton::ColorPickerButton() {
- popup = memnew( PopupPanel );
- picker = memnew( ColorPicker );
+ popup = memnew(PopupPanel);
+ picker = memnew(ColorPicker);
popup->add_child(picker);
popup->set_child_rect(picker);
- picker->connect("color_changed",this,"_color_changed");
+ picker->connect("color_changed", this, "_color_changed");
add_child(popup);
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 5832f7db7..e83327f16 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -29,24 +29,23 @@
#ifndef COLOR_PICKER_H
#define COLOR_PICKER_H
-#include "scene/gui/slider.h"
-#include "scene/gui/line_edit.h"
-#include "scene/gui/spin_box.h"
-#include "scene/gui/label.h"
+#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
+#include "scene/gui/check_button.h"
+#include "scene/gui/label.h"
+#include "scene/gui/line_edit.h"
#include "scene/gui/popup.h"
-#include "scene/gui/box_container.h"
+#include "scene/gui/slider.h"
+#include "scene/gui/spin_box.h"
#include "scene/gui/texture_frame.h"
#include "scene/gui/tool_button.h"
-#include "scene/gui/check_button.h"
#include "scene/resources/material.h"
class ColorPicker : public BoxContainer {
- OBJ_TYPE(ColorPicker,BoxContainer);
+ OBJ_TYPE(ColorPicker, BoxContainer);
private:
-
Control *screen;
Image last_capture;
TextureFrame *uv_edit;
@@ -72,10 +71,10 @@ private:
bool raw_mode_enabled;
bool updating;
bool changing_color;
- float h,s,v;
+ float h, s, v;
Color last_hsv;
- void _html_entered(const String& p_html);
+ void _html_entered(const String &p_html);
void _value_changed(double);
void _update_controls();
void _update_color();
@@ -83,28 +82,27 @@ private:
void _update_text_value();
void _text_type_toggled();
void _sample_draw();
- void _hsv_draw(int p_wich,Control *c);
+ void _hsv_draw(int p_wich, Control *c);
- void _uv_input(const InputEvent& p_input);
- void _w_input(const InputEvent& p_input);
- void _preset_input(const InputEvent& p_input);
- void _screen_input(const InputEvent& p_input);
+ void _uv_input(const InputEvent &p_input);
+ void _w_input(const InputEvent &p_input);
+ void _preset_input(const InputEvent &p_input);
+ void _screen_input(const InputEvent &p_input);
void _add_preset_pressed();
void _screen_pick_pressed();
protected:
-
void _notification(int);
static void _bind_methods();
-public:
+public:
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
- void set_color(const Color& p_color);
+ void set_color(const Color &p_color);
Color get_color() const;
- void add_preset(const Color& p_color);
+ void add_preset(const Color &p_color);
void set_raw_mode(bool p_enabled);
bool is_raw_mode() const;
@@ -115,21 +113,20 @@ public:
class ColorPickerButton : public Button {
- OBJ_TYPE(ColorPickerButton,Button);
+ OBJ_TYPE(ColorPickerButton, Button);
PopupPanel *popup;
ColorPicker *picker;
- void _color_changed(const Color& p_color);
+ void _color_changed(const Color &p_color);
virtual void pressed();
protected:
-
void _notification(int);
static void _bind_methods();
-public:
- void set_color(const Color& p_color);
+public:
+ void set_color(const Color &p_color);
Color get_color() const;
void set_edit_alpha(bool p_show);
diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp
index 7415aad0f..44548f23c 100644
--- a/scene/gui/color_ramp_edit.cpp
+++ b/scene/gui/color_ramp_edit.cpp
@@ -29,74 +29,72 @@
#include "color_ramp_edit.h"
#include "os/keyboard.h"
-ColorRampEdit::ColorRampEdit(){
- grabbed=-1;
- grabbing=false;
+ColorRampEdit::ColorRampEdit() {
+ grabbed = -1;
+ grabbing = false;
set_focus_mode(FOCUS_ALL);
- popup = memnew( PopupPanel );
- picker = memnew( ColorPicker );
+ popup = memnew(PopupPanel);
+ picker = memnew(ColorPicker);
popup->add_child(picker);
popup->set_child_rect(picker);
add_child(popup);
- checker = Ref<ImageTexture>(memnew( ImageTexture ));
- checker->create_from_image( Image(checker_bg_png),ImageTexture::FLAG_REPEAT );
+ checker = Ref<ImageTexture>(memnew(ImageTexture));
+ checker->create_from_image(Image(checker_bg_png), ImageTexture::FLAG_REPEAT);
}
int ColorRampEdit::_get_point_from_pos(int x) {
int result = -1;
- int total_w = get_size().width-get_size().height-3;
- for(int i=0;i<points.size();i++) {
+ int total_w = get_size().width - get_size().height - 3;
+ for (int i = 0; i < points.size(); i++) {
//Check if we clicked at point
- if (ABS(x-points[i].offset*total_w+1)<(POINT_WIDTH/2+1)) {
- result=i;
+ if (ABS(x - points[i].offset * total_w + 1) < (POINT_WIDTH / 2 + 1)) {
+ result = i;
}
}
return result;
}
void ColorRampEdit::_show_color_picker() {
- if (grabbed==-1)
+ if (grabbed == -1)
return;
- Size2 ms = Size2(350, picker->get_combined_minimum_size().height+10);
+ Size2 ms = Size2(350, picker->get_combined_minimum_size().height + 10);
picker->set_color(points[grabbed].color);
- popup->set_pos(get_global_pos()-Vector2(ms.width-get_size().width,ms.height));
+ popup->set_pos(get_global_pos() - Vector2(ms.width - get_size().width, ms.height));
popup->set_size(ms);
popup->popup();
}
ColorRampEdit::~ColorRampEdit() {
-
}
-void ColorRampEdit::_input_event(const InputEvent& p_event) {
+void ColorRampEdit::_input_event(const InputEvent &p_event) {
- if (p_event.type==InputEvent::KEY && p_event.key.pressed && p_event.key.scancode==KEY_DELETE && grabbed!=-1) {
+ if (p_event.type == InputEvent::KEY && p_event.key.pressed && p_event.key.scancode == KEY_DELETE && grabbed != -1) {
points.remove(grabbed);
- grabbed=-1;
- grabbing=false;
+ grabbed = -1;
+ grabbing = false;
update();
emit_signal("ramp_changed");
accept_event();
}
//Show color picker on double click.
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1 && p_event.mouse_button.doubleclick && p_event.mouse_button.pressed) {
- grabbed=_get_point_from_pos(p_event.mouse_button.x);
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 1 && p_event.mouse_button.doubleclick && p_event.mouse_button.pressed) {
+ grabbed = _get_point_from_pos(p_event.mouse_button.x);
_show_color_picker();
accept_event();
}
//Delete point on right click
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==2 && p_event.mouse_button.pressed) {
- grabbed=_get_point_from_pos(p_event.mouse_button.x);
- if(grabbed != -1)
- {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 2 && p_event.mouse_button.pressed) {
+ grabbed = _get_point_from_pos(p_event.mouse_button.x);
+ if (grabbed != -1) {
points.remove(grabbed);
- grabbed=-1;
- grabbing=false;
+ grabbed = -1;
+ grabbing = false;
update();
emit_signal("ramp_changed");
accept_event();
@@ -104,21 +102,21 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) {
}
//Hold alt key to duplicate selected color
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1 && p_event.mouse_button.pressed && p_event.key.mod.alt ) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 1 && p_event.mouse_button.pressed && p_event.key.mod.alt) {
int x = p_event.mouse_button.x;
- grabbed=_get_point_from_pos(x);
+ grabbed = _get_point_from_pos(x);
- if( grabbed != -1 ) {
- int total_w = get_size().width-get_size().height-3;
+ if (grabbed != -1) {
+ int total_w = get_size().width - get_size().height - 3;
ColorRamp::Point newPoint = points[grabbed];
- newPoint.offset=CLAMP(x/float(total_w),0,1);
+ newPoint.offset = CLAMP(x / float(total_w), 0, 1);
points.push_back(newPoint);
points.sort();
- for(int i=0;i<points.size();++i) {
- if (points[i].offset==newPoint.offset) {
- grabbed=i;
+ for (int i = 0; i < points.size(); ++i) {
+ if (points[i].offset == newPoint.offset) {
+ grabbed = i;
break;
}
}
@@ -128,91 +126,89 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) {
}
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1 && p_event.mouse_button.pressed) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 1 && p_event.mouse_button.pressed) {
update();
int x = p_event.mouse_button.x;
- int total_w = get_size().width-get_size().height-3;
+ int total_w = get_size().width - get_size().height - 3;
//Check if color selector was clicked.
- if (x>total_w+3) {
+ if (x > total_w + 3) {
_show_color_picker();
return;
}
- grabbing=true;
+ grabbing = true;
- grabbed=_get_point_from_pos(x);
+ grabbed = _get_point_from_pos(x);
//grab or select
- if (grabbed!=-1) {
+ if (grabbed != -1) {
return;
}
//insert
ColorRamp::Point newPoint;
- newPoint.offset=CLAMP(x/float(total_w),0,1);
+ newPoint.offset = CLAMP(x / float(total_w), 0, 1);
ColorRamp::Point prev;
ColorRamp::Point next;
- int pos=-1;
- for(int i=0;i<points.size();i++) {
- if (points[i].offset<newPoint.offset)
- pos=i;
+ int pos = -1;
+ for (int i = 0; i < points.size(); i++) {
+ if (points[i].offset < newPoint.offset)
+ pos = i;
}
- if (pos==-1) {
+ if (pos == -1) {
- prev.color=Color(0,0,0);
- prev.offset=0;
+ prev.color = Color(0, 0, 0);
+ prev.offset = 0;
if (points.size()) {
- next=points[0];
+ next = points[0];
} else {
- next.color=Color(1,1,1);
- next.offset=1.0;
+ next.color = Color(1, 1, 1);
+ next.offset = 1.0;
}
- } else {
+ } else {
- if (pos==points.size()-1) {
- next.color=Color(1,1,1);
- next.offset=1.0;
+ if (pos == points.size() - 1) {
+ next.color = Color(1, 1, 1);
+ next.offset = 1.0;
} else {
- next=points[pos+1];
+ next = points[pos + 1];
}
- prev=points[pos];
-
+ prev = points[pos];
}
- newPoint.color=prev.color.linear_interpolate(next.color,(newPoint.offset-prev.offset)/(next.offset-prev.offset));
+ newPoint.color = prev.color.linear_interpolate(next.color, (newPoint.offset - prev.offset) / (next.offset - prev.offset));
points.push_back(newPoint);
points.sort();
- for(int i=0;i<points.size();i++) {
- if (points[i].offset==newPoint.offset) {
- grabbed=i;
+ for (int i = 0; i < points.size(); i++) {
+ if (points[i].offset == newPoint.offset) {
+ grabbed = i;
break;
}
}
emit_signal("ramp_changed");
-
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==1 && !p_event.mouse_button.pressed) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 1 && !p_event.mouse_button.pressed) {
if (grabbing) {
- grabbing=false;
+ grabbing = false;
emit_signal("ramp_changed");
}
update();
}
- if (p_event.type==InputEvent::MOUSE_MOTION && grabbing) {
+ if (p_event.type == InputEvent::MOUSE_MOTION && grabbing) {
- int total_w = get_size().width-get_size().height-3;
+ int total_w = get_size().width - get_size().height - 3;
int x = p_event.mouse_motion.x;
- float newofs = CLAMP(x/float(total_w),0,1);
+ float newofs = CLAMP(x / float(total_w), 0, 1);
//Snap to nearest point if holding shift
if (p_event.key.mod.shift) {
@@ -220,7 +216,7 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) {
float smallest_ofs = snap_treshhold;
bool founded = false;
int nearest_point;
- for(int i=0;i<points.size();++i) {
+ for (int i = 0; i < points.size(); ++i) {
if (i != grabbed) {
float temp_ofs = ABS(points[i].offset - newofs);
if (temp_ofs < smallest_ofs) {
@@ -234,30 +230,30 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) {
}
if (founded) {
if (points[nearest_point].offset < newofs)
- newofs = points[nearest_point].offset+0.00001;
+ newofs = points[nearest_point].offset + 0.00001;
else
- newofs = points[nearest_point].offset-0.00001;
- newofs = CLAMP(newofs,0,1);
+ newofs = points[nearest_point].offset - 0.00001;
+ newofs = CLAMP(newofs, 0, 1);
}
}
- bool valid=true;
- for(int i=0;i<points.size();i++) {
+ bool valid = true;
+ for (int i = 0; i < points.size(); i++) {
- if (points[i].offset==newofs && i!=grabbed) {
- valid=false;
+ if (points[i].offset == newofs && i != grabbed) {
+ valid = false;
}
}
if (!valid)
return;
- points[grabbed].offset=newofs;
+ points[grabbed].offset = newofs;
points.sort();
- for(int i=0;i<points.size();i++) {
- if (points[i].offset==newofs) {
- grabbed=i;
+ for (int i = 0; i < points.size(); i++) {
+ if (points[i].offset == newofs) {
+ grabbed = i;
break;
}
}
@@ -270,12 +266,12 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) {
void ColorRampEdit::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
- if (!picker->is_connected("color_changed",this,"_color_changed")) {
- picker->connect("color_changed",this,"_color_changed");
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+ if (!picker->is_connected("color_changed", this, "_color_changed")) {
+ picker->connect("color_changed", this, "_color_changed");
}
}
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
int w = get_size().x;
int h = get_size().y;
@@ -283,89 +279,86 @@ void ColorRampEdit::_notification(int p_what) {
if (w == 0 || h == 0)
return; //Safety check. We have division by 'h'. And in any case there is nothing to draw with such size
- int total_w = get_size().width-get_size().height-3;
+ int total_w = get_size().width - get_size().height - 3;
//Draw checker pattern for ramp
- _draw_checker(0,0, total_w, h);
+ _draw_checker(0, 0, total_w, h);
//Draw color ramp
ColorRamp::Point prev;
- prev.offset=0;
- if(points.size() == 0)
- prev.color=Color(0,0,0); //Draw black rectangle if we have no points
+ prev.offset = 0;
+ if (points.size() == 0)
+ prev.color = Color(0, 0, 0); //Draw black rectangle if we have no points
else
- prev.color = points[0].color; //Extend color of first point to the beginning.
+ prev.color = points[0].color; //Extend color of first point to the beginning.
- for(int i=-1;i<points.size();i++) {
+ for (int i = -1; i < points.size(); i++) {
ColorRamp::Point next;
//If there is no next point
- if (i+1 == points.size()) {
- if(points.size() == 0)
- next.color=Color(0,0,0); //Draw black rectangle if we have no points
+ if (i + 1 == points.size()) {
+ if (points.size() == 0)
+ next.color = Color(0, 0, 0); //Draw black rectangle if we have no points
else
- next.color=points[i].color; //Extend color of last point to the end.
- next.offset=1;
+ next.color = points[i].color; //Extend color of last point to the end.
+ next.offset = 1;
} else {
- next=points[i+1];
+ next = points[i + 1];
}
- if (prev.offset==next.offset) {
- prev=next;
+ if (prev.offset == next.offset) {
+ prev = next;
continue;
}
Vector<Vector2> points;
Vector<Color> colors;
- points.push_back(Vector2(prev.offset*total_w,h));
- points.push_back(Vector2(prev.offset*total_w,0));
- points.push_back(Vector2(next.offset*total_w,0));
- points.push_back(Vector2(next.offset*total_w,h));
+ points.push_back(Vector2(prev.offset * total_w, h));
+ points.push_back(Vector2(prev.offset * total_w, 0));
+ points.push_back(Vector2(next.offset * total_w, 0));
+ points.push_back(Vector2(next.offset * total_w, h));
colors.push_back(prev.color);
colors.push_back(prev.color);
colors.push_back(next.color);
colors.push_back(next.color);
- draw_primitive(points,colors,Vector<Point2>());
- prev=next;
+ draw_primitive(points, colors, Vector<Point2>());
+ prev = next;
}
//Draw point markers
- for(int i=0;i<points.size();i++) {
+ for (int i = 0; i < points.size(); i++) {
- Color col = i==grabbed?Color(1,0.0,0.0,0.9):points[i].color.contrasted();
+ Color col = i == grabbed ? Color(1, 0.0, 0.0, 0.9) : points[i].color.contrasted();
col.a = 0.9;
- draw_line(Vector2(points[i].offset*total_w,0),Vector2(points[i].offset*total_w,h/2),col);
- draw_rect(Rect2(points[i].offset*total_w-POINT_WIDTH/2, h/2, POINT_WIDTH, h/2), Color(0.6, 0.6, 0.6, i==grabbed?0.9:0.4));
- draw_line(Vector2(points[i].offset*total_w-POINT_WIDTH/2,h/2),Vector2(points[i].offset*total_w-POINT_WIDTH/2,h-1),col);
- draw_line(Vector2(points[i].offset*total_w+POINT_WIDTH/2,h/2),Vector2(points[i].offset*total_w+POINT_WIDTH/2,h-1),col);
- draw_line(Vector2(points[i].offset*total_w-POINT_WIDTH/2,h/2),Vector2(points[i].offset*total_w+POINT_WIDTH/2,h/2),col);
- draw_line(Vector2(points[i].offset*total_w-POINT_WIDTH/2,h-1),Vector2(points[i].offset*total_w+POINT_WIDTH/2,h-1),col);
-
+ draw_line(Vector2(points[i].offset * total_w, 0), Vector2(points[i].offset * total_w, h / 2), col);
+ draw_rect(Rect2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2, POINT_WIDTH, h / 2), Color(0.6, 0.6, 0.6, i == grabbed ? 0.9 : 0.4));
+ draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h - 1), col);
+ draw_line(Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h - 1), col);
+ draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h / 2), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h / 2), col);
+ draw_line(Vector2(points[i].offset * total_w - POINT_WIDTH / 2, h - 1), Vector2(points[i].offset * total_w + POINT_WIDTH / 2, h - 1), col);
}
-
//Draw "button" for color selector
- _draw_checker(total_w+3,0, h, h);
- if (grabbed!=-1) {
+ _draw_checker(total_w + 3, 0, h, h);
+ if (grabbed != -1) {
//Draw with selection color
- draw_rect(Rect2(total_w+3,0,h,h),points[grabbed].color);
+ draw_rect(Rect2(total_w + 3, 0, h, h), points[grabbed].color);
} else {
//if no color selected draw grey color with 'X' on top.
- draw_rect(Rect2(total_w+3,0,h,h), Color(0.5, 0.5, 0.5, 1));
- draw_line(Vector2(total_w+3,0),Vector2(total_w+3+h,h),Color(1,1,1,0.6));
- draw_line(Vector2(total_w+3,h),Vector2(total_w+3+h,0),Color(1,1,1,0.6));
+ draw_rect(Rect2(total_w + 3, 0, h, h), Color(0.5, 0.5, 0.5, 1));
+ draw_line(Vector2(total_w + 3, 0), Vector2(total_w + 3 + h, h), Color(1, 1, 1, 0.6));
+ draw_line(Vector2(total_w + 3, h), Vector2(total_w + 3 + h, 0), Color(1, 1, 1, 0.6));
}
//Draw borders around color ramp if in focus
if (has_focus()) {
- draw_line(Vector2(-1,-1),Vector2(total_w+1,-1),Color(1,1,1,0.6));
- draw_line(Vector2(total_w+1,-1),Vector2(total_w+1,h+1),Color(1,1,1,0.6));
- draw_line(Vector2(total_w+1,h+1),Vector2(-1,h+1),Color(1,1,1,0.6));
- draw_line(Vector2(-1,-1),Vector2(-1,h+1),Color(1,1,1,0.6));
+ draw_line(Vector2(-1, -1), Vector2(total_w + 1, -1), Color(1, 1, 1, 0.6));
+ draw_line(Vector2(total_w + 1, -1), Vector2(total_w + 1, h + 1), Color(1, 1, 1, 0.6));
+ draw_line(Vector2(total_w + 1, h + 1), Vector2(-1, h + 1), Color(1, 1, 1, 0.6));
+ draw_line(Vector2(-1, -1), Vector2(-1, h + 1), Color(1, 1, 1, 0.6));
}
-
}
}
@@ -373,9 +366,9 @@ void ColorRampEdit::_draw_checker(int x, int y, int w, int h) {
//Draw it with polygon to insert UVs for scale
Vector<Vector2> backPoints;
backPoints.push_back(Vector2(x, y));
- backPoints.push_back(Vector2(x, y+h));
- backPoints.push_back(Vector2(x+w, y+h));
- backPoints.push_back(Vector2(x+w, y));
+ backPoints.push_back(Vector2(x, y + h));
+ backPoints.push_back(Vector2(x + w, y + h));
+ backPoints.push_back(Vector2(x + w, y));
Vector<Color> colorPoints;
colorPoints.push_back(Color(1, 1, 1, 1));
colorPoints.push_back(Color(1, 1, 1, 1));
@@ -384,35 +377,34 @@ void ColorRampEdit::_draw_checker(int x, int y, int w, int h) {
Vector<Vector2> uvPoints;
//Draw checker pattern pixel-perfect and scale it by 2.
uvPoints.push_back(Vector2(x, y));
- uvPoints.push_back(Vector2(x, y+h*.5f/checker->get_height()));
- uvPoints.push_back(Vector2(x+w*.5f/checker->get_width(), y+h*.5f/checker->get_height()));
- uvPoints.push_back(Vector2(x+w*.5f/checker->get_width(), y));
+ uvPoints.push_back(Vector2(x, y + h * .5f / checker->get_height()));
+ uvPoints.push_back(Vector2(x + w * .5f / checker->get_width(), y + h * .5f / checker->get_height()));
+ uvPoints.push_back(Vector2(x + w * .5f / checker->get_width(), y));
draw_polygon(backPoints, colorPoints, uvPoints, checker);
}
Size2 ColorRampEdit::get_minimum_size() const {
- return Vector2(0,16);
+ return Vector2(0, 16);
}
-void ColorRampEdit::_color_changed(const Color& p_color) {
+void ColorRampEdit::_color_changed(const Color &p_color) {
- if (grabbed==-1)
+ if (grabbed == -1)
return;
- points[grabbed].color=p_color;
+ points[grabbed].color = p_color;
update();
emit_signal("ramp_changed");
-
}
-void ColorRampEdit::set_ramp(const Vector<float>& p_offsets,const Vector<Color>& p_colors) {
+void ColorRampEdit::set_ramp(const Vector<float> &p_offsets, const Vector<Color> &p_colors) {
- ERR_FAIL_COND(p_offsets.size()!=p_colors.size());
+ ERR_FAIL_COND(p_offsets.size() != p_colors.size());
points.clear();
- for(int i=0;i<p_offsets.size();i++) {
+ for (int i = 0; i < p_offsets.size(); i++) {
ColorRamp::Point p;
- p.offset=p_offsets[i];
- p.color=p_colors[i];
+ p.offset = p_offsets[i];
+ p.color = p_colors[i];
points.push_back(p);
}
@@ -422,31 +414,31 @@ void ColorRampEdit::set_ramp(const Vector<float>& p_offsets,const Vector<Color>&
Vector<float> ColorRampEdit::get_offsets() const {
Vector<float> ret;
- for(int i=0;i<points.size();i++)
+ for (int i = 0; i < points.size(); i++)
ret.push_back(points[i].offset);
return ret;
}
Vector<Color> ColorRampEdit::get_colors() const {
Vector<Color> ret;
- for(int i=0;i<points.size();i++)
+ for (int i = 0; i < points.size(); i++)
ret.push_back(points[i].color);
return ret;
}
-void ColorRampEdit::set_points(Vector<ColorRamp::Point>& p_points) {
- if(points.size() != p_points.size())
+void ColorRampEdit::set_points(Vector<ColorRamp::Point> &p_points) {
+ if (points.size() != p_points.size())
grabbed = -1;
points.clear();
points = p_points;
}
-Vector<ColorRamp::Point>& ColorRampEdit::get_points() {
+Vector<ColorRamp::Point> &ColorRampEdit::get_points() {
return points;
}
void ColorRampEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&ColorRampEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("_color_changed"),&ColorRampEdit::_color_changed);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &ColorRampEdit::_input_event);
+ ObjectTypeDB::bind_method(_MD("_color_changed"), &ColorRampEdit::_color_changed);
ADD_SIGNAL(MethodInfo("ramp_changed"));
}
diff --git a/scene/gui/color_ramp_edit.h b/scene/gui/color_ramp_edit.h
index bbe8e2e6c..0525f83aa 100644
--- a/scene/gui/color_ramp_edit.h
+++ b/scene/gui/color_ramp_edit.h
@@ -29,8 +29,8 @@
#ifndef SCENE_GUI_COLOR_RAMP_EDIT_H_
#define SCENE_GUI_COLOR_RAMP_EDIT_H_
-#include "scene/gui/popup.h"
#include "scene/gui/color_picker.h"
+#include "scene/gui/popup.h"
#include "scene/resources/color_ramp.h"
#include "scene/resources/default_theme/theme_data.h"
@@ -38,7 +38,7 @@
class ColorRampEdit : public Control {
- OBJ_TYPE(ColorRampEdit,Control);
+ OBJ_TYPE(ColorRampEdit, Control);
PopupPanel *popup;
ColorPicker *picker;
@@ -50,21 +50,21 @@ class ColorRampEdit : public Control {
Vector<ColorRamp::Point> points;
void _draw_checker(int x, int y, int w, int h);
- void _color_changed(const Color& p_color);
+ void _color_changed(const Color &p_color);
int _get_point_from_pos(int x);
void _show_color_picker();
protected:
- void _input_event(const InputEvent& p_event);
+ void _input_event(const InputEvent &p_event);
void _notification(int p_what);
static void _bind_methods();
public:
- void set_ramp(const Vector<float>& p_offsets,const Vector<Color>& p_colors);
+ void set_ramp(const Vector<float> &p_offsets, const Vector<Color> &p_colors);
Vector<float> get_offsets() const;
Vector<Color> get_colors() const;
- void set_points(Vector<ColorRamp::Point>& p_points);
- Vector<ColorRamp::Point>& get_points();
+ void set_points(Vector<ColorRamp::Point> &p_points);
+ Vector<ColorRamp::Point> &get_points();
virtual Size2 get_minimum_size() const;
ColorRampEdit();
@@ -76,5 +76,4 @@ public:
OBJ_TYPE(ColorRampEditPanel, Panel );
};*/
-
#endif /* SCENE_GUI_COLOR_RAMP_EDIT_H_ */
diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp
index a0e4df66b..0a4763f70 100644
--- a/scene/gui/color_rect.cpp
+++ b/scene/gui/color_rect.cpp
@@ -1,36 +1,32 @@
#include "color_rect.h"
+void ColorFrame::set_frame_color(const Color &p_color) {
-
-
-void ColorFrame::set_frame_color(const Color& p_color) {
-
- color=p_color;
+ color = p_color;
update();
}
-Color ColorFrame::get_frame_color() const{
+Color ColorFrame::get_frame_color() const {
return color;
}
void ColorFrame::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
- draw_rect(Rect2(Point2(),get_size()),color);
+ if (p_what == NOTIFICATION_DRAW) {
+ draw_rect(Rect2(Point2(), get_size()), color);
}
}
void ColorFrame::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_frame_color","color"),&ColorFrame::set_frame_color);
- ObjectTypeDB::bind_method(_MD("get_frame_color"),&ColorFrame::get_frame_color);
+ ObjectTypeDB::bind_method(_MD("set_frame_color", "color"), &ColorFrame::set_frame_color);
+ ObjectTypeDB::bind_method(_MD("get_frame_color"), &ColorFrame::get_frame_color);
- ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_frame_color"),_SCS("get_frame_color") );
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), _SCS("set_frame_color"), _SCS("get_frame_color"));
}
ColorFrame::ColorFrame() {
- color=Color(1,1,1);
+ color = Color(1, 1, 1);
}
-
diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h
index 3816d4405..0fb764640 100644
--- a/scene/gui/color_rect.h
+++ b/scene/gui/color_rect.h
@@ -3,17 +3,17 @@
#include "scene/gui/control.h"
-class ColorFrame : public Control {
- OBJ_TYPE(ColorFrame,Control)
+class ColorFrame : public Control {
+ OBJ_TYPE(ColorFrame, Control)
Color color;
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- void set_frame_color(const Color& p_color);
+public:
+ void set_frame_color(const Color &p_color);
Color get_frame_color() const;
ColorFrame();
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 32ed56ceb..97aee0360 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -27,9 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "container.h"
-#include "scene/scene_string_names.h"
#include "message_queue.h"
-
+#include "scene/scene_string_names.h"
void Container::_child_minsize_changed() {
@@ -45,11 +44,10 @@ void Container::add_child_notify(Node *p_child) {
if (!control)
return;
- control->connect("size_flags_changed",this,"queue_sort");
- control->connect("minimum_size_changed",this,"_child_minsize_changed");
- control->connect("visibility_changed",this,"_child_minsize_changed");
+ control->connect("size_flags_changed", this, "queue_sort");
+ control->connect("minimum_size_changed", this, "_child_minsize_changed");
+ control->connect("visibility_changed", this, "_child_minsize_changed");
queue_sort();
-
}
void Container::move_child_notify(Node *p_child) {
@@ -62,14 +60,13 @@ void Container::move_child_notify(Node *p_child) {
void Container::remove_child_notify(Node *p_child) {
-
Control *control = p_child->cast_to<Control>();
if (!control)
return;
- control->disconnect("size_flags_changed",this,"queue_sort");
- control->disconnect("minimum_size_changed",this,"_child_minsize_changed");
- control->disconnect("visibility_changed",this,"_child_minsize_changed");
+ control->disconnect("size_flags_changed", this, "queue_sort");
+ control->disconnect("minimum_size_changed", this, "_child_minsize_changed");
+ control->disconnect("visibility_changed", this, "_child_minsize_changed");
queue_sort();
}
@@ -80,33 +77,33 @@ void Container::_sort_children() {
notification(NOTIFICATION_SORT_CHILDREN);
emit_signal(SceneStringNames::get_singleton()->sort_children);
- pending_sort=false;
+ pending_sort = false;
}
-void Container::fit_child_in_rect(Control *p_child,const Rect2& p_rect) {
+void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) {
- ERR_FAIL_COND(p_child->get_parent()!=this);
+ ERR_FAIL_COND(p_child->get_parent() != this);
Size2 minsize = p_child->get_combined_minimum_size();
- Rect2 r=p_rect;
+ Rect2 r = p_rect;
- if (!(p_child->get_h_size_flags()&SIZE_FILL)) {
- r.size.x=minsize.x;
- r.pos.x += Math::floor((p_rect.size.x - minsize.x)/2);
+ if (!(p_child->get_h_size_flags() & SIZE_FILL)) {
+ r.size.x = minsize.x;
+ r.pos.x += Math::floor((p_rect.size.x - minsize.x) / 2);
}
- if (!(p_child->get_v_size_flags()&SIZE_FILL)) {
- r.size.y=minsize.y;
- r.pos.y += Math::floor((p_rect.size.y - minsize.y)/2);
+ if (!(p_child->get_v_size_flags() & SIZE_FILL)) {
+ r.size.y = minsize.y;
+ r.pos.y += Math::floor((p_rect.size.y - minsize.y) / 2);
}
- for(int i=0;i<4;i++)
- p_child->set_anchor(Margin(i),ANCHOR_BEGIN);
+ for (int i = 0; i < 4; i++)
+ p_child->set_anchor(Margin(i), ANCHOR_BEGIN);
p_child->set_pos(r.pos);
p_child->set_size(r.size);
p_child->set_rotation(0);
- p_child->set_scale(Vector2(1,1));
+ p_child->set_scale(Vector2(1, 1));
}
void Container::queue_sort() {
@@ -117,16 +114,16 @@ void Container::queue_sort() {
if (pending_sort)
return;
- MessageQueue::get_singleton()->push_call(this,"_sort_children");
- pending_sort=true;
+ MessageQueue::get_singleton()->push_call(this, "_sort_children");
+ pending_sort = true;
}
void Container::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- pending_sort=false;
+ pending_sort = false;
queue_sort();
} break;
case NOTIFICATION_RESIZED: {
@@ -148,17 +145,17 @@ void Container::_notification(int p_what) {
void Container::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_sort_children"),&Container::_sort_children);
- ObjectTypeDB::bind_method(_MD("_child_minsize_changed"),&Container::_child_minsize_changed);
+ ObjectTypeDB::bind_method(_MD("_sort_children"), &Container::_sort_children);
+ ObjectTypeDB::bind_method(_MD("_child_minsize_changed"), &Container::_child_minsize_changed);
- ObjectTypeDB::bind_method(_MD("queue_sort"),&Container::queue_sort);
- ObjectTypeDB::bind_method(_MD("fit_child_in_rect","child:Control","rect"),&Container::fit_child_in_rect);
+ ObjectTypeDB::bind_method(_MD("queue_sort"), &Container::queue_sort);
+ ObjectTypeDB::bind_method(_MD("fit_child_in_rect", "child:Control", "rect"), &Container::fit_child_in_rect);
- BIND_CONSTANT( NOTIFICATION_SORT_CHILDREN );
+ BIND_CONSTANT(NOTIFICATION_SORT_CHILDREN);
ADD_SIGNAL(MethodInfo("sort_children"));
}
Container::Container() {
- pending_sort=false;
+ pending_sort = false;
}
diff --git a/scene/gui/container.h b/scene/gui/container.h
index 23693a7fd..12fd74b48 100644
--- a/scene/gui/container.h
+++ b/scene/gui/container.h
@@ -33,13 +33,13 @@
class Container : public Control {
- OBJ_TYPE(Container,Control);
+ OBJ_TYPE(Container, Control);
bool pending_sort;
void _sort_children();
void _child_minsize_changed();
-protected:
+protected:
void queue_sort();
virtual void add_child_notify(Node *p_child);
virtual void move_child_notify(Node *p_child);
@@ -47,12 +47,13 @@ protected:
void _notification(int p_what);
static void _bind_methods();
+
public:
enum {
- NOTIFICATION_SORT_CHILDREN=50
+ NOTIFICATION_SORT_CHILDREN = 50
};
- void fit_child_in_rect(Control *p_child,const Rect2& p_rect);
+ void fit_child_in_rect(Control *p_child, const Rect2 &p_rect);
Container();
};
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index a4c362ab0..0c85cc1db 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -27,55 +27,51 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "control.h"
-#include "servers/visual_server.h"
-#include "scene/main/viewport.h"
-#include "scene/main/canvas_layer.h"
#include "globals.h"
+#include "scene/main/canvas_layer.h"
+#include "scene/main/viewport.h"
+#include "servers/visual_server.h"
-#include "print_string.h"
+#include "message_queue.h"
#include "os/keyboard.h"
#include "os/os.h"
-#include "message_queue.h"
-#include "scene/scene_string_names.h"
-#include "scene/gui/panel.h"
+#include "print_string.h"
#include "scene/gui/label.h"
+#include "scene/gui/panel.h"
+#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#endif
#include <stdio.h>
-
-
-
Variant Control::edit_get_state() const {
Dictionary s;
- s["rect"]=get_rect();
- s["rot"]=get_rotation();
- s["scale"]=get_scale();
+ s["rect"] = get_rect();
+ s["rot"] = get_rotation();
+ s["scale"] = get_scale();
return s;
-
}
-void Control::edit_set_state(const Variant& p_state) {
+void Control::edit_set_state(const Variant &p_state) {
- Dictionary s=p_state;
+ Dictionary s = p_state;
- Rect2 state=s["rect"];
+ Rect2 state = s["rect"];
set_pos(state.pos);
set_size(state.size);
set_rotation(s["rot"]);
set_scale(s["scale"]);
}
-void Control::set_custom_minimum_size(const Size2& p_custom) {
+void Control::set_custom_minimum_size(const Size2 &p_custom) {
- if (p_custom==data.custom_minimum_size)
+ if (p_custom == data.custom_minimum_size)
return;
- data.custom_minimum_size=p_custom;
+ data.custom_minimum_size = p_custom;
minimum_size_changed();
}
-Size2 Control::get_custom_minimum_size() const{
+Size2 Control::get_custom_minimum_size() const {
return data.custom_minimum_size;
}
@@ -83,8 +79,8 @@ Size2 Control::get_custom_minimum_size() const{
Size2 Control::get_combined_minimum_size() const {
Size2 minsize = get_minimum_size();
- minsize.x = MAX(minsize.x,data.custom_minimum_size.x);
- minsize.y = MAX(minsize.y,data.custom_minimum_size.y);
+ minsize.x = MAX(minsize.x, data.custom_minimum_size.x);
+ minsize.y = MAX(minsize.y, data.custom_minimum_size.y);
return minsize;
}
@@ -93,48 +89,41 @@ Size2 Control::edit_get_minimum_size() const {
return get_combined_minimum_size();
}
-void Control::edit_set_rect(const Rect2& p_edit_rect) {
-
+void Control::edit_set_rect(const Rect2 &p_edit_rect) {
Matrix32 postxf;
- postxf.set_rotation_and_scale(data.rotation,data.scale);
+ postxf.set_rotation_and_scale(data.rotation, data.scale);
Vector2 new_pos = postxf.xform(p_edit_rect.pos);
- Vector2 pos = get_pos()+new_pos;
+ Vector2 pos = get_pos() + new_pos;
- Rect2 new_rect=get_rect();
- new_rect.pos=pos.snapped(Vector2(1,1));
- new_rect.size=p_edit_rect.size.snapped(Vector2(1,1));
+ Rect2 new_rect = get_rect();
+ new_rect.pos = pos.snapped(Vector2(1, 1));
+ new_rect.size = p_edit_rect.size.snapped(Vector2(1, 1));
set_pos(new_rect.pos);
set_size(new_rect.size);
-
}
-bool Control::_set(const StringName& p_name, const Variant& p_value) {
-
+bool Control::_set(const StringName &p_name, const Variant &p_value) {
- String name= p_name;
+ String name = p_name;
if (!name.begins_with("custom")) {
if (name.begins_with("margin/")) {
String dname = name.get_slicec('/', 1);
if (dname == "left") {
set_margin(MARGIN_LEFT, p_value);
return true;
- }
- else if (dname == "top") {
+ } else if (dname == "top") {
set_margin(MARGIN_TOP, p_value);
return true;
- }
- else if (dname == "right") {
+ } else if (dname == "right") {
set_margin(MARGIN_RIGHT, p_value);
return true;
- }
- else if (dname == "bottom") {
+ } else if (dname == "bottom") {
set_margin(MARGIN_BOTTOM, p_value);
return true;
- }
- else {
+ } else {
return false;
}
} else {
@@ -142,25 +131,25 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) {
}
}
- if (p_value.get_type()==Variant::NIL) {
+ if (p_value.get_type() == Variant::NIL) {
if (name.begins_with("custom_icons/")) {
- String dname = name.get_slicec('/',1);
+ String dname = name.get_slicec('/', 1);
data.icon_override.erase(dname);
notification(NOTIFICATION_THEME_CHANGED);
update();
} else if (name.begins_with("custom_shaders/")) {
- String dname = name.get_slicec('/',1);
+ String dname = name.get_slicec('/', 1);
data.shader_override.erase(dname);
notification(NOTIFICATION_THEME_CHANGED);
update();
} else if (name.begins_with("custom_styles/")) {
- String dname = name.get_slicec('/',1);
+ String dname = name.get_slicec('/', 1);
data.style_override.erase(dname);
notification(NOTIFICATION_THEME_CHANGED);
update();
} else if (name.begins_with("custom_fonts/")) {
- String dname = name.get_slicec('/',1);
+ String dname = name.get_slicec('/', 1);
if (data.font_override.has(dname)) {
_unref_font(data.font_override[dname]);
}
@@ -168,12 +157,12 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) {
notification(NOTIFICATION_THEME_CHANGED);
update();
} else if (name.begins_with("custom_colors/")) {
- String dname = name.get_slicec('/',1);
+ String dname = name.get_slicec('/', 1);
data.color_override.erase(dname);
notification(NOTIFICATION_THEME_CHANGED);
update();
} else if (name.begins_with("custom_constants/")) {
- String dname = name.get_slicec('/',1);
+ String dname = name.get_slicec('/', 1);
data.constant_override.erase(dname);
notification(NOTIFICATION_THEME_CHANGED);
update();
@@ -182,34 +171,33 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) {
} else {
if (name.begins_with("custom_icons/")) {
- String dname = name.get_slicec('/',1);
+ String dname = name.get_slicec('/', 1);
notification(NOTIFICATION_THEME_CHANGED);
- add_icon_override(dname,p_value);
+ add_icon_override(dname, p_value);
} else if (name.begins_with("custom_shaders/")) {
- String dname = name.get_slicec('/',1);
- add_shader_override(dname,p_value);
+ String dname = name.get_slicec('/', 1);
+ add_shader_override(dname, p_value);
notification(NOTIFICATION_THEME_CHANGED);
} else if (name.begins_with("custom_styles/")) {
- String dname = name.get_slicec('/',1);
- add_style_override(dname,p_value);
+ String dname = name.get_slicec('/', 1);
+ add_style_override(dname, p_value);
notification(NOTIFICATION_THEME_CHANGED);
} else if (name.begins_with("custom_fonts/")) {
- String dname = name.get_slicec('/',1);
- add_font_override(dname,p_value);
+ String dname = name.get_slicec('/', 1);
+ add_font_override(dname, p_value);
notification(NOTIFICATION_THEME_CHANGED);
} else if (name.begins_with("custom_colors/")) {
- String dname = name.get_slicec('/',1);
- add_color_override(dname,p_value);
+ String dname = name.get_slicec('/', 1);
+ add_color_override(dname, p_value);
notification(NOTIFICATION_THEME_CHANGED);
} else if (name.begins_with("custom_constants/")) {
- String dname = name.get_slicec('/',1);
- add_constant_override(dname,p_value);
+ String dname = name.get_slicec('/', 1);
+ add_constant_override(dname, p_value);
notification(NOTIFICATION_THEME_CHANGED);
} else
return false;
}
return true;
-
}
void Control::_update_minimum_size() {
@@ -217,22 +205,19 @@ void Control::_update_minimum_size() {
if (!is_inside_tree())
return;
- data.pending_min_size_update=false;
+ data.pending_min_size_update = false;
Size2 minsize = get_combined_minimum_size();
if (minsize.x > data.size_cache.x ||
- minsize.y > data.size_cache.y
- ) {
+ minsize.y > data.size_cache.y) {
_size_changed();
}
emit_signal(SceneStringNames::get_singleton()->minimum_size_changed);
-
}
-bool Control::_get(const StringName& p_name,Variant &r_ret) const {
+bool Control::_get(const StringName &p_name, Variant &r_ret) const {
-
- String sname=p_name;
+ String sname = p_name;
if (!sname.begins_with("custom")) {
if (sname.begins_with("margin/")) {
@@ -240,20 +225,16 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
if (dname == "left") {
r_ret = get_margin(MARGIN_LEFT);
return true;
- }
- else if (dname == "top") {
+ } else if (dname == "top") {
r_ret = get_margin(MARGIN_TOP);
return true;
- }
- else if (dname == "right") {
+ } else if (dname == "right") {
r_ret = get_margin(MARGIN_RIGHT);
return true;
- }
- else if (dname == "bottom") {
+ } else if (dname == "bottom") {
r_ret = get_margin(MARGIN_BOTTOM);
return true;
- }
- else {
+ } else {
return false;
}
} else {
@@ -262,65 +243,57 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
}
if (sname.begins_with("custom_icons/")) {
- String name = sname.get_slicec('/',1);
+ String name = sname.get_slicec('/', 1);
- r_ret= data.icon_override.has(name)?Variant(data.icon_override[name]):Variant();
+ r_ret = data.icon_override.has(name) ? Variant(data.icon_override[name]) : Variant();
} else if (sname.begins_with("custom_shaders/")) {
- String name = sname.get_slicec('/',1);
+ String name = sname.get_slicec('/', 1);
- r_ret= data.shader_override.has(name)?Variant(data.shader_override[name]):Variant();
+ r_ret = data.shader_override.has(name) ? Variant(data.shader_override[name]) : Variant();
} else if (sname.begins_with("custom_styles/")) {
- String name = sname.get_slicec('/',1);
+ String name = sname.get_slicec('/', 1);
- r_ret= data.style_override.has(name)?Variant(data.style_override[name]):Variant();
+ r_ret = data.style_override.has(name) ? Variant(data.style_override[name]) : Variant();
} else if (sname.begins_with("custom_fonts/")) {
- String name = sname.get_slicec('/',1);
+ String name = sname.get_slicec('/', 1);
- r_ret= data.font_override.has(name)?Variant(data.font_override[name]):Variant();
+ r_ret = data.font_override.has(name) ? Variant(data.font_override[name]) : Variant();
} else if (sname.begins_with("custom_colors/")) {
- String name = sname.get_slicec('/',1);
- r_ret= data.color_override.has(name)?Variant(data.color_override[name]):Variant();
+ String name = sname.get_slicec('/', 1);
+ r_ret = data.color_override.has(name) ? Variant(data.color_override[name]) : Variant();
} else if (sname.begins_with("custom_constants/")) {
- String name = sname.get_slicec('/',1);
+ String name = sname.get_slicec('/', 1);
- r_ret= data.constant_override.has(name)?Variant(data.constant_override[name]):Variant();
+ r_ret = data.constant_override.has(name) ? Variant(data.constant_override[name]) : Variant();
} else
return false;
-
-
return true;
-
-
}
-void Control::_get_property_list( List<PropertyInfo> *p_list) const {
+void Control::_get_property_list(List<PropertyInfo> *p_list) const {
{
if (get_anchor(MARGIN_LEFT) == ANCHOR_RATIO) {
p_list->push_back(PropertyInfo(Variant::REAL, "margin/left", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
+ } else {
p_list->push_back(PropertyInfo(Variant::INT, "margin/left", PROPERTY_HINT_RANGE, "-4096,4096"));
}
if (get_anchor(MARGIN_TOP) == ANCHOR_RATIO) {
p_list->push_back(PropertyInfo(Variant::REAL, "margin/top", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
+ } else {
p_list->push_back(PropertyInfo(Variant::INT, "margin/top", PROPERTY_HINT_RANGE, "-4096,4096"));
}
if (get_anchor(MARGIN_RIGHT) == ANCHOR_RATIO) {
p_list->push_back(PropertyInfo(Variant::REAL, "margin/right", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
+ } else {
p_list->push_back(PropertyInfo(Variant::INT, "margin/right", PROPERTY_HINT_RANGE, "-4096,4096"));
}
if (get_anchor(MARGIN_BOTTOM) == ANCHOR_RATIO) {
p_list->push_back(PropertyInfo(Variant::REAL, "margin/bottom", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
+ } else {
p_list->push_back(PropertyInfo(Variant::INT, "margin/bottom", PROPERTY_HINT_RANGE, "-4096,4096"));
}
}
@@ -328,106 +301,98 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
Ref<Theme> theme;
if (data.theme.is_valid()) {
- theme=data.theme;
+ theme = data.theme;
} else {
- theme=Theme::get_default();
+ theme = Theme::get_default();
}
-
{
List<StringName> names;
- theme->get_icon_list(get_type_name(),&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
+ theme->get_icon_list(get_type_name(), &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
+ uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
if (data.icon_override.has(E->get()))
- hint|=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_CHECKED;
+ hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
- p_list->push_back( PropertyInfo(Variant::OBJECT,"custom_icons/"+E->get(),PROPERTY_HINT_RESOURCE_TYPE, "Texture",hint) );
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture", hint));
}
}
{
List<StringName> names;
- theme->get_shader_list(get_type_name(),&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
+ theme->get_shader_list(get_type_name(), &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
+ uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
if (data.shader_override.has(E->get()))
- hint|=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_CHECKED;
+ hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
- p_list->push_back( PropertyInfo(Variant::OBJECT,"custom_shaders/"+E->get(),PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph",hint) );
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_shaders/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph", hint));
}
}
{
List<StringName> names;
- theme->get_stylebox_list(get_type_name(),&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
+ theme->get_stylebox_list(get_type_name(), &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
+ uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
if (data.style_override.has(E->get()))
- hint|=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_CHECKED;
+ hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
- p_list->push_back( PropertyInfo(Variant::OBJECT,"custom_styles/"+E->get(),PROPERTY_HINT_RESOURCE_TYPE, "StyleBox",hint) );
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_styles/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", hint));
}
}
{
List<StringName> names;
- theme->get_font_list(get_type_name(),&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
+ theme->get_font_list(get_type_name(), &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
+ uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
if (data.font_override.has(E->get()))
- hint|=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_CHECKED;
+ hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
- p_list->push_back( PropertyInfo(Variant::OBJECT,"custom_fonts/"+E->get(),PROPERTY_HINT_RESOURCE_TYPE, "Font",hint) );
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_fonts/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Font", hint));
}
}
{
List<StringName> names;
- theme->get_color_list(get_type_name(),&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
+ theme->get_color_list(get_type_name(), &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
+ uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
if (data.color_override.has(E->get()))
- hint|=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_CHECKED;
+ hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
- p_list->push_back( PropertyInfo(Variant::COLOR,"custom_colors/"+E->get(),PROPERTY_HINT_NONE, "",hint) );
+ p_list->push_back(PropertyInfo(Variant::COLOR, "custom_colors/" + E->get(), PROPERTY_HINT_NONE, "", hint));
}
}
{
List<StringName> names;
- theme->get_constant_list(get_type_name(),&names);
- for(List<StringName>::Element *E=names.front();E;E=E->next()) {
+ theme->get_constant_list(get_type_name(), &names);
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
+ uint32_t hint = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
if (data.constant_override.has(E->get()))
- hint|=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_CHECKED;
+ hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
- p_list->push_back( PropertyInfo(Variant::INT,"custom_constants/"+E->get(),PROPERTY_HINT_RANGE, "-16384,16384",hint) );
+ p_list->push_back(PropertyInfo(Variant::INT, "custom_constants/" + E->get(), PROPERTY_HINT_RANGE, "-16384,16384", hint));
}
}
-
-
}
-
Control *Control::get_parent_control() const {
return data.parent;
}
-
-void Control::_resize(const Size2& p_size) {
+void Control::_resize(const Size2 &p_size) {
_size_changed();
}
-
-
void Control::_notification(int p_notification) {
-
- switch(p_notification) {
+ switch (p_notification) {
case NOTIFICATION_ENTER_TREE: {
@@ -438,43 +403,40 @@ void Control::_notification(int p_notification) {
get_viewport()->_gui_remove_control(this);
-
} break;
-
case NOTIFICATION_ENTER_CANVAS: {
- data.parent=get_parent()->cast_to<Control>();
+ data.parent = get_parent()->cast_to<Control>();
if (is_set_as_toplevel()) {
- data.SI=get_viewport()->_gui_add_subwindow_control(this);
+ data.SI = get_viewport()->_gui_add_subwindow_control(this);
if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
- data.theme_owner=data.parent->data.theme_owner;
+ data.theme_owner = data.parent->data.theme_owner;
notification(NOTIFICATION_THEME_CHANGED);
}
} else {
+ Node *parent = this; //meh
+ Control *parent_control = NULL;
+ bool subwindow = false;
- Node *parent=this; //meh
- Control *parent_control=NULL;
- bool subwindow=false;
-
- while(parent) {
+ while (parent) {
- parent=parent->get_parent();
+ parent = parent->get_parent();
if (!parent)
break;
- CanvasItem *ci =parent->cast_to<CanvasItem>();
+ CanvasItem *ci = parent->cast_to<CanvasItem>();
if (ci && ci->is_set_as_toplevel()) {
- subwindow=true;
+ subwindow = true;
break;
}
- parent_control=parent->cast_to<Control>();
+ parent_control = parent->cast_to<Control>();
if (parent_control) {
break;
@@ -485,35 +447,33 @@ void Control::_notification(int p_notification) {
}
}
-
if (parent_control) {
//do nothing, has a parent control
if (data.theme.is_null() && parent_control->data.theme_owner) {
- data.theme_owner=parent_control->data.theme_owner;
+ data.theme_owner = parent_control->data.theme_owner;
notification(NOTIFICATION_THEME_CHANGED);
}
} else if (subwindow) {
//is a subwindow (process input before other controls for that canvas)
- data.SI=get_viewport()->_gui_add_subwindow_control(this);
+ data.SI = get_viewport()->_gui_add_subwindow_control(this);
} else {
//is a regular root control
- data.RI=get_viewport()->_gui_add_root_control(this);
+ data.RI = get_viewport()->_gui_add_root_control(this);
}
- data.parent_canvas_item=get_parent_item();
+ data.parent_canvas_item = get_parent_item();
if (data.parent_canvas_item) {
- data.parent_canvas_item->connect("item_rect_changed",this,"_size_changed");
- } else {
+ data.parent_canvas_item->connect("item_rect_changed", this, "_size_changed");
+ } else {
//connect viewport
- get_viewport()->connect("size_changed",this,"_size_changed");
+ get_viewport()->connect("size_changed", this, "_size_changed");
}
}
-
if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
- data.theme_owner=data.parent->data.theme_owner;
+ data.theme_owner = data.parent->data.theme_owner;
notification(NOTIFICATION_THEME_CHANGED);
}
@@ -522,62 +482,61 @@ void Control::_notification(int p_notification) {
if (data.parent_canvas_item) {
- data.parent_canvas_item->disconnect("item_rect_changed",this,"_size_changed");
- data.parent_canvas_item=NULL;
+ data.parent_canvas_item->disconnect("item_rect_changed", this, "_size_changed");
+ data.parent_canvas_item = NULL;
} else if (!is_set_as_toplevel()) {
//disconnect viewport
- get_viewport()->disconnect("size_changed",this,"_size_changed");
-
+ get_viewport()->disconnect("size_changed", this, "_size_changed");
}
if (data.MI) {
get_viewport()->_gui_remove_modal_control(data.MI);
- data.MI=NULL;
+ data.MI = NULL;
}
if (data.SI) {
get_viewport()->_gui_remove_subwindow_control(data.SI);
- data.SI=NULL;
+ data.SI = NULL;
}
if (data.RI) {
get_viewport()->_gui_remove_root_control(data.RI);
- data.RI=NULL;
+ data.RI = NULL;
}
- data.parent=NULL;
- data.parent_canvas_item=NULL;
+ data.parent = NULL;
+ data.parent_canvas_item = NULL;
if (data.theme_owner && data.theme.is_null()) {
- data.theme_owner=NULL;
+ data.theme_owner = NULL;
//notification(NOTIFICATION_THEME_CHANGED);
}
} break;
- case NOTIFICATION_MOVED_IN_PARENT: {
- // some parents need to know the order of the childrens to draw (like TabContainer)
- // update if necesary
- if (data.parent)
- data.parent->update();
- update();
+ case NOTIFICATION_MOVED_IN_PARENT: {
+ // some parents need to know the order of the childrens to draw (like TabContainer)
+ // update if necesary
+ if (data.parent)
+ data.parent->update();
+ update();
- if (data.SI) {
- get_viewport()->_gui_set_subwindow_order_dirty();
- }
- if (data.RI) {
- get_viewport()->_gui_set_root_order_dirty();
- }
+ if (data.SI) {
+ get_viewport()->_gui_set_subwindow_order_dirty();
+ }
+ if (data.RI) {
+ get_viewport()->_gui_set_root_order_dirty();
+ }
- } break;
+ } break;
case NOTIFICATION_RESIZED: {
emit_signal(SceneStringNames::get_singleton()->resized);
} break;
case NOTIFICATION_DRAW: {
- Matrix32 xform=Matrix32(data.rotation,get_pos());
+ Matrix32 xform = Matrix32(data.rotation, get_pos());
xform.scale_basis(data.scale);
- VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),xform);
- VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),true, Rect2(Point2(),get_size()));
+ VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), xform);
+ VisualServer::get_singleton()->canvas_item_set_custom_rect(get_canvas_item(), true, Rect2(Point2(), get_size()));
//emit_signal(SceneStringNames::get_singleton()->draw);
} break;
@@ -612,10 +571,10 @@ void Control::_notification(int p_notification) {
if (!is_visible()) {
- if(get_viewport() != NULL)
+ if (get_viewport() != NULL)
get_viewport()->_gui_hid_control(this);
- if(is_inside_tree()) {
+ if (is_inside_tree()) {
_modal_stack_remove();
minimum_size_changed();
}
@@ -633,25 +592,21 @@ void Control::_notification(int p_notification) {
get_viewport()->_gui_unfocus_control(this);
} break;
-
-
-
}
}
-
bool Control::clips_input() const {
return false;
}
-bool Control::has_point(const Point2& p_point) const {
+bool Control::has_point(const Point2 &p_point) const {
if (get_script_instance()) {
- Variant v=p_point;
- const Variant *p=&v;
+ Variant v = p_point;
+ const Variant *p = &v;
Variant::CallError ce;
- Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->has_point,&p,1,ce);
- if (ce.error==Variant::CallError::CALL_OK) {
+ Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->has_point, &p, 1, ce);
+ if (ce.error == Variant::CallError::CALL_OK) {
return ret;
}
}
@@ -659,101 +614,95 @@ bool Control::has_point(const Point2& p_point) const {
Ref<StyleBox> mask = get_stylebox("mask");
return mask->test_mask(p_point,Rect2(Point2(),get_size()));
}*/
- return Rect2( Point2(), get_size() ).has_point(p_point);
+ return Rect2(Point2(), get_size()).has_point(p_point);
}
-void Control::set_drag_forwarding(Control* p_target) {
+void Control::set_drag_forwarding(Control *p_target) {
if (p_target)
- data.drag_owner=p_target->get_instance_ID();
+ data.drag_owner = p_target->get_instance_ID();
else
- data.drag_owner=0;
+ data.drag_owner = 0;
}
-Variant Control::get_drag_data(const Point2& p_point) {
+Variant Control::get_drag_data(const Point2 &p_point) {
if (data.drag_owner) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
Control *c = obj->cast_to<Control>();
- return c->call("get_drag_data_fw",p_point,this);
+ return c->call("get_drag_data_fw", p_point, this);
}
}
if (get_script_instance()) {
- Variant v=p_point;
- const Variant *p=&v;
+ Variant v = p_point;
+ const Variant *p = &v;
Variant::CallError ce;
- Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->get_drag_data,&p,1,ce);
- if (ce.error==Variant::CallError::CALL_OK)
+ Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->get_drag_data, &p, 1, ce);
+ if (ce.error == Variant::CallError::CALL_OK)
return ret;
}
return Variant();
}
-
-bool Control::can_drop_data(const Point2& p_point,const Variant& p_data) const {
+bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
if (data.drag_owner) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
Control *c = obj->cast_to<Control>();
- return c->call("can_drop_data_fw",p_point,p_data,this);
+ return c->call("can_drop_data_fw", p_point, p_data, this);
}
}
if (get_script_instance()) {
- Variant v=p_point;
- const Variant *p[2]={&v,&p_data};
+ Variant v = p_point;
+ const Variant *p[2] = { &v, &p_data };
Variant::CallError ce;
- Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->can_drop_data,p,2,ce);
- if (ce.error==Variant::CallError::CALL_OK)
+ Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->can_drop_data, p, 2, ce);
+ if (ce.error == Variant::CallError::CALL_OK)
return ret;
}
return Variant();
-
}
-void Control::drop_data(const Point2& p_point,const Variant& p_data){
+void Control::drop_data(const Point2 &p_point, const Variant &p_data) {
if (data.drag_owner) {
Object *obj = ObjectDB::get_instance(data.drag_owner);
if (obj) {
Control *c = obj->cast_to<Control>();
- c->call("drop_data_fw",p_point,p_data,this);
+ c->call("drop_data_fw", p_point, p_data, this);
return;
}
}
if (get_script_instance()) {
- Variant v=p_point;
- const Variant *p[2]={&v,&p_data};
+ Variant v = p_point;
+ const Variant *p[2] = { &v, &p_data };
Variant::CallError ce;
- Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->drop_data,p,2,ce);
- if (ce.error==Variant::CallError::CALL_OK)
+ Variant ret = get_script_instance()->call(SceneStringNames::get_singleton()->drop_data, p, 2, ce);
+ if (ce.error == Variant::CallError::CALL_OK)
return;
}
}
-void Control::force_drag(const Variant& p_data,Control *p_control) {
+void Control::force_drag(const Variant &p_data, Control *p_control) {
ERR_FAIL_COND(!is_inside_tree());
- ERR_FAIL_COND(p_data.get_type()==Variant::NIL);
-
- get_viewport()->_gui_force_drag(this,p_data,p_control);
+ ERR_FAIL_COND(p_data.get_type() == Variant::NIL);
+ get_viewport()->_gui_force_drag(this, p_data, p_control);
}
void Control::set_drag_preview(Control *p_control) {
ERR_FAIL_COND(!is_inside_tree());
- get_viewport()->_gui_set_drag_preview(this,p_control);
+ get_viewport()->_gui_set_drag_preview(this, p_control);
}
-
-
-
bool Control::is_window_modal_on_top() const {
if (!is_inside_tree())
@@ -767,204 +716,190 @@ uint64_t Control::get_modal_frame() const {
return data.modal_frame;
}
-
-
Size2 Control::get_minimum_size() const {
- ScriptInstance *si = const_cast<Control*>(this)->get_script_instance();
+ ScriptInstance *si = const_cast<Control *>(this)->get_script_instance();
if (si) {
Variant::CallError ce;
- Variant s = si->call(SceneStringNames::get_singleton()->get_minimum_size,NULL,0,ce);
- if (ce.error==Variant::CallError::CALL_OK)
+ Variant s = si->call(SceneStringNames::get_singleton()->get_minimum_size, NULL, 0, ce);
+ if (ce.error == Variant::CallError::CALL_OK)
return s;
}
return Size2();
}
+Ref<Texture> Control::get_icon(const StringName &p_name, const StringName &p_type) const {
-Ref<Texture> Control::get_icon(const StringName& p_name,const StringName& p_type) const {
-
- if (p_type==StringName() || p_type=="") {
+ if (p_type == StringName() || p_type == "") {
- const Ref<Texture>* tex = data.icon_override.getptr(p_name);
+ const Ref<Texture> *tex = data.icon_override.getptr(p_name);
if (tex)
return *tex;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_icon(p_name, type ) )
- return theme_owner->data.theme->get_icon(p_name, type );
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ if (theme_owner->data.theme->has_icon(p_name, type))
+ return theme_owner->data.theme->get_icon(p_name, type);
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->get_icon( p_name, type );
-
+ return Theme::get_default()->get_icon(p_name, type);
}
-Ref<Shader> Control::get_shader(const StringName& p_name,const StringName& p_type) const {
- if (p_type==StringName() || p_type=="") {
+Ref<Shader> Control::get_shader(const StringName &p_name, const StringName &p_type) const {
+ if (p_type == StringName() || p_type == "") {
- const Ref<Shader>* sdr = data.shader_override.getptr(p_name);
+ const Ref<Shader> *sdr = data.shader_override.getptr(p_name);
if (sdr)
return *sdr;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
if (theme_owner->data.theme->has_shader(p_name, type))
- return theme_owner->data.theme->get_shader(p_name, type );
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ return theme_owner->data.theme->get_shader(p_name, type);
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->get_shader( p_name, type );
+ return Theme::get_default()->get_shader(p_name, type);
}
-Ref<StyleBox> Control::get_stylebox(const StringName& p_name,const StringName& p_type) const {
+Ref<StyleBox> Control::get_stylebox(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
- const Ref<StyleBox>* style = data.style_override.getptr(p_name);
+ if (p_type == StringName() || p_type == "") {
+ const Ref<StyleBox> *style = data.style_override.getptr(p_name);
if (style)
return *style;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_stylebox(p_name, type ) ) {
- return theme_owner->data.theme->get_stylebox(p_name, type );
+ if (theme_owner->data.theme->has_stylebox(p_name, type)) {
+ return theme_owner->data.theme->get_stylebox(p_name, type);
}
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
+ theme_owner = NULL;
}
- return Theme::get_default()->get_stylebox( p_name, type );
-
+ return Theme::get_default()->get_stylebox(p_name, type);
}
-Ref<Font> Control::get_font(const StringName& p_name,const StringName& p_type) const {
+Ref<Font> Control::get_font(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
- const Ref<Font>* font = data.font_override.getptr(p_name);
+ if (p_type == StringName() || p_type == "") {
+ const Ref<Font> *font = data.font_override.getptr(p_name);
if (font)
return *font;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_font(p_name, type ) )
- return theme_owner->data.theme->get_font(p_name, type );
+ if (theme_owner->data.theme->has_font(p_name, type))
+ return theme_owner->data.theme->get_font(p_name, type);
if (theme_owner->data.theme->get_default_theme_font().is_valid())
return theme_owner->data.theme->get_default_theme_font();
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->get_font( p_name, type );
-
+ return Theme::get_default()->get_font(p_name, type);
}
-Color Control::get_color(const StringName& p_name,const StringName& p_type) const {
+Color Control::get_color(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
- const Color* color = data.color_override.getptr(p_name);
+ if (p_type == StringName() || p_type == "") {
+ const Color *color = data.color_override.getptr(p_name);
if (color)
return *color;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_color(p_name, type ) )
- return theme_owner->data.theme->get_color(p_name, type );
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ if (theme_owner->data.theme->has_color(p_name, type))
+ return theme_owner->data.theme->get_color(p_name, type);
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->get_color( p_name, type );
-
+ return Theme::get_default()->get_color(p_name, type);
}
-int Control::get_constant(const StringName& p_name,const StringName& p_type) const {
+int Control::get_constant(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
- const int* constant = data.constant_override.getptr(p_name);
+ if (p_type == StringName() || p_type == "") {
+ const int *constant = data.constant_override.getptr(p_name);
if (constant)
return *constant;
}
- StringName type = p_type?p_type:get_type_name();
- // try with custom themes
+ StringName type = p_type ? p_type : get_type_name();
+ // try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_constant(p_name, type ) )
- return theme_owner->data.theme->get_constant(p_name, type );
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ if (theme_owner->data.theme->has_constant(p_name, type))
+ return theme_owner->data.theme->get_constant(p_name, type);
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->get_constant( p_name, type );
-
-
+ return Theme::get_default()->get_constant(p_name, type);
}
-bool Control::has_icon_override(const StringName& p_name) const {
+bool Control::has_icon_override(const StringName &p_name) const {
- const Ref<Texture>* tex = data.icon_override.getptr(p_name);
+ const Ref<Texture> *tex = data.icon_override.getptr(p_name);
if (tex)
return true;
else
@@ -973,237 +908,223 @@ bool Control::has_icon_override(const StringName& p_name) const {
bool Control::has_shader_override(const StringName &p_name) const {
- const Ref<Shader>* sdr = data.shader_override.getptr(p_name);
+ const Ref<Shader> *sdr = data.shader_override.getptr(p_name);
if (sdr)
return true;
else
return false;
}
-bool Control::has_stylebox_override(const StringName& p_name) const {
+bool Control::has_stylebox_override(const StringName &p_name) const {
- const Ref<StyleBox>* style = data.style_override.getptr(p_name);
+ const Ref<StyleBox> *style = data.style_override.getptr(p_name);
if (style)
return true;
else
return false;
}
-bool Control::has_font_override(const StringName& p_name) const {
+bool Control::has_font_override(const StringName &p_name) const {
- const Ref<Font>* font = data.font_override.getptr(p_name);
+ const Ref<Font> *font = data.font_override.getptr(p_name);
if (font)
return true;
else
return false;
}
-bool Control::has_color_override(const StringName& p_name) const {
+bool Control::has_color_override(const StringName &p_name) const {
- const Color* color = data.color_override.getptr(p_name);
+ const Color *color = data.color_override.getptr(p_name);
if (color)
return true;
else
return false;
}
-bool Control::has_constant_override(const StringName& p_name) const {
+bool Control::has_constant_override(const StringName &p_name) const {
- const int* constant = data.constant_override.getptr(p_name);
+ const int *constant = data.constant_override.getptr(p_name);
if (constant)
return true;
else
return false;
}
-bool Control::has_icon(const StringName& p_name,const StringName& p_type) const {
+bool Control::has_icon(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
+ if (p_type == StringName() || p_type == "") {
if (has_icon_override(p_name) == true)
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_icon(p_name, type ) )
+ if (theme_owner->data.theme->has_icon(p_name, type))
return true;
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->has_icon( p_name, type );
-
+ return Theme::get_default()->has_icon(p_name, type);
}
bool Control::has_shader(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
- if (has_shader_override(p_name)==true)
+ if (p_type == StringName() || p_type == "") {
+ if (has_shader_override(p_name) == true)
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
if (theme_owner->data.theme->has_shader(p_name, type))
return true;
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->has_shader( p_name, type );
-
+ return Theme::get_default()->has_shader(p_name, type);
}
-bool Control::has_stylebox(const StringName& p_name,const StringName& p_type) const {
+bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
- if (has_stylebox_override(p_name)==true)
+ if (p_type == StringName() || p_type == "") {
+ if (has_stylebox_override(p_name) == true)
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_stylebox(p_name, type ) )
+ if (theme_owner->data.theme->has_stylebox(p_name, type))
return true;
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->has_stylebox( p_name, type );
-
+ return Theme::get_default()->has_stylebox(p_name, type);
}
-bool Control::has_font(const StringName& p_name,const StringName& p_type) const {
+bool Control::has_font(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
- if (has_font_override(p_name)==true)
+ if (p_type == StringName() || p_type == "") {
+ if (has_font_override(p_name) == true)
return true;
}
-
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_font(p_name, type ) )
+ if (theme_owner->data.theme->has_font(p_name, type))
return true;
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->has_font( p_name, type );
-
+ return Theme::get_default()->has_font(p_name, type);
}
-bool Control::has_color(const StringName& p_name, const StringName& p_type) const {
+bool Control::has_color(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
- if (has_color_override(p_name)==true)
+ if (p_type == StringName() || p_type == "") {
+ if (has_color_override(p_name) == true)
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_color(p_name, type ) )
+ if (theme_owner->data.theme->has_color(p_name, type))
return true;
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->has_color( p_name, type );
-
+ return Theme::get_default()->has_color(p_name, type);
}
-bool Control::has_constant(const StringName& p_name,const StringName& p_type) const {
+bool Control::has_constant(const StringName &p_name, const StringName &p_type) const {
- if (p_type==StringName() || p_type=="") {
+ if (p_type == StringName() || p_type == "") {
if (has_constant_override(p_name) == true)
return true;
}
-
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type ? p_type : get_type_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
- while(theme_owner) {
+ while (theme_owner) {
- if (theme_owner->data.theme->has_constant(p_name, type ) )
+ if (theme_owner->data.theme->has_constant(p_name, type))
return true;
- Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
+ Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL;
if (parent)
- theme_owner=parent->data.theme_owner;
+ theme_owner = parent->data.theme_owner;
else
- theme_owner=NULL;
-
+ theme_owner = NULL;
}
- return Theme::get_default()->has_constant( p_name, type );
+ return Theme::get_default()->has_constant(p_name, type);
}
Size2 Control::get_parent_area_size() const {
- ERR_FAIL_COND_V(!is_inside_tree(),Size2());
+ ERR_FAIL_COND_V(!is_inside_tree(), Size2());
Size2 parent_size;
if (data.parent_canvas_item) {
- parent_size=data.parent_canvas_item->get_item_rect().size;
+ parent_size = data.parent_canvas_item->get_item_rect().size;
} else {
- parent_size=get_viewport()->get_visible_rect().size;
+ parent_size = get_viewport()->get_visible_rect().size;
}
return parent_size;
-
}
void Control::_size_changed() {
@@ -1215,43 +1136,42 @@ void Control::_size_changed() {
float margin_pos[4];
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- float area = parent_size[i&1];
- switch(data.anchor[i]) {
+ float area = parent_size[i & 1];
+ switch (data.anchor[i]) {
case ANCHOR_BEGIN: {
- margin_pos[i]=data.margin[i];
+ margin_pos[i] = data.margin[i];
} break;
case ANCHOR_END: {
- margin_pos[i]=area-data.margin[i];
+ margin_pos[i] = area - data.margin[i];
} break;
case ANCHOR_RATIO: {
- margin_pos[i]=area*data.margin[i];
+ margin_pos[i] = area * data.margin[i];
} break;
- case ANCHOR_CENTER: {
+ case ANCHOR_CENTER: {
- margin_pos[i]=(area/2)-data.margin[i];
- } break;
+ margin_pos[i] = (area / 2) - data.margin[i];
+ } break;
}
}
- Point2 new_pos_cache=Point2(margin_pos[0],margin_pos[1]).floor();
- Size2 new_size_cache=Point2(margin_pos[2],margin_pos[3]).floor()-new_pos_cache;
- Size2 minimum_size=get_combined_minimum_size();
-
- new_size_cache.x = MAX( minimum_size.x, new_size_cache.x );
- new_size_cache.y = MAX( minimum_size.y, new_size_cache.y );
+ Point2 new_pos_cache = Point2(margin_pos[0], margin_pos[1]).floor();
+ Size2 new_size_cache = Point2(margin_pos[2], margin_pos[3]).floor() - new_pos_cache;
+ Size2 minimum_size = get_combined_minimum_size();
+ new_size_cache.x = MAX(minimum_size.x, new_size_cache.x);
+ new_size_cache.y = MAX(minimum_size.y, new_size_cache.y);
if (new_pos_cache == data.pos_cache && new_size_cache == data.size_cache)
return; // did not change, don't emit signal
- data.pos_cache=new_pos_cache;
- data.size_cache=new_size_cache;
+ data.pos_cache = new_pos_cache;
+ data.size_cache = new_size_cache;
notification(NOTIFICATION_RESIZED);
item_rect_changed();
@@ -1264,82 +1184,79 @@ float Control::_get_parent_range(int p_idx) const {
if (!is_inside_tree()) {
return 1.0;
+ }
+ if (data.parent_canvas_item) {
- } if (data.parent_canvas_item) {
-
- return data.parent_canvas_item->get_item_rect().size[p_idx&1];
+ return data.parent_canvas_item->get_item_rect().size[p_idx & 1];
} else {
- return get_viewport()->get_visible_rect().size[p_idx&1];
+ return get_viewport()->get_visible_rect().size[p_idx & 1];
}
return 1.0;
}
-
float Control::_get_range(int p_idx) const {
- p_idx&=1;
+ p_idx &= 1;
- float parent_range = _get_parent_range( p_idx );
- float from = _a2s( data.margin[p_idx], data.anchor[p_idx], parent_range );
- float to = _a2s( data.margin[p_idx+2], data.anchor[p_idx+2], parent_range );
+ float parent_range = _get_parent_range(p_idx);
+ float from = _a2s(data.margin[p_idx], data.anchor[p_idx], parent_range);
+ float to = _a2s(data.margin[p_idx + 2], data.anchor[p_idx + 2], parent_range);
- return to-from;
+ return to - from;
}
-float Control::_s2a(float p_val, AnchorType p_anchor,float p_range) const {
+float Control::_s2a(float p_val, AnchorType p_anchor, float p_range) const {
- switch(p_anchor) {
+ switch (p_anchor) {
case ANCHOR_BEGIN: {
return p_val;
} break;
case ANCHOR_END: {
- return p_range-p_val;
+ return p_range - p_val;
} break;
case ANCHOR_RATIO: {
- return p_val/p_range;
+ return p_val / p_range;
+ } break;
+ case ANCHOR_CENTER: {
+ return (p_range / 2) - p_val;
} break;
- case ANCHOR_CENTER: {
- return (p_range/2)-p_val;
- } break;
}
return 0;
}
+float Control::_a2s(float p_val, AnchorType p_anchor, float p_range) const {
-float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const {
-
- switch(p_anchor) {
+ switch (p_anchor) {
case ANCHOR_BEGIN: {
return Math::floor(p_val);
} break;
case ANCHOR_END: {
- return Math::floor(p_range-p_val);
+ return Math::floor(p_range - p_val);
} break;
case ANCHOR_RATIO: {
- return Math::floor(p_range*p_val);
+ return Math::floor(p_range * p_val);
} break;
case ANCHOR_CENTER: {
- return Math::floor((p_range/2)-p_val);
+ return Math::floor((p_range / 2) - p_val);
} break;
}
return 0;
}
-
-void Control::set_anchor(Margin p_margin,AnchorType p_anchor, bool p_keep_margin) {
+void Control::set_anchor(Margin p_margin, AnchorType p_anchor, bool p_keep_margin) {
if (!is_inside_tree()) {
data.anchor[p_margin] = p_anchor;
- } else if(!p_keep_margin) {
+ } else if (!p_keep_margin) {
float pr = _get_parent_range(p_margin);
- float s = _a2s( data.margin[p_margin], data.anchor[p_margin], pr );
+ float s = _a2s(data.margin[p_margin], data.anchor[p_margin], pr);
data.anchor[p_margin] = p_anchor;
- data.margin[p_margin] = _s2a( s, p_anchor, pr );
+ data.margin[p_margin] = _s2a(s, p_anchor, pr);
} else {
data.anchor[p_margin] = p_anchor;
_size_changed();
@@ -1347,34 +1264,29 @@ void Control::set_anchor(Margin p_margin,AnchorType p_anchor, bool p_keep_margin
_change_notify();
}
-void Control::_set_anchor(Margin p_margin,AnchorType p_anchor) {
- #ifdef TOOLS_ENABLED
+void Control::_set_anchor(Margin p_margin, AnchorType p_anchor) {
+#ifdef TOOLS_ENABLED
if (is_inside_tree() && get_tree()->is_editor_hint()) {
set_anchor(p_margin, p_anchor, EDITOR_DEF("2d_editor/keep_margins_when_changing_anchors", false));
} else {
set_anchor(p_margin, p_anchor, false);
}
- #else
+#else
set_anchor(p_margin, p_anchor, false);
- #endif
+#endif
}
-void Control::set_anchor_and_margin(Margin p_margin,AnchorType p_anchor, float p_pos) {
+void Control::set_anchor_and_margin(Margin p_margin, AnchorType p_anchor, float p_pos) {
- set_anchor(p_margin,p_anchor);
- set_margin(p_margin,p_pos);
+ set_anchor(p_margin, p_anchor);
+ set_margin(p_margin, p_pos);
}
-
Control::AnchorType Control::get_anchor(Margin p_margin) const {
return data.anchor[p_margin];
}
-
-
-
-
void Control::_change_notify_margins() {
// this avoids sending the whole object data again on a change
@@ -1384,28 +1296,25 @@ void Control::_change_notify_margins() {
_change_notify("margin/bottom");
_change_notify("rect/pos");
_change_notify("rect/size");
-
}
+void Control::set_margin(Margin p_margin, float p_value) {
-void Control::set_margin(Margin p_margin,float p_value) {
-
- data.margin[p_margin]=p_value;
+ data.margin[p_margin] = p_value;
_size_changed();
-
}
-void Control::set_begin(const Size2& p_point) {
+void Control::set_begin(const Size2 &p_point) {
- data.margin[0]=p_point.x;
- data.margin[1]=p_point.y;
+ data.margin[0] = p_point.x;
+ data.margin[1] = p_point.y;
_size_changed();
}
-void Control::set_end(const Size2& p_point) {
+void Control::set_end(const Size2 &p_point) {
- data.margin[2]=p_point.x;
- data.margin[3]=p_point.y;
+ data.margin[2] = p_point.x;
+ data.margin[3] = p_point.y;
_size_changed();
}
@@ -1416,11 +1325,11 @@ float Control::get_margin(Margin p_margin) const {
Size2 Control::get_begin() const {
- return Size2( data.margin[0], data.margin[1] );
+ return Size2(data.margin[0], data.margin[1]);
}
Size2 Control::get_end() const {
- return Size2( data.margin[2], data.margin[3] );
+ return Size2(data.margin[2], data.margin[3]);
}
Point2 Control::get_global_pos() const {
@@ -1428,7 +1337,7 @@ Point2 Control::get_global_pos() const {
return get_global_transform().get_origin();
}
-void Control::set_global_pos(const Point2& p_point) {
+void Control::set_global_pos(const Point2 &p_point) {
Matrix32 inv;
@@ -1440,60 +1349,58 @@ void Control::set_global_pos(const Point2& p_point) {
set_pos(inv.xform(p_point));
}
-void Control::set_pos(const Size2& p_point) {
+void Control::set_pos(const Size2 &p_point) {
float pw = _get_parent_range(0);
float ph = _get_parent_range(1);
- float x = _a2s( data.margin[0], data.anchor[0], pw );
- float y = _a2s( data.margin[1], data.anchor[1], ph );
- float x2 = _a2s( data.margin[2], data.anchor[2], pw );
- float y2 = _a2s( data.margin[3], data.anchor[3], ph );
+ float x = _a2s(data.margin[0], data.anchor[0], pw);
+ float y = _a2s(data.margin[1], data.anchor[1], ph);
+ float x2 = _a2s(data.margin[2], data.anchor[2], pw);
+ float y2 = _a2s(data.margin[3], data.anchor[3], ph);
- Size2 ret = Size2(x2-x,y2-y);
+ Size2 ret = Size2(x2 - x, y2 - y);
Size2 min = get_combined_minimum_size();
- Size2 size = Size2(MAX( min.width, ret.width),MAX( min.height, ret.height));
- float w=size.x;
- float h=size.y;
+ Size2 size = Size2(MAX(min.width, ret.width), MAX(min.height, ret.height));
+ float w = size.x;
+ float h = size.y;
- x=p_point.x;
- y=p_point.y;
+ x = p_point.x;
+ y = p_point.y;
- data.margin[0] = _s2a( x, data.anchor[0], pw );
- data.margin[1] = _s2a( y, data.anchor[1], ph );
- data.margin[2] = _s2a( x+w, data.anchor[2], pw );
- data.margin[3] = _s2a( y+h, data.anchor[3], ph );
+ data.margin[0] = _s2a(x, data.anchor[0], pw);
+ data.margin[1] = _s2a(y, data.anchor[1], ph);
+ data.margin[2] = _s2a(x + w, data.anchor[2], pw);
+ data.margin[3] = _s2a(y + h, data.anchor[3], ph);
_size_changed();
}
-void Control::set_size(const Size2& p_size) {
+void Control::set_size(const Size2 &p_size) {
- Size2 new_size=p_size;
- Size2 min=get_combined_minimum_size();
- if (new_size.x<min.x)
- new_size.x=min.x;
- if (new_size.y<min.y)
- new_size.y=min.y;
+ Size2 new_size = p_size;
+ Size2 min = get_combined_minimum_size();
+ if (new_size.x < min.x)
+ new_size.x = min.x;
+ if (new_size.y < min.y)
+ new_size.y = min.y;
float pw = _get_parent_range(0);
float ph = _get_parent_range(1);
- float x = _a2s( data.margin[0], data.anchor[0], pw );
- float y = _a2s( data.margin[1], data.anchor[1], ph );
+ float x = _a2s(data.margin[0], data.anchor[0], pw);
+ float y = _a2s(data.margin[1], data.anchor[1], ph);
- float w=new_size.width;
- float h=new_size.height;
+ float w = new_size.width;
+ float h = new_size.height;
- data.margin[2] = _s2a( x+w, data.anchor[2], pw );
- data.margin[3] = _s2a( y+h, data.anchor[3], ph );
+ data.margin[2] = _s2a(x + w, data.anchor[2], pw);
+ data.margin[3] = _s2a(y + h, data.anchor[3], ph);
_size_changed();
-
}
-
Size2 Control::get_pos() const {
return data.pos_cache;
@@ -1506,71 +1413,67 @@ Size2 Control::get_size() const {
Rect2 Control::get_global_rect() const {
- return Rect2( get_global_pos(), get_size() );
+ return Rect2(get_global_pos(), get_size());
}
Rect2 Control::get_window_rect() const {
- ERR_FAIL_COND_V(!is_inside_tree(),Rect2());
+ ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
Rect2 gr = get_global_rect();
- gr.pos+=get_viewport()->get_visible_rect().pos;
+ gr.pos += get_viewport()->get_visible_rect().pos;
return gr;
}
-
Rect2 Control::get_rect() const {
- return Rect2(get_pos(),get_size());
+ return Rect2(get_pos(), get_size());
}
Rect2 Control::get_item_rect() const {
- return Rect2(Point2(),get_size());
+ return Rect2(Point2(), get_size());
}
void Control::set_area_as_parent_rect(int p_margin) {
- data.anchor[MARGIN_LEFT]=ANCHOR_BEGIN;
- data.anchor[MARGIN_TOP]=ANCHOR_BEGIN;
- data.anchor[MARGIN_RIGHT]=ANCHOR_END;
- data.anchor[MARGIN_BOTTOM]=ANCHOR_END;
- for(int i=0;i<4;i++)
- data.margin[i]=p_margin;
+ data.anchor[MARGIN_LEFT] = ANCHOR_BEGIN;
+ data.anchor[MARGIN_TOP] = ANCHOR_BEGIN;
+ data.anchor[MARGIN_RIGHT] = ANCHOR_END;
+ data.anchor[MARGIN_BOTTOM] = ANCHOR_END;
+ for (int i = 0; i < 4; i++)
+ data.margin[i] = p_margin;
_size_changed();
-
}
-void Control::add_icon_override(const StringName& p_name, const Ref<Texture>& p_icon) {
+void Control::add_icon_override(const StringName &p_name, const Ref<Texture> &p_icon) {
ERR_FAIL_COND(p_icon.is_null());
- data.icon_override[p_name]=p_icon;
+ data.icon_override[p_name] = p_icon;
notification(NOTIFICATION_THEME_CHANGED);
update();
-
}
void Control::add_shader_override(const StringName &p_name, const Ref<Shader> &p_shader) {
ERR_FAIL_COND(p_shader.is_null());
- data.shader_override[p_name]=p_shader;
+ data.shader_override[p_name] = p_shader;
notification(NOTIFICATION_THEME_CHANGED);
update();
}
-void Control::add_style_override(const StringName& p_name, const Ref<StyleBox>& p_style) {
+void Control::add_style_override(const StringName &p_name, const Ref<StyleBox> &p_style) {
ERR_FAIL_COND(p_style.is_null());
- data.style_override[p_name]=p_style;
+ data.style_override[p_name] = p_style;
notification(NOTIFICATION_THEME_CHANGED);
update();
}
-
-void Control::add_font_override(const StringName& p_name, const Ref<Font>& p_font) {
+void Control::add_font_override(const StringName &p_name, const Ref<Font> &p_font) {
ERR_FAIL_COND(p_font.is_null());
if (data.font_override.has(p_name)) {
_unref_font(data.font_override[p_name]);
}
- data.font_override[p_name]=p_font;
+ data.font_override[p_name] = p_font;
if (p_font.is_valid()) {
_ref_font(p_font);
@@ -1579,26 +1482,25 @@ void Control::add_font_override(const StringName& p_name, const Ref<Font>& p_fon
notification(NOTIFICATION_THEME_CHANGED);
update();
}
-void Control::add_color_override(const StringName& p_name, const Color& p_color) {
+void Control::add_color_override(const StringName &p_name, const Color &p_color) {
- data.color_override[p_name]=p_color;
+ data.color_override[p_name] = p_color;
notification(NOTIFICATION_THEME_CHANGED);
update();
}
-void Control::add_constant_override(const StringName& p_name, int p_constant) {
+void Control::add_constant_override(const StringName &p_name, int p_constant) {
- data.constant_override[p_name]=p_constant;
+ data.constant_override[p_name] = p_constant;
notification(NOTIFICATION_THEME_CHANGED);
update();
}
void Control::set_focus_mode(FocusMode p_focus_mode) {
- if (is_inside_tree() && p_focus_mode == FOCUS_NONE && data.focus_mode!=FOCUS_NONE && has_focus())
+ if (is_inside_tree() && p_focus_mode == FOCUS_NONE && data.focus_mode != FOCUS_NONE && has_focus())
release_focus();
- data.focus_mode=p_focus_mode;
-
+ data.focus_mode = p_focus_mode;
}
static Control *_next_control(Control *p_from) {
@@ -1606,17 +1508,16 @@ static Control *_next_control(Control *p_from) {
if (p_from->is_set_as_toplevel())
return NULL; // can't go above
- Control *parent = p_from->get_parent()?p_from->get_parent()->cast_to<Control>():NULL;
+ Control *parent = p_from->get_parent() ? p_from->get_parent()->cast_to<Control>() : NULL;
if (!parent) {
return NULL;
}
-
int next = p_from->get_position_in_parent();
- ERR_FAIL_INDEX_V(next,parent->get_child_count(),NULL);
- for(int i=(next+1);i<parent->get_child_count();i++) {
+ ERR_FAIL_INDEX_V(next, parent->get_child_count(), NULL);
+ for (int i = (next + 1); i < parent->get_child_count(); i++) {
Control *c = parent->get_child(i)->cast_to<Control>();
if (!c || !c->is_visible() || c->is_set_as_toplevel())
@@ -1631,24 +1532,22 @@ static Control *_next_control(Control *p_from) {
Control *Control::find_next_valid_focus() const {
- Control *from = const_cast<Control*>(this);
-
- while(true) {
+ Control *from = const_cast<Control *>(this);
+ while (true) {
// find next child
- Control *next_child=NULL;
-
+ Control *next_child = NULL;
- for(int i=0;i<from->get_child_count();i++) {
+ for (int i = 0; i < from->get_child_count(); i++) {
Control *c = from->get_child(i)->cast_to<Control>();
if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
continue;
}
- next_child=c;
+ next_child = c;
break;
}
@@ -1657,63 +1556,52 @@ Control *Control::find_next_valid_focus() const {
from = next_child;
} else {
- next_child=_next_control(from);
+ next_child = _next_control(from);
if (!next_child) { //nothing else.. go up and find either window or subwindow
- next_child=const_cast<Control*>(this);
- while(next_child && !next_child->is_set_as_toplevel()) {
+ next_child = const_cast<Control *>(this);
+ while (next_child && !next_child->is_set_as_toplevel()) {
if (next_child->get_parent()) {
- next_child=next_child->get_parent()->cast_to<Control>();
+ next_child = next_child->get_parent()->cast_to<Control>();
} else
- next_child=NULL;
-
+ next_child = NULL;
}
if (!next_child) {
- next_child=const_cast<Control*>(this);
- while(next_child) {
+ next_child = const_cast<Control *>(this);
+ while (next_child) {
if (next_child->data.SI || next_child->data.RI)
break;
- next_child=next_child->get_parent_control();
-
+ next_child = next_child->get_parent_control();
}
-
-
}
}
-
}
-
- if (next_child==this) // no next control->
- return (get_focus_mode()==FOCUS_ALL)?next_child:NULL;
+ if (next_child == this) // no next control->
+ return (get_focus_mode() == FOCUS_ALL) ? next_child : NULL;
if (next_child) {
- if (next_child->get_focus_mode()==FOCUS_ALL)
+ if (next_child->get_focus_mode() == FOCUS_ALL)
return next_child;
from = next_child;
- } else break;
+ } else
+ break;
}
return NULL;
-
-
}
-
-
-
static Control *_prev_control(Control *p_from) {
-
- Control *child=NULL;
- for(int i=p_from->get_child_count()-1;i>=0;i--) {
+ Control *child = NULL;
+ for (int i = p_from->get_child_count() - 1; i >= 0; i--) {
Control *c = p_from->get_child(i)->cast_to<Control>();
if (!c || !c->is_visible() || c->is_set_as_toplevel())
continue;
- child=c;
+ child = c;
break;
}
@@ -1725,72 +1613,57 @@ static Control *_prev_control(Control *p_from) {
}
Control *Control::find_prev_valid_focus() const {
- Control *from = const_cast<Control*>(this);
-
- while(true) {
+ Control *from = const_cast<Control *>(this);
+ while (true) {
// find prev child
+ Control *prev_child = NULL;
- Control *prev_child = NULL;
-
-
-
- if ( from->is_set_as_toplevel() || !from->get_parent() || !from->get_parent()->cast_to<Control>()) {
-
- //find last of the childs
-
- prev_child=_prev_control(from);
+ if (from->is_set_as_toplevel() || !from->get_parent() || !from->get_parent()->cast_to<Control>()) {
- } else {
-
- for(int i=(from->get_position_in_parent()-1);i>=0;i--) {
+ //find last of the childs
+ prev_child = _prev_control(from);
- Control *c = from->get_parent()->get_child(i)->cast_to<Control>();
+ } else {
- if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
- continue;
- }
+ for (int i = (from->get_position_in_parent() - 1); i >= 0; i--) {
- prev_child=c;
- break;
+ Control *c = from->get_parent()->get_child(i)->cast_to<Control>();
+ if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
+ continue;
}
- if (!prev_child) {
-
-
-
- prev_child = from->get_parent()->cast_to<Control>();
- } else {
-
-
-
- prev_child = _prev_control(prev_child);
- }
+ prev_child = c;
+ break;
}
+ if (!prev_child) {
+ prev_child = from->get_parent()->cast_to<Control>();
+ } else {
+ prev_child = _prev_control(prev_child);
+ }
+ }
- if (prev_child==this) // no prev control->
- return (get_focus_mode()==FOCUS_ALL)?prev_child:NULL;
-
- if (prev_child->get_focus_mode()==FOCUS_ALL)
- return prev_child;
+ if (prev_child == this) // no prev control->
+ return (get_focus_mode() == FOCUS_ALL) ? prev_child : NULL;
- from = prev_child;
+ if (prev_child->get_focus_mode() == FOCUS_ALL)
+ return prev_child;
- }
+ from = prev_child;
+ }
- return NULL;
+ return NULL;
return NULL;
}
-
Control::FocusMode Control::get_focus_mode() const {
return data.focus_mode;
@@ -1802,14 +1675,13 @@ bool Control::has_focus() const {
void Control::grab_focus() {
- if (!is_inside_tree()){
+ if (!is_inside_tree()) {
ERR_FAIL_COND(!is_inside_tree());
}
- if (data.focus_mode==FOCUS_NONE)
+ if (data.focus_mode == FOCUS_NONE)
return;
get_viewport()->_gui_control_grab_focus(this);
-
}
void Control::release_focus() {
@@ -1821,7 +1693,6 @@ void Control::release_focus() {
get_viewport()->_gui_remove_focus();
update();
-
}
bool Control::is_toplevel_control() const {
@@ -1837,105 +1708,94 @@ void Control::show_modal(bool p_exclusive) {
if (is_visible())
hide();
- ERR_FAIL_COND( data.MI!=NULL );
+ ERR_FAIL_COND(data.MI != NULL);
show();
raise();
- data.modal_exclusive=p_exclusive;
- data.MI=get_viewport()->_gui_show_modal(this);
- data.modal_frame=OS::get_singleton()->get_frames_drawn();
-
+ data.modal_exclusive = p_exclusive;
+ data.MI = get_viewport()->_gui_show_modal(this);
+ data.modal_frame = OS::get_singleton()->get_frames_drawn();
}
void Control::_modal_set_prev_focus_owner(ObjectID p_prev) {
- data.modal_prev_focus_owner=p_prev;
+ data.modal_prev_focus_owner = p_prev;
}
void Control::_modal_stack_remove() {
-
ERR_FAIL_COND(!is_inside_tree());
if (!data.MI)
return;
- get_viewport()->_gui_remove_from_modal_stack(data.MI,data.modal_prev_focus_owner);
-
- data.MI=NULL;
- data.modal_prev_focus_owner=0;
+ get_viewport()->_gui_remove_from_modal_stack(data.MI, data.modal_prev_focus_owner);
+ data.MI = NULL;
+ data.modal_prev_focus_owner = 0;
}
-void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner,bool p_assign) {
+void Control::_propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign) {
Control *c = p_at->cast_to<Control>();
- if (c && c!=p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated
+ if (c && c != p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated
return;
- for(int i=0;i<p_at->get_child_count();i++) {
+ for (int i = 0; i < p_at->get_child_count(); i++) {
CanvasItem *child = p_at->get_child(i)->cast_to<CanvasItem>();
if (child) {
- _propagate_theme_changed(child,p_owner);
+ _propagate_theme_changed(child, p_owner);
}
-
}
-
if (c) {
if (p_assign) {
- c->data.theme_owner=p_owner;
+ c->data.theme_owner = p_owner;
}
c->_notification(NOTIFICATION_THEME_CHANGED);
c->update();
}
}
-
void Control::_theme_changed() {
- _propagate_theme_changed(this,this,false);
+ _propagate_theme_changed(this, this, false);
}
-void Control::set_theme(const Ref<Theme>& p_theme) {
+void Control::set_theme(const Ref<Theme> &p_theme) {
-
- if (data.theme==p_theme)
+ if (data.theme == p_theme)
return;
if (data.theme.is_valid()) {
- data.theme->disconnect("changed",this,"_theme_changed");
+ data.theme->disconnect("changed", this, "_theme_changed");
}
- data.theme=p_theme;
+ data.theme = p_theme;
if (!p_theme.is_null()) {
- _propagate_theme_changed(this,this);
+ _propagate_theme_changed(this, this);
} else {
- Control *parent = get_parent()?get_parent()->cast_to<Control>():NULL;
+ Control *parent = get_parent() ? get_parent()->cast_to<Control>() : NULL;
if (parent && parent->data.theme_owner) {
- _propagate_theme_changed(this,parent->data.theme_owner);
+ _propagate_theme_changed(this, parent->data.theme_owner);
} else {
- _propagate_theme_changed(this,NULL);
+ _propagate_theme_changed(this, NULL);
}
-
}
if (data.theme.is_valid()) {
- data.theme->connect("changed",this,"_theme_changed");
+ data.theme->connect("changed", this, "_theme_changed");
}
-
}
void Control::accept_event() {
if (is_inside_tree())
get_viewport()->_gui_accept_event();
-
-
}
Ref<Theme> Control::get_theme() const {
@@ -1943,32 +1803,32 @@ Ref<Theme> Control::get_theme() const {
return data.theme;
}
-void Control::set_tooltip(const String& p_tooltip) {
+void Control::set_tooltip(const String &p_tooltip) {
- data.tooltip=p_tooltip;
+ data.tooltip = p_tooltip;
}
-String Control::get_tooltip(const Point2& p_pos) const {
+String Control::get_tooltip(const Point2 &p_pos) const {
return data.tooltip;
}
void Control::set_default_cursor_shape(CursorShape p_shape) {
- data.default_cursor=p_shape;
+ data.default_cursor = p_shape;
}
Control::CursorShape Control::get_default_cursor_shape() const {
return data.default_cursor;
}
-Control::CursorShape Control::get_cursor_shape(const Point2& p_pos) const {
+Control::CursorShape Control::get_cursor_shape(const Point2 &p_pos) const {
return data.default_cursor;
}
Matrix32 Control::get_transform() const {
- Matrix32 xform=Matrix32(data.rotation,get_pos());
+ Matrix32 xform = Matrix32(data.rotation, get_pos());
xform.scale_basis(data.scale);
return xform;
}
@@ -1980,82 +1840,81 @@ String Control::_get_tooltip() const {
void Control::set_focus_neighbour(Margin p_margin, const NodePath &p_neighbour) {
- ERR_FAIL_INDEX(p_margin,4);
- data.focus_neighbour[p_margin]=p_neighbour;
+ ERR_FAIL_INDEX(p_margin, 4);
+ data.focus_neighbour[p_margin] = p_neighbour;
}
NodePath Control::get_focus_neighbour(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin,4,NodePath());
+ ERR_FAIL_INDEX_V(p_margin, 4, NodePath());
return data.focus_neighbour[p_margin];
}
#define MAX_NEIGHBOUR_SEARCH_COUNT 512
-Control *Control::_get_focus_neighbour(Margin p_margin,int p_count) {
+Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
if (p_count >= MAX_NEIGHBOUR_SEARCH_COUNT)
return NULL;
if (!data.focus_neighbour[p_margin].is_empty()) {
- Control *c=NULL;
- Node * n = get_node(data.focus_neighbour[p_margin]);
+ Control *c = NULL;
+ Node *n = get_node(data.focus_neighbour[p_margin]);
if (n) {
- c=n->cast_to<Control>();
+ c = n->cast_to<Control>();
if (!c) {
- ERR_EXPLAIN("Next focus node is not a control: "+n->get_name());
+ ERR_EXPLAIN("Next focus node is not a control: " + n->get_name());
ERR_FAIL_V(NULL);
}
} else {
return NULL;
}
- bool valid=true;
+ bool valid = true;
if (c->is_hidden())
- valid=false;
- if (c->get_focus_mode()==FOCUS_NONE)
- valid=false;
+ valid = false;
+ if (c->get_focus_mode() == FOCUS_NONE)
+ valid = false;
if (valid)
return c;
- c=c->_get_focus_neighbour(p_margin,p_count+1);
+ c = c->_get_focus_neighbour(p_margin, p_count + 1);
return c;
}
-
- float dist=1e7;
- Control * result=NULL;
+ float dist = 1e7;
+ Control *result = NULL;
Point2 points[4];
Matrix32 xform = get_global_transform();
Rect2 rect = get_item_rect();
- points[0]=xform.xform(rect.pos);
- points[1]=xform.xform(rect.pos + Point2(rect.size.x, 0));
- points[2]=xform.xform(rect.pos + rect.size);
- points[3]=xform.xform(rect.pos + Point2(0, rect.size.y));
+ points[0] = xform.xform(rect.pos);
+ points[1] = xform.xform(rect.pos + Point2(rect.size.x, 0));
+ points[2] = xform.xform(rect.pos + rect.size);
+ points[3] = xform.xform(rect.pos + Point2(0, rect.size.y));
- const Vector2 dir[4]={
- Vector2(-1,0),
- Vector2(0,-1),
- Vector2(1,0),
- Vector2(0,1)
+ const Vector2 dir[4] = {
+ Vector2(-1, 0),
+ Vector2(0, -1),
+ Vector2(1, 0),
+ Vector2(0, 1)
};
- Vector2 vdir=dir[p_margin];
+ Vector2 vdir = dir[p_margin];
- float maxd=-1e7;
+ float maxd = -1e7;
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
float d = vdir.dot(points[i]);
- if (d>maxd)
- maxd=d;
+ if (d > maxd)
+ maxd = d;
}
- Node *base=this;
+ Node *base = this;
while (base) {
@@ -2066,109 +1925,104 @@ Control *Control::_get_focus_neighbour(Margin p_margin,int p_count) {
if (c->data.RI)
break;
}
- base=base->get_parent();
+ base = base->get_parent();
}
if (!base)
return NULL;
- _window_find_focus_neighbour(vdir,base,points,maxd,dist,&result);
+ _window_find_focus_neighbour(vdir, base, points, maxd, dist, &result);
return result;
-
}
-void Control::_window_find_focus_neighbour(const Vector2& p_dir, Node *p_at,const Point2* p_points,float p_min ,float &r_closest_dist,Control **r_closest) {
+void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, float p_min, float &r_closest_dist, Control **r_closest) {
if (p_at->cast_to<Viewport>())
return; //bye
Control *c = p_at->cast_to<Control>();
- if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible()) {
+ if (c && c != this && c->get_focus_mode() == FOCUS_ALL && c->is_visible()) {
Point2 points[4];
Matrix32 xform = c->get_global_transform();
Rect2 rect = c->get_item_rect();
- points[0]=xform.xform(rect.pos);
- points[1]=xform.xform(rect.pos + Point2(rect.size.x, 0));
- points[2]=xform.xform(rect.pos + rect.size);
- points[3]=xform.xform(rect.pos + Point2(0, rect.size.y));
+ points[0] = xform.xform(rect.pos);
+ points[1] = xform.xform(rect.pos + Point2(rect.size.x, 0));
+ points[2] = xform.xform(rect.pos + rect.size);
+ points[3] = xform.xform(rect.pos + Point2(0, rect.size.y));
+ float min = 1e7;
- float min=1e7;
-
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
float d = p_dir.dot(points[i]);
if (d < min)
- min =d;
+ min = d;
}
+ if (min > (p_min - CMP_EPSILON)) {
- if (min>(p_min-CMP_EPSILON)) {
-
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- Vector2 la=p_points[i];
- Vector2 lb=p_points[(i+1)%4];
+ Vector2 la = p_points[i];
+ Vector2 lb = p_points[(i + 1) % 4];
- for(int j=0;j<4;j++) {
+ for (int j = 0; j < 4; j++) {
- Vector2 fa=points[j];
- Vector2 fb=points[(j+1)%4];
+ Vector2 fa = points[j];
+ Vector2 fb = points[(j + 1) % 4];
- Vector2 pa,pb;
- float d=Geometry::get_closest_points_between_segments(la,lb,fa,fb,pa,pb);
+ Vector2 pa, pb;
+ float d = Geometry::get_closest_points_between_segments(la, lb, fa, fb, pa, pb);
//float d = Geometry::get_closest_distance_between_segments(Vector3(la.x,la.y,0),Vector3(lb.x,lb.y,0),Vector3(fa.x,fa.y,0),Vector3(fb.x,fb.y,0));
- if (d<r_closest_dist) {
- r_closest_dist=d;
- *r_closest=c;
+ if (d < r_closest_dist) {
+ r_closest_dist = d;
+ *r_closest = c;
}
}
}
}
-
}
- for(int i=0;i<p_at->get_child_count();i++) {
+ for (int i = 0; i < p_at->get_child_count(); i++) {
- Node *child=p_at->get_child(i);
+ Node *child = p_at->get_child(i);
Control *childc = child->cast_to<Control>();
if (childc && childc->data.SI)
continue; //subwindow, ignore
- _window_find_focus_neighbour(p_dir,p_at->get_child(i),p_points,p_min,r_closest_dist,r_closest);
+ _window_find_focus_neighbour(p_dir, p_at->get_child(i), p_points, p_min, r_closest_dist, r_closest);
}
}
void Control::set_h_size_flags(int p_flags) {
- if (data.h_size_flags==p_flags)
+ if (data.h_size_flags == p_flags)
return;
- data.h_size_flags=p_flags;
+ data.h_size_flags = p_flags;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
}
-int Control::get_h_size_flags() const{
+int Control::get_h_size_flags() const {
return data.h_size_flags;
}
void Control::set_v_size_flags(int p_flags) {
- if (data.v_size_flags==p_flags)
+ if (data.v_size_flags == p_flags)
return;
- data.v_size_flags=p_flags;
+ data.v_size_flags = p_flags;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
}
-
void Control::set_stretch_ratio(float p_ratio) {
- if (data.expand==p_ratio)
+ if (data.expand == p_ratio)
return;
- data.expand=p_ratio;
+ data.expand = p_ratio;
emit_signal(SceneStringNames::get_singleton()->size_flags_changed);
}
@@ -2177,13 +2031,11 @@ float Control::get_stretch_ratio() const {
return data.expand;
}
-
void Control::grab_click_focus() {
ERR_FAIL_COND(!is_inside_tree());
get_viewport()->_gui_grab_click_focus(this);
-
}
void Control::minimum_size_changed() {
@@ -2194,9 +2046,8 @@ void Control::minimum_size_changed() {
if (data.pending_min_size_update)
return;
-
- data.pending_min_size_update=true;
- MessageQueue::get_singleton()->push_call(this,"_update_minimum_size");
+ data.pending_min_size_update = true;
+ MessageQueue::get_singleton()->push_call(this, "_update_minimum_size");
if (!is_toplevel_control()) {
Control *pc = get_parent_control();
@@ -2205,13 +2056,13 @@ void Control::minimum_size_changed() {
}
}
-int Control::get_v_size_flags() const{
+int Control::get_v_size_flags() const {
return data.v_size_flags;
}
void Control::set_ignore_mouse(bool p_ignore) {
- data.ignore_mouse=p_ignore;
+ data.ignore_mouse = p_ignore;
}
bool Control::is_ignoring_mouse() const {
@@ -2221,7 +2072,7 @@ bool Control::is_ignoring_mouse() const {
void Control::set_stop_mouse(bool p_stop) {
- data.stop_mouse=p_stop;
+ data.stop_mouse = p_stop;
}
bool Control::is_stopping_mouse() const {
@@ -2231,19 +2082,17 @@ bool Control::is_stopping_mouse() const {
Control *Control::get_focus_owner() const {
- ERR_FAIL_COND_V(!is_inside_tree(),NULL);
+ ERR_FAIL_COND_V(!is_inside_tree(), NULL);
return get_viewport()->_gui_get_focus_owner();
}
-
-void Control::warp_mouse(const Point2& p_to_pos) {
+void Control::warp_mouse(const Point2 &p_to_pos) {
ERR_FAIL_COND(!is_inside_tree());
get_viewport()->warp_mouse(get_global_transform().xform(p_to_pos));
}
-
bool Control::is_text_field() const {
-/*
+ /*
if (get_script_instance()) {
Variant v=p_point;
const Variant *p[2]={&v,&p_data};
@@ -2253,19 +2102,18 @@ bool Control::is_text_field() const {
return ret;
}
*/
- return false;
+ return false;
}
-
void Control::set_rotation(float p_radians) {
- data.rotation=p_radians;
+ data.rotation = p_radians;
update();
_notify_transform();
_change_notify("rect/rotation");
}
-float Control::get_rotation() const{
+float Control::get_rotation() const {
return data.rotation;
}
@@ -2289,13 +2137,13 @@ float Control::_get_rotation_deg() const {
return get_rotation_deg();
}
//needed to update the control if the font changes..
-void Control::_ref_font( Ref<Font> p_sc) {
+void Control::_ref_font(Ref<Font> p_sc) {
if (!data.font_refcount.has(p_sc)) {
- data.font_refcount[p_sc]=1;
- p_sc->connect("changed",this,"_font_changed");
+ data.font_refcount[p_sc] = 1;
+ p_sc->connect("changed", this, "_font_changed");
} else {
- data.font_refcount[p_sc]+=1;
+ data.font_refcount[p_sc] += 1;
}
}
@@ -2303,127 +2151,124 @@ void Control::_unref_font(Ref<Font> p_sc) {
ERR_FAIL_COND(!data.font_refcount.has(p_sc));
data.font_refcount[p_sc]--;
- if (data.font_refcount[p_sc]==0) {
- p_sc->disconnect("changed",this,"_font_changed");
+ if (data.font_refcount[p_sc] == 0) {
+ p_sc->disconnect("changed", this, "_font_changed");
data.font_refcount.erase(p_sc);
}
}
-void Control::_font_changed(){
+void Control::_font_changed() {
update();
notification(NOTIFICATION_THEME_CHANGED);
minimum_size_changed(); //fonts affect minimum size pretty much almost always
}
-void Control::set_scale(const Vector2& p_scale){
+void Control::set_scale(const Vector2 &p_scale) {
- data.scale=p_scale;
+ data.scale = p_scale;
update();
_notify_transform();
}
-Vector2 Control::get_scale() const{
+Vector2 Control::get_scale() const {
return data.scale;
}
Control *Control::get_root_parent_control() const {
- const CanvasItem *ci=this;
- const Control *root=this;
+ const CanvasItem *ci = this;
+ const Control *root = this;
- while(ci) {
+ while (ci) {
const Control *c = ci->cast_to<Control>();
if (c) {
- root=c;
+ root = c;
if (c->data.RI || c->data.MI || c->is_toplevel_control())
break;
}
- ci=ci->get_parent_item();
+ ci = ci->get_parent_item();
}
- return const_cast<Control*>(root);
+ return const_cast<Control *>(root);
}
-
-
void Control::_bind_methods() {
+ // ObjectTypeDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event);
+ ObjectTypeDB::bind_method(_MD("_size_changed"), &Control::_size_changed);
+ ObjectTypeDB::bind_method(_MD("_update_minimum_size"), &Control::_update_minimum_size);
-// ObjectTypeDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event);
- ObjectTypeDB::bind_method(_MD("_size_changed"),&Control::_size_changed);
- ObjectTypeDB::bind_method(_MD("_update_minimum_size"),&Control::_update_minimum_size);
-
- ObjectTypeDB::bind_method(_MD("accept_event"),&Control::accept_event);
- ObjectTypeDB::bind_method(_MD("get_minimum_size"),&Control::get_minimum_size);
- ObjectTypeDB::bind_method(_MD("get_combined_minimum_size"),&Control::get_combined_minimum_size);
- ObjectTypeDB::bind_method(_MD("set_anchor","margin","anchor_mode","keep_margin"),&Control::set_anchor,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("_set_anchor","margin","anchor_mode"),&Control::_set_anchor);
- ObjectTypeDB::bind_method(_MD("get_anchor","margin"),&Control::get_anchor);
- ObjectTypeDB::bind_method(_MD("set_margin","margin","offset"),&Control::set_margin);
- ObjectTypeDB::bind_method(_MD("set_anchor_and_margin","margin","anchor_mode","offset"),&Control::set_anchor_and_margin);
- ObjectTypeDB::bind_method(_MD("set_begin","pos"),&Control::set_begin);
- ObjectTypeDB::bind_method(_MD("set_end","pos"),&Control::set_end);
- ObjectTypeDB::bind_method(_MD("set_pos","pos"),&Control::set_pos);
- ObjectTypeDB::bind_method(_MD("set_size","size"),&Control::set_size);
- ObjectTypeDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
- ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos);
- ObjectTypeDB::bind_method(_MD("set_rotation","radians"),&Control::set_rotation);
- ObjectTypeDB::bind_method(_MD("set_rotation_deg","degrees"),&Control::set_rotation_deg);
+ ObjectTypeDB::bind_method(_MD("accept_event"), &Control::accept_event);
+ ObjectTypeDB::bind_method(_MD("get_minimum_size"), &Control::get_minimum_size);
+ ObjectTypeDB::bind_method(_MD("get_combined_minimum_size"), &Control::get_combined_minimum_size);
+ ObjectTypeDB::bind_method(_MD("set_anchor", "margin", "anchor_mode", "keep_margin"), &Control::set_anchor, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("_set_anchor", "margin", "anchor_mode"), &Control::_set_anchor);
+ ObjectTypeDB::bind_method(_MD("get_anchor", "margin"), &Control::get_anchor);
+ ObjectTypeDB::bind_method(_MD("set_margin", "margin", "offset"), &Control::set_margin);
+ ObjectTypeDB::bind_method(_MD("set_anchor_and_margin", "margin", "anchor_mode", "offset"), &Control::set_anchor_and_margin);
+ ObjectTypeDB::bind_method(_MD("set_begin", "pos"), &Control::set_begin);
+ ObjectTypeDB::bind_method(_MD("set_end", "pos"), &Control::set_end);
+ ObjectTypeDB::bind_method(_MD("set_pos", "pos"), &Control::set_pos);
+ ObjectTypeDB::bind_method(_MD("set_size", "size"), &Control::set_size);
+ ObjectTypeDB::bind_method(_MD("set_custom_minimum_size", "size"), &Control::set_custom_minimum_size);
+ ObjectTypeDB::bind_method(_MD("set_global_pos", "pos"), &Control::set_global_pos);
+ ObjectTypeDB::bind_method(_MD("set_rotation", "radians"), &Control::set_rotation);
+ ObjectTypeDB::bind_method(_MD("set_rotation_deg", "degrees"), &Control::set_rotation_deg);
// TODO: Obsolete this method (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_set_rotation_deg","degrees"),&Control::_set_rotation_deg);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Control::set_scale);
- ObjectTypeDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
- ObjectTypeDB::bind_method(_MD("get_begin"),&Control::get_begin);
- ObjectTypeDB::bind_method(_MD("get_end"),&Control::get_end);
- ObjectTypeDB::bind_method(_MD("get_pos"),&Control::get_pos);
- ObjectTypeDB::bind_method(_MD("get_size"),&Control::get_size);
- ObjectTypeDB::bind_method(_MD("get_rotation"),&Control::get_rotation);
- ObjectTypeDB::bind_method(_MD("get_rotation_deg"),&Control::get_rotation_deg);
+ ObjectTypeDB::bind_method(_MD("_set_rotation_deg", "degrees"), &Control::_set_rotation_deg);
+ ObjectTypeDB::bind_method(_MD("set_scale", "scale"), &Control::set_scale);
+ ObjectTypeDB::bind_method(_MD("get_margin", "margin"), &Control::get_margin);
+ ObjectTypeDB::bind_method(_MD("get_begin"), &Control::get_begin);
+ ObjectTypeDB::bind_method(_MD("get_end"), &Control::get_end);
+ ObjectTypeDB::bind_method(_MD("get_pos"), &Control::get_pos);
+ ObjectTypeDB::bind_method(_MD("get_size"), &Control::get_size);
+ ObjectTypeDB::bind_method(_MD("get_rotation"), &Control::get_rotation);
+ ObjectTypeDB::bind_method(_MD("get_rotation_deg"), &Control::get_rotation_deg);
// TODO: Obsolete this method (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
- ObjectTypeDB::bind_method(_MD("get_scale"),&Control::get_scale);
- ObjectTypeDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size);
- ObjectTypeDB::bind_method(_MD("get_parent_area_size"),&Control::get_size);
- ObjectTypeDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos);
- ObjectTypeDB::bind_method(_MD("get_rect"),&Control::get_rect);
- ObjectTypeDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect);
- ObjectTypeDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_focus_mode","mode"),&Control::set_focus_mode);
- ObjectTypeDB::bind_method(_MD("get_focus_mode"),&Control::get_focus_mode);
- ObjectTypeDB::bind_method(_MD("has_focus"),&Control::has_focus);
- ObjectTypeDB::bind_method(_MD("grab_focus"),&Control::grab_focus);
- ObjectTypeDB::bind_method(_MD("release_focus"),&Control::release_focus);
- ObjectTypeDB::bind_method(_MD("get_focus_owner:Control"),&Control::get_focus_owner);
+ ObjectTypeDB::bind_method(_MD("_get_rotation_deg"), &Control::_get_rotation_deg);
+ ObjectTypeDB::bind_method(_MD("get_scale"), &Control::get_scale);
+ ObjectTypeDB::bind_method(_MD("get_custom_minimum_size"), &Control::get_custom_minimum_size);
+ ObjectTypeDB::bind_method(_MD("get_parent_area_size"), &Control::get_size);
+ ObjectTypeDB::bind_method(_MD("get_global_pos"), &Control::get_global_pos);
+ ObjectTypeDB::bind_method(_MD("get_rect"), &Control::get_rect);
+ ObjectTypeDB::bind_method(_MD("get_global_rect"), &Control::get_global_rect);
+ ObjectTypeDB::bind_method(_MD("set_area_as_parent_rect", "margin"), &Control::set_area_as_parent_rect, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("show_modal", "exclusive"), &Control::show_modal, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("set_focus_mode", "mode"), &Control::set_focus_mode);
+ ObjectTypeDB::bind_method(_MD("get_focus_mode"), &Control::get_focus_mode);
+ ObjectTypeDB::bind_method(_MD("has_focus"), &Control::has_focus);
+ ObjectTypeDB::bind_method(_MD("grab_focus"), &Control::grab_focus);
+ ObjectTypeDB::bind_method(_MD("release_focus"), &Control::release_focus);
+ ObjectTypeDB::bind_method(_MD("get_focus_owner:Control"), &Control::get_focus_owner);
- ObjectTypeDB::bind_method(_MD("set_h_size_flags","flags"),&Control::set_h_size_flags);
- ObjectTypeDB::bind_method(_MD("get_h_size_flags"),&Control::get_h_size_flags);
+ ObjectTypeDB::bind_method(_MD("set_h_size_flags", "flags"), &Control::set_h_size_flags);
+ ObjectTypeDB::bind_method(_MD("get_h_size_flags"), &Control::get_h_size_flags);
- ObjectTypeDB::bind_method(_MD("set_stretch_ratio","ratio"),&Control::set_stretch_ratio);
- ObjectTypeDB::bind_method(_MD("get_stretch_ratio"),&Control::get_stretch_ratio);
+ ObjectTypeDB::bind_method(_MD("set_stretch_ratio", "ratio"), &Control::set_stretch_ratio);
+ ObjectTypeDB::bind_method(_MD("get_stretch_ratio"), &Control::get_stretch_ratio);
- ObjectTypeDB::bind_method(_MD("set_v_size_flags","flags"),&Control::set_v_size_flags);
- ObjectTypeDB::bind_method(_MD("get_v_size_flags"),&Control::get_v_size_flags);
+ ObjectTypeDB::bind_method(_MD("set_v_size_flags", "flags"), &Control::set_v_size_flags);
+ ObjectTypeDB::bind_method(_MD("get_v_size_flags"), &Control::get_v_size_flags);
- ObjectTypeDB::bind_method(_MD("set_theme","theme:Theme"),&Control::set_theme);
- ObjectTypeDB::bind_method(_MD("get_theme:Theme"),&Control::get_theme);
+ ObjectTypeDB::bind_method(_MD("set_theme", "theme:Theme"), &Control::set_theme);
+ ObjectTypeDB::bind_method(_MD("get_theme:Theme"), &Control::get_theme);
- ObjectTypeDB::bind_method(_MD("add_icon_override","name","texture:Texture"),&Control::add_icon_override);
- ObjectTypeDB::bind_method(_MD("add_shader_override","name","shader:Shader"),&Control::add_shader_override);
- ObjectTypeDB::bind_method(_MD("add_style_override","name","stylebox:StyleBox"),&Control::add_style_override);
- ObjectTypeDB::bind_method(_MD("add_font_override","name","font:Font"),&Control::add_font_override);
- ObjectTypeDB::bind_method(_MD("add_color_override","name","color"),&Control::add_color_override);
- ObjectTypeDB::bind_method(_MD("add_constant_override","name","constant"),&Control::add_constant_override);
+ ObjectTypeDB::bind_method(_MD("add_icon_override", "name", "texture:Texture"), &Control::add_icon_override);
+ ObjectTypeDB::bind_method(_MD("add_shader_override", "name", "shader:Shader"), &Control::add_shader_override);
+ ObjectTypeDB::bind_method(_MD("add_style_override", "name", "stylebox:StyleBox"), &Control::add_style_override);
+ ObjectTypeDB::bind_method(_MD("add_font_override", "name", "font:Font"), &Control::add_font_override);
+ ObjectTypeDB::bind_method(_MD("add_color_override", "name", "color"), &Control::add_color_override);
+ ObjectTypeDB::bind_method(_MD("add_constant_override", "name", "constant"), &Control::add_constant_override);
- ObjectTypeDB::bind_method(_MD("get_icon:Texture","name","type"),&Control::get_icon,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Control::get_stylebox,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_font:Font","name","type"),&Control::get_font,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_color","name","type"),&Control::get_color,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_constant","name","type"),&Control::get_constant,DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("get_icon:Texture", "name", "type"), &Control::get_icon, DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("get_stylebox:StyleBox", "name", "type"), &Control::get_stylebox, DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("get_font:Font", "name", "type"), &Control::get_font, DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("get_color", "name", "type"), &Control::get_color, DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("get_constant", "name", "type"), &Control::get_constant, DEFVAL(""));
ObjectTypeDB::bind_method(_MD("has_icon_override", "name"), &Control::has_icon_override);
ObjectTypeDB::bind_method(_MD("has_stylebox_override", "name"), &Control::has_stylebox_override);
@@ -2437,162 +2282,148 @@ void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("has_color", "name", "type"), &Control::has_color, DEFVAL(""));
ObjectTypeDB::bind_method(_MD("has_constant", "name", "type"), &Control::has_constant, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_parent_control:Control"),&Control::get_parent_control);
+ ObjectTypeDB::bind_method(_MD("get_parent_control:Control"), &Control::get_parent_control);
- ObjectTypeDB::bind_method(_MD("set_tooltip","tooltip"),&Control::set_tooltip);
- ObjectTypeDB::bind_method(_MD("get_tooltip","atpos"),&Control::get_tooltip,DEFVAL(Point2()));
- ObjectTypeDB::bind_method(_MD("_get_tooltip"),&Control::_get_tooltip);
+ ObjectTypeDB::bind_method(_MD("set_tooltip", "tooltip"), &Control::set_tooltip);
+ ObjectTypeDB::bind_method(_MD("get_tooltip", "atpos"), &Control::get_tooltip, DEFVAL(Point2()));
+ ObjectTypeDB::bind_method(_MD("_get_tooltip"), &Control::_get_tooltip);
- ObjectTypeDB::bind_method(_MD("set_default_cursor_shape","shape"),&Control::set_default_cursor_shape);
- ObjectTypeDB::bind_method(_MD("get_default_cursor_shape"),&Control::get_default_cursor_shape);
- ObjectTypeDB::bind_method(_MD("get_cursor_shape","pos"),&Control::get_cursor_shape,DEFVAL(Point2()));
+ ObjectTypeDB::bind_method(_MD("set_default_cursor_shape", "shape"), &Control::set_default_cursor_shape);
+ ObjectTypeDB::bind_method(_MD("get_default_cursor_shape"), &Control::get_default_cursor_shape);
+ ObjectTypeDB::bind_method(_MD("get_cursor_shape", "pos"), &Control::get_cursor_shape, DEFVAL(Point2()));
- ObjectTypeDB::bind_method(_MD("set_focus_neighbour","margin","neighbour"),&Control::set_focus_neighbour);
- ObjectTypeDB::bind_method(_MD("get_focus_neighbour","margin"),&Control::get_focus_neighbour);
+ ObjectTypeDB::bind_method(_MD("set_focus_neighbour", "margin", "neighbour"), &Control::set_focus_neighbour);
+ ObjectTypeDB::bind_method(_MD("get_focus_neighbour", "margin"), &Control::get_focus_neighbour);
- ObjectTypeDB::bind_method(_MD("set_ignore_mouse","ignore"),&Control::set_ignore_mouse);
- ObjectTypeDB::bind_method(_MD("is_ignoring_mouse"),&Control::is_ignoring_mouse);
+ ObjectTypeDB::bind_method(_MD("set_ignore_mouse", "ignore"), &Control::set_ignore_mouse);
+ ObjectTypeDB::bind_method(_MD("is_ignoring_mouse"), &Control::is_ignoring_mouse);
- ObjectTypeDB::bind_method(_MD("force_drag","data","preview"),&Control::force_drag);
+ ObjectTypeDB::bind_method(_MD("force_drag", "data", "preview"), &Control::force_drag);
- ObjectTypeDB::bind_method(_MD("set_stop_mouse","stop"),&Control::set_stop_mouse);
- ObjectTypeDB::bind_method(_MD("is_stopping_mouse"),&Control::is_stopping_mouse);
+ ObjectTypeDB::bind_method(_MD("set_stop_mouse", "stop"), &Control::set_stop_mouse);
+ ObjectTypeDB::bind_method(_MD("is_stopping_mouse"), &Control::is_stopping_mouse);
- ObjectTypeDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus);
+ ObjectTypeDB::bind_method(_MD("grab_click_focus"), &Control::grab_click_focus);
- ObjectTypeDB::bind_method(_MD("set_drag_forwarding","target:Control"),&Control::set_drag_forwarding);
- ObjectTypeDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview);
+ ObjectTypeDB::bind_method(_MD("set_drag_forwarding", "target:Control"), &Control::set_drag_forwarding);
+ ObjectTypeDB::bind_method(_MD("set_drag_preview", "control:Control"), &Control::set_drag_preview);
- ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse);
+ ObjectTypeDB::bind_method(_MD("warp_mouse", "to_pos"), &Control::warp_mouse);
ObjectTypeDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed);
ObjectTypeDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed);
-
-
ObjectTypeDB::bind_method(_MD("_font_changed"), &Control::_font_changed);
- BIND_VMETHOD(MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"event")));
- BIND_VMETHOD(MethodInfo(Variant::VECTOR2,"get_minimum_size"));
- BIND_VMETHOD(MethodInfo(Variant::OBJECT,"get_drag_data",PropertyInfo(Variant::VECTOR2,"pos")));
- BIND_VMETHOD(MethodInfo(Variant::BOOL,"can_drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data")));
- BIND_VMETHOD(MethodInfo("drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data")));
-
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/left", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/top", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/right", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/bottom", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM );
+ BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::INPUT_EVENT, "event")));
+ BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "get_minimum_size"));
+ BIND_VMETHOD(MethodInfo(Variant::OBJECT, "get_drag_data", PropertyInfo(Variant::VECTOR2, "pos")));
+ BIND_VMETHOD(MethodInfo(Variant::BOOL, "can_drop_data", PropertyInfo(Variant::VECTOR2, "pos"), PropertyInfo(Variant::NIL, "data")));
+ BIND_VMETHOD(MethodInfo("drop_data", PropertyInfo(Variant::VECTOR2, "pos"), PropertyInfo(Variant::NIL, "data")));
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect/rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") );
- ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect/scale"), _SCS("set_scale"),_SCS("get_scale") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/ignore_mouse"), _SCS("set_ignore_mouse"),_SCS("is_ignoring_mouse") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/stop_mouse"), _SCS("set_stop_mouse"),_SCS("is_stopping_mouse") );
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "anchor/left", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"), _SCS("get_anchor"), MARGIN_LEFT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "anchor/top", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"), _SCS("get_anchor"), MARGIN_TOP);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "anchor/right", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"), _SCS("get_anchor"), MARGIN_RIGHT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "anchor/bottom", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"), _SCS("get_anchor"), MARGIN_BOTTOM);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/horizontal", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") );
- ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/vertical", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") );
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect/pos", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), _SCS("set_pos"), _SCS("get_pos"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect/size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), _SCS("set_size"), _SCS("get_size"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect/min_size"), _SCS("set_custom_minimum_size"), _SCS("get_custom_minimum_size"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rect/rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), _SCS("set_rotation_deg"), _SCS("get_rotation_deg"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect/scale"), _SCS("set_scale"), _SCS("get_scale"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"), _SCS("_get_tooltip"));
+ ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour/left"), _SCS("set_focus_neighbour"), _SCS("get_focus_neighbour"), MARGIN_LEFT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour/top"), _SCS("set_focus_neighbour"), _SCS("get_focus_neighbour"), MARGIN_TOP);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour/right"), _SCS("set_focus_neighbour"), _SCS("get_focus_neighbour"), MARGIN_RIGHT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour/bottom"), _SCS("set_focus_neighbour"), _SCS("get_focus_neighbour"), MARGIN_BOTTOM);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "focus/ignore_mouse"), _SCS("set_ignore_mouse"), _SCS("is_ignoring_mouse"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "focus/stop_mouse"), _SCS("set_stop_mouse"), _SCS("is_stopping_mouse"));
- BIND_CONSTANT( ANCHOR_BEGIN );
- BIND_CONSTANT( ANCHOR_END );
- BIND_CONSTANT( ANCHOR_RATIO );
- BIND_CONSTANT( ANCHOR_CENTER );
- BIND_CONSTANT( FOCUS_NONE );
- BIND_CONSTANT( FOCUS_CLICK );
- BIND_CONSTANT( FOCUS_ALL );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags/horizontal", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_h_size_flags"), _SCS("get_h_size_flags"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "size_flags/vertical", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_v_size_flags"), _SCS("get_v_size_flags"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"), _SCS("get_stretch_ratio"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"), _SCS("get_theme"));
+ BIND_CONSTANT(ANCHOR_BEGIN);
+ BIND_CONSTANT(ANCHOR_END);
+ BIND_CONSTANT(ANCHOR_RATIO);
+ BIND_CONSTANT(ANCHOR_CENTER);
+ BIND_CONSTANT(FOCUS_NONE);
+ BIND_CONSTANT(FOCUS_CLICK);
+ BIND_CONSTANT(FOCUS_ALL);
- BIND_CONSTANT( NOTIFICATION_RESIZED );
- BIND_CONSTANT( NOTIFICATION_MOUSE_ENTER );
- BIND_CONSTANT( NOTIFICATION_MOUSE_EXIT );
- BIND_CONSTANT( NOTIFICATION_FOCUS_ENTER );
- BIND_CONSTANT( NOTIFICATION_FOCUS_EXIT );
- BIND_CONSTANT( NOTIFICATION_THEME_CHANGED );
- BIND_CONSTANT( NOTIFICATION_MODAL_CLOSE );
+ BIND_CONSTANT(NOTIFICATION_RESIZED);
+ BIND_CONSTANT(NOTIFICATION_MOUSE_ENTER);
+ BIND_CONSTANT(NOTIFICATION_MOUSE_EXIT);
+ BIND_CONSTANT(NOTIFICATION_FOCUS_ENTER);
+ BIND_CONSTANT(NOTIFICATION_FOCUS_EXIT);
+ BIND_CONSTANT(NOTIFICATION_THEME_CHANGED);
+ BIND_CONSTANT(NOTIFICATION_MODAL_CLOSE);
- BIND_CONSTANT( CURSOR_ARROW );
- BIND_CONSTANT( CURSOR_IBEAM );
- BIND_CONSTANT( CURSOR_POINTING_HAND );
- BIND_CONSTANT( CURSOR_CROSS );
- BIND_CONSTANT( CURSOR_WAIT );
- BIND_CONSTANT( CURSOR_BUSY );
- BIND_CONSTANT( CURSOR_DRAG );
- BIND_CONSTANT( CURSOR_CAN_DROP );
- BIND_CONSTANT( CURSOR_FORBIDDEN );
- BIND_CONSTANT( CURSOR_VSIZE );
- BIND_CONSTANT( CURSOR_HSIZE );
- BIND_CONSTANT( CURSOR_BDIAGSIZE );
- BIND_CONSTANT( CURSOR_FDIAGSIZE );
- BIND_CONSTANT( CURSOR_MOVE );
- BIND_CONSTANT( CURSOR_VSPLIT );
- BIND_CONSTANT( CURSOR_HSPLIT );
- BIND_CONSTANT( CURSOR_HELP );
-
- BIND_CONSTANT( SIZE_EXPAND );
- BIND_CONSTANT( SIZE_FILL );
- BIND_CONSTANT( SIZE_EXPAND_FILL );
-
- ADD_SIGNAL( MethodInfo("resized") );
- ADD_SIGNAL( MethodInfo("input_event",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
- ADD_SIGNAL( MethodInfo("mouse_enter") );
- ADD_SIGNAL( MethodInfo("mouse_exit") );
- ADD_SIGNAL( MethodInfo("focus_enter") );
- ADD_SIGNAL( MethodInfo("focus_exit") );
- ADD_SIGNAL( MethodInfo("size_flags_changed") );
- ADD_SIGNAL( MethodInfo("minimum_size_changed") );
- ADD_SIGNAL( MethodInfo("modal_close") );
+ BIND_CONSTANT(CURSOR_ARROW);
+ BIND_CONSTANT(CURSOR_IBEAM);
+ BIND_CONSTANT(CURSOR_POINTING_HAND);
+ BIND_CONSTANT(CURSOR_CROSS);
+ BIND_CONSTANT(CURSOR_WAIT);
+ BIND_CONSTANT(CURSOR_BUSY);
+ BIND_CONSTANT(CURSOR_DRAG);
+ BIND_CONSTANT(CURSOR_CAN_DROP);
+ BIND_CONSTANT(CURSOR_FORBIDDEN);
+ BIND_CONSTANT(CURSOR_VSIZE);
+ BIND_CONSTANT(CURSOR_HSIZE);
+ BIND_CONSTANT(CURSOR_BDIAGSIZE);
+ BIND_CONSTANT(CURSOR_FDIAGSIZE);
+ BIND_CONSTANT(CURSOR_MOVE);
+ BIND_CONSTANT(CURSOR_VSPLIT);
+ BIND_CONSTANT(CURSOR_HSPLIT);
+ BIND_CONSTANT(CURSOR_HELP);
+ BIND_CONSTANT(SIZE_EXPAND);
+ BIND_CONSTANT(SIZE_FILL);
+ BIND_CONSTANT(SIZE_EXPAND_FILL);
+ ADD_SIGNAL(MethodInfo("resized"));
+ ADD_SIGNAL(MethodInfo("input_event", PropertyInfo(Variant::INPUT_EVENT, "ev")));
+ ADD_SIGNAL(MethodInfo("mouse_enter"));
+ ADD_SIGNAL(MethodInfo("mouse_exit"));
+ ADD_SIGNAL(MethodInfo("focus_enter"));
+ ADD_SIGNAL(MethodInfo("focus_exit"));
+ ADD_SIGNAL(MethodInfo("size_flags_changed"));
+ ADD_SIGNAL(MethodInfo("minimum_size_changed"));
+ ADD_SIGNAL(MethodInfo("modal_close"));
}
Control::Control() {
- data.parent=NULL;
-
- data.ignore_mouse=false;
- data.stop_mouse=true;
+ data.parent = NULL;
+ data.ignore_mouse = false;
+ data.stop_mouse = true;
- data.SI=NULL;
- data.MI=NULL;
- data.RI=NULL;
- data.modal=false;
- data.theme_owner=NULL;
- data.modal_exclusive=false;
+ data.SI = NULL;
+ data.MI = NULL;
+ data.RI = NULL;
+ data.modal = false;
+ data.theme_owner = NULL;
+ data.modal_exclusive = false;
data.default_cursor = CURSOR_ARROW;
- data.h_size_flags=SIZE_FILL;
- data.v_size_flags=SIZE_FILL;
- data.expand=1;
- data.pending_min_size_update=false;
- data.rotation=0;
- data.parent_canvas_item=NULL;
- data.scale=Vector2(1,1);
- data.drag_owner=0;
- data.modal_frame=0;
+ data.h_size_flags = SIZE_FILL;
+ data.v_size_flags = SIZE_FILL;
+ data.expand = 1;
+ data.pending_min_size_update = false;
+ data.rotation = 0;
+ data.parent_canvas_item = NULL;
+ data.scale = Vector2(1, 1);
+ data.drag_owner = 0;
+ data.modal_frame = 0;
-
- for (int i=0;i<4;i++) {
- data.anchor[i]=ANCHOR_BEGIN;
- data.margin[i]=0;
+ for (int i = 0; i < 4; i++) {
+ data.anchor[i] = ANCHOR_BEGIN;
+ data.margin[i] = 0;
}
- data.focus_mode=FOCUS_NONE;
- data.modal_prev_focus_owner=0;
-
-
-
-
-
+ data.focus_mode = FOCUS_NONE;
+ data.modal_prev_focus_owner = 0;
}
-
-Control::~Control()
-{
+Control::~Control() {
}
diff --git a/scene/gui/control.h b/scene/gui/control.h
index f3d25a4c0..ddbdee548 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -29,13 +29,13 @@
#ifndef CONTROL_H
#define CONTROL_H
-#include "scene/main/node.h"
-#include "scene/resources/theme.h"
-#include "scene/main/timer.h"
-#include "scene/2d/canvas_item.h"
#include "math_2d.h"
#include "rid.h"
+#include "scene/2d/canvas_item.h"
#include "scene/gui/input_action.h"
+#include "scene/main/node.h"
+#include "scene/main/timer.h"
+#include "scene/resources/theme.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -46,11 +46,10 @@ class Panel;
class Control : public CanvasItem {
- OBJ_TYPE( Control, CanvasItem );
+ OBJ_TYPE(Control, CanvasItem);
OBJ_CATEGORY("GUI Nodes");
public:
-
enum AnchorType {
ANCHOR_BEGIN,
ANCHOR_END,
@@ -66,9 +65,9 @@ public:
enum SizeFlags {
- SIZE_EXPAND=1,
- SIZE_FILL=2,
- SIZE_EXPAND_FILL=SIZE_EXPAND|SIZE_FILL
+ SIZE_EXPAND = 1,
+ SIZE_FILL = 2,
+ SIZE_EXPAND_FILL = SIZE_EXPAND | SIZE_FILL
};
@@ -94,11 +93,10 @@ public:
};
private:
-
struct CComparator {
- bool operator()(const Control* p_a, const Control* p_b) const {
- if (p_a->get_canvas_layer()==p_b->get_canvas_layer())
+ bool operator()(const Control *p_a, const Control *p_b) const {
+ if (p_a->get_canvas_layer() == p_b->get_canvas_layer())
return p_b->is_greater_than(p_a);
else
return p_a->get_canvas_layer() < p_b->get_canvas_layer();
@@ -138,9 +136,9 @@ private:
String tooltip;
CursorShape default_cursor;
- List<Control*>::Element *MI; //modal item
- List<Control*>::Element *SI;
- List<Control*>::Element *RI;
+ List<Control *>::Element *MI; //modal item
+ List<Control *>::Element *SI;
+ List<Control *>::Element *RI;
CanvasItem *parent_canvas_item;
@@ -148,39 +146,36 @@ private:
NodePath focus_neighbour[4];
- HashMap<StringName, Ref<Texture>, StringNameHasher > icon_override;
- HashMap<StringName, Ref<Shader>, StringNameHasher > shader_override;
- HashMap<StringName, Ref<StyleBox>, StringNameHasher > style_override;
- HashMap<StringName, Ref<Font>, StringNameHasher > font_override;
- HashMap<StringName, Color, StringNameHasher > color_override;
- HashMap<StringName, int, StringNameHasher > constant_override;
- Map< Ref<Font>, int> font_refcount;
+ HashMap<StringName, Ref<Texture>, StringNameHasher> icon_override;
+ HashMap<StringName, Ref<Shader>, StringNameHasher> shader_override;
+ HashMap<StringName, Ref<StyleBox>, StringNameHasher> style_override;
+ HashMap<StringName, Ref<Font>, StringNameHasher> font_override;
+ HashMap<StringName, Color, StringNameHasher> color_override;
+ HashMap<StringName, int, StringNameHasher> constant_override;
+ Map<Ref<Font>, int> font_refcount;
} data;
// used internally
- Control* _find_control_at_pos(CanvasItem* p_node,const Point2& p_pos,const Matrix32& p_xform,Matrix32& r_inv_xform);
-
-
- void _window_find_focus_neighbour(const Vector2& p_dir, Node *p_at, const Point2* p_points ,float p_min,float &r_closest_dist,Control **r_closest);
- Control *_get_focus_neighbour(Margin p_margin,int p_count=0);
+ Control *_find_control_at_pos(CanvasItem *p_node, const Point2 &p_pos, const Matrix32 &p_xform, Matrix32 &r_inv_xform);
+ void _window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, float p_min, float &r_closest_dist, Control **r_closest);
+ Control *_get_focus_neighbour(Margin p_margin, int p_count = 0);
- void _set_anchor(Margin p_margin,AnchorType p_anchor);
+ void _set_anchor(Margin p_margin, AnchorType p_anchor);
float _get_parent_range(int p_idx) const;
float _get_range(int p_idx) const;
- float _s2a(float p_val, AnchorType p_anchor,float p_range) const;
- float _a2s(float p_val, AnchorType p_anchor,float p_range) const;
- void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign=true);
+ float _s2a(float p_val, AnchorType p_anchor, float p_range) const;
+ float _a2s(float p_val, AnchorType p_anchor, float p_range) const;
+ void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign = true);
void _theme_changed();
-
void _change_notify_margins();
void _update_minimum_size();
void _update_scroll();
- void _resize(const Size2& p_size);
+ void _resize(const Size2 &p_size);
void _size_changed();
String _get_tooltip() const;
@@ -190,65 +185,60 @@ private:
float _get_rotation_deg() const;
void _ref_font(Ref<Font> p_sc);
- void _unref_font( Ref<Font> p_sc);
+ void _unref_font(Ref<Font> p_sc);
void _font_changed();
-
-friend class Viewport;
+ friend class Viewport;
void _modal_stack_remove();
void _modal_set_prev_focus_owner(ObjectID p_prev);
protected:
-
//virtual void _window_input_event(InputEvent p_event);
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
void _notification(int p_notification);
-
static void _bind_methods();
//bind helpers
public:
-
enum {
-/* NOTIFICATION_DRAW=30,
+ /* NOTIFICATION_DRAW=30,
NOTIFICATION_VISIBILITY_CHANGED=38*/
- NOTIFICATION_RESIZED=40,
- NOTIFICATION_MOUSE_ENTER=41,
- NOTIFICATION_MOUSE_EXIT=42,
- NOTIFICATION_FOCUS_ENTER=43,
- NOTIFICATION_FOCUS_EXIT=44,
- NOTIFICATION_THEME_CHANGED=45,
- NOTIFICATION_MODAL_CLOSE=46,
-
+ NOTIFICATION_RESIZED = 40,
+ NOTIFICATION_MOUSE_ENTER = 41,
+ NOTIFICATION_MOUSE_EXIT = 42,
+ NOTIFICATION_FOCUS_ENTER = 43,
+ NOTIFICATION_FOCUS_EXIT = 44,
+ NOTIFICATION_THEME_CHANGED = 45,
+ NOTIFICATION_MODAL_CLOSE = 46,
};
virtual Variant edit_get_state() const;
- virtual void edit_set_state(const Variant& p_state);
- virtual void edit_set_rect(const Rect2& p_edit_rect);
+ virtual void edit_set_state(const Variant &p_state);
+ virtual void edit_set_rect(const Rect2 &p_edit_rect);
virtual Size2 edit_get_minimum_size() const;
void accept_event();
virtual Size2 get_minimum_size() const;
virtual Size2 get_combined_minimum_size() const;
- virtual bool has_point(const Point2& p_point) const;
+ virtual bool has_point(const Point2 &p_point) const;
virtual bool clips_input() const;
- virtual void set_drag_forwarding(Control* p_target);
- virtual Variant get_drag_data(const Point2& p_point);
- virtual bool can_drop_data(const Point2& p_point,const Variant& p_data) const;
- virtual void drop_data(const Point2& p_point,const Variant& p_data);
+ virtual void set_drag_forwarding(Control *p_target);
+ virtual Variant get_drag_data(const Point2 &p_point);
+ virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
+ virtual void drop_data(const Point2 &p_point, const Variant &p_data);
void set_drag_preview(Control *p_control);
- void force_drag(const Variant& p_data,Control *p_control);
+ void force_drag(const Variant &p_data, Control *p_control);
- void set_custom_minimum_size(const Size2& p_custom);
+ void set_custom_minimum_size(const Size2 &p_custom);
Size2 get_custom_minimum_size() const;
bool is_window_modal_on_top() const;
@@ -256,29 +246,25 @@ public:
Control *get_parent_control() const;
-
-
/* POSITIONING */
- void set_anchor(Margin p_margin,AnchorType p_anchor, bool p_keep_margin=false);
- void set_anchor_and_margin(Margin p_margin,AnchorType p_anchor, float p_pos);
+ void set_anchor(Margin p_margin, AnchorType p_anchor, bool p_keep_margin = false);
+ void set_anchor_and_margin(Margin p_margin, AnchorType p_anchor, float p_pos);
AnchorType get_anchor(Margin p_margin) const;
- void set_margin(Margin p_margin,float p_value);
-
- void set_begin(const Point2& p_point); // helper
- void set_end(const Point2& p_point); // helper
-
+ void set_margin(Margin p_margin, float p_value);
+ void set_begin(const Point2 &p_point); // helper
+ void set_end(const Point2 &p_point); // helper
float get_margin(Margin p_margin) const;
Point2 get_begin() const;
Point2 get_end() const;
- void set_pos(const Point2& p_point);
- void set_size(const Size2& p_size);
- void set_global_pos(const Point2& p_point);
+ void set_pos(const Point2 &p_point);
+ void set_size(const Size2 &p_size);
+ void set_global_pos(const Point2 &p_point);
Point2 get_pos() const;
Point2 get_global_pos() const;
@@ -292,15 +278,14 @@ public:
float get_rotation() const;
float get_rotation_deg() const;
- void set_scale(const Vector2& p_scale);
+ void set_scale(const Vector2 &p_scale);
Vector2 get_scale() const;
+ void set_area_as_parent_rect(int p_margin = 0);
- void set_area_as_parent_rect(int p_margin=0);
-
- void show_modal(bool p_exclusive=false);
+ void show_modal(bool p_exclusive = false);
- void set_theme(const Ref<Theme>& p_theme);
+ void set_theme(const Ref<Theme> &p_theme);
Ref<Theme> get_theme() const;
void set_h_size_flags(int p_flags);
@@ -338,44 +323,44 @@ public:
/* SKINNING */
- void add_icon_override(const StringName& p_name, const Ref<Texture>& p_icon);
- void add_shader_override(const StringName& p_name, const Ref<Shader>& p_shader);
- void add_style_override(const StringName& p_name, const Ref<StyleBox>& p_style);
- void add_font_override(const StringName& p_name, const Ref<Font>& p_font);
- void add_color_override(const StringName& p_name, const Color& p_color);
- void add_constant_override(const StringName& p_name, int p_constant);
+ void add_icon_override(const StringName &p_name, const Ref<Texture> &p_icon);
+ void add_shader_override(const StringName &p_name, const Ref<Shader> &p_shader);
+ void add_style_override(const StringName &p_name, const Ref<StyleBox> &p_style);
+ void add_font_override(const StringName &p_name, const Ref<Font> &p_font);
+ void add_color_override(const StringName &p_name, const Color &p_color);
+ void add_constant_override(const StringName &p_name, int p_constant);
- Ref<Texture> get_icon(const StringName& p_name,const StringName& p_type=StringName()) const;
- Ref<Shader> get_shader(const StringName &p_name, const StringName &p_type=StringName()) const;
- Ref<StyleBox> get_stylebox(const StringName& p_name,const StringName& p_type=StringName()) const;
- Ref<Font> get_font(const StringName& p_name,const StringName& p_type=StringName()) const;
- Color get_color(const StringName& p_name,const StringName& p_type=StringName()) const;
- int get_constant(const StringName& p_name,const StringName& p_type=StringName()) const;
+ Ref<Texture> get_icon(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<Shader> get_shader(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<StyleBox> get_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Ref<Font> get_font(const StringName &p_name, const StringName &p_type = StringName()) const;
+ Color get_color(const StringName &p_name, const StringName &p_type = StringName()) const;
+ int get_constant(const StringName &p_name, const StringName &p_type = StringName()) const;
- bool has_icon_override(const StringName& p_name) const;
- bool has_shader_override(const StringName& p_name) const;
- bool has_stylebox_override(const StringName& p_name) const;
- bool has_font_override(const StringName& p_name) const;
- bool has_color_override(const StringName& p_name) const;
- bool has_constant_override(const StringName& p_name) const;
+ bool has_icon_override(const StringName &p_name) const;
+ bool has_shader_override(const StringName &p_name) const;
+ bool has_stylebox_override(const StringName &p_name) const;
+ bool has_font_override(const StringName &p_name) const;
+ bool has_color_override(const StringName &p_name) const;
+ bool has_constant_override(const StringName &p_name) const;
- bool has_icon(const StringName& p_name,const StringName& p_type=StringName()) const;
- bool has_shader(const StringName& p_name,const StringName& p_type=StringName()) const;
- bool has_stylebox(const StringName& p_name,const StringName& p_type=StringName()) const;
- bool has_font(const StringName& p_name,const StringName& p_type=StringName()) const;
- bool has_color(const StringName& p_name,const StringName& p_type=StringName()) const;
- bool has_constant(const StringName& p_name,const StringName& p_type=StringName()) const;
+ bool has_icon(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_shader(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_font(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_color(const StringName &p_name, const StringName &p_type = StringName()) const;
+ bool has_constant(const StringName &p_name, const StringName &p_type = StringName()) const;
/* TOOLTIP */
- void set_tooltip(const String& p_tooltip);
- virtual String get_tooltip(const Point2& p_pos) const;
+ void set_tooltip(const String &p_tooltip);
+ virtual String get_tooltip(const Point2 &p_pos) const;
/* CURSOR */
void set_default_cursor_shape(CursorShape p_shape);
CursorShape get_default_cursor_shape() const;
- virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
virtual Rect2 get_item_rect() const;
virtual Matrix32 get_transform() const;
@@ -386,7 +371,7 @@ public:
void grab_click_focus();
- void warp_mouse(const Point2& p_to_pos);
+ void warp_mouse(const Point2 &p_to_pos);
virtual bool is_text_field() const;
@@ -394,7 +379,6 @@ public:
Control();
~Control();
-
};
VARIANT_ENUM_CAST(Control::AnchorType);
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 923d2ec56..c887ae9cd 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -27,46 +27,43 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "dialogs.h"
-#include "print_string.h"
#include "line_edit.h"
+#include "print_string.h"
#include "translation.h"
void WindowDialog::_post_popup() {
- dragging=false; //just in case
+ dragging = false; //just in case
}
-bool WindowDialog::has_point(const Point2& p_point) const {
-
+bool WindowDialog::has_point(const Point2 &p_point) const {
- int extra = get_constant("titlebar_height","WindowDialog");
- Rect2 r( Point2(), get_size() );
- r.pos.y-=extra;
- r.size.y+=extra;
+ int extra = get_constant("titlebar_height", "WindowDialog");
+ Rect2 r(Point2(), get_size());
+ r.pos.y -= extra;
+ r.size.y += extra;
return r.has_point(p_point);
-
}
-void WindowDialog::_input_event(const InputEvent& p_event) {
+void WindowDialog::_input_event(const InputEvent &p_event) {
- if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_LEFT) {
if (p_event.mouse_button.pressed && p_event.mouse_button.y < 0)
- dragging=true;
+ dragging = true;
else if (dragging && !p_event.mouse_button.pressed)
- dragging=false;
+ dragging = false;
}
-
if (p_event.type == InputEvent::MOUSE_MOTION && dragging) {
- Point2 rel( p_event.mouse_motion.relative_x, p_event.mouse_motion.relative_y );
+ Point2 rel(p_event.mouse_motion.relative_x, p_event.mouse_motion.relative_y);
Point2 pos = get_pos();
- pos+=rel;
+ pos += rel;
- if (pos.y<0)
- pos.y=0;
+ if (pos.y < 0)
+ pos.y = 0;
set_pos(pos);
}
@@ -74,35 +71,33 @@ void WindowDialog::_input_event(const InputEvent& p_event) {
void WindowDialog::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
RID ci = get_canvas_item();
Size2 s = get_size();
- Ref<StyleBox> st = get_stylebox("panel","WindowDialog");
- st->draw(ci,Rect2(Point2(),s));
- int th = get_constant("title_height","WindowDialog");
- Color tc = get_color("title_color","WindowDialog");
- Ref<Font> font = get_font("title_font","WindowDialog");
- int ofs = (s.width-font->get_string_size(title).width)/2;
+ Ref<StyleBox> st = get_stylebox("panel", "WindowDialog");
+ st->draw(ci, Rect2(Point2(), s));
+ int th = get_constant("title_height", "WindowDialog");
+ Color tc = get_color("title_color", "WindowDialog");
+ Ref<Font> font = get_font("title_font", "WindowDialog");
+ int ofs = (s.width - font->get_string_size(title).width) / 2;
//int ofs = st->get_margin(MARGIN_LEFT);
- draw_string(font,Point2(ofs,-th+font->get_ascent()),title,tc,s.width - st->get_minimum_size().width);
-
+ draw_string(font, Point2(ofs, -th + font->get_ascent()), title, tc, s.width - st->get_minimum_size().width);
} break;
case NOTIFICATION_THEME_CHANGED:
case NOTIFICATION_ENTER_TREE: {
- close_button->set_normal_texture( get_icon("close","WindowDialog"));
- close_button->set_pressed_texture( get_icon("close","WindowDialog"));
- close_button->set_hover_texture( get_icon("close_hilite","WindowDialog"));
- close_button->set_anchor(MARGIN_LEFT,ANCHOR_END);
- close_button->set_begin( Point2( get_constant("close_h_ofs","WindowDialog"), -get_constant("close_v_ofs","WindowDialog") ));
+ close_button->set_normal_texture(get_icon("close", "WindowDialog"));
+ close_button->set_pressed_texture(get_icon("close", "WindowDialog"));
+ close_button->set_hover_texture(get_icon("close_hilite", "WindowDialog"));
+ close_button->set_anchor(MARGIN_LEFT, ANCHOR_END);
+ close_button->set_begin(Point2(get_constant("close_h_ofs", "WindowDialog"), -get_constant("close_v_ofs", "WindowDialog")));
} break;
}
-
}
void WindowDialog::_closed() {
@@ -111,103 +106,90 @@ void WindowDialog::_closed() {
hide();
}
-void WindowDialog::set_title(const String& p_title) {
+void WindowDialog::set_title(const String &p_title) {
- title=XL_MESSAGE(p_title);
+ title = XL_MESSAGE(p_title);
update();
}
Size2 WindowDialog::get_minimum_size() const {
- Ref<Font> font = get_font("title_font","WindowDialog");
- int msx=close_button->get_combined_minimum_size().x;
- msx+=font->get_string_size(title).x;
+ Ref<Font> font = get_font("title_font", "WindowDialog");
+ int msx = close_button->get_combined_minimum_size().x;
+ msx += font->get_string_size(title).x;
- return Size2(msx,1);
+ return Size2(msx, 1);
}
-
String WindowDialog::get_title() const {
return title;
}
-
TextureButton *WindowDialog::get_close_button() {
-
return close_button;
}
void WindowDialog::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("_input_event"),&WindowDialog::_input_event);
- ObjectTypeDB::bind_method( _MD("set_title","title"),&WindowDialog::set_title);
- ObjectTypeDB::bind_method( _MD("get_title"),&WindowDialog::get_title);
- ObjectTypeDB::bind_method( _MD("_closed"),&WindowDialog::_closed);
- ObjectTypeDB::bind_method( _MD("get_close_button:TextureButton"),&WindowDialog::get_close_button);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &WindowDialog::_input_event);
+ ObjectTypeDB::bind_method(_MD("set_title", "title"), &WindowDialog::set_title);
+ ObjectTypeDB::bind_method(_MD("get_title"), &WindowDialog::get_title);
+ ObjectTypeDB::bind_method(_MD("_closed"), &WindowDialog::_closed);
+ ObjectTypeDB::bind_method(_MD("get_close_button:TextureButton"), &WindowDialog::get_close_button);
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"window/title",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_title"),_SCS("get_title"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "window/title", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_title"), _SCS("get_title"));
}
WindowDialog::WindowDialog() {
//title="Hello!";
- dragging=false;
- close_button = memnew( TextureButton );
+ dragging = false;
+ close_button = memnew(TextureButton);
add_child(close_button);
- close_button->connect("pressed",this,"_closed");
-
+ close_button->connect("pressed", this, "_closed");
}
-WindowDialog::~WindowDialog(){
-
-
+WindowDialog::~WindowDialog() {
}
-
void PopupDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
- get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
+ get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
}
}
PopupDialog::PopupDialog() {
-
-
}
PopupDialog::~PopupDialog() {
-
-
}
-
//
-
void AcceptDialog::_post_popup() {
WindowDialog::_post_popup();
get_ok()->grab_focus();
-
}
void AcceptDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_MODAL_CLOSE) {
+ if (p_what == NOTIFICATION_MODAL_CLOSE) {
cancel_pressed();
- } if (p_what==NOTIFICATION_RESIZED) {
+ }
+ if (p_what == NOTIFICATION_RESIZED) {
_update_child_rect();
}
}
-void AcceptDialog::_builtin_text_entered(const String& p_text) {
+void AcceptDialog::_builtin_text_entered(const String &p_text) {
_ok_pressed();
}
@@ -218,7 +200,6 @@ void AcceptDialog::_ok_pressed() {
hide();
ok_pressed();
emit_signal("confirmed");
-
}
void AcceptDialog::_close_pressed() {
@@ -238,7 +219,7 @@ void AcceptDialog::set_text(String p_text) {
void AcceptDialog::set_hide_on_ok(bool p_hide) {
- hide_on_ok=p_hide;
+ hide_on_ok = p_hide;
}
bool AcceptDialog::get_hide_on_ok() const {
@@ -246,24 +227,23 @@ bool AcceptDialog::get_hide_on_ok() const {
return hide_on_ok;
}
-
void AcceptDialog::register_text_enter(Node *p_line_edit) {
ERR_FAIL_NULL(p_line_edit);
- p_line_edit->connect("text_entered", this,"_builtin_text_entered");
+ p_line_edit->connect("text_entered", this, "_builtin_text_entered");
}
void AcceptDialog::_update_child_rect() {
- Size2 label_size=label->get_minimum_size();
+ Size2 label_size = label->get_minimum_size();
if (label->get_text().empty()) {
label_size.height = 0;
}
- int margin = get_constant("margin","Dialogs");
+ int margin = get_constant("margin", "Dialogs");
Size2 size = get_size();
Size2 hminsize = hbc->get_combined_minimum_size();
- Vector2 cpos(margin,margin+label_size.height);
- Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y-label_size.height);
+ Vector2 cpos(margin, margin + label_size.height);
+ Vector2 csize(size.x - margin * 2, size.y - margin * 3 - hminsize.y - label_size.height);
if (child) {
@@ -271,64 +251,61 @@ void AcceptDialog::_update_child_rect() {
child->set_size(csize);
}
- cpos.y+=csize.y+margin;
- csize.y=hminsize.y;
+ cpos.y += csize.y + margin;
+ csize.y = hminsize.y;
hbc->set_pos(cpos);
hbc->set_size(csize);
-
}
Size2 AcceptDialog::get_minimum_size() const {
- int margin = get_constant("margin","Dialogs");
+ int margin = get_constant("margin", "Dialogs");
Size2 minsize = label->get_combined_minimum_size();
if (child) {
Size2 cminsize = child->get_combined_minimum_size();
- minsize.x=MAX(cminsize.x,minsize.x);
- minsize.y=MAX(cminsize.y,minsize.y);
+ minsize.x = MAX(cminsize.x, minsize.x);
+ minsize.y = MAX(cminsize.y, minsize.y);
}
Size2 hminsize = hbc->get_combined_minimum_size();
- minsize.x = MAX(hminsize.x,minsize.x);
- minsize.y+=hminsize.y;
- minsize.x+=margin*2;
- minsize.y+=margin*3; //one as separation between hbc and child
+ minsize.x = MAX(hminsize.x, minsize.x);
+ minsize.y += hminsize.y;
+ minsize.x += margin * 2;
+ minsize.y += margin * 3; //one as separation between hbc and child
Size2 wmsize = WindowDialog::get_minimum_size();
- minsize.x=MAX(wmsize.x,minsize.x);
+ minsize.x = MAX(wmsize.x, minsize.x);
return minsize;
}
-
void AcceptDialog::set_child_rect(Control *p_child) {
- ERR_FAIL_COND(p_child->get_parent()!=this);
+ ERR_FAIL_COND(p_child->get_parent() != this);
//p_child->set_area_as_parent_rect(get_constant("margin","Dialogs"));
- child=p_child;
+ child = p_child;
minimum_size_changed();
_update_child_rect();
}
void AcceptDialog::remove_child_notify(Node *p_child) {
- if (p_child==child) {
- child=NULL;
+ if (p_child == child) {
+ child = NULL;
}
}
-void AcceptDialog::_custom_action(const String& p_action) {
+void AcceptDialog::_custom_action(const String &p_action) {
- emit_signal("custom_action",p_action);
+ emit_signal("custom_action", p_action);
custom_action(p_action);
}
-Button* AcceptDialog::add_button(const String& p_text,bool p_right,const String& p_action) {
-
+Button *AcceptDialog::add_button(const String &p_text, bool p_right, const String &p_action) {
- Button *button = memnew( Button );
+ Button *button = memnew(Button);
button->set_text(p_text);
if (p_right) {
hbc->add_child(button);
@@ -336,99 +313,92 @@ Button* AcceptDialog::add_button(const String& p_text,bool p_right,const String&
} else {
hbc->add_child(button);
- hbc->move_child(button,0);
+ hbc->move_child(button, 0);
hbc->add_spacer(true);
}
- if (p_action!="") {
- button->connect("pressed",this,"_custom_action",varray(p_action));
+ if (p_action != "") {
+ button->connect("pressed", this, "_custom_action", varray(p_action));
}
return button;
}
-Button* AcceptDialog::add_cancel(const String &p_cancel) {
+Button *AcceptDialog::add_cancel(const String &p_cancel) {
String c = p_cancel;
- if (p_cancel=="")
- c=RTR("Cancel");
- Button *b = swap_ok_cancel ? add_button(c,true) : add_button(c);
- b->connect("pressed",this,"_closed");
+ if (p_cancel == "")
+ c = RTR("Cancel");
+ Button *b = swap_ok_cancel ? add_button(c, true) : add_button(c);
+ b->connect("pressed", this, "_closed");
return b;
}
void AcceptDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_ok"),&AcceptDialog::_ok_pressed);
- ObjectTypeDB::bind_method(_MD("get_ok"),&AcceptDialog::get_ok);
- ObjectTypeDB::bind_method(_MD("get_label"),&AcceptDialog::get_label);
- ObjectTypeDB::bind_method(_MD("set_hide_on_ok","enabled"),&AcceptDialog::set_hide_on_ok);
- ObjectTypeDB::bind_method(_MD("get_hide_on_ok"),&AcceptDialog::get_hide_on_ok);
- ObjectTypeDB::bind_method(_MD("add_button:Button","text","right","action"),&AcceptDialog::add_button,DEFVAL(false),DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("add_cancel:Button","name"),&AcceptDialog::add_cancel);
- ObjectTypeDB::bind_method(_MD("_builtin_text_entered"),&AcceptDialog::_builtin_text_entered);
- ObjectTypeDB::bind_method(_MD("register_text_enter:LineEdit","line_edit"),&AcceptDialog::register_text_enter);
- ObjectTypeDB::bind_method(_MD("_custom_action"),&AcceptDialog::_custom_action);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&AcceptDialog::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&AcceptDialog::get_text);
+ ObjectTypeDB::bind_method(_MD("_ok"), &AcceptDialog::_ok_pressed);
+ ObjectTypeDB::bind_method(_MD("get_ok"), &AcceptDialog::get_ok);
+ ObjectTypeDB::bind_method(_MD("get_label"), &AcceptDialog::get_label);
+ ObjectTypeDB::bind_method(_MD("set_hide_on_ok", "enabled"), &AcceptDialog::set_hide_on_ok);
+ ObjectTypeDB::bind_method(_MD("get_hide_on_ok"), &AcceptDialog::get_hide_on_ok);
+ ObjectTypeDB::bind_method(_MD("add_button:Button", "text", "right", "action"), &AcceptDialog::add_button, DEFVAL(false), DEFVAL(""));
+ ObjectTypeDB::bind_method(_MD("add_cancel:Button", "name"), &AcceptDialog::add_cancel);
+ ObjectTypeDB::bind_method(_MD("_builtin_text_entered"), &AcceptDialog::_builtin_text_entered);
+ ObjectTypeDB::bind_method(_MD("register_text_enter:LineEdit", "line_edit"), &AcceptDialog::register_text_enter);
+ ObjectTypeDB::bind_method(_MD("_custom_action"), &AcceptDialog::_custom_action);
+ ObjectTypeDB::bind_method(_MD("set_text", "text"), &AcceptDialog::set_text);
+ ObjectTypeDB::bind_method(_MD("get_text"), &AcceptDialog::get_text);
- ADD_SIGNAL( MethodInfo("confirmed") );
- ADD_SIGNAL( MethodInfo("custom_action",PropertyInfo(Variant::STRING,"action")) );
-
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"dialog/text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_text"),_SCS("get_text"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "dialog/hide_on_ok"),_SCS("set_hide_on_ok"),_SCS("get_hide_on_ok") );
+ ADD_SIGNAL(MethodInfo("confirmed"));
+ ADD_SIGNAL(MethodInfo("custom_action", PropertyInfo(Variant::STRING, "action")));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "dialog/text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"), _SCS("get_text"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dialog/hide_on_ok"), _SCS("set_hide_on_ok"), _SCS("get_hide_on_ok"));
}
-
-bool AcceptDialog::swap_ok_cancel=false;
+bool AcceptDialog::swap_ok_cancel = false;
void AcceptDialog::set_swap_ok_cancel(bool p_swap) {
- swap_ok_cancel=p_swap;
+ swap_ok_cancel = p_swap;
}
AcceptDialog::AcceptDialog() {
- int margin = get_constant("margin","Dialogs");
- int button_margin = get_constant("button_margin","Dialogs");
+ int margin = get_constant("margin", "Dialogs");
+ int button_margin = get_constant("button_margin", "Dialogs");
-
- label = memnew( Label );
- label->set_anchor(MARGIN_RIGHT,ANCHOR_END);
- label->set_anchor(MARGIN_BOTTOM,ANCHOR_END);
- label->set_begin( Point2( margin, margin) );
- label->set_end( Point2( margin, button_margin+10) );
+ label = memnew(Label);
+ label->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ label->set_anchor(MARGIN_BOTTOM, ANCHOR_END);
+ label->set_begin(Point2(margin, margin));
+ label->set_end(Point2(margin, button_margin + 10));
//label->set_autowrap(true);
add_child(label);
- hbc = memnew( HBoxContainer );
+ hbc = memnew(HBoxContainer);
add_child(hbc);
hbc->add_spacer();
- ok = memnew( Button );
+ ok = memnew(Button);
ok->set_text(RTR("OK"));
hbc->add_child(ok);
hbc->add_spacer();
-
- ok->connect("pressed", this,"_ok");
+ ok->connect("pressed", this, "_ok");
set_as_toplevel(true);
- hide_on_ok=true;
+ hide_on_ok = true;
set_title(RTR("Alert!"));
- child=NULL;
+ child = NULL;
}
-
-AcceptDialog::~AcceptDialog()
-{
+AcceptDialog::~AcceptDialog() {
}
-
void ConfirmationDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_cancel:Button"),&ConfirmationDialog::get_cancel);
+ ObjectTypeDB::bind_method(_MD("get_cancel:Button"), &ConfirmationDialog::get_cancel);
}
Button *ConfirmationDialog::get_cancel() {
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index 2278ce026..955514dc3 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -29,110 +29,101 @@
#ifndef DIALOGS_H
#define DIALOGS_H
-#include "scene/gui/label.h"
+#include "box_container.h"
#include "scene/gui/button.h"
-#include "scene/gui/texture_button.h"
+#include "scene/gui/label.h"
#include "scene/gui/panel.h"
#include "scene/gui/popup.h"
-#include "box_container.h"
+#include "scene/gui/texture_button.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
class WindowDialog : public Popup {
- OBJ_TYPE(WindowDialog,Popup);
+ OBJ_TYPE(WindowDialog, Popup);
TextureButton *close_button;
String title;
bool dragging;
- void _input_event(const InputEvent& p_event);
+ void _input_event(const InputEvent &p_event);
void _closed();
+
protected:
virtual void _post_popup();
- virtual void _close_pressed() {}
- virtual bool has_point(const Point2& p_point) const;
+ virtual void _close_pressed() {}
+ virtual bool has_point(const Point2 &p_point) const;
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
TextureButton *get_close_button();
- void set_title(const String& p_title);
+ void set_title(const String &p_title);
String get_title() const;
Size2 get_minimum_size() const;
WindowDialog();
~WindowDialog();
-
};
class PopupDialog : public Popup {
- OBJ_TYPE(PopupDialog,Popup);
+ OBJ_TYPE(PopupDialog, Popup);
protected:
void _notification(int p_what);
-public:
+public:
PopupDialog();
~PopupDialog();
-
};
-
class LineEdit;
class AcceptDialog : public WindowDialog {
- OBJ_TYPE(AcceptDialog,WindowDialog);
+ OBJ_TYPE(AcceptDialog, WindowDialog);
Control *child;
HBoxContainer *hbc;
Label *label;
Button *ok;
-// Button *cancel; no more cancel (there is X on tht titlebar)
+ // Button *cancel; no more cancel (there is X on tht titlebar)
bool hide_on_ok;
-
- void _custom_action(const String& p_action);
+ void _custom_action(const String &p_action);
void _ok_pressed();
void _close_pressed();
- void _builtin_text_entered(const String& p_text);
+ void _builtin_text_entered(const String &p_text);
void _update_child_rect();
static bool swap_ok_cancel;
-
virtual void remove_child_notify(Node *p_child);
-
protected:
-
virtual void _post_popup();
void _notification(int p_what);
static void _bind_methods();
virtual void ok_pressed() {}
virtual void cancel_pressed() {}
- virtual void custom_action(const String&) {}
-public:
+ virtual void custom_action(const String &) {}
+public:
Size2 get_minimum_size() const;
Label *get_label() { return label; }
static void set_swap_ok_cancel(bool p_swap);
-
void register_text_enter(Node *p_line_edit);
Button *get_ok() { return ok; }
- Button* add_button(const String& p_text,bool p_right=false,const String& p_action="");
- Button* add_cancel(const String &p_cancel="");
-
+ Button *add_button(const String &p_text, bool p_right = false, const String &p_action = "");
+ Button *add_cancel(const String &p_cancel = "");
void set_hide_on_ok(bool p_hide);
bool get_hide_on_ok() const;
@@ -144,21 +135,19 @@ public:
AcceptDialog();
~AcceptDialog();
-
};
-
class ConfirmationDialog : public AcceptDialog {
- OBJ_TYPE(ConfirmationDialog,AcceptDialog);
+ OBJ_TYPE(ConfirmationDialog, AcceptDialog);
Button *cancel;
+
protected:
static void _bind_methods();
-public:
+public:
Button *get_cancel();
ConfirmationDialog();
-
};
#endif
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 81085d23a..fa7f05e5a 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -27,52 +27,48 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_dialog.h"
-#include "scene/gui/label.h"
-#include "print_string.h"
#include "os/keyboard.h"
+#include "print_string.h"
+#include "scene/gui/label.h"
+FileDialog::GetIconFunc FileDialog::get_icon_func = NULL;
+FileDialog::GetIconFunc FileDialog::get_large_icon_func = NULL;
-
-FileDialog::GetIconFunc FileDialog::get_icon_func=NULL;
-FileDialog::GetIconFunc FileDialog::get_large_icon_func=NULL;
-
-FileDialog::RegisterFunc FileDialog::register_func=NULL;
-FileDialog::RegisterFunc FileDialog::unregister_func=NULL;
-
+FileDialog::RegisterFunc FileDialog::register_func = NULL;
+FileDialog::RegisterFunc FileDialog::unregister_func = NULL;
VBoxContainer *FileDialog::get_vbox() {
return vbox;
-
}
void FileDialog::_notification(int p_what) {
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
refresh->set_icon(get_icon("reload"));
}
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
//RID ci = get_canvas_item();
//get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
}
- if (p_what==NOTIFICATION_POPUP_HIDE) {
+ if (p_what == NOTIFICATION_POPUP_HIDE) {
set_process_unhandled_input(false);
}
}
-void FileDialog::_unhandled_input(const InputEvent& p_event) {
+void FileDialog::_unhandled_input(const InputEvent &p_event) {
- if (p_event.type==InputEvent::KEY && is_window_modal_on_top()) {
+ if (p_event.type == InputEvent::KEY && is_window_modal_on_top()) {
- const InputEventKey &k=p_event.key;
+ const InputEventKey &k = p_event.key;
if (k.pressed) {
- bool handled=true;
+ bool handled = true;
switch (k.scancode) {
@@ -81,7 +77,7 @@ void FileDialog::_unhandled_input(const InputEvent& p_event) {
if (k.mod.command) {
set_show_hidden_files(!show_hidden_files);
} else {
- handled=false;
+ handled = false;
}
} break;
@@ -89,7 +85,7 @@ void FileDialog::_unhandled_input(const InputEvent& p_event) {
invalidate();
} break;
- default: { handled=false; }
+ default: { handled = false; }
}
if (handled)
@@ -100,15 +96,15 @@ void FileDialog::_unhandled_input(const InputEvent& p_event) {
void FileDialog::set_enable_multiple_selection(bool p_enable) {
- tree->set_select_mode(p_enable?Tree::SELECT_MULTI : Tree::SELECT_SINGLE);
+ tree->set_select_mode(p_enable ? Tree::SELECT_MULTI : Tree::SELECT_SINGLE);
};
Vector<String> FileDialog::get_selected_files() const {
Vector<String> list;
- TreeItem* item = tree->get_root();
- while ( (item = tree->get_next_selected(item)) ) {
+ TreeItem *item = tree->get_root();
+ while ((item = tree->get_next_selected(item))) {
list.push_back(dir_access->get_current_dir().plus_file(item->get_text(0)));
};
@@ -123,21 +119,20 @@ void FileDialog::update_dir() {
void FileDialog::_dir_entered(String p_dir) {
-
dir_access->change_dir(p_dir);
file->set_text("");
invalidate();
update_dir();
}
-void FileDialog::_file_entered(const String& p_file) {
+void FileDialog::_file_entered(const String &p_file) {
_action_pressed();
}
void FileDialog::_save_confirm_pressed() {
- String f=dir_access->get_current_dir().plus_file(file->get_text());
- emit_signal("file_selected",f);
+ String f = dir_access->get_current_dir().plus_file(file->get_text());
+ emit_signal("file_selected", f);
hide();
}
@@ -146,75 +141,73 @@ void FileDialog::_post_popup() {
ConfirmationDialog::_post_popup();
if (invalidated) {
update_file_list();
- invalidated=false;
+ invalidated = false;
}
- if (mode==MODE_SAVE_FILE)
+ if (mode == MODE_SAVE_FILE)
file->grab_focus();
else
tree->grab_focus();
set_process_unhandled_input(true);
-
}
void FileDialog::_action_pressed() {
- if (mode==MODE_OPEN_FILES) {
+ if (mode == MODE_OPEN_FILES) {
- TreeItem *ti=tree->get_next_selected(NULL);
- String fbase=dir_access->get_current_dir();
+ TreeItem *ti = tree->get_next_selected(NULL);
+ String fbase = dir_access->get_current_dir();
DVector<String> files;
- while(ti) {
+ while (ti) {
- files.push_back( fbase.plus_file(ti->get_text(0)) );
- ti=tree->get_next_selected(ti);
+ files.push_back(fbase.plus_file(ti->get_text(0)));
+ ti = tree->get_next_selected(ti);
}
if (files.size()) {
- emit_signal("files_selected",files);
+ emit_signal("files_selected", files);
hide();
}
return;
}
- String f=dir_access->get_current_dir().plus_file(file->get_text());
+ String f = dir_access->get_current_dir().plus_file(file->get_text());
- if ((mode==MODE_OPEN_ANY || mode==MODE_OPEN_FILE) && dir_access->file_exists(f)) {
- emit_signal("file_selected",f);
+ if ((mode == MODE_OPEN_ANY || mode == MODE_OPEN_FILE) && dir_access->file_exists(f)) {
+ emit_signal("file_selected", f);
hide();
- }else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) {
+ } else if (mode == MODE_OPEN_ANY || mode == MODE_OPEN_DIR) {
-
- String path=dir_access->get_current_dir();
+ String path = dir_access->get_current_dir();
/*if (tree->get_selected()) {
Dictionary d = tree->get_selected()->get_metadata(0);
if (d["dir"]) {
path=path+"/"+String(d["name"]);
}
}*/
- path=path.replace("\\","/");
- emit_signal("dir_selected",path);
+ path = path.replace("\\", "/");
+ emit_signal("dir_selected", path);
hide();
}
- if (mode==MODE_SAVE_FILE) {
+ if (mode == MODE_SAVE_FILE) {
- bool valid=false;
+ bool valid = false;
- if (filter->get_selected()==filter->get_item_count()-1) {
- valid=true; //match none
- } else if (filters.size()>1 && filter->get_selected()==0) {
+ if (filter->get_selected() == filter->get_item_count() - 1) {
+ valid = true; //match none
+ } else if (filters.size() > 1 && filter->get_selected() == 0) {
// match all filters
- for (int i=0;i<filters.size();i++) {
+ for (int i = 0; i < filters.size(); i++) {
- String flt=filters[i].get_slice(";",0);
- for (int j=0;j<flt.get_slice_count(",");j++) {
+ String flt = filters[i].get_slice(";", 0);
+ for (int j = 0; j < flt.get_slice_count(","); j++) {
- String str = flt.get_slice(",",j).strip_edges();
+ String str = flt.get_slice(",", j).strip_edges();
if (f.match(str)) {
- valid=true;
+ valid = true;
break;
}
}
@@ -222,48 +215,45 @@ void FileDialog::_action_pressed() {
break;
}
} else {
- int idx=filter->get_selected();
- if (filters.size()>1)
+ int idx = filter->get_selected();
+ if (filters.size() > 1)
idx--;
- if (idx>=0 && idx<filters.size()) {
+ if (idx >= 0 && idx < filters.size()) {
- String flt=filters[idx].get_slice(";",0);
- int filterSliceCount=flt.get_slice_count(",");
- for (int j=0;j<filterSliceCount;j++) {
+ String flt = filters[idx].get_slice(";", 0);
+ int filterSliceCount = flt.get_slice_count(",");
+ for (int j = 0; j < filterSliceCount; j++) {
- String str = (flt.get_slice(",",j).strip_edges());
+ String str = (flt.get_slice(",", j).strip_edges());
if (f.match(str)) {
- valid=true;
+ valid = true;
break;
}
}
- if (!valid && filterSliceCount>0) {
- String str = (flt.get_slice(",",0).strip_edges());
- f+=str.substr(1, str.length()-1);
+ if (!valid && filterSliceCount > 0) {
+ String str = (flt.get_slice(",", 0).strip_edges());
+ f += str.substr(1, str.length() - 1);
file->set_text(f.get_file());
- valid=true;
+ valid = true;
}
} else {
- valid=true;
+ valid = true;
}
}
-
if (!valid) {
- exterr->popup_centered_minsize(Size2(250,80));
+ exterr->popup_centered_minsize(Size2(250, 80));
return;
-
}
if (dir_access->file_exists(f)) {
confirm_save->set_text(RTR("File Exists, Overwrite?"));
- confirm_save->popup_centered(Size2(200,80));
+ confirm_save->popup_centered(Size2(200, 80));
} else {
-
- emit_signal("file_selected",f);
+ emit_signal("file_selected", f);
hide();
}
}
@@ -278,31 +268,29 @@ void FileDialog::_cancel_pressed() {
void FileDialog::_tree_selected() {
- TreeItem *ti=tree->get_selected();
+ TreeItem *ti = tree->get_selected();
if (!ti)
return;
- Dictionary d=ti->get_metadata(0);
+ Dictionary d = ti->get_metadata(0);
if (!d["dir"]) {
file->set_text(d["name"]);
}
-
}
void FileDialog::_tree_dc_selected() {
-
- TreeItem *ti=tree->get_selected();
+ TreeItem *ti = tree->get_selected();
if (!ti)
return;
- Dictionary d=ti->get_metadata(0);
+ Dictionary d = ti->get_metadata(0);
if (d["dir"]) {
dir_access->change_dir(d["name"]);
- if (mode==MODE_OPEN_FILE || mode==MODE_OPEN_FILES || mode==MODE_OPEN_DIR || mode==MODE_OPEN_ANY)
+ if (mode == MODE_OPEN_FILE || mode == MODE_OPEN_FILES || mode == MODE_OPEN_DIR || mode == MODE_OPEN_ANY)
file->set_text("");
call_deferred("_update_file_list");
call_deferred("_update_dir");
@@ -327,7 +315,7 @@ void FileDialog::update_file_list() {
bool show_hidden = show_hidden_files;
String item;
- while ((item=dir_access->get_next(&isdir))!="") {
+ while ((item = dir_access->get_next(&isdir)) != "") {
ishidden = dir_access->current_is_hidden();
@@ -339,7 +327,7 @@ void FileDialog::update_file_list() {
}
}
- if (dirs.find("..")==NULL) {
+ if (dirs.find("..") == NULL) {
//may happen if lacking permissions
dirs.push_back("..");
}
@@ -347,102 +335,98 @@ void FileDialog::update_file_list() {
dirs.sort_custom<NoCaseComparator>();
files.sort_custom<NoCaseComparator>();
- while(!dirs.empty()) {
+ while (!dirs.empty()) {
- if (dirs.front()->get()!=".") {
- TreeItem *ti=tree->create_item(root);
- ti->set_text(0,dirs.front()->get()+"/");
- ti->set_icon(0,folder);
+ if (dirs.front()->get() != ".") {
+ TreeItem *ti = tree->create_item(root);
+ ti->set_text(0, dirs.front()->get() + "/");
+ ti->set_icon(0, folder);
Dictionary d;
- d["name"]=dirs.front()->get();
- d["dir"]=true;
- ti->set_metadata(0,d);
+ d["name"] = dirs.front()->get();
+ d["dir"] = true;
+ ti->set_metadata(0, d);
}
dirs.pop_front();
-
}
dirs.clear();
List<String> patterns;
// build filter
- if (filter->get_selected()==filter->get_item_count()-1) {
+ if (filter->get_selected() == filter->get_item_count() - 1) {
// match all
- } else if (filters.size()>1 && filter->get_selected()==0) {
+ } else if (filters.size() > 1 && filter->get_selected() == 0) {
// match all filters
- for (int i=0;i<filters.size();i++) {
+ for (int i = 0; i < filters.size(); i++) {
- String f=filters[i].get_slice(";",0);
- for (int j=0;j<f.get_slice_count(",");j++) {
+ String f = filters[i].get_slice(";", 0);
+ for (int j = 0; j < f.get_slice_count(","); j++) {
- patterns.push_back(f.get_slice(",",j).strip_edges());
+ patterns.push_back(f.get_slice(",", j).strip_edges());
}
}
} else {
- int idx=filter->get_selected();
- if (filters.size()>1)
+ int idx = filter->get_selected();
+ if (filters.size() > 1)
idx--;
- if (idx>=0 && idx<filters.size()) {
+ if (idx >= 0 && idx < filters.size()) {
- String f=filters[idx].get_slice(";",0);
- for (int j=0;j<f.get_slice_count(",");j++) {
+ String f = filters[idx].get_slice(";", 0);
+ for (int j = 0; j < f.get_slice_count(","); j++) {
- patterns.push_back(f.get_slice(",",j).strip_edges());
+ patterns.push_back(f.get_slice(",", j).strip_edges());
}
}
}
-
String base_dir = dir_access->get_current_dir();
+ while (!files.empty()) {
- while(!files.empty()) {
-
- bool match=patterns.empty();
+ bool match = patterns.empty();
String match_str;
- for(List<String>::Element *E=patterns.front();E;E=E->next()) {
+ for (List<String>::Element *E = patterns.front(); E; E = E->next()) {
if (files.front()->get().matchn(E->get())) {
- match_str=E->get();
- match=true;
+ match_str = E->get();
+ match = true;
break;
}
}
if (match) {
- TreeItem *ti=tree->create_item(root);
- ti->set_text(0,files.front()->get());
+ TreeItem *ti = tree->create_item(root);
+ ti->set_text(0, files.front()->get());
if (get_icon_func) {
Ref<Texture> icon = get_icon_func(base_dir.plus_file(files.front()->get()));
- ti->set_icon(0,icon);
+ ti->set_icon(0, icon);
}
- if (mode==MODE_OPEN_DIR) {
- ti->set_custom_color(0,get_color("files_disabled"));
- ti->set_selectable(0,false);
+ if (mode == MODE_OPEN_DIR) {
+ ti->set_custom_color(0, get_color("files_disabled"));
+ ti->set_selectable(0, false);
}
Dictionary d;
- d["name"]=files.front()->get();
- d["dir"]=false;
- ti->set_metadata(0,d);
+ d["name"] = files.front()->get();
+ d["dir"] = false;
+ ti->set_metadata(0, d);
- if (file->get_text()==files.front()->get() || match_str==files.front()->get())
+ if (file->get_text() == files.front()->get() || match_str == files.front()->get())
ti->select(0);
}
files.pop_front();
}
- if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected()==NULL)
+ if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected() == NULL)
tree->get_root()->get_children()->select(0);
files.clear();
-
}
void FileDialog::_filter_selected(int) {
@@ -454,35 +438,34 @@ void FileDialog::update_filters() {
filter->clear();
- if (filters.size()>1) {
+ if (filters.size() > 1) {
String all_filters;
- const int max_filters=5;
+ const int max_filters = 5;
- for(int i=0;i<MIN( max_filters, filters.size()) ;i++) {
- String flt=filters[i].get_slice(";",0);
- if (i>0)
- all_filters+=",";
- all_filters+=flt;
+ for (int i = 0; i < MIN(max_filters, filters.size()); i++) {
+ String flt = filters[i].get_slice(";", 0);
+ if (i > 0)
+ all_filters += ",";
+ all_filters += flt;
}
- if (max_filters<filters.size())
- all_filters+=", ...";
+ if (max_filters < filters.size())
+ all_filters += ", ...";
- filter->add_item(RTR("All Recognized")+" ( "+all_filters+" )");
+ filter->add_item(RTR("All Recognized") + " ( " + all_filters + " )");
}
- for(int i=0;i<filters.size();i++) {
+ for (int i = 0; i < filters.size(); i++) {
- String flt=filters[i].get_slice(";",0).strip_edges();
- String desc=filters[i].get_slice(";",1).strip_edges();
+ String flt = filters[i].get_slice(";", 0).strip_edges();
+ String desc = filters[i].get_slice(";", 1).strip_edges();
if (desc.length())
- filter->add_item(String(XL_MESSAGE(desc))+" ( "+flt+" )");
+ filter->add_item(String(XL_MESSAGE(desc)) + " ( " + flt + " )");
else
- filter->add_item("( "+flt+" )");
+ filter->add_item("( " + flt + " )");
}
filter->add_item(RTR("All Files (*)"));
-
}
void FileDialog::clear_filters() {
@@ -491,21 +474,20 @@ void FileDialog::clear_filters() {
update_filters();
invalidate();
}
-void FileDialog::add_filter(const String& p_filter) {
+void FileDialog::add_filter(const String &p_filter) {
filters.push_back(p_filter);
update_filters();
invalidate();
-
}
-void FileDialog::set_filters(const Vector<String>& p_filters){
- filters=p_filters;
+void FileDialog::set_filters(const Vector<String> &p_filters) {
+ filters = p_filters;
update_filters();
invalidate();
}
-Vector<String> FileDialog::get_filters() const{
+Vector<String> FileDialog::get_filters() const {
return filters;
}
@@ -521,61 +503,76 @@ String FileDialog::get_current_path() const {
return dir->get_text().plus_file(file->get_text());
}
-void FileDialog::set_current_dir(const String& p_dir) {
+void FileDialog::set_current_dir(const String &p_dir) {
dir_access->change_dir(p_dir);
update_dir();
invalidate();
-
}
-void FileDialog::set_current_file(const String& p_file) {
+void FileDialog::set_current_file(const String &p_file) {
file->set_text(p_file);
update_dir();
invalidate();
int lp = p_file.find_last(".");
- if (lp!=-1) {
- file->select(0,lp);
+ if (lp != -1) {
+ file->select(0, lp);
file->grab_focus();
}
-
-
}
-void FileDialog::set_current_path(const String& p_path) {
+void FileDialog::set_current_path(const String &p_path) {
if (!p_path.size())
return;
- int pos=MAX( p_path.find_last("/"), p_path.find_last("\\") );
- if (pos==-1) {
+ int pos = MAX(p_path.find_last("/"), p_path.find_last("\\"));
+ if (pos == -1) {
set_current_file(p_path);
} else {
- String dir=p_path.substr(0,pos);
- String file=p_path.substr(pos+1,p_path.length());
+ String dir = p_path.substr(0, pos);
+ String file = p_path.substr(pos + 1, p_path.length());
set_current_dir(dir);
set_current_file(file);
}
}
-
void FileDialog::set_mode(Mode p_mode) {
- mode=p_mode;
- switch(mode) {
+ mode = p_mode;
+ switch (mode) {
- case MODE_OPEN_FILE: get_ok()->set_text(RTR("Open")); set_title(RTR("Open a File")); makedir->hide(); break;
- case MODE_OPEN_FILES: get_ok()->set_text(RTR("Open")); set_title(RTR("Open File(s)")); makedir->hide(); break;
- case MODE_OPEN_DIR: get_ok()->set_text(RTR("Open")); set_title(RTR("Open a Directory")); makedir->show(); break;
- case MODE_OPEN_ANY: get_ok()->set_text(RTR("Open")); set_title(RTR("Open a File or Directory")); makedir->show(); break;
- case MODE_SAVE_FILE: get_ok()->set_text(RTR("Save")); set_title(RTR("Save a File")); makedir->show(); break;
+ case MODE_OPEN_FILE:
+ get_ok()->set_text(RTR("Open"));
+ set_title(RTR("Open a File"));
+ makedir->hide();
+ break;
+ case MODE_OPEN_FILES:
+ get_ok()->set_text(RTR("Open"));
+ set_title(RTR("Open File(s)"));
+ makedir->hide();
+ break;
+ case MODE_OPEN_DIR:
+ get_ok()->set_text(RTR("Open"));
+ set_title(RTR("Open a Directory"));
+ makedir->show();
+ break;
+ case MODE_OPEN_ANY:
+ get_ok()->set_text(RTR("Open"));
+ set_title(RTR("Open a File or Directory"));
+ makedir->show();
+ break;
+ case MODE_SAVE_FILE:
+ get_ok()->set_text(RTR("Save"));
+ set_title(RTR("Save a File"));
+ makedir->show();
+ break;
}
- if (mode==MODE_OPEN_FILES) {
+ if (mode == MODE_OPEN_FILES) {
tree->set_select_mode(Tree::SELECT_MULTI);
} else {
tree->set_select_mode(Tree::SELECT_SINGLE);
-
}
}
@@ -586,11 +583,11 @@ FileDialog::Mode FileDialog::get_mode() const {
void FileDialog::set_access(Access p_access) {
- ERR_FAIL_INDEX(p_access,3);
- if (access==p_access)
+ ERR_FAIL_INDEX(p_access, 3);
+ if (access == p_access)
return;
- memdelete( dir_access );
- switch(p_access) {
+ memdelete(dir_access);
+ switch (p_access) {
case ACCESS_FILESYSTEM: {
dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
@@ -604,7 +601,7 @@ void FileDialog::set_access(Access p_access) {
dir_access = DirAccess::create(DirAccess::ACCESS_USERDATA);
} break;
}
- access=p_access;
+ access = p_access;
_update_drives();
invalidate();
update_filters();
@@ -615,38 +612,35 @@ void FileDialog::invalidate() {
if (is_visible()) {
update_file_list();
- invalidated=false;
+ invalidated = false;
} else {
- invalidated=true;
+ invalidated = true;
}
-
}
-FileDialog::Access FileDialog::get_access() const{
+FileDialog::Access FileDialog::get_access() const {
return access;
}
void FileDialog::_make_dir_confirm() {
- Error err = dir_access->make_dir( makedirname->get_text() );
- if (err==OK) {
+ Error err = dir_access->make_dir(makedirname->get_text());
+ if (err == OK) {
dir_access->change_dir(makedirname->get_text());
invalidate();
update_filters();
update_dir();
} else {
- mkdirerr->popup_centered_minsize(Size2(250,50));
+ mkdirerr->popup_centered_minsize(Size2(250, 50));
}
makedirname->set_text(""); // reset label
}
-
void FileDialog::_make_dir() {
- makedialog->popup_centered_minsize(Size2(250,80));
+ makedialog->popup_centered_minsize(Size2(250, 80));
makedirname->grab_focus();
-
}
void FileDialog::_select_drive(int p_idx) {
@@ -656,95 +650,89 @@ void FileDialog::_select_drive(int p_idx) {
file->set_text("");
invalidate();
update_dir();
-
}
void FileDialog::_update_drives() {
-
int dc = dir_access->get_drive_count();
- if (dc==0 || access!=ACCESS_FILESYSTEM) {
+ if (dc == 0 || access != ACCESS_FILESYSTEM) {
drives->hide();
} else {
drives->clear();
drives->show();
- for(int i=0;i<dir_access->get_drive_count();i++) {
+ for (int i = 0; i < dir_access->get_drive_count(); i++) {
String d = dir_access->get_drive(i);
drives->add_item(dir_access->get_drive(i));
}
drives->select(dir_access->get_current_drive());
-
}
}
-bool FileDialog::default_show_hidden_files=false;
-
+bool FileDialog::default_show_hidden_files = false;
void FileDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_unhandled_input"),&FileDialog::_unhandled_input);
-
- ObjectTypeDB::bind_method(_MD("_tree_selected"),&FileDialog::_tree_selected);
- ObjectTypeDB::bind_method(_MD("_tree_db_selected"),&FileDialog::_tree_dc_selected);
- ObjectTypeDB::bind_method(_MD("_dir_entered"),&FileDialog::_dir_entered);
- ObjectTypeDB::bind_method(_MD("_file_entered"),&FileDialog::_file_entered);
- ObjectTypeDB::bind_method(_MD("_action_pressed"),&FileDialog::_action_pressed);
- ObjectTypeDB::bind_method(_MD("_cancel_pressed"),&FileDialog::_cancel_pressed);
- ObjectTypeDB::bind_method(_MD("_filter_selected"),&FileDialog::_filter_selected);
- ObjectTypeDB::bind_method(_MD("_save_confirm_pressed"),&FileDialog::_save_confirm_pressed);
+ ObjectTypeDB::bind_method(_MD("_unhandled_input"), &FileDialog::_unhandled_input);
- ObjectTypeDB::bind_method(_MD("clear_filters"),&FileDialog::clear_filters);
- ObjectTypeDB::bind_method(_MD("add_filter","filter"),&FileDialog::add_filter);
- ObjectTypeDB::bind_method(_MD("set_filters","filters"),&FileDialog::set_filters);
- ObjectTypeDB::bind_method(_MD("get_filters"),&FileDialog::get_filters);
- ObjectTypeDB::bind_method(_MD("get_current_dir"),&FileDialog::get_current_dir);
- ObjectTypeDB::bind_method(_MD("get_current_file"),&FileDialog::get_current_file);
- ObjectTypeDB::bind_method(_MD("get_current_path"),&FileDialog::get_current_path);
- ObjectTypeDB::bind_method(_MD("set_current_dir","dir"),&FileDialog::set_current_dir);
- ObjectTypeDB::bind_method(_MD("set_current_file","file"),&FileDialog::set_current_file);
- ObjectTypeDB::bind_method(_MD("set_current_path","path"),&FileDialog::set_current_path);
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&FileDialog::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&FileDialog::get_mode);
- ObjectTypeDB::bind_method(_MD("get_vbox:VBoxContainer"),&FileDialog::get_vbox);
- ObjectTypeDB::bind_method(_MD("set_access","access"),&FileDialog::set_access);
- ObjectTypeDB::bind_method(_MD("get_access"),&FileDialog::get_access);
- ObjectTypeDB::bind_method(_MD("set_show_hidden_files","show"),&FileDialog::set_show_hidden_files);
- ObjectTypeDB::bind_method(_MD("is_showing_hidden_files"),&FileDialog::is_showing_hidden_files);
- ObjectTypeDB::bind_method(_MD("_select_drive"),&FileDialog::_select_drive);
- ObjectTypeDB::bind_method(_MD("_make_dir"),&FileDialog::_make_dir);
- ObjectTypeDB::bind_method(_MD("_make_dir_confirm"),&FileDialog::_make_dir_confirm);
- ObjectTypeDB::bind_method(_MD("_update_file_list"),&FileDialog::update_file_list);
- ObjectTypeDB::bind_method(_MD("_update_dir"),&FileDialog::update_dir);
+ ObjectTypeDB::bind_method(_MD("_tree_selected"), &FileDialog::_tree_selected);
+ ObjectTypeDB::bind_method(_MD("_tree_db_selected"), &FileDialog::_tree_dc_selected);
+ ObjectTypeDB::bind_method(_MD("_dir_entered"), &FileDialog::_dir_entered);
+ ObjectTypeDB::bind_method(_MD("_file_entered"), &FileDialog::_file_entered);
+ ObjectTypeDB::bind_method(_MD("_action_pressed"), &FileDialog::_action_pressed);
+ ObjectTypeDB::bind_method(_MD("_cancel_pressed"), &FileDialog::_cancel_pressed);
+ ObjectTypeDB::bind_method(_MD("_filter_selected"), &FileDialog::_filter_selected);
+ ObjectTypeDB::bind_method(_MD("_save_confirm_pressed"), &FileDialog::_save_confirm_pressed);
- ObjectTypeDB::bind_method(_MD("invalidate"),&FileDialog::invalidate);
+ ObjectTypeDB::bind_method(_MD("clear_filters"), &FileDialog::clear_filters);
+ ObjectTypeDB::bind_method(_MD("add_filter", "filter"), &FileDialog::add_filter);
+ ObjectTypeDB::bind_method(_MD("set_filters", "filters"), &FileDialog::set_filters);
+ ObjectTypeDB::bind_method(_MD("get_filters"), &FileDialog::get_filters);
+ ObjectTypeDB::bind_method(_MD("get_current_dir"), &FileDialog::get_current_dir);
+ ObjectTypeDB::bind_method(_MD("get_current_file"), &FileDialog::get_current_file);
+ ObjectTypeDB::bind_method(_MD("get_current_path"), &FileDialog::get_current_path);
+ ObjectTypeDB::bind_method(_MD("set_current_dir", "dir"), &FileDialog::set_current_dir);
+ ObjectTypeDB::bind_method(_MD("set_current_file", "file"), &FileDialog::set_current_file);
+ ObjectTypeDB::bind_method(_MD("set_current_path", "path"), &FileDialog::set_current_path);
+ ObjectTypeDB::bind_method(_MD("set_mode", "mode"), &FileDialog::set_mode);
+ ObjectTypeDB::bind_method(_MD("get_mode"), &FileDialog::get_mode);
+ ObjectTypeDB::bind_method(_MD("get_vbox:VBoxContainer"), &FileDialog::get_vbox);
+ ObjectTypeDB::bind_method(_MD("set_access", "access"), &FileDialog::set_access);
+ ObjectTypeDB::bind_method(_MD("get_access"), &FileDialog::get_access);
+ ObjectTypeDB::bind_method(_MD("set_show_hidden_files", "show"), &FileDialog::set_show_hidden_files);
+ ObjectTypeDB::bind_method(_MD("is_showing_hidden_files"), &FileDialog::is_showing_hidden_files);
+ ObjectTypeDB::bind_method(_MD("_select_drive"), &FileDialog::_select_drive);
+ ObjectTypeDB::bind_method(_MD("_make_dir"), &FileDialog::_make_dir);
+ ObjectTypeDB::bind_method(_MD("_make_dir_confirm"), &FileDialog::_make_dir_confirm);
+ ObjectTypeDB::bind_method(_MD("_update_file_list"), &FileDialog::update_file_list);
+ ObjectTypeDB::bind_method(_MD("_update_dir"), &FileDialog::update_dir);
- ADD_SIGNAL(MethodInfo("file_selected",PropertyInfo( Variant::STRING,"path")));
- ADD_SIGNAL(MethodInfo("files_selected",PropertyInfo( Variant::STRING_ARRAY,"paths")));
- ADD_SIGNAL(MethodInfo("dir_selected",PropertyInfo( Variant::STRING,"dir")));
+ ObjectTypeDB::bind_method(_MD("invalidate"), &FileDialog::invalidate);
- BIND_CONSTANT( MODE_OPEN_FILE );
- BIND_CONSTANT( MODE_OPEN_FILES );
- BIND_CONSTANT( MODE_OPEN_DIR );
- BIND_CONSTANT( MODE_OPEN_ANY );
+ ADD_SIGNAL(MethodInfo("file_selected", PropertyInfo(Variant::STRING, "path")));
+ ADD_SIGNAL(MethodInfo("files_selected", PropertyInfo(Variant::STRING_ARRAY, "paths")));
+ ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir")));
- BIND_CONSTANT( MODE_SAVE_FILE );
+ BIND_CONSTANT(MODE_OPEN_FILE);
+ BIND_CONSTANT(MODE_OPEN_FILES);
+ BIND_CONSTANT(MODE_OPEN_DIR);
+ BIND_CONSTANT(MODE_OPEN_ANY);
- BIND_CONSTANT( ACCESS_RESOURCES );
- BIND_CONSTANT( ACCESS_USERDATA );
- BIND_CONSTANT( ACCESS_FILESYSTEM );
+ BIND_CONSTANT(MODE_SAVE_FILE);
- ADD_PROPERTY( PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"),_SCS("set_mode"),_SCS("get_mode") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"),_SCS("set_access"),_SCS("get_access") );
- ADD_PROPERTY( PropertyInfo(Variant::STRING_ARRAY, "filters"),_SCS("set_filters"),_SCS("get_filters") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "show_hidden_files"),_SCS("set_show_hidden_files"),_SCS("is_showing_hidden_files") );
+ BIND_CONSTANT(ACCESS_RESOURCES);
+ BIND_CONSTANT(ACCESS_USERDATA);
+ BIND_CONSTANT(ACCESS_FILESYSTEM);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"), _SCS("set_mode"), _SCS("get_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"), _SCS("set_access"), _SCS("get_access"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING_ARRAY, "filters"), _SCS("set_filters"), _SCS("get_filters"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_hidden_files"), _SCS("set_show_hidden_files"), _SCS("is_showing_hidden_files"));
}
-
void FileDialog::set_show_hidden_files(bool p_show) {
- show_hidden_files=p_show;
+ show_hidden_files = p_show;
invalidate();
}
@@ -753,109 +741,101 @@ bool FileDialog::is_showing_hidden_files() const {
}
void FileDialog::set_default_show_hidden_files(bool p_show) {
- default_show_hidden_files=p_show;
+ default_show_hidden_files = p_show;
}
FileDialog::FileDialog() {
- show_hidden_files=default_show_hidden_files;
+ show_hidden_files = default_show_hidden_files;
- VBoxContainer *vbc = memnew( VBoxContainer );
+ VBoxContainer *vbc = memnew(VBoxContainer);
add_child(vbc);
set_child_rect(vbc);
- mode=MODE_SAVE_FILE;
+ mode = MODE_SAVE_FILE;
set_title(RTR("Save a File"));
dir = memnew(LineEdit);
- HBoxContainer *pathhb = memnew( HBoxContainer );
+ HBoxContainer *pathhb = memnew(HBoxContainer);
pathhb->add_child(dir);
dir->set_h_size_flags(SIZE_EXPAND_FILL);
- refresh = memnew( ToolButton );
- refresh->connect("pressed",this,"_update_file_list");
+ refresh = memnew(ToolButton);
+ refresh->connect("pressed", this, "_update_file_list");
pathhb->add_child(refresh);
- drives = memnew( OptionButton );
+ drives = memnew(OptionButton);
pathhb->add_child(drives);
- drives->connect("item_selected",this,"_select_drive");
+ drives->connect("item_selected", this, "_select_drive");
- makedir = memnew( Button );
+ makedir = memnew(Button);
makedir->set_text(RTR("Create Folder"));
- makedir->connect("pressed",this,"_make_dir");
+ makedir->connect("pressed", this, "_make_dir");
pathhb->add_child(makedir);
- vbc->add_margin_child(RTR("Path:"),pathhb);
+ vbc->add_margin_child(RTR("Path:"), pathhb);
tree = memnew(Tree);
tree->set_hide_root(true);
- vbc->add_margin_child(RTR("Directories & Files:"),tree,true);
+ vbc->add_margin_child(RTR("Directories & Files:"), tree, true);
file = memnew(LineEdit);
//add_child(file);
- vbc->add_margin_child(RTR("File:"),file);
+ vbc->add_margin_child(RTR("File:"), file);
-
- filter = memnew( OptionButton );
+ filter = memnew(OptionButton);
//add_child(filter);
- vbc->add_margin_child(RTR("Filter:"),filter);
- filter->set_clip_text(true);//too many extensions overflow it
+ vbc->add_margin_child(RTR("Filter:"), filter);
+ filter->set_clip_text(true); //too many extensions overflow it
dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
- access=ACCESS_RESOURCES;
+ access = ACCESS_RESOURCES;
_update_drives();
-
- connect("confirmed", this,"_action_pressed");
+ connect("confirmed", this, "_action_pressed");
//cancel->connect("pressed", this,"_cancel_pressed");
- tree->connect("cell_selected", this,"_tree_selected",varray(),CONNECT_DEFERRED);
- tree->connect("item_activated", this,"_tree_db_selected",varray());
- dir->connect("text_entered", this,"_dir_entered");
- file->connect("text_entered", this,"_file_entered");
- filter->connect("item_selected", this,"_filter_selected");
-
+ tree->connect("cell_selected", this, "_tree_selected", varray(), CONNECT_DEFERRED);
+ tree->connect("item_activated", this, "_tree_db_selected", varray());
+ dir->connect("text_entered", this, "_dir_entered");
+ file->connect("text_entered", this, "_file_entered");
+ filter->connect("item_selected", this, "_filter_selected");
- confirm_save = memnew( ConfirmationDialog );
+ confirm_save = memnew(ConfirmationDialog);
confirm_save->set_as_toplevel(true);
add_child(confirm_save);
+ confirm_save->connect("confirmed", this, "_save_confirm_pressed");
- confirm_save->connect("confirmed", this,"_save_confirm_pressed");
-
- makedialog = memnew( ConfirmationDialog );
+ makedialog = memnew(ConfirmationDialog);
makedialog->set_title(RTR("Create Folder"));
- VBoxContainer *makevb= memnew( VBoxContainer );
+ VBoxContainer *makevb = memnew(VBoxContainer);
makedialog->add_child(makevb);
makedialog->set_child_rect(makevb);
- makedirname = memnew( LineEdit );
- makevb->add_margin_child(RTR("Name:"),makedirname);
+ makedirname = memnew(LineEdit);
+ makevb->add_margin_child(RTR("Name:"), makedirname);
add_child(makedialog);
makedialog->register_text_enter(makedirname);
- makedialog->connect("confirmed",this,"_make_dir_confirm");
- mkdirerr = memnew( AcceptDialog );
+ makedialog->connect("confirmed", this, "_make_dir_confirm");
+ mkdirerr = memnew(AcceptDialog);
mkdirerr->set_text(RTR("Could not create folder."));
add_child(mkdirerr);
- exterr = memnew( AcceptDialog );
+ exterr = memnew(AcceptDialog);
exterr->set_text(RTR("Must use a valid extension."));
add_child(exterr);
-
//update_file_list();
update_filters();
update_dir();
set_hide_on_ok(false);
- vbox=vbc;
-
+ vbox = vbc;
- invalidated=true;
+ invalidated = true;
if (register_func)
register_func(this);
-
}
-
FileDialog::~FileDialog() {
if (unregister_func)
@@ -863,21 +843,19 @@ FileDialog::~FileDialog() {
memdelete(dir_access);
}
-
void LineEditFileChooser::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_browse"),&LineEditFileChooser::_browse);
- ObjectTypeDB::bind_method(_MD("_chosen"),&LineEditFileChooser::_chosen);
- ObjectTypeDB::bind_method(_MD("get_button:Button"),&LineEditFileChooser::get_button);
- ObjectTypeDB::bind_method(_MD("get_line_edit:LineEdit"),&LineEditFileChooser::get_line_edit);
- ObjectTypeDB::bind_method(_MD("get_file_dialog:FileDialog"),&LineEditFileChooser::get_file_dialog);
-
+ ObjectTypeDB::bind_method(_MD("_browse"), &LineEditFileChooser::_browse);
+ ObjectTypeDB::bind_method(_MD("_chosen"), &LineEditFileChooser::_chosen);
+ ObjectTypeDB::bind_method(_MD("get_button:Button"), &LineEditFileChooser::get_button);
+ ObjectTypeDB::bind_method(_MD("get_line_edit:LineEdit"), &LineEditFileChooser::get_line_edit);
+ ObjectTypeDB::bind_method(_MD("get_file_dialog:FileDialog"), &LineEditFileChooser::get_file_dialog);
}
-void LineEditFileChooser::_chosen(const String& p_text){
+void LineEditFileChooser::_chosen(const String &p_text) {
line_edit->set_text(p_text);
- line_edit->emit_signal("text_entered",p_text);
+ line_edit->emit_signal("text_entered", p_text);
}
void LineEditFileChooser::_browse() {
@@ -887,18 +865,16 @@ void LineEditFileChooser::_browse() {
LineEditFileChooser::LineEditFileChooser() {
- line_edit = memnew( LineEdit );
+ line_edit = memnew(LineEdit);
add_child(line_edit);
line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
- button = memnew( Button );
+ button = memnew(Button);
button->set_text(" .. ");
add_child(button);
- button->connect("pressed",this,"_browse");
- dialog = memnew( FileDialog);
+ button->connect("pressed", this, "_browse");
+ dialog = memnew(FileDialog);
add_child(dialog);
- dialog->connect("file_selected",this,"_chosen");
- dialog->connect("dir_selected",this,"_chosen");
- dialog->connect("files_selected",this,"_chosen");
-
+ dialog->connect("file_selected", this, "_chosen");
+ dialog->connect("dir_selected", this, "_chosen");
+ dialog->connect("files_selected", this, "_chosen");
}
-
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 2f57771a8..bac626a0b 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -29,30 +29,28 @@
#ifndef FILE_DIALOG_H
#define FILE_DIALOG_H
+#include "box_container.h"
+#include "os/dir_access.h"
+#include "scene/gui/dialogs.h"
#include "scene/gui/dialogs.h"
-#include "scene/gui/tree.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/option_button.h"
-#include "scene/gui/dialogs.h"
#include "scene/gui/tool_button.h"
-#include "os/dir_access.h"
-#include "box_container.h"
+#include "scene/gui/tree.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class FileDialog : public ConfirmationDialog {
- OBJ_TYPE( FileDialog, ConfirmationDialog );
+ OBJ_TYPE(FileDialog, ConfirmationDialog);
public:
-
enum Access {
ACCESS_RESOURCES,
ACCESS_USERDATA,
ACCESS_FILESYSTEM
};
-
enum Mode {
MODE_OPEN_FILE,
MODE_OPEN_FILES,
@@ -61,8 +59,8 @@ public:
MODE_SAVE_FILE
};
- typedef Ref<Texture> (*GetIconFunc)(const String&);
- typedef void (*RegisterFunc)(FileDialog*);
+ typedef Ref<Texture> (*GetIconFunc)(const String &);
+ typedef void (*RegisterFunc)(FileDialog *);
static GetIconFunc get_icon_func;
static GetIconFunc get_large_icon_func;
@@ -70,7 +68,6 @@ public:
static RegisterFunc unregister_func;
private:
-
ConfirmationDialog *makedialog;
LineEdit *makedirname;
@@ -93,7 +90,6 @@ private:
Vector<String> filters;
-
static bool default_show_hidden_files;
bool show_hidden_files;
@@ -108,7 +104,7 @@ private:
void _select_drive(int p_idx);
void _tree_dc_selected();
void _dir_entered(String p_dir);
- void _file_entered(const String& p_file);
+ void _file_entered(const String &p_file);
void _action_pressed();
void _save_confirm_pressed();
void _cancel_pressed();
@@ -118,20 +114,18 @@ private:
void _update_drives();
- void _unhandled_input(const InputEvent& p_event);
+ void _unhandled_input(const InputEvent &p_event);
virtual void _post_popup();
protected:
-
void _notification(int p_what);
static void _bind_methods();
//bind helpers
public:
-
void clear_filters();
- void add_filter(const String& p_filter);
- void set_filters(const Vector<String>& p_filters);
+ void add_filter(const String &p_filter);
+ void set_filters(const Vector<String> &p_filters);
Vector<String> get_filters() const;
void set_enable_multiple_selection(bool p_enable);
@@ -140,9 +134,9 @@ public:
String get_current_dir() const;
String get_current_file() const;
String get_current_path() const;
- void set_current_dir(const String& p_dir);
- void set_current_file(const String& p_file);
- void set_current_path(const String& p_path);
+ void set_current_dir(const String &p_dir);
+ void set_current_file(const String &p_file);
+ void set_current_path(const String &p_path);
void set_mode(Mode p_mode);
Mode get_mode() const;
@@ -162,22 +156,22 @@ public:
FileDialog();
~FileDialog();
-
};
class LineEditFileChooser : public HBoxContainer {
- OBJ_TYPE( LineEditFileChooser, HBoxContainer );
+ OBJ_TYPE(LineEditFileChooser, HBoxContainer);
Button *button;
LineEdit *line_edit;
FileDialog *dialog;
- void _chosen(const String& p_text);
+ void _chosen(const String &p_text);
void _browse();
+
protected:
static void _bind_methods();
-public:
+public:
Button *get_button() { return button; }
LineEdit *get_line_edit() { return line_edit; }
FileDialog *get_file_dialog() { return dialog; }
@@ -185,7 +179,7 @@ public:
LineEditFileChooser();
};
-VARIANT_ENUM_CAST( FileDialog::Mode );
-VARIANT_ENUM_CAST( FileDialog::Access );
+VARIANT_ENUM_CAST(FileDialog::Mode);
+VARIANT_ENUM_CAST(FileDialog::Access);
#endif
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index b0a19ac4a..bcb8d35e7 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -31,57 +31,52 @@
#include "os/keyboard.h"
#include "scene/gui/box_container.h"
-
#define ZOOM_SCALE 1.2
-#define MIN_ZOOM (((1/ZOOM_SCALE)/ZOOM_SCALE)/ZOOM_SCALE)
-#define MAX_ZOOM (1*ZOOM_SCALE*ZOOM_SCALE*ZOOM_SCALE)
-
+#define MIN_ZOOM (((1 / ZOOM_SCALE) / ZOOM_SCALE) / ZOOM_SCALE)
+#define MAX_ZOOM (1 * ZOOM_SCALE * ZOOM_SCALE * ZOOM_SCALE)
-bool GraphEditFilter::has_point(const Point2& p_point) const {
+bool GraphEditFilter::has_point(const Point2 &p_point) const {
return ge->_filter_input(p_point);
}
-
GraphEditFilter::GraphEditFilter(GraphEdit *p_edit) {
- ge=p_edit;
+ ge = p_edit;
}
+Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
-Error GraphEdit::connect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port) {
-
- if (is_node_connected(p_from,p_from_port,p_to,p_to_port))
+ if (is_node_connected(p_from, p_from_port, p_to, p_to_port))
return OK;
Connection c;
- c.from=p_from;
- c.from_port=p_from_port;
- c.to=p_to;
- c.to_port=p_to_port;
+ c.from = p_from;
+ c.from_port = p_from_port;
+ c.to = p_to;
+ c.to_port = p_to_port;
connections.push_back(c);
top_layer->update();
return OK;
}
-bool GraphEdit::is_node_connected(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port) {
+bool GraphEdit::is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
- for(List<Connection>::Element *E=connections.front();E;E=E->next()) {
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
- if (E->get().from==p_from && E->get().from_port==p_from_port && E->get().to==p_to && E->get().to_port==p_to_port)
+ if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port)
return true;
}
return false;
-
}
-void GraphEdit::disconnect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port){
+void GraphEdit::disconnect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
- for(List<Connection>::Element *E=connections.front();E;E=E->next()) {
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
- if (E->get().from==p_from && E->get().from_port==p_from_port && E->get().to==p_to && E->get().to_port==p_to_port) {
+ if (E->get().from == p_from && E->get().from_port == p_from_port && E->get().to == p_to && E->get().to_port == p_to_port) {
connections.erase(E);
top_layer->update();
@@ -97,12 +92,12 @@ bool GraphEdit::clips_input() const {
void GraphEdit::get_connection_list(List<Connection> *r_connections) const {
- *r_connections=connections;
+ *r_connections = connections;
}
-Vector2 GraphEdit::get_scroll_ofs() const{
+Vector2 GraphEdit::get_scroll_ofs() const {
- return Vector2(h_scroll->get_val(),v_scroll->get_val());
+ return Vector2(h_scroll->get_val(), v_scroll->get_val());
}
void GraphEdit::_scroll_moved(double) {
@@ -113,18 +108,17 @@ void GraphEdit::_scroll_moved(double) {
void GraphEdit::_update_scroll_offset() {
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn)
continue;
- Point2 pos=gn->get_offset()*zoom;
- pos-=Point2(h_scroll->get_val(),v_scroll->get_val());
+ Point2 pos = gn->get_offset() * zoom;
+ pos -= Point2(h_scroll->get_val(), v_scroll->get_val());
gn->set_pos(pos);
- gn->set_scale(Vector2(zoom,zoom));
+ gn->set_scale(Vector2(zoom, zoom));
}
-
}
void GraphEdit::_update_scroll() {
@@ -132,26 +126,25 @@ void GraphEdit::_update_scroll() {
if (updating)
return;
- updating=true;
+ updating = true;
Rect2 screen;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn)
continue;
Rect2 r;
- r.pos=gn->get_offset()*zoom;
- r.size=gn->get_size()*zoom;
+ r.pos = gn->get_offset() * zoom;
+ r.size = gn->get_size() * zoom;
screen = screen.merge(r);
}
- screen.pos-=get_size();
- screen.size+=get_size()*2.0;
-
+ screen.pos -= get_size();
+ screen.size += get_size() * 2.0;
h_scroll->set_min(screen.pos.x);
- h_scroll->set_max(screen.pos.x+screen.size.x);
+ h_scroll->set_max(screen.pos.x + screen.size.x);
h_scroll->set_page(get_size().x);
if (h_scroll->get_max() - h_scroll->get_min() <= h_scroll->get_page())
h_scroll->hide();
@@ -159,7 +152,7 @@ void GraphEdit::_update_scroll() {
h_scroll->show();
v_scroll->set_min(screen.pos.y);
- v_scroll->set_max(screen.pos.y+screen.size.y);
+ v_scroll->set_max(screen.pos.y + screen.size.y);
v_scroll->set_page(get_size().y);
if (v_scroll->get_max() - v_scroll->get_min() <= v_scroll->get_page())
@@ -168,23 +161,20 @@ void GraphEdit::_update_scroll() {
v_scroll->show();
_update_scroll_offset();
- updating=false;
+ updating = false;
}
+void GraphEdit::_graph_node_raised(Node *p_gn) {
-void GraphEdit::_graph_node_raised(Node* p_gn) {
-
- GraphNode *gn=p_gn->cast_to<GraphNode>();
+ GraphNode *gn = p_gn->cast_to<GraphNode>();
ERR_FAIL_COND(!gn);
gn->raise();
top_layer->raise();
-
}
-
void GraphEdit::_graph_node_moved(Node *p_gn) {
- GraphNode *gn=p_gn->cast_to<GraphNode>();
+ GraphNode *gn = p_gn->cast_to<GraphNode>();
ERR_FAIL_COND(!gn);
top_layer->update();
}
@@ -194,9 +184,9 @@ void GraphEdit::add_child_notify(Node *p_child) {
top_layer->call_deferred("raise"); //top layer always on top!
GraphNode *gn = p_child->cast_to<GraphNode>();
if (gn) {
- gn->set_scale(Vector2(zoom,zoom));
- gn->connect("offset_changed",this,"_graph_node_moved",varray(gn));
- gn->connect("raise_request",this,"_graph_node_raised",varray(gn));
+ gn->set_scale(Vector2(zoom, zoom));
+ gn->connect("offset_changed", this, "_graph_node_moved", varray(gn));
+ gn->connect("raise_request", this, "_graph_node_raised", varray(gn));
_graph_node_moved(gn);
gn->set_stop_mouse(false);
}
@@ -207,202 +197,187 @@ void GraphEdit::remove_child_notify(Node *p_child) {
top_layer->call_deferred("raise"); //top layer always on top!
GraphNode *gn = p_child->cast_to<GraphNode>();
if (gn) {
- gn->disconnect("offset_changed",this,"_graph_node_moved");
- gn->disconnect("raise_request",this,"_graph_node_raised");
+ gn->disconnect("offset_changed", this, "_graph_node_moved");
+ gn->disconnect("raise_request", this, "_graph_node_raised");
}
}
void GraphEdit::_notification(int p_what) {
- if (p_what==NOTIFICATION_READY) {
+ if (p_what == NOTIFICATION_READY) {
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
- v_scroll->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,vmin.width);
- v_scroll->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,0);
- v_scroll->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,0);
- v_scroll->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,0);
-
- h_scroll->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,0);
- h_scroll->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,0);
- h_scroll->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,hmin.height);
- h_scroll->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,0);
+ v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, vmin.width);
+ v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
+ v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
-// zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
+ h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
+ h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, hmin.height);
+ h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
+ // zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
}
- if (p_what==NOTIFICATION_DRAW) {
- draw_style_box( get_stylebox("bg"),Rect2(Point2(),get_size()) );
- VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
-
+ if (p_what == NOTIFICATION_DRAW) {
+ draw_style_box(get_stylebox("bg"), Rect2(Point2(), get_size()));
+ VS::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
}
- if (p_what==NOTIFICATION_RESIZED) {
+ if (p_what == NOTIFICATION_RESIZED) {
_update_scroll();
top_layer->update();
}
}
-bool GraphEdit::_filter_input(const Point2& p_point) {
+bool GraphEdit::_filter_input(const Point2 &p_point) {
- Ref<Texture> port =get_icon("port","GraphNode");
+ Ref<Texture> port = get_icon("port", "GraphNode");
- float grab_r=port->get_width()*0.5;
- for(int i=get_child_count()-1;i>=0;i--) {
+ float grab_r = port->get_width() * 0.5;
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn)
continue;
- for(int j=0;j<gn->get_connection_output_count();j++) {
+ for (int j = 0; j < gn->get_connection_output_count(); j++) {
- Vector2 pos = gn->get_connection_output_pos(j)+gn->get_pos();
- if (pos.distance_to(p_point)<grab_r)
+ Vector2 pos = gn->get_connection_output_pos(j) + gn->get_pos();
+ if (pos.distance_to(p_point) < grab_r)
return true;
-
-
}
- for(int j=0;j<gn->get_connection_input_count();j++) {
+ for (int j = 0; j < gn->get_connection_input_count(); j++) {
- Vector2 pos = gn->get_connection_input_pos(j)+gn->get_pos();
- if (pos.distance_to(p_point)<grab_r)
+ Vector2 pos = gn->get_connection_input_pos(j) + gn->get_pos();
+ if (pos.distance_to(p_point) < grab_r)
return true;
-
-
}
-
}
return false;
}
-void GraphEdit::_top_layer_input(const InputEvent& p_ev) {
+void GraphEdit::_top_layer_input(const InputEvent &p_ev) {
- if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index==BUTTON_LEFT && p_ev.mouse_button.pressed) {
+ if (p_ev.type == InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index == BUTTON_LEFT && p_ev.mouse_button.pressed) {
- Ref<Texture> port =get_icon("port","GraphNode");
- Vector2 mpos(p_ev.mouse_button.x,p_ev.mouse_button.y);
- float grab_r=port->get_width()*0.5;
- for(int i=get_child_count()-1;i>=0;i--) {
+ Ref<Texture> port = get_icon("port", "GraphNode");
+ Vector2 mpos(p_ev.mouse_button.x, p_ev.mouse_button.y);
+ float grab_r = port->get_width() * 0.5;
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn)
continue;
- for(int j=0;j<gn->get_connection_output_count();j++) {
+ for (int j = 0; j < gn->get_connection_output_count(); j++) {
- Vector2 pos = gn->get_connection_output_pos(j)+gn->get_pos();
- if (pos.distance_to(mpos)<grab_r) {
+ Vector2 pos = gn->get_connection_output_pos(j) + gn->get_pos();
+ if (pos.distance_to(mpos) < grab_r) {
- connecting=true;
- connecting_from=gn->get_name();
- connecting_index=j;
- connecting_out=true;
- connecting_type=gn->get_connection_output_type(j);
- connecting_color=gn->get_connection_output_color(j);
- connecting_target=false;
- connecting_to=pos;
+ connecting = true;
+ connecting_from = gn->get_name();
+ connecting_index = j;
+ connecting_out = true;
+ connecting_type = gn->get_connection_output_type(j);
+ connecting_color = gn->get_connection_output_color(j);
+ connecting_target = false;
+ connecting_to = pos;
return;
}
-
-
}
- for(int j=0;j<gn->get_connection_input_count();j++) {
+ for (int j = 0; j < gn->get_connection_input_count(); j++) {
- Vector2 pos = gn->get_connection_input_pos(j)+gn->get_pos();
+ Vector2 pos = gn->get_connection_input_pos(j) + gn->get_pos();
- if (pos.distance_to(mpos)<grab_r) {
+ if (pos.distance_to(mpos) < grab_r) {
if (right_disconnects) {
//check disconnect
- for (List<Connection>::Element*E=connections.front();E;E=E->next()) {
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
- if (E->get().to==gn->get_name() && E->get().to_port==j) {
+ if (E->get().to == gn->get_name() && E->get().to_port == j) {
- Node*fr = get_node(String(E->get().from));
+ Node *fr = get_node(String(E->get().from));
if (fr && fr->cast_to<GraphNode>()) {
- connecting_from=E->get().from;
- connecting_index=E->get().from_port;
- connecting_out=true;
- connecting_type=fr->cast_to<GraphNode>()->get_connection_output_type(E->get().from_port);
- connecting_color=fr->cast_to<GraphNode>()->get_connection_output_color(E->get().from_port);
- connecting_target=false;
- connecting_to=pos;
+ connecting_from = E->get().from;
+ connecting_index = E->get().from_port;
+ connecting_out = true;
+ connecting_type = fr->cast_to<GraphNode>()->get_connection_output_type(E->get().from_port);
+ connecting_color = fr->cast_to<GraphNode>()->get_connection_output_color(E->get().from_port);
+ connecting_target = false;
+ connecting_to = pos;
- emit_signal("disconnection_request",E->get().from,E->get().from_port,E->get().to,E->get().to_port);
+ emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port);
fr = get_node(String(connecting_from)); //maybe it was erased
if (fr && fr->cast_to<GraphNode>()) {
- connecting=true;
+ connecting = true;
}
return;
}
-
}
}
}
-
- connecting=true;
- connecting_from=gn->get_name();
- connecting_index=j;
- connecting_out=false;
- connecting_type=gn->get_connection_input_type(j);
- connecting_color=gn->get_connection_input_color(j);
- connecting_target=false;
- connecting_to=pos;
+ connecting = true;
+ connecting_from = gn->get_name();
+ connecting_index = j;
+ connecting_out = false;
+ connecting_type = gn->get_connection_input_type(j);
+ connecting_color = gn->get_connection_input_color(j);
+ connecting_target = false;
+ connecting_to = pos;
return;
}
-
-
}
}
}
- if (p_ev.type==InputEvent::MOUSE_MOTION && connecting) {
+ if (p_ev.type == InputEvent::MOUSE_MOTION && connecting) {
- connecting_to=Vector2(p_ev.mouse_motion.x,p_ev.mouse_motion.y);
- connecting_target=false;
+ connecting_to = Vector2(p_ev.mouse_motion.x, p_ev.mouse_motion.y);
+ connecting_target = false;
top_layer->update();
- Ref<Texture> port =get_icon("port","GraphNode");
- Vector2 mpos(p_ev.mouse_button.x,p_ev.mouse_button.y);
- float grab_r=port->get_width()*0.5;
- for(int i=get_child_count()-1;i>=0;i--) {
+ Ref<Texture> port = get_icon("port", "GraphNode");
+ Vector2 mpos(p_ev.mouse_button.x, p_ev.mouse_button.y);
+ float grab_r = port->get_width() * 0.5;
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn)
continue;
if (!connecting_out) {
- for(int j=0;j<gn->get_connection_output_count();j++) {
+ for (int j = 0; j < gn->get_connection_output_count(); j++) {
- Vector2 pos = gn->get_connection_output_pos(j)+gn->get_pos();
- int type =gn->get_connection_output_type(j);
- if (type==connecting_type && pos.distance_to(mpos)<grab_r) {
+ Vector2 pos = gn->get_connection_output_pos(j) + gn->get_pos();
+ int type = gn->get_connection_output_type(j);
+ if (type == connecting_type && pos.distance_to(mpos) < grab_r) {
- connecting_target=true;
- connecting_to=pos;
- connecting_target_to=gn->get_name();
- connecting_target_index=j;
+ connecting_target = true;
+ connecting_to = pos;
+ connecting_target_to = gn->get_name();
+ connecting_target_index = j;
return;
}
-
-
}
} else {
- for(int j=0;j<gn->get_connection_input_count();j++) {
+ for (int j = 0; j < gn->get_connection_input_count(); j++) {
- Vector2 pos = gn->get_connection_input_pos(j)+gn->get_pos();
- int type =gn->get_connection_input_type(j);
- if (type==connecting_type && pos.distance_to(mpos)<grab_r) {
- connecting_target=true;
- connecting_to=pos;
- connecting_target_to=gn->get_name();
- connecting_target_index=j;
+ Vector2 pos = gn->get_connection_input_pos(j) + gn->get_pos();
+ int type = gn->get_connection_input_type(j);
+ if (type == connecting_type && pos.distance_to(mpos) < grab_r) {
+ connecting_target = true;
+ connecting_to = pos;
+ connecting_target_to = gn->get_name();
+ connecting_target_index = j;
return;
}
}
@@ -410,54 +385,51 @@ void GraphEdit::_top_layer_input(const InputEvent& p_ev) {
}
}
- if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index==BUTTON_LEFT && !p_ev.mouse_button.pressed) {
+ if (p_ev.type == InputEvent::MOUSE_BUTTON && p_ev.mouse_button.button_index == BUTTON_LEFT && !p_ev.mouse_button.pressed) {
if (connecting && connecting_target) {
String from = connecting_from;
int from_slot = connecting_index;
- String to =connecting_target_to;
+ String to = connecting_target_to;
int to_slot = connecting_target_index;
if (!connecting_out) {
- SWAP(from,to);
- SWAP(from_slot,to_slot);
+ SWAP(from, to);
+ SWAP(from_slot, to_slot);
}
- emit_signal("connection_request",from,from_slot,to,to_slot);
-
+ emit_signal("connection_request", from, from_slot, to, to_slot);
}
- connecting=false;
+ connecting = false;
top_layer->update();
-
}
-
}
-void GraphEdit::_draw_cos_line(const Vector2& p_from, const Vector2& p_to,const Color& p_color) {
+void GraphEdit::_draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color) {
static const int steps = 20;
Rect2 r;
- r.pos=p_from;
+ r.pos = p_from;
r.expand_to(p_to);
- Vector2 sign=Vector2((p_from.x < p_to.x) ? 1 : -1,(p_from.y < p_to.y) ? 1 : -1);
+ Vector2 sign = Vector2((p_from.x < p_to.x) ? 1 : -1, (p_from.y < p_to.y) ? 1 : -1);
bool flip = sign.x * sign.y < 0;
Vector2 prev;
- for(int i=0;i<=steps;i++) {
+ for (int i = 0; i <= steps; i++) {
- float d = i/float(steps);
- float c=-Math::cos(d*Math_PI) * 0.5+0.5;
+ float d = i / float(steps);
+ float c = -Math::cos(d * Math_PI) * 0.5 + 0.5;
if (flip)
- c=1.0-c;
- Vector2 p = r.pos+Vector2(d*r.size.width,c*r.size.height);
+ c = 1.0 - c;
+ Vector2 p = r.pos + Vector2(d * r.size.width, c * r.size.height);
- if (i>0) {
+ if (i > 0) {
- top_layer->draw_line(prev,p,p_color,2);
+ top_layer->draw_line(prev, p, p_color, 2);
}
- prev=p;
+ prev = p;
}
}
@@ -473,30 +445,30 @@ void GraphEdit::_top_layer_draw() {
ERR_FAIL_COND(!from);
Vector2 pos;
if (connecting_out)
- pos=from->get_connection_output_pos(connecting_index);
+ pos = from->get_connection_output_pos(connecting_index);
else
- pos=from->get_connection_input_pos(connecting_index);
- pos+=from->get_pos();
+ pos = from->get_connection_input_pos(connecting_index);
+ pos += from->get_pos();
Vector2 topos;
- topos=connecting_to;
+ topos = connecting_to;
- Color col=connecting_color;
+ Color col = connecting_color;
if (connecting_target) {
- col.r+=0.4;
- col.g+=0.4;
- col.b+=0.4;
+ col.r += 0.4;
+ col.g += 0.4;
+ col.b += 0.4;
}
- _draw_cos_line(pos,topos,col);
+ _draw_cos_line(pos, topos, col);
}
- List<List<Connection>::Element* > to_erase;
- for(List<Connection>::Element *E=connections.front();E;E=E->next()) {
+ List<List<Connection>::Element *> to_erase;
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
NodePath fromnp(E->get().from);
- Node * from = get_node(fromnp);
+ Node *from = get_node(fromnp);
if (!from) {
to_erase.push_back(E);
continue;
@@ -510,7 +482,7 @@ void GraphEdit::_top_layer_draw() {
}
NodePath tonp(E->get().to);
- Node * to = get_node(tonp);
+ Node *to = get_node(tonp);
if (!to) {
to_erase.push_back(E);
continue;
@@ -523,83 +495,81 @@ void GraphEdit::_top_layer_draw() {
continue;
}
- Vector2 frompos=gfrom->get_connection_output_pos(E->get().from_port)+gfrom->get_pos();
+ Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_pos();
Color color = gfrom->get_connection_output_color(E->get().from_port);
- Vector2 topos=gto->get_connection_input_pos(E->get().to_port)+gto->get_pos();
- _draw_cos_line(frompos,topos,color);
-
+ Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_pos();
+ _draw_cos_line(frompos, topos, color);
}
- while(to_erase.size()) {
+ while (to_erase.size()) {
connections.erase(to_erase.front()->get());
to_erase.pop_front();
}
if (box_selecting)
- top_layer->draw_rect(box_selecting_rect,Color(0.7,0.7,1.0,0.3));
+ top_layer->draw_rect(box_selecting_rect, Color(0.7, 0.7, 1.0, 0.3));
}
-void GraphEdit::_input_event(const InputEvent& p_ev) {
+void GraphEdit::_input_event(const InputEvent &p_ev) {
- if (p_ev.type==InputEvent::MOUSE_MOTION && (p_ev.mouse_motion.button_mask&BUTTON_MASK_MIDDLE || (p_ev.mouse_motion.button_mask&BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
- h_scroll->set_val( h_scroll->get_val() - p_ev.mouse_motion.relative_x );
- v_scroll->set_val( v_scroll->get_val() - p_ev.mouse_motion.relative_y );
+ if (p_ev.type == InputEvent::MOUSE_MOTION && (p_ev.mouse_motion.button_mask & BUTTON_MASK_MIDDLE || (p_ev.mouse_motion.button_mask & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
+ h_scroll->set_val(h_scroll->get_val() - p_ev.mouse_motion.relative_x);
+ v_scroll->set_val(v_scroll->get_val() - p_ev.mouse_motion.relative_y);
}
- if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {
+ if (p_ev.type == InputEvent::MOUSE_MOTION && dragging) {
- just_selected=true;
+ just_selected = true;
// TODO: Remove local mouse pos hack if/when InputEventMouseMotion is fixed to support floats
//drag_accum+=Vector2(p_ev.mouse_motion.relative_x,p_ev.mouse_motion.relative_y);
drag_accum = get_local_mouse_pos() - drag_origin;
- for(int i=get_child_count()-1;i>=0;i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ for (int i = get_child_count() - 1; i >= 0; i--) {
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (gn && gn->is_selected())
- gn->set_offset((gn->get_drag_from()*zoom+drag_accum)/zoom);
+ gn->set_offset((gn->get_drag_from() * zoom + drag_accum) / zoom);
}
}
- if (p_ev.type==InputEvent::MOUSE_MOTION && box_selecting) {
+ if (p_ev.type == InputEvent::MOUSE_MOTION && box_selecting) {
box_selecting_to = get_local_mouse_pos();
- box_selecting_rect = Rect2(MIN(box_selecting_from.x,box_selecting_to.x),
- MIN(box_selecting_from.y,box_selecting_to.y),
- ABS(box_selecting_from.x-box_selecting_to.x),
- ABS(box_selecting_from.y-box_selecting_to.y));
+ box_selecting_rect = Rect2(MIN(box_selecting_from.x, box_selecting_to.x),
+ MIN(box_selecting_from.y, box_selecting_to.y),
+ ABS(box_selecting_from.x - box_selecting_to.x),
+ ABS(box_selecting_from.y - box_selecting_to.y));
- for(int i=get_child_count()-1;i>=0;i--) {
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn)
continue;
Rect2 r = gn->get_rect();
- r.size*=zoom;
+ r.size *= zoom;
bool in_box = r.intersects(box_selecting_rect);
if (in_box)
gn->set_selected(box_selection_mode_aditive);
else
- gn->set_selected(previus_selected.find(gn)!=NULL);
+ gn->set_selected(previus_selected.find(gn) != NULL);
}
top_layer->update();
}
- if (p_ev.type==InputEvent::MOUSE_BUTTON) {
+ if (p_ev.type == InputEvent::MOUSE_BUTTON) {
- const InputEventMouseButton &b=p_ev.mouse_button;
+ const InputEventMouseButton &b = p_ev.mouse_button;
- if (b.button_index==BUTTON_RIGHT && b.pressed)
- {
+ if (b.button_index == BUTTON_RIGHT && b.pressed) {
if (box_selecting) {
box_selecting = false;
- for(int i=get_child_count()-1;i>=0;i--) {
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn)
continue;
- gn->set_selected(previus_selected.find(gn)!=NULL);
+ gn->set_selected(previus_selected.find(gn) != NULL);
}
top_layer->update();
} else {
@@ -612,27 +582,27 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
}
}
- if (b.button_index==BUTTON_LEFT && !b.pressed && dragging) {
- if (!just_selected && drag_accum==Vector2() && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (b.button_index == BUTTON_LEFT && !b.pressed && dragging) {
+ if (!just_selected && drag_accum == Vector2() && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
//deselect current node
- for(int i=get_child_count()-1;i>=0;i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ for (int i = get_child_count() - 1; i >= 0; i--) {
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (gn) {
Rect2 r = gn->get_rect();
- r.size*=zoom;
+ r.size *= zoom;
if (r.has_point(get_local_mouse_pos()))
gn->set_selected(false);
}
}
}
- if (drag_accum!=Vector2()) {
+ if (drag_accum != Vector2()) {
emit_signal("_begin_node_move");
- for(int i=get_child_count()-1;i>=0;i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ for (int i = get_child_count() - 1; i >= 0; i--) {
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (gn && gn->is_selected())
gn->set_drag(false);
}
@@ -645,16 +615,16 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
top_layer->update();
}
- if (b.button_index==BUTTON_LEFT && b.pressed) {
+ if (b.button_index == BUTTON_LEFT && b.pressed) {
GraphNode *gn = NULL;
- for(int i=get_child_count()-1;i>=0;i--) {
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- gn=get_child(i)->cast_to<GraphNode>();
+ gn = get_child(i)->cast_to<GraphNode>();
if (gn) {
Rect2 r = gn->get_rect();
- r.size*=zoom;
+ r.size *= zoom;
if (r.has_point(get_local_mouse_pos()))
break;
}
@@ -662,14 +632,14 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
if (gn) {
- if (_filter_input(Vector2(b.x,b.y)))
+ if (_filter_input(Vector2(b.x, b.y)))
return;
dragging = true;
drag_accum = Vector2();
drag_origin = get_local_mouse_pos();
just_selected = !gn->is_selected();
- if(!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < get_child_count(); i++) {
GraphNode *o_gn = get_child(i)->cast_to<GraphNode>();
if (o_gn)
@@ -687,7 +657,7 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
}
} else {
- if (_filter_input(Vector2(b.x,b.y)))
+ if (_filter_input(Vector2(b.x, b.y)))
return;
if (Input::get_singleton()->is_key_pressed(KEY_SPACE))
return;
@@ -697,9 +667,9 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
if (b.mod.control) {
box_selection_mode_aditive = true;
previus_selected.clear();
- for(int i=get_child_count()-1;i>=0;i--) {
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn || !gn->is_selected())
continue;
@@ -708,9 +678,9 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
} else if (b.mod.shift) {
box_selection_mode_aditive = false;
previus_selected.clear();
- for(int i=get_child_count()-1;i>=0;i--) {
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn || !gn->is_selected())
continue;
@@ -719,9 +689,9 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
} else {
box_selection_mode_aditive = true;
previus_selected.clear();
- for(int i=get_child_count()-1;i>=0;i--) {
+ for (int i = get_child_count() - 1; i >= 0; i--) {
- GraphNode *gn=get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = get_child(i)->cast_to<GraphNode>();
if (!gn)
continue;
@@ -731,33 +701,32 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
}
}
- if (b.button_index==BUTTON_LEFT && !b.pressed && box_selecting) {
+ if (b.button_index == BUTTON_LEFT && !b.pressed && box_selecting) {
box_selecting = false;
previus_selected.clear();
top_layer->update();
}
- if (b.button_index==BUTTON_WHEEL_UP && b.pressed) {
+ if (b.button_index == BUTTON_WHEEL_UP && b.pressed) {
//too difficult to get right
//set_zoom(zoom*ZOOM_SCALE);
}
- if (b.button_index==BUTTON_WHEEL_DOWN && b.pressed) {
+ if (b.button_index == BUTTON_WHEEL_DOWN && b.pressed) {
//too difficult to get right
//set_zoom(zoom/ZOOM_SCALE);
}
}
- if (p_ev.type==InputEvent::KEY && p_ev.key.scancode==KEY_D && p_ev.key.pressed && p_ev.key.mod.command) {
+ if (p_ev.type == InputEvent::KEY && p_ev.key.scancode == KEY_D && p_ev.key.pressed && p_ev.key.mod.command) {
emit_signal("duplicate_nodes_request");
accept_event();
}
- if (p_ev.type==InputEvent::KEY && p_ev.key.scancode==KEY_DELETE && p_ev.key.pressed) {
+ if (p_ev.type == InputEvent::KEY && p_ev.key.scancode == KEY_DELETE && p_ev.key.pressed) {
emit_signal("delete_nodes_request");
accept_event();
}
-
}
void GraphEdit::clear_connections() {
@@ -768,14 +737,14 @@ void GraphEdit::clear_connections() {
void GraphEdit::set_zoom(float p_zoom) {
- p_zoom=CLAMP(p_zoom,MIN_ZOOM,MAX_ZOOM);
+ p_zoom = CLAMP(p_zoom, MIN_ZOOM, MAX_ZOOM);
if (zoom == p_zoom)
return;
- zoom_minus->set_disabled(zoom==MIN_ZOOM);
- zoom_plus->set_disabled(zoom==MAX_ZOOM);
+ zoom_minus->set_disabled(zoom == MIN_ZOOM);
+ zoom_plus->set_disabled(zoom == MAX_ZOOM);
- Vector2 sbofs = (Vector2( h_scroll->get_val(), v_scroll->get_val() ) + get_size()/2)/zoom;
+ Vector2 sbofs = (Vector2(h_scroll->get_val(), v_scroll->get_val()) + get_size() / 2) / zoom;
zoom = p_zoom;
top_layer->update();
@@ -784,12 +753,11 @@ void GraphEdit::set_zoom(float p_zoom) {
if (is_visible()) {
- Vector2 ofs = sbofs*zoom - get_size()/2;
- h_scroll->set_val( ofs.x );
- v_scroll->set_val( ofs.y );
+ Vector2 ofs = sbofs * zoom - get_size() / 2;
+ h_scroll->set_val(ofs.x);
+ v_scroll->set_val(ofs.y);
}
-
update();
}
@@ -799,10 +767,10 @@ float GraphEdit::get_zoom() const {
void GraphEdit::set_right_disconnects(bool p_enable) {
- right_disconnects=p_enable;
+ right_disconnects = p_enable;
}
-bool GraphEdit::is_right_disconnects_enabled() const{
+bool GraphEdit::is_right_disconnects_enabled() const {
return right_disconnects;
}
@@ -812,84 +780,77 @@ Array GraphEdit::_get_connection_list() const {
List<Connection> conns;
get_connection_list(&conns);
Array arr;
- for(List<Connection>::Element *E=conns.front();E;E=E->next()) {
+ for (List<Connection>::Element *E = conns.front(); E; E = E->next()) {
Dictionary d;
- d["from"]=E->get().from;
- d["from_port"]=E->get().from_port;
- d["to"]=E->get().to;
- d["to_port"]=E->get().to_port;
+ d["from"] = E->get().from;
+ d["from_port"] = E->get().from_port;
+ d["to"] = E->get().to;
+ d["to_port"] = E->get().to_port;
arr.push_back(d);
}
return arr;
}
-
-
void GraphEdit::_zoom_minus() {
-
- set_zoom(zoom/ZOOM_SCALE);
+ set_zoom(zoom / ZOOM_SCALE);
}
void GraphEdit::_zoom_reset() {
-
set_zoom(1);
}
void GraphEdit::_zoom_plus() {
- set_zoom(zoom*ZOOM_SCALE);
+ set_zoom(zoom * ZOOM_SCALE);
}
-
void GraphEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node);
- ObjectTypeDB::bind_method(_MD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected);
- ObjectTypeDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node);
- ObjectTypeDB::bind_method(_MD("get_connection_list"),&GraphEdit::_get_connection_list);
- ObjectTypeDB::bind_method(_MD("get_scroll_ofs"),&GraphEdit::get_scroll_ofs);
+ ObjectTypeDB::bind_method(_MD("connect_node:Error", "from", "from_port", "to", "to_port"), &GraphEdit::connect_node);
+ ObjectTypeDB::bind_method(_MD("is_node_connected", "from", "from_port", "to", "to_port"), &GraphEdit::is_node_connected);
+ ObjectTypeDB::bind_method(_MD("disconnect_node", "from", "from_port", "to", "to_port"), &GraphEdit::disconnect_node);
+ ObjectTypeDB::bind_method(_MD("get_connection_list"), &GraphEdit::_get_connection_list);
+ ObjectTypeDB::bind_method(_MD("get_scroll_ofs"), &GraphEdit::get_scroll_ofs);
- ObjectTypeDB::bind_method(_MD("set_zoom","p_zoom"),&GraphEdit::set_zoom);
- ObjectTypeDB::bind_method(_MD("get_zoom"),&GraphEdit::get_zoom);
+ ObjectTypeDB::bind_method(_MD("set_zoom", "p_zoom"), &GraphEdit::set_zoom);
+ ObjectTypeDB::bind_method(_MD("get_zoom"), &GraphEdit::get_zoom);
- ObjectTypeDB::bind_method(_MD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects);
- ObjectTypeDB::bind_method(_MD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled);
+ ObjectTypeDB::bind_method(_MD("set_right_disconnects", "enable"), &GraphEdit::set_right_disconnects);
+ ObjectTypeDB::bind_method(_MD("is_right_disconnects_enabled"), &GraphEdit::is_right_disconnects_enabled);
- ObjectTypeDB::bind_method(_MD("_graph_node_moved"),&GraphEdit::_graph_node_moved);
- ObjectTypeDB::bind_method(_MD("_graph_node_raised"),&GraphEdit::_graph_node_raised);
+ ObjectTypeDB::bind_method(_MD("_graph_node_moved"), &GraphEdit::_graph_node_moved);
+ ObjectTypeDB::bind_method(_MD("_graph_node_raised"), &GraphEdit::_graph_node_raised);
- ObjectTypeDB::bind_method(_MD("_top_layer_input"),&GraphEdit::_top_layer_input);
- ObjectTypeDB::bind_method(_MD("_top_layer_draw"),&GraphEdit::_top_layer_draw);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&GraphEdit::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_zoom_minus"),&GraphEdit::_zoom_minus);
- ObjectTypeDB::bind_method(_MD("_zoom_reset"),&GraphEdit::_zoom_reset);
- ObjectTypeDB::bind_method(_MD("_zoom_plus"),&GraphEdit::_zoom_plus);
+ ObjectTypeDB::bind_method(_MD("_top_layer_input"), &GraphEdit::_top_layer_input);
+ ObjectTypeDB::bind_method(_MD("_top_layer_draw"), &GraphEdit::_top_layer_draw);
+ ObjectTypeDB::bind_method(_MD("_scroll_moved"), &GraphEdit::_scroll_moved);
+ ObjectTypeDB::bind_method(_MD("_zoom_minus"), &GraphEdit::_zoom_minus);
+ ObjectTypeDB::bind_method(_MD("_zoom_reset"), &GraphEdit::_zoom_reset);
+ ObjectTypeDB::bind_method(_MD("_zoom_plus"), &GraphEdit::_zoom_plus);
- ObjectTypeDB::bind_method(_MD("_input_event"),&GraphEdit::_input_event);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &GraphEdit::_input_event);
- ADD_SIGNAL(MethodInfo("connection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
- ADD_SIGNAL(MethodInfo("disconnection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
- ADD_SIGNAL(MethodInfo("popup_request", PropertyInfo(Variant::VECTOR2,"p_position")));
+ ADD_SIGNAL(MethodInfo("connection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot")));
+ ADD_SIGNAL(MethodInfo("disconnection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot")));
+ ADD_SIGNAL(MethodInfo("popup_request", PropertyInfo(Variant::VECTOR2, "p_position")));
ADD_SIGNAL(MethodInfo("duplicate_nodes_request"));
ADD_SIGNAL(MethodInfo("delete_nodes_request"));
ADD_SIGNAL(MethodInfo("_begin_node_move"));
ADD_SIGNAL(MethodInfo("_end_node_move"));
}
-
-
GraphEdit::GraphEdit() {
set_focus_mode(FOCUS_ALL);
- top_layer=NULL;
- top_layer=memnew(GraphEditFilter(this));
+ top_layer = NULL;
+ top_layer = memnew(GraphEditFilter(this));
add_child(top_layer);
top_layer->set_stop_mouse(false);
top_layer->set_area_as_parent_rect();
- top_layer->connect("draw",this,"_top_layer_draw");
+ top_layer->connect("draw", this, "_top_layer_draw");
top_layer->set_stop_mouse(false);
- top_layer->connect("input_event",this,"_top_layer_input");
+ top_layer->connect("input_event", this, "_top_layer_input");
h_scroll = memnew(HScrollBar);
h_scroll->set_name("_h_scroll");
@@ -898,37 +859,34 @@ GraphEdit::GraphEdit() {
v_scroll = memnew(VScrollBar);
v_scroll->set_name("_v_scroll");
top_layer->add_child(v_scroll);
- updating=false;
- connecting=false;
- right_disconnects=false;
+ updating = false;
+ connecting = false;
+ right_disconnects = false;
box_selecting = false;
dragging = false;
- h_scroll->connect("value_changed", this,"_scroll_moved");
- v_scroll->connect("value_changed", this,"_scroll_moved");
+ h_scroll->connect("value_changed", this, "_scroll_moved");
+ v_scroll->connect("value_changed", this, "_scroll_moved");
zoom = 1;
- HBoxContainer *zoom_hb = memnew( HBoxContainer );
+ HBoxContainer *zoom_hb = memnew(HBoxContainer);
top_layer->add_child(zoom_hb);
- zoom_hb->set_pos(Vector2(10,10));
-
+ zoom_hb->set_pos(Vector2(10, 10));
- zoom_minus = memnew( ToolButton );
+ zoom_minus = memnew(ToolButton);
zoom_hb->add_child(zoom_minus);
- zoom_minus->connect("pressed",this,"_zoom_minus");
+ zoom_minus->connect("pressed", this, "_zoom_minus");
zoom_minus->set_icon(get_icon("minus"));
- zoom_reset = memnew( ToolButton );
+ zoom_reset = memnew(ToolButton);
zoom_hb->add_child(zoom_reset);
- zoom_reset->connect("pressed",this,"_zoom_reset");
+ zoom_reset->connect("pressed", this, "_zoom_reset");
zoom_reset->set_icon(get_icon("reset"));
- zoom_plus = memnew( ToolButton );
+ zoom_plus = memnew(ToolButton);
zoom_hb->add_child(zoom_plus);
- zoom_plus->connect("pressed",this,"_zoom_plus");
+ zoom_plus->connect("pressed", this, "_zoom_plus");
zoom_plus->set_icon(get_icon("more"));
-
-
}
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 36551f35c..263d7bd79 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -39,33 +39,29 @@ class GraphEdit;
class GraphEditFilter : public Control {
- OBJ_TYPE(GraphEditFilter,Control);
+ OBJ_TYPE(GraphEditFilter, Control);
friend class GraphEdit;
GraphEdit *ge;
- virtual bool has_point(const Point2& p_point) const;
+ virtual bool has_point(const Point2 &p_point) const;
public:
-
-
GraphEditFilter(GraphEdit *p_edit);
};
class GraphEdit : public Control {
- OBJ_TYPE(GraphEdit,Control);
-public:
+ OBJ_TYPE(GraphEdit, Control);
+public:
struct Connection {
StringName from;
StringName to;
int from_port;
int to_port;
-
};
-private:
-
+private:
ToolButton *zoom_minus;
ToolButton *zoom_reset;
ToolButton *zoom_plus;
@@ -74,9 +70,8 @@ private:
void _zoom_reset();
void _zoom_plus();
- HScrollBar* h_scroll;
- VScrollBar* v_scroll;
-
+ HScrollBar *h_scroll;
+ VScrollBar *v_scroll;
bool connecting;
String connecting_from;
@@ -101,42 +96,42 @@ private:
Point2 box_selecting_from;
Point2 box_selecting_to;
Rect2 box_selecting_rect;
- List<GraphNode*> previus_selected;
+ List<GraphNode *> previus_selected;
bool right_disconnects;
bool updating;
List<Connection> connections;
- void _draw_cos_line(const Vector2& p_from, const Vector2& p_to,const Color& p_color);
+ void _draw_cos_line(const Vector2 &p_from, const Vector2 &p_to, const Color &p_color);
- void _graph_node_raised(Node* p_gn);
+ void _graph_node_raised(Node *p_gn);
void _graph_node_moved(Node *p_gn);
void _update_scroll();
void _scroll_moved(double);
- void _input_event(const InputEvent& p_ev);
+ void _input_event(const InputEvent &p_ev);
GraphEditFilter *top_layer;
- void _top_layer_input(const InputEvent& p_ev);
+ void _top_layer_input(const InputEvent &p_ev);
void _top_layer_draw();
void _update_scroll_offset();
Array _get_connection_list() const;
friend class GraphEditFilter;
- bool _filter_input(const Point2& p_point);
-protected:
+ bool _filter_input(const Point2 &p_point);
+protected:
static void _bind_methods();
virtual void add_child_notify(Node *p_child);
virtual void remove_child_notify(Node *p_child);
void _notification(int p_what);
virtual bool clips_input() const;
-public:
- Error connect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
- bool is_node_connected(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
- void disconnect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
+public:
+ Error connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port);
+ bool is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port);
+ void disconnect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port);
void clear_connections();
void set_zoom(float p_zoom);
@@ -150,7 +145,6 @@ public:
Vector2 get_scroll_ofs() const;
-
GraphEdit();
};
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 223d05575..129efd733 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -29,356 +29,322 @@
#include "graph_node.h"
#include "method_bind_ext.inc"
-
-bool GraphNode::_set(const StringName& p_name, const Variant& p_value) {
+bool GraphNode::_set(const StringName &p_name, const Variant &p_value) {
if (!p_name.operator String().begins_with("slot/"))
return false;
- int idx=p_name.operator String().get_slice("/",1).to_int();
- String what = p_name.operator String().get_slice("/",2);
-
+ int idx = p_name.operator String().get_slice("/", 1).to_int();
+ String what = p_name.operator String().get_slice("/", 2);
Slot si;
if (slot_info.has(idx))
- si=slot_info[idx];
-
+ si = slot_info[idx];
- if (what=="left_enabled")
- si.enable_left=p_value;
- else if (what=="left_type")
- si.type_left=p_value;
- else if (what=="left_color")
- si.color_left=p_value;
- else if (what=="right_enabled")
- si.enable_right=p_value;
- else if (what=="right_type")
- si.type_right=p_value;
- else if (what=="right_color")
- si.color_right=p_value;
+ if (what == "left_enabled")
+ si.enable_left = p_value;
+ else if (what == "left_type")
+ si.type_left = p_value;
+ else if (what == "left_color")
+ si.color_left = p_value;
+ else if (what == "right_enabled")
+ si.enable_right = p_value;
+ else if (what == "right_type")
+ si.type_right = p_value;
+ else if (what == "right_color")
+ si.color_right = p_value;
else
return false;
- set_slot(idx,si.enable_left,si.type_left,si.color_left,si.enable_right,si.type_right,si.color_right);
+ set_slot(idx, si.enable_left, si.type_left, si.color_left, si.enable_right, si.type_right, si.color_right);
update();
return true;
}
-bool GraphNode::_get(const StringName& p_name,Variant &r_ret) const{
-
-
+bool GraphNode::_get(const StringName &p_name, Variant &r_ret) const {
if (!p_name.operator String().begins_with("slot/")) {
return false;
}
- int idx=p_name.operator String().get_slice("/",1).to_int();
- String what = p_name.operator String().get_slice("/",2);
-
-
+ int idx = p_name.operator String().get_slice("/", 1).to_int();
+ String what = p_name.operator String().get_slice("/", 2);
Slot si;
if (slot_info.has(idx))
- si=slot_info[idx];
+ si = slot_info[idx];
- if (what=="left_enabled")
- r_ret=si.enable_left;
- else if (what=="left_type")
- r_ret=si.type_left;
- else if (what=="left_color")
- r_ret=si.color_left;
- else if (what=="right_enabled")
- r_ret=si.enable_right;
- else if (what=="right_type")
- r_ret=si.type_right;
- else if (what=="right_color")
- r_ret=si.color_right;
+ if (what == "left_enabled")
+ r_ret = si.enable_left;
+ else if (what == "left_type")
+ r_ret = si.type_left;
+ else if (what == "left_color")
+ r_ret = si.color_left;
+ else if (what == "right_enabled")
+ r_ret = si.enable_right;
+ else if (what == "right_type")
+ r_ret = si.type_right;
+ else if (what == "right_color")
+ r_ret = si.color_right;
else
return false;
return true;
}
-void GraphNode::_get_property_list( List<PropertyInfo> *p_list) const{
+void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const {
- int idx=0;
- for(int i=0;i<get_child_count();i++) {
- Control *c=get_child(i)->cast_to<Control>();
- if (!c || c->is_set_as_toplevel() )
+ int idx = 0;
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = get_child(i)->cast_to<Control>();
+ if (!c || c->is_set_as_toplevel())
continue;
- String base="slot/"+itos(idx)+"/";
+ String base = "slot/" + itos(idx) + "/";
- p_list->push_back(PropertyInfo(Variant::BOOL,base+"left_enabled"));
- p_list->push_back(PropertyInfo(Variant::INT,base+"left_type"));
- p_list->push_back(PropertyInfo(Variant::COLOR,base+"left_color"));
- p_list->push_back(PropertyInfo(Variant::BOOL,base+"right_enabled"));
- p_list->push_back(PropertyInfo(Variant::INT,base+"right_type"));
- p_list->push_back(PropertyInfo(Variant::COLOR,base+"right_color"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, base + "left_enabled"));
+ p_list->push_back(PropertyInfo(Variant::INT, base + "left_type"));
+ p_list->push_back(PropertyInfo(Variant::COLOR, base + "left_color"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, base + "right_enabled"));
+ p_list->push_back(PropertyInfo(Variant::INT, base + "right_type"));
+ p_list->push_back(PropertyInfo(Variant::COLOR, base + "right_color"));
idx++;
}
}
-
void GraphNode::_resort() {
-
-
- int sep=get_constant("separation");
- Ref<StyleBox> sb=get_stylebox("frame");
- bool first=true;
+ int sep = get_constant("separation");
+ Ref<StyleBox> sb = get_stylebox("frame");
+ bool first = true;
Size2 minsize;
- for(int i=0;i<get_child_count();i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- Size2i size=c->get_combined_minimum_size();
+ Size2i size = c->get_combined_minimum_size();
- minsize.y+=size.y;
- minsize.x=MAX(minsize.x,size.x);
+ minsize.y += size.y;
+ minsize.x = MAX(minsize.x, size.x);
if (first)
- first=false;
+ first = false;
else
- minsize.y+=sep;
-
+ minsize.y += sep;
}
-
- int vofs=0;
+ int vofs = 0;
int w = get_size().x - sb->get_minimum_size().x;
-
cache_y.clear();
- for(int i=0;i<get_child_count();i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- Size2i size=c->get_combined_minimum_size();
-
- Rect2 r(sb->get_margin(MARGIN_LEFT),sb->get_margin(MARGIN_TOP)+vofs,w,size.y);
-
- fit_child_in_rect(c,r);
- cache_y.push_back(vofs+size.y*0.5);
+ Size2i size = c->get_combined_minimum_size();
- if (vofs>0)
- vofs+=sep;
- vofs+=size.y;
+ Rect2 r(sb->get_margin(MARGIN_LEFT), sb->get_margin(MARGIN_TOP) + vofs, w, size.y);
+ fit_child_in_rect(c, r);
+ cache_y.push_back(vofs + size.y * 0.5);
+ if (vofs > 0)
+ vofs += sep;
+ vofs += size.y;
}
_change_notify();
update();
- connpos_dirty=true;
-
-
+ connpos_dirty = true;
}
-
void GraphNode::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
- Ref<StyleBox> sb=get_stylebox(selected ? "selectedframe" : "frame");
- Ref<Texture> port =get_icon("port");
- Ref<Texture> close =get_icon("close");
+ Ref<StyleBox> sb = get_stylebox(selected ? "selectedframe" : "frame");
+ Ref<Texture> port = get_icon("port");
+ Ref<Texture> close = get_icon("close");
int close_offset = get_constant("close_offset");
Ref<Font> title_font = get_font("title_font");
int title_offset = get_constant("title_offset");
Color title_color = get_color("title_color");
- Point2i icofs = -port->get_size()*0.5;
- int edgeofs=get_constant("port_offset");
- icofs.y+=sb->get_margin(MARGIN_TOP);
- draw_style_box(sb,Rect2(Point2(),get_size()));
+ Point2i icofs = -port->get_size() * 0.5;
+ int edgeofs = get_constant("port_offset");
+ icofs.y += sb->get_margin(MARGIN_TOP);
+ draw_style_box(sb, Rect2(Point2(), get_size()));
- int w = get_size().width-sb->get_minimum_size().x;
+ int w = get_size().width - sb->get_minimum_size().x;
if (show_close)
- w-=close->get_width();
+ w -= close->get_width();
- draw_string(title_font,Point2(sb->get_margin(MARGIN_LEFT),-title_font->get_height()+title_font->get_ascent()+title_offset),title,title_color,w);
+ draw_string(title_font, Point2(sb->get_margin(MARGIN_LEFT), -title_font->get_height() + title_font->get_ascent() + title_offset), title, title_color, w);
if (show_close) {
- Vector2 cpos = Point2(w+sb->get_margin(MARGIN_LEFT),-close->get_height()+close_offset);
- draw_texture(close,cpos);
- close_rect.pos=cpos;
- close_rect.size=close->get_size();
+ Vector2 cpos = Point2(w + sb->get_margin(MARGIN_LEFT), -close->get_height() + close_offset);
+ draw_texture(close, cpos);
+ close_rect.pos = cpos;
+ close_rect.size = close->get_size();
} else {
- close_rect=Rect2();
+ close_rect = Rect2();
}
- for (Map<int,Slot>::Element *E=slot_info.front();E;E=E->next()) {
+ for (Map<int, Slot>::Element *E = slot_info.front(); E; E = E->next()) {
- if (E->key() < 0 || E->key()>=cache_y.size())
+ if (E->key() < 0 || E->key() >= cache_y.size())
continue;
if (!slot_info.has(E->key()))
continue;
- const Slot &s=slot_info[E->key()];
+ const Slot &s = slot_info[E->key()];
//left
if (s.enable_left)
- port->draw(get_canvas_item(),icofs+Point2(edgeofs,cache_y[E->key()]),s.color_left);
+ port->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E->key()]), s.color_left);
if (s.enable_right)
- port->draw(get_canvas_item(),icofs+Point2(get_size().x-edgeofs,cache_y[E->key()]),s.color_right);
-
+ port->draw(get_canvas_item(), icofs + Point2(get_size().x - edgeofs, cache_y[E->key()]), s.color_right);
}
}
- if (p_what==NOTIFICATION_SORT_CHILDREN) {
+ if (p_what == NOTIFICATION_SORT_CHILDREN) {
_resort();
}
-
}
+void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right) {
-void GraphNode::set_slot(int p_idx,bool p_enable_left,int p_type_left,const Color& p_color_left, bool p_enable_right,int p_type_right,const Color& p_color_right) {
-
- ERR_FAIL_COND(p_idx<0);
+ ERR_FAIL_COND(p_idx < 0);
- if (!p_enable_left && p_type_left==0 && p_color_left==Color(1,1,1,1) && !p_enable_right && p_type_right==0 && p_color_right==Color(1,1,1,1)) {
+ if (!p_enable_left && p_type_left == 0 && p_color_left == Color(1, 1, 1, 1) && !p_enable_right && p_type_right == 0 && p_color_right == Color(1, 1, 1, 1)) {
slot_info.erase(p_idx);
return;
}
Slot s;
- s.enable_left=p_enable_left;
- s.type_left=p_type_left;
- s.color_left=p_color_left;
- s.enable_right=p_enable_right;
- s.type_right=p_type_right;
- s.color_right=p_color_right;
- slot_info[p_idx]=s;
+ s.enable_left = p_enable_left;
+ s.type_left = p_type_left;
+ s.color_left = p_color_left;
+ s.enable_right = p_enable_right;
+ s.type_right = p_type_right;
+ s.color_right = p_color_right;
+ slot_info[p_idx] = s;
update();
- connpos_dirty=true;
-
+ connpos_dirty = true;
}
-void GraphNode::clear_slot(int p_idx){
+void GraphNode::clear_slot(int p_idx) {
slot_info.erase(p_idx);
update();
- connpos_dirty=true;
-
+ connpos_dirty = true;
}
-void GraphNode::clear_all_slots(){
+void GraphNode::clear_all_slots() {
slot_info.clear();
update();
- connpos_dirty=true;
-
+ connpos_dirty = true;
}
-bool GraphNode::is_slot_enabled_left(int p_idx) const{
+bool GraphNode::is_slot_enabled_left(int p_idx) const {
if (!slot_info.has(p_idx))
return false;
return slot_info[p_idx].enable_left;
-
}
-int GraphNode::get_slot_type_left(int p_idx) const{
+int GraphNode::get_slot_type_left(int p_idx) const {
if (!slot_info.has(p_idx))
return 0;
return slot_info[p_idx].type_left;
-
}
-Color GraphNode::get_slot_color_left(int p_idx) const{
+Color GraphNode::get_slot_color_left(int p_idx) const {
if (!slot_info.has(p_idx))
- return Color(1,1,1,1);
+ return Color(1, 1, 1, 1);
return slot_info[p_idx].color_left;
-
}
-bool GraphNode::is_slot_enabled_right(int p_idx) const{
+bool GraphNode::is_slot_enabled_right(int p_idx) const {
if (!slot_info.has(p_idx))
return false;
return slot_info[p_idx].enable_right;
-
}
-
-
-int GraphNode::get_slot_type_right(int p_idx) const{
+int GraphNode::get_slot_type_right(int p_idx) const {
if (!slot_info.has(p_idx))
return 0;
return slot_info[p_idx].type_right;
-
}
-Color GraphNode::get_slot_color_right(int p_idx) const{
+Color GraphNode::get_slot_color_right(int p_idx) const {
if (!slot_info.has(p_idx))
- return Color(1,1,1,1);
+ return Color(1, 1, 1, 1);
return slot_info[p_idx].color_right;
-
}
Size2 GraphNode::get_minimum_size() const {
Ref<Font> title_font = get_font("title_font");
- int sep=get_constant("separation");
- Ref<StyleBox> sb=get_stylebox("frame");
- bool first=true;
+ int sep = get_constant("separation");
+ Ref<StyleBox> sb = get_stylebox("frame");
+ bool first = true;
Size2 minsize;
- minsize.x=title_font->get_string_size(title).x;
+ minsize.x = title_font->get_string_size(title).x;
if (show_close) {
- Ref<Texture> close =get_icon("close");
- minsize.x+=sep+close->get_width();
+ Ref<Texture> close = get_icon("close");
+ minsize.x += sep + close->get_width();
}
+ for (int i = 0; i < get_child_count(); i++) {
- for(int i=0;i<get_child_count();i++) {
-
- Control *c=get_child(i)->cast_to<Control>();
+ Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- Size2i size=c->get_combined_minimum_size();
+ Size2i size = c->get_combined_minimum_size();
- minsize.y+=size.y;
- minsize.x=MAX(minsize.x,size.x);
+ minsize.y += size.y;
+ minsize.x = MAX(minsize.x, size.x);
if (first)
- first=false;
+ first = false;
else
- minsize.y+=sep;
+ minsize.y += sep;
}
- return minsize+sb->get_minimum_size();
+ return minsize + sb->get_minimum_size();
}
-void GraphNode::set_title(const String& p_title) {
+void GraphNode::set_title(const String &p_title) {
- title=p_title;
+ title = p_title;
minimum_size_changed();
update();
-
}
-String GraphNode::get_title() const{
+String GraphNode::get_title() const {
return title;
}
-void GraphNode::set_offset(const Vector2& p_offset) {
+void GraphNode::set_offset(const Vector2 &p_offset) {
- offset=p_offset;
+ offset = p_offset;
emit_signal("offset_changed");
update();
}
@@ -388,103 +354,93 @@ Vector2 GraphNode::get_offset() const {
return offset;
}
-void GraphNode::set_selected(bool p_selected)
-{
+void GraphNode::set_selected(bool p_selected) {
selected = p_selected;
update();
}
-bool GraphNode::is_selected()
-{
+bool GraphNode::is_selected() {
return selected;
}
-void GraphNode::set_drag(bool p_drag)
-{
+void GraphNode::set_drag(bool p_drag) {
if (p_drag)
- drag_from=get_offset();
+ drag_from = get_offset();
else
- emit_signal("dragged",drag_from,get_offset()); //useful for undo/redo
+ emit_signal("dragged", drag_from, get_offset()); //useful for undo/redo
}
-Vector2 GraphNode::get_drag_from()
-{
+Vector2 GraphNode::get_drag_from() {
return drag_from;
}
+void GraphNode::set_show_close_button(bool p_enable) {
-void GraphNode::set_show_close_button(bool p_enable){
-
- show_close=p_enable;
+ show_close = p_enable;
update();
}
-bool GraphNode::is_close_button_visible() const{
+bool GraphNode::is_close_button_visible() const {
return show_close;
}
void GraphNode::_connpos_update() {
+ int edgeofs = get_constant("port_offset");
+ int sep = get_constant("separation");
- int edgeofs=get_constant("port_offset");
- int sep=get_constant("separation");
-
- Ref<StyleBox> sb=get_stylebox("frame");
+ Ref<StyleBox> sb = get_stylebox("frame");
conn_input_cache.clear();
conn_output_cache.clear();
- int vofs=0;
+ int vofs = 0;
- int idx=0;
+ int idx = 0;
- for(int i=0;i<get_child_count();i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- Size2i size=c->get_combined_minimum_size();
+ Size2i size = c->get_combined_minimum_size();
- int y = sb->get_margin(MARGIN_TOP)+vofs;
+ int y = sb->get_margin(MARGIN_TOP) + vofs;
int h = size.y;
-
if (slot_info.has(idx)) {
if (slot_info[idx].enable_left) {
ConnCache cc;
- cc.pos=Point2i(edgeofs,y+h/2);
- cc.type=slot_info[idx].type_left;
- cc.color=slot_info[idx].color_left;
+ cc.pos = Point2i(edgeofs, y + h / 2);
+ cc.type = slot_info[idx].type_left;
+ cc.color = slot_info[idx].color_left;
conn_input_cache.push_back(cc);
}
if (slot_info[idx].enable_right) {
ConnCache cc;
- cc.pos=Point2i(get_size().width-edgeofs,y+h/2);
- cc.type=slot_info[idx].type_right;
- cc.color=slot_info[idx].color_right;
+ cc.pos = Point2i(get_size().width - edgeofs, y + h / 2);
+ cc.type = slot_info[idx].type_right;
+ cc.color = slot_info[idx].color_right;
conn_output_cache.push_back(cc);
}
}
- if (vofs>0)
- vofs+=sep;
- vofs+=size.y;
+ if (vofs > 0)
+ vofs += sep;
+ vofs += size.y;
idx++;
-
}
-
- connpos_dirty=false;
+ connpos_dirty = false;
}
-int GraphNode::get_connection_input_count() {
+int GraphNode::get_connection_input_count() {
if (connpos_dirty)
_connpos_update();
return conn_input_cache.size();
-
}
int GraphNode::get_connection_output_count() {
@@ -492,16 +448,14 @@ int GraphNode::get_connection_output_count() {
_connpos_update();
return conn_output_cache.size();
-
}
-
Vector2 GraphNode::get_connection_input_pos(int p_idx) {
if (connpos_dirty)
_connpos_update();
- ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),Vector2());
+ ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), Vector2());
Vector2 pos = conn_input_cache[p_idx].pos;
pos.x *= get_scale().x;
pos.y *= get_scale().y;
@@ -513,7 +467,7 @@ int GraphNode::get_connection_input_type(int p_idx) {
if (connpos_dirty)
_connpos_update();
- ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),0);
+ ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), 0);
return conn_input_cache[p_idx].type;
}
@@ -522,16 +476,16 @@ Color GraphNode::get_connection_input_color(int p_idx) {
if (connpos_dirty)
_connpos_update();
- ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),Color());
+ ERR_FAIL_INDEX_V(p_idx, conn_input_cache.size(), Color());
return conn_input_cache[p_idx].color;
}
-Vector2 GraphNode::get_connection_output_pos(int p_idx){
+Vector2 GraphNode::get_connection_output_pos(int p_idx) {
if (connpos_dirty)
_connpos_update();
- ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),Vector2());
+ ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), Vector2());
Vector2 pos = conn_output_cache[p_idx].pos;
pos.x *= get_scale().x;
pos.y *= get_scale().y;
@@ -543,7 +497,7 @@ int GraphNode::get_connection_output_type(int p_idx) {
if (connpos_dirty)
_connpos_update();
- ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),0);
+ ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), 0);
return conn_output_cache[p_idx].type;
}
@@ -552,77 +506,74 @@ Color GraphNode::get_connection_output_color(int p_idx) {
if (connpos_dirty)
_connpos_update();
- ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),Color());
+ ERR_FAIL_INDEX_V(p_idx, conn_output_cache.size(), Color());
return conn_output_cache[p_idx].color;
}
-void GraphNode::_input_event(const InputEvent& p_ev) {
+void GraphNode::_input_event(const InputEvent &p_ev) {
- if (p_ev.type==InputEvent::MOUSE_BUTTON) {
+ if (p_ev.type == InputEvent::MOUSE_BUTTON) {
ERR_EXPLAIN("GraphNode must be the child of a GraphEdit node.");
ERR_FAIL_COND(get_parent_control() == NULL);
get_parent_control()->grab_focus();
- if(p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
+ if (p_ev.mouse_button.pressed && p_ev.mouse_button.button_index == BUTTON_LEFT) {
- Vector2 mpos = Vector2(p_ev.mouse_button.x,p_ev.mouse_button.y);
- if (close_rect.size!=Size2() && close_rect.has_point(mpos)) {
+ Vector2 mpos = Vector2(p_ev.mouse_button.x, p_ev.mouse_button.y);
+ if (close_rect.size != Size2() && close_rect.has_point(mpos)) {
emit_signal("close_request");
return;
}
emit_signal("raise_request");
}
}
-
}
-
void GraphNode::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
- ObjectTypeDB::bind_method(_MD("get_title"),&GraphNode::get_title);
- ObjectTypeDB::bind_method(_MD("_input_event"),&GraphNode::_input_event);
-
- ObjectTypeDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right"),&GraphNode::set_slot);
- ObjectTypeDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
- ObjectTypeDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
- ObjectTypeDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
- ObjectTypeDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
- ObjectTypeDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
- ObjectTypeDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
- ObjectTypeDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
- ObjectTypeDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
+ ObjectTypeDB::bind_method(_MD("set_title", "title"), &GraphNode::set_title);
+ ObjectTypeDB::bind_method(_MD("get_title"), &GraphNode::get_title);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &GraphNode::_input_event);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_slot", "idx", "enable_left", "type_left", "color_left", "enable_right", "type_right", "color_right"), &GraphNode::set_slot);
+ ObjectTypeDB::bind_method(_MD("clear_slot", "idx"), &GraphNode::clear_slot);
+ ObjectTypeDB::bind_method(_MD("clear_all_slots", "idx"), &GraphNode::clear_all_slots);
+ ObjectTypeDB::bind_method(_MD("is_slot_enabled_left", "idx"), &GraphNode::is_slot_enabled_left);
+ ObjectTypeDB::bind_method(_MD("get_slot_type_left", "idx"), &GraphNode::get_slot_type_left);
+ ObjectTypeDB::bind_method(_MD("get_slot_color_left", "idx"), &GraphNode::get_slot_color_left);
+ ObjectTypeDB::bind_method(_MD("is_slot_enabled_right", "idx"), &GraphNode::is_slot_enabled_right);
+ ObjectTypeDB::bind_method(_MD("get_slot_type_right", "idx"), &GraphNode::get_slot_type_right);
+ ObjectTypeDB::bind_method(_MD("get_slot_color_right", "idx"), &GraphNode::get_slot_color_right);
- ObjectTypeDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
- ObjectTypeDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &GraphNode::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &GraphNode::get_offset);
- ObjectTypeDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
- ObjectTypeDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
- ObjectTypeDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
- ObjectTypeDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
- ObjectTypeDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
- ObjectTypeDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
+ ObjectTypeDB::bind_method(_MD("get_connection_output_count"), &GraphNode::get_connection_output_count);
+ ObjectTypeDB::bind_method(_MD("get_connection_input_count"), &GraphNode::get_connection_input_count);
+ ObjectTypeDB::bind_method(_MD("get_connection_output_pos", "idx"), &GraphNode::get_connection_output_pos);
+ ObjectTypeDB::bind_method(_MD("get_connection_output_type", "idx"), &GraphNode::get_connection_output_type);
+ ObjectTypeDB::bind_method(_MD("get_connection_output_color", "idx"), &GraphNode::get_connection_output_color);
+ ObjectTypeDB::bind_method(_MD("get_connection_input_pos", "idx"), &GraphNode::get_connection_input_pos);
+ ObjectTypeDB::bind_method(_MD("get_connection_input_type", "idx"), &GraphNode::get_connection_input_type);
+ ObjectTypeDB::bind_method(_MD("get_connection_input_color", "idx"), &GraphNode::get_connection_input_color);
- ObjectTypeDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
- ObjectTypeDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
+ ObjectTypeDB::bind_method(_MD("set_show_close_button", "show"), &GraphNode::set_show_close_button);
+ ObjectTypeDB::bind_method(_MD("is_close_button_visible"), &GraphNode::is_close_button_visible);
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),_SCS("set_show_close_button"),_SCS("is_close_button_visible"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), _SCS("set_title"), _SCS("get_title"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_close"), _SCS("set_show_close_button"), _SCS("is_close_button_visible"));
ADD_SIGNAL(MethodInfo("offset_changed"));
- ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to")));
+ ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "from"), PropertyInfo(Variant::VECTOR2, "to")));
ADD_SIGNAL(MethodInfo("raise_request"));
ADD_SIGNAL(MethodInfo("close_request"));
}
GraphNode::GraphNode() {
- show_close=false;
- connpos_dirty=true;
+ show_close = false;
+ connpos_dirty = true;
set_stop_mouse(false);
}
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index 46c8cf9ac..801f84ec4 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -33,9 +33,7 @@
class GraphNode : public Container {
- OBJ_TYPE(GraphNode,Container);
-
-
+ OBJ_TYPE(GraphNode, Container);
struct Slot {
bool enable_left;
@@ -45,8 +43,14 @@ class GraphNode : public Container {
int type_right;
Color color_right;
-
- Slot() { enable_left=false; type_left=0; color_left=Color(1,1,1,1); enable_right=false; type_right=0; color_right=Color(1,1,1,1); }
+ Slot() {
+ enable_left = false;
+ type_left = 0;
+ color_left = Color(1, 1, 1, 1);
+ enable_right = false;
+ type_right = 0;
+ color_right = Color(1, 1, 1, 1);
+ }
};
String title;
@@ -66,7 +70,7 @@ class GraphNode : public Container {
Vector<ConnCache> conn_input_cache;
Vector<ConnCache> conn_output_cache;
- Map<int,Slot> slot_info;
+ Map<int, Slot> slot_info;
bool connpos_dirty;
@@ -75,23 +79,18 @@ class GraphNode : public Container {
Vector2 drag_from;
bool selected;
-protected:
-
- void _input_event(const InputEvent& p_ev);
+protected:
+ void _input_event(const InputEvent &p_ev);
void _notification(int p_what);
static void _bind_methods();
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
public:
-
-
-
-
- void set_slot(int p_idx,bool p_enable_left,int p_type_left,const Color& p_color_left, bool p_enable_right,int p_type_right,const Color& p_color_right);
+ void set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right);
void clear_slot(int p_idx);
void clear_all_slots();
bool is_slot_enabled_left(int p_idx) const;
@@ -101,10 +100,10 @@ public:
int get_slot_type_right(int p_idx) const;
Color get_slot_color_right(int p_idx) const;
- void set_title(const String& p_title);
+ void set_title(const String &p_title);
String get_title() const;
- void set_offset(const Vector2& p_offset);
+ void set_offset(const Vector2 &p_offset);
Vector2 get_offset() const;
void set_selected(bool p_selected);
@@ -116,8 +115,8 @@ public:
void set_show_close_button(bool p_enable);
bool is_close_button_visible() const;
- int get_connection_input_count() ;
- int get_connection_output_count() ;
+ int get_connection_input_count();
+ int get_connection_output_count();
Vector2 get_connection_input_pos(int p_idx);
int get_connection_input_type(int p_idx);
Color get_connection_input_color(int p_idx);
@@ -125,11 +124,9 @@ public:
int get_connection_output_type(int p_idx);
Color get_connection_output_color(int p_idx);
-
virtual Size2 get_minimum_size() const;
GraphNode();
};
-
#endif // GRAPH_NODE_H
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index debc8e6f2..85d99a6ec 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -28,29 +28,27 @@
/*************************************************************************/
#include "grid_container.h"
-
void GridContainer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_SORT_CHILDREN: {
- Map<int,int> col_minw;
- Map<int,int> row_minh;
+ Map<int, int> col_minw;
+ Map<int, int> row_minh;
Set<int> col_expanded;
Set<int> row_expanded;
- int hsep=get_constant("hseparation");
- int vsep=get_constant("vseparation");
+ int hsep = get_constant("hseparation");
+ int vsep = get_constant("vseparation");
- int idx=0;
- int max_row=0;
- int max_col=0;
+ int idx = 0;
+ int max_row = 0;
+ int max_col = 0;
Size2 size = get_size();
-
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
@@ -61,55 +59,54 @@ void GridContainer::_notification(int p_what) {
Size2i ms = c->get_combined_minimum_size();
if (col_minw.has(col))
- col_minw[col] = MAX(col_minw[col],ms.width);
+ col_minw[col] = MAX(col_minw[col], ms.width);
else
- col_minw[col]=ms.width;
+ col_minw[col] = ms.width;
if (row_minh.has(row))
- row_minh[row] = MAX(row_minh[row],ms.height);
+ row_minh[row] = MAX(row_minh[row], ms.height);
else
- row_minh[row]=ms.height;
+ row_minh[row] = ms.height;
- // print_line("store row "+itos(row)+" mw "+itos(ms.height));
+ // print_line("store row "+itos(row)+" mw "+itos(ms.height));
- if (c->get_h_size_flags()&SIZE_EXPAND)
+ if (c->get_h_size_flags() & SIZE_EXPAND)
col_expanded.insert(col);
- if (c->get_v_size_flags()&SIZE_EXPAND)
+ if (c->get_v_size_flags() & SIZE_EXPAND)
row_expanded.insert(row);
- max_col=MAX(col,max_col);
- max_row=MAX(row,max_row);
+ max_col = MAX(col, max_col);
+ max_row = MAX(row, max_row);
idx++;
}
Size2 ms;
- int expand_rows=0;
- int expand_cols=0;
+ int expand_rows = 0;
+ int expand_cols = 0;
- for (Map<int,int>::Element *E=col_minw.front();E;E=E->next()) {
- ms.width+=E->get();
+ for (Map<int, int>::Element *E = col_minw.front(); E; E = E->next()) {
+ ms.width += E->get();
if (col_expanded.has(E->key()))
expand_cols++;
}
- for (Map<int,int>::Element *E=row_minh.front();E;E=E->next()) {
- ms.height+=E->get();
+ for (Map<int, int>::Element *E = row_minh.front(); E; E = E->next()) {
+ ms.height += E->get();
if (row_expanded.has(E->key()))
expand_rows++;
}
- ms.height+=vsep*max_row;
- ms.width+=hsep*max_col;
-
- int row_expand = expand_rows?(size.y-ms.y)/expand_rows:0;
- int col_expand = expand_cols?(size.x-ms.x)/expand_cols:0;
+ ms.height += vsep * max_row;
+ ms.width += hsep * max_col;
+ int row_expand = expand_rows ? (size.y - ms.y) / expand_rows : 0;
+ int col_expand = expand_cols ? (size.x - ms.x) / expand_cols : 0;
- int col_ofs=0;
- int row_ofs=0;
- idx=0;
+ int col_ofs = 0;
+ int row_ofs = 0;
+ idx = 0;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
@@ -117,78 +114,74 @@ void GridContainer::_notification(int p_what) {
int row = idx / columns;
int col = idx % columns;
- if (col==0) {
- col_ofs=0;
- if (row>0 && row_minh.has(row-1))
- row_ofs+=row_minh[row-1]+vsep+(row_expanded.has(row-1)?row_expand:0);
+ if (col == 0) {
+ col_ofs = 0;
+ if (row > 0 && row_minh.has(row - 1))
+ row_ofs += row_minh[row - 1] + vsep + (row_expanded.has(row - 1) ? row_expand : 0);
}
Size2 s;
if (col_minw.has(col))
- s.width=col_minw[col];
+ s.width = col_minw[col];
if (row_minh.has(row))
- s.height=row_minh[row];
+ s.height = row_minh[row];
if (row_expanded.has(row))
- s.height+=row_expand;
+ s.height += row_expand;
if (col_expanded.has(col))
- s.width+=col_expand;
+ s.width += col_expand;
- Point2 p(col_ofs,row_ofs);
+ Point2 p(col_ofs, row_ofs);
-// print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
- fit_child_in_rect(c,Rect2(p,s));
+ // print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
+ fit_child_in_rect(c, Rect2(p, s));
//print_line("col: "+itos(col)+" row: "+itos(row)+" rect: "+Rect2(p,s));
if (col_minw.has(col)) {
- col_ofs+=col_minw[col]+hsep+(col_expanded.has(col)?col_expand:0);
+ col_ofs += col_minw[col] + hsep + (col_expanded.has(col) ? col_expand : 0);
}
idx++;
}
-
-
} break;
}
-
}
void GridContainer::set_columns(int p_columns) {
- ERR_FAIL_COND(p_columns<1);
- columns=p_columns;
+ ERR_FAIL_COND(p_columns < 1);
+ columns = p_columns;
queue_sort();
minimum_size_changed();
-
}
-int GridContainer::get_columns() const{
+int GridContainer::get_columns() const {
return columns;
}
-void GridContainer::_bind_methods(){
+void GridContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_columns","columns"),&GridContainer::set_columns);
- ObjectTypeDB::bind_method(_MD("get_columns"),&GridContainer::get_columns);
+ ObjectTypeDB::bind_method(_MD("set_columns", "columns"), &GridContainer::set_columns);
+ ObjectTypeDB::bind_method(_MD("get_columns"), &GridContainer::get_columns);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"columns",PROPERTY_HINT_RANGE,"1,1024,1"),_SCS("set_columns"),_SCS("get_columns"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "columns", PROPERTY_HINT_RANGE, "1,1024,1"), _SCS("set_columns"), _SCS("get_columns"));
}
Size2 GridContainer::get_minimum_size() const {
- Map<int,int> col_minw;
- Map<int,int> row_minh;
+ Map<int, int> col_minw;
+ Map<int, int> row_minh;
- int hsep=get_constant("hseparation");
- int vsep=get_constant("vseparation");
+ int hsep = get_constant("hseparation");
+ int vsep = get_constant("vseparation");
- int idx=0;
- int max_row=0;
- int max_col=0;
+ int idx = 0;
+ int max_row = 0;
+ int max_col = 0;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
@@ -197,39 +190,37 @@ Size2 GridContainer::get_minimum_size() const {
int col = idx % columns;
Size2i ms = c->get_combined_minimum_size();
if (col_minw.has(col))
- col_minw[col] = MAX(col_minw[col],ms.width);
+ col_minw[col] = MAX(col_minw[col], ms.width);
else
- col_minw[col]=ms.width;
+ col_minw[col] = ms.width;
if (row_minh.has(row))
- row_minh[row] = MAX(row_minh[row],ms.height);
+ row_minh[row] = MAX(row_minh[row], ms.height);
else
- row_minh[row]=ms.height;
- max_col=MAX(col,max_col);
- max_row=MAX(row,max_row);
+ row_minh[row] = ms.height;
+ max_col = MAX(col, max_col);
+ max_row = MAX(row, max_row);
idx++;
}
Size2 ms;
- for (Map<int,int>::Element *E=col_minw.front();E;E=E->next()) {
- ms.width+=E->get();
+ for (Map<int, int>::Element *E = col_minw.front(); E; E = E->next()) {
+ ms.width += E->get();
}
- for (Map<int,int>::Element *E=row_minh.front();E;E=E->next()) {
- ms.height+=E->get();
+ for (Map<int, int>::Element *E = row_minh.front(); E; E = E->next()) {
+ ms.height += E->get();
}
- ms.height+=vsep*max_row;
- ms.width+=hsep*max_col;
+ ms.height += vsep * max_row;
+ ms.width += hsep * max_col;
return ms;
-
}
-
GridContainer::GridContainer() {
set_stop_mouse(false);
- columns=1;
+ columns = 1;
}
diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h
index 7cf7cb711..fabea8fdb 100644
--- a/scene/gui/grid_container.h
+++ b/scene/gui/grid_container.h
@@ -33,15 +33,15 @@
class GridContainer : public Container {
- OBJ_TYPE(GridContainer,Container);
+ OBJ_TYPE(GridContainer, Container);
int columns;
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_columns(int p_columns);
int get_columns() const;
virtual Size2 get_minimum_size() const;
diff --git a/scene/gui/input_action.cpp b/scene/gui/input_action.cpp
index c4e7a7529..5b5175067 100644
--- a/scene/gui/input_action.cpp
+++ b/scene/gui/input_action.cpp
@@ -1,42 +1,41 @@
#include "input_action.h"
#include "os/keyboard.h"
-void ShortCut::set_shortcut(const InputEvent& p_shortcut){
+void ShortCut::set_shortcut(const InputEvent &p_shortcut) {
- shortcut=p_shortcut;
+ shortcut = p_shortcut;
emit_changed();
}
-InputEvent ShortCut::get_shortcut() const{
+InputEvent ShortCut::get_shortcut() const {
return shortcut;
}
-bool ShortCut::is_shortcut(const InputEvent& p_event) const {
+bool ShortCut::is_shortcut(const InputEvent &p_event) const {
- bool same=false;
+ bool same = false;
-
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::KEY: {
- same=(shortcut.key.scancode==p_event.key.scancode && shortcut.key.mod == p_event.key.mod);
+ same = (shortcut.key.scancode == p_event.key.scancode && shortcut.key.mod == p_event.key.mod);
} break;
case InputEvent::JOYSTICK_BUTTON: {
- same=(shortcut.joy_button.button_index==p_event.joy_button.button_index);
+ same = (shortcut.joy_button.button_index == p_event.joy_button.button_index);
} break;
case InputEvent::MOUSE_BUTTON: {
- same=(shortcut.mouse_button.button_index==p_event.mouse_button.button_index);
+ same = (shortcut.mouse_button.button_index == p_event.mouse_button.button_index);
} break;
case InputEvent::JOYSTICK_MOTION: {
- same=(shortcut.joy_motion.axis==p_event.joy_motion.axis && (shortcut.joy_motion.axis_value < 0) == (p_event.joy_motion.axis_value < 0));
+ same = (shortcut.joy_motion.axis == p_event.joy_motion.axis && (shortcut.joy_motion.axis_value < 0) == (p_event.joy_motion.axis_value < 0));
} break;
default: {};
@@ -47,7 +46,7 @@ bool ShortCut::is_shortcut(const InputEvent& p_event) const {
String ShortCut::get_as_text() const {
- switch(shortcut.type) {
+ switch (shortcut.type) {
case InputEvent::NONE: {
@@ -57,35 +56,35 @@ String ShortCut::get_as_text() const {
String str;
if (shortcut.key.mod.shift)
- str+=RTR("Shift+");
+ str += RTR("Shift+");
if (shortcut.key.mod.alt)
- str+=RTR("Alt+");
+ str += RTR("Alt+");
if (shortcut.key.mod.control)
- str+=RTR("Ctrl+");
+ str += RTR("Ctrl+");
if (shortcut.key.mod.meta)
- str+=RTR("Meta+");
+ str += RTR("Meta+");
- str+=keycode_get_string(shortcut.key.scancode).capitalize();
+ str += keycode_get_string(shortcut.key.scancode).capitalize();
return str;
} break;
case InputEvent::JOYSTICK_BUTTON: {
- String str = RTR("Device")+" "+itos(shortcut.device)+", "+RTR("Button")+" "+itos(shortcut.joy_button.button_index);
- str+=".";
+ String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Button") + " " + itos(shortcut.joy_button.button_index);
+ str += ".";
return str;
} break;
case InputEvent::MOUSE_BUTTON: {
- String str = RTR("Device")+" "+itos(shortcut.device)+", ";
+ String str = RTR("Device") + " " + itos(shortcut.device) + ", ";
switch (shortcut.mouse_button.button_index) {
- case BUTTON_LEFT: str+=RTR("Left Button."); break;
- case BUTTON_RIGHT: str+=RTR("Right Button."); break;
- case BUTTON_MIDDLE: str+=RTR("Middle Button."); break;
- case BUTTON_WHEEL_UP: str+=RTR("Wheel Up."); break;
- case BUTTON_WHEEL_DOWN: str+=RTR("Wheel Down."); break;
- default: str+=RTR("Button")+" "+itos(shortcut.mouse_button.button_index)+".";
+ case BUTTON_LEFT: str += RTR("Left Button."); break;
+ case BUTTON_RIGHT: str += RTR("Right Button."); break;
+ case BUTTON_MIDDLE: str += RTR("Middle Button."); break;
+ case BUTTON_WHEEL_UP: str += RTR("Wheel Up."); break;
+ case BUTTON_WHEEL_DOWN: str += RTR("Wheel Down."); break;
+ default: str += RTR("Button") + " " + itos(shortcut.mouse_button.button_index) + ".";
}
return str;
@@ -93,7 +92,7 @@ String ShortCut::get_as_text() const {
case InputEvent::JOYSTICK_MOTION: {
int ax = shortcut.joy_motion.axis;
- String str = RTR("Device")+" "+itos(shortcut.device)+", "+RTR("Axis")+" "+itos(ax)+".";
+ String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Axis") + " " + itos(ax) + ".";
return str;
} break;
@@ -104,22 +103,21 @@ String ShortCut::get_as_text() const {
bool ShortCut::is_valid() const {
- return shortcut.type!=InputEvent::NONE;
+ return shortcut.type != InputEvent::NONE;
}
void ShortCut::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shortcut","event"),&ShortCut::set_shortcut);
- ObjectTypeDB::bind_method(_MD("get_shortcut"),&ShortCut::get_shortcut);
+ ObjectTypeDB::bind_method(_MD("set_shortcut", "event"), &ShortCut::set_shortcut);
+ ObjectTypeDB::bind_method(_MD("get_shortcut"), &ShortCut::get_shortcut);
- ObjectTypeDB::bind_method(_MD("is_valid"),&ShortCut::is_valid);
+ ObjectTypeDB::bind_method(_MD("is_valid"), &ShortCut::is_valid);
- ObjectTypeDB::bind_method(_MD("is_shortcut","event"),&ShortCut::is_shortcut);
- ObjectTypeDB::bind_method(_MD("get_as_text"),&ShortCut::get_as_text);
+ ObjectTypeDB::bind_method(_MD("is_shortcut", "event"), &ShortCut::is_shortcut);
+ ObjectTypeDB::bind_method(_MD("get_as_text"), &ShortCut::get_as_text);
- ADD_PROPERTY(PropertyInfo(Variant::INPUT_EVENT,"shortcut"),_SCS("set_shortcut"),_SCS("get_shortcut"));
+ ADD_PROPERTY(PropertyInfo(Variant::INPUT_EVENT, "shortcut"), _SCS("set_shortcut"), _SCS("get_shortcut"));
}
-ShortCut::ShortCut(){
-
+ShortCut::ShortCut() {
}
diff --git a/scene/gui/input_action.h b/scene/gui/input_action.h
index 8e0e1ef0b..1aea9096a 100644
--- a/scene/gui/input_action.h
+++ b/scene/gui/input_action.h
@@ -5,17 +5,17 @@
class ShortCut : public Resource {
- OBJ_TYPE(ShortCut,Resource);
+ OBJ_TYPE(ShortCut, Resource);
InputEvent shortcut;
-protected:
+protected:
static void _bind_methods();
-public:
- void set_shortcut(const InputEvent& p_shortcut);
+public:
+ void set_shortcut(const InputEvent &p_shortcut);
InputEvent get_shortcut() const;
- bool is_shortcut(const InputEvent& p_Event) const;
+ bool is_shortcut(const InputEvent &p_Event) const;
bool is_valid() const;
String get_as_text() const;
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 44bdf5ad4..5fc2ee83b 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -27,264 +27,235 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "item_list.h"
-#include "os/os.h"
#include "globals.h"
+#include "os/os.h"
-
-void ItemList::add_item(const String& p_item,const Ref<Texture>& p_texture,bool p_selectable) {
+void ItemList::add_item(const String &p_item, const Ref<Texture> &p_texture, bool p_selectable) {
Item item;
- item.icon=p_texture;
- item.icon_region=Rect2i();
- item.text=p_item;
- item.selectable=p_selectable;
- item.selected=false;
- item.disabled=false;
- item.tooltip_enabled=true;
- item.custom_bg=Color(0,0,0,0);
+ item.icon = p_texture;
+ item.icon_region = Rect2i();
+ item.text = p_item;
+ item.selectable = p_selectable;
+ item.selected = false;
+ item.disabled = false;
+ item.tooltip_enabled = true;
+ item.custom_bg = Color(0, 0, 0, 0);
items.push_back(item);
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-void ItemList::add_icon_item(const Ref<Texture>& p_item,bool p_selectable){
+void ItemList::add_icon_item(const Ref<Texture> &p_item, bool p_selectable) {
Item item;
- item.icon=p_item;
- item.icon_region=Rect2i();
+ item.icon = p_item;
+ item.icon_region = Rect2i();
//item.text=p_item;
- item.selectable=p_selectable;
- item.selected=false;
- item.disabled=false;
- item.tooltip_enabled=true;
- item.custom_bg=Color(0,0,0,0);
+ item.selectable = p_selectable;
+ item.selected = false;
+ item.disabled = false;
+ item.tooltip_enabled = true;
+ item.custom_bg = Color(0, 0, 0, 0);
items.push_back(item);
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-void ItemList::set_item_text(int p_idx,const String& p_text){
+void ItemList::set_item_text(int p_idx, const String &p_text) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- items[p_idx].text=p_text;
+ items[p_idx].text = p_text;
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-String ItemList::get_item_text(int p_idx) const{
+String ItemList::get_item_text(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),String());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), String());
return items[p_idx].text;
-
}
void ItemList::set_item_tooltip_enabled(int p_idx, const bool p_enabled) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
items[p_idx].tooltip_enabled = p_enabled;
}
bool ItemList::is_item_tooltip_enabled(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(), false);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].tooltip_enabled;
}
-void ItemList::set_item_tooltip(int p_idx,const String& p_tooltip){
+void ItemList::set_item_tooltip(int p_idx, const String &p_tooltip) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- items[p_idx].tooltip=p_tooltip;
+ items[p_idx].tooltip = p_tooltip;
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-String ItemList::get_item_tooltip(int p_idx) const{
+String ItemList::get_item_tooltip(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),String());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), String());
return items[p_idx].tooltip;
-
}
-void ItemList::set_item_icon(int p_idx,const Ref<Texture>& p_icon){
+void ItemList::set_item_icon(int p_idx, const Ref<Texture> &p_icon) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- items[p_idx].icon=p_icon;
+ items[p_idx].icon = p_icon;
update();
- shape_changed=true;
-
-
+ shape_changed = true;
}
-Ref<Texture> ItemList::get_item_icon(int p_idx) const{
+Ref<Texture> ItemList::get_item_icon(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>());
return items[p_idx].icon;
-
}
-void ItemList::set_item_icon_region(int p_idx,const Rect2& p_region) {
+void ItemList::set_item_icon_region(int p_idx, const Rect2 &p_region) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- items[p_idx].icon_region=p_region;
+ items[p_idx].icon_region = p_region;
update();
- shape_changed=true;
+ shape_changed = true;
}
Rect2 ItemList::get_item_icon_region(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),Rect2());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Rect2());
return items[p_idx].icon_region;
}
-void ItemList::set_item_custom_bg_color(int p_idx,const Color& p_custom_bg_color) {
-
- ERR_FAIL_INDEX(p_idx,items.size());
+void ItemList::set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color) {
- items[p_idx].custom_bg=p_custom_bg_color;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].custom_bg = p_custom_bg_color;
}
Color ItemList::get_item_custom_bg_color(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),Color());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
return items[p_idx].custom_bg;
-
}
+void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) {
+ ERR_FAIL_INDEX(p_idx, items.size());
-void ItemList::set_item_tag_icon(int p_idx,const Ref<Texture>& p_tag_icon){
-
- ERR_FAIL_INDEX(p_idx,items.size());
-
- items[p_idx].tag_icon=p_tag_icon;
+ items[p_idx].tag_icon = p_tag_icon;
update();
- shape_changed=true;
-
-
+ shape_changed = true;
}
-Ref<Texture> ItemList::get_item_tag_icon(int p_idx) const{
+Ref<Texture> ItemList::get_item_tag_icon(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>());
return items[p_idx].tag_icon;
-
}
-void ItemList::set_item_selectable(int p_idx,bool p_selectable){
-
- ERR_FAIL_INDEX(p_idx,items.size());
-
- items[p_idx].selectable=p_selectable;
+void ItemList::set_item_selectable(int p_idx, bool p_selectable) {
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].selectable = p_selectable;
}
+bool ItemList::is_item_selectable(int p_idx) const {
-bool ItemList::is_item_selectable(int p_idx) const{
-
- ERR_FAIL_INDEX_V(p_idx,items.size(),false);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].selectable;
}
-void ItemList::set_item_disabled(int p_idx,bool p_disabled){
+void ItemList::set_item_disabled(int p_idx, bool p_disabled) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- items[p_idx].disabled=p_disabled;
+ items[p_idx].disabled = p_disabled;
update();
-
}
+bool ItemList::is_item_disabled(int p_idx) const {
-bool ItemList::is_item_disabled(int p_idx) const{
-
- ERR_FAIL_INDEX_V(p_idx,items.size(),false);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].disabled;
}
+void ItemList::set_item_metadata(int p_idx, const Variant &p_metadata) {
-void ItemList::set_item_metadata(int p_idx,const Variant& p_metadata){
-
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- items[p_idx].metadata=p_metadata;
+ items[p_idx].metadata = p_metadata;
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-Variant ItemList::get_item_metadata(int p_idx) const{
+Variant ItemList::get_item_metadata(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),Variant());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Variant());
return items[p_idx].metadata;
-
}
-void ItemList::select(int p_idx,bool p_single){
+void ItemList::select(int p_idx, bool p_single) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- if (p_single || select_mode==SELECT_SINGLE) {
+ if (p_single || select_mode == SELECT_SINGLE) {
if (!items[p_idx].selectable || items[p_idx].disabled) {
return;
}
- for(int i=0;i<items.size();i++) {
- items[i].selected=p_idx==i;
+ for (int i = 0; i < items.size(); i++) {
+ items[i].selected = p_idx == i;
}
- current=p_idx;
- ensure_selected_visible=false;
+ current = p_idx;
+ ensure_selected_visible = false;
} else {
if (items[p_idx].selectable && !items[p_idx].disabled) {
- items[p_idx].selected=true;
+ items[p_idx].selected = true;
}
}
update();
-
-
}
-void ItemList::unselect(int p_idx){
+void ItemList::unselect(int p_idx) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- if (select_mode!=SELECT_MULTI) {
- items[p_idx].selected=false;
- current=-1;
+ if (select_mode != SELECT_MULTI) {
+ items[p_idx].selected = false;
+ current = -1;
} else {
- items[p_idx].selected=false;
+ items[p_idx].selected = false;
}
update();
-
}
-bool ItemList::is_selected(int p_idx) const{
+bool ItemList::is_selected(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),false);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].selected;
-
}
void ItemList::set_current(int p_current) {
- ERR_FAIL_INDEX(p_current,items.size());
+ ERR_FAIL_INDEX(p_current, items.size());
- if (select_mode==SELECT_SINGLE)
- select(p_current,true);
+ if (select_mode == SELECT_SINGLE)
+ select(p_current, true);
else {
- current=p_current;
+ current = p_current;
update();
}
}
@@ -294,117 +265,111 @@ int ItemList::get_current() const {
return current;
}
-void ItemList::move_item(int p_item,int p_to_pos) {
+void ItemList::move_item(int p_item, int p_to_pos) {
- ERR_FAIL_INDEX(p_item,items.size());
- ERR_FAIL_INDEX(p_to_pos,items.size()+1);
+ ERR_FAIL_INDEX(p_item, items.size());
+ ERR_FAIL_INDEX(p_to_pos, items.size() + 1);
- Item it=items[p_item];
+ Item it = items[p_item];
items.remove(p_item);
- if (p_to_pos>p_item) {
+ if (p_to_pos > p_item) {
p_to_pos--;
}
- if (p_to_pos>=items.size()) {
+ if (p_to_pos >= items.size()) {
items.push_back(it);
} else {
- items.insert(p_to_pos,it);
+ items.insert(p_to_pos, it);
}
- if (current<0) {
+ if (current < 0) {
//do none
- } if (p_item==current) {
- current=p_to_pos;
- } else if (p_to_pos>p_item && current>p_item && current<p_to_pos) {
+ }
+ if (p_item == current) {
+ current = p_to_pos;
+ } else if (p_to_pos > p_item && current > p_item && current < p_to_pos) {
current--;
- } else if (p_to_pos<p_item && current<p_item && current>p_to_pos) {
+ } else if (p_to_pos < p_item && current < p_item && current > p_to_pos) {
current++;
}
-
update();
}
-int ItemList::get_item_count() const{
+int ItemList::get_item_count() const {
return items.size();
}
-void ItemList::remove_item(int p_idx){
+void ItemList::remove_item(int p_idx) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
items.remove(p_idx);
update();
- shape_changed=true;
- defer_select_single=-1;
-
-
+ shape_changed = true;
+ defer_select_single = -1;
}
-void ItemList::clear(){
+void ItemList::clear() {
items.clear();
- current=-1;
- ensure_selected_visible=false;
+ current = -1;
+ ensure_selected_visible = false;
update();
- shape_changed=true;
- defer_select_single=-1;
-
+ shape_changed = true;
+ defer_select_single = -1;
}
-void ItemList::set_fixed_column_width(int p_size){
+void ItemList::set_fixed_column_width(int p_size) {
- ERR_FAIL_COND(p_size<0);
- fixed_column_width=p_size;
+ ERR_FAIL_COND(p_size < 0);
+ fixed_column_width = p_size;
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-int ItemList::get_fixed_column_width() const{
+int ItemList::get_fixed_column_width() const {
return fixed_column_width;
}
-void ItemList::set_same_column_width(bool p_enable){
+void ItemList::set_same_column_width(bool p_enable) {
- same_column_width=p_enable;
+ same_column_width = p_enable;
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-int ItemList::is_same_column_width() const{
+int ItemList::is_same_column_width() const {
return same_column_width;
}
-void ItemList::set_max_text_lines(int p_lines){
+void ItemList::set_max_text_lines(int p_lines) {
- ERR_FAIL_COND(p_lines<1);
- max_text_lines=p_lines;
+ ERR_FAIL_COND(p_lines < 1);
+ max_text_lines = p_lines;
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-int ItemList::get_max_text_lines() const{
+int ItemList::get_max_text_lines() const {
return max_text_lines;
}
-void ItemList::set_max_columns(int p_amount){
+void ItemList::set_max_columns(int p_amount) {
- ERR_FAIL_COND(p_amount<0);
- max_columns=p_amount;
+ ERR_FAIL_COND(p_amount < 0);
+ max_columns = p_amount;
update();
}
-int ItemList::get_max_columns() const{
+int ItemList::get_max_columns() const {
return max_columns;
}
void ItemList::set_select_mode(SelectMode p_mode) {
- select_mode=p_mode;
+ select_mode = p_mode;
update();
}
@@ -413,22 +378,20 @@ ItemList::SelectMode ItemList::get_select_mode() const {
return select_mode;
}
-void ItemList::set_icon_mode(IconMode p_mode){
+void ItemList::set_icon_mode(IconMode p_mode) {
- icon_mode=p_mode;
+ icon_mode = p_mode;
update();
- shape_changed=true;
-
+ shape_changed = true;
}
-ItemList::IconMode ItemList::get_icon_mode() const{
+ItemList::IconMode ItemList::get_icon_mode() const {
return icon_mode;
}
+void ItemList::set_fixed_icon_size(const Size2 &p_size) {
-void ItemList::set_fixed_icon_size(const Size2& p_size) {
-
- fixed_icon_size=p_size;
+ fixed_icon_size = p_size;
update();
}
@@ -446,151 +409,142 @@ Size2 ItemList::Item::get_icon_size() const {
return icon_region.size;
}
-void ItemList::_input_event(const InputEvent& p_event) {
+void ItemList::_input_event(const InputEvent &p_event) {
- if (defer_select_single>=0 && p_event.type==InputEvent::MOUSE_MOTION) {
- defer_select_single=-1;
+ if (defer_select_single >= 0 && p_event.type == InputEvent::MOUSE_MOTION) {
+ defer_select_single = -1;
return;
}
- if (defer_select_single>=0 && p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT && !p_event.mouse_button.pressed) {
+ if (defer_select_single >= 0 && p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_LEFT && !p_event.mouse_button.pressed) {
- select(defer_select_single,true);
+ select(defer_select_single, true);
-
- emit_signal("multi_selected",defer_select_single,true);
- defer_select_single=-1;
+ emit_signal("multi_selected", defer_select_single, true);
+ defer_select_single = -1;
return;
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && (p_event.mouse_button.button_index==BUTTON_LEFT || (allow_rmb_select && p_event.mouse_button.button_index==BUTTON_RIGHT)) && p_event.mouse_button.pressed) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && (p_event.mouse_button.button_index == BUTTON_LEFT || (allow_rmb_select && p_event.mouse_button.button_index == BUTTON_RIGHT)) && p_event.mouse_button.pressed) {
const InputEventMouseButton &mb = p_event.mouse_button;
- search_string=""; //any mousepress cancels
- Vector2 pos(mb.x,mb.y);
+ search_string = ""; //any mousepress cancels
+ Vector2 pos(mb.x, mb.y);
Ref<StyleBox> bg = get_stylebox("bg");
- pos-=bg->get_offset();
- pos.y+=scroll_bar->get_val();
+ pos -= bg->get_offset();
+ pos.y += scroll_bar->get_val();
int closest = -1;
- for(int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
Rect2 rc = items[i].rect_cache;
- if (i%current_columns==current_columns-1) {
- rc.size.width=get_size().width; //not right but works
+ if (i % current_columns == current_columns - 1) {
+ rc.size.width = get_size().width; //not right but works
}
if (rc.has_point(pos)) {
- closest=i;
+ closest = i;
break;
}
}
- if (closest!=-1) {
+ if (closest != -1) {
int i = closest;
- if (select_mode==SELECT_MULTI && items[i].selected && mb.mod.command) {
+ if (select_mode == SELECT_MULTI && items[i].selected && mb.mod.command) {
unselect(i);
- emit_signal("multi_selected",i,false);
+ emit_signal("multi_selected", i, false);
- } else if (select_mode==SELECT_MULTI && mb.mod.shift && current>=0 && current<items.size() && current!=i) {
+ } else if (select_mode == SELECT_MULTI && mb.mod.shift && current >= 0 && current < items.size() && current != i) {
int from = current;
int to = i;
- if (i<current) {
- SWAP(from,to);
+ if (i < current) {
+ SWAP(from, to);
}
- for(int j=from;j<=to;j++) {
+ for (int j = from; j <= to; j++) {
bool selected = !items[j].selected;
- select(j,false);
+ select(j, false);
if (selected)
- emit_signal("multi_selected",i,true);
+ emit_signal("multi_selected", i, true);
}
- if (p_event.mouse_button.button_index==BUTTON_RIGHT) {
+ if (p_event.mouse_button.button_index == BUTTON_RIGHT) {
- emit_signal("item_rmb_selected",i,Vector2(mb.x,mb.y));
+ emit_signal("item_rmb_selected", i, Vector2(mb.x, mb.y));
}
} else {
- if (!mb.doubleclick && !mb.mod.command && select_mode==SELECT_MULTI && items[i].selectable && !items[i].disabled && items[i].selected && p_event.mouse_button.button_index==BUTTON_LEFT) {
- defer_select_single=i;
+ if (!mb.doubleclick && !mb.mod.command && select_mode == SELECT_MULTI && items[i].selectable && !items[i].disabled && items[i].selected && p_event.mouse_button.button_index == BUTTON_LEFT) {
+ defer_select_single = i;
return;
}
- if (items[i].selected && p_event.mouse_button.button_index==BUTTON_RIGHT) {
+ if (items[i].selected && p_event.mouse_button.button_index == BUTTON_RIGHT) {
- emit_signal("item_rmb_selected",i,Vector2(mb.x,mb.y));
+ emit_signal("item_rmb_selected", i, Vector2(mb.x, mb.y));
} else {
bool selected = !items[i].selected;
-
- select(i,select_mode==SELECT_SINGLE || !mb.mod.command);
+ select(i, select_mode == SELECT_SINGLE || !mb.mod.command);
if (selected) {
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",i);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", i);
} else
- emit_signal("multi_selected",i,true);
-
-
+ emit_signal("multi_selected", i, true);
}
- if (p_event.mouse_button.button_index==BUTTON_RIGHT) {
+ if (p_event.mouse_button.button_index == BUTTON_RIGHT) {
- emit_signal("item_rmb_selected",i,Vector2(mb.x,mb.y));
+ emit_signal("item_rmb_selected", i, Vector2(mb.x, mb.y));
} else if (/*select_mode==SELECT_SINGLE &&*/ mb.doubleclick) {
- emit_signal("item_activated",i);
-
+ emit_signal("item_activated", i);
}
}
}
-
return;
} else {
Vector<int> sItems = get_selected_items();
- for(int i = 0; i < sItems.size(); i++) {
+ for (int i = 0; i < sItems.size(); i++) {
unselect(sItems[i]);
}
}
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
-
- scroll_bar->set_val( scroll_bar->get_val()-scroll_bar->get_page()/8 );
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
+ scroll_bar->set_val(scroll_bar->get_val() - scroll_bar->get_page() / 8);
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) {
-
- scroll_bar->set_val( scroll_bar->get_val()+scroll_bar->get_page()/8 );
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) {
+ scroll_bar->set_val(scroll_bar->get_val() + scroll_bar->get_page() / 8);
}
- if (p_event.is_pressed() && items.size()>0) {
+ if (p_event.is_pressed() && items.size() > 0) {
if (p_event.is_action("ui_up")) {
- if (search_string!="") {
+ if (search_string != "") {
uint64_t now = OS::get_singleton()->get_ticks_msec();
- uint64_t diff = now-search_time_msec;
+ uint64_t diff = now - search_time_msec;
- if (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) {
+ if (diff < int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec")) * 2) {
- for(int i=current-1;i>=0;i--) {
+ for (int i = current - 1; i >= 0; i--) {
if (items[i].text.begins_with(search_string)) {
set_current(i);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
-
break;
}
}
@@ -599,31 +553,31 @@ void ItemList::_input_event(const InputEvent& p_event) {
}
}
- if (current>=current_columns) {
- set_current(current-current_columns);
+ if (current >= current_columns) {
+ set_current(current - current_columns);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
accept_event();
}
} else if (p_event.is_action("ui_down")) {
- if (search_string!="") {
+ if (search_string != "") {
uint64_t now = OS::get_singleton()->get_ticks_msec();
- uint64_t diff = now-search_time_msec;
+ uint64_t diff = now - search_time_msec;
- if (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) {
+ if (diff < int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec")) * 2) {
- for(int i=current+1;i<items.size();i++) {
+ for (int i = current + 1; i < items.size(); i++) {
if (items[i].text.begins_with(search_string)) {
set_current(i);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
break;
}
@@ -633,25 +587,24 @@ void ItemList::_input_event(const InputEvent& p_event) {
}
}
- if (current<items.size()-current_columns) {
- set_current(current+current_columns);
+ if (current < items.size() - current_columns) {
+ set_current(current + current_columns);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
accept_event();
-
}
} else if (p_event.is_action("ui_page_up")) {
- search_string=""; //any mousepress cancels
+ search_string = ""; //any mousepress cancels
- for(int i=4;i>0;i--) {
- if (current-current_columns*i >=0 ) {
- set_current( current- current_columns*i);
+ for (int i = 4; i > 0; i--) {
+ if (current - current_columns * i >= 0) {
+ set_current(current - current_columns * i);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
accept_event();
break;
@@ -659,14 +612,14 @@ void ItemList::_input_event(const InputEvent& p_event) {
}
} else if (p_event.is_action("ui_page_down")) {
- search_string=""; //any mousepress cancels
+ search_string = ""; //any mousepress cancels
- for(int i=4;i>0;i--) {
- if (current+current_columns*i < items.size() ) {
- set_current( current+ current_columns*i);
+ for (int i = 4; i > 0; i--) {
+ if (current + current_columns * i < items.size()) {
+ set_current(current + current_columns * i);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
accept_event();
@@ -675,147 +628,135 @@ void ItemList::_input_event(const InputEvent& p_event) {
}
} else if (p_event.is_action("ui_left")) {
- search_string=""; //any mousepress cancels
+ search_string = ""; //any mousepress cancels
- if (current%current_columns!=0) {
- set_current(current-1);
+ if (current % current_columns != 0) {
+ set_current(current - 1);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
accept_event();
-
}
} else if (p_event.is_action("ui_right")) {
- search_string=""; //any mousepress cancels
+ search_string = ""; //any mousepress cancels
- if (current%current_columns!=(current_columns-1)) {
- set_current(current+1);
+ if (current % current_columns != (current_columns - 1)) {
+ set_current(current + 1);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
accept_event();
-
}
} else if (p_event.is_action("ui_cancel")) {
- search_string="";
+ search_string = "";
} else if (p_event.is_action("ui_select")) {
-
- if (select_mode==SELECT_MULTI && current>=0 && current<items.size()) {
+ if (select_mode == SELECT_MULTI && current >= 0 && current < items.size()) {
if (items[current].selectable && !items[current].disabled && !items[current].selected) {
- select(current,false);
- emit_signal("multi_selected",current,true);
+ select(current, false);
+ emit_signal("multi_selected", current, true);
} else if (items[current].selected) {
unselect(current);
- emit_signal("multi_selected",current,false);
+ emit_signal("multi_selected", current, false);
}
}
} else if (p_event.is_action("ui_accept")) {
- search_string=""; //any mousepress cance
+ search_string = ""; //any mousepress cance
- if (current>=0 && current<items.size()) {
- emit_signal("item_activated",current);
+ if (current >= 0 && current < items.size()) {
+ emit_signal("item_activated", current);
}
- } else if (p_event.type==InputEvent::KEY) {
+ } else if (p_event.type == InputEvent::KEY) {
if (p_event.key.unicode) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
- uint64_t diff = now-search_time_msec;
- uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000));
+ uint64_t diff = now - search_time_msec;
+ uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec", 2000));
search_time_msec = now;
- if (diff>max_interval) {
- search_string="";
+ if (diff > max_interval) {
+ search_string = "";
}
- search_string+=String::chr(p_event.key.unicode);
- for(int i=0;i<items.size();i++) {
+ search_string += String::chr(p_event.key.unicode);
+ for (int i = 0; i < items.size(); i++) {
if (items[i].text.begins_with(search_string)) {
set_current(i);
ensure_current_is_visible();
- if (select_mode==SELECT_SINGLE) {
- emit_signal("item_selected",current);
+ if (select_mode == SELECT_SINGLE) {
+ emit_signal("item_selected", current);
}
break;
}
}
-
}
-
}
}
-
-
-
-
}
void ItemList::ensure_current_is_visible() {
- ensure_selected_visible=true;
+ ensure_selected_visible = true;
update();
}
static Rect2 _adjust_to_max_size(Size2 p_size, Size2 p_max_size) {
- Size2 size=p_max_size;
+ Size2 size = p_max_size;
int tex_width = p_size.width * size.height / p_size.height;
int tex_height = size.height;
- if (tex_width>size.width) {
- tex_width=size.width;
- tex_height=p_size.height * tex_width / p_size.width;
+ if (tex_width > size.width) {
+ tex_width = size.width;
+ tex_height = p_size.height * tex_width / p_size.width;
}
- int ofs_x=(size.width - tex_width)/2;
- int ofs_y=(size.height - tex_height)/2;
-
- return Rect2(ofs_x,ofs_y,tex_width,tex_height);
-
+ int ofs_x = (size.width - tex_width) / 2;
+ int ofs_y = (size.height - tex_height) / 2;
+ return Rect2(ofs_x, ofs_y, tex_width, tex_height);
}
void ItemList::_notification(int p_what) {
- if (p_what==NOTIFICATION_RESIZED) {
- shape_changed=true;
+ if (p_what == NOTIFICATION_RESIZED) {
+ shape_changed = true;
update();
}
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
- VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
+ VS::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
Ref<StyleBox> bg = get_stylebox("bg");
int mw = scroll_bar->get_minimum_size().x;
- scroll_bar->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,mw+bg->get_margin(MARGIN_RIGHT));
- scroll_bar->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,bg->get_margin(MARGIN_RIGHT));
- scroll_bar->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,bg->get_margin(MARGIN_TOP));
- scroll_bar->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,bg->get_margin(MARGIN_BOTTOM));
-
+ scroll_bar->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, mw + bg->get_margin(MARGIN_RIGHT));
+ scroll_bar->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, bg->get_margin(MARGIN_RIGHT));
+ scroll_bar->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, bg->get_margin(MARGIN_TOP));
+ scroll_bar->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, bg->get_margin(MARGIN_BOTTOM));
Size2 size = get_size();
- float page = size.height-bg->get_minimum_size().height;
- int width = size.width-bg->get_minimum_size().width;
- if (!scroll_bar->is_hidden()){
- width-=mw+bg->get_margin(MARGIN_RIGHT);
+ float page = size.height - bg->get_minimum_size().height;
+ int width = size.width - bg->get_minimum_size().width;
+ if (!scroll_bar->is_hidden()) {
+ width -= mw + bg->get_margin(MARGIN_RIGHT);
}
scroll_bar->set_page(page);
- draw_style_box(bg,Rect2(Point2(),size));
+ draw_style_box(bg, Rect2(Point2(), size));
int hseparation = get_constant("hseparation");
int vseparation = get_constant("vseparation");
int icon_margin = get_constant("icon_margin");
int line_separation = get_constant("line_separation");
- Ref<StyleBox> sbsel = has_focus()?get_stylebox("selected_focus"):get_stylebox("selected");
- Ref<StyleBox> cursor = has_focus()?get_stylebox("cursor"):get_stylebox("cursor_unfocused");
+ Ref<StyleBox> sbsel = has_focus() ? get_stylebox("selected_focus") : get_stylebox("selected");
+ Ref<StyleBox> cursor = has_focus() ? get_stylebox("cursor") : get_stylebox("cursor_unfocused");
Ref<Font> font = get_font("font");
Color guide_color = get_color("guide_color");
@@ -831,9 +772,9 @@ void ItemList::_notification(int p_what) {
}
if (has_focus()) {
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(),true);
- draw_style_box(get_stylebox("bg_focus"),Rect2(Point2(),size));
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(),false);
+ VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), true);
+ draw_style_box(get_stylebox("bg_focus"), Rect2(Point2(), size));
+ VisualServer::get_singleton()->canvas_item_add_clip_ignore(get_canvas_item(), false);
}
if (shape_changed) {
@@ -841,114 +782,109 @@ void ItemList::_notification(int p_what) {
float max_column_width = 0;
//1- compute item minimum sizes
- for(int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
Size2 minsize;
if (items[i].icon.is_valid()) {
- if (fixed_icon_size.x>0 && fixed_icon_size.y>0) {
- minsize=fixed_icon_size* icon_scale;
+ if (fixed_icon_size.x > 0 && fixed_icon_size.y > 0) {
+ minsize = fixed_icon_size * icon_scale;
} else {
- minsize=items[i].get_icon_size() *icon_scale;
+ minsize = items[i].get_icon_size() * icon_scale;
}
- if (items[i].text!="") {
- if (icon_mode==ICON_MODE_TOP) {
- minsize.y+=icon_margin;
+ if (items[i].text != "") {
+ if (icon_mode == ICON_MODE_TOP) {
+ minsize.y += icon_margin;
} else {
- minsize.x+=icon_margin;
+ minsize.x += icon_margin;
}
}
}
- if (items[i].text!="") {
+ if (items[i].text != "") {
Size2 s = font->get_string_size(items[i].text);
//s.width=MIN(s.width,fixed_column_width);
-
-
- if (icon_mode==ICON_MODE_TOP) {
- minsize.x=MAX(minsize.x,s.width);
- if (max_text_lines>0) {
- minsize.y+=(font_height+line_separation)*max_text_lines;
+ if (icon_mode == ICON_MODE_TOP) {
+ minsize.x = MAX(minsize.x, s.width);
+ if (max_text_lines > 0) {
+ minsize.y += (font_height + line_separation) * max_text_lines;
} else {
- minsize.y+=s.height;
+ minsize.y += s.height;
}
} else {
- minsize.y=MAX(minsize.y,s.height);
- minsize.x+=s.width;
+ minsize.y = MAX(minsize.y, s.height);
+ minsize.x += s.width;
}
}
-
- if (fixed_column_width>0)
- minsize.x=fixed_column_width;
- max_column_width=MAX(max_column_width,minsize.x);
- items[i].rect_cache.size=minsize;
- items[i].min_rect_cache.size=minsize;
-
+ if (fixed_column_width > 0)
+ minsize.x = fixed_column_width;
+ max_column_width = MAX(max_column_width, minsize.x);
+ items[i].rect_cache.size = minsize;
+ items[i].min_rect_cache.size = minsize;
}
int fit_size = size.x - bg->get_minimum_size().width - mw;
//2-attempt best fit
current_columns = 0x7FFFFFFF;
- if (max_columns>0)
- current_columns=max_columns;
-
+ if (max_columns > 0)
+ current_columns = max_columns;
- while(true) {
+ while (true) {
//repeat util all fits
//print_line("try with "+itos(current_columns));
- bool all_fit=true;
+ bool all_fit = true;
Vector2 ofs;
- int col=0;
- int max_h=0;
+ int col = 0;
+ int max_h = 0;
separators.clear();
- for(int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
- if (current_columns>1 && items[i].rect_cache.size.width+ofs.x > fit_size) {
+ if (current_columns > 1 && items[i].rect_cache.size.width + ofs.x > fit_size) {
//went past
- current_columns=MAX(col,1);
- all_fit=false;
+ current_columns = MAX(col, 1);
+ all_fit = false;
break;
}
- items[i].rect_cache=items[i].min_rect_cache;
- if(same_column_width)
- items[i].rect_cache.size.x=max_column_width;
- items[i].rect_cache.pos=ofs;
- max_h=MAX(max_h,items[i].rect_cache.size.y);
- ofs.x+=items[i].rect_cache.size.x + hseparation;
+ items[i].rect_cache = items[i].min_rect_cache;
+ if (same_column_width)
+ items[i].rect_cache.size.x = max_column_width;
+ items[i].rect_cache.pos = ofs;
+ max_h = MAX(max_h, items[i].rect_cache.size.y);
+ ofs.x += items[i].rect_cache.size.x + hseparation;
//print_line("item "+itos(i)+" ofs "+rtos(items[i].rect_cache.size.x));
col++;
- if (col==current_columns) {
+ if (col == current_columns) {
- if (i<items.size()-1)
- separators.push_back(ofs.y+max_h+vseparation/2);
+ if (i < items.size() - 1)
+ separators.push_back(ofs.y + max_h + vseparation / 2);
- for(int j=i;j>=0 && col>0;j--, col--) {
+ for (int j = i; j >= 0 && col > 0; j--, col--) {
items[j].rect_cache.size.y = max_h;
}
- ofs.x=0;
- ofs.y+=max_h+vseparation;
- col=0;
- max_h=0;
+ ofs.x = 0;
+ ofs.y += max_h + vseparation;
+ col = 0;
+ max_h = 0;
}
}
- for(int j=items.size()-1;j>=0 && col>0;j--, col--) {
+ for (int j = items.size() - 1; j >= 0 && col > 0; j--, col--) {
items[j].rect_cache.size.y = max_h;
}
if (all_fit) {
- float max = MAX(page,ofs.y+max_h);
+ float max = MAX(page, ofs.y + max_h);
scroll_bar->set_max(max);
//print_line("max: "+rtos(max)+" page "+rtos(page));
- if (max<=page) {
+ if (max <= page) {
scroll_bar->set_val(0);
scroll_bar->hide();
} else {
@@ -958,12 +894,11 @@ void ItemList::_notification(int p_what) {
}
}
-
- shape_changed=false;
+ shape_changed = false;
}
//ensure_selected_visible needs to be checked before we draw the list.
- if (ensure_selected_visible && current>=0 && current <=items.size()) {
+ if (ensure_selected_visible && current >= 0 && current <= items.size()) {
Rect2 r = items[current].rect_cache;
int from = scroll_bar->get_val();
@@ -971,200 +906,188 @@ void ItemList::_notification(int p_what) {
if (r.pos.y < from) {
scroll_bar->set_val(r.pos.y);
- } else if (r.pos.y+r.size.y > to) {
- scroll_bar->set_val(r.pos.y+r.size.y - (to-from));
+ } else if (r.pos.y + r.size.y > to) {
+ scroll_bar->set_val(r.pos.y + r.size.y - (to - from));
}
-
-
}
- ensure_selected_visible=false;
+ ensure_selected_visible = false;
Vector2 base_ofs = bg->get_offset();
- base_ofs.y-=int(scroll_bar->get_val());
+ base_ofs.y -= int(scroll_bar->get_val());
- Rect2 clip(Point2(),size-bg->get_minimum_size()+Vector2(0,scroll_bar->get_val()));
-
- for(int i=0;i<items.size();i++) {
+ Rect2 clip(Point2(), size - bg->get_minimum_size() + Vector2(0, scroll_bar->get_val()));
+ for (int i = 0; i < items.size(); i++) {
Rect2 rcache = items[i].rect_cache;
if (!clip.intersects(rcache))
continue;
-
- if (current_columns==1) {
- rcache.size.width = width-rcache.pos.x;
+ if (current_columns == 1) {
+ rcache.size.width = width - rcache.pos.x;
}
- Rect2 r=rcache;
- r.pos+=base_ofs;
+ Rect2 r = rcache;
+ r.pos += base_ofs;
// Use stylebox to dimension potential bg color, even if not selected
- r.pos.x-=sbsel->get_margin(MARGIN_LEFT);
- r.size.x+=sbsel->get_margin(MARGIN_LEFT)+sbsel->get_margin(MARGIN_RIGHT);
- r.pos.y-=sbsel->get_margin(MARGIN_TOP);
- r.size.y+=sbsel->get_margin(MARGIN_TOP)+sbsel->get_margin(MARGIN_BOTTOM);
+ r.pos.x -= sbsel->get_margin(MARGIN_LEFT);
+ r.size.x += sbsel->get_margin(MARGIN_LEFT) + sbsel->get_margin(MARGIN_RIGHT);
+ r.pos.y -= sbsel->get_margin(MARGIN_TOP);
+ r.size.y += sbsel->get_margin(MARGIN_TOP) + sbsel->get_margin(MARGIN_BOTTOM);
if (items[i].selected) {
- draw_style_box(sbsel,r);
+ draw_style_box(sbsel, r);
}
- if (items[i].custom_bg.a>0.001) {
- r.pos.x+=2;
- r.size.x-=4;
- r.pos.y+=2;
- r.size.y-=4;
- draw_rect(r,items[i].custom_bg);
+ if (items[i].custom_bg.a > 0.001) {
+ r.pos.x += 2;
+ r.size.x -= 4;
+ r.pos.y += 2;
+ r.size.y -= 4;
+ draw_rect(r, items[i].custom_bg);
}
-
Vector2 text_ofs;
if (items[i].icon.is_valid()) {
Size2 icon_size;
//= _adjust_to_max_size(items[i].get_icon_size(),fixed_icon_size) * icon_scale;
- if (fixed_icon_size.x>0 && fixed_icon_size.y>0) {
- icon_size=fixed_icon_size* icon_scale;
+ if (fixed_icon_size.x > 0 && fixed_icon_size.y > 0) {
+ icon_size = fixed_icon_size * icon_scale;
} else {
- icon_size=items[i].get_icon_size() *icon_scale;
-
+ icon_size = items[i].get_icon_size() * icon_scale;
}
Vector2 icon_ofs;
Point2 pos = items[i].rect_cache.pos + icon_ofs + base_ofs;
- if (icon_mode==ICON_MODE_TOP) {
+ if (icon_mode == ICON_MODE_TOP) {
- pos.x += Math::floor((items[i].rect_cache.size.width - icon_size.width)/2);
+ pos.x += Math::floor((items[i].rect_cache.size.width - icon_size.width) / 2);
pos.y += MIN(
- Math::floor((items[i].rect_cache.size.height - icon_size.height)/2),
- items[i].rect_cache.size.height - items[i].min_rect_cache.size.height
- );
+ Math::floor((items[i].rect_cache.size.height - icon_size.height) / 2),
+ items[i].rect_cache.size.height - items[i].min_rect_cache.size.height);
text_ofs.y = icon_size.height + icon_margin;
text_ofs.y += items[i].rect_cache.size.height - items[i].min_rect_cache.size.height;
} else {
- pos.y += Math::floor((items[i].rect_cache.size.height - icon_size.height)/2);
+ pos.y += Math::floor((items[i].rect_cache.size.height - icon_size.height) / 2);
text_ofs.x = icon_size.width + icon_margin;
}
- Rect2 draw_rect=Rect2(pos,icon_size);
+ Rect2 draw_rect = Rect2(pos, icon_size);
- if (fixed_icon_size.x>0 && fixed_icon_size.y>0) {
- Rect2 adj = _adjust_to_max_size(items[i].get_icon_size() * icon_scale,icon_size);
- draw_rect.pos+=adj.pos;
- draw_rect.size=adj.size;
+ if (fixed_icon_size.x > 0 && fixed_icon_size.y > 0) {
+ Rect2 adj = _adjust_to_max_size(items[i].get_icon_size() * icon_scale, icon_size);
+ draw_rect.pos += adj.pos;
+ draw_rect.size = adj.size;
}
- Color modulate=Color(1,1,1,1);
+ Color modulate = Color(1, 1, 1, 1);
if (items[i].disabled)
- modulate.a*=0.5;
+ modulate.a *= 0.5;
if (items[i].icon_region.has_no_area())
- draw_texture_rect(items[i].icon, draw_rect,false,modulate );
+ draw_texture_rect(items[i].icon, draw_rect, false, modulate);
else
- draw_texture_rect_region(items[i].icon, draw_rect, items[i].icon_region,modulate);
-
+ draw_texture_rect_region(items[i].icon, draw_rect, items[i].icon_region, modulate);
}
if (items[i].tag_icon.is_valid()) {
- draw_texture(items[i].tag_icon,items[i].rect_cache.pos+base_ofs);
+ draw_texture(items[i].tag_icon, items[i].rect_cache.pos + base_ofs);
}
- if (items[i].text!="") {
+ if (items[i].text != "") {
- int max_len=-1;
+ int max_len = -1;
Vector2 size = font->get_string_size(items[i].text);
if (fixed_column_width)
- max_len=fixed_column_width;
- else if(same_column_width)
- max_len=items[i].rect_cache.size.x;
+ max_len = fixed_column_width;
+ else if (same_column_width)
+ max_len = items[i].rect_cache.size.x;
else
- max_len=size.x;
+ max_len = size.x;
- Color modulate=items[i].selected?font_color_selected:font_color;
+ Color modulate = items[i].selected ? font_color_selected : font_color;
if (items[i].disabled)
- modulate.a*=0.5;
+ modulate.a *= 0.5;
- if (icon_mode==ICON_MODE_TOP && max_text_lines>0) {
+ if (icon_mode == ICON_MODE_TOP && max_text_lines > 0) {
int ss = items[i].text.length();
- float ofs=0;
- int line=0;
- for(int j=0;j<=ss;j++) {
+ float ofs = 0;
+ int line = 0;
+ for (int j = 0; j <= ss; j++) {
- int cs = j<ss?font->get_char_size(items[i].text[j],items[i].text[j+1]).x:0;
- if (ofs+cs>max_len || j==ss) {
- line_limit_cache[line]=j;
- line_size_cache[line]=ofs;
+ int cs = j < ss ? font->get_char_size(items[i].text[j], items[i].text[j + 1]).x : 0;
+ if (ofs + cs > max_len || j == ss) {
+ line_limit_cache[line] = j;
+ line_size_cache[line] = ofs;
line++;
- ofs=0;
- if (line>=max_text_lines)
+ ofs = 0;
+ if (line >= max_text_lines)
break;
} else {
- ofs+=cs;
+ ofs += cs;
}
-
}
- line=0;
- ofs=0;
+ line = 0;
+ ofs = 0;
- text_ofs.y+=font->get_ascent();
- text_ofs=text_ofs.floor();
- text_ofs+=base_ofs;
- text_ofs+=items[i].rect_cache.pos;
+ text_ofs.y += font->get_ascent();
+ text_ofs = text_ofs.floor();
+ text_ofs += base_ofs;
+ text_ofs += items[i].rect_cache.pos;
- for(int j=0;j<ss;j++) {
+ for (int j = 0; j < ss; j++) {
- if (j==line_limit_cache[line]) {
+ if (j == line_limit_cache[line]) {
line++;
- ofs=0;
- if (line>=max_text_lines)
+ ofs = 0;
+ if (line >= max_text_lines)
break;
}
- ofs+=font->draw_char(get_canvas_item(),text_ofs+Vector2(ofs+(max_len-line_size_cache[line])/2,line*(font_height+line_separation)).floor(),items[i].text[j],items[i].text[j+1],modulate);
+ ofs += font->draw_char(get_canvas_item(), text_ofs + Vector2(ofs + (max_len - line_size_cache[line]) / 2, line * (font_height + line_separation)).floor(), items[i].text[j], items[i].text[j + 1], modulate);
}
//special multiline mode
} else {
- if (fixed_column_width>0)
- size.x=MIN(size.x,fixed_column_width);
+ if (fixed_column_width > 0)
+ size.x = MIN(size.x, fixed_column_width);
- if (icon_mode==ICON_MODE_TOP) {
- text_ofs.x+=(items[i].rect_cache.size.width-size.x)/2;
+ if (icon_mode == ICON_MODE_TOP) {
+ text_ofs.x += (items[i].rect_cache.size.width - size.x) / 2;
} else {
- text_ofs.y+=(items[i].rect_cache.size.height-size.y)/2;
+ text_ofs.y += (items[i].rect_cache.size.height - size.y) / 2;
}
- text_ofs.y+=font->get_ascent();
- text_ofs=text_ofs.floor();
- text_ofs+=base_ofs;
- text_ofs+=items[i].rect_cache.pos;
+ text_ofs.y += font->get_ascent();
+ text_ofs = text_ofs.floor();
+ text_ofs += base_ofs;
+ text_ofs += items[i].rect_cache.pos;
- draw_string(font,text_ofs,items[i].text,modulate,max_len+1);
+ draw_string(font, text_ofs, items[i].text, modulate, max_len + 1);
}
-
-
}
- if (select_mode==SELECT_MULTI && i==current) {
-
- Rect2 r=rcache;
- r.pos+=base_ofs;
- draw_style_box(cursor,r);
+ if (select_mode == SELECT_MULTI && i == current) {
+ Rect2 r = rcache;
+ r.pos += base_ofs;
+ draw_style_box(cursor, r);
}
}
- for(int i=0;i<separators.size();i++) {
- draw_line(Vector2(bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),Vector2(size.width-bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),guide_color);
+ for (int i = 0; i < separators.size(); i++) {
+ draw_line(Vector2(bg->get_margin(MARGIN_LEFT), base_ofs.y + separators[i]), Vector2(size.width - bg->get_margin(MARGIN_LEFT), base_ofs.y + separators[i]), guide_color);
}
}
}
@@ -1173,50 +1096,50 @@ void ItemList::_scroll_changed(double) {
update();
}
-int ItemList::get_item_at_pos(const Point2& p_pos, bool p_exact) const {
+int ItemList::get_item_at_pos(const Point2 &p_pos, bool p_exact) const {
- Vector2 pos=p_pos;
+ Vector2 pos = p_pos;
Ref<StyleBox> bg = get_stylebox("bg");
- pos-=bg->get_offset();
- pos.y+=scroll_bar->get_val();
+ pos -= bg->get_offset();
+ pos.y += scroll_bar->get_val();
int closest = -1;
- int closest_dist=0x7FFFFFFF;
+ int closest_dist = 0x7FFFFFFF;
- for(int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
Rect2 rc = items[i].rect_cache;
- if (i%current_columns==current_columns-1) {
- rc.size.width=get_size().width; //not right but works
+ if (i % current_columns == current_columns - 1) {
+ rc.size.width = get_size().width; //not right but works
}
if (rc.has_point(pos)) {
- closest=i;
+ closest = i;
break;
}
float dist = rc.distance_to(pos);
- if (!p_exact && dist<closest_dist) {
- closest=i;
- closest_dist=dist;
+ if (!p_exact && dist < closest_dist) {
+ closest = i;
+ closest_dist = dist;
}
}
return closest;
}
-String ItemList::get_tooltip(const Point2& p_pos) const {
+String ItemList::get_tooltip(const Point2 &p_pos) const {
int closest = get_item_at_pos(p_pos);
- if (closest!=-1) {
+ if (closest != -1) {
if (!items[closest].tooltip_enabled) {
return "";
}
- if (items[closest].tooltip!="") {
+ if (items[closest].tooltip != "") {
return items[closest].tooltip;
}
- if (items[closest].text!="") {
+ if (items[closest].text != "") {
return items[closest].text;
}
}
@@ -1228,10 +1151,10 @@ void ItemList::sort_items_by_text() {
items.sort();
update();
- shape_changed=true;
+ shape_changed = true;
- if (select_mode==SELECT_SINGLE) {
- for(int i=0;i<items.size();i++) {
+ if (select_mode == SELECT_SINGLE) {
+ for (int i = 0; i < items.size(); i++) {
if (items[i].selected) {
select(i);
return;
@@ -1240,21 +1163,19 @@ void ItemList::sort_items_by_text() {
}
}
-int ItemList::find_metadata(const Variant& p_metadata) const {
+int ItemList::find_metadata(const Variant &p_metadata) const {
- for(int i=0;i<items.size();i++) {
- if (items[i].metadata==p_metadata) {
+ for (int i = 0; i < items.size(); i++) {
+ if (items[i].metadata == p_metadata) {
return i;
}
}
return -1;
-
}
-
void ItemList::set_allow_rmb_select(bool p_allow) {
- allow_rmb_select=p_allow;
+ allow_rmb_select = p_allow;
}
bool ItemList::get_allow_rmb_select() const {
@@ -1283,125 +1204,123 @@ Vector<int> ItemList::get_selected_items() {
return selected;
}
-void ItemList::_bind_methods(){
+void ItemList::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("add_icon_item","icon:Texture","selectable"),&ItemList::add_icon_item,DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("add_item", "text", "icon:Texture", "selectable"), &ItemList::add_item, DEFVAL(Variant()), DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("add_icon_item", "icon:Texture", "selectable"), &ItemList::add_icon_item, DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&ItemList::set_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&ItemList::get_item_text);
+ ObjectTypeDB::bind_method(_MD("set_item_text", "idx", "text"), &ItemList::set_item_text);
+ ObjectTypeDB::bind_method(_MD("get_item_text", "idx"), &ItemList::get_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
+ ObjectTypeDB::bind_method(_MD("set_item_icon", "idx", "icon:Texture"), &ItemList::set_item_icon);
+ ObjectTypeDB::bind_method(_MD("get_item_icon:Texture", "idx"), &ItemList::get_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
- ObjectTypeDB::bind_method(_MD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
+ ObjectTypeDB::bind_method(_MD("set_item_icon_region", "idx", "rect"), &ItemList::set_item_icon_region);
+ ObjectTypeDB::bind_method(_MD("get_item_icon_region", "idx"), &ItemList::get_item_icon_region);
- ObjectTypeDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
- ObjectTypeDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable);
+ ObjectTypeDB::bind_method(_MD("set_item_selectable", "idx", "selectable"), &ItemList::set_item_selectable);
+ ObjectTypeDB::bind_method(_MD("is_item_selectable", "idx"), &ItemList::is_item_selectable);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&ItemList::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&ItemList::is_item_disabled);
+ ObjectTypeDB::bind_method(_MD("set_item_disabled", "idx", "disabled"), &ItemList::set_item_disabled);
+ ObjectTypeDB::bind_method(_MD("is_item_disabled", "idx"), &ItemList::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&ItemList::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&ItemList::get_item_metadata);
+ ObjectTypeDB::bind_method(_MD("set_item_metadata", "idx", "metadata"), &ItemList::set_item_metadata);
+ ObjectTypeDB::bind_method(_MD("get_item_metadata", "idx"), &ItemList::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("set_item_custom_bg_color","idx","custom_bg_color"),&ItemList::set_item_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("get_item_custom_bg_color","idx"),&ItemList::get_item_custom_bg_color);
+ ObjectTypeDB::bind_method(_MD("set_item_custom_bg_color", "idx", "custom_bg_color"), &ItemList::set_item_custom_bg_color);
+ ObjectTypeDB::bind_method(_MD("get_item_custom_bg_color", "idx"), &ItemList::get_item_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("set_item_tooltip_enabled","idx","enable"),&ItemList::set_item_tooltip_enabled);
- ObjectTypeDB::bind_method(_MD("is_item_tooltip_enabled","idx"),&ItemList::is_item_tooltip_enabled);
+ ObjectTypeDB::bind_method(_MD("set_item_tooltip_enabled", "idx", "enable"), &ItemList::set_item_tooltip_enabled);
+ ObjectTypeDB::bind_method(_MD("is_item_tooltip_enabled", "idx"), &ItemList::is_item_tooltip_enabled);
- ObjectTypeDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip);
- ObjectTypeDB::bind_method(_MD("get_item_tooltip","idx"),&ItemList::get_item_tooltip);
+ ObjectTypeDB::bind_method(_MD("set_item_tooltip", "idx", "tooltip"), &ItemList::set_item_tooltip);
+ ObjectTypeDB::bind_method(_MD("get_item_tooltip", "idx"), &ItemList::get_item_tooltip);
- ObjectTypeDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
- ObjectTypeDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items);
+ ObjectTypeDB::bind_method(_MD("select", "idx", "single"), &ItemList::select, DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("unselect", "idx"), &ItemList::unselect);
+ ObjectTypeDB::bind_method(_MD("is_selected", "idx"), &ItemList::is_selected);
+ ObjectTypeDB::bind_method(_MD("get_selected_items"), &ItemList::get_selected_items);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item);
+ ObjectTypeDB::bind_method(_MD("get_item_count"), &ItemList::get_item_count);
+ ObjectTypeDB::bind_method(_MD("remove_item", "idx"), &ItemList::remove_item);
- ObjectTypeDB::bind_method(_MD("clear"),&ItemList::clear);
- ObjectTypeDB::bind_method(_MD("sort_items_by_text"),&ItemList::sort_items_by_text);
+ ObjectTypeDB::bind_method(_MD("clear"), &ItemList::clear);
+ ObjectTypeDB::bind_method(_MD("sort_items_by_text"), &ItemList::sort_items_by_text);
- ObjectTypeDB::bind_method(_MD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width);
- ObjectTypeDB::bind_method(_MD("get_fixed_column_width"),&ItemList::get_fixed_column_width);
+ ObjectTypeDB::bind_method(_MD("set_fixed_column_width", "width"), &ItemList::set_fixed_column_width);
+ ObjectTypeDB::bind_method(_MD("get_fixed_column_width"), &ItemList::get_fixed_column_width);
- ObjectTypeDB::bind_method(_MD("set_same_column_width","enable"),&ItemList::set_same_column_width);
- ObjectTypeDB::bind_method(_MD("is_same_column_width"),&ItemList::is_same_column_width);
+ ObjectTypeDB::bind_method(_MD("set_same_column_width", "enable"), &ItemList::set_same_column_width);
+ ObjectTypeDB::bind_method(_MD("is_same_column_width"), &ItemList::is_same_column_width);
- ObjectTypeDB::bind_method(_MD("set_max_text_lines","lines"),&ItemList::set_max_text_lines);
- ObjectTypeDB::bind_method(_MD("get_max_text_lines"),&ItemList::get_max_text_lines);
+ ObjectTypeDB::bind_method(_MD("set_max_text_lines", "lines"), &ItemList::set_max_text_lines);
+ ObjectTypeDB::bind_method(_MD("get_max_text_lines"), &ItemList::get_max_text_lines);
- ObjectTypeDB::bind_method(_MD("set_max_columns","amount"),&ItemList::set_max_columns);
- ObjectTypeDB::bind_method(_MD("get_max_columns"),&ItemList::get_max_columns);
+ ObjectTypeDB::bind_method(_MD("set_max_columns", "amount"), &ItemList::set_max_columns);
+ ObjectTypeDB::bind_method(_MD("get_max_columns"), &ItemList::get_max_columns);
- ObjectTypeDB::bind_method(_MD("set_select_mode","mode"),&ItemList::set_select_mode);
- ObjectTypeDB::bind_method(_MD("get_select_mode"),&ItemList::get_select_mode);
+ ObjectTypeDB::bind_method(_MD("set_select_mode", "mode"), &ItemList::set_select_mode);
+ ObjectTypeDB::bind_method(_MD("get_select_mode"), &ItemList::get_select_mode);
- ObjectTypeDB::bind_method(_MD("set_icon_mode","mode"),&ItemList::set_icon_mode);
- ObjectTypeDB::bind_method(_MD("get_icon_mode"),&ItemList::get_icon_mode);
+ ObjectTypeDB::bind_method(_MD("set_icon_mode", "mode"), &ItemList::set_icon_mode);
+ ObjectTypeDB::bind_method(_MD("get_icon_mode"), &ItemList::get_icon_mode);
+ ObjectTypeDB::bind_method(_MD("set_fixed_icon_size", "size"), &ItemList::set_fixed_icon_size);
+ ObjectTypeDB::bind_method(_MD("get_fixed_icon_size"), &ItemList::get_fixed_icon_size);
- ObjectTypeDB::bind_method(_MD("set_fixed_icon_size","size"),&ItemList::set_fixed_icon_size);
- ObjectTypeDB::bind_method(_MD("get_fixed_icon_size"),&ItemList::get_fixed_icon_size);
+ ObjectTypeDB::bind_method(_MD("set_icon_scale", "scale"), &ItemList::set_icon_scale);
+ ObjectTypeDB::bind_method(_MD("get_icon_scale"), &ItemList::get_icon_scale);
- ObjectTypeDB::bind_method(_MD("set_icon_scale","scale"),&ItemList::set_icon_scale);
- ObjectTypeDB::bind_method(_MD("get_icon_scale"),&ItemList::get_icon_scale);
+ ObjectTypeDB::bind_method(_MD("set_allow_rmb_select", "allow"), &ItemList::set_allow_rmb_select);
+ ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"), &ItemList::get_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("set_allow_rmb_select","allow"),&ItemList::set_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"),&ItemList::get_allow_rmb_select);
+ ObjectTypeDB::bind_method(_MD("get_item_at_pos", "pos", "exact"), &ItemList::get_item_at_pos, DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_item_at_pos","pos","exact"),&ItemList::get_item_at_pos,DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("ensure_current_is_visible"), &ItemList::ensure_current_is_visible);
- ObjectTypeDB::bind_method(_MD("ensure_current_is_visible"),&ItemList::ensure_current_is_visible);
+ ObjectTypeDB::bind_method(_MD("get_v_scroll"), &ItemList::get_v_scroll);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&ItemList::get_v_scroll);
+ ObjectTypeDB::bind_method(_MD("_scroll_changed"), &ItemList::_scroll_changed);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &ItemList::_input_event);
- ObjectTypeDB::bind_method(_MD("_scroll_changed"),&ItemList::_scroll_changed);
- ObjectTypeDB::bind_method(_MD("_input_event"),&ItemList::_input_event);
+ BIND_CONSTANT(ICON_MODE_TOP);
+ BIND_CONSTANT(ICON_MODE_LEFT);
+ BIND_CONSTANT(SELECT_SINGLE);
+ BIND_CONSTANT(SELECT_MULTI);
- BIND_CONSTANT( ICON_MODE_TOP );
- BIND_CONSTANT( ICON_MODE_LEFT );
- BIND_CONSTANT( SELECT_SINGLE );
- BIND_CONSTANT( SELECT_MULTI );
-
- ADD_SIGNAL( MethodInfo("item_selected",PropertyInfo(Variant::INT,"index")));
- ADD_SIGNAL( MethodInfo("item_rmb_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::VECTOR2,"atpos")));
- ADD_SIGNAL( MethodInfo("multi_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::BOOL,"selected")));
- ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index")));
+ ADD_SIGNAL(MethodInfo("item_selected", PropertyInfo(Variant::INT, "index")));
+ ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::VECTOR2, "atpos")));
+ ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "selected")));
+ ADD_SIGNAL(MethodInfo("item_activated", PropertyInfo(Variant::INT, "index")));
}
ItemList::ItemList() {
- current=-1;
+ current = -1;
- select_mode=SELECT_SINGLE;
- icon_mode=ICON_MODE_LEFT;
+ select_mode = SELECT_SINGLE;
+ icon_mode = ICON_MODE_LEFT;
- fixed_column_width=0;
+ fixed_column_width = 0;
same_column_width = false;
- max_text_lines=1;
- max_columns=1;
+ max_text_lines = 1;
+ max_columns = 1;
- scroll_bar = memnew( VScrollBar );
+ scroll_bar = memnew(VScrollBar);
add_child(scroll_bar);
- shape_changed=true;
- scroll_bar->connect("value_changed",this,"_scroll_changed");
+ shape_changed = true;
+ scroll_bar->connect("value_changed", this, "_scroll_changed");
set_focus_mode(FOCUS_ALL);
- current_columns=1;
- search_time_msec=0;
- ensure_selected_visible=false;
- defer_select_single=-1;
- allow_rmb_select=false;
+ current_columns = 1;
+ search_time_msec = 0;
+ ensure_selected_visible = false;
+ defer_select_single = -1;
+ allow_rmb_select = false;
icon_scale = 1.0f;
}
ItemList::~ItemList() {
-
}
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index acafc88fb..ff1f54e3c 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -34,9 +34,9 @@
class ItemList : public Control {
- OBJ_TYPE( ItemList, Control );
-public:
+ OBJ_TYPE(ItemList, Control);
+public:
enum IconMode {
ICON_MODE_TOP,
ICON_MODE_LEFT
@@ -46,6 +46,7 @@ public:
SELECT_SINGLE,
SELECT_MULTI
};
+
private:
struct Item {
@@ -66,7 +67,7 @@ private:
Size2 get_icon_size() const;
- bool operator<(const Item& p_another) const { return text<p_another.text; }
+ bool operator<(const Item &p_another) const { return text < p_another.text; }
};
int current;
@@ -102,50 +103,47 @@ private:
real_t icon_scale;
void _scroll_changed(double);
- void _input_event(const InputEvent& p_event);
-
+ void _input_event(const InputEvent &p_event);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
-
- void add_item(const String& p_item,const Ref<Texture>& p_texture=Ref<Texture>(),bool p_selectable=true);
- void add_icon_item(const Ref<Texture>& p_item,bool p_selectable=true);
+public:
+ void add_item(const String &p_item, const Ref<Texture> &p_texture = Ref<Texture>(), bool p_selectable = true);
+ void add_icon_item(const Ref<Texture> &p_item, bool p_selectable = true);
- void set_item_text(int p_idx,const String& p_text);
+ void set_item_text(int p_idx, const String &p_text);
String get_item_text(int p_idx) const;
- void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
+ void set_item_icon(int p_idx, const Ref<Texture> &p_icon);
Ref<Texture> get_item_icon(int p_idx) const;
- void set_item_icon_region(int p_idx,const Rect2& p_region);
+ void set_item_icon_region(int p_idx, const Rect2 &p_region);
Rect2 get_item_icon_region(int p_idx) const;
- void set_item_selectable(int p_idx,bool p_selectable);
+ void set_item_selectable(int p_idx, bool p_selectable);
bool is_item_selectable(int p_idx) const;
- void set_item_disabled(int p_idx,bool p_disabled);
+ void set_item_disabled(int p_idx, bool p_disabled);
bool is_item_disabled(int p_idx) const;
- void set_item_metadata(int p_idx,const Variant& p_metadata);
+ void set_item_metadata(int p_idx, const Variant &p_metadata);
Variant get_item_metadata(int p_idx) const;
- void set_item_tag_icon(int p_idx,const Ref<Texture>& p_tag_icon);
+ void set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon);
Ref<Texture> get_item_tag_icon(int p_idx) const;
void set_item_tooltip_enabled(int p_idx, const bool p_enabled);
bool is_item_tooltip_enabled(int p_idx) const;
- void set_item_tooltip(int p_idx,const String& p_tooltip);
+ void set_item_tooltip(int p_idx, const String &p_tooltip);
String get_item_tooltip(int p_idx) const;
- void set_item_custom_bg_color(int p_idx,const Color& p_custom_bg_color);
+ void set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color);
Color get_item_custom_bg_color(int p_idx) const;
- void select(int p_idx,bool p_single=true);
+ void select(int p_idx, bool p_single = true);
void unselect(int p_idx);
bool is_selected(int p_idx) const;
Vector<int> get_selected_items();
@@ -153,7 +151,7 @@ public:
void set_current(int p_current);
int get_current() const;
- void move_item(int p_item,int p_to_pos);
+ void move_item(int p_item, int p_to_pos);
int get_item_count() const;
void remove_item(int p_idx);
@@ -178,7 +176,7 @@ public:
void set_icon_mode(IconMode p_mode);
IconMode get_icon_mode() const;
- void set_fixed_icon_size(const Size2& p_size);
+ void set_fixed_icon_size(const Size2 &p_size);
Size2 get_fixed_icon_size() const;
void set_allow_rmb_select(bool p_allow);
@@ -187,10 +185,10 @@ public:
void ensure_current_is_visible();
void sort_items_by_text();
- int find_metadata(const Variant& p_metadata) const;
+ int find_metadata(const Variant &p_metadata) const;
- virtual String get_tooltip(const Point2& p_pos) const;
- int get_item_at_pos(const Point2& p_pos,bool p_exact=false) const;
+ virtual String get_tooltip(const Point2 &p_pos) const;
+ int get_item_at_pos(const Point2 &p_pos, bool p_exact = false) const;
void set_icon_scale(real_t p_scale);
real_t get_icon_scale() const;
@@ -204,5 +202,4 @@ public:
VARIANT_ENUM_CAST(ItemList::SelectMode);
VARIANT_ENUM_CAST(ItemList::IconMode);
-
#endif // ITEMLIST_H
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index a097b3a1a..5d5ae388c 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -27,29 +27,26 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "label.h"
-#include "print_string.h"
#include "globals.h"
+#include "print_string.h"
#include "translation.h"
-
void Label::set_autowrap(bool p_autowrap) {
- autowrap=p_autowrap;
- word_cache_dirty=true;
+ autowrap = p_autowrap;
+ word_cache_dirty = true;
minimum_size_changed();
update();
-
}
bool Label::has_autowrap() const {
return autowrap;
}
-
void Label::set_uppercase(bool p_uppercase) {
- uppercase=p_uppercase;
- word_cache_dirty=true;
+ uppercase = p_uppercase;
+ word_cache_dirty = true;
minimum_size_changed();
update();
}
@@ -58,256 +55,239 @@ bool Label::is_uppercase() const {
return uppercase;
}
-
int Label::get_line_height() const {
return get_font("font")->get_height();
-
}
-
void Label::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
if (clip || autowrap)
- VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
+ VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
if (word_cache_dirty)
regenerate_word_cache();
-
RID ci = get_canvas_item();
Size2 string_size;
- Size2 size=get_size();
+ Size2 size = get_size();
Ref<Font> font = get_font("font");
Color font_color = get_color("font_color");
Color font_color_shadow = get_color("font_color_shadow");
bool use_outline = get_constant("shadow_as_outline");
- Point2 shadow_ofs(get_constant("shadow_offset_x"),get_constant("shadow_offset_y"));
+ Point2 shadow_ofs(get_constant("shadow_offset_x"), get_constant("shadow_offset_y"));
int line_spacing = get_constant("line_spacing");
- VisualServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(),font.is_valid() && font->is_distance_field_hint());
+ VisualServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(), font.is_valid() && font->is_distance_field_hint());
- int font_h = font->get_height()+line_spacing;
+ int font_h = font->get_height() + line_spacing;
- int lines_visible = (size.y+line_spacing)/font_h;
+ int lines_visible = (size.y + line_spacing) / font_h;
- int space_w=font->get_char_size(' ').width;
- int chars_total=0;
+ int space_w = font->get_char_size(' ').width;
+ int chars_total = 0;
- int vbegin=0,vsep=0;
+ int vbegin = 0, vsep = 0;
if (lines_visible > line_count) {
lines_visible = line_count;
-
}
if (max_lines_visible >= 0 && lines_visible > max_lines_visible) {
lines_visible = max_lines_visible;
-
}
if (lines_visible > 0) {
- switch(valign) {
+ switch (valign) {
case VALIGN_TOP: {
//nothing
} break;
case VALIGN_CENTER: {
- vbegin=(size.y - (lines_visible * font_h - line_spacing)) / 2;
- vsep=0;
+ vbegin = (size.y - (lines_visible * font_h - line_spacing)) / 2;
+ vsep = 0;
} break;
case VALIGN_BOTTOM: {
- vbegin=size.y - (lines_visible * font_h - line_spacing);
- vsep=0;
+ vbegin = size.y - (lines_visible * font_h - line_spacing);
+ vsep = 0;
} break;
case VALIGN_FILL: {
- vbegin=0;
- if (lines_visible>1) {
- vsep=(size.y - (lines_visible * font_h - line_spacing)) / (lines_visible - 1);
+ vbegin = 0;
+ if (lines_visible > 1) {
+ vsep = (size.y - (lines_visible * font_h - line_spacing)) / (lines_visible - 1);
} else {
- vsep=0;
+ vsep = 0;
}
} break;
}
}
-
WordCache *wc = word_cache;
if (!wc)
return;
- int line=0;
- int line_to=lines_skipped + (lines_visible>0?lines_visible:1);
- while(wc) {
- /* handle lines not meant to be drawn quickly */
- if (line>=line_to)
+ int line = 0;
+ int line_to = lines_skipped + (lines_visible > 0 ? lines_visible : 1);
+ while (wc) {
+ /* handle lines not meant to be drawn quickly */
+ if (line >= line_to)
break;
- if (line<lines_skipped) {
+ if (line < lines_skipped) {
- while (wc && wc->char_pos>=0)
- wc=wc->next;
+ while (wc && wc->char_pos >= 0)
+ wc = wc->next;
if (wc)
- wc=wc->next;
+ wc = wc->next;
line++;
continue;
}
- /* handle lines normally */
+ /* handle lines normally */
- if (wc->char_pos<0) {
- //empty line
- wc=wc->next;
+ if (wc->char_pos < 0) {
+ //empty line
+ wc = wc->next;
line++;
continue;
}
- WordCache *from=wc;
- WordCache *to=wc;
+ WordCache *from = wc;
+ WordCache *to = wc;
- int taken=0;
- int spaces=0;
- while(to && to->char_pos>=0) {
+ int taken = 0;
+ int spaces = 0;
+ while (to && to->char_pos >= 0) {
- taken+=to->pixel_width;
- if (to!=from && to->space_count) {
- spaces+=to->space_count;
+ taken += to->pixel_width;
+ if (to != from && to->space_count) {
+ spaces += to->space_count;
}
- to=to->next;
+ to = to->next;
}
- bool can_fill = to && to->char_pos==WordCache::CHAR_WRAPLINE;
+ bool can_fill = to && to->char_pos == WordCache::CHAR_WRAPLINE;
- float x_ofs=0;
+ float x_ofs = 0;
switch (align) {
case ALIGN_FILL:
case ALIGN_LEFT: {
- x_ofs=0;
+ x_ofs = 0;
} break;
case ALIGN_CENTER: {
- x_ofs=int(size.width-(taken+spaces*space_w))/2;
+ x_ofs = int(size.width - (taken + spaces * space_w)) / 2;
} break;
case ALIGN_RIGHT: {
-
- x_ofs=int(size.width-(taken+spaces*space_w));
+ x_ofs = int(size.width - (taken + spaces * space_w));
} break;
- }
+ }
- int y_ofs=(line-lines_skipped)*font_h + font->get_ascent();
- y_ofs+=vbegin + line*vsep;
+ int y_ofs = (line - lines_skipped) * font_h + font->get_ascent();
+ y_ofs += vbegin + line * vsep;
- while(from!=to) {
+ while (from != to) {
- // draw a word
+ // draw a word
int pos = from->char_pos;
- if (from->char_pos<0) {
+ if (from->char_pos < 0) {
ERR_PRINT("BUG");
return;
}
if (from->space_count) {
- /* spacing */
- x_ofs+=space_w*from->space_count;
- if (can_fill && align==ALIGN_FILL && spaces) {
+ /* spacing */
+ x_ofs += space_w * from->space_count;
+ if (can_fill && align == ALIGN_FILL && spaces) {
- x_ofs+=int((size.width-(taken+space_w*spaces))/spaces);
+ x_ofs += int((size.width - (taken + space_w * spaces)) / spaces);
}
-
-
}
-
-
- if (font_color_shadow.a>0) {
+ if (font_color_shadow.a > 0) {
int chars_total_shadow = chars_total; //save chars drawn
- float x_ofs_shadow=x_ofs;
- for (int i=0;i<from->word_len;i++) {
+ float x_ofs_shadow = x_ofs;
+ for (int i = 0; i < from->word_len; i++) {
- if (visible_chars < 0 || chars_total_shadow<visible_chars) {
- CharType c = text[i+pos];
- CharType n = text[i+pos+1];
+ if (visible_chars < 0 || chars_total_shadow < visible_chars) {
+ CharType c = text[i + pos];
+ CharType n = text[i + pos + 1];
if (uppercase) {
- c=String::char_uppercase(c);
- n=String::char_uppercase(c);
+ c = String::char_uppercase(c);
+ n = String::char_uppercase(c);
}
- float move=font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+shadow_ofs, c, n,font_color_shadow );
+ float move = font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + shadow_ofs, c, n, font_color_shadow);
if (use_outline) {
- font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,shadow_ofs.y), c, n,font_color_shadow );
- font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow );
- font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow );
+ font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(-shadow_ofs.x, shadow_ofs.y), c, n, font_color_shadow);
+ font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(shadow_ofs.x, -shadow_ofs.y), c, n, font_color_shadow);
+ font->draw_char(ci, Point2(x_ofs_shadow, y_ofs) + Vector2(-shadow_ofs.x, -shadow_ofs.y), c, n, font_color_shadow);
}
- x_ofs_shadow+=move;
+ x_ofs_shadow += move;
chars_total_shadow++;
}
}
-
-
}
- for (int i=0;i<from->word_len;i++) {
+ for (int i = 0; i < from->word_len; i++) {
- if (visible_chars < 0 || chars_total<visible_chars) {
- CharType c = text[i+pos];
- CharType n = text[i+pos+1];
+ if (visible_chars < 0 || chars_total < visible_chars) {
+ CharType c = text[i + pos];
+ CharType n = text[i + pos + 1];
if (uppercase) {
- c=String::char_uppercase(c);
- n=String::char_uppercase(c);
+ c = String::char_uppercase(c);
+ n = String::char_uppercase(c);
}
- x_ofs+=font->draw_char(ci,Point2( x_ofs, y_ofs ), c, n, font_color );
+ x_ofs += font->draw_char(ci, Point2(x_ofs, y_ofs), c, n, font_color);
chars_total++;
}
-
}
- from=from->next;
+ from = from->next;
}
- wc=to?to->next:0;
+ wc = to ? to->next : 0;
line++;
-
}
}
- if (p_what==NOTIFICATION_THEME_CHANGED) {
+ if (p_what == NOTIFICATION_THEME_CHANGED) {
- word_cache_dirty=true;
+ word_cache_dirty = true;
update();
}
- if (p_what==NOTIFICATION_RESIZED) {
+ if (p_what == NOTIFICATION_RESIZED) {
- word_cache_dirty=true;
+ word_cache_dirty = true;
}
-
}
Size2 Label::get_minimum_size() const {
if (autowrap)
- return Size2(1,1);
+ return Size2(1, 1);
else {
// don't want to mutable everything
- if(word_cache_dirty)
- const_cast<Label*>(this)->regenerate_word_cache();
+ if (word_cache_dirty)
+ const_cast<Label *>(this)->regenerate_word_cache();
- Size2 ms=minsize;
+ Size2 ms = minsize;
if (clip)
- ms.width=1;
+ ms.width = 1;
return ms;
}
}
@@ -315,33 +295,32 @@ Size2 Label::get_minimum_size() const {
int Label::get_longest_line_width() const {
Ref<Font> font = get_font("font");
- int max_line_width=0;
- int line_width=0;
+ int max_line_width = 0;
+ int line_width = 0;
- for (int i=0;i<text.size();i++) {
+ for (int i = 0; i < text.size(); i++) {
- CharType current=text[i];
+ CharType current = text[i];
if (uppercase)
- current=String::char_uppercase(current);
+ current = String::char_uppercase(current);
- if (current<32) {
+ if (current < 32) {
- if (current=='\n') {
+ if (current == '\n') {
- if (line_width>max_line_width)
- max_line_width=line_width;
- line_width=0;
+ if (line_width > max_line_width)
+ max_line_width = line_width;
+ line_width = 0;
}
} else {
- int char_width=font->get_char_size(current,text[i+1]).width;
- line_width+=char_width;
+ int char_width = font->get_char_size(current, text[i + 1]).width;
+ line_width += char_width;
}
-
}
- if (line_width>max_line_width)
- max_line_width=line_width;
+ if (line_width > max_line_width)
+ max_line_width = line_width;
return max_line_width;
}
@@ -351,7 +330,7 @@ int Label::get_line_count() const {
if (!is_inside_tree())
return 1;
if (word_cache_dirty)
- const_cast<Label*>(this)->regenerate_word_cache();
+ const_cast<Label *>(this)->regenerate_word_cache();
return line_count;
}
@@ -359,8 +338,8 @@ int Label::get_line_count() const {
int Label::get_visible_line_count() const {
int line_spacing = get_constant("line_spacing");
- int font_h = get_font("font")->get_height()+line_spacing;
- int lines_visible = (get_size().y+line_spacing)/font_h;
+ int font_h = get_font("font")->get_height() + line_spacing;
+ int lines_visible = (get_size().y + line_spacing) / font_h;
if (lines_visible > line_count)
lines_visible = line_count;
@@ -375,190 +354,181 @@ void Label::regenerate_word_cache() {
while (word_cache) {
- WordCache *current=word_cache;
- word_cache=current->next;
- memdelete( current );
+ WordCache *current = word_cache;
+ word_cache = current->next;
+ memdelete(current);
}
-
- int width=autowrap?get_size().width:get_longest_line_width();
+ int width = autowrap ? get_size().width : get_longest_line_width();
Ref<Font> font = get_font("font");
- int current_word_size=0;
- int word_pos=0;
- int line_width=0;
- int space_count=0;
- int space_width=font->get_char_size(' ').width;
+ int current_word_size = 0;
+ int word_pos = 0;
+ int line_width = 0;
+ int space_count = 0;
+ int space_width = font->get_char_size(' ').width;
int line_spacing = get_constant("line_spacing");
- line_count=1;
- total_char_cache=0;
+ line_count = 1;
+ total_char_cache = 0;
- WordCache *last=NULL;
+ WordCache *last = NULL;
- for (int i=0;i<text.size()+1;i++) {
+ for (int i = 0; i < text.size() + 1; i++) {
- CharType current=i<text.length()?text[i]:' '; //always a space at the end, so the algo works
+ CharType current = i < text.length() ? text[i] : ' '; //always a space at the end, so the algo works
if (uppercase)
- current=String::char_uppercase(current);
+ current = String::char_uppercase(current);
// ranges taken from http://www.unicodemap.org/
// if your language is not well supported, consider helping improve
// the unicode support in Godot.
- bool separatable = (current>=0x2E08 && current<=0xFAFF) || (current>=0xFE30 && current<=0xFE4F);
- //current>=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57);
- bool insert_newline=false;
+ bool separatable = (current >= 0x2E08 && current <= 0xFAFF) || (current >= 0xFE30 && current <= 0xFE4F);
+ //current>=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57);
+ bool insert_newline = false;
int char_width;
- if (current<33) {
+ if (current < 33) {
- if (current_word_size>0) {
- WordCache *wc = memnew( WordCache );
+ if (current_word_size > 0) {
+ WordCache *wc = memnew(WordCache);
if (word_cache) {
- last->next=wc;
+ last->next = wc;
} else {
- word_cache=wc;
+ word_cache = wc;
}
- last=wc;
+ last = wc;
- wc->pixel_width=current_word_size;
- wc->char_pos=word_pos;
- wc->word_len=i-word_pos;
+ wc->pixel_width = current_word_size;
+ wc->char_pos = word_pos;
+ wc->word_len = i - word_pos;
wc->space_count = space_count;
- current_word_size=0;
- space_count=0;
-
+ current_word_size = 0;
+ space_count = 0;
}
-
- if (current=='\n') {
- insert_newline=true;
+ if (current == '\n') {
+ insert_newline = true;
} else {
total_char_cache++;
}
- if (i<text.length() && text[i] == ' ') {
- total_char_cache--; // do not count spaces
- if (line_width > 0 || last==NULL || last->char_pos!=WordCache::CHAR_WRAPLINE) {
+ if (i < text.length() && text[i] == ' ') {
+ total_char_cache--; // do not count spaces
+ if (line_width > 0 || last == NULL || last->char_pos != WordCache::CHAR_WRAPLINE) {
space_count++;
- line_width+=space_width;
- }else {
- space_count=0;
+ line_width += space_width;
+ } else {
+ space_count = 0;
}
}
-
} else {
// latin characters
- if (current_word_size==0) {
- word_pos=i;
+ if (current_word_size == 0) {
+ word_pos = i;
}
- char_width=font->get_char_size(current,text[i+1]).width;
- current_word_size+=char_width;
- line_width+=char_width;
+ char_width = font->get_char_size(current, text[i + 1]).width;
+ current_word_size += char_width;
+ line_width += char_width;
total_char_cache++;
-
}
if ((autowrap && (line_width >= width) && ((last && last->char_pos >= 0) || separatable)) || insert_newline) {
if (separatable) {
- if (current_word_size>0) {
- WordCache *wc = memnew( WordCache );
+ if (current_word_size > 0) {
+ WordCache *wc = memnew(WordCache);
if (word_cache) {
- last->next=wc;
+ last->next = wc;
} else {
- word_cache=wc;
+ word_cache = wc;
}
- last=wc;
+ last = wc;
- wc->pixel_width=current_word_size-char_width;
- wc->char_pos=word_pos;
- wc->word_len=i-word_pos;
+ wc->pixel_width = current_word_size - char_width;
+ wc->char_pos = word_pos;
+ wc->word_len = i - word_pos;
wc->space_count = space_count;
- current_word_size=char_width;
- space_count=0;
- word_pos=i;
+ current_word_size = char_width;
+ space_count = 0;
+ word_pos = i;
}
}
- WordCache *wc = memnew( WordCache );
+ WordCache *wc = memnew(WordCache);
if (word_cache) {
- last->next=wc;
+ last->next = wc;
} else {
- word_cache=wc;
+ word_cache = wc;
}
- last=wc;
+ last = wc;
- wc->pixel_width=0;
- wc->char_pos=insert_newline?WordCache::CHAR_NEWLINE:WordCache::CHAR_WRAPLINE;
+ wc->pixel_width = 0;
+ wc->char_pos = insert_newline ? WordCache::CHAR_NEWLINE : WordCache::CHAR_WRAPLINE;
- line_width=current_word_size;
+ line_width = current_word_size;
line_count++;
- space_count=0;
-
+ space_count = 0;
}
-
}
if (!autowrap) {
- minsize.width=width;
+ minsize.width = width;
if (max_lines_visible > 0 && line_count > max_lines_visible) {
- minsize.height=(font->get_height() * max_lines_visible) + (line_spacing * (max_lines_visible - 1));
+ minsize.height = (font->get_height() * max_lines_visible) + (line_spacing * (max_lines_visible - 1));
} else {
- minsize.height=(font->get_height() * line_count)+(line_spacing * (line_count - 1));
+ minsize.height = (font->get_height() * line_count) + (line_spacing * (line_count - 1));
}
}
- word_cache_dirty=false;
-
+ word_cache_dirty = false;
}
void Label::set_align(Align p_align) {
- ERR_FAIL_INDEX(p_align,4);
- align=p_align;
+ ERR_FAIL_INDEX(p_align, 4);
+ align = p_align;
update();
}
-Label::Align Label::get_align() const{
+Label::Align Label::get_align() const {
return align;
}
void Label::set_valign(VAlign p_align) {
- ERR_FAIL_INDEX(p_align,4);
- valign=p_align;
+ ERR_FAIL_INDEX(p_align, 4);
+ valign = p_align;
update();
}
-Label::VAlign Label::get_valign() const{
+Label::VAlign Label::get_valign() const {
return valign;
}
-void Label::set_text(const String& p_string) {
+void Label::set_text(const String &p_string) {
String str = XL_MESSAGE(p_string);
- if (text==str)
+ if (text == str)
return;
- text=str;
- word_cache_dirty=true;
- if (percent_visible<1)
- visible_chars=get_total_character_count()*percent_visible;
+ text = str;
+ word_cache_dirty = true;
+ if (percent_visible < 1)
+ visible_chars = get_total_character_count() * percent_visible;
update();
if (!autowrap) {
minimum_size_changed();
}
-
}
void Label::set_clip_text(bool p_clip) {
- clip=p_clip;
+ clip = p_clip;
update();
minimum_size_changed();
}
@@ -575,9 +545,9 @@ String Label::get_text() const {
void Label::set_visible_characters(int p_amount) {
- visible_chars=p_amount;
+ visible_chars = p_amount;
if (get_total_character_count() > 0) {
- percent_visible=(float)p_amount/(float)total_char_cache;
+ percent_visible = (float)p_amount / (float)total_char_cache;
}
update();
}
@@ -589,44 +559,42 @@ int Label::get_visible_characters() const {
void Label::set_percent_visible(float p_percent) {
- if (p_percent<0 || p_percent>=1) {
+ if (p_percent < 0 || p_percent >= 1) {
- visible_chars=-1;
- percent_visible=1;
+ visible_chars = -1;
+ percent_visible = 1;
} else {
- visible_chars=get_total_character_count()*p_percent;
- percent_visible=p_percent;
-
+ visible_chars = get_total_character_count() * p_percent;
+ percent_visible = p_percent;
}
update();
-
}
-float Label::get_percent_visible() const{
+float Label::get_percent_visible() const {
return percent_visible;
}
void Label::set_lines_skipped(int p_lines) {
- lines_skipped=p_lines;
+ lines_skipped = p_lines;
update();
}
-int Label::get_lines_skipped() const{
+int Label::get_lines_skipped() const {
return lines_skipped;
}
void Label::set_max_lines_visible(int p_lines) {
- max_lines_visible=p_lines;
+ max_lines_visible = p_lines;
update();
}
-int Label::get_max_lines_visible() const{
+int Label::get_max_lines_visible() const {
return max_lines_visible;
}
@@ -634,90 +602,86 @@ int Label::get_max_lines_visible() const{
int Label::get_total_character_count() const {
if (word_cache_dirty)
- const_cast<Label*>(this)->regenerate_word_cache();
+ const_cast<Label *>(this)->regenerate_word_cache();
return total_char_cache;
}
void Label::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_align","align"),&Label::set_align);
- ObjectTypeDB::bind_method(_MD("get_align"),&Label::get_align);
- ObjectTypeDB::bind_method(_MD("set_valign","valign"),&Label::set_valign);
- ObjectTypeDB::bind_method(_MD("get_valign"),&Label::get_valign);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&Label::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&Label::get_text);
- ObjectTypeDB::bind_method(_MD("set_autowrap","enable"),&Label::set_autowrap);
- ObjectTypeDB::bind_method(_MD("has_autowrap"),&Label::has_autowrap);
- ObjectTypeDB::bind_method(_MD("set_clip_text","enable"),&Label::set_clip_text);
- ObjectTypeDB::bind_method(_MD("is_clipping_text"),&Label::is_clipping_text);
- ObjectTypeDB::bind_method(_MD("set_uppercase","enable"),&Label::set_uppercase);
- ObjectTypeDB::bind_method(_MD("is_uppercase"),&Label::is_uppercase);
- ObjectTypeDB::bind_method(_MD("get_line_height"),&Label::get_line_height);
- ObjectTypeDB::bind_method(_MD("get_line_count"),&Label::get_line_count);
- ObjectTypeDB::bind_method(_MD("get_visible_line_count"),&Label::get_visible_line_count);
- ObjectTypeDB::bind_method(_MD("get_total_character_count"),&Label::get_total_character_count);
- ObjectTypeDB::bind_method(_MD("set_visible_characters","amount"),&Label::set_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_visible_characters"),&Label::get_visible_characters);
- ObjectTypeDB::bind_method(_MD("set_percent_visible","percent_visible"),&Label::set_percent_visible);
- ObjectTypeDB::bind_method(_MD("get_percent_visible"),&Label::get_percent_visible);
- ObjectTypeDB::bind_method(_MD("set_lines_skipped","lines_skipped"),&Label::set_lines_skipped);
- ObjectTypeDB::bind_method(_MD("get_lines_skipped"),&Label::get_lines_skipped);
- ObjectTypeDB::bind_method(_MD("set_max_lines_visible","lines_visible"),&Label::set_max_lines_visible);
- ObjectTypeDB::bind_method(_MD("get_max_lines_visible"),&Label::get_max_lines_visible);
-
- BIND_CONSTANT( ALIGN_LEFT );
- BIND_CONSTANT( ALIGN_CENTER );
- BIND_CONSTANT( ALIGN_RIGHT );
- BIND_CONSTANT( ALIGN_FILL );
+ ObjectTypeDB::bind_method(_MD("set_align", "align"), &Label::set_align);
+ ObjectTypeDB::bind_method(_MD("get_align"), &Label::get_align);
+ ObjectTypeDB::bind_method(_MD("set_valign", "valign"), &Label::set_valign);
+ ObjectTypeDB::bind_method(_MD("get_valign"), &Label::get_valign);
+ ObjectTypeDB::bind_method(_MD("set_text", "text"), &Label::set_text);
+ ObjectTypeDB::bind_method(_MD("get_text"), &Label::get_text);
+ ObjectTypeDB::bind_method(_MD("set_autowrap", "enable"), &Label::set_autowrap);
+ ObjectTypeDB::bind_method(_MD("has_autowrap"), &Label::has_autowrap);
+ ObjectTypeDB::bind_method(_MD("set_clip_text", "enable"), &Label::set_clip_text);
+ ObjectTypeDB::bind_method(_MD("is_clipping_text"), &Label::is_clipping_text);
+ ObjectTypeDB::bind_method(_MD("set_uppercase", "enable"), &Label::set_uppercase);
+ ObjectTypeDB::bind_method(_MD("is_uppercase"), &Label::is_uppercase);
+ ObjectTypeDB::bind_method(_MD("get_line_height"), &Label::get_line_height);
+ ObjectTypeDB::bind_method(_MD("get_line_count"), &Label::get_line_count);
+ ObjectTypeDB::bind_method(_MD("get_visible_line_count"), &Label::get_visible_line_count);
+ ObjectTypeDB::bind_method(_MD("get_total_character_count"), &Label::get_total_character_count);
+ ObjectTypeDB::bind_method(_MD("set_visible_characters", "amount"), &Label::set_visible_characters);
+ ObjectTypeDB::bind_method(_MD("get_visible_characters"), &Label::get_visible_characters);
+ ObjectTypeDB::bind_method(_MD("set_percent_visible", "percent_visible"), &Label::set_percent_visible);
+ ObjectTypeDB::bind_method(_MD("get_percent_visible"), &Label::get_percent_visible);
+ ObjectTypeDB::bind_method(_MD("set_lines_skipped", "lines_skipped"), &Label::set_lines_skipped);
+ ObjectTypeDB::bind_method(_MD("get_lines_skipped"), &Label::get_lines_skipped);
+ ObjectTypeDB::bind_method(_MD("set_max_lines_visible", "lines_visible"), &Label::set_max_lines_visible);
+ ObjectTypeDB::bind_method(_MD("get_max_lines_visible"), &Label::get_max_lines_visible);
- BIND_CONSTANT( VALIGN_TOP );
- BIND_CONSTANT( VALIGN_CENTER );
- BIND_CONSTANT( VALIGN_BOTTOM );
- BIND_CONSTANT( VALIGN_FILL );
+ BIND_CONSTANT(ALIGN_LEFT);
+ BIND_CONSTANT(ALIGN_CENTER);
+ BIND_CONSTANT(ALIGN_RIGHT);
+ BIND_CONSTANT(ALIGN_FILL);
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"),_SCS("get_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "align", PROPERTY_HINT_ENUM,"Left,Center,Right,Fill" ),_SCS("set_align"),_SCS("get_align") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),_SCS("set_valign"),_SCS("get_valign") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "autowrap"),_SCS("set_autowrap"),_SCS("has_autowrap") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "clip_text"),_SCS("set_clip_text"),_SCS("is_clipping_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "uppercase"),_SCS("set_uppercase"),_SCS("is_uppercase") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_percent_visible"),_SCS("get_percent_visible") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "lines_skipped", PROPERTY_HINT_RANGE,"0,999,1"),_SCS("set_lines_skipped"),_SCS("get_lines_skipped") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "max_lines_visible", PROPERTY_HINT_RANGE,"-1,999,1"),_SCS("set_max_lines_visible"),_SCS("get_max_lines_visible") );
+ BIND_CONSTANT(VALIGN_TOP);
+ BIND_CONSTANT(VALIGN_CENTER);
+ BIND_CONSTANT(VALIGN_BOTTOM);
+ BIND_CONSTANT(VALIGN_FILL);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"), _SCS("get_text"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), _SCS("set_align"), _SCS("get_align"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "valign", PROPERTY_HINT_ENUM, "Top,Center,Bottom,Fill"), _SCS("set_valign"), _SCS("get_valign"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "autowrap"), _SCS("set_autowrap"), _SCS("has_autowrap"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "clip_text"), _SCS("set_clip_text"), _SCS("is_clipping_text"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "uppercase"), _SCS("set_uppercase"), _SCS("is_uppercase"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE, "0,1,0.001"), _SCS("set_percent_visible"), _SCS("get_percent_visible"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "lines_skipped", PROPERTY_HINT_RANGE, "0,999,1"), _SCS("set_lines_skipped"), _SCS("get_lines_skipped"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_lines_visible", PROPERTY_HINT_RANGE, "-1,999,1"), _SCS("set_max_lines_visible"), _SCS("get_max_lines_visible"));
}
Label::Label(const String &p_text) {
- align=ALIGN_LEFT;
- valign=VALIGN_TOP;
- text="";
- word_cache=NULL;
- word_cache_dirty=true;
- autowrap=false;
- line_count=0;
+ align = ALIGN_LEFT;
+ valign = VALIGN_TOP;
+ text = "";
+ word_cache = NULL;
+ word_cache_dirty = true;
+ autowrap = false;
+ line_count = 0;
set_v_size_flags(0);
- clip=false;
+ clip = false;
set_ignore_mouse(true);
- total_char_cache=0;
- visible_chars=-1;
- percent_visible=1;
- lines_skipped=0;
- max_lines_visible=-1;
+ total_char_cache = 0;
+ visible_chars = -1;
+ percent_visible = 1;
+ lines_skipped = 0;
+ max_lines_visible = -1;
set_text(p_text);
- uppercase=false;
+ uppercase = false;
}
-
Label::~Label() {
while (word_cache) {
- WordCache *current=word_cache;
- word_cache=current->next;
- memdelete( current );
+ WordCache *current = word_cache;
+ word_cache = current->next;
+ memdelete(current);
}
}
-
-
diff --git a/scene/gui/label.h b/scene/gui/label.h
index bd531f7c9..59f5323f5 100644
--- a/scene/gui/label.h
+++ b/scene/gui/label.h
@@ -35,9 +35,9 @@
*/
class Label : public Control {
- OBJ_TYPE( Label, Control );
-public:
+ OBJ_TYPE(Label, Control);
+public:
enum Align {
ALIGN_LEFT,
@@ -69,15 +69,21 @@ private:
struct WordCache {
enum {
- CHAR_NEWLINE=-1,
- CHAR_WRAPLINE=-2
+ CHAR_NEWLINE = -1,
+ CHAR_WRAPLINE = -2
};
int char_pos; // if -1, then newline
int word_len;
int pixel_width;
int space_count;
WordCache *next;
- WordCache() { char_pos=0; word_len=0; pixel_width=0; next=0; space_count=0;}
+ WordCache() {
+ char_pos = 0;
+ word_len = 0;
+ pixel_width = 0;
+ next = 0;
+ space_count = 0;
+ }
};
bool word_cache_dirty;
@@ -90,13 +96,13 @@ private:
int visible_chars;
int lines_skipped;
int max_lines_visible;
+
protected:
void _notification(int p_what);
static void _bind_methods();
// bind helpers
public:
-
virtual Size2 get_minimum_size() const;
void set_align(Align p_align);
@@ -105,7 +111,7 @@ public:
void set_valign(VAlign p_align);
VAlign get_valign() const;
- void set_text(const String& p_string);
+ void set_text(const String &p_string);
String get_text() const;
void set_autowrap(bool p_autowrap);
@@ -134,13 +140,11 @@ public:
int get_line_count() const;
int get_visible_line_count() const;
- Label(const String& p_text=String());
+ Label(const String &p_text = String());
~Label();
-
};
-
-VARIANT_ENUM_CAST( Label::Align );
-VARIANT_ENUM_CAST( Label::VAlign );
+VARIANT_ENUM_CAST(Label::Align);
+VARIANT_ENUM_CAST(Label::VAlign);
#endif
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 523cfee85..bab50b835 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -27,10 +27,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "line_edit.h"
+#include "label.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "print_string.h"
-#include "label.h"
#include "translation.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
@@ -38,27 +38,26 @@
static bool _is_text_char(CharType c) {
- return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_';
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
}
void LineEdit::_input_event(InputEvent p_event) {
-
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
const InputEventMouseButton &b = p_event.mouse_button;
- if (b.pressed && b.button_index==BUTTON_RIGHT) {
+ if (b.pressed && b.button_index == BUTTON_RIGHT) {
menu->set_pos(get_global_transform().xform(get_local_mouse_pos()));
- menu->set_size(Vector2(1,1));
+ menu->set_size(Vector2(1, 1));
menu->popup();
grab_focus();
return;
}
- if (b.button_index!=BUTTON_LEFT)
+ if (b.button_index != BUTTON_LEFT)
break;
_reset_caret_blink_timer();
@@ -71,28 +70,28 @@ void LineEdit::_input_event(InputEvent p_event) {
if (b.mod.shift) {
selection_fill_at_cursor();
- selection.creating=true;
+ selection.creating = true;
} else {
if (b.doubleclick) {
- selection.enabled=true;
- selection.begin=0;
- selection.end=text.length();
- selection.doubleclick=true;
+ selection.enabled = true;
+ selection.begin = 0;
+ selection.end = text.length();
+ selection.doubleclick = true;
}
- selection.drag_attempt=false;
+ selection.drag_attempt = false;
- if ((cursor_pos<selection.begin) || (cursor_pos>selection.end) || !selection.enabled) {
+ if ((cursor_pos < selection.begin) || (cursor_pos > selection.end) || !selection.enabled) {
selection_clear();
- selection.cursor_start=cursor_pos;
- selection.creating=true;
+ selection.cursor_start = cursor_pos;
+ selection.creating = true;
} else if (selection.enabled) {
- selection.drag_attempt=true;
+ selection.drag_attempt = true;
}
}
@@ -102,23 +101,23 @@ void LineEdit::_input_event(InputEvent p_event) {
} else {
- if ( (!selection.creating) && (!selection.doubleclick)) {
+ if ((!selection.creating) && (!selection.doubleclick)) {
selection_clear();
}
- selection.creating=false;
- selection.doubleclick=false;
+ selection.creating = false;
+ selection.doubleclick = false;
if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->show_virtual_keyboard(text,get_global_rect());
+ OS::get_singleton()->show_virtual_keyboard(text, get_global_rect());
}
update();
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion& m=p_event.mouse_motion;
+ const InputEventMouseMotion &m = p_event.mouse_motion;
- if (m.button_mask&BUTTON_LEFT) {
+ if (m.button_mask & BUTTON_LEFT) {
if (selection.creating) {
set_cursor_at_pixel_pos(m.x);
@@ -129,22 +128,21 @@ void LineEdit::_input_event(InputEvent p_event) {
} break;
case InputEvent::KEY: {
- const InputEventKey &k =p_event.key;
+ const InputEventKey &k = p_event.key;
if (!k.pressed)
return;
- unsigned int code = k.scancode;
-
+ unsigned int code = k.scancode;
if (k.mod.command) {
- bool handled=true;
+ bool handled = true;
switch (code) {
case (KEY_X): { // CUT
- if(editable) {
+ if (editable) {
cut_text();
}
@@ -158,7 +156,7 @@ void LineEdit::_input_event(InputEvent p_event) {
case (KEY_V): { // PASTE
- if(editable) {
+ if (editable) {
paste_text();
}
@@ -167,22 +165,20 @@ void LineEdit::_input_event(InputEvent p_event) {
case (KEY_Z): { // Simple One level undo
- if(editable) {
+ if (editable) {
undo();
-
}
-
} break;
case (KEY_U): { // Delete from start to cursor
- if(editable) {
+ if (editable) {
selection_clear();
undo_text = text;
- text = text.substr(cursor_pos,text.length()-cursor_pos);
+ text = text.substr(cursor_pos, text.length() - cursor_pos);
Ref<Font> font = get_font("font");
@@ -193,16 +189,15 @@ void LineEdit::_input_event(InputEvent p_event) {
}
set_cursor_pos(0);
- emit_signal("text_changed",text);
+ emit_signal("text_changed", text);
_change_notify("text");
}
-
} break;
case (KEY_Y): { // PASTE (Yank for unix users)
- if(editable) {
+ if (editable) {
paste_text();
}
@@ -210,12 +205,12 @@ void LineEdit::_input_event(InputEvent p_event) {
} break;
case (KEY_K): { // Delete from cursor_pos to end
- if(editable) {
+ if (editable) {
selection_clear();
undo_text = text;
- text = text.substr(0,cursor_pos);
- emit_signal("text_changed",text);
+ text = text.substr(0, cursor_pos);
+ emit_signal("text_changed", text);
_change_notify("text");
}
@@ -223,7 +218,7 @@ void LineEdit::_input_event(InputEvent p_event) {
case (KEY_A): { //Select All
select();
} break;
- default: { handled=false;}
+ default: { handled = false; }
}
if (handled) {
@@ -235,13 +230,13 @@ void LineEdit::_input_event(InputEvent p_event) {
_reset_caret_blink_timer();
if (!k.mod.meta) {
- bool handled=true;
+ bool handled = true;
switch (code) {
case KEY_ENTER:
case KEY_RETURN: {
- emit_signal( "text_entered",text );
+ emit_signal("text_entered", text);
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
@@ -254,7 +249,7 @@ void LineEdit::_input_event(InputEvent p_event) {
break;
if (selection.enabled) {
- undo_text=text;
+ undo_text = text;
selection_delete();
break;
}
@@ -263,20 +258,20 @@ void LineEdit::_input_event(InputEvent p_event) {
if (k.mod.alt) {
#else
if (k.mod.alt) {
- handled=false;
+ handled = false;
break;
} else if (k.mod.command) {
#endif
- int cc=cursor_pos;
- bool prev_char=false;
+ int cc = cursor_pos;
+ bool prev_char = false;
- while (cc>0) {
- bool ischar=_is_text_char(text[cc-1]);
+ while (cc > 0) {
+ bool ischar = _is_text_char(text[cc - 1]);
if (prev_char && !ischar)
break;
- prev_char=ischar;
+ prev_char = ischar;
cc--;
}
@@ -285,7 +280,7 @@ void LineEdit::_input_event(InputEvent p_event) {
set_cursor_pos(cc);
} else {
- undo_text=text;
+ undo_text = text;
delete_char();
}
@@ -302,7 +297,7 @@ void LineEdit::_input_event(InputEvent p_event) {
#ifndef APPLE_STYLE_KEYS
if (!k.mod.alt)
#endif
- shift_selection_check_pre(k.mod.shift);
+ shift_selection_check_pre(k.mod.shift);
#ifdef APPLE_STYLE_KEYS
if (k.mod.command) {
@@ -311,27 +306,27 @@ void LineEdit::_input_event(InputEvent p_event) {
#else
if (k.mod.alt) {
- handled=false;
+ handled = false;
break;
} else if (k.mod.command) {
#endif
- bool prev_char=false;
- int cc=cursor_pos;
+ bool prev_char = false;
+ int cc = cursor_pos;
- while (cc>0) {
- bool ischar=_is_text_char(text[cc-1]);
+ while (cc > 0) {
+ bool ischar = _is_text_char(text[cc - 1]);
if (prev_char && !ischar)
break;
- prev_char=ischar;
+ prev_char = ischar;
cc--;
}
set_cursor_pos(cc);
} else {
- set_cursor_pos(get_cursor_pos()-1);
+ set_cursor_pos(get_cursor_pos() - 1);
}
shift_selection_check_post(k.mod.shift);
@@ -354,27 +349,27 @@ void LineEdit::_input_event(InputEvent p_event) {
} else if (k.mod.alt) {
#else
if (k.mod.alt) {
- handled=false;
+ handled = false;
break;
} else if (k.mod.command) {
#endif
- bool prev_char=false;
- int cc=cursor_pos;
+ bool prev_char = false;
+ int cc = cursor_pos;
- while (cc<text.length()) {
- bool ischar=_is_text_char(text[cc]);
+ while (cc < text.length()) {
+ bool ischar = _is_text_char(text[cc]);
if (prev_char && !ischar)
break;
- prev_char=ischar;
+ prev_char = ischar;
cc++;
}
set_cursor_pos(cc);
} else {
- set_cursor_pos(get_cursor_pos()+1);
+ set_cursor_pos(get_cursor_pos() + 1);
}
shift_selection_check_post(k.mod.shift);
@@ -391,43 +386,43 @@ void LineEdit::_input_event(InputEvent p_event) {
}
if (selection.enabled) {
- undo_text=text;
+ undo_text = text;
selection_delete();
break;
}
int text_len = text.length();
- if (cursor_pos==text_len)
+ if (cursor_pos == text_len)
break; // nothing to do
#ifdef APPLE_STYLE_KEYS
if (k.mod.alt) {
#else
if (k.mod.alt) {
- handled=false;
+ handled = false;
break;
} else if (k.mod.command) {
#endif
- int cc=cursor_pos;
+ int cc = cursor_pos;
- bool prev_char=false;
+ bool prev_char = false;
- while (cc<text.length()) {
+ while (cc < text.length()) {
- bool ischar=_is_text_char(text[cc]);
+ bool ischar = _is_text_char(text[cc]);
if (prev_char && !ischar)
break;
- prev_char=ischar;
+ prev_char = ischar;
cc++;
}
- delete_text(cursor_pos,cc);
+ delete_text(cursor_pos, cc);
} else {
- undo_text=text;
- set_cursor_pos(cursor_pos+1);
+ undo_text = text;
+ set_cursor_pos(cursor_pos + 1);
delete_char();
}
@@ -459,23 +454,22 @@ void LineEdit::_input_event(InputEvent p_event) {
shift_selection_check_post(k.mod.shift);
} break;
-
default: {
- handled=false;
+ handled = false;
} break;
}
if (handled) {
accept_event();
} else if (!k.mod.alt && !k.mod.command) {
- if (k.unicode>=32 && k.scancode!=KEY_DELETE) {
+ if (k.unicode >= 32 && k.scancode != KEY_DELETE) {
if (editable) {
selection_delete();
- CharType ucodestr[2]={(CharType)k.unicode,0};
+ CharType ucodestr[2] = { (CharType)k.unicode, 0 };
append_at_cursor(ucodestr);
- emit_signal("text_changed",text);
+ emit_signal("text_changed", text);
_change_notify("text");
accept_event();
@@ -487,14 +481,11 @@ void LineEdit::_input_event(InputEvent p_event) {
}
update();
-
}
-
return;
} break;
-
}
}
@@ -505,31 +496,30 @@ void LineEdit::set_align(Align p_align) {
update();
}
-LineEdit::Align LineEdit::get_align() const{
+LineEdit::Align LineEdit::get_align() const {
return align;
}
-Variant LineEdit::get_drag_data(const Point2& p_point) {
+Variant LineEdit::get_drag_data(const Point2 &p_point) {
if (selection.drag_attempt && selection.enabled) {
String t = text.substr(selection.begin, selection.end - selection.begin);
- Label *l = memnew( Label );
+ Label *l = memnew(Label);
l->set_text(t);
set_drag_preview(l);
- return t;
+ return t;
}
return Variant();
-
}
-bool LineEdit::can_drop_data(const Point2& p_point,const Variant& p_data) const{
+bool LineEdit::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
- return p_data.get_type()==Variant::STRING;
+ return p_data.get_type() == Variant::STRING;
}
-void LineEdit::drop_data(const Point2& p_point,const Variant& p_data){
+void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) {
- if (p_data.get_type()==Variant::STRING) {
+ if (p_data.get_type() == Variant::STRING) {
set_cursor_at_pixel_pos(p_point.x);
int selected = selection.end - selection.begin;
@@ -542,30 +532,29 @@ void LineEdit::drop_data(const Point2& p_point,const Variant& p_data){
text.erase(selection.begin, selected);
append_at_cursor(p_data);
- selection.begin = cursor_pos-selected;
+ selection.begin = cursor_pos - selected;
selection.end = cursor_pos;
}
}
-
void LineEdit::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
#ifdef TOOLS_ENABLED
case NOTIFICATION_ENTER_TREE: {
if (get_tree()->is_editor_hint()) {
cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
- if (!EditorSettings::get_singleton()->is_connected("settings_changed",this,"_editor_settings_changed")) {
- EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
+ if (!EditorSettings::get_singleton()->is_connected("settings_changed", this, "_editor_settings_changed")) {
+ EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed");
}
}
} break;
#endif
case NOTIFICATION_RESIZED: {
- set_cursor_pos( get_cursor_pos() );
+ set_cursor_pos(get_cursor_pos());
} break;
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
@@ -584,100 +573,100 @@ void LineEdit::_notification(int p_what) {
draw_caret = false;
}
- int width,height;
+ int width, height;
- Size2 size=get_size();
- width=size.width;
- height=size.height;
+ Size2 size = get_size();
+ width = size.width;
+ height = size.height;
RID ci = get_canvas_item();
Ref<StyleBox> style = get_stylebox("normal");
if (!is_editable())
- style=get_stylebox("read_only");
+ style = get_stylebox("read_only");
- Ref<Font> font=get_font("font");
+ Ref<Font> font = get_font("font");
- style->draw( ci, Rect2( Point2(), size ) );
+ style->draw(ci, Rect2(Point2(), size));
if (has_focus()) {
- get_stylebox("focus")->draw( ci, Rect2( Point2(), size ) );
+ get_stylebox("focus")->draw(ci, Rect2(Point2(), size));
}
- int x_ofs=0;
+ int x_ofs = 0;
switch (align) {
case ALIGN_FILL:
case ALIGN_LEFT: {
- x_ofs=style->get_offset().x;
+ x_ofs = style->get_offset().x;
} break;
case ALIGN_CENTER: {
- x_ofs=int(size.width-(cached_width))/2;
+ x_ofs = int(size.width - (cached_width)) / 2;
} break;
case ALIGN_RIGHT: {
- x_ofs=int(size.width-style->get_offset().x-(cached_width));
+ x_ofs = int(size.width - style->get_offset().x - (cached_width));
} break;
}
- int ofs_max=width-style->get_minimum_size().width;
- int char_ofs=window_pos;
+ int ofs_max = width - style->get_minimum_size().width;
+ int char_ofs = window_pos;
- int y_area=height-style->get_minimum_size().height;
- int y_ofs=style->get_offset().y;
+ int y_area = height - style->get_minimum_size().height;
+ int y_ofs = style->get_offset().y;
- int font_ascent=font->get_ascent();
+ int font_ascent = font->get_ascent();
- Color selection_color=get_color("selection_color");
- Color font_color=get_color("font_color");
- Color font_color_selected=get_color("font_color_selected");
- Color cursor_color=get_color("cursor_color");
+ Color selection_color = get_color("selection_color");
+ Color font_color = get_color("font_color");
+ Color font_color_selected = get_color("font_color_selected");
+ Color cursor_color = get_color("cursor_color");
- const String& t = text.empty() ? placeholder : text;
+ const String &t = text.empty() ? placeholder : text;
// draw placeholder color
- if(text.empty())
+ if (text.empty())
font_color.a *= placeholder_alpha;
int caret_height = font->get_height() > y_area ? y_area : font->get_height();
- while(true) {
+ while (true) {
- //end of string, break!
- if (char_ofs>=t.length())
+ //end of string, break!
+ if (char_ofs >= t.length())
break;
- CharType cchar=pass?'*':t[char_ofs];
- CharType next=pass?'*':t[char_ofs+1];
- int char_width=font->get_char_size( cchar,next ).width;
+ CharType cchar = pass ? '*' : t[char_ofs];
+ CharType next = pass ? '*' : t[char_ofs + 1];
+ int char_width = font->get_char_size(cchar, next).width;
- // end of widget, break!
+ // end of widget, break!
if ((x_ofs + char_width) > ofs_max)
break;
-
- bool selected=selection.enabled && char_ofs>=selection.begin && char_ofs<selection.end;
+ bool selected = selection.enabled && char_ofs >= selection.begin && char_ofs < selection.end;
if (selected)
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color);
-
font->draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, selected ? font_color_selected : font_color);
- if (char_ofs==cursor_pos && draw_caret) {
+ if (char_ofs == cursor_pos && draw_caret) {
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
- Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color );
+ Point2(x_ofs, y_ofs), Size2(1, caret_height)),
+ cursor_color);
}
- x_ofs+=char_width;
+ x_ofs += char_width;
char_ofs++;
}
- if (char_ofs==cursor_pos && draw_caret) {//may be at the end
+ if (char_ofs == cursor_pos && draw_caret) { //may be at the end
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
- Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color );
+ Point2(x_ofs, y_ofs), Size2(1, caret_height)),
+ cursor_color);
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -687,7 +676,7 @@ void LineEdit::_notification(int p_what) {
}
if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->show_virtual_keyboard(text,get_global_rect());
+ OS::get_singleton()->show_virtual_keyboard(text, get_global_rect());
} break;
case NOTIFICATION_FOCUS_EXIT: {
@@ -696,13 +685,12 @@ void LineEdit::_notification(int p_what) {
OS::get_singleton()->hide_virtual_keyboard();
} break;
-
}
}
void LineEdit::copy_text() {
- if(selection.enabled) {
+ if (selection.enabled) {
OS::get_singleton()->set_clipboard(text.substr(selection.begin, selection.end - selection.begin));
}
@@ -710,7 +698,7 @@ void LineEdit::copy_text() {
void LineEdit::cut_text() {
- if(selection.enabled) {
+ if (selection.enabled) {
undo_text = text;
OS::get_singleton()->set_clipboard(text.substr(selection.begin, selection.end - selection.begin));
selection_delete();
@@ -721,17 +709,14 @@ void LineEdit::paste_text() {
String paste_buffer = OS::get_singleton()->get_clipboard();
- if(paste_buffer != "") {
+ if (paste_buffer != "") {
- if(selection.enabled) selection_delete();
+ if (selection.enabled) selection_delete();
append_at_cursor(paste_buffer);
- emit_signal("text_changed",text);
+ emit_signal("text_changed", text);
_change_notify("text");
}
-
-
-
}
void LineEdit::undo() {
@@ -742,28 +727,26 @@ void LineEdit::undo() {
Ref<Font> font = get_font("font");
cached_width = 0;
- for (int i = 0; i<text.length(); i++)
+ for (int i = 0; i < text.length(); i++)
cached_width += font->get_char_size(text[i]).width;
- if(old_cursor_pos > text.length()) {
+ if (old_cursor_pos > text.length()) {
set_cursor_pos(text.length());
} else {
set_cursor_pos(old_cursor_pos);
}
- emit_signal("text_changed",text);
+ emit_signal("text_changed", text);
_change_notify("text");
-
}
void LineEdit::shift_selection_check_pre(bool p_shift) {
- if (!selection.enabled && p_shift) {
- selection.cursor_start=cursor_pos;
+ if (!selection.enabled && p_shift) {
+ selection.cursor_start = cursor_pos;
}
if (!p_shift)
selection_clear();
-
}
void LineEdit::shift_selection_check_post(bool p_shift) {
@@ -789,32 +772,30 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) {
} break;
case ALIGN_CENTER: {
- pixel_ofs=int(size.width-(cached_width))/2;
+ pixel_ofs = int(size.width - (cached_width)) / 2;
} break;
case ALIGN_RIGHT: {
- pixel_ofs=int(size.width-style->get_offset().x-(cached_width));
+ pixel_ofs = int(size.width - style->get_offset().x - (cached_width));
} break;
}
-
- while (ofs<text.length()) {
+ while (ofs < text.length()) {
int char_w = 0;
if (font != NULL) {
char_w = font->get_char_size(text[ofs]).width;
}
- pixel_ofs+=char_w;
+ pixel_ofs += char_w;
if (pixel_ofs > p_x) { //found what we look for
break;
}
-
ofs++;
}
- set_cursor_pos( ofs );
+ set_cursor_pos(ofs);
/*
int new_cursor_pos=p_x;
@@ -824,7 +805,6 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) {
set_cursor_pos(window_pos+new_cursor_pos); */
}
-
bool LineEdit::cursor_get_blink_enabled() const {
return caret_blink_enabled;
}
@@ -855,7 +835,7 @@ void LineEdit::_reset_caret_blink_timer() {
draw_caret = true;
update();
}
- }
+}
void LineEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
@@ -866,23 +846,23 @@ void LineEdit::_toggle_draw_caret() {
void LineEdit::delete_char() {
- if ((text.length()<=0) || (cursor_pos==0)) return;
+ if ((text.length() <= 0) || (cursor_pos == 0)) return;
Ref<Font> font = get_font("font");
if (font != NULL) {
cached_width -= font->get_char_size(text[cursor_pos - 1]).width;
}
- text.erase( cursor_pos-1, 1 );
+ text.erase(cursor_pos - 1, 1);
- set_cursor_pos(get_cursor_pos()-1);
+ set_cursor_pos(get_cursor_pos() - 1);
- if (cursor_pos==window_pos) {
+ if (cursor_pos == window_pos) {
- // set_window_pos(cursor_pos-get_window_length());
+ // set_window_pos(cursor_pos-get_window_length());
}
- emit_signal("text_changed",text);
+ emit_signal("text_changed", text);
_change_notify("text");
}
@@ -890,32 +870,29 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) {
undo_text = text;
- if (text.size() > 0)
- {
+ if (text.size() > 0) {
Ref<Font> font = get_font("font");
if (font != NULL) {
for (int i = p_from_column; i < p_to_column; i++)
cached_width -= font->get_char_size(text[i]).width;
}
- }
- else
- {
+ } else {
cached_width = 0;
}
- text.erase(p_from_column,p_to_column-p_from_column);
- cursor_pos-=CLAMP( cursor_pos-p_from_column, 0, p_to_column-p_from_column);
+ text.erase(p_from_column, p_to_column - p_from_column);
+ cursor_pos -= CLAMP(cursor_pos - p_from_column, 0, p_to_column - p_from_column);
- if (cursor_pos>=text.length()) {
+ if (cursor_pos >= text.length()) {
- cursor_pos=text.length();
+ cursor_pos = text.length();
}
- if (window_pos>cursor_pos) {
+ if (window_pos > cursor_pos) {
- window_pos=cursor_pos;
+ window_pos = cursor_pos;
}
- emit_signal("text_changed",text);
+ emit_signal("text_changed", text);
_change_notify("text");
}
@@ -924,14 +901,14 @@ void LineEdit::set_text(String p_text) {
clear_internal();
append_at_cursor(p_text);
update();
- cursor_pos=0;
- window_pos=0;
+ cursor_pos = 0;
+ window_pos = 0;
}
void LineEdit::clear() {
clear_internal();
- emit_signal("text_changed",text);
+ emit_signal("text_changed", text);
_change_notify("text");
}
@@ -951,7 +928,6 @@ String LineEdit::get_placeholder() const {
return placeholder;
}
-
void LineEdit::set_placeholder_alpha(float p_alpha) {
placeholder_alpha = p_alpha;
@@ -965,76 +941,72 @@ float LineEdit::get_placeholder_alpha() const {
void LineEdit::set_cursor_pos(int p_pos) {
- if (p_pos>(int)text.length())
- p_pos=text.length();
+ if (p_pos > (int)text.length())
+ p_pos = text.length();
- if(p_pos<0)
- p_pos=0;
+ if (p_pos < 0)
+ p_pos = 0;
-
-
- cursor_pos=p_pos;
+ cursor_pos = p_pos;
if (!is_inside_tree()) {
- window_pos=cursor_pos;
+ window_pos = cursor_pos;
return;
}
Ref<StyleBox> style = get_stylebox("normal");
- Ref<Font> font=get_font("font");
+ Ref<Font> font = get_font("font");
- if (cursor_pos<window_pos) {
+ if (cursor_pos < window_pos) {
/* Adjust window if cursor goes too much to the left */
set_window_pos(cursor_pos);
- } else if (cursor_pos>window_pos) {
+ } else if (cursor_pos > window_pos) {
/* Adjust window if cursor goes too much to the right */
- int window_width=get_size().width-style->get_minimum_size().width;
+ int window_width = get_size().width - style->get_minimum_size().width;
- if (window_width<0)
+ if (window_width < 0)
return;
- int wp=window_pos;
+ int wp = window_pos;
if (font.is_valid()) {
- int accum_width=0;
+ int accum_width = 0;
- for(int i=cursor_pos;i>=window_pos;i--) {
+ for (int i = cursor_pos; i >= window_pos; i--) {
- if (i>=text.length()) {
- accum_width=font->get_char_size(' ').width; //anything should do
+ if (i >= text.length()) {
+ accum_width = font->get_char_size(' ').width; //anything should do
} else {
- accum_width+=font->get_char_size(text[i],i+1<text.length()?text[i+1]:0).width; //anything should do
+ accum_width += font->get_char_size(text[i], i + 1 < text.length() ? text[i + 1] : 0).width; //anything should do
}
- if (accum_width>=window_width)
+ if (accum_width >= window_width)
break;
- wp=i;
+ wp = i;
}
}
- if (wp!=window_pos)
- set_window_pos( wp );
-
+ if (wp != window_pos)
+ set_window_pos(wp);
}
update();
}
-int LineEdit::get_cursor_pos() const {
+int LineEdit::get_cursor_pos() const {
return cursor_pos;
}
void LineEdit::set_window_pos(int p_pos) {
- window_pos=p_pos;
- if (window_pos<0) window_pos=0;
+ window_pos = p_pos;
+ if (window_pos < 0) window_pos = 0;
}
void LineEdit::append_at_cursor(String p_text) {
-
- if ( ( max_length <= 0 ) || (text.length()+p_text.length() <= max_length)) {
+ if ((max_length <= 0) || (text.length() + p_text.length() <= max_length)) {
undo_text = text;
@@ -1042,36 +1014,35 @@ void LineEdit::append_at_cursor(String p_text) {
if (font != NULL) {
for (int i = 0; i < p_text.length(); i++)
cached_width += font->get_char_size(p_text[i]).width;
- }
- else {
+ } else {
cached_width = 0;
}
- String pre = text.substr( 0, cursor_pos );
- String post = text.substr( cursor_pos, text.length()-cursor_pos );
- text=pre+p_text+post;
- set_cursor_pos(cursor_pos+p_text.length());
+ String pre = text.substr(0, cursor_pos);
+ String post = text.substr(cursor_pos, text.length() - cursor_pos);
+ text = pre + p_text + post;
+ set_cursor_pos(cursor_pos + p_text.length());
}
}
void LineEdit::clear_internal() {
cached_width = 0;
- cursor_pos=0;
- window_pos=0;
- undo_text="";
- text="";
+ cursor_pos = 0;
+ window_pos = 0;
+ undo_text = "";
+ text = "";
update();
}
Size2 LineEdit::get_minimum_size() const {
Ref<StyleBox> style = get_stylebox("normal");
- Ref<Font> font=get_font("font");
+ Ref<Font> font = get_font("font");
- Size2 min=style->get_minimum_size();
- min.height+=font->get_height();
- min.width+=get_constant("minimum_spaces")*font->get_char_size(' ').x;
+ Size2 min = style->get_minimum_size();
+ min.height += font->get_height();
+ min.width += get_constant("minimum_spaces") * font->get_char_size(' ').x;
return min;
}
@@ -1079,26 +1050,26 @@ Size2 LineEdit::get_minimum_size() const {
void LineEdit::selection_clear() {
- selection.begin=0;
- selection.end=0;
- selection.cursor_start=0;
- selection.enabled=false;
- selection.creating=false;
- selection.doubleclick=false;
+ selection.begin = 0;
+ selection.end = 0;
+ selection.cursor_start = 0;
+ selection.enabled = false;
+ selection.creating = false;
+ selection.doubleclick = false;
update();
}
void LineEdit::selection_delete() {
if (selection.enabled)
- delete_text(selection.begin,selection.end);
+ delete_text(selection.begin, selection.end);
selection_clear();
}
void LineEdit::set_max_length(int p_max_length) {
- ERR_FAIL_COND(p_max_length<0);
+ ERR_FAIL_COND(p_max_length < 0);
max_length = p_max_length;
set_text(text);
}
@@ -1112,16 +1083,16 @@ void LineEdit::selection_fill_at_cursor() {
int aux;
- selection.begin=cursor_pos;
- selection.end=selection.cursor_start;
+ selection.begin = cursor_pos;
+ selection.end = selection.cursor_start;
- if (selection.end<selection.begin) {
- aux=selection.end;
- selection.end=selection.begin;
- selection.begin=aux;
+ if (selection.end < selection.begin) {
+ aux = selection.end;
+ selection.end = selection.begin;
+ selection.begin = aux;
}
- selection.enabled=(selection.begin!=selection.end);
+ selection.enabled = (selection.begin != selection.end);
}
void LineEdit::select_all() {
@@ -1129,15 +1100,14 @@ void LineEdit::select_all() {
if (!text.length())
return;
- selection.begin=0;
- selection.end=text.length();
- selection.enabled=true;
+ selection.begin = 0;
+ selection.end = text.length();
+ selection.enabled = true;
update();
-
}
void LineEdit::set_editable(bool p_editable) {
- editable=p_editable;
+ editable = p_editable;
update();
}
@@ -1148,7 +1118,7 @@ bool LineEdit::is_editable() const {
void LineEdit::set_secret(bool p_secret) {
- pass=p_secret;
+ pass = p_secret;
update();
}
bool LineEdit::is_secret() const {
@@ -1158,38 +1128,38 @@ bool LineEdit::is_secret() const {
void LineEdit::select(int p_from, int p_to) {
- if (p_from==0 && p_to==0) {
+ if (p_from == 0 && p_to == 0) {
selection_clear();
return;
}
int len = text.length();
- if (p_from<0)
- p_from=0;
- if (p_from>len)
- p_from=len;
- if (p_to<0 || p_to>len)
- p_to=len;
+ if (p_from < 0)
+ p_from = 0;
+ if (p_from > len)
+ p_from = len;
+ if (p_to < 0 || p_to > len)
+ p_to = len;
- if (p_from>=p_to)
+ if (p_from >= p_to)
return;
- selection.enabled=true;
- selection.begin=p_from;
- selection.end=p_to;
- selection.creating=false;
- selection.doubleclick=false;
+ selection.enabled = true;
+ selection.begin = p_from;
+ selection.end = p_to;
+ selection.creating = false;
+ selection.doubleclick = false;
update();
}
bool LineEdit::is_text_field() const {
- return true;
+ return true;
}
void LineEdit::menu_option(int p_option) {
- switch(p_option) {
+ switch (p_option) {
case MENU_CUT: {
if (editable) {
cut_text();
@@ -1215,9 +1185,7 @@ void LineEdit::menu_option(int p_option) {
case MENU_UNDO: {
undo();
} break;
-
}
-
}
PopupMenu *LineEdit::get_menu() const {
@@ -1225,120 +1193,114 @@ PopupMenu *LineEdit::get_menu() const {
}
#ifdef TOOLS_ENABLED
- void LineEdit::_editor_settings_changed() {
- cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
- cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
- }
+void LineEdit::_editor_settings_changed() {
+ cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
+ cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
+}
#endif
void LineEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret);
+ ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"), &LineEdit::_toggle_draw_caret);
#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method("_editor_settings_changed",&LineEdit::_editor_settings_changed);
+ ObjectTypeDB::bind_method("_editor_settings_changed", &LineEdit::_editor_settings_changed);
#endif
ObjectTypeDB::bind_method(_MD("set_align", "align"), &LineEdit::set_align);
ObjectTypeDB::bind_method(_MD("get_align"), &LineEdit::get_align);
- ObjectTypeDB::bind_method(_MD("_input_event"),&LineEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("clear"),&LineEdit::clear);
- ObjectTypeDB::bind_method(_MD("select_all"),&LineEdit::select_all);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&LineEdit::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&LineEdit::get_text);
- ObjectTypeDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
- ObjectTypeDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
- ObjectTypeDB::bind_method(_MD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
- ObjectTypeDB::bind_method(_MD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
- ObjectTypeDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
- ObjectTypeDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&LineEdit::cursor_set_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_enabled"),&LineEdit::cursor_get_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&LineEdit::cursor_set_blink_speed);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_speed"),&LineEdit::cursor_get_blink_speed);
- ObjectTypeDB::bind_method(_MD("set_max_length","chars"),&LineEdit::set_max_length);
- ObjectTypeDB::bind_method(_MD("get_max_length"),&LineEdit::get_max_length);
- ObjectTypeDB::bind_method(_MD("append_at_cursor","text"),&LineEdit::append_at_cursor);
- ObjectTypeDB::bind_method(_MD("set_editable","enabled"),&LineEdit::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable"),&LineEdit::is_editable);
- ObjectTypeDB::bind_method(_MD("set_secret","enabled"),&LineEdit::set_secret);
- ObjectTypeDB::bind_method(_MD("is_secret"),&LineEdit::is_secret);
- ObjectTypeDB::bind_method(_MD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("menu_option","option"),&LineEdit::menu_option);
- ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&LineEdit::get_menu);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &LineEdit::_input_event);
+ ObjectTypeDB::bind_method(_MD("clear"), &LineEdit::clear);
+ ObjectTypeDB::bind_method(_MD("select_all"), &LineEdit::select_all);
+ ObjectTypeDB::bind_method(_MD("set_text", "text"), &LineEdit::set_text);
+ ObjectTypeDB::bind_method(_MD("get_text"), &LineEdit::get_text);
+ ObjectTypeDB::bind_method(_MD("set_placeholder", "text"), &LineEdit::set_placeholder);
+ ObjectTypeDB::bind_method(_MD("get_placeholder"), &LineEdit::get_placeholder);
+ ObjectTypeDB::bind_method(_MD("set_placeholder_alpha", "alpha"), &LineEdit::set_placeholder_alpha);
+ ObjectTypeDB::bind_method(_MD("get_placeholder_alpha"), &LineEdit::get_placeholder_alpha);
+ ObjectTypeDB::bind_method(_MD("set_cursor_pos", "pos"), &LineEdit::set_cursor_pos);
+ ObjectTypeDB::bind_method(_MD("get_cursor_pos"), &LineEdit::get_cursor_pos);
+ ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"), &LineEdit::cursor_set_blink_enabled);
+ ObjectTypeDB::bind_method(_MD("cursor_get_blink_enabled"), &LineEdit::cursor_get_blink_enabled);
+ ObjectTypeDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"), &LineEdit::cursor_set_blink_speed);
+ ObjectTypeDB::bind_method(_MD("cursor_get_blink_speed"), &LineEdit::cursor_get_blink_speed);
+ ObjectTypeDB::bind_method(_MD("set_max_length", "chars"), &LineEdit::set_max_length);
+ ObjectTypeDB::bind_method(_MD("get_max_length"), &LineEdit::get_max_length);
+ ObjectTypeDB::bind_method(_MD("append_at_cursor", "text"), &LineEdit::append_at_cursor);
+ ObjectTypeDB::bind_method(_MD("set_editable", "enabled"), &LineEdit::set_editable);
+ ObjectTypeDB::bind_method(_MD("is_editable"), &LineEdit::is_editable);
+ ObjectTypeDB::bind_method(_MD("set_secret", "enabled"), &LineEdit::set_secret);
+ ObjectTypeDB::bind_method(_MD("is_secret"), &LineEdit::is_secret);
+ ObjectTypeDB::bind_method(_MD("select", "from", "to"), &LineEdit::select, DEFVAL(0), DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("menu_option", "option"), &LineEdit::menu_option);
+ ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"), &LineEdit::get_menu);
- ADD_SIGNAL( MethodInfo("text_changed", PropertyInfo( Variant::STRING, "text" )) );
- ADD_SIGNAL( MethodInfo("text_entered", PropertyInfo( Variant::STRING, "text" )) );
+ ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "text")));
+ ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "text")));
BIND_CONSTANT(ALIGN_LEFT);
BIND_CONSTANT(ALIGN_CENTER);
BIND_CONSTANT(ALIGN_RIGHT);
BIND_CONSTANT(ALIGN_FILL);
- BIND_CONSTANT( MENU_CUT );
- BIND_CONSTANT( MENU_COPY );
- BIND_CONSTANT( MENU_PASTE );
- BIND_CONSTANT( MENU_CLEAR );
- BIND_CONSTANT( MENU_SELECT_ALL );
- BIND_CONSTANT( MENU_UNDO );
- BIND_CONSTANT( MENU_MAX );
+ BIND_CONSTANT(MENU_CUT);
+ BIND_CONSTANT(MENU_COPY);
+ BIND_CONSTANT(MENU_PASTE);
+ BIND_CONSTANT(MENU_CLEAR);
+ BIND_CONSTANT(MENU_SELECT_ALL);
+ BIND_CONSTANT(MENU_UNDO);
+ BIND_CONSTANT(MENU_MAX);
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text" ), _SCS("set_text"),_SCS("get_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder/text" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder/alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "text"), _SCS("set_text"), _SCS("get_text"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "placeholder/text"), _SCS("set_placeholder"), _SCS("get_placeholder"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "placeholder/alpha", PROPERTY_HINT_RANGE, "0,1,0.001"), _SCS("set_placeholder_alpha"), _SCS("get_placeholder_alpha"));
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), _SCS("set_align"), _SCS("get_align"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "max_length" ), _SCS("set_max_length"),_SCS("get_max_length") );
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "editable" ), _SCS("set_editable"),_SCS("is_editable") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "secret" ), _SCS("set_secret"),_SCS("is_secret") );
- ADD_PROPERTY( PropertyInfo( Variant::INT,"focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_focus_mode"), _SCS("get_focus_mode") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "max_length"), _SCS("set_max_length"), _SCS("get_max_length"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "editable"), _SCS("set_editable"), _SCS("is_editable"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "secret"), _SCS("set_secret"), _SCS("is_secret"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), _SCS("set_focus_mode"), _SCS("get_focus_mode"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1,10,0.1"), _SCS("cursor_set_blink_speed"), _SCS("cursor_get_blink_speed"));
}
LineEdit::LineEdit() {
align = ALIGN_LEFT;
cached_width = 0;
- cursor_pos=0;
- window_pos=0;
- window_has_focus=true;
+ cursor_pos = 0;
+ window_pos = 0;
+ window_has_focus = true;
max_length = 0;
- pass=false;
- placeholder_alpha=0.6;
+ pass = false;
+ placeholder_alpha = 0.6;
selection_clear();
- set_focus_mode( FOCUS_ALL );
- editable=true;
+ set_focus_mode(FOCUS_ALL);
+ editable = true;
set_default_cursor_shape(CURSOR_IBEAM);
set_stop_mouse(true);
- draw_caret=true;
- caret_blink_enabled=false;
+ draw_caret = true;
+ caret_blink_enabled = false;
caret_blink_timer = memnew(Timer);
add_child(caret_blink_timer);
caret_blink_timer->set_wait_time(0.65);
- caret_blink_timer->connect("timeout", this,"_toggle_draw_caret");
+ caret_blink_timer->connect("timeout", this, "_toggle_draw_caret");
cursor_set_blink_enabled(false);
- menu = memnew( PopupMenu );
+ menu = memnew(PopupMenu);
add_child(menu);
- menu->add_item(TTR("Cut"),MENU_CUT,KEY_MASK_CMD|KEY_X);
- menu->add_item(TTR("Copy"),MENU_COPY,KEY_MASK_CMD|KEY_C);
- menu->add_item(TTR("Paste"),MENU_PASTE,KEY_MASK_CMD|KEY_V);
+ menu->add_item(TTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X);
+ menu->add_item(TTR("Copy"), MENU_COPY, KEY_MASK_CMD | KEY_C);
+ menu->add_item(TTR("Paste"), MENU_PASTE, KEY_MASK_CMD | KEY_V);
menu->add_separator();
- menu->add_item(TTR("Select All"),MENU_SELECT_ALL,KEY_MASK_CMD|KEY_A);
- menu->add_item(TTR("Clear"),MENU_CLEAR);
+ menu->add_item(TTR("Select All"), MENU_SELECT_ALL, KEY_MASK_CMD | KEY_A);
+ menu->add_item(TTR("Clear"), MENU_CLEAR);
menu->add_separator();
- menu->add_item(TTR("Undo"),MENU_UNDO,KEY_MASK_CMD|KEY_Z);
- menu->connect("item_pressed",this,"menu_option");
-
-
-
+ menu->add_item(TTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z);
+ menu->connect("item_pressed", this, "menu_option");
}
LineEdit::~LineEdit() {
-
-
}
-
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index fe906f514..b43a16c51 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -37,7 +37,7 @@
*/
class LineEdit : public Control {
- OBJ_TYPE( LineEdit, Control );
+ OBJ_TYPE(LineEdit, Control);
public:
enum Align {
@@ -117,16 +117,16 @@ private:
void _input_event(InputEvent p_event);
void _notification(int p_what);
-
protected:
static void _bind_methods();
+
public:
void set_align(Align p_align);
Align get_align() const;
- virtual Variant get_drag_data(const Point2& p_point);
- virtual bool can_drop_data(const Point2& p_point,const Variant& p_data) const;
- virtual void drop_data(const Point2& p_point,const Variant& p_data);
+ virtual Variant get_drag_data(const Point2 &p_point);
+ virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const;
+ virtual void drop_data(const Point2 &p_point, const Variant &p_data);
void menu_option(int p_option);
PopupMenu *get_menu() const;
@@ -165,17 +165,15 @@ public:
void set_secret(bool p_secret);
bool is_secret() const;
- void select(int p_from=0, int p_to=-1);
+ void select(int p_from = 0, int p_to = -1);
virtual Size2 get_minimum_size() const;
virtual bool is_text_field() const;
LineEdit();
~LineEdit();
-
};
-
VARIANT_ENUM_CAST(LineEdit::Align);
#endif
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index a547521ef..d44918e5c 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -28,10 +28,9 @@
/*************************************************************************/
#include "link_button.h"
+void LinkButton::set_text(const String &p_text) {
-void LinkButton::set_text(const String& p_text) {
-
- text=p_text;
+ text = p_text;
update();
minimum_size_changed();
}
@@ -42,7 +41,7 @@ String LinkButton::get_text() const {
void LinkButton::set_underline_mode(UnderlineMode p_underline_mode) {
- underline_mode=p_underline_mode;
+ underline_mode = p_underline_mode;
update();
}
@@ -51,55 +50,51 @@ LinkButton::UnderlineMode LinkButton::get_underline_mode() const {
return underline_mode;
}
-
Size2 LinkButton::get_minimum_size() const {
- return get_font("font")->get_string_size( text );
+ return get_font("font")->get_string_size(text);
}
-
-
void LinkButton::_notification(int p_what) {
- switch( p_what ) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
-
RID ci = get_canvas_item();
- Size2 size=get_size();
+ Size2 size = get_size();
Color color;
- bool do_underline=false;
+ bool do_underline = false;
//print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode()));
- switch( get_draw_mode() ) {
+ switch (get_draw_mode()) {
case DRAW_NORMAL: {
- color=get_color("font_color");
- do_underline=underline_mode==UNDERLINE_MODE_ALWAYS;
+ color = get_color("font_color");
+ do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
case DRAW_PRESSED: {
if (has_color("font_color_pressed"))
- color=get_color("font_color_pressed");
+ color = get_color("font_color_pressed");
else
- color=get_color("font_color");
+ color = get_color("font_color");
- do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
+ do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_HOVER: {
- color=get_color("font_color_hover");
- do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
+ color = get_color("font_color_hover");
+ do_underline = underline_mode != UNDERLINE_MODE_NEVER;
} break;
case DRAW_DISABLED: {
- color=get_color("font_color_disabled");
- do_underline=underline_mode==UNDERLINE_MODE_ALWAYS;
+ color = get_color("font_color_disabled");
+ do_underline = underline_mode == UNDERLINE_MODE_ALWAYS;
} break;
}
@@ -107,21 +102,19 @@ void LinkButton::_notification(int p_what) {
if (has_focus()) {
Ref<StyleBox> style = get_stylebox("focus");
- style->draw(ci,Rect2(Point2(),size));
+ style->draw(ci, Rect2(Point2(), size));
}
- Ref<Font> font=get_font("font");
-
- draw_string(font,Vector2(0,font->get_ascent()),text,color);
-
+ Ref<Font> font = get_font("font");
+ draw_string(font, Vector2(0, font->get_ascent()), text, color);
if (do_underline) {
int underline_spacing = get_constant("underline_spacing");
int width = font->get_string_size(text).width;
- int y = font->get_ascent()+underline_spacing;
+ int y = font->get_ascent() + underline_spacing;
- draw_line(Vector2(0,y),Vector2(width,y),color);
+ draw_line(Vector2(0, y), Vector2(width, y), color);
}
} break;
@@ -130,24 +123,22 @@ void LinkButton::_notification(int p_what) {
void LinkButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_text","text"),&LinkButton::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&LinkButton::get_text);
-
- ObjectTypeDB::bind_method(_MD("set_underline_mode","underline_mode"),&LinkButton::set_underline_mode);
- ObjectTypeDB::bind_method(_MD("get_underline_mode"),&LinkButton::get_underline_mode);
-
+ ObjectTypeDB::bind_method(_MD("set_text", "text"), &LinkButton::set_text);
+ ObjectTypeDB::bind_method(_MD("get_text"), &LinkButton::get_text);
- BIND_CONSTANT( UNDERLINE_MODE_ALWAYS );
- BIND_CONSTANT( UNDERLINE_MODE_ON_HOVER );
- BIND_CONSTANT( UNDERLINE_MODE_NEVER );
+ ObjectTypeDB::bind_method(_MD("set_underline_mode", "underline_mode"), &LinkButton::set_underline_mode);
+ ObjectTypeDB::bind_method(_MD("get_underline_mode"), &LinkButton::get_underline_mode);
- ADD_PROPERTYNZ(PropertyInfo(Variant::STRING,"text"), _SCS("set_text"), _SCS("get_text"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover,Never"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
+ BIND_CONSTANT(UNDERLINE_MODE_ALWAYS);
+ BIND_CONSTANT(UNDERLINE_MODE_ON_HOVER);
+ BIND_CONSTANT(UNDERLINE_MODE_NEVER);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "text"), _SCS("set_text"), _SCS("get_text"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "underline", PROPERTY_HINT_ENUM, "Always,On Hover,Never"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
}
LinkButton::LinkButton() {
- underline_mode=UNDERLINE_MODE_ALWAYS;
+ underline_mode = UNDERLINE_MODE_ALWAYS;
set_enabled_focus_mode(FOCUS_NONE);
set_default_cursor_shape(CURSOR_POINTING_HAND);
}
diff --git a/scene/gui/link_button.h b/scene/gui/link_button.h
index 992daf256..8e1263a37 100644
--- a/scene/gui/link_button.h
+++ b/scene/gui/link_button.h
@@ -29,33 +29,31 @@
#ifndef LINKBUTTON_H
#define LINKBUTTON_H
-
#include "scene/gui/base_button.h"
#include "scene/resources/bit_mask.h"
class LinkButton : public BaseButton {
- OBJ_TYPE( LinkButton, BaseButton );
-public:
+ OBJ_TYPE(LinkButton, BaseButton);
+public:
enum UnderlineMode {
UNDERLINE_MODE_ALWAYS,
UNDERLINE_MODE_ON_HOVER,
UNDERLINE_MODE_NEVER
};
+
private:
String text;
UnderlineMode underline_mode;
protected:
-
virtual Size2 get_minimum_size() const;
void _notification(int p_what);
static void _bind_methods();
public:
-
- void set_text(const String& p_text);
+ void set_text(const String &p_text);
String get_text() const;
void set_underline_mode(UnderlineMode p_underline_mode);
@@ -64,6 +62,6 @@ public:
LinkButton();
};
-VARIANT_ENUM_CAST( LinkButton::UnderlineMode );
+VARIANT_ENUM_CAST(LinkButton::UnderlineMode);
#endif // LINKBUTTON_H
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp
index 883364b2f..495af8adf 100644
--- a/scene/gui/margin_container.cpp
+++ b/scene/gui/margin_container.cpp
@@ -28,7 +28,6 @@
/*************************************************************************/
#include "margin_container.h"
-
Size2 MarginContainer::get_minimum_size() const {
int margin_left = get_constant("margin_left");
@@ -38,7 +37,7 @@ Size2 MarginContainer::get_minimum_size() const {
Size2 max;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -59,12 +58,11 @@ Size2 MarginContainer::get_minimum_size() const {
max.height += (margin_top + margin_bottom);
return max;
-
}
void MarginContainer::_notification(int p_what) {
- if (p_what==NOTIFICATION_SORT_CHILDREN) {
+ if (p_what == NOTIFICATION_SORT_CHILDREN) {
int margin_left = get_constant("margin_left");
int margin_top = get_constant("margin_top");
@@ -73,7 +71,7 @@ void MarginContainer::_notification(int p_what) {
Size2 s = get_size();
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -81,14 +79,12 @@ void MarginContainer::_notification(int p_what) {
if (c->is_set_as_toplevel())
continue;
- int w=s.width-margin_left-margin_right;
- int h=s.height-margin_top-margin_bottom;
- fit_child_in_rect(c,Rect2(margin_left,margin_top,w,h));
+ int w = s.width - margin_left - margin_right;
+ int h = s.height - margin_top - margin_bottom;
+ fit_child_in_rect(c, Rect2(margin_left, margin_top, w, h));
}
-
}
}
-MarginContainer::MarginContainer()
-{
+MarginContainer::MarginContainer() {
}
diff --git a/scene/gui/margin_container.h b/scene/gui/margin_container.h
index 1959fcaec..0bb82ec78 100644
--- a/scene/gui/margin_container.h
+++ b/scene/gui/margin_container.h
@@ -32,12 +32,12 @@
#include "scene/gui/container.h"
class MarginContainer : public Container {
- OBJ_TYPE(MarginContainer,Container);
+ OBJ_TYPE(MarginContainer, Container);
protected:
void _notification(int p_what);
-public:
+public:
virtual Size2 get_minimum_size() const;
MarginContainer();
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 1ba54f218..b5ee870b0 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -30,11 +30,9 @@
#include "os/keyboard.h"
#include "scene/main/viewport.h"
-
void MenuButton::_unhandled_key_input(InputEvent p_event) {
-
- if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type==InputEvent::KEY || p_event.type==InputEvent::ACTION || p_event.type==InputEvent::JOYSTICK_BUTTON)) {
+ if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type == InputEvent::KEY || p_event.type == InputEvent::ACTION || p_event.type == InputEvent::JOYSTICK_BUTTON)) {
if (!get_parent() || !is_visible() || is_disabled())
return;
@@ -42,26 +40,23 @@ void MenuButton::_unhandled_key_input(InputEvent p_event) {
if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
return; //ignore because of modal window
-
if (popup->activate_item_by_event(p_event))
accept_event();
}
}
-
void MenuButton::pressed() {
emit_signal("about_to_show");
- Size2 size=get_size();
+ Size2 size = get_size();
Point2 gp = get_global_pos();
- popup->set_global_pos( gp + Size2( 0, size.height ) );
- popup->set_size( Size2( size.width, 0) );
- popup->set_parent_rect( Rect2(Point2(gp-popup->get_global_pos()),get_size()));
+ popup->set_global_pos(gp + Size2(0, size.height));
+ popup->set_size(Size2(size.width, 0));
+ popup->set_parent_rect(Rect2(Point2(gp - popup->get_global_pos()), get_size()));
popup->popup();
popup->call_deferred("grab_click_focus");
popup->set_invalidate_click_until_motion();
-
}
void MenuButton::_input_event(InputEvent p_event) {
@@ -93,28 +88,27 @@ Array MenuButton::_get_items() const {
return popup->get("items");
}
-void MenuButton::_set_items(const Array& p_items) {
+void MenuButton::_set_items(const Array &p_items) {
- popup->set("items",p_items);
+ popup->set("items", p_items);
}
void MenuButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_popup:PopupMenu"),&MenuButton::get_popup);
- ObjectTypeDB::bind_method(_MD("_unhandled_key_input"),&MenuButton::_unhandled_key_input);
- ObjectTypeDB::bind_method(_MD("_set_items"),&MenuButton::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&MenuButton::_get_items);
+ ObjectTypeDB::bind_method(_MD("get_popup:PopupMenu"), &MenuButton::get_popup);
+ ObjectTypeDB::bind_method(_MD("_unhandled_key_input"), &MenuButton::_unhandled_key_input);
+ ObjectTypeDB::bind_method(_MD("_set_items"), &MenuButton::_set_items);
+ ObjectTypeDB::bind_method(_MD("_get_items"), &MenuButton::_get_items);
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"), _SCS("_get_items"));
- ADD_SIGNAL( MethodInfo("about_to_show") );
+ ADD_SIGNAL(MethodInfo("about_to_show"));
}
MenuButton::MenuButton() {
-
set_flat(true);
set_enabled_focus_mode(FOCUS_NONE);
- popup = memnew( PopupMenu );
+ popup = memnew(PopupMenu);
popup->hide();
add_child(popup);
popup->set_as_toplevel(true);
@@ -122,9 +116,5 @@ MenuButton::MenuButton() {
set_click_on_press(true);
}
-
MenuButton::~MenuButton() {
-
}
-
-
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index 865d6df55..871bdbac4 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -29,14 +29,14 @@
#ifndef MENU_BUTTON_H
#define MENU_BUTTON_H
-#include "scene/gui/popup_menu.h"
#include "scene/gui/button.h"
+#include "scene/gui/popup_menu.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class MenuButton : public Button {
- OBJ_TYPE( MenuButton, Button );
+ OBJ_TYPE(MenuButton, Button);
bool clicked;
PopupMenu *popup;
@@ -44,15 +44,14 @@ class MenuButton : public Button {
void _unhandled_key_input(InputEvent p_event);
Array _get_items() const;
- void _set_items(const Array& p_items);
+ void _set_items(const Array &p_items);
void _input_event(InputEvent p_event);
-protected:
-
+protected:
static void _bind_methods();
-public:
+public:
PopupMenu *get_popup();
MenuButton();
~MenuButton();
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index d74c03a21..46800b694 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -29,22 +29,19 @@
#include "option_button.h"
#include "print_string.h"
-
Size2 OptionButton::get_minimum_size() const {
-
Size2 minsize = Button::get_minimum_size();
if (has_icon("arrow"))
- minsize.width+=Control::get_icon("arrow")->get_width();
+ minsize.width += Control::get_icon("arrow")->get_width();
return minsize;
}
void OptionButton::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
@@ -53,86 +50,82 @@ void OptionButton::_notification(int p_what) {
RID ci = get_canvas_item();
Ref<Texture> arrow = Control::get_icon("arrow");
- Ref<StyleBox> normal = get_stylebox("normal" );
+ Ref<StyleBox> normal = get_stylebox("normal");
Size2 size = get_size();
- Point2 ofs( size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height-arrow->get_height())/2)));
- arrow->draw(ci,ofs);
+ Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
+ arrow->draw(ci, ofs);
} break;
}
}
-
void OptionButton::_selected(int p_which) {
int selid = -1;
- for (int i=0;i<popup->get_item_count();i++) {
+ for (int i = 0; i < popup->get_item_count(); i++) {
- bool is_clicked = popup->get_item_ID(i)==p_which;
+ bool is_clicked = popup->get_item_ID(i) == p_which;
if (is_clicked) {
- selid=i;
+ selid = i;
break;
}
}
- if (selid==-1 && p_which>=0 && p_which<popup->get_item_count()) {
- _select(p_which,true);
+ if (selid == -1 && p_which >= 0 && p_which < popup->get_item_count()) {
+ _select(p_which, true);
} else {
- ERR_FAIL_COND(selid==-1);
+ ERR_FAIL_COND(selid == -1);
- _select(selid,true);
+ _select(selid, true);
}
}
-
void OptionButton::pressed() {
- Size2 size=get_size();
- popup->set_global_pos( get_global_pos() + Size2( 0, size.height ) );
- popup->set_size( Size2( size.width, 0) );
+ Size2 size = get_size();
+ popup->set_global_pos(get_global_pos() + Size2(0, size.height));
+ popup->set_size(Size2(size.width, 0));
popup->popup();
}
-void OptionButton::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,int p_ID) {
+void OptionButton::add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID) {
- popup->add_icon_check_item( p_icon, p_label, p_ID );
- if (popup->get_item_count()==1)
+ popup->add_icon_check_item(p_icon, p_label, p_ID);
+ if (popup->get_item_count() == 1)
select(0);
}
-void OptionButton::add_item(const String& p_label,int p_ID) {
+void OptionButton::add_item(const String &p_label, int p_ID) {
- popup->add_check_item( p_label, p_ID );
- if (popup->get_item_count()==1)
+ popup->add_check_item(p_label, p_ID);
+ if (popup->get_item_count() == 1)
select(0);
}
-void OptionButton::set_item_text(int p_idx,const String& p_text) {
-
- popup->set_item_text(p_idx,p_text);
+void OptionButton::set_item_text(int p_idx, const String &p_text) {
+ popup->set_item_text(p_idx, p_text);
}
-void OptionButton::set_item_icon(int p_idx,const Ref<Texture>& p_icon) {
-
- popup->set_item_icon(p_idx,p_icon);
+void OptionButton::set_item_icon(int p_idx, const Ref<Texture> &p_icon) {
+ popup->set_item_icon(p_idx, p_icon);
}
-void OptionButton::set_item_ID(int p_idx,int p_ID) {
+void OptionButton::set_item_ID(int p_idx, int p_ID) {
- popup->set_item_ID(p_idx,p_ID);
+ popup->set_item_ID(p_idx, p_ID);
}
-void OptionButton::set_item_metadata(int p_idx,const Variant& p_metadata) {
+void OptionButton::set_item_metadata(int p_idx, const Variant &p_metadata) {
- popup->set_item_metadata(p_idx,p_metadata);
+ popup->set_item_metadata(p_idx, p_metadata);
}
-void OptionButton::set_item_disabled(int p_idx,bool p_disabled) {
+void OptionButton::set_item_disabled(int p_idx, bool p_disabled) {
- popup->set_item_disabled(p_idx,p_disabled);
+ popup->set_item_disabled(p_idx, p_disabled);
}
String OptionButton::get_item_text(int p_idx) const {
@@ -159,8 +152,7 @@ bool OptionButton::is_item_disabled(int p_idx) const {
return popup->is_item_disabled(p_idx);
}
-
-int OptionButton::get_item_count() const {
+int OptionButton::get_item_count() const {
return popup->get_item_count();
}
@@ -174,44 +166,41 @@ void OptionButton::clear() {
popup->clear();
set_text("");
- current=-1;
+ current = -1;
}
-void OptionButton::_select(int p_idx,bool p_emit) {
+void OptionButton::_select(int p_idx, bool p_emit) {
- if (p_idx<0)
+ if (p_idx < 0)
return;
- if (p_idx==current)
+ if (p_idx == current)
return;
- ERR_FAIL_INDEX( p_idx, popup->get_item_count() );
+ ERR_FAIL_INDEX(p_idx, popup->get_item_count());
- for (int i=0;i<popup->get_item_count();i++) {
+ for (int i = 0; i < popup->get_item_count(); i++) {
- popup->set_item_checked(i,i==p_idx);
+ popup->set_item_checked(i, i == p_idx);
}
-
-
- current=p_idx;
- set_text( popup->get_item_text( current ) );
- set_icon( popup->get_item_icon( current ) );
+ current = p_idx;
+ set_text(popup->get_item_text(current));
+ set_icon(popup->get_item_icon(current));
if (is_inside_tree() && p_emit)
- emit_signal("item_selected",current);
+ emit_signal("item_selected", current);
}
void OptionButton::_select_int(int p_which) {
- if (p_which<0 || p_which>=popup->get_item_count())
+ if (p_which < 0 || p_which >= popup->get_item_count())
return;
- _select(p_which,false);
-
+ _select(p_which, false);
}
void OptionButton::select(int p_idx) {
- _select(p_idx,false);
+ _select(p_idx, false);
}
int OptionButton::get_selected() const {
@@ -222,17 +211,16 @@ int OptionButton::get_selected() const {
int OptionButton::get_selected_ID() const {
int idx = get_selected();
- if (idx<0)
+ if (idx < 0)
return 0;
return get_item_ID(current);
}
Variant OptionButton::get_selected_metadata() const {
int idx = get_selected();
- if (idx<0)
+ if (idx < 0)
return Variant();
return get_item_metadata(current);
-
}
void OptionButton::remove_item(int p_idx) {
@@ -243,7 +231,7 @@ void OptionButton::remove_item(int p_idx) {
Array OptionButton::_get_items() const {
Array items;
- for(int i=0;i<get_item_count();i++) {
+ for (int i = 0; i < get_item_count(); i++) {
items.push_back(get_item_text(i));
items.push_back(get_item_icon(i));
@@ -253,90 +241,78 @@ Array OptionButton::_get_items() const {
}
return items;
-
}
-void OptionButton::_set_items(const Array& p_items){
+void OptionButton::_set_items(const Array &p_items) {
ERR_FAIL_COND(p_items.size() % 5);
clear();
- for(int i=0;i<p_items.size();i+=5) {
+ for (int i = 0; i < p_items.size(); i += 5) {
- String text=p_items[i+0];
- Ref<Texture> icon=p_items[i+1];
- bool disabled=p_items[i+2];
- int id=p_items[i+3];
- Variant meta = p_items[i+4];
+ String text = p_items[i + 0];
+ Ref<Texture> icon = p_items[i + 1];
+ bool disabled = p_items[i + 2];
+ int id = p_items[i + 3];
+ Variant meta = p_items[i + 4];
- int idx=get_item_count();
- add_item(text,id);
- set_item_icon(idx,icon);
- set_item_disabled(idx,disabled);
- set_item_metadata(idx,meta);
+ int idx = get_item_count();
+ add_item(text, id);
+ set_item_icon(idx, icon);
+ set_item_disabled(idx, disabled);
+ set_item_metadata(idx, meta);
}
-
-
}
-
void OptionButton::get_translatable_strings(List<String> *p_strings) const {
return popup->get_translatable_strings(p_strings);
}
-
void OptionButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_selected"),&OptionButton::_selected);
+ ObjectTypeDB::bind_method(_MD("_selected"), &OptionButton::_selected);
- ObjectTypeDB::bind_method(_MD("add_item","label","id"),&OptionButton::add_item,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_icon_item","texture:Texture","label","id"),&OptionButton::add_icon_item);
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&OptionButton::set_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","texture:Texture"),&OptionButton::set_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&OptionButton::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&OptionButton::set_item_ID);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&OptionButton::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&OptionButton::get_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_icon:Texture","idx"),&OptionButton::get_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&OptionButton::get_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&OptionButton::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&OptionButton::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&OptionButton::get_item_count);
- ObjectTypeDB::bind_method(_MD("add_separator"),&OptionButton::add_separator);
- ObjectTypeDB::bind_method(_MD("clear"),&OptionButton::clear);
- ObjectTypeDB::bind_method(_MD("select","idx"),&OptionButton::select);
- ObjectTypeDB::bind_method(_MD("get_selected"),&OptionButton::get_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_ID"),&OptionButton::get_selected_ID);
- ObjectTypeDB::bind_method(_MD("get_selected_metadata"),&OptionButton::get_selected_metadata);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&OptionButton::remove_item);
- ObjectTypeDB::bind_method(_MD("_select_int"),&OptionButton::_select_int);
+ ObjectTypeDB::bind_method(_MD("add_item", "label", "id"), &OptionButton::add_item, DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("add_icon_item", "texture:Texture", "label", "id"), &OptionButton::add_icon_item);
+ ObjectTypeDB::bind_method(_MD("set_item_text", "idx", "text"), &OptionButton::set_item_text);
+ ObjectTypeDB::bind_method(_MD("set_item_icon", "idx", "texture:Texture"), &OptionButton::set_item_icon);
+ ObjectTypeDB::bind_method(_MD("set_item_disabled", "idx", "disabled"), &OptionButton::set_item_disabled);
+ ObjectTypeDB::bind_method(_MD("set_item_ID", "idx", "id"), &OptionButton::set_item_ID);
+ ObjectTypeDB::bind_method(_MD("set_item_metadata", "idx", "metadata"), &OptionButton::set_item_metadata);
+ ObjectTypeDB::bind_method(_MD("get_item_text", "idx"), &OptionButton::get_item_text);
+ ObjectTypeDB::bind_method(_MD("get_item_icon:Texture", "idx"), &OptionButton::get_item_icon);
+ ObjectTypeDB::bind_method(_MD("get_item_ID", "idx"), &OptionButton::get_item_ID);
+ ObjectTypeDB::bind_method(_MD("get_item_metadata", "idx"), &OptionButton::get_item_metadata);
+ ObjectTypeDB::bind_method(_MD("is_item_disabled", "idx"), &OptionButton::is_item_disabled);
+ ObjectTypeDB::bind_method(_MD("get_item_count"), &OptionButton::get_item_count);
+ ObjectTypeDB::bind_method(_MD("add_separator"), &OptionButton::add_separator);
+ ObjectTypeDB::bind_method(_MD("clear"), &OptionButton::clear);
+ ObjectTypeDB::bind_method(_MD("select", "idx"), &OptionButton::select);
+ ObjectTypeDB::bind_method(_MD("get_selected"), &OptionButton::get_selected);
+ ObjectTypeDB::bind_method(_MD("get_selected_ID"), &OptionButton::get_selected_ID);
+ ObjectTypeDB::bind_method(_MD("get_selected_metadata"), &OptionButton::get_selected_metadata);
+ ObjectTypeDB::bind_method(_MD("remove_item", "idx"), &OptionButton::remove_item);
+ ObjectTypeDB::bind_method(_MD("_select_int"), &OptionButton::_select_int);
- ObjectTypeDB::bind_method(_MD("_set_items"),&OptionButton::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&OptionButton::_get_items);
+ ObjectTypeDB::bind_method(_MD("_set_items"), &OptionButton::_set_items);
+ ObjectTypeDB::bind_method(_MD("_get_items"), &OptionButton::_get_items);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"selected"), _SCS("_select_int"),_SCS("get_selected") );
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
- ADD_SIGNAL( MethodInfo("item_selected", PropertyInfo( Variant::INT,"ID") ) );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "selected"), _SCS("_select_int"), _SCS("get_selected"));
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"), _SCS("_get_items"));
+ ADD_SIGNAL(MethodInfo("item_selected", PropertyInfo(Variant::INT, "ID")));
}
OptionButton::OptionButton() {
-
- popup = memnew( PopupMenu );
+ popup = memnew(PopupMenu);
popup->hide();
popup->set_as_toplevel(true);
add_child(popup);
- popup->connect("item_pressed", this,"_selected");
+ popup->connect("item_pressed", this, "_selected");
- current=-1;
+ current = -1;
set_text_align(ALIGN_LEFT);
}
-
OptionButton::~OptionButton() {
-
-
-
}
-
-
diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h
index 3dd057151..25715bc02 100644
--- a/scene/gui/option_button.h
+++ b/scene/gui/option_button.h
@@ -36,34 +36,34 @@
*/
class OptionButton : public Button {
- OBJ_TYPE( OptionButton, Button );
+ OBJ_TYPE(OptionButton, Button);
PopupMenu *popup;
int current;
void _selected(int p_which);
- void _select(int p_which,bool p_emit=false);
+ void _select(int p_which, bool p_emit = false);
void _select_int(int p_which);
Array _get_items() const;
- void _set_items(const Array& p_items);
+ void _set_items(const Array &p_items);
virtual void pressed();
-protected:
+protected:
Size2 get_minimum_size() const;
void _notification(int p_what);
static void _bind_methods();
-public:
- void add_icon_item(const Ref<Texture>& p_icon,const String& p_label,int p_ID=-1);
- void add_item(const String& p_label,int p_ID=-1);
+public:
+ void add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID = -1);
+ void add_item(const String &p_label, int p_ID = -1);
- void set_item_text(int p_idx,const String& p_text);
- void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
- void set_item_ID(int p_idx,int p_ID);
- void set_item_metadata(int p_idx,const Variant& p_metadata);
- void set_item_disabled(int p_idx,bool p_disabled);
+ void set_item_text(int p_idx, const String &p_text);
+ void set_item_icon(int p_idx, const Ref<Texture> &p_icon);
+ void set_item_ID(int p_idx, int p_ID);
+ void set_item_metadata(int p_idx, const Variant &p_metadata);
+ void set_item_disabled(int p_idx, bool p_disabled);
String get_item_text(int p_idx) const;
Ref<Texture> get_item_icon(int p_idx) const;
@@ -71,7 +71,6 @@ public:
Variant get_item_metadata(int p_idx) const;
bool is_item_disabled(int p_idx) const;
-
int get_item_count() const;
void add_separator();
@@ -89,7 +88,6 @@ public:
OptionButton();
~OptionButton();
-
};
#endif
diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp
index 68d01ccb6..5f6c4b8ec 100644
--- a/scene/gui/panel.cpp
+++ b/scene/gui/panel.cpp
@@ -31,11 +31,11 @@
void Panel::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
Ref<StyleBox> style = get_stylebox("panel");
- style->draw( ci, Rect2( Point2(), get_size() ) );
+ style->draw(ci, Rect2(Point2(), get_size()));
}
}
@@ -44,9 +44,5 @@ Panel::Panel() {
set_stop_mouse(true);
}
-
-Panel::~Panel()
-{
+Panel::~Panel() {
}
-
-
diff --git a/scene/gui/panel.h b/scene/gui/panel.h
index bb7cd8e58..9dd73ddc6 100644
--- a/scene/gui/panel.h
+++ b/scene/gui/panel.h
@@ -33,16 +33,16 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class Panel : public Control{
+class Panel : public Control {
- OBJ_TYPE(Panel,Control);
-protected:
+ OBJ_TYPE(Panel, Control);
+protected:
void _notification(int p_what);
+
public:
Panel();
~Panel();
-
};
#endif
diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp
index 451a85cf4..a00c91377 100644
--- a/scene/gui/panel_container.cpp
+++ b/scene/gui/panel_container.cpp
@@ -28,19 +28,17 @@
/*************************************************************************/
#include "panel_container.h"
-
Size2 PanelContainer::get_minimum_size() const {
Ref<StyleBox> style;
if (has_stylebox("panel"))
- style=get_stylebox("panel");
+ style = get_stylebox("panel");
else
- style=get_stylebox("panel","PanelContainer");
-
+ style = get_stylebox("panel", "PanelContainer");
Size2 ms;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
@@ -49,53 +47,47 @@ Size2 PanelContainer::get_minimum_size() const {
continue;
Size2 minsize = c->get_combined_minimum_size();
- ms.width = MAX(ms.width , minsize.width);
- ms.height = MAX(ms.height , minsize.height);
-
-
+ ms.width = MAX(ms.width, minsize.width);
+ ms.height = MAX(ms.height, minsize.height);
}
if (style.is_valid())
- ms+=style->get_minimum_size();
+ ms += style->get_minimum_size();
return ms;
-
}
void PanelContainer::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
Ref<StyleBox> style;
if (has_stylebox("panel"))
- style=get_stylebox("panel");
+ style = get_stylebox("panel");
else
- style=get_stylebox("panel","PanelContainer");
-
- style->draw( ci, Rect2( Point2(), get_size() ) );
+ style = get_stylebox("panel", "PanelContainer");
+ style->draw(ci, Rect2(Point2(), get_size()));
}
- if (p_what==NOTIFICATION_SORT_CHILDREN) {
+ if (p_what == NOTIFICATION_SORT_CHILDREN) {
Ref<StyleBox> style;
if (has_stylebox("panel"))
- style=get_stylebox("panel");
+ style = get_stylebox("panel");
else
- style=get_stylebox("panel","PanelContainer");
+ style = get_stylebox("panel", "PanelContainer");
Size2 size = get_size();
Point2 ofs;
if (style.is_valid()) {
- size-=style->get_minimum_size();
- ofs+=style->get_offset();
+ size -= style->get_minimum_size();
+ ofs += style->get_offset();
}
-
-
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
@@ -103,12 +95,10 @@ void PanelContainer::_notification(int p_what) {
if (c->is_set_as_toplevel())
continue;
- fit_child_in_rect(c,Rect2(ofs,size));
-
+ fit_child_in_rect(c, Rect2(ofs, size));
}
}
}
-PanelContainer::PanelContainer()
-{
+PanelContainer::PanelContainer() {
}
diff --git a/scene/gui/panel_container.h b/scene/gui/panel_container.h
index 4ccae197f..1003363d6 100644
--- a/scene/gui/panel_container.h
+++ b/scene/gui/panel_container.h
@@ -33,13 +33,12 @@
class PanelContainer : public Container {
- OBJ_TYPE( PanelContainer, Container );
+ OBJ_TYPE(PanelContainer, Container);
protected:
-
void _notification(int p_what);
-public:
+public:
virtual Size2 get_minimum_size() const;
PanelContainer();
diff --git a/scene/gui/patch_9_frame.cpp b/scene/gui/patch_9_frame.cpp
index 40d3cb0e0..53f103344 100644
--- a/scene/gui/patch_9_frame.cpp
+++ b/scene/gui/patch_9_frame.cpp
@@ -32,17 +32,17 @@
void Patch9Frame::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
if (texture.is_null())
return;
- Size2 s=get_size();
+ Size2 s = get_size();
RID ci = get_canvas_item();
- VS::get_singleton()->canvas_item_add_style_box(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate);
-// draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+ VS::get_singleton()->canvas_item_add_style_box(ci, Rect2(Point2(), s), region_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), draw_center, modulate);
+ // draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
-/*
+ /*
Vector<Point2> points;
points.resize(4);
points[0]=Point2(0,0);
@@ -63,41 +63,38 @@ void Patch9Frame::_notification(int p_what) {
Size2 Patch9Frame::get_minimum_size() const {
- return Size2(margin[MARGIN_LEFT]+margin[MARGIN_RIGHT],margin[MARGIN_TOP]+margin[MARGIN_BOTTOM]);
+ return Size2(margin[MARGIN_LEFT] + margin[MARGIN_RIGHT], margin[MARGIN_TOP] + margin[MARGIN_BOTTOM]);
}
void Patch9Frame::_bind_methods() {
-
- ObjectTypeDB::bind_method(_MD("set_texture","texture"), & Patch9Frame::set_texture );
- ObjectTypeDB::bind_method(_MD("get_texture"), & Patch9Frame::get_texture );
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"), & Patch9Frame::set_modulate );
- ObjectTypeDB::bind_method(_MD("get_modulate"), & Patch9Frame::get_modulate );
- ObjectTypeDB::bind_method(_MD("set_patch_margin","margin","value"), & Patch9Frame::set_patch_margin );
- ObjectTypeDB::bind_method(_MD("get_patch_margin","margin"), & Patch9Frame::get_patch_margin );
- ObjectTypeDB::bind_method(_MD("set_region_rect","rect"),&Patch9Frame::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&Patch9Frame::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_draw_center","draw_center"), & Patch9Frame::set_draw_center );
- ObjectTypeDB::bind_method(_MD("get_draw_center"), & Patch9Frame::get_draw_center );
+ ObjectTypeDB::bind_method(_MD("set_texture", "texture"), &Patch9Frame::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture"), &Patch9Frame::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_modulate", "modulate"), &Patch9Frame::set_modulate);
+ ObjectTypeDB::bind_method(_MD("get_modulate"), &Patch9Frame::get_modulate);
+ ObjectTypeDB::bind_method(_MD("set_patch_margin", "margin", "value"), &Patch9Frame::set_patch_margin);
+ ObjectTypeDB::bind_method(_MD("get_patch_margin", "margin"), &Patch9Frame::get_patch_margin);
+ ObjectTypeDB::bind_method(_MD("set_region_rect", "rect"), &Patch9Frame::set_region_rect);
+ ObjectTypeDB::bind_method(_MD("get_region_rect"), &Patch9Frame::get_region_rect);
+ ObjectTypeDB::bind_method(_MD("set_draw_center", "draw_center"), &Patch9Frame::set_draw_center);
+ ObjectTypeDB::bind_method(_MD("get_draw_center"), &Patch9Frame::get_draw_center);
ADD_SIGNAL(MethodInfo("texture_changed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
- ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "draw_center"), _SCS("set_draw_center"),_SCS("get_draw_center") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/left",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/top",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/right",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/bottom",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_BOTTOM );
-
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "draw_center"), _SCS("set_draw_center"), _SCS("get_draw_center"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::RECT2, "region_rect"), _SCS("set_region_rect"), _SCS("get_region_rect"));
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "patch_margin/left", PROPERTY_HINT_RANGE, "0,16384,1"), _SCS("set_patch_margin"), _SCS("get_patch_margin"), MARGIN_LEFT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "patch_margin/top", PROPERTY_HINT_RANGE, "0,16384,1"), _SCS("set_patch_margin"), _SCS("get_patch_margin"), MARGIN_TOP);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "patch_margin/right", PROPERTY_HINT_RANGE, "0,16384,1"), _SCS("set_patch_margin"), _SCS("get_patch_margin"), MARGIN_RIGHT);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "patch_margin/bottom", PROPERTY_HINT_RANGE, "0,16384,1"), _SCS("set_patch_margin"), _SCS("get_patch_margin"), MARGIN_BOTTOM);
}
+void Patch9Frame::set_texture(const Ref<Texture> &p_tex) {
-void Patch9Frame::set_texture(const Ref<Texture>& p_tex) {
-
- if (texture==p_tex)
+ if (texture == p_tex)
return;
- texture=p_tex;
+ texture = p_tex;
update();
//if (texture.is_valid())
// texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
@@ -110,22 +107,21 @@ Ref<Texture> Patch9Frame::get_texture() const {
return texture;
}
-void Patch9Frame::set_modulate(const Color& p_tex) {
+void Patch9Frame::set_modulate(const Color &p_tex) {
- modulate=p_tex;
+ modulate = p_tex;
update();
}
-Color Patch9Frame::get_modulate() const{
+Color Patch9Frame::get_modulate() const {
return modulate;
}
+void Patch9Frame::set_patch_margin(Margin p_margin, int p_size) {
-void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) {
-
- ERR_FAIL_INDEX(p_margin,4);
- margin[p_margin]=p_size;
+ ERR_FAIL_INDEX(p_margin, 4);
+ margin[p_margin] = p_size;
update();
minimum_size_changed();
switch (p_margin) {
@@ -144,18 +140,18 @@ void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) {
}
}
-int Patch9Frame::get_patch_margin(Margin p_margin) const{
+int Patch9Frame::get_patch_margin(Margin p_margin) const {
- ERR_FAIL_INDEX_V(p_margin,4,0);
+ ERR_FAIL_INDEX_V(p_margin, 4, 0);
return margin[p_margin];
}
-void Patch9Frame::set_region_rect(const Rect2& p_region_rect) {
+void Patch9Frame::set_region_rect(const Rect2 &p_region_rect) {
- if (region_rect==p_region_rect)
+ if (region_rect == p_region_rect)
return;
- region_rect=p_region_rect;
+ region_rect = p_region_rect;
item_rect_changed();
_change_notify("region_rect");
@@ -168,28 +164,25 @@ Rect2 Patch9Frame::get_region_rect() const {
void Patch9Frame::set_draw_center(bool p_draw) {
- draw_center=p_draw;
+ draw_center = p_draw;
update();
}
-bool Patch9Frame::get_draw_center() const{
+bool Patch9Frame::get_draw_center() const {
return draw_center;
}
Patch9Frame::Patch9Frame() {
-
- margin[MARGIN_LEFT]=0;
- margin[MARGIN_RIGHT]=0;
- margin[MARGIN_BOTTOM]=0;
- margin[MARGIN_TOP]=0;
- modulate=Color(1,1,1,1);
+ margin[MARGIN_LEFT] = 0;
+ margin[MARGIN_RIGHT] = 0;
+ margin[MARGIN_BOTTOM] = 0;
+ margin[MARGIN_TOP] = 0;
+ modulate = Color(1, 1, 1, 1);
set_ignore_mouse(true);
- draw_center=true;
+ draw_center = true;
}
-
-Patch9Frame::~Patch9Frame()
-{
+Patch9Frame::~Patch9Frame() {
}
diff --git a/scene/gui/patch_9_frame.h b/scene/gui/patch_9_frame.h
index f9a029493..f821b71ac 100644
--- a/scene/gui/patch_9_frame.h
+++ b/scene/gui/patch_9_frame.h
@@ -35,31 +35,30 @@
*/
class Patch9Frame : public Control {
- OBJ_TYPE(Patch9Frame,Control);
+ OBJ_TYPE(Patch9Frame, Control);
bool draw_center;
int margin[4];
Rect2 region_rect;
Color modulate;
Ref<Texture> texture;
-protected:
+protected:
void _notification(int p_what);
virtual Size2 get_minimum_size() const;
static void _bind_methods();
public:
-
- void set_texture(const Ref<Texture>& p_tex);
+ void set_texture(const Ref<Texture> &p_tex);
Ref<Texture> get_texture() const;
- void set_modulate(const Color& p_tex);
+ void set_modulate(const Color &p_tex);
Color get_modulate() const;
- void set_patch_margin(Margin p_margin,int p_size);
+ void set_patch_margin(Margin p_margin, int p_size);
int get_patch_margin(Margin p_margin) const;
- void set_region_rect(const Rect2& p_region_rect);
+ void set_region_rect(const Rect2 &p_region_rect);
Rect2 get_region_rect() const;
void set_draw_center(bool p_enable);
@@ -67,6 +66,5 @@ public:
Patch9Frame();
~Patch9Frame();
-
};
#endif // PATCH_9_FRAME_H
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 5bae2b974..127626217 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -29,18 +29,14 @@
#include "popup.h"
#include "os/keyboard.h"
-
-
void Popup::_input_event(InputEvent p_event) {
-
-
}
void Popup::_notification(int p_what) {
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (popped_up && !is_visible()) {
- popped_up=false;
+ popped_up = false;
notification(NOTIFICATION_POPUP_HIDE);
emit_signal("popup_hide");
}
@@ -48,20 +44,18 @@ void Popup::_notification(int p_what) {
update_configuration_warning();
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
- //small helper to make editing of these easier in editor
+ if (p_what == NOTIFICATION_ENTER_TREE) {
+//small helper to make editing of these easier in editor
#ifdef TOOLS_ENABLED
if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
set_as_toplevel(false);
}
#endif
}
-
}
void Popup::_fix_size() {
-
#if 0
Point2 pos = get_pos();
Size2 size = get_size();
@@ -73,34 +67,32 @@ void Popup::_fix_size() {
Point2 window_size = get_viewport_rect().size;
#endif
- if (pos.x+size.width > window_size.width)
- pos.x=window_size.width-size.width;
- if (pos.x<0)
- pos.x=0;
+ if (pos.x + size.width > window_size.width)
+ pos.x = window_size.width - size.width;
+ if (pos.x < 0)
+ pos.x = 0;
- if (pos.y+size.height > window_size.height)
- pos.y=window_size.height-size.height;
- if (pos.y<0)
- pos.y=0;
+ if (pos.y + size.height > window_size.height)
+ pos.y = window_size.height - size.height;
+ if (pos.y < 0)
+ pos.y = 0;
#if 0
if (pos!=get_pos())
set_pos(pos);
#else
- if (pos!=get_pos())
+ if (pos != get_pos())
set_global_pos(pos);
#endif
-
}
-
void Popup::set_as_minsize() {
Size2 total_minsize;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_hidden())
@@ -108,10 +100,10 @@ void Popup::set_as_minsize() {
Size2 minsize = c->get_combined_minimum_size();
- for(int j=0;j<2;j++) {
+ for (int j = 0; j < 2; j++) {
- Margin m_beg = Margin(0+j);
- Margin m_end = Margin(2+j);
+ Margin m_beg = Margin(0 + j);
+ Margin m_end = Margin(2 + j);
float margin_begin = c->get_margin(m_beg);
float margin_end = c->get_margin(m_end);
@@ -119,29 +111,25 @@ void Popup::set_as_minsize() {
AnchorType anchor_end = c->get_anchor(m_end);
if (anchor_begin == ANCHOR_BEGIN)
- minsize[j]+=margin_begin;
+ minsize[j] += margin_begin;
if (anchor_end == ANCHOR_END)
- minsize[j]+=margin_end;
-
+ minsize[j] += margin_end;
}
- total_minsize.width = MAX( total_minsize.width, minsize.width );
- total_minsize.height = MAX( total_minsize.height, minsize.height );
+ total_minsize.width = MAX(total_minsize.width, minsize.width);
+ total_minsize.height = MAX(total_minsize.height, minsize.height);
}
set_size(total_minsize);
-
}
+void Popup::popup_centered_minsize(const Size2 &p_minsize) {
-void Popup::popup_centered_minsize(const Size2& p_minsize) {
+ Size2 total_minsize = p_minsize;
+ for (int i = 0; i < get_child_count(); i++) {
- Size2 total_minsize=p_minsize;
-
- for(int i=0;i<get_child_count();i++) {
-
- Control *c=get_child(i)->cast_to<Control>();
+ Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_hidden())
@@ -149,10 +137,10 @@ void Popup::popup_centered_minsize(const Size2& p_minsize) {
Size2 minsize = c->get_combined_minimum_size();
- for(int j=0;j<2;j++) {
+ for (int j = 0; j < 2; j++) {
- Margin m_beg = Margin(0+j);
- Margin m_end = Margin(2+j);
+ Margin m_beg = Margin(0 + j);
+ Margin m_end = Margin(2 + j);
float margin_begin = c->get_margin(m_beg);
float margin_end = c->get_margin(m_end);
@@ -160,33 +148,30 @@ void Popup::popup_centered_minsize(const Size2& p_minsize) {
AnchorType anchor_end = c->get_anchor(m_end);
if (anchor_begin == ANCHOR_BEGIN)
- minsize[j]+=margin_begin;
+ minsize[j] += margin_begin;
if (anchor_end == ANCHOR_END)
- minsize[j]+=margin_end;
-
+ minsize[j] += margin_end;
}
- total_minsize.width = MAX( total_minsize.width, minsize.width );
- total_minsize.height = MAX( total_minsize.height, minsize.height );
+ total_minsize.width = MAX(total_minsize.width, minsize.width);
+ total_minsize.height = MAX(total_minsize.height, minsize.height);
}
-
- popup_centered( total_minsize );
- popped_up=true;
-
+ popup_centered(total_minsize);
+ popped_up = true;
}
-void Popup::popup_centered(const Size2& p_size) {
+void Popup::popup_centered(const Size2 &p_size) {
Point2 window_size = get_viewport_rect().size;
emit_signal("about_to_show");
Rect2 rect;
- rect.size = p_size==Size2()?get_size():p_size;
+ rect.size = p_size == Size2() ? get_size() : p_size;
- rect.pos = ((window_size-rect.size)/2.0).floor();
- set_pos( rect.pos );
- set_size( rect.size );
+ rect.pos = ((window_size - rect.size) / 2.0).floor();
+ set_pos(rect.pos);
+ set_size(rect.size);
show_modal(exclusive);
_fix_size();
@@ -197,21 +182,19 @@ void Popup::popup_centered(const Size2& p_size) {
_post_popup();
notification(NOTIFICATION_POST_POPUP);
- popped_up=true;
+ popped_up = true;
}
void Popup::popup_centered_ratio(float p_screen_ratio) {
-
-
emit_signal("about_to_show");
Rect2 rect;
Point2 window_size = get_viewport_rect().size;
rect.size = (window_size * p_screen_ratio).floor();
- rect.pos = ((window_size-rect.size)/2.0).floor();
- set_pos( rect.pos );
- set_size( rect.size );
+ rect.pos = ((window_size - rect.size) / 2.0).floor();
+ set_pos(rect.pos);
+ set_size(rect.size);
show_modal(exclusive);
_fix_size();
@@ -222,8 +205,7 @@ void Popup::popup_centered_ratio(float p_screen_ratio) {
_post_popup();
notification(NOTIFICATION_POST_POPUP);
- popped_up=true;
-
+ popped_up = true;
}
void Popup::popup() {
@@ -231,7 +213,6 @@ void Popup::popup() {
emit_signal("about_to_show");
show_modal(exclusive);
-
_fix_size();
Control *focusable = find_next_valid_focus();
@@ -241,42 +222,39 @@ void Popup::popup() {
_post_popup();
notification(NOTIFICATION_POST_POPUP);
- popped_up=true;
+ popped_up = true;
}
void Popup::set_exclusive(bool p_exclusive) {
- exclusive=p_exclusive;
+ exclusive = p_exclusive;
}
-bool Popup::is_exclusive() const {
+bool Popup::is_exclusive() const {
return exclusive;
}
-
void Popup::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("popup_centered","size"),&Popup::popup_centered,DEFVAL(Size2()));
- ObjectTypeDB::bind_method(_MD("popup_centered_ratio","ratio"),&Popup::popup_centered_ratio,DEFVAL(0.75));
- ObjectTypeDB::bind_method(_MD("popup_centered_minsize","minsize"),&Popup::popup_centered_minsize,DEFVAL(Size2()));
- ObjectTypeDB::bind_method(_MD("popup"),&Popup::popup);
- ObjectTypeDB::bind_method(_MD("set_exclusive","enable"),&Popup::set_exclusive);
- ObjectTypeDB::bind_method(_MD("is_exclusive"),&Popup::is_exclusive);
- ADD_SIGNAL( MethodInfo("about_to_show") );
- ADD_SIGNAL( MethodInfo("popup_hide") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "popup/exclusive"), _SCS("set_exclusive"),_SCS("is_exclusive") );
+ ObjectTypeDB::bind_method(_MD("popup_centered", "size"), &Popup::popup_centered, DEFVAL(Size2()));
+ ObjectTypeDB::bind_method(_MD("popup_centered_ratio", "ratio"), &Popup::popup_centered_ratio, DEFVAL(0.75));
+ ObjectTypeDB::bind_method(_MD("popup_centered_minsize", "minsize"), &Popup::popup_centered_minsize, DEFVAL(Size2()));
+ ObjectTypeDB::bind_method(_MD("popup"), &Popup::popup);
+ ObjectTypeDB::bind_method(_MD("set_exclusive", "enable"), &Popup::set_exclusive);
+ ObjectTypeDB::bind_method(_MD("is_exclusive"), &Popup::is_exclusive);
+ ADD_SIGNAL(MethodInfo("about_to_show"));
+ ADD_SIGNAL(MethodInfo("popup_hide"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "popup/exclusive"), _SCS("set_exclusive"), _SCS("is_exclusive"));
BIND_CONSTANT(NOTIFICATION_POST_POPUP);
BIND_CONSTANT(NOTIFICATION_POPUP_HIDE);
-
-
}
Popup::Popup() {
set_as_toplevel(true);
- exclusive=false;
- popped_up=false;
+ exclusive = false;
+ popped_up = false;
hide();
}
@@ -289,9 +267,7 @@ String Popup::get_configuration_warning() const {
return String();
}
-Popup::~Popup()
-{
-
+Popup::~Popup() {
}
void PopupPanel::set_child_rect(Control *p_child) {
@@ -299,21 +275,18 @@ void PopupPanel::set_child_rect(Control *p_child) {
Ref<StyleBox> p = get_stylebox("panel");
p_child->set_area_as_parent_rect();
- for(int i=0;i<4;i++) {
- p_child->set_margin(Margin(i),p->get_margin(Margin(i)));
+ for (int i = 0; i < 4; i++) {
+ p_child->set_margin(Margin(i), p->get_margin(Margin(i)));
}
}
void PopupPanel::_notification(int p_what) {
+ if (p_what == NOTIFICATION_DRAW) {
- if (p_what==NOTIFICATION_DRAW) {
-
- get_stylebox("panel")->draw(get_canvas_item(),Rect2(Point2(),get_size()));
+ get_stylebox("panel")->draw(get_canvas_item(), Rect2(Point2(), get_size()));
}
}
PopupPanel::PopupPanel() {
-
-
}
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 05c8198e7..aba0f96cb 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -36,32 +36,31 @@
*/
class Popup : public Control {
- OBJ_TYPE( Popup, Control );
+ OBJ_TYPE(Popup, Control);
bool exclusive;
bool popped_up;
protected:
-
virtual void _post_popup() {}
void _input_event(InputEvent p_event);
void _notification(int p_what);
void _fix_size();
static void _bind_methods();
-public:
+public:
enum {
- NOTIFICATION_POST_POPUP=80,
- NOTIFICATION_POPUP_HIDE=81
+ NOTIFICATION_POST_POPUP = 80,
+ NOTIFICATION_POPUP_HIDE = 81
};
void set_exclusive(bool p_exclusive);
bool is_exclusive() const;
- void popup_centered_ratio(float p_screen_ratio=0.75);
- void popup_centered(const Size2& p_size=Size2());
- void popup_centered_minsize(const Size2& p_minsize=Size2());
+ void popup_centered_ratio(float p_screen_ratio = 0.75);
+ void popup_centered(const Size2 &p_size = Size2());
+ void popup_centered_minsize(const Size2 &p_minsize = Size2());
void set_as_minsize();
virtual void popup();
@@ -69,23 +68,18 @@ public:
Popup();
~Popup();
-
};
class PopupPanel : public Popup {
- OBJ_TYPE(PopupPanel,Popup);
-
+ OBJ_TYPE(PopupPanel, Popup);
protected:
-
void _notification(int p_what);
-public:
+public:
void set_child_rect(Control *p_child);
PopupPanel();
-
};
-
#endif
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 0fce06f3e..4f9450104 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -27,14 +27,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "popup_menu.h"
-#include "print_string.h"
+#include "os/input.h"
#include "os/keyboard.h"
+#include "print_string.h"
#include "translation.h"
-#include "os/input.h"
String PopupMenu::_get_accel_text(int p_item) const {
- ERR_FAIL_INDEX_V(p_item,items.size(),String());
+ ERR_FAIL_INDEX_V(p_item, items.size(), String());
if (items[p_item].shortcut.is_valid())
return items[p_item].shortcut->get_as_text();
@@ -61,7 +61,6 @@ String PopupMenu::_get_accel_text(int p_item) const {
*/
}
-
Size2 PopupMenu::get_minimum_size() const {
int vseparation = get_constant("vseparation");
@@ -70,120 +69,112 @@ Size2 PopupMenu::get_minimum_size() const {
Size2 minsize = get_stylebox("panel")->get_minimum_size();
Ref<Font> font = get_font("font");
- float max_w=0;
+ float max_w = 0;
int font_h = font->get_height();
int check_w = get_icon("checked")->get_width();
- int accel_max_w=0;
+ int accel_max_w = 0;
- for (int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
Size2 size;
if (!items[i].icon.is_null()) {
Size2 icon_size = items[i].icon->get_size();
- size.height = MAX( icon_size.height, font_h );
- size.width+=icon_size.width;
- size.width+=hseparation;
+ size.height = MAX(icon_size.height, font_h);
+ size.width += icon_size.width;
+ size.width += hseparation;
} else {
- size.height=font_h;
+ size.height = font_h;
}
if (items[i].checkable) {
- size.width+=check_w+hseparation;
+ size.width += check_w + hseparation;
}
String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].text;
- size.width+=font->get_string_size(text).width;
- if (i>0)
- size.height+=vseparation;
+ size.width += font->get_string_size(text).width;
+ if (i > 0)
+ size.height += vseparation;
if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
- int accel_w = hseparation*2;
- accel_w+=font->get_string_size(_get_accel_text(i)).width;
- accel_max_w = MAX( accel_w, accel_max_w );
+ int accel_w = hseparation * 2;
+ accel_w += font->get_string_size(_get_accel_text(i)).width;
+ accel_max_w = MAX(accel_w, accel_max_w);
}
- minsize.height+=size.height;
- max_w = MAX( max_w, size.width );
-
+ minsize.height += size.height;
+ max_w = MAX(max_w, size.width);
}
- minsize.width+=max_w+accel_max_w;
+ minsize.width += max_w + accel_max_w;
return minsize;
}
-int PopupMenu::_get_mouse_over(const Point2& p_over) const {
-
+int PopupMenu::_get_mouse_over(const Point2 &p_over) const {
- if (p_over.x<0 || p_over.x>=get_size().width)
+ if (p_over.x < 0 || p_over.x >= get_size().width)
return -1;
Ref<StyleBox> style = get_stylebox("panel");
- Point2 ofs=style->get_offset();
-
+ Point2 ofs = style->get_offset();
- if (ofs.y>p_over.y)
+ if (ofs.y > p_over.y)
return -1;
-
Ref<Font> font = get_font("font");
int vseparation = get_constant("vseparation");
-// int hseparation = get_constant("hseparation");
- float font_h=font->get_height();
-
+ // int hseparation = get_constant("hseparation");
+ float font_h = font->get_height();
- for (int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
- if (i>0)
- ofs.y+=vseparation;
+ if (i > 0)
+ ofs.y += vseparation;
float h;
if (!items[i].icon.is_null()) {
Size2 icon_size = items[i].icon->get_size();
- h = MAX( icon_size.height, font_h );
+ h = MAX(icon_size.height, font_h);
} else {
- h=font_h;
+ h = font_h;
}
- ofs.y+=h;
+ ofs.y += h;
if (p_over.y < ofs.y) {
return i;
}
}
return -1;
-
}
-
void PopupMenu::_activate_submenu(int over) {
- Node* n = get_node(items[over].submenu);
- ERR_EXPLAIN("item subnode does not exist: "+items[over].submenu);
+ Node *n = get_node(items[over].submenu);
+ ERR_EXPLAIN("item subnode does not exist: " + items[over].submenu);
ERR_FAIL_COND(!n);
Popup *pm = n->cast_to<Popup>();
- ERR_EXPLAIN("item subnode is not a Popup: "+items[over].submenu);
+ ERR_EXPLAIN("item subnode is not a Popup: " + items[over].submenu);
ERR_FAIL_COND(!pm);
if (pm->is_visible())
return; //already visible!
-
Point2 p = get_global_pos();
- Rect2 pr(p,get_size());
+ Rect2 pr(p, get_size());
Ref<StyleBox> style = get_stylebox("panel");
- Point2 pos = p+Point2(get_size().width,items[over]._ofs_cache-style->get_offset().y);
+ Point2 pos = p + Point2(get_size().width, items[over]._ofs_cache - style->get_offset().y);
Size2 size = pm->get_size();
// fix pos
- if (pos.x+size.width > get_viewport_rect().size.width)
- pos.x=p.x-size.width;
+ if (pos.x + size.width > get_viewport_rect().size.width)
+ pos.x = p.x - size.width;
pm->set_pos(pos);
pm->popup();
@@ -191,52 +182,45 @@ void PopupMenu::_activate_submenu(int over) {
PopupMenu *pum = pm->cast_to<PopupMenu>();
if (pum) {
- pr.pos-=pum->get_global_pos();
+ pr.pos -= pum->get_global_pos();
pum->clear_autohide_areas();
- pum->add_autohide_area(Rect2(pr.pos.x,pr.pos.y,pr.size.x,items[over]._ofs_cache));
- if (over<items.size()-1) {
- int from = items[over+1]._ofs_cache;
- pum->add_autohide_area(Rect2(pr.pos.x,pr.pos.y+from,pr.size.x,pr.size.y-from));
+ pum->add_autohide_area(Rect2(pr.pos.x, pr.pos.y, pr.size.x, items[over]._ofs_cache));
+ if (over < items.size() - 1) {
+ int from = items[over + 1]._ofs_cache;
+ pum->add_autohide_area(Rect2(pr.pos.x, pr.pos.y + from, pr.size.x, pr.size.y - from));
}
-
}
-
}
void PopupMenu::_submenu_timeout() {
- if (mouse_over==submenu_over) {
+ if (mouse_over == submenu_over) {
_activate_submenu(mouse_over);
- submenu_over=-1;
+ submenu_over = -1;
}
}
-
void PopupMenu::_input_event(const InputEvent &p_event) {
- switch( p_event.type) {
+ switch (p_event.type) {
case InputEvent::KEY: {
-
if (!p_event.key.pressed)
break;
- switch(p_event.key.scancode) {
-
+ switch (p_event.key.scancode) {
case KEY_DOWN: {
+ for (int i = mouse_over + 1; i < items.size(); i++) {
- for(int i=mouse_over+1;i<items.size();i++) {
-
- if (i<0 || i>=items.size())
+ if (i < 0 || i >= items.size())
continue;
if (!items[i].separator && !items[i].disabled) {
-
- mouse_over=i;
+ mouse_over = i;
update();
break;
}
@@ -244,49 +228,38 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
} break;
case KEY_UP: {
+ for (int i = mouse_over - 1; i >= 0; i--) {
- for(int i=mouse_over-1;i>=0;i--) {
-
- if (i<0 || i>=items.size())
+ if (i < 0 || i >= items.size())
continue;
-
if (!items[i].separator && !items[i].disabled) {
-
- mouse_over=i;
- update();
- break;
+ mouse_over = i;
+ update();
+ break;
}
}
} break;
case KEY_RETURN:
case KEY_ENTER: {
- if (mouse_over>=0 && mouse_over<items.size() && !items[mouse_over].separator) {
-
+ if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator) {
activate_item(mouse_over);
-
}
} break;
}
-
-
-
-
} break;
case InputEvent::MOUSE_BUTTON: {
-
- const InputEventMouseButton &b=p_event.mouse_button;
+ const InputEventMouseButton &b = p_event.mouse_button;
if (b.pressed)
break;
- switch(b.button_index) {
-
+ switch (b.button_index) {
case BUTTON_WHEEL_DOWN: {
@@ -296,15 +269,15 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
Ref<Font> font = get_font("font");
Point2 pos = get_pos();
- int s = (vseparation+font->get_height())*3;
- pos.y-=s;
+ int s = (vseparation + font->get_height()) * 3;
+ pos.y -= s;
set_pos(pos);
//update hover
InputEvent ie;
- ie.type=InputEvent::MOUSE_MOTION;
- ie.mouse_motion.x=b.x;
- ie.mouse_motion.y=b.y+s;
+ ie.type = InputEvent::MOUSE_MOTION;
+ ie.mouse_motion.x = b.x;
+ ie.mouse_motion.y = b.y + s;
_input_event(ie);
}
} break;
@@ -316,29 +289,27 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
Ref<Font> font = get_font("font");
Point2 pos = get_pos();
- int s = (vseparation+font->get_height())*3;
- pos.y+=s;
+ int s = (vseparation + font->get_height()) * 3;
+ pos.y += s;
set_pos(pos);
//update hover
InputEvent ie;
- ie.type=InputEvent::MOUSE_MOTION;
- ie.mouse_motion.x=b.x;
- ie.mouse_motion.y=b.y-s;
+ ie.type = InputEvent::MOUSE_MOTION;
+ ie.mouse_motion.x = b.x;
+ ie.mouse_motion.y = b.y - s;
_input_event(ie);
-
-
}
} break;
case BUTTON_LEFT: {
- int over=_get_mouse_over(Point2(b.x,b.y));
+ int over = _get_mouse_over(Point2(b.x, b.y));
if (invalidated_click) {
- invalidated_click=false;
+ invalidated_click = false;
break;
}
- if (over<0) {
+ if (over < 0) {
hide();
break; //non-activable
}
@@ -346,7 +317,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
if (items[over].separator || items[over].disabled)
break;
- if (items[over].submenu!="") {
+ if (items[over].submenu != "") {
_activate_submenu(over);
return;
@@ -360,52 +331,48 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
} break;
case InputEvent::MOUSE_MOTION: {
-
if (invalidated_click) {
- moved+=Vector2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y);
- if (moved.length()>4)
- invalidated_click=false;
-
+ moved += Vector2(p_event.mouse_motion.relative_x, p_event.mouse_motion.relative_y);
+ if (moved.length() > 4)
+ invalidated_click = false;
}
- const InputEventMouseMotion &m=p_event.mouse_motion;
- for(List<Rect2>::Element *E=autohide_areas.front();E;E=E->next()) {
+ const InputEventMouseMotion &m = p_event.mouse_motion;
+ for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {
- if (!Rect2(Point2(),get_size()).has_point(Point2(m.x,m.y)) && E->get().has_point(Point2(m.x,m.y))) {
+ if (!Rect2(Point2(), get_size()).has_point(Point2(m.x, m.y)) && E->get().has_point(Point2(m.x, m.y))) {
call_deferred("hide");
return;
}
}
- int over=_get_mouse_over(Point2(m.x,m.y));
- int id = (over<0 || items[over].separator || items[over].disabled)?-1:(items[over].ID>=0?items[over].ID:over);
+ int over = _get_mouse_over(Point2(m.x, m.y));
+ int id = (over < 0 || items[over].separator || items[over].disabled) ? -1 : (items[over].ID >= 0 ? items[over].ID : over);
- if (id<0) {
- mouse_over=-1;
+ if (id < 0) {
+ mouse_over = -1;
update();
break;
}
- if (items[over].submenu!="" && submenu_over!=over) {
- submenu_over=over;
+ if (items[over].submenu != "" && submenu_over != over) {
+ submenu_over = over;
submenu_timer->start();
}
- if (over!=mouse_over) {
- mouse_over=over;
+ if (over != mouse_over) {
+ mouse_over = over;
update();
}
} break;
-
}
}
-
-bool PopupMenu::has_point(const Point2& p_point) const {
+bool PopupMenu::has_point(const Point2 &p_point) const {
if (parent_rect.has_point(p_point))
return true;
- for(const List<Rect2>::Element *E=autohide_areas.front();E;E=E->next()) {
+ for (const List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {
if (E->get().has_point(p_point))
return true;
@@ -416,100 +383,96 @@ bool PopupMenu::has_point(const Point2& p_point) const {
void PopupMenu::_notification(int p_what) {
- switch(p_what) {
-
+ switch (p_what) {
case NOTIFICATION_DRAW: {
RID ci = get_canvas_item();
- Size2 size=get_size();
+ Size2 size = get_size();
Ref<StyleBox> style = get_stylebox("panel");
Ref<StyleBox> hover = get_stylebox("hover");
Ref<Font> font = get_font("font");
Ref<Texture> check = get_icon("checked");
Ref<Texture> uncheck = get_icon("unchecked");
- Ref<Texture> submenu= get_icon("submenu");
+ Ref<Texture> submenu = get_icon("submenu");
Ref<StyleBox> separator = get_stylebox("separator");
- style->draw( ci, Rect2( Point2(), get_size() ) );
- Point2 ofs=style->get_offset();
+ style->draw(ci, Rect2(Point2(), get_size()));
+ Point2 ofs = style->get_offset();
int vseparation = get_constant("vseparation");
int hseparation = get_constant("hseparation");
Color font_color = get_color("font_color");
Color font_color_disabled = get_color("font_color_disabled");
Color font_color_accel = get_color("font_color_accel");
Color font_color_hover = get_color("font_color_hover");
- float font_h=font->get_height();
+ float font_h = font->get_height();
- for (int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
- if (i>0)
- ofs.y+=vseparation;
- Point2 item_ofs=ofs;
+ if (i > 0)
+ ofs.y += vseparation;
+ Point2 item_ofs = ofs;
float h;
Size2 icon_size;
if (!items[i].icon.is_null()) {
icon_size = items[i].icon->get_size();
- h = MAX( icon_size.height, font_h );
+ h = MAX(icon_size.height, font_h);
} else {
- h=font_h;
+ h = font_h;
}
- if (i==mouse_over) {
+ if (i == mouse_over) {
- hover->draw(ci, Rect2( ofs+Point2(-hseparation,-vseparation), Size2( get_size().width - style->get_minimum_size().width + hseparation*2, h+vseparation*2 ) ));
+ hover->draw(ci, Rect2(ofs + Point2(-hseparation, -vseparation), Size2(get_size().width - style->get_minimum_size().width + hseparation * 2, h + vseparation * 2)));
}
if (items[i].separator) {
- int sep_h=separator->get_center_size().height+separator->get_minimum_size().height;
- separator->draw(ci, Rect2( ofs+Point2(0,Math::floor((h-sep_h)/2.0)), Size2( get_size().width - style->get_minimum_size().width , sep_h ) ));
-
+ int sep_h = separator->get_center_size().height + separator->get_minimum_size().height;
+ separator->draw(ci, Rect2(ofs + Point2(0, Math::floor((h - sep_h) / 2.0)), Size2(get_size().width - style->get_minimum_size().width, sep_h)));
}
if (items[i].checkable) {
if (items[i].checked)
- check->draw(ci, item_ofs+Point2(0,Math::floor((h-check->get_height())/2.0)));
+ check->draw(ci, item_ofs + Point2(0, Math::floor((h - check->get_height()) / 2.0)));
else
- uncheck->draw(ci, item_ofs+Point2(0,Math::floor((h-check->get_height())/2.0)));
+ uncheck->draw(ci, item_ofs + Point2(0, Math::floor((h - check->get_height()) / 2.0)));
- item_ofs.x+=check->get_width()+hseparation;
+ item_ofs.x += check->get_width() + hseparation;
}
if (!items[i].icon.is_null()) {
- items[i].icon->draw( ci, item_ofs+Point2(0,Math::floor((h-icon_size.height)/2.0)));
- item_ofs.x+=items[i].icon->get_width();
- item_ofs.x+=hseparation;
+ items[i].icon->draw(ci, item_ofs + Point2(0, Math::floor((h - icon_size.height) / 2.0)));
+ item_ofs.x += items[i].icon->get_width();
+ item_ofs.x += hseparation;
}
- if (items[i].submenu!="") {
- submenu->draw( ci, Point2(size.width - style->get_margin(MARGIN_RIGHT) - submenu->get_width(),item_ofs.y+Math::floor(h-submenu->get_height())/2));
+ if (items[i].submenu != "") {
+ submenu->draw(ci, Point2(size.width - style->get_margin(MARGIN_RIGHT) - submenu->get_width(), item_ofs.y + Math::floor(h - submenu->get_height()) / 2));
}
- item_ofs.y+=font->get_ascent();
+ item_ofs.y += font->get_ascent();
String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].text;
if (!items[i].separator) {
- font->draw(ci,item_ofs+Point2(0,Math::floor((h-font_h)/2.0)),text,items[i].disabled?font_color_disabled:(i==mouse_over?font_color_hover:font_color));
+ font->draw(ci, item_ofs + Point2(0, Math::floor((h - font_h) / 2.0)), text, items[i].disabled ? font_color_disabled : (i == mouse_over ? font_color_hover : font_color));
}
if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
//accelerator
String text = _get_accel_text(i);
- item_ofs.x=size.width-style->get_margin(MARGIN_RIGHT)-font->get_string_size(text).width;
- font->draw(ci,item_ofs+Point2(0,Math::floor((h-font_h)/2.0)),text,i==mouse_over?font_color_hover:font_color_accel);
-
+ item_ofs.x = size.width - style->get_margin(MARGIN_RIGHT) - font->get_string_size(text).width;
+ font->draw(ci, item_ofs + Point2(0, Math::floor((h - font_h) / 2.0)), text, i == mouse_over ? font_color_hover : font_color_accel);
}
- items[i]._ofs_cache=ofs.y;
-
- ofs.y+=h;
+ items[i]._ofs_cache = ofs.y;
+ ofs.y += h;
}
} break;
@@ -519,245 +482,233 @@ void PopupMenu::_notification(int p_what) {
} break;
case NOTIFICATION_MOUSE_EXIT: {
- if (mouse_over>=0) {
- mouse_over=-1;
+ if (mouse_over >= 0) {
+ mouse_over = -1;
update();
}
} break;
}
}
-
-void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,int p_ID,uint32_t p_accel) {
+void PopupMenu::add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID, uint32_t p_accel) {
Item item;
- item.icon=p_icon;
- item.text=p_label;
- item.accel=p_accel;
- item.ID=p_ID;
+ item.icon = p_icon;
+ item.text = p_label;
+ item.accel = p_accel;
+ item.ID = p_ID;
items.push_back(item);
update();
}
-void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) {
+void PopupMenu::add_item(const String &p_label, int p_ID, uint32_t p_accel) {
Item item;
- item.text=XL_MESSAGE(p_label);
- item.accel=p_accel;
- item.ID=p_ID;
+ item.text = XL_MESSAGE(p_label);
+ item.accel = p_accel;
+ item.ID = p_ID;
items.push_back(item);
update();
}
-void PopupMenu::add_submenu_item(const String& p_label, const String& p_submenu,int p_ID){
+void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu, int p_ID) {
Item item;
- item.text=XL_MESSAGE(p_label);
- item.ID=p_ID;
- item.submenu=p_submenu;
+ item.text = XL_MESSAGE(p_label);
+ item.ID = p_ID;
+ item.submenu = p_submenu;
items.push_back(item);
update();
}
-void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_label,int p_ID,uint32_t p_accel) {
+void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID, uint32_t p_accel) {
Item item;
- item.icon=p_icon;
- item.text=XL_MESSAGE(p_label);
- item.accel=p_accel;
- item.ID=p_ID;
- item.checkable=true;
+ item.icon = p_icon;
+ item.text = XL_MESSAGE(p_label);
+ item.accel = p_accel;
+ item.ID = p_ID;
+ item.checkable = true;
items.push_back(item);
update();
}
-void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel) {
+void PopupMenu::add_check_item(const String &p_label, int p_ID, uint32_t p_accel) {
Item item;
- item.text=XL_MESSAGE(p_label);
- item.accel=p_accel;
- item.ID=p_ID;
- item.checkable=true;
+ item.text = XL_MESSAGE(p_label);
+ item.accel = p_accel;
+ item.ID = p_ID;
+ item.checkable = true;
items.push_back(item);
update();
}
-
-void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID) {
+void PopupMenu::add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID) {
ERR_FAIL_COND(p_shortcut.is_null());
_ref_shortcut(p_shortcut);
Item item;
- item.ID=p_ID;
- item.icon=p_icon;
- item.shortcut=p_shortcut;
+ item.ID = p_ID;
+ item.icon = p_icon;
+ item.shortcut = p_shortcut;
items.push_back(item);
update();
-
}
-void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID) {
ERR_FAIL_COND(p_shortcut.is_null());
_ref_shortcut(p_shortcut);
Item item;
- item.ID=p_ID;
- item.shortcut=p_shortcut;
+ item.ID = p_ID;
+ item.shortcut = p_shortcut;
items.push_back(item);
update();
-
}
-void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID) {
ERR_FAIL_COND(p_shortcut.is_null());
_ref_shortcut(p_shortcut);
Item item;
- item.ID=p_ID;
- item.shortcut=p_shortcut;
- item.checkable=true;
- item.icon=p_icon;
+ item.ID = p_ID;
+ item.shortcut = p_shortcut;
+ item.checkable = true;
+ item.icon = p_icon;
items.push_back(item);
update();
}
-void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID) {
ERR_FAIL_COND(p_shortcut.is_null());
_ref_shortcut(p_shortcut);
Item item;
- item.ID=p_ID;
- item.shortcut=p_shortcut;
- item.checkable=true;
+ item.ID = p_ID;
+ item.shortcut = p_shortcut;
+ item.checkable = true;
items.push_back(item);
update();
}
-void PopupMenu::set_item_text(int p_idx,const String& p_text) {
+void PopupMenu::set_item_text(int p_idx, const String &p_text) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].text=XL_MESSAGE(p_text);
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].text = XL_MESSAGE(p_text);
update();
-
}
-void PopupMenu::set_item_icon(int p_idx,const Ref<Texture>& p_icon) {
+void PopupMenu::set_item_icon(int p_idx, const Ref<Texture> &p_icon) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].icon=p_icon;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].icon = p_icon;
update();
-
}
-void PopupMenu::set_item_checked(int p_idx,bool p_checked) {
+void PopupMenu::set_item_checked(int p_idx, bool p_checked) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
- items[p_idx].checked=p_checked;
+ items[p_idx].checked = p_checked;
update();
}
-void PopupMenu::set_item_ID(int p_idx,int p_ID) {
+void PopupMenu::set_item_ID(int p_idx, int p_ID) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].ID=p_ID;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].ID = p_ID;
update();
}
-void PopupMenu::set_item_accelerator(int p_idx,uint32_t p_accel) {
+void PopupMenu::set_item_accelerator(int p_idx, uint32_t p_accel) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].accel=p_accel;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].accel = p_accel;
update();
-
}
+void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) {
-void PopupMenu::set_item_metadata(int p_idx,const Variant& p_meta) {
-
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].metadata=p_meta;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].metadata = p_meta;
update();
}
-void PopupMenu::set_item_disabled(int p_idx,bool p_disabled) {
+void PopupMenu::set_item_disabled(int p_idx, bool p_disabled) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].disabled=p_disabled;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].disabled = p_disabled;
update();
}
-void PopupMenu::set_item_submenu(int p_idx, const String& p_submenu) {
+void PopupMenu::set_item_submenu(int p_idx, const String &p_submenu) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].submenu=p_submenu;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].submenu = p_submenu;
update();
}
void PopupMenu::toggle_item_checked(int p_idx) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
items[p_idx].checked = !items[p_idx].checked;
update();
}
String PopupMenu::get_item_text(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),"");
+ ERR_FAIL_INDEX_V(p_idx, items.size(), "");
return items[p_idx].text;
-
}
Ref<Texture> PopupMenu::get_item_icon(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>());
return items[p_idx].icon;
}
-
uint32_t PopupMenu::get_item_accelerator(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),0);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), 0);
return items[p_idx].accel;
-
}
Variant PopupMenu::get_item_metadata(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),Variant());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Variant());
return items[p_idx].metadata;
-
}
bool PopupMenu::is_item_disabled(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),false);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].disabled;
}
bool PopupMenu::is_item_checked(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),false);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].checked;
}
int PopupMenu::get_item_ID(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),0);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), 0);
return items[p_idx].ID;
}
int PopupMenu::get_item_index(int p_ID) const {
- for(int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
- if (items[i].ID==p_ID)
+ if (items[i].ID == p_ID)
return i;
}
@@ -766,68 +717,64 @@ int PopupMenu::get_item_index(int p_ID) const {
String PopupMenu::get_item_submenu(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),"");
+ ERR_FAIL_INDEX_V(p_idx, items.size(), "");
return items[p_idx].submenu;
}
String PopupMenu::get_item_tooltip(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),"");
+ ERR_FAIL_INDEX_V(p_idx, items.size(), "");
return items[p_idx].tooltip;
}
Ref<ShortCut> PopupMenu::get_item_shortcut(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),Ref<ShortCut>());
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<ShortCut>());
return items[p_idx].shortcut;
}
void PopupMenu::set_item_as_separator(int p_idx, bool p_separator) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].separator=p_separator;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].separator = p_separator;
update();
-
}
bool PopupMenu::is_item_separator(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),false);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].separator;
}
-
void PopupMenu::set_item_as_checkable(int p_idx, bool p_checkable) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].checkable=p_checkable;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].checkable = p_checkable;
update();
-
}
-void PopupMenu::set_item_tooltip(int p_idx,const String& p_tooltip) {
+void PopupMenu::set_item_tooltip(int p_idx, const String &p_tooltip) {
- ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].tooltip=p_tooltip;
+ ERR_FAIL_INDEX(p_idx, items.size());
+ items[p_idx].tooltip = p_tooltip;
update();
}
-void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut) {
- ERR_FAIL_INDEX(p_idx,items.size());
+void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut) {
+ ERR_FAIL_INDEX(p_idx, items.size());
if (items[p_idx].shortcut.is_valid()) {
_unref_shortcut(items[p_idx].shortcut);
}
- items[p_idx].shortcut=p_shortcut;
+ items[p_idx].shortcut = p_shortcut;
if (items[p_idx].shortcut.is_valid()) {
_ref_shortcut(items[p_idx].shortcut);
}
-
update();
}
bool PopupMenu::is_item_checkable(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,items.size(),false);
+ ERR_FAIL_INDEX_V(p_idx, items.size(), false);
return items[p_idx].checkable;
}
@@ -836,50 +783,48 @@ int PopupMenu::get_item_count() const {
return items.size();
}
-bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
+bool PopupMenu::activate_item_by_event(const InputEvent &p_event) {
- uint32_t code=0;
- if (p_event.type==InputEvent::KEY) {
- code=p_event.key.scancode;
- if (code==0)
- code=p_event.key.unicode;
+ uint32_t code = 0;
+ if (p_event.type == InputEvent::KEY) {
+ code = p_event.key.scancode;
+ if (code == 0)
+ code = p_event.key.unicode;
if (p_event.key.mod.control)
- code|=KEY_MASK_CTRL;
+ code |= KEY_MASK_CTRL;
if (p_event.key.mod.alt)
- code|=KEY_MASK_ALT;
+ code |= KEY_MASK_ALT;
if (p_event.key.mod.meta)
- code|=KEY_MASK_META;
+ code |= KEY_MASK_META;
if (p_event.key.mod.shift)
- code|=KEY_MASK_SHIFT;
+ code |= KEY_MASK_SHIFT;
}
-
- int il=items.size();
- for(int i=0;i<il;i++) {
+ int il = items.size();
+ for (int i = 0; i < il; i++) {
if (is_item_disabled(i))
continue;
-
if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event)) {
activate_item(i);
return true;
}
- if (code!=0 && items[i].accel==code) {
+ if (code != 0 && items[i].accel == code) {
activate_item(i);
return true;
}
- if (items[i].submenu!="") {
- Node* n = get_node(items[i].submenu);
- if(!n)
+ if (items[i].submenu != "") {
+ Node *n = get_node(items[i].submenu);
+ if (!n)
continue;
- PopupMenu* pm = n->cast_to<PopupMenu>();
- if(!pm)
+ PopupMenu *pm = n->cast_to<PopupMenu>();
+ if (!pm)
continue;
- if(pm->activate_item_by_event(p_event)) {
+ if (pm->activate_item_by_event(p_event)) {
return true;
}
}
@@ -889,40 +834,37 @@ bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
void PopupMenu::activate_item(int p_item) {
-
- ERR_FAIL_INDEX(p_item,items.size());
+ ERR_FAIL_INDEX(p_item, items.size());
ERR_FAIL_COND(items[p_item].separator);
- int id = items[p_item].ID>=0?items[p_item].ID:p_item;
- emit_signal("item_pressed",id);
+ int id = items[p_item].ID >= 0 ? items[p_item].ID : p_item;
+ emit_signal("item_pressed", id);
//hide all parent PopupMenue's
Node *next = get_parent();
PopupMenu *pop = next->cast_to<PopupMenu>();
while (pop) {
- // We close all parents that are chained together,
+ // We close all parents that are chained together,
// with hide_on_item_selection enabled
- if(hide_on_item_selection && pop->is_hide_on_item_selection()) {
+ if (hide_on_item_selection && pop->is_hide_on_item_selection()) {
pop->hide();
next = next->get_parent();
pop = next->cast_to<PopupMenu>();
- }
- else {
- // Break out of loop when the next parent has
+ } else {
+ // Break out of loop when the next parent has
// hide_on_item_selection disabled
break;
}
}
- // Hides popup by default; unless otherwise specified
+ // Hides popup by default; unless otherwise specified
// by using set_hide_on_item_selection
if (hide_on_item_selection) {
hide();
}
-
}
void PopupMenu::remove_item(int p_idx) {
- ERR_FAIL_INDEX(p_idx,items.size());
+ ERR_FAIL_INDEX(p_idx, items.size());
if (items[p_idx].shortcut.is_valid()) {
_unref_shortcut(items[p_idx].shortcut);
@@ -935,30 +877,28 @@ void PopupMenu::remove_item(int p_idx) {
void PopupMenu::add_separator() {
Item sep;
- sep.separator=true;
- sep.ID=-1;
+ sep.separator = true;
+ sep.ID = -1;
items.push_back(sep);
update();
}
-void PopupMenu::clear() {
+void PopupMenu::clear() {
- for(int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
if (items[i].shortcut.is_valid()) {
_unref_shortcut(items[i].shortcut);
}
}
items.clear();
- mouse_over=-1;
+ mouse_over = -1;
update();
-
-
}
Array PopupMenu::_get_items() const {
Array items;
- for(int i=0;i<get_item_count();i++) {
+ for (int i = 0; i < get_item_count(); i++) {
items.push_back(get_item_text(i));
items.push_back(get_item_icon(i));
@@ -974,68 +914,65 @@ Array PopupMenu::_get_items() const {
}
return items;
-
}
-void PopupMenu::_ref_shortcut( Ref<ShortCut> p_sc) {
+void PopupMenu::_ref_shortcut(Ref<ShortCut> p_sc) {
if (!shortcut_refcount.has(p_sc)) {
- shortcut_refcount[p_sc]=1;
- p_sc->connect("changed",this,"update");
+ shortcut_refcount[p_sc] = 1;
+ p_sc->connect("changed", this, "update");
} else {
- shortcut_refcount[p_sc]+=1;
+ shortcut_refcount[p_sc] += 1;
}
}
-void PopupMenu::_unref_shortcut(Ref<ShortCut> p_sc) {
+void PopupMenu::_unref_shortcut(Ref<ShortCut> p_sc) {
ERR_FAIL_COND(!shortcut_refcount.has(p_sc));
shortcut_refcount[p_sc]--;
- if (shortcut_refcount[p_sc]==0) {
- p_sc->disconnect("changed",this,"update");
+ if (shortcut_refcount[p_sc] == 0) {
+ p_sc->disconnect("changed", this, "update");
shortcut_refcount.erase(p_sc);
}
}
-void PopupMenu::_set_items(const Array& p_items){
+void PopupMenu::_set_items(const Array &p_items) {
ERR_FAIL_COND(p_items.size() % 10);
clear();
- for(int i=0;i<p_items.size();i+=10) {
+ for (int i = 0; i < p_items.size(); i += 10) {
- String text=p_items[i+0];
- Ref<Texture> icon=p_items[i+1];
- bool checkable=p_items[i+2];
- bool checked=p_items[i+3];
- bool disabled=p_items[i+4];
+ String text = p_items[i + 0];
+ Ref<Texture> icon = p_items[i + 1];
+ bool checkable = p_items[i + 2];
+ bool checked = p_items[i + 3];
+ bool disabled = p_items[i + 4];
- int id=p_items[i+5];
- int accel=p_items[i+6];
- Variant meta=p_items[i+7];
- String subm=p_items[i+8];
- bool sep=p_items[i+9];
+ int id = p_items[i + 5];
+ int accel = p_items[i + 6];
+ Variant meta = p_items[i + 7];
+ String subm = p_items[i + 8];
+ bool sep = p_items[i + 9];
- int idx=get_item_count();
- add_item(text,id);
- set_item_icon(idx,icon);
- set_item_as_checkable(idx,checkable);
- set_item_checked(idx,checked);
- set_item_disabled(idx,disabled);
- set_item_ID(idx,id);
- set_item_metadata(idx,meta);
- set_item_as_separator(idx,sep);
- set_item_accelerator(idx,accel);
- set_item_submenu(idx,subm);
+ int idx = get_item_count();
+ add_item(text, id);
+ set_item_icon(idx, icon);
+ set_item_as_checkable(idx, checkable);
+ set_item_checked(idx, checked);
+ set_item_disabled(idx, disabled);
+ set_item_ID(idx, id);
+ set_item_metadata(idx, meta);
+ set_item_as_separator(idx, sep);
+ set_item_accelerator(idx, accel);
+ set_item_submenu(idx, subm);
}
-
-
}
// Hide on item selection determines whether or not the popup will close after item selection
void PopupMenu::set_hide_on_item_selection(bool p_enabled) {
- hide_on_item_selection=p_enabled;
+ hide_on_item_selection = p_enabled;
}
bool PopupMenu::is_hide_on_item_selection() {
@@ -1043,127 +980,121 @@ bool PopupMenu::is_hide_on_item_selection() {
return hide_on_item_selection;
}
-String PopupMenu::get_tooltip(const Point2& p_pos) const {
+String PopupMenu::get_tooltip(const Point2 &p_pos) const {
-
- int over=_get_mouse_over(p_pos);
- if (over<0 || over>=items.size())
+ int over = _get_mouse_over(p_pos);
+ if (over < 0 || over >= items.size())
return "";
return items[over].tooltip;
}
+void PopupMenu::set_parent_rect(const Rect2 &p_rect) {
-void PopupMenu::set_parent_rect(const Rect2& p_rect) {
-
- parent_rect=p_rect;
+ parent_rect = p_rect;
}
void PopupMenu::get_translatable_strings(List<String> *p_strings) const {
- for(int i=0;i<items.size();i++) {
+ for (int i = 0; i < items.size(); i++) {
- if (items[i].text!="")
+ if (items[i].text != "")
p_strings->push_back(items[i].text);
}
}
-void PopupMenu::add_autohide_area(const Rect2& p_area) {
+void PopupMenu::add_autohide_area(const Rect2 &p_area) {
autohide_areas.push_back(p_area);
}
-void PopupMenu::clear_autohide_areas(){
+void PopupMenu::clear_autohide_areas() {
autohide_areas.clear();
}
void PopupMenu::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&PopupMenu::_input_event);
- ObjectTypeDB::bind_method(_MD("add_icon_item","texture","label","id","accel"),&PopupMenu::add_icon_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_item","label","id","accel"),&PopupMenu::add_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_icon_check_item","texture","label","id","accel"),&PopupMenu::add_icon_check_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_check_item","label","id","accel"),&PopupMenu::add_check_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_submenu_item","label","submenu","id"),&PopupMenu::add_submenu_item,DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("_input_event"), &PopupMenu::_input_event);
+ ObjectTypeDB::bind_method(_MD("add_icon_item", "texture", "label", "id", "accel"), &PopupMenu::add_icon_item, DEFVAL(-1), DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("add_item", "label", "id", "accel"), &PopupMenu::add_item, DEFVAL(-1), DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("add_icon_check_item", "texture", "label", "id", "accel"), &PopupMenu::add_icon_check_item, DEFVAL(-1), DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("add_check_item", "label", "id", "accel"), &PopupMenu::add_check_item, DEFVAL(-1), DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("add_submenu_item", "label", "submenu", "id"), &PopupMenu::add_submenu_item, DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_icon_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_check_shortcut,DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("add_icon_shortcut", "texture", "shortcut:ShortCut", "id"), &PopupMenu::add_icon_shortcut, DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("add_shortcut", "shortcut:ShortCut", "id"), &PopupMenu::add_shortcut, DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("add_icon_check_shortcut", "texture", "shortcut:ShortCut", "id"), &PopupMenu::add_icon_check_shortcut, DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("add_check_shortcut", "shortcut:ShortCut", "id"), &PopupMenu::add_check_shortcut, DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
- ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
- ObjectTypeDB::bind_method(_MD("set_item_accelerator","idx","accel"),&PopupMenu::set_item_accelerator);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
- ObjectTypeDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
- ObjectTypeDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
- ObjectTypeDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&PopupMenu::set_item_tooltip);
- ObjectTypeDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut"),&PopupMenu::set_item_shortcut);
+ ObjectTypeDB::bind_method(_MD("set_item_text", "idx", "text"), &PopupMenu::set_item_text);
+ ObjectTypeDB::bind_method(_MD("set_item_icon", "idx", "icon"), &PopupMenu::set_item_icon);
+ ObjectTypeDB::bind_method(_MD("set_item_checked", "idx", "checked"), &PopupMenu::set_item_checked);
+ ObjectTypeDB::bind_method(_MD("set_item_ID", "idx", "id"), &PopupMenu::set_item_ID);
+ ObjectTypeDB::bind_method(_MD("set_item_accelerator", "idx", "accel"), &PopupMenu::set_item_accelerator);
+ ObjectTypeDB::bind_method(_MD("set_item_metadata", "idx", "metadata"), &PopupMenu::set_item_metadata);
+ ObjectTypeDB::bind_method(_MD("set_item_disabled", "idx", "disabled"), &PopupMenu::set_item_disabled);
+ ObjectTypeDB::bind_method(_MD("set_item_submenu", "idx", "submenu"), &PopupMenu::set_item_submenu);
+ ObjectTypeDB::bind_method(_MD("set_item_as_separator", "idx", "enable"), &PopupMenu::set_item_as_separator);
+ ObjectTypeDB::bind_method(_MD("set_item_as_checkable", "idx", "enable"), &PopupMenu::set_item_as_checkable);
+ ObjectTypeDB::bind_method(_MD("set_item_tooltip", "idx", "tooltip"), &PopupMenu::set_item_tooltip);
+ ObjectTypeDB::bind_method(_MD("set_item_shortcut", "idx", "shortcut:ShortCut"), &PopupMenu::set_item_shortcut);
- ObjectTypeDB::bind_method(_MD("toggle_item_checked","idx"), &PopupMenu::toggle_item_checked);
+ ObjectTypeDB::bind_method(_MD("toggle_item_checked", "idx"), &PopupMenu::toggle_item_checked);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&PopupMenu::get_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_icon","idx"),&PopupMenu::get_item_icon);
- ObjectTypeDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
- ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
- ObjectTypeDB::bind_method(_MD("get_item_accelerator","idx"),&PopupMenu::get_item_accelerator);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("get_item_submenu","idx"),&PopupMenu::get_item_submenu);
- ObjectTypeDB::bind_method(_MD("is_item_separator","idx"),&PopupMenu::is_item_separator);
- ObjectTypeDB::bind_method(_MD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
- ObjectTypeDB::bind_method(_MD("get_item_tooltip","idx"),&PopupMenu::get_item_tooltip);
- ObjectTypeDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
+ ObjectTypeDB::bind_method(_MD("get_item_text", "idx"), &PopupMenu::get_item_text);
+ ObjectTypeDB::bind_method(_MD("get_item_icon", "idx"), &PopupMenu::get_item_icon);
+ ObjectTypeDB::bind_method(_MD("is_item_checked", "idx"), &PopupMenu::is_item_checked);
+ ObjectTypeDB::bind_method(_MD("get_item_ID", "idx"), &PopupMenu::get_item_ID);
+ ObjectTypeDB::bind_method(_MD("get_item_index", "id"), &PopupMenu::get_item_index);
+ ObjectTypeDB::bind_method(_MD("get_item_accelerator", "idx"), &PopupMenu::get_item_accelerator);
+ ObjectTypeDB::bind_method(_MD("get_item_metadata", "idx"), &PopupMenu::get_item_metadata);
+ ObjectTypeDB::bind_method(_MD("is_item_disabled", "idx"), &PopupMenu::is_item_disabled);
+ ObjectTypeDB::bind_method(_MD("get_item_submenu", "idx"), &PopupMenu::get_item_submenu);
+ ObjectTypeDB::bind_method(_MD("is_item_separator", "idx"), &PopupMenu::is_item_separator);
+ ObjectTypeDB::bind_method(_MD("is_item_checkable", "idx"), &PopupMenu::is_item_checkable);
+ ObjectTypeDB::bind_method(_MD("get_item_tooltip", "idx"), &PopupMenu::get_item_tooltip);
+ ObjectTypeDB::bind_method(_MD("get_item_shortcut:ShortCut", "idx"), &PopupMenu::get_item_shortcut);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&PopupMenu::get_item_count);
+ ObjectTypeDB::bind_method(_MD("get_item_count"), &PopupMenu::get_item_count);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&PopupMenu::remove_item);
+ ObjectTypeDB::bind_method(_MD("remove_item", "idx"), &PopupMenu::remove_item);
- ObjectTypeDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
- ObjectTypeDB::bind_method(_MD("clear"),&PopupMenu::clear);
+ ObjectTypeDB::bind_method(_MD("add_separator"), &PopupMenu::add_separator);
+ ObjectTypeDB::bind_method(_MD("clear"), &PopupMenu::clear);
- ObjectTypeDB::bind_method(_MD("_set_items"),&PopupMenu::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&PopupMenu::_get_items);
+ ObjectTypeDB::bind_method(_MD("_set_items"), &PopupMenu::_set_items);
+ ObjectTypeDB::bind_method(_MD("_get_items"), &PopupMenu::_get_items);
- ObjectTypeDB::bind_method(_MD("set_hide_on_item_selection","enable"),&PopupMenu::set_hide_on_item_selection);
- ObjectTypeDB::bind_method(_MD("is_hide_on_item_selection"),&PopupMenu::is_hide_on_item_selection);
+ ObjectTypeDB::bind_method(_MD("set_hide_on_item_selection", "enable"), &PopupMenu::set_hide_on_item_selection);
+ ObjectTypeDB::bind_method(_MD("is_hide_on_item_selection"), &PopupMenu::is_hide_on_item_selection);
- ObjectTypeDB::bind_method(_MD("_submenu_timeout"),&PopupMenu::_submenu_timeout);
+ ObjectTypeDB::bind_method(_MD("_submenu_timeout"), &PopupMenu::_submenu_timeout);
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
- ADD_PROPERTYNO( PropertyInfo(Variant::BOOL, "hide_on_item_selection" ), _SCS("set_hide_on_item_selection"), _SCS("is_hide_on_item_selection") );
-
- ADD_SIGNAL( MethodInfo("item_pressed", PropertyInfo( Variant::INT,"ID") ) );
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"), _SCS("_get_items"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "hide_on_item_selection"), _SCS("set_hide_on_item_selection"), _SCS("is_hide_on_item_selection"));
+ ADD_SIGNAL(MethodInfo("item_pressed", PropertyInfo(Variant::INT, "ID")));
}
-
void PopupMenu::set_invalidate_click_until_motion() {
- moved=Vector2();
- invalidated_click=true;
+ moved = Vector2();
+ invalidated_click = true;
}
PopupMenu::PopupMenu() {
-
- mouse_over=-1;
+ mouse_over = -1;
set_focus_mode(FOCUS_ALL);
set_as_toplevel(true);
set_hide_on_item_selection(true);
- submenu_timer = memnew( Timer );
+ submenu_timer = memnew(Timer);
submenu_timer->set_wait_time(0.3);
submenu_timer->set_one_shot(true);
- submenu_timer->connect("timeout",this,"_submenu_timeout");
+ submenu_timer->connect("timeout", this, "_submenu_timeout");
add_child(submenu_timer);
}
-
PopupMenu::~PopupMenu() {
}
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index 09f537000..1ea6881c2 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -35,11 +35,9 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-
-
class PopupMenu : public Popup {
- OBJ_TYPE(PopupMenu, Popup );
+ OBJ_TYPE(PopupMenu, Popup);
struct Item {
Ref<Texture> icon;
@@ -56,10 +54,16 @@ class PopupMenu : public Popup {
int _ofs_cache;
Ref<ShortCut> shortcut;
- Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; }
+ Item() {
+ checked = false;
+ checkable = false;
+ separator = false;
+ accel = 0;
+ disabled = false;
+ _ofs_cache = 0;
+ }
};
-
Timer *submenu_timer;
List<Rect2> autohide_areas;
Vector<Item> items;
@@ -67,7 +71,7 @@ class PopupMenu : public Popup {
int submenu_over;
Rect2 parent_rect;
String _get_accel_text(int p_item) const;
- int _get_mouse_over(const Point2& p_over) const;
+ int _get_mouse_over(const Point2 &p_over) const;
virtual Size2 get_minimum_size() const;
void _input_event(const InputEvent &p_event);
void _activate_submenu(int over);
@@ -78,44 +82,44 @@ class PopupMenu : public Popup {
Vector2 moved;
Array _get_items() const;
- void _set_items(const Array& p_items);
+ void _set_items(const Array &p_items);
- Map< Ref<ShortCut>, int> shortcut_refcount;
+ Map<Ref<ShortCut>, int> shortcut_refcount;
void _ref_shortcut(Ref<ShortCut> p_sc);
- void _unref_shortcut( Ref<ShortCut> p_sc);
-protected:
+ void _unref_shortcut(Ref<ShortCut> p_sc);
- virtual bool has_point(const Point2& p_point) const;
+protected:
+ virtual bool has_point(const Point2 &p_point) const;
-friend class MenuButton;
+ friend class MenuButton;
void _notification(int p_what);
static void _bind_methods();
-public:
- void add_icon_item(const Ref<Texture>& p_icon,const String& p_label,int p_ID=-1,uint32_t p_accel=0);
- void add_item(const String& p_label,int p_ID=-1,uint32_t p_accel=0);
- void add_icon_check_item(const Ref<Texture>& p_icon,const String& p_label,int p_ID=-1,uint32_t p_accel=0);
- void add_check_item(const String& p_label,int p_ID=-1,uint32_t p_accel=0);
- void add_submenu_item(const String& p_label,const String& p_submenu, int p_ID=-1);
+public:
+ void add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID = -1, uint32_t p_accel = 0);
+ void add_item(const String &p_label, int p_ID = -1, uint32_t p_accel = 0);
+ void add_icon_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_ID = -1, uint32_t p_accel = 0);
+ void add_check_item(const String &p_label, int p_ID = -1, uint32_t p_accel = 0);
+ void add_submenu_item(const String &p_label, const String &p_submenu, int p_ID = -1);
- void add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1);
+ void add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID = -1);
+ void add_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID = -1);
+ void add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID = -1);
+ void add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID = -1);
- void set_item_text(int p_idx,const String& p_text);
- void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
- void set_item_checked(int p_idx,bool p_checked);
- void set_item_ID(int p_idx,int p_ID);
- void set_item_accelerator(int p_idx,uint32_t p_accel);
- void set_item_metadata(int p_idx,const Variant& p_meta);
- void set_item_disabled(int p_idx,bool p_disabled);
- void set_item_submenu(int p_idx, const String& p_submenu);
+ void set_item_text(int p_idx, const String &p_text);
+ void set_item_icon(int p_idx, const Ref<Texture> &p_icon);
+ void set_item_checked(int p_idx, bool p_checked);
+ void set_item_ID(int p_idx, int p_ID);
+ void set_item_accelerator(int p_idx, uint32_t p_accel);
+ void set_item_metadata(int p_idx, const Variant &p_meta);
+ void set_item_disabled(int p_idx, bool p_disabled);
+ void set_item_submenu(int p_idx, const String &p_submenu);
void set_item_as_separator(int p_idx, bool p_separator);
void set_item_as_checkable(int p_idx, bool p_checkable);
- void set_item_tooltip(int p_idx,const String& p_tooltip);
- void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut);
+ void set_item_tooltip(int p_idx, const String &p_tooltip);
+ void set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut);
void toggle_item_checked(int p_idx);
@@ -135,7 +139,7 @@ public:
int get_item_count() const;
- bool activate_item_by_event(const InputEvent& p_event);
+ bool activate_item_by_event(const InputEvent &p_event);
void activate_item(int p_item);
void remove_item(int p_idx);
@@ -144,13 +148,13 @@ public:
void clear();
- void set_parent_rect(const Rect2& p_rect);
+ void set_parent_rect(const Rect2 &p_rect);
- virtual String get_tooltip(const Point2& p_pos) const;
+ virtual String get_tooltip(const Point2 &p_pos) const;
virtual void get_translatable_strings(List<String> *p_strings) const;
- void add_autohide_area(const Rect2& p_area);
+ void add_autohide_area(const Rect2 &p_area);
void clear_autohide_areas();
void set_invalidate_click_until_motion();
@@ -159,7 +163,6 @@ public:
PopupMenu();
~PopupMenu();
-
};
#endif
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 71c2a4027..bb108fcb0 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -28,67 +28,63 @@
/*************************************************************************/
#include "progress_bar.h"
-
Size2 ProgressBar::get_minimum_size() const {
Ref<StyleBox> bg = get_stylebox("bg");
Ref<Font> font = get_font("font");
- Size2 ms=bg->get_minimum_size()+bg->get_center_size();
+ Size2 ms = bg->get_minimum_size() + bg->get_center_size();
if (percent_visible) {
- ms.height=MAX(ms.height,bg->get_minimum_size().height+font->get_height());
+ ms.height = MAX(ms.height, bg->get_minimum_size().height + font->get_height());
}
return ms;
}
-
void ProgressBar::_notification(int p_what) {
-
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
Ref<StyleBox> bg = get_stylebox("bg");
Ref<StyleBox> fg = get_stylebox("fg");
Ref<Font> font = get_font("font");
- Color font_color=get_color("font_color");
+ Color font_color = get_color("font_color");
- draw_style_box(bg,Rect2(Point2(),get_size()));
+ draw_style_box(bg, Rect2(Point2(), get_size()));
float r = get_unit_value();
int mp = fg->get_minimum_size().width;
- int p = r*get_size().width-mp;
- if (p>0) {
+ int p = r * get_size().width - mp;
+ if (p > 0) {
- draw_style_box(fg,Rect2(Point2(),Size2(p+fg->get_minimum_size().width,get_size().height)));
+ draw_style_box(fg, Rect2(Point2(), Size2(p + fg->get_minimum_size().width, get_size().height)));
}
if (percent_visible) {
- String txt=itos(int(get_unit_value()*100))+"%";
- font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
+ String txt = itos(int(get_unit_value() * 100)) + "%";
+ font->draw_halign(get_canvas_item(), Point2(0, font->get_ascent() + (get_size().height - font->get_height()) / 2), HALIGN_CENTER, get_size().width, txt, font_color);
}
}
}
-
void ProgressBar::set_percent_visible(bool p_visible) {
- percent_visible=p_visible;
+ percent_visible = p_visible;
update();
}
-bool ProgressBar::is_percent_visible() const{
+bool ProgressBar::is_percent_visible() const {
return percent_visible;
}
void ProgressBar::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
- ObjectTypeDB::bind_method(_MD("is_percent_visible"),&ProgressBar::is_percent_visible);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent/visible"),_SCS("set_percent_visible"),_SCS("is_percent_visible"));
+ ObjectTypeDB::bind_method(_MD("set_percent_visible", "visible"), &ProgressBar::set_percent_visible);
+ ObjectTypeDB::bind_method(_MD("is_percent_visible"), &ProgressBar::is_percent_visible);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "percent/visible"), _SCS("set_percent_visible"), _SCS("is_percent_visible"));
}
ProgressBar::ProgressBar() {
set_v_size_flags(0);
- percent_visible=true;
+ percent_visible = true;
}
diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h
index 4f5e0d998..68b1714e7 100644
--- a/scene/gui/progress_bar.h
+++ b/scene/gui/progress_bar.h
@@ -33,15 +33,15 @@
class ProgressBar : public Range {
- OBJ_TYPE( ProgressBar, Range );
+ OBJ_TYPE(ProgressBar, Range);
bool percent_visible;
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_percent_visible(bool p_visible);
bool is_percent_visible() const;
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index ef0e735af..b7be00b09 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -28,20 +28,18 @@
/*************************************************************************/
#include "range.h"
-
-
void Range::_value_changed_notify() {
_value_changed(shared->val);
- emit_signal("value_changed",shared->val);
+ emit_signal("value_changed", shared->val);
update();
_change_notify("range/value");
}
void Range::Shared::emit_value_changed() {
- for (Set<Range*>::Element *E=owners.front();E;E=E->next()) {
- Range *r=E->get();
+ for (Set<Range *>::Element *E = owners.front(); E; E = E->next()) {
+ Range *r = E->get();
if (!r->is_inside_tree())
continue;
r->_value_changed_notify();
@@ -50,65 +48,62 @@ void Range::Shared::emit_value_changed() {
void Range::_changed_notify(const char *p_what) {
- emit_signal("changed",shared->val);
+ emit_signal("changed", shared->val);
update();
_change_notify(p_what);
}
void Range::Shared::emit_changed(const char *p_what) {
- for (Set<Range*>::Element *E=owners.front();E;E=E->next()) {
- Range *r=E->get();
+ for (Set<Range *>::Element *E = owners.front(); E; E = E->next()) {
+ Range *r = E->get();
if (!r->is_inside_tree())
continue;
r->_changed_notify(p_what);
}
}
-
void Range::set_val(double p_val) {
- if(_rounded_values){
+ if (_rounded_values) {
p_val = Math::round(p_val);
}
- if (p_val>shared->max-shared->page)
- p_val=shared->max-shared->page;
+ if (p_val > shared->max - shared->page)
+ p_val = shared->max - shared->page;
- if (p_val<shared->min)
- p_val=shared->min;
+ if (p_val < shared->min)
+ p_val = shared->min;
- if (shared->val==p_val)
+ if (shared->val == p_val)
return;
- shared->val=p_val;
+ shared->val = p_val;
shared->emit_value_changed();
}
void Range::set_min(double p_min) {
- shared->min=p_min;
+ shared->min = p_min;
set_val(shared->val);
shared->emit_changed("range/min");
}
void Range::set_max(double p_max) {
- shared->max=p_max;
+ shared->max = p_max;
set_val(shared->val);
shared->emit_changed("range/max");
-
}
void Range::set_step(double p_step) {
- shared->step=p_step;
+ shared->step = p_step;
shared->emit_changed("range/step");
-
}
void Range::set_page(double p_page) {
- shared->page=p_page;
+ shared->page = p_page;
set_val(shared->val);
shared->emit_changed("range/page");
@@ -139,11 +134,11 @@ void Range::set_unit_value(double p_value) {
double v;
- if (shared->exp_unit_value && get_min()>0) {
+ if (shared->exp_unit_value && get_min() > 0) {
- double exp_min = Math::log(get_min())/Math::log(2);
- double exp_max = Math::log(get_max())/Math::log(2);
- v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
+ double exp_min = Math::log(get_min()) / Math::log(2);
+ double exp_max = Math::log(get_max()) / Math::log(2);
+ v = Math::pow(2, exp_min + (exp_max - exp_min) * p_value);
} else {
double percent = (get_max() - get_min()) * p_value;
@@ -154,15 +149,15 @@ void Range::set_unit_value(double p_value) {
v = percent + get_min();
}
}
- set_val( v );
+ set_val(v);
}
double Range::get_unit_value() const {
- if (shared->exp_unit_value && get_min()>0) {
+ if (shared->exp_unit_value && get_min() > 0) {
- double exp_min = Math::log(get_min())/Math::log(2);
- double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::log(get_val())/Math::log(2);
+ double exp_min = Math::log(get_min()) / Math::log(2);
+ double exp_max = Math::log(get_max()) / Math::log(2);
+ double v = Math::log(get_val()) / Math::log(2);
return (v - exp_min) / (exp_max - exp_min);
@@ -174,7 +169,7 @@ double Range::get_unit_value() const {
void Range::_share(Node *p_range) {
- Range * r = p_range->cast_to<Range>();
+ Range *r = p_range->cast_to<Range>();
ERR_FAIL_COND(!r);
share(r);
}
@@ -190,71 +185,69 @@ void Range::share(Range *p_range) {
void Range::unshare() {
- Shared * nshared = memnew(Shared);
- nshared->min=shared->min;
- nshared->max=shared->max;
- nshared->val=shared->val;
- nshared->step=shared->step;
- nshared->page=shared->page;
+ Shared *nshared = memnew(Shared);
+ nshared->min = shared->min;
+ nshared->max = shared->max;
+ nshared->val = shared->val;
+ nshared->step = shared->step;
+ nshared->page = shared->page;
_unref_shared();
_ref_shared(nshared);
}
void Range::_ref_shared(Shared *p_shared) {
- if (shared && p_shared==shared)
+ if (shared && p_shared == shared)
return;
_unref_shared();
- shared=p_shared;
+ shared = p_shared;
shared->owners.insert(this);
}
-
void Range::_unref_shared() {
shared->owners.erase(this);
- if (shared->owners.size()==0) {
+ if (shared->owners.size() == 0) {
memdelete(shared);
- shared=NULL;
+ shared = NULL;
}
}
void Range::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_val"),&Range::get_val);
- ObjectTypeDB::bind_method(_MD("get_value"),&Range::get_val);
- ObjectTypeDB::bind_method(_MD("get_min"),&Range::get_min);
- ObjectTypeDB::bind_method(_MD("get_max"),&Range::get_max);
- ObjectTypeDB::bind_method(_MD("get_step"),&Range::get_step);
- ObjectTypeDB::bind_method(_MD("get_page"),&Range::get_page);
- ObjectTypeDB::bind_method(_MD("get_unit_value"),&Range::get_unit_value);
- ObjectTypeDB::bind_method(_MD("set_val","value"),&Range::set_val);
- ObjectTypeDB::bind_method(_MD("set_value","value"),&Range::set_val);
- ObjectTypeDB::bind_method(_MD("set_min","minimum"),&Range::set_min);
- ObjectTypeDB::bind_method(_MD("set_max","maximum"),&Range::set_max);
- ObjectTypeDB::bind_method(_MD("set_step","step"),&Range::set_step);
- ObjectTypeDB::bind_method(_MD("set_page","pagesize"),&Range::set_page);
- ObjectTypeDB::bind_method(_MD("set_unit_value","value"),&Range::set_unit_value);
- ObjectTypeDB::bind_method(_MD("set_rounded_values","enabled"),&Range::set_rounded_values);
- ObjectTypeDB::bind_method(_MD("is_rounded_values"),&Range::is_rounded_values);
- ObjectTypeDB::bind_method(_MD("set_exp_unit_value","enabled"),&Range::set_exp_unit_value);
- ObjectTypeDB::bind_method(_MD("is_unit_value_exp"),&Range::is_unit_value_exp);
+ ObjectTypeDB::bind_method(_MD("get_val"), &Range::get_val);
+ ObjectTypeDB::bind_method(_MD("get_value"), &Range::get_val);
+ ObjectTypeDB::bind_method(_MD("get_min"), &Range::get_min);
+ ObjectTypeDB::bind_method(_MD("get_max"), &Range::get_max);
+ ObjectTypeDB::bind_method(_MD("get_step"), &Range::get_step);
+ ObjectTypeDB::bind_method(_MD("get_page"), &Range::get_page);
+ ObjectTypeDB::bind_method(_MD("get_unit_value"), &Range::get_unit_value);
+ ObjectTypeDB::bind_method(_MD("set_val", "value"), &Range::set_val);
+ ObjectTypeDB::bind_method(_MD("set_value", "value"), &Range::set_val);
+ ObjectTypeDB::bind_method(_MD("set_min", "minimum"), &Range::set_min);
+ ObjectTypeDB::bind_method(_MD("set_max", "maximum"), &Range::set_max);
+ ObjectTypeDB::bind_method(_MD("set_step", "step"), &Range::set_step);
+ ObjectTypeDB::bind_method(_MD("set_page", "pagesize"), &Range::set_page);
+ ObjectTypeDB::bind_method(_MD("set_unit_value", "value"), &Range::set_unit_value);
+ ObjectTypeDB::bind_method(_MD("set_rounded_values", "enabled"), &Range::set_rounded_values);
+ ObjectTypeDB::bind_method(_MD("is_rounded_values"), &Range::is_rounded_values);
+ ObjectTypeDB::bind_method(_MD("set_exp_unit_value", "enabled"), &Range::set_exp_unit_value);
+ ObjectTypeDB::bind_method(_MD("is_unit_value_exp"), &Range::is_unit_value_exp);
- ObjectTypeDB::bind_method(_MD("share","with"),&Range::_share);
- ObjectTypeDB::bind_method(_MD("unshare"),&Range::unshare);
+ ObjectTypeDB::bind_method(_MD("share", "with"), &Range::_share);
+ ObjectTypeDB::bind_method(_MD("unshare"), &Range::unshare);
- ADD_SIGNAL( MethodInfo("value_changed", PropertyInfo(Variant::REAL,"value")));
- ADD_SIGNAL( MethodInfo("changed"));
-
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/min" ), _SCS("set_min"), _SCS("get_min") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/max" ), _SCS("set_max"), _SCS("get_max") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/step" ), _SCS("set_step"), _SCS("get_step") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/page" ), _SCS("set_page"), _SCS("get_page") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/value" ), _SCS("set_val"), _SCS("get_val") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "range/exp_edit" ), _SCS("set_exp_unit_value"), _SCS("is_unit_value_exp") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "range/rounded" ), _SCS("set_rounded_values"), _SCS("is_rounded_values") );
+ ADD_SIGNAL(MethodInfo("value_changed", PropertyInfo(Variant::REAL, "value")));
+ ADD_SIGNAL(MethodInfo("changed"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "range/min"), _SCS("set_min"), _SCS("get_min"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "range/max"), _SCS("set_max"), _SCS("get_max"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "range/step"), _SCS("set_step"), _SCS("get_step"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "range/page"), _SCS("set_page"), _SCS("get_page"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "range/value"), _SCS("set_val"), _SCS("get_val"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "range/exp_edit"), _SCS("set_exp_unit_value"), _SCS("is_unit_value_exp"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "range/rounded"), _SCS("set_rounded_values"), _SCS("is_rounded_values"));
}
void Range::set_rounded_values(bool p_enable) {
@@ -269,7 +262,7 @@ bool Range::is_rounded_values() const {
void Range::set_exp_unit_value(bool p_enable) {
- shared->exp_unit_value=p_enable;
+ shared->exp_unit_value = p_enable;
}
bool Range::is_unit_value_exp() const {
@@ -277,25 +270,20 @@ bool Range::is_unit_value_exp() const {
return shared->exp_unit_value;
}
-
-Range::Range()
-{
+Range::Range() {
shared = memnew(Shared);
- shared->min=0;
- shared->max=100;
- shared->val=
- shared->step=1;
- shared->page=0;
+ shared->min = 0;
+ shared->max = 100;
+ shared->val =
+ shared->step = 1;
+ shared->page = 0;
shared->owners.insert(this);
- shared->exp_unit_value=false;
+ shared->exp_unit_value = false;
_rounded_values = false;
}
-
Range::~Range() {
_unref_shared();
}
-
-
diff --git a/scene/gui/range.h b/scene/gui/range.h
index ba59c7bc2..4418d3ef4 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -35,16 +35,15 @@
*/
class Range : public Control {
- OBJ_TYPE( Range, Control );
-
+ OBJ_TYPE(Range, Control);
struct Shared {
- double val,min,max;
- double step,page;
+ double val, min, max;
+ double step, page;
bool exp_unit_value;
- Set<Range*> owners;
+ Set<Range *> owners;
void emit_value_changed();
- void emit_changed(const char *p_what="");
+ void emit_changed(const char *p_what = "");
};
Shared *shared;
@@ -55,17 +54,16 @@ class Range : public Control {
void _share(Node *p_range);
void _value_changed_notify();
- void _changed_notify(const char *p_what="");
+ void _changed_notify(const char *p_what = "");
protected:
-
virtual void _value_changed(double) {}
static void _bind_methods();
bool _rounded_values;
-public:
+public:
void set_val(double p_val);
void set_min(double p_min);
void set_max(double p_max);
@@ -91,7 +89,6 @@ public:
Range();
~Range();
-
};
#endif
diff --git a/scene/gui/reference_frame.cpp b/scene/gui/reference_frame.cpp
index 37bc3ae6f..cf64403fe 100644
--- a/scene/gui/reference_frame.cpp
+++ b/scene/gui/reference_frame.cpp
@@ -30,15 +30,14 @@
void ReferenceFrame::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
if (!is_inside_tree())
return;
if (get_tree()->is_editor_hint())
- draw_style_box(get_stylebox("border"),Rect2(Point2(),get_size())) ;
+ draw_style_box(get_stylebox("border"), Rect2(Point2(), get_size()));
}
}
-ReferenceFrame::ReferenceFrame()
-{
+ReferenceFrame::ReferenceFrame() {
}
diff --git a/scene/gui/reference_frame.h b/scene/gui/reference_frame.h
index 139ee3e66..aec7ff80e 100644
--- a/scene/gui/reference_frame.h
+++ b/scene/gui/reference_frame.h
@@ -33,11 +33,11 @@
class ReferenceFrame : public Control {
- OBJ_TYPE( ReferenceFrame, Control);
+ OBJ_TYPE(ReferenceFrame, Control);
protected:
-
void _notification(int p_what);
+
public:
ReferenceFrame();
};
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 88ac23ec5..7f8d81022 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -27,10 +27,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "rich_text_label.h"
-#include "scene/scene_string_names.h"
#include "os/keyboard.h"
#include "os/os.h"
-RichTextLabel::Item *RichTextLabel::_get_next_item(Item* p_item,bool p_free) {
+#include "scene/scene_string_names.h"
+RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) {
if (p_free) {
@@ -45,550 +45,511 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item* p_item,bool p_free) {
} else {
//go up until something with a next is found
while (p_item->parent && !p_item->E->next()) {
- p_item=p_item->parent;
+ p_item = p_item->parent;
}
-
if (p_item->parent)
return p_item->E->next()->get();
else
return NULL;
-
}
} else {
- if (p_item->subitems.size() && p_item->type!=ITEM_TABLE) {
+ if (p_item->subitems.size() && p_item->type != ITEM_TABLE) {
return p_item->subitems.front()->get();
- } else if (p_item->type==ITEM_FRAME) {
+ } else if (p_item->type == ITEM_FRAME) {
return NULL;
} else if (p_item->E->next()) {
return p_item->E->next()->get();
} else {
//go up until something with a next is found
- while (p_item->type!=ITEM_FRAME && !p_item->E->next()) {
- p_item=p_item->parent;
+ while (p_item->type != ITEM_FRAME && !p_item->E->next()) {
+ p_item = p_item->parent;
}
-
- if (p_item->type!=ITEM_FRAME)
+ if (p_item->type != ITEM_FRAME)
return p_item->E->next()->get();
else
return NULL;
-
}
}
return NULL;
-
}
-
-void RichTextLabel::_process_line(ItemFrame *p_frame,const Vector2& p_ofs,int &y, int p_width, int p_line, ProcessMode p_mode,const Ref<Font> &p_base_font,const Color &p_base_color,const Point2i& p_click_pos,Item **r_click_item,int *r_click_char,bool *r_outside,int p_char_count) {
+void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos, Item **r_click_item, int *r_click_char, bool *r_outside, int p_char_count) {
RID ci;
if (r_outside)
- *r_outside=false;
- if (p_mode==PROCESS_DRAW) {
- ci=get_canvas_item();
+ *r_outside = false;
+ if (p_mode == PROCESS_DRAW) {
+ ci = get_canvas_item();
if (r_click_item)
- *r_click_item=NULL;
-
+ *r_click_item = NULL;
}
Line &l = p_frame->lines[p_line];
Item *it = l.from;
+ int line_ofs = 0;
+ int margin = _find_margin(it, p_base_font);
+ Align align = _find_align(it);
+ int line = 0;
+ int spaces = 0;
- int line_ofs=0;
- int margin=_find_margin(it,p_base_font);
- Align align=_find_align(it);
- int line=0;
- int spaces=0;
+ if (p_mode != PROCESS_CACHE) {
-
- if (p_mode!=PROCESS_CACHE) {
-
- ERR_FAIL_INDEX(line,l.offset_caches.size());
+ ERR_FAIL_INDEX(line, l.offset_caches.size());
line_ofs = l.offset_caches[line];
}
- if (p_mode==PROCESS_CACHE) {
+ if (p_mode == PROCESS_CACHE) {
l.offset_caches.clear();
l.height_caches.clear();
- l.char_count=0;
- l.minimum_width=0;
+ l.char_count = 0;
+ l.minimum_width = 0;
}
- int wofs=margin;
- int spaces_size=0;
- int align_ofs=0;
-
+ int wofs = margin;
+ int spaces_size = 0;
+ int align_ofs = 0;
- if (p_mode!=PROCESS_CACHE && align!=ALIGN_FILL)
- wofs+=line_ofs;
+ if (p_mode != PROCESS_CACHE && align != ALIGN_FILL)
+ wofs += line_ofs;
- int begin=wofs;
+ int begin = wofs;
Ref<Font> cfont = _find_font(it);
if (cfont.is_null())
- cfont=p_base_font;
+ cfont = p_base_font;
//line height should be the font height for the first time, this ensures that an empty line will never have zero height and succesive newlines are displayed
- int line_height=cfont->get_height();
+ int line_height = cfont->get_height();
Variant meta;
-#define NEW_LINE \
-{\
- if (p_mode!=PROCESS_CACHE) {\
- line++;\
- if (line < l.offset_caches.size())\
- line_ofs=l.offset_caches[line];\
- wofs=margin;\
- if (align!=ALIGN_FILL)\
- wofs+=line_ofs;\
- } else {\
- int used=wofs-margin;\
- switch(align) {\
- case ALIGN_LEFT: l.offset_caches.push_back(0); break;\
- case ALIGN_CENTER: l.offset_caches.push_back(((p_width-margin)-used)/2); break;\
- case ALIGN_RIGHT: l.offset_caches.push_back(((p_width-margin)-used)); break;\
- case ALIGN_FILL: l.offset_caches.push_back((p_width-margin)-used/*+spaces_size*/); break;\
- }\
- l.height_caches.push_back(line_height);\
- l.space_caches.push_back(spaces);\
- }\
- y+=line_height+get_constant(SceneStringNames::get_singleton()->line_separation);\
- line_height=0;\
- spaces=0;\
- spaces_size=0;\
- wofs=begin;\
- align_ofs=0;\
- if (p_mode!=PROCESS_CACHE) {\
- lh=line<l.height_caches.size()?l.height_caches[line]:1;\
- }\
- if (p_mode==PROCESS_POINTER && r_click_item && p_click_pos.y>=p_ofs.y+y && p_click_pos.y<=p_ofs.y+y+lh && p_click_pos.x<p_ofs.x+wofs) {\
- if (r_outside) *r_outside=true;\
- *r_click_item=it;\
- *r_click_char=rchar;\
- return;\
- }\
-}
-
-
-#define ENSURE_WIDTH(m_width) \
- if (p_mode==PROCESS_CACHE) { \
- l.minimum_width=MAX(l.minimum_width,wofs+m_width);\
- }\
- if (wofs + m_width > p_width) {\
- if (p_mode==PROCESS_CACHE) {\
- if (spaces>0) \
- spaces-=1;\
- }\
- if (p_mode==PROCESS_POINTER && r_click_item && p_click_pos.y>=p_ofs.y+y && p_click_pos.y<=p_ofs.y+y+lh && p_click_pos.x>p_ofs.x+wofs) {\
- if (r_outside) *r_outside=true; \
- *r_click_item=it;\
- *r_click_char=rchar;\
- return;\
- }\
- NEW_LINE\
+#define NEW_LINE \
+ { \
+ if (p_mode != PROCESS_CACHE) { \
+ line++; \
+ if (line < l.offset_caches.size()) \
+ line_ofs = l.offset_caches[line]; \
+ wofs = margin; \
+ if (align != ALIGN_FILL) \
+ wofs += line_ofs; \
+ } else { \
+ int used = wofs - margin; \
+ switch (align) { \
+ case ALIGN_LEFT: l.offset_caches.push_back(0); break; \
+ case ALIGN_CENTER: l.offset_caches.push_back(((p_width - margin) - used) / 2); break; \
+ case ALIGN_RIGHT: l.offset_caches.push_back(((p_width - margin) - used)); break; \
+ case ALIGN_FILL: l.offset_caches.push_back((p_width - margin) - used /*+spaces_size*/); break; \
+ } \
+ l.height_caches.push_back(line_height); \
+ l.space_caches.push_back(spaces); \
+ } \
+ y += line_height + get_constant(SceneStringNames::get_singleton()->line_separation); \
+ line_height = 0; \
+ spaces = 0; \
+ spaces_size = 0; \
+ wofs = begin; \
+ align_ofs = 0; \
+ if (p_mode != PROCESS_CACHE) { \
+ lh = line < l.height_caches.size() ? l.height_caches[line] : 1; \
+ } \
+ if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && p_click_pos.x < p_ofs.x + wofs) { \
+ if (r_outside) *r_outside = true; \
+ *r_click_item = it; \
+ *r_click_char = rchar; \
+ return; \
+ } \
}
+#define ENSURE_WIDTH(m_width) \
+ if (p_mode == PROCESS_CACHE) { \
+ l.minimum_width = MAX(l.minimum_width, wofs + m_width); \
+ } \
+ if (wofs + m_width > p_width) { \
+ if (p_mode == PROCESS_CACHE) { \
+ if (spaces > 0) \
+ spaces -= 1; \
+ } \
+ if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && p_click_pos.x > p_ofs.x + wofs) { \
+ if (r_outside) *r_outside = true; \
+ *r_click_item = it; \
+ *r_click_char = rchar; \
+ return; \
+ } \
+ NEW_LINE \
+ }
-#define ADVANCE(m_width) \
-{\
- if (p_mode==PROCESS_POINTER && r_click_item && p_click_pos.y>=p_ofs.y+y && p_click_pos.y<=p_ofs.y+y+lh && p_click_pos.x>=p_ofs.x+wofs && p_click_pos.x<p_ofs.x+wofs+m_width) {\
- if (r_outside) *r_outside=false; \
- *r_click_item=it;\
- *r_click_char=rchar;\
- return;\
- }\
- wofs+=m_width;\
-}
+#define ADVANCE(m_width) \
+ { \
+ if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh && p_click_pos.x >= p_ofs.x + wofs && p_click_pos.x < p_ofs.x + wofs + m_width) { \
+ if (r_outside) *r_outside = false; \
+ *r_click_item = it; \
+ *r_click_char = rchar; \
+ return; \
+ } \
+ wofs += m_width; \
+ }
-#define CHECK_HEIGHT( m_height ) \
-if (m_height > line_height) {\
- line_height=m_height;\
-}
+#define CHECK_HEIGHT(m_height) \
+ if (m_height > line_height) { \
+ line_height = m_height; \
+ }
Color selection_fg;
Color selection_bg;
- if (p_mode==PROCESS_DRAW) {
-
+ if (p_mode == PROCESS_DRAW) {
selection_fg = get_color("font_color_selected");
selection_bg = get_color("selection_color");
}
- int rchar=0;
- int lh=0;
+ int rchar = 0;
+ int lh = 0;
while (it) {
- switch(it->type) {
+ switch (it->type) {
case ITEM_TEXT: {
- ItemText *text = static_cast<ItemText*>(it);
+ ItemText *text = static_cast<ItemText *>(it);
- Ref<Font> font=_find_font(it);
+ Ref<Font> font = _find_font(it);
if (font.is_null())
- font=p_base_font;
+ font = p_base_font;
const CharType *c = text->text.c_str();
- const CharType *cf=c;
- int fh=font->get_height();
+ const CharType *cf = c;
+ int fh = font->get_height();
int ascent = font->get_ascent();
Color color;
- bool underline=false;
+ bool underline = false;
- if (p_mode==PROCESS_DRAW) {
- color=_find_color(text,p_base_color);
- underline=_find_underline(text);
- if (_find_meta(text,&meta)) {
+ if (p_mode == PROCESS_DRAW) {
+ color = _find_color(text, p_base_color);
+ underline = _find_underline(text);
+ if (_find_meta(text, &meta)) {
- underline=true;
+ underline = true;
}
-
- } else if (p_mode==PROCESS_CACHE) {
- l.char_count+=text->text.length();
-
+ } else if (p_mode == PROCESS_CACHE) {
+ l.char_count += text->text.length();
}
- rchar=0;
+ rchar = 0;
- while(*c) {
+ while (*c) {
- int end=0;
- int w=0;
- int fw=0;
+ int end = 0;
+ int w = 0;
+ int fw = 0;
- lh=0;
- if (p_mode!=PROCESS_CACHE) {
- lh=line<l.height_caches.size()?l.height_caches[line]:1;
+ lh = 0;
+ if (p_mode != PROCESS_CACHE) {
+ lh = line < l.height_caches.size() ? l.height_caches[line] : 1;
}
- while (c[end]!=0 && !(end && c[end-1]==' ' && c[end]!=' ')) {
+ while (c[end] != 0 && !(end && c[end - 1] == ' ' && c[end] != ' ')) {
- int cw = font->get_char_size(c[end],c[end+1]).width;
- if (c[end]=='\t') {
- cw=tab_size*font->get_char_size(' ').width;
+ int cw = font->get_char_size(c[end], c[end + 1]).width;
+ if (c[end] == '\t') {
+ cw = tab_size * font->get_char_size(' ').width;
}
- if (end>0 && w+cw+begin > p_width ) {
+ if (end > 0 && w + cw + begin > p_width) {
break; //don't allow lines longer than assigned width
}
- w+=cw;
- fw+=cw;
+ w += cw;
+ fw += cw;
end++;
}
ENSURE_WIDTH(w);
- if (end && c[end-1]==' ') {
- if (p_mode==PROCESS_CACHE) {
- spaces_size+=font->get_char_size(' ').width;
- } else if (align==ALIGN_FILL) {
- int ln = MIN(l.offset_caches.size()-1,line);
+ if (end && c[end - 1] == ' ') {
+ if (p_mode == PROCESS_CACHE) {
+ spaces_size += font->get_char_size(' ').width;
+ } else if (align == ALIGN_FILL) {
+ int ln = MIN(l.offset_caches.size() - 1, line);
if (l.space_caches[ln]) {
align_ofs = spaces * l.offset_caches[ln] / l.space_caches[ln];
}
}
spaces++;
-
}
-
{
- int ofs=0;
+ int ofs = 0;
- for(int i=0;i<end;i++) {
- int pofs=wofs+ofs;
+ for (int i = 0; i < end; i++) {
+ int pofs = wofs + ofs;
-
- if (p_mode==PROCESS_POINTER && r_click_char && p_click_pos.y>=p_ofs.y+y && p_click_pos.y<=p_ofs.y+y+lh) {
+ if (p_mode == PROCESS_POINTER && r_click_char && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh) {
//int o = (wofs+w)-p_click_pos.x;
+ int cw = font->get_char_size(c[i], c[i + 1]).x;
- int cw=font->get_char_size(c[i],c[i+1]).x;
-
- if (c[i]=='\t') {
- cw=tab_size*font->get_char_size(' ').width;
+ if (c[i] == '\t') {
+ cw = tab_size * font->get_char_size(' ').width;
}
+ if (p_click_pos.x - cw / 2 > p_ofs.x + align_ofs + pofs) {
- if (p_click_pos.x-cw/2>p_ofs.x+align_ofs+pofs) {
-
- rchar=int((&c[i])-cf);
+ rchar = int((&c[i]) - cf);
}
+ ofs += cw;
+ } else if (p_mode == PROCESS_DRAW) {
- ofs+=cw;
- } else if (p_mode==PROCESS_DRAW) {
-
- bool selected=false;
+ bool selected = false;
if (selection.active) {
- int cofs = (&c[i])-cf;
- if ((text->index > selection.from->index || (text->index == selection.from->index && cofs >=selection.from_char)) && (text->index < selection.to->index || (text->index == selection.to->index && cofs <=selection.to_char))) {
- selected=true;
+ int cofs = (&c[i]) - cf;
+ if ((text->index > selection.from->index || (text->index == selection.from->index && cofs >= selection.from_char)) && (text->index < selection.to->index || (text->index == selection.to->index && cofs <= selection.to_char))) {
+ selected = true;
}
}
- int cw=0;
+ int cw = 0;
- bool visible = visible_characters<0 || p_char_count<visible_characters;
- if (c[i]=='\t')
- visible=false;
+ bool visible = visible_characters < 0 || p_char_count < visible_characters;
+ if (c[i] == '\t')
+ visible = false;
if (selected) {
- cw = font->get_char_size(c[i],c[i+1]).x;
- draw_rect(Rect2(p_ofs.x+pofs,p_ofs.y+y,cw,lh),selection_bg);
+ cw = font->get_char_size(c[i], c[i + 1]).x;
+ draw_rect(Rect2(p_ofs.x + pofs, p_ofs.y + y, cw, lh), selection_bg);
if (visible)
- font->draw_char(ci,p_ofs+Point2(align_ofs+pofs,y+lh-(fh-ascent)),c[i],c[i+1],selection_fg);
+ font->draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - (fh - ascent)), c[i], c[i + 1], selection_fg);
} else {
if (visible)
- cw=font->draw_char(ci,p_ofs+Point2(align_ofs+pofs,y+lh-(fh-ascent)),c[i],c[i+1],color);
+ cw = font->draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - (fh - ascent)), c[i], c[i + 1], color);
}
p_char_count++;
- if (c[i]=='\t') {
- cw=tab_size*font->get_char_size(' ').width;
+ if (c[i] == '\t') {
+ cw = tab_size * font->get_char_size(' ').width;
}
-
if (underline) {
- Color uc=color;
- uc.a*=0.5;
- int uy = y+lh-fh+ascent+2;
- VS::get_singleton()->canvas_item_add_line(ci,p_ofs+Point2(align_ofs+pofs,uy),p_ofs+Point2(align_ofs+pofs+cw,uy),uc);
+ Color uc = color;
+ uc.a *= 0.5;
+ int uy = y + lh - fh + ascent + 2;
+ VS::get_singleton()->canvas_item_add_line(ci, p_ofs + Point2(align_ofs + pofs, uy), p_ofs + Point2(align_ofs + pofs + cw, uy), uc);
}
- ofs+=cw;
+ ofs += cw;
}
-
}
}
-
ADVANCE(fw);
CHECK_HEIGHT(fh); //must be done somewhere
- c=&c[end];
+ c = &c[end];
}
-
} break;
case ITEM_IMAGE: {
- lh=0;
- if (p_mode!=PROCESS_CACHE)
- lh = line<l.height_caches.size()?l.height_caches[line]:1;
+ lh = 0;
+ if (p_mode != PROCESS_CACHE)
+ lh = line < l.height_caches.size() ? l.height_caches[line] : 1;
else
- l.char_count+=1; //images count as chars too
+ l.char_count += 1; //images count as chars too
- ItemImage *img = static_cast<ItemImage*>(it);
+ ItemImage *img = static_cast<ItemImage *>(it);
- Ref<Font> font=_find_font(it);
+ Ref<Font> font = _find_font(it);
if (font.is_null())
- font=p_base_font;
+ font = p_base_font;
- if (p_mode==PROCESS_POINTER && r_click_char)
- *r_click_char=0;
+ if (p_mode == PROCESS_POINTER && r_click_char)
+ *r_click_char = 0;
- ENSURE_WIDTH( img->image->get_width() );
+ ENSURE_WIDTH(img->image->get_width());
- bool visible = visible_characters<0 || p_char_count<visible_characters;
+ bool visible = visible_characters < 0 || p_char_count < visible_characters;
- if (p_mode==PROCESS_DRAW && visible) {
- img->image->draw(ci,p_ofs+Point2(align_ofs+wofs,y+lh-font->get_descent()-img->image->get_height()));
+ if (p_mode == PROCESS_DRAW && visible) {
+ img->image->draw(ci, p_ofs + Point2(align_ofs + wofs, y + lh - font->get_descent() - img->image->get_height()));
}
p_char_count++;
- ADVANCE( img->image->get_width() );
- CHECK_HEIGHT( (img->image->get_height()+font->get_descent()) );
+ ADVANCE(img->image->get_width());
+ CHECK_HEIGHT((img->image->get_height() + font->get_descent()));
} break;
case ITEM_NEWLINE: {
-
- lh=0;
- if (p_mode!=PROCESS_CACHE)
- lh = line<l.height_caches.size()?l.height_caches[line]:1;
+ lh = 0;
+ if (p_mode != PROCESS_CACHE)
+ lh = line < l.height_caches.size() ? l.height_caches[line] : 1;
} break;
case ITEM_TABLE: {
- lh=0;
- ItemTable *table = static_cast<ItemTable*>(it);
- int hseparation=get_constant("table_hseparation");
- int vseparation=get_constant("table_vseparation");
- Color ccolor = _find_color(table,p_base_color);
- Vector2 draw_ofs = Point2(wofs,y);
+ lh = 0;
+ ItemTable *table = static_cast<ItemTable *>(it);
+ int hseparation = get_constant("table_hseparation");
+ int vseparation = get_constant("table_vseparation");
+ Color ccolor = _find_color(table, p_base_color);
+ Vector2 draw_ofs = Point2(wofs, y);
- if (p_mode==PROCESS_CACHE) {
+ if (p_mode == PROCESS_CACHE) {
- int idx=0;
+ int idx = 0;
//set minimums to zero
- for(int i=0;i<table->columns.size();i++) {
- table->columns[i].min_width=0;
- table->columns[i].width=0;
+ for (int i = 0; i < table->columns.size(); i++) {
+ table->columns[i].min_width = 0;
+ table->columns[i].width = 0;
}
//compute minimum width for each cell
- for (List<Item*>::Element *E=table->subitems.front();E;E=E->next()) {
- ERR_CONTINUE(E->get()->type!=ITEM_FRAME); //children should all be frames
- ItemFrame *frame = static_cast<ItemFrame*>(E->get());
+ for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) {
+ ERR_CONTINUE(E->get()->type != ITEM_FRAME); //children should all be frames
+ ItemFrame *frame = static_cast<ItemFrame *>(E->get());
int column = idx % table->columns.size();
- int ly=0;
-
+ int ly = 0;
- for(int i=0;i<frame->lines.size();i++) {
+ for (int i = 0; i < frame->lines.size(); i++) {
- _process_line(frame,Point2(),ly,p_width,i,PROCESS_CACHE,cfont,Color());
- table->columns[column].min_width=MAX( table->columns[i].min_width, frame->lines[i].minimum_width );
+ _process_line(frame, Point2(), ly, p_width, i, PROCESS_CACHE, cfont, Color());
+ table->columns[column].min_width = MAX(table->columns[i].min_width, frame->lines[i].minimum_width);
}
idx++;
}
//compute available width and total radio (for expanders)
+ int total_ratio = 0;
+ int available_width = p_width - hseparation * (table->columns.size() - 1);
+ table->total_width = hseparation;
- int total_ratio=0;
- int available_width=p_width - hseparation * (table->columns.size() -1);
- table->total_width=hseparation;
-
- for(int i=0;i<table->columns.size();i++) {
- available_width-=table->columns[i].min_width;
+ for (int i = 0; i < table->columns.size(); i++) {
+ available_width -= table->columns[i].min_width;
if (table->columns[i].expand)
- total_ratio+=table->columns[i].expand_ratio;
+ total_ratio += table->columns[i].expand_ratio;
}
//assign actual widths
- for(int i=0;i<table->columns.size();i++) {
+ for (int i = 0; i < table->columns.size(); i++) {
table->columns[i].width = table->columns[i].min_width;
if (table->columns[i].expand)
- table->columns[i].width+=table->columns[i].expand_ratio*available_width/total_ratio;
- table->total_width+=table->columns[i].width+hseparation;
+ table->columns[i].width += table->columns[i].expand_ratio * available_width / total_ratio;
+ table->total_width += table->columns[i].width + hseparation;
}
//compute caches properly again with the right width
- idx=0;
- for (List<Item*>::Element *E=table->subitems.front();E;E=E->next()) {
- ERR_CONTINUE(E->get()->type!=ITEM_FRAME); //children should all be frames
- ItemFrame *frame = static_cast<ItemFrame*>(E->get());
+ idx = 0;
+ for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) {
+ ERR_CONTINUE(E->get()->type != ITEM_FRAME); //children should all be frames
+ ItemFrame *frame = static_cast<ItemFrame *>(E->get());
int column = idx % table->columns.size();
+ for (int i = 0; i < frame->lines.size(); i++) {
- for(int i=0;i<frame->lines.size();i++) {
-
- int ly=0;
- _process_line(frame,Point2(),ly,table->columns[column].width,i,PROCESS_CACHE,cfont,Color());
- frame->lines[i].height_cache=ly; //actual height
- frame->lines[i].height_accum_cache=ly; //actual height
+ int ly = 0;
+ _process_line(frame, Point2(), ly, table->columns[column].width, i, PROCESS_CACHE, cfont, Color());
+ frame->lines[i].height_cache = ly; //actual height
+ frame->lines[i].height_accum_cache = ly; //actual height
}
idx++;
}
-
}
+ Point2 offset(align_ofs + hseparation, vseparation);
-
- Point2 offset(align_ofs+hseparation,vseparation);
-
- int row_height=0;
+ int row_height = 0;
//draw using computed caches
- int idx=0;
- for (List<Item*>::Element *E=table->subitems.front();E;E=E->next()) {
- ERR_CONTINUE(E->get()->type!=ITEM_FRAME); //children should all be frames
- ItemFrame *frame = static_cast<ItemFrame*>(E->get());
+ int idx = 0;
+ for (List<Item *>::Element *E = table->subitems.front(); E; E = E->next()) {
+ ERR_CONTINUE(E->get()->type != ITEM_FRAME); //children should all be frames
+ ItemFrame *frame = static_cast<ItemFrame *>(E->get());
int column = idx % table->columns.size();
- int ly=0;
- int yofs=0;
+ int ly = 0;
+ int yofs = 0;
+ int lines_h = frame->lines[frame->lines.size() - 1].height_accum_cache - (frame->lines[0].height_accum_cache - frame->lines[0].height_cache);
+ int lines_ofs = p_ofs.y + offset.y + draw_ofs.y;
- int lines_h = frame->lines[frame->lines.size()-1].height_accum_cache - (frame->lines[0].height_accum_cache - frame->lines[0].height_cache);
- int lines_ofs = p_ofs.y+offset.y+draw_ofs.y;
-
- bool visible = lines_ofs < get_size().height && lines_ofs+lines_h >=0;
-
- for(int i=0;i<frame->lines.size();i++) {
+ bool visible = lines_ofs < get_size().height && lines_ofs + lines_h >= 0;
+ for (int i = 0; i < frame->lines.size(); i++) {
if (visible) {
- if (p_mode==PROCESS_DRAW) {
- _process_line(frame,p_ofs+offset+draw_ofs+Vector2(0,yofs),ly,table->columns[column].width,i,PROCESS_DRAW,cfont,ccolor);
- } else if (p_mode==PROCESS_POINTER) {
- _process_line(frame,p_ofs+offset+draw_ofs+Vector2(0,yofs),ly,table->columns[column].width,i,PROCESS_POINTER,cfont,ccolor,p_click_pos,r_click_item,r_click_char,r_outside);
+ if (p_mode == PROCESS_DRAW) {
+ _process_line(frame, p_ofs + offset + draw_ofs + Vector2(0, yofs), ly, table->columns[column].width, i, PROCESS_DRAW, cfont, ccolor);
+ } else if (p_mode == PROCESS_POINTER) {
+ _process_line(frame, p_ofs + offset + draw_ofs + Vector2(0, yofs), ly, table->columns[column].width, i, PROCESS_POINTER, cfont, ccolor, p_click_pos, r_click_item, r_click_char, r_outside);
}
}
- yofs+=frame->lines[i].height_cache;
- if (p_mode==PROCESS_CACHE) {
- frame->lines[i].height_accum_cache=offset.y+draw_ofs.y+frame->lines[i].height_cache;
+ yofs += frame->lines[i].height_cache;
+ if (p_mode == PROCESS_CACHE) {
+ frame->lines[i].height_accum_cache = offset.y + draw_ofs.y + frame->lines[i].height_cache;
}
-
}
- row_height=MAX(yofs,row_height);
- offset.x+=table->columns[column].width+hseparation;
+ row_height = MAX(yofs, row_height);
+ offset.x += table->columns[column].width + hseparation;
- if (column==table->columns.size()-1) {
+ if (column == table->columns.size() - 1) {
- offset.y+=row_height+vseparation;
- offset.x=hseparation;
- row_height=0;
+ offset.y += row_height + vseparation;
+ offset.x = hseparation;
+ row_height = 0;
}
idx++;
}
int total_height = offset.y;
if (row_height) {
- total_height=row_height+vseparation;
+ total_height = row_height + vseparation;
}
-
-
- ADVANCE( table->total_width );
- CHECK_HEIGHT( total_height );
+ ADVANCE(table->total_width);
+ CHECK_HEIGHT(total_height);
} break;
default: {}
-
}
-
Item *itp = it;
it = _get_next_item(it);
- if (p_mode == PROCESS_POINTER && r_click_item && itp && !it && p_click_pos.y>p_ofs.y+y+lh) {
+ if (p_mode == PROCESS_POINTER && r_click_item && itp && !it && p_click_pos.y > p_ofs.y + y + lh) {
//at the end of all, return this
- if (r_outside) *r_outside=true;
- *r_click_item=itp;
- *r_click_char=rchar;
+ if (r_outside) *r_outside = true;
+ *r_click_item = itp;
+ *r_click_char = rchar;
return;
}
- if (it && (p_line+1 < p_frame->lines.size()) && p_frame->lines[p_line+1].from==it) {
+ if (it && (p_line + 1 < p_frame->lines.size()) && p_frame->lines[p_line + 1].from == it) {
- if (p_mode==PROCESS_POINTER && r_click_item && p_click_pos.y>=p_ofs.y+y && p_click_pos.y<=p_ofs.y+y+lh) {
+ if (p_mode == PROCESS_POINTER && r_click_item && p_click_pos.y >= p_ofs.y + y && p_click_pos.y <= p_ofs.y + y + lh) {
//went to next line, but pointer was on the previous one
- if (r_outside) *r_outside=true;
- *r_click_item=itp;
- *r_click_char=rchar;
+ if (r_outside) *r_outside = true;
+ *r_click_item = itp;
+ *r_click_char = rchar;
return;
}
@@ -602,7 +563,6 @@ if (m_height > line_height) {\
#undef ENSURE_WIDTH
#undef ADVANCE
#undef CHECK_HEIGHT
-
}
void RichTextLabel::_scroll_changed(double) {
@@ -610,44 +570,40 @@ void RichTextLabel::_scroll_changed(double) {
if (updating_scroll)
return;
- if (scroll_follow && vscroll->get_val()>=(vscroll->get_max()-vscroll->get_page()))
- scroll_following=true;
+ if (scroll_follow && vscroll->get_val() >= (vscroll->get_max() - vscroll->get_page()))
+ scroll_following = true;
else
- scroll_following=false;
+ scroll_following = false;
update();
-
}
void RichTextLabel::_update_scroll() {
- int total_height=0;
+ int total_height = 0;
if (main->lines.size())
- total_height=main->lines[main->lines.size()-1].height_accum_cache;
+ total_height = main->lines[main->lines.size() - 1].height_accum_cache;
bool exceeds = total_height > get_size().height && scroll_active;
-
- if (exceeds!=scroll_visible) {
+ if (exceeds != scroll_visible) {
if (exceeds) {
- scroll_visible=true;
- main->first_invalid_line=0;
- scroll_w=vscroll->get_combined_minimum_size().width;
+ scroll_visible = true;
+ main->first_invalid_line = 0;
+ scroll_w = vscroll->get_combined_minimum_size().width;
vscroll->show();
- vscroll->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_END,scroll_w);
+ vscroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, scroll_w);
_validate_line_caches(main);
} else {
- scroll_visible=false;
+ scroll_visible = false;
vscroll->hide();
- scroll_w=0;
+ scroll_w = 0;
_validate_line_caches(main);
}
-
}
-
}
void RichTextLabel::_notification(int p_what) {
@@ -656,7 +612,7 @@ void RichTextLabel::_notification(int p_what) {
case NOTIFICATION_RESIZED: {
- main->first_invalid_line=0; //invalidate ALL
+ main->first_invalid_line = 0; //invalidate ALL
update();
} break;
@@ -665,7 +621,7 @@ void RichTextLabel::_notification(int p_what) {
if (bbcode != "")
set_bbcode(bbcode);
- main->first_invalid_line=0; //invalidate ALL
+ main->first_invalid_line = 0; //invalidate ALL
update();
} break;
@@ -683,16 +639,15 @@ void RichTextLabel::_notification(int p_what) {
_validate_line_caches(main);
_update_scroll();
-
- RID ci=get_canvas_item();
+ RID ci = get_canvas_item();
Size2 size = get_size();
- VisualServer::get_singleton()->canvas_item_set_clip(ci,true);
+ VisualServer::get_singleton()->canvas_item_set_clip(ci, true);
if (has_focus()) {
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,true);
- draw_style_box(get_stylebox("focus"),Rect2(Point2(),size));
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,false);
+ VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true);
+ draw_style_box(get_stylebox("focus"), Rect2(Point2(), size));
+ VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, false);
}
int ofs = vscroll->get_val();
@@ -701,36 +656,35 @@ void RichTextLabel::_notification(int p_what) {
int from_line = 0;
int total_chars = 0;
- while (from_line<main->lines.size()) {
+ while (from_line < main->lines.size()) {
- if (main->lines[from_line].height_accum_cache>=ofs)
+ if (main->lines[from_line].height_accum_cache >= ofs)
break;
from_line++;
- total_chars+=main->lines[from_line].char_count;
+ total_chars += main->lines[from_line].char_count;
}
- if (from_line>=main->lines.size())
+ if (from_line >= main->lines.size())
break; //nothing to draw
int y = (main->lines[from_line].height_accum_cache - main->lines[from_line].height_cache) - ofs;
- Ref<Font> base_font=get_font("normal_font");
- Color base_color=get_color("default_color");
+ Ref<Font> base_font = get_font("normal_font");
+ Color base_color = get_color("default_color");
- while (y<size.height && from_line<main->lines.size()) {
+ while (y < size.height && from_line < main->lines.size()) {
- _process_line(main,Point2(),y,size.width-scroll_w,from_line,PROCESS_DRAW,base_font,base_color,Point2i(),NULL,NULL,NULL,total_chars);
- total_chars+=main->lines[from_line].char_count;
+ _process_line(main, Point2(), y, size.width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars);
+ total_chars += main->lines[from_line].char_count;
from_line++;
}
}
}
}
-
-void RichTextLabel::_find_click(ItemFrame* p_frame,const Point2i& p_click,Item **r_click_item,int *r_click_char,bool *r_outside) {
+void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item, int *r_click_char, bool *r_outside) {
if (r_click_item)
- *r_click_item=NULL;
+ *r_click_item = NULL;
Size2 size = get_size();
@@ -739,148 +693,137 @@ void RichTextLabel::_find_click(ItemFrame* p_frame,const Point2i& p_click,Item *
//todo, change to binary search
int from_line = 0;
- while (from_line<p_frame->lines.size()) {
+ while (from_line < p_frame->lines.size()) {
- if (p_frame->lines[from_line].height_accum_cache>=ofs)
+ if (p_frame->lines[from_line].height_accum_cache >= ofs)
break;
from_line++;
}
-
- if (from_line>=p_frame->lines.size())
+ if (from_line >= p_frame->lines.size())
return;
-
int y = (p_frame->lines[from_line].height_accum_cache - p_frame->lines[from_line].height_cache) - ofs;
- Ref<Font> base_font=get_font("normal_font");
- Color base_color=get_color("default_color");
-
+ Ref<Font> base_font = get_font("normal_font");
+ Color base_color = get_color("default_color");
- while (y<size.height && from_line<p_frame->lines.size()) {
+ while (y < size.height && from_line < p_frame->lines.size()) {
- _process_line(p_frame,Point2(),y,size.width-scroll_w,from_line,PROCESS_POINTER,base_font,base_color,p_click,r_click_item,r_click_char,r_outside);
+ _process_line(p_frame, Point2(), y, size.width - scroll_w, from_line, PROCESS_POINTER, base_font, base_color, p_click, r_click_item, r_click_char, r_outside);
if (r_click_item && *r_click_item)
return;
from_line++;
}
-
-
}
-
-Control::CursorShape RichTextLabel::get_cursor_shape(const Point2& p_pos) const {
+Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const {
if (!underline_meta || selection.click)
return CURSOR_ARROW;
- if (main->first_invalid_line<main->lines.size())
+ if (main->first_invalid_line < main->lines.size())
return CURSOR_ARROW; //invalid
- int line=0;
- Item *item=NULL;
-
- ((RichTextLabel*)(this))->_find_click(main,p_pos,&item,&line);
+ int line = 0;
+ Item *item = NULL;
+ ((RichTextLabel *)(this))->_find_click(main, p_pos, &item, &line);
- if (item && ((RichTextLabel*)(this))->_find_meta(item,NULL))
+ if (item && ((RichTextLabel *)(this))->_find_meta(item, NULL))
return CURSOR_POINTING_HAND;
return CURSOR_ARROW;
}
-
void RichTextLabel::_input_event(InputEvent p_event) {
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- if (main->first_invalid_line<main->lines.size())
+ if (main->first_invalid_line < main->lines.size())
return;
- const InputEventMouseButton& b = p_event.mouse_button;
+ const InputEventMouseButton &b = p_event.mouse_button;
- if (b.button_index==BUTTON_LEFT) {
+ if (b.button_index == BUTTON_LEFT) {
if (true) {
-
if (b.pressed && !b.doubleclick) {
- int line=0;
- Item *item=NULL;
+ int line = 0;
+ Item *item = NULL;
bool outside;
- _find_click(main,Point2i(b.x,b.y),&item,&line,&outside);
+ _find_click(main, Point2i(b.x, b.y), &item, &line, &outside);
if (item) {
Variant meta;
- if (!outside && _find_meta(item,&meta)) {
+ if (!outside && _find_meta(item, &meta)) {
//meta clicked
- emit_signal("meta_clicked",meta);
+ emit_signal("meta_clicked", meta);
} else if (selection.enabled) {
- selection.click=item;
- selection.click_char=line;
-
+ selection.click = item;
+ selection.click_char = line;
}
-
}
} else if (!b.pressed) {
- selection.click=NULL;
+ selection.click = NULL;
}
}
}
- if (b.button_index==BUTTON_WHEEL_UP) {
+ if (b.button_index == BUTTON_WHEEL_UP) {
if (scroll_active)
- vscroll->set_val( vscroll->get_val()-vscroll->get_page()/8 );
+ vscroll->set_val(vscroll->get_val() - vscroll->get_page() / 8);
}
- if (b.button_index==BUTTON_WHEEL_DOWN) {
+ if (b.button_index == BUTTON_WHEEL_DOWN) {
if (scroll_active)
- vscroll->set_val( vscroll->get_val()+vscroll->get_page()/8 );
+ vscroll->set_val(vscroll->get_val() + vscroll->get_page() / 8);
}
} break;
case InputEvent::KEY: {
- const InputEventKey &k=p_event.key;
+ const InputEventKey &k = p_event.key;
if (k.pressed && !k.mod.alt && !k.mod.shift && !k.mod.meta) {
- bool handled=true;
- switch(k.scancode) {
+ bool handled = true;
+ switch (k.scancode) {
case KEY_PAGEUP: {
if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() - vscroll->get_page() );
+ vscroll->set_val(vscroll->get_val() - vscroll->get_page());
} break;
case KEY_PAGEDOWN: {
if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() + vscroll->get_page() );
+ vscroll->set_val(vscroll->get_val() + vscroll->get_page());
} break;
case KEY_UP: {
if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() - get_font("normal_font")->get_height() );
+ vscroll->set_val(vscroll->get_val() - get_font("normal_font")->get_height());
} break;
case KEY_DOWN: {
if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() + get_font("normal_font")->get_height() );
+ vscroll->set_val(vscroll->get_val() + get_font("normal_font")->get_height());
} break;
case KEY_HOME: {
if (vscroll->is_visible())
- vscroll->set_val( 0 );
+ vscroll->set_val(0);
} break;
case KEY_END: {
if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_max() );
+ vscroll->set_val(vscroll->get_max());
} break;
case KEY_INSERT:
case KEY_C: {
@@ -888,14 +831,13 @@ void RichTextLabel::_input_event(InputEvent p_event) {
if (k.mod.command) {
selection_copy();
} else {
- handled=false;
+ handled = false;
}
} break;
- default: handled=false;
+ default: handled = false;
}
-
if (handled)
accept_event();
}
@@ -903,138 +845,131 @@ void RichTextLabel::_input_event(InputEvent p_event) {
} break;
case InputEvent::MOUSE_MOTION: {
- if (main->first_invalid_line<main->lines.size())
+ if (main->first_invalid_line < main->lines.size())
return;
- const InputEventMouseMotion& m = p_event.mouse_motion;
+ const InputEventMouseMotion &m = p_event.mouse_motion;
if (selection.click) {
- int line=0;
- Item *item=NULL;
- _find_click(main,Point2i(m.x,m.y),&item,&line);
+ int line = 0;
+ Item *item = NULL;
+ _find_click(main, Point2i(m.x, m.y), &item, &line);
if (!item)
return; // do not update
+ selection.from = selection.click;
+ selection.from_char = selection.click_char;
- selection.from=selection.click;
- selection.from_char=selection.click_char;
-
- selection.to=item;
- selection.to_char=line;
+ selection.to = item;
+ selection.to_char = line;
- bool swap=false;
- if (selection.from->index > selection.to->index )
- swap=true;
+ bool swap = false;
+ if (selection.from->index > selection.to->index)
+ swap = true;
else if (selection.from->index == selection.to->index) {
if (selection.from_char > selection.to_char)
- swap=true;
+ swap = true;
else if (selection.from_char == selection.to_char) {
- selection.active=false;
+ selection.active = false;
return;
}
}
if (swap) {
- SWAP( selection.from, selection.to );
- SWAP( selection.from_char, selection.to_char );
+ SWAP(selection.from, selection.to);
+ SWAP(selection.from_char, selection.to_char);
}
- selection.active=true;
+ selection.active = true;
update();
-
}
} break;
}
-
}
Ref<Font> RichTextLabel::_find_font(Item *p_item) {
- Item *fontitem=p_item;
+ Item *fontitem = p_item;
- while(fontitem) {
+ while (fontitem) {
- if (fontitem->type==ITEM_FONT) {
+ if (fontitem->type == ITEM_FONT) {
- ItemFont *fi = static_cast<ItemFont*>(fontitem);
+ ItemFont *fi = static_cast<ItemFont *>(fontitem);
return fi->font;
}
- fontitem=fontitem->parent;
+ fontitem = fontitem->parent;
}
return Ref<Font>();
}
-int RichTextLabel::_find_margin(Item *p_item,const Ref<Font>& p_base_font) {
+int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font) {
- Item *item=p_item;
+ Item *item = p_item;
- int margin=0;
+ int margin = 0;
- while(item) {
+ while (item) {
- if (item->type==ITEM_INDENT) {
+ if (item->type == ITEM_INDENT) {
- Ref<Font> font=_find_font(item);
+ Ref<Font> font = _find_font(item);
if (font.is_null())
- font=p_base_font;
+ font = p_base_font;
- ItemIndent *indent = static_cast<ItemIndent*>(item);
+ ItemIndent *indent = static_cast<ItemIndent *>(item);
- margin+=indent->level*tab_size*font->get_char_size(' ').width;
+ margin += indent->level * tab_size * font->get_char_size(' ').width;
- } else if (item->type==ITEM_LIST) {
+ } else if (item->type == ITEM_LIST) {
- Ref<Font> font=_find_font(item);
+ Ref<Font> font = _find_font(item);
if (font.is_null())
- font=p_base_font;
-
+ font = p_base_font;
}
- item=item->parent;
+ item = item->parent;
}
return margin;
}
-
RichTextLabel::Align RichTextLabel::_find_align(Item *p_item) {
- Item *item=p_item;
+ Item *item = p_item;
- while(item) {
+ while (item) {
- if (item->type==ITEM_ALIGN) {
+ if (item->type == ITEM_ALIGN) {
- ItemAlign *align = static_cast<ItemAlign*>(item);
+ ItemAlign *align = static_cast<ItemAlign *>(item);
return align->align;
-
}
- item=item->parent;
+ item = item->parent;
}
return default_align;
}
-Color RichTextLabel::_find_color(Item *p_item,const Color& p_default_color) {
+Color RichTextLabel::_find_color(Item *p_item, const Color &p_default_color) {
- Item *item=p_item;
+ Item *item = p_item;
- while(item) {
+ while (item) {
- if (item->type==ITEM_COLOR) {
+ if (item->type == ITEM_COLOR) {
- ItemColor *color = static_cast<ItemColor*>(item);
+ ItemColor *color = static_cast<ItemColor *>(item);
return color->color;
-
}
- item=item->parent;
+ item = item->parent;
}
return p_default_color;
@@ -1042,182 +977,165 @@ Color RichTextLabel::_find_color(Item *p_item,const Color& p_default_color) {
bool RichTextLabel::_find_underline(Item *p_item) {
- Item *item=p_item;
+ Item *item = p_item;
- while(item) {
+ while (item) {
- if (item->type==ITEM_UNDERLINE) {
+ if (item->type == ITEM_UNDERLINE) {
return true;
-
}
- item=item->parent;
+ item = item->parent;
}
return false;
}
-bool RichTextLabel::_find_meta(Item *p_item,Variant *r_meta) {
+bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta) {
- Item *item=p_item;
+ Item *item = p_item;
- while(item) {
+ while (item) {
- if (item->type==ITEM_META) {
+ if (item->type == ITEM_META) {
- ItemMeta *meta = static_cast<ItemMeta*>(item);
+ ItemMeta *meta = static_cast<ItemMeta *>(item);
if (r_meta)
- *r_meta=meta->meta;
+ *r_meta = meta->meta;
return true;
-
}
- item=item->parent;
+ item = item->parent;
}
return false;
-
}
-void RichTextLabel::_validate_line_caches(ItemFrame* p_frame) {
+void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
- if (p_frame->first_invalid_line==p_frame->lines.size())
+ if (p_frame->first_invalid_line == p_frame->lines.size())
return;
//validate invalid lines!s
Size2 size = get_size();
- Ref<Font> base_font=get_font("normal_font");
-
- for(int i=p_frame->first_invalid_line;i<p_frame->lines.size();i++) {
-
- int y=0;
- _process_line(p_frame,Point2(),y,size.width-scroll_w,i,PROCESS_CACHE,base_font,Color());
- p_frame->lines[i].height_cache=y;
- p_frame->lines[i].height_accum_cache=y;
+ Ref<Font> base_font = get_font("normal_font");
- if (i>0)
- p_frame->lines[i].height_accum_cache+=p_frame->lines[i-1].height_accum_cache;
+ for (int i = p_frame->first_invalid_line; i < p_frame->lines.size(); i++) {
+ int y = 0;
+ _process_line(p_frame, Point2(), y, size.width - scroll_w, i, PROCESS_CACHE, base_font, Color());
+ p_frame->lines[i].height_cache = y;
+ p_frame->lines[i].height_accum_cache = y;
+ if (i > 0)
+ p_frame->lines[i].height_accum_cache += p_frame->lines[i - 1].height_accum_cache;
}
- int total_height=0;
+ int total_height = 0;
if (p_frame->lines.size())
- total_height=p_frame->lines[p_frame->lines.size()-1].height_accum_cache;
+ total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache;
- main->first_invalid_line=p_frame->lines.size();
+ main->first_invalid_line = p_frame->lines.size();
- updating_scroll=true;
+ updating_scroll = true;
vscroll->set_max(total_height);
vscroll->set_page(size.height);
if (scroll_follow && scroll_following)
- vscroll->set_val(total_height-size.height);
-
- updating_scroll=false;
+ vscroll->set_val(total_height - size.height);
+ updating_scroll = false;
}
+void RichTextLabel::_invalidate_current_line(ItemFrame *p_frame) {
-void RichTextLabel::_invalidate_current_line(ItemFrame* p_frame) {
-
- if (p_frame->lines.size()-1 <= p_frame->first_invalid_line) {
+ if (p_frame->lines.size() - 1 <= p_frame->first_invalid_line) {
- p_frame->first_invalid_line=p_frame->lines.size()-1;
+ p_frame->first_invalid_line = p_frame->lines.size() - 1;
update();
}
}
-void RichTextLabel::add_text(const String& p_text) {
+void RichTextLabel::add_text(const String &p_text) {
- if (current->type==ITEM_TABLE)
+ if (current->type == ITEM_TABLE)
return; //can't add anything here
- int pos=0;
+ int pos = 0;
- while (pos<p_text.length()) {
+ while (pos < p_text.length()) {
- int end=p_text.find("\n",pos);
+ int end = p_text.find("\n", pos);
String line;
- bool eol=false;
- if (end==-1) {
+ bool eol = false;
+ if (end == -1) {
- end=p_text.length();
+ end = p_text.length();
} else {
- eol=true;
+ eol = true;
}
- if (pos==0 && end==p_text.length())
- line=p_text;
+ if (pos == 0 && end == p_text.length())
+ line = p_text;
else
- line=p_text.substr(pos,end-pos);
+ line = p_text.substr(pos, end - pos);
- if (line.length()>0) {
+ if (line.length() > 0) {
- if (current->subitems.size() && current->subitems.back()->get()->type==ITEM_TEXT) {
+ if (current->subitems.size() && current->subitems.back()->get()->type == ITEM_TEXT) {
//append text condition!
- ItemText *ti = static_cast<ItemText*>(current->subitems.back()->get());
- ti->text+=line;
+ ItemText *ti = static_cast<ItemText *>(current->subitems.back()->get());
+ ti->text += line;
_invalidate_current_line(main);
} else {
//append item condition
- ItemText *item = memnew( ItemText );
- item->text=line;
- _add_item(item,false);
-
+ ItemText *item = memnew(ItemText);
+ item->text = line;
+ _add_item(item, false);
}
-
-
}
if (eol) {
- ItemNewline *item = memnew( ItemNewline );
- item->line=current_frame->lines.size();
- _add_item(item,false);
- current_frame->lines.resize(current_frame->lines.size()+1);
- if (item->type!=ITEM_NEWLINE)
- current_frame->lines[current_frame->lines.size()-1].from=item;
+ ItemNewline *item = memnew(ItemNewline);
+ item->line = current_frame->lines.size();
+ _add_item(item, false);
+ current_frame->lines.resize(current_frame->lines.size() + 1);
+ if (item->type != ITEM_NEWLINE)
+ current_frame->lines[current_frame->lines.size() - 1].from = item;
_invalidate_current_line(current_frame);
-
}
- pos=end+1;
+ pos = end + 1;
}
}
void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) {
-
-
- p_item->parent=current;
- p_item->E=current->subitems.push_back(p_item);
- p_item->index=current_idx++;
-
+ p_item->parent = current;
+ p_item->E = current->subitems.push_back(p_item);
+ p_item->index = current_idx++;
if (p_enter)
- current=p_item;
+ current = p_item;
- if (p_ensure_newline && current_frame->lines[current_frame->lines.size()-1].from) {
+ if (p_ensure_newline && current_frame->lines[current_frame->lines.size() - 1].from) {
_invalidate_current_line(current_frame);
- current_frame->lines.resize( current_frame->lines.size() +1 );
-
+ current_frame->lines.resize(current_frame->lines.size() + 1);
}
- if (current_frame->lines[current_frame->lines.size()-1].from==NULL) {
- current_frame->lines[current_frame->lines.size()-1].from=p_item;
+ if (current_frame->lines[current_frame->lines.size() - 1].from == NULL) {
+ current_frame->lines[current_frame->lines.size() - 1].from = p_item;
}
- p_item->line=current_frame->lines.size()-1;
+ p_item->line = current_frame->lines.size() - 1;
_invalidate_current_line(current_frame);
-
}
-void RichTextLabel::_remove_item(Item* p_item, const int p_line, const int p_subitem_line) {
-
+void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_subitem_line) {
int size = p_item->subitems.size();
if (size == 0) {
@@ -1229,37 +1147,33 @@ void RichTextLabel::_remove_item(Item* p_item, const int p_line, const int p_sub
current->subitems[i]->line--;
}
}
- }
- else {
+ } else {
for (int i = 0; i < size; i++) {
_remove_item(p_item->subitems.front()->get(), p_line, p_subitem_line);
}
}
-
}
-void RichTextLabel::add_image(const Ref<Texture>& p_image) {
+void RichTextLabel::add_image(const Ref<Texture> &p_image) {
- if (current->type==ITEM_TABLE)
+ if (current->type == ITEM_TABLE)
return;
ERR_FAIL_COND(p_image.is_null());
- ItemImage *item = memnew( ItemImage );
-
- item->image=p_image;
- _add_item(item,false);
+ ItemImage *item = memnew(ItemImage);
+ item->image = p_image;
+ _add_item(item, false);
}
void RichTextLabel::add_newline() {
- if (current->type==ITEM_TABLE)
+ if (current->type == ITEM_TABLE)
return;
- ItemNewline *item = memnew( ItemNewline );
- item->line=current_frame->lines.size();
- current_frame->lines.resize(current_frame->lines.size()+1);
- _add_item(item,false);
-
+ ItemNewline *item = memnew(ItemNewline);
+ item->line = current_frame->lines.size();
+ current_frame->lines.resize(current_frame->lines.size() + 1);
+ _add_item(item, false);
}
bool RichTextLabel::remove_line(const int p_line) {
@@ -1282,155 +1196,144 @@ bool RichTextLabel::remove_line(const int p_line) {
return true;
}
-void RichTextLabel::push_font(const Ref<Font>& p_font) {
+void RichTextLabel::push_font(const Ref<Font> &p_font) {
- ERR_FAIL_COND(current->type==ITEM_TABLE);
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
ERR_FAIL_COND(p_font.is_null());
- ItemFont *item = memnew( ItemFont );
-
- item->font=p_font;
- _add_item(item,true);
+ ItemFont *item = memnew(ItemFont);
+ item->font = p_font;
+ _add_item(item, true);
}
-void RichTextLabel::push_color(const Color& p_color) {
-
- ERR_FAIL_COND(current->type==ITEM_TABLE);
- ItemColor *item = memnew( ItemColor );
+void RichTextLabel::push_color(const Color &p_color) {
- item->color=p_color;
- _add_item(item,true);
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ItemColor *item = memnew(ItemColor);
+ item->color = p_color;
+ _add_item(item, true);
}
void RichTextLabel::push_underline() {
- ERR_FAIL_COND(current->type==ITEM_TABLE);
- ItemUnderline *item = memnew( ItemUnderline );
-
- _add_item(item,true);
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ItemUnderline *item = memnew(ItemUnderline);
+ _add_item(item, true);
}
void RichTextLabel::push_align(Align p_align) {
- ERR_FAIL_COND(current->type==ITEM_TABLE);
-
- ItemAlign *item = memnew( ItemAlign );
- item->align=p_align;
- _add_item(item,true,true);
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ItemAlign *item = memnew(ItemAlign);
+ item->align = p_align;
+ _add_item(item, true, true);
}
void RichTextLabel::push_indent(int p_level) {
- ERR_FAIL_COND(current->type==ITEM_TABLE);
- ERR_FAIL_COND(p_level<0);
-
- ItemIndent *item = memnew( ItemIndent );
- item->level=p_level;
- _add_item(item,true,true);
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ERR_FAIL_COND(p_level < 0);
+ ItemIndent *item = memnew(ItemIndent);
+ item->level = p_level;
+ _add_item(item, true, true);
}
void RichTextLabel::push_list(ListType p_list) {
- ERR_FAIL_COND(current->type==ITEM_TABLE);
- ERR_FAIL_INDEX(p_list,3);
-
- ItemList *item = memnew( ItemList );
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ERR_FAIL_INDEX(p_list, 3);
- item->list_type=p_list;
- _add_item(item,true,true);
+ ItemList *item = memnew(ItemList);
+ item->list_type = p_list;
+ _add_item(item, true, true);
}
-void RichTextLabel::push_meta(const Variant& p_meta) {
+void RichTextLabel::push_meta(const Variant &p_meta) {
- ERR_FAIL_COND(current->type==ITEM_TABLE);
- ItemMeta *item = memnew( ItemMeta );
-
- item->meta=p_meta;
- _add_item(item,true);
+ ERR_FAIL_COND(current->type == ITEM_TABLE);
+ ItemMeta *item = memnew(ItemMeta);
+ item->meta = p_meta;
+ _add_item(item, true);
}
void RichTextLabel::push_table(int p_columns) {
- ERR_FAIL_COND( p_columns < 1);
- ItemTable *item = memnew( ItemTable );
+ ERR_FAIL_COND(p_columns < 1);
+ ItemTable *item = memnew(ItemTable);
item->columns.resize(p_columns);
- item->total_width=0;
- for(int i=0;i<item->columns.size();i++) {
- item->columns[i].expand=false;
- item->columns[i].expand_ratio=1;
+ item->total_width = 0;
+ for (int i = 0; i < item->columns.size(); i++) {
+ item->columns[i].expand = false;
+ item->columns[i].expand_ratio = 1;
}
- _add_item(item,true,true);
-
+ _add_item(item, true, true);
}
-void RichTextLabel::set_table_column_expand(int p_column,bool p_expand,int p_ratio) {
+void RichTextLabel::set_table_column_expand(int p_column, bool p_expand, int p_ratio) {
- ERR_FAIL_COND(current->type!=ITEM_TABLE);
- ItemTable *table = static_cast<ItemTable*>(current);
- ERR_FAIL_INDEX(p_column,table->columns.size());
- table->columns[p_column].expand=p_expand;
- table->columns[p_column].expand_ratio=p_ratio;
+ ERR_FAIL_COND(current->type != ITEM_TABLE);
+ ItemTable *table = static_cast<ItemTable *>(current);
+ ERR_FAIL_INDEX(p_column, table->columns.size());
+ table->columns[p_column].expand = p_expand;
+ table->columns[p_column].expand_ratio = p_ratio;
}
-void RichTextLabel::push_cell(){
+void RichTextLabel::push_cell() {
- ERR_FAIL_COND(current->type!=ITEM_TABLE);
+ ERR_FAIL_COND(current->type != ITEM_TABLE);
- ItemFrame *item = memnew( ItemFrame );
- item->parent_frame=current_frame;
- _add_item(item,true);
- current_frame=item;
- item->cell=true;
- item->parent_line=item->parent_frame->lines.size()-1;
+ ItemFrame *item = memnew(ItemFrame);
+ item->parent_frame = current_frame;
+ _add_item(item, true);
+ current_frame = item;
+ item->cell = true;
+ item->parent_line = item->parent_frame->lines.size() - 1;
item->lines.resize(1);
- item->lines[0].from=NULL;
- item->first_invalid_line=0;
-
+ item->lines[0].from = NULL;
+ item->first_invalid_line = 0;
}
int RichTextLabel::get_current_table_column() const {
- ERR_FAIL_COND_V(current->type!=ITEM_TABLE,-1);
+ ERR_FAIL_COND_V(current->type != ITEM_TABLE, -1);
- ItemTable *table = static_cast<ItemTable*>(current);
+ ItemTable *table = static_cast<ItemTable *>(current);
return table->subitems.size() % table->columns.size();
-
}
void RichTextLabel::pop() {
ERR_FAIL_COND(!current->parent);
- if (current->type==ITEM_FRAME) {
- current_frame = static_cast<ItemFrame*>(current)->parent_frame;
+ if (current->type == ITEM_FRAME) {
+ current_frame = static_cast<ItemFrame *>(current)->parent_frame;
}
- current=current->parent;
+ current = current->parent;
}
void RichTextLabel::clear() {
main->_clear_children();
- current=main;
- current_frame=main;
+ current = main;
+ current_frame = main;
main->lines.clear();
main->lines.resize(1);
- main->first_invalid_line=0;
+ main->first_invalid_line = 0;
update();
- selection.click=NULL;
- selection.active=false;
- current_idx=1;
-
+ selection.click = NULL;
+ selection.active = false;
+ current_idx = 1;
}
void RichTextLabel::set_tab_size(int p_spaces) {
- tab_size=p_spaces;
- main->first_invalid_line=0;
+ tab_size = p_spaces;
+ main->first_invalid_line = 0;
update();
}
@@ -1439,10 +1342,9 @@ int RichTextLabel::get_tab_size() const {
return tab_size;
}
-
void RichTextLabel::set_meta_underline(bool p_underline) {
- underline_meta=p_underline;
+ underline_meta = p_underline;
update();
}
@@ -1458,10 +1360,10 @@ void RichTextLabel::set_offset(int p_pixel) {
void RichTextLabel::set_scroll_active(bool p_active) {
- if (scroll_active==p_active)
+ if (scroll_active == p_active)
return;
- scroll_active=p_active;
+ scroll_active = p_active;
update();
}
@@ -1472,9 +1374,9 @@ bool RichTextLabel::is_scroll_active() const {
void RichTextLabel::set_scroll_follow(bool p_follow) {
- scroll_follow=p_follow;
- if (!vscroll->is_visible() || vscroll->get_val()>=(vscroll->get_max()-vscroll->get_page()))
- scroll_following=true;
+ scroll_follow = p_follow;
+ if (!vscroll->is_visible() || vscroll->get_val() >= (vscroll->get_max() - vscroll->get_page()))
+ scroll_following = true;
}
bool RichTextLabel::is_scroll_following() const {
@@ -1482,71 +1384,65 @@ bool RichTextLabel::is_scroll_following() const {
return scroll_follow;
}
-Error RichTextLabel::parse_bbcode(const String& p_bbcode) {
+Error RichTextLabel::parse_bbcode(const String &p_bbcode) {
clear();
return append_bbcode(p_bbcode);
}
-Error RichTextLabel::append_bbcode(const String& p_bbcode) {
+Error RichTextLabel::append_bbcode(const String &p_bbcode) {
int pos = 0;
List<String> tag_stack;
- Ref<Font> normal_font=get_font("normal_font");
- Ref<Font> bold_font=get_font("bold_font");
- Ref<Font> italics_font=get_font("italics_font");
- Ref<Font> bold_italics_font=get_font("bold_italics_font");
- Ref<Font> mono_font=get_font("mono_font");
-
- Color base_color=get_color("default_color");
+ Ref<Font> normal_font = get_font("normal_font");
+ Ref<Font> bold_font = get_font("bold_font");
+ Ref<Font> italics_font = get_font("italics_font");
+ Ref<Font> bold_italics_font = get_font("bold_italics_font");
+ Ref<Font> mono_font = get_font("mono_font");
- int indent_level=0;
+ Color base_color = get_color("default_color");
- bool in_bold=false;
- bool in_italics=false;
+ int indent_level = 0;
- while(pos < p_bbcode.length()) {
+ bool in_bold = false;
+ bool in_italics = false;
+ while (pos < p_bbcode.length()) {
- int brk_pos = p_bbcode.find("[",pos);
+ int brk_pos = p_bbcode.find("[", pos);
- if (brk_pos<0)
- brk_pos=p_bbcode.length();
+ if (brk_pos < 0)
+ brk_pos = p_bbcode.length();
if (brk_pos > pos) {
- add_text(p_bbcode.substr(pos,brk_pos-pos));
+ add_text(p_bbcode.substr(pos, brk_pos - pos));
}
- if (brk_pos==p_bbcode.length())
+ if (brk_pos == p_bbcode.length())
break; //nothing else o add
- int brk_end = p_bbcode.find("]",brk_pos+1);
+ int brk_end = p_bbcode.find("]", brk_pos + 1);
- if (brk_end==-1) {
+ if (brk_end == -1) {
//no close, add the rest
- add_text(p_bbcode.substr(brk_pos,p_bbcode.length()-brk_pos));
+ add_text(p_bbcode.substr(brk_pos, p_bbcode.length() - brk_pos));
break;
}
-
- String tag = p_bbcode.substr(brk_pos+1,brk_end-brk_pos-1);
-
+ String tag = p_bbcode.substr(brk_pos + 1, brk_end - brk_pos - 1);
if (tag.begins_with("/") && tag_stack.size()) {
- bool tag_ok = tag_stack.size() && tag_stack.front()->get()==tag.substr(1,tag.length());
+ bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length());
-
-
- if (tag_stack.front()->get()=="b")
- in_bold=false;
- if (tag_stack.front()->get()=="i")
- in_italics=false;
- if (tag_stack.front()->get()=="indent")
+ if (tag_stack.front()->get() == "b")
+ in_bold = false;
+ if (tag_stack.front()->get() == "i")
+ in_italics = false;
+ if (tag_stack.front()->get() == "indent")
indent_level--;
-
if (!tag_ok) {
add_text("[");
@@ -1555,223 +1451,216 @@ Error RichTextLabel::append_bbcode(const String& p_bbcode) {
}
tag_stack.pop_front();
- pos=brk_end+1;
- if (tag!="/img")
+ pos = brk_end + 1;
+ if (tag != "/img")
pop();
- } else if (tag=="b") {
+ } else if (tag == "b") {
//use bold font
- in_bold=true;
+ in_bold = true;
if (in_italics)
push_font(bold_italics_font);
else
push_font(bold_font);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="i") {
+ } else if (tag == "i") {
//use italics font
- in_italics=true;
+ in_italics = true;
if (in_bold)
push_font(bold_italics_font);
else
push_font(italics_font);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="code") {
+ } else if (tag == "code") {
//use monospace font
push_font(mono_font);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag.begins_with("table=")) {
- int columns = tag.substr(6,tag.length()).to_int();
- if (columns<1)
- columns=1;
+ int columns = tag.substr(6, tag.length()).to_int();
+ if (columns < 1)
+ columns = 1;
//use monospace font
push_table(columns);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front("table");
- } else if (tag=="cell") {
+ } else if (tag == "cell") {
push_cell();
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag.begins_with("cell=")) {
- int ratio = tag.substr(6,tag.length()).to_int();
- if (ratio<1)
- ratio=1;
+ int ratio = tag.substr(6, tag.length()).to_int();
+ if (ratio < 1)
+ ratio = 1;
//use monospace font
- set_table_column_expand(get_current_table_column(),true,ratio);
+ set_table_column_expand(get_current_table_column(), true, ratio);
push_cell();
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front("cell");
- } else if (tag=="u") {
+ } else if (tag == "u") {
//use underline
push_underline();
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="s") {
+ } else if (tag == "s") {
//use strikethrough (not supported underline instead)
push_underline();
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="center") {
+ } else if (tag == "center") {
//use underline
push_align(ALIGN_CENTER);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="fill") {
+ } else if (tag == "fill") {
//use underline
push_align(ALIGN_FILL);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="right") {
+ } else if (tag == "right") {
//use underline
push_align(ALIGN_RIGHT);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="ul") {
+ } else if (tag == "ul") {
//use underline
push_list(LIST_DOTS);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="ol") {
+ } else if (tag == "ol") {
//use underline
push_list(LIST_NUMBERS);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="indent") {
+ } else if (tag == "indent") {
//use underline
indent_level++;
push_indent(indent_level);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
- } else if (tag=="url") {
+ } else if (tag == "url") {
//use strikethrough (not supported underline instead)
- int end=p_bbcode.find("[",brk_end);
- if (end==-1)
- end=p_bbcode.length();
- String url = p_bbcode.substr(brk_end+1,end-brk_end-1);
+ int end = p_bbcode.find("[", brk_end);
+ if (end == -1)
+ end = p_bbcode.length();
+ String url = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
push_meta(url);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag.begins_with("url=")) {
- String url = tag.substr(4,tag.length());
+ String url = tag.substr(4, tag.length());
push_meta(url);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front("url");
- } else if (tag=="img") {
+ } else if (tag == "img") {
//use strikethrough (not supported underline instead)
- int end=p_bbcode.find("[",brk_end);
- if (end==-1)
- end=p_bbcode.length();
- String image = p_bbcode.substr(brk_end+1,end-brk_end-1);
+ int end = p_bbcode.find("[", brk_end);
+ if (end == -1)
+ end = p_bbcode.length();
+ String image = p_bbcode.substr(brk_end + 1, end - brk_end - 1);
- Ref<Texture> texture = ResourceLoader::load(image,"Texture");
+ Ref<Texture> texture = ResourceLoader::load(image, "Texture");
if (texture.is_valid())
add_image(texture);
- pos=end;
+ pos = end;
tag_stack.push_front(tag);
} else if (tag.begins_with("color=")) {
- String col = tag.substr(6,tag.length());
+ String col = tag.substr(6, tag.length());
Color color;
if (col.begins_with("#"))
- color=Color::html(col);
- else if (col=="aqua")
- color=Color::html("#00FFFF");
- else if (col=="black")
- color=Color::html("#000000");
- else if (col=="blue")
- color=Color::html("#0000FF");
- else if (col=="fuchsia")
- color=Color::html("#FF00FF");
- else if (col=="gray" || col=="grey")
- color=Color::html("#808080");
- else if (col=="green")
- color=Color::html("#008000");
- else if (col=="lime")
- color=Color::html("#00FF00");
- else if (col=="maroon")
- color=Color::html("#800000");
- else if (col=="navy")
- color=Color::html("#000080");
- else if (col=="olive")
- color=Color::html("#808000");
- else if (col=="purple")
- color=Color::html("#800080");
- else if (col=="red")
- color=Color::html("#FF0000");
- else if (col=="silver")
- color=Color::html("#C0C0C0");
- else if (col=="teal")
- color=Color::html("#008008");
- else if (col=="white")
- color=Color::html("#FFFFFF");
- else if (col=="yellow")
- color=Color::html("#FFFF00");
+ color = Color::html(col);
+ else if (col == "aqua")
+ color = Color::html("#00FFFF");
+ else if (col == "black")
+ color = Color::html("#000000");
+ else if (col == "blue")
+ color = Color::html("#0000FF");
+ else if (col == "fuchsia")
+ color = Color::html("#FF00FF");
+ else if (col == "gray" || col == "grey")
+ color = Color::html("#808080");
+ else if (col == "green")
+ color = Color::html("#008000");
+ else if (col == "lime")
+ color = Color::html("#00FF00");
+ else if (col == "maroon")
+ color = Color::html("#800000");
+ else if (col == "navy")
+ color = Color::html("#000080");
+ else if (col == "olive")
+ color = Color::html("#808000");
+ else if (col == "purple")
+ color = Color::html("#800080");
+ else if (col == "red")
+ color = Color::html("#FF0000");
+ else if (col == "silver")
+ color = Color::html("#C0C0C0");
+ else if (col == "teal")
+ color = Color::html("#008008");
+ else if (col == "white")
+ color = Color::html("#FFFFFF");
+ else if (col == "yellow")
+ color = Color::html("#FFFF00");
else
- color=base_color;
-
-
+ color = base_color;
push_color(color);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front("color");
} else if (tag.begins_with("font=")) {
- String fnt = tag.substr(5,tag.length());
-
+ String fnt = tag.substr(5, tag.length());
- Ref<Font> font = ResourceLoader::load(fnt,"Font");
+ Ref<Font> font = ResourceLoader::load(fnt, "Font");
if (font.is_valid())
push_font(font);
else
push_font(normal_font);
- pos=brk_end+1;
+ pos = brk_end + 1;
tag_stack.push_front("font");
-
} else {
add_text("["); //ignore
- pos=brk_pos+1;
-
+ pos = brk_pos + 1;
}
}
return OK;
}
-
void RichTextLabel::scroll_to_line(int p_line) {
- ERR_FAIL_INDEX(p_line,main->lines.size());
+ ERR_FAIL_INDEX(p_line, main->lines.size());
_validate_line_caches(main);
- vscroll->set_val(main->lines[p_line].height_accum_cache-main->lines[p_line].height_cache);
-
+ vscroll->set_val(main->lines[p_line].height_accum_cache - main->lines[p_line].height_cache);
}
int RichTextLabel::get_line_count() const {
@@ -1781,75 +1670,72 @@ int RichTextLabel::get_line_count() const {
void RichTextLabel::set_selection_enabled(bool p_enabled) {
- selection.enabled=p_enabled;
+ selection.enabled = p_enabled;
if (!p_enabled) {
if (selection.active) {
- selection.active=false;
+ selection.active = false;
update();
}
set_focus_mode(FOCUS_NONE);
} else {
set_focus_mode(FOCUS_ALL);
}
-
}
-bool RichTextLabel::search(const String& p_string,bool p_from_selection) {
+bool RichTextLabel::search(const String &p_string, bool p_from_selection) {
- ERR_FAIL_COND_V(!selection.enabled,false);
- Item *it=main;
- int charidx=0;
+ ERR_FAIL_COND_V(!selection.enabled, false);
+ Item *it = main;
+ int charidx = 0;
if (p_from_selection && selection.active && selection.enabled) {
- it=selection.to;
- charidx=selection.to_char+1;
+ it = selection.to;
+ charidx = selection.to_char + 1;
}
- while(it) {
+ while (it) {
- if (it->type==ITEM_TEXT) {
+ if (it->type == ITEM_TEXT) {
- ItemText *t = static_cast<ItemText*>(it);
- int sp = t->text.find(p_string,charidx);
- if (sp!=-1) {
- selection.from=it;
- selection.from_char=sp;
- selection.to=it;
- selection.to_char=sp+p_string.length()-1;
- selection.active=true;
+ ItemText *t = static_cast<ItemText *>(it);
+ int sp = t->text.find(p_string, charidx);
+ if (sp != -1) {
+ selection.from = it;
+ selection.from_char = sp;
+ selection.to = it;
+ selection.to_char = sp + p_string.length() - 1;
+ selection.active = true;
update();
_validate_line_caches(main);
- int fh = _find_font(t).is_valid()?_find_font(t)->get_height():get_font("normal_font")->get_height();
+ int fh = _find_font(t).is_valid() ? _find_font(t)->get_height() : get_font("normal_font")->get_height();
- float offset =0;
+ float offset = 0;
int line = t->line;
- Item *item =t;
- while(item) {
- if (item->type==ITEM_FRAME) {
- ItemFrame *frame = static_cast<ItemFrame*>(item);
- if (line>=0 && line<frame->lines.size()) {
- offset+=frame->lines[line].height_accum_cache-frame->lines[line].height_cache;
- line=frame->line;
+ Item *item = t;
+ while (item) {
+ if (item->type == ITEM_FRAME) {
+ ItemFrame *frame = static_cast<ItemFrame *>(item);
+ if (line >= 0 && line < frame->lines.size()) {
+ offset += frame->lines[line].height_accum_cache - frame->lines[line].height_cache;
+ line = frame->line;
}
}
- item=item->parent;
+ item = item->parent;
}
- vscroll->set_val(offset-fh);
+ vscroll->set_val(offset - fh);
return true;
}
}
- it=_get_next_item(it,true);
- charidx=0;
-
+ it = _get_next_item(it, true);
+ charidx = 0;
}
return false;
-
}
void RichTextLabel::selection_copy() {
@@ -1859,37 +1745,36 @@ void RichTextLabel::selection_copy() {
String text;
- RichTextLabel::Item *item=selection.from;
+ RichTextLabel::Item *item = selection.from;
- while(item) {
+ while (item) {
- if (item->type==ITEM_TEXT) {
+ if (item->type == ITEM_TEXT) {
- String itext = static_cast<ItemText*>(item)->text;
- if (item==selection.from && item==selection.to) {
- text+=itext.substr(selection.from_char,selection.to_char-selection.from_char+1);
- } else if (item==selection.from) {
- text+=itext.substr(selection.from_char,itext.size());
- } else if (item==selection.to) {
- text+=itext.substr(0,selection.to_char+1);
+ String itext = static_cast<ItemText *>(item)->text;
+ if (item == selection.from && item == selection.to) {
+ text += itext.substr(selection.from_char, selection.to_char - selection.from_char + 1);
+ } else if (item == selection.from) {
+ text += itext.substr(selection.from_char, itext.size());
+ } else if (item == selection.to) {
+ text += itext.substr(0, selection.to_char + 1);
} else {
- text+=itext;
+ text += itext;
}
- } else if (item->type==ITEM_NEWLINE) {
- text+="\n";
+ } else if (item->type == ITEM_NEWLINE) {
+ text += "\n";
}
- if (item==selection.to)
+ if (item == selection.to)
break;
- item=_get_next_item(item,true);
+ item = _get_next_item(item, true);
}
- if (text!="") {
+ if (text != "") {
OS::get_singleton()->set_clipboard(text);
//print_line("COPY: "+text);
}
-
}
bool RichTextLabel::is_selection_enabled() const {
@@ -1897,8 +1782,8 @@ bool RichTextLabel::is_selection_enabled() const {
return selection.enabled;
}
-void RichTextLabel::set_bbcode(const String& p_bbcode) {
- bbcode=p_bbcode;
+void RichTextLabel::set_bbcode(const String &p_bbcode) {
+ bbcode = p_bbcode;
if (is_inside_tree() && use_bbcode)
parse_bbcode(p_bbcode);
else { // raw text
@@ -1913,9 +1798,9 @@ String RichTextLabel::get_bbcode() const {
}
void RichTextLabel::set_use_bbcode(bool p_enable) {
- if (use_bbcode==p_enable)
+ if (use_bbcode == p_enable)
return;
- use_bbcode=p_enable;
+ use_bbcode = p_enable;
set_bbcode(bbcode);
}
@@ -1929,108 +1814,105 @@ String RichTextLabel::get_text() {
Item *it = main;
while (it) {
if (it->type == ITEM_TEXT) {
- ItemText *t = static_cast<ItemText*>(it);
+ ItemText *t = static_cast<ItemText *>(it);
text += t->text;
} else if (it->type == ITEM_NEWLINE) {
text += "\n";
} else if (it->type == ITEM_INDENT) {
text += "\t";
}
- it=_get_next_item(it,true);
+ it = _get_next_item(it, true);
}
return text;
}
void RichTextLabel::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("_input_event"), &RichTextLabel::_input_event);
+ ObjectTypeDB::bind_method(_MD("_scroll_changed"), &RichTextLabel::_scroll_changed);
+ ObjectTypeDB::bind_method(_MD("get_text"), &RichTextLabel::get_text);
+ ObjectTypeDB::bind_method(_MD("add_text", "text"), &RichTextLabel::add_text);
+ ObjectTypeDB::bind_method(_MD("add_image", "image:Texture"), &RichTextLabel::add_image);
+ ObjectTypeDB::bind_method(_MD("newline"), &RichTextLabel::add_newline);
+ ObjectTypeDB::bind_method(_MD("remove_line"), &RichTextLabel::remove_line);
+ ObjectTypeDB::bind_method(_MD("push_font", "font"), &RichTextLabel::push_font);
+ ObjectTypeDB::bind_method(_MD("push_color", "color"), &RichTextLabel::push_color);
+ ObjectTypeDB::bind_method(_MD("push_align", "align"), &RichTextLabel::push_align);
+ ObjectTypeDB::bind_method(_MD("push_indent", "level"), &RichTextLabel::push_indent);
+ ObjectTypeDB::bind_method(_MD("push_list", "type"), &RichTextLabel::push_list);
+ ObjectTypeDB::bind_method(_MD("push_meta", "data"), &RichTextLabel::push_meta);
+ ObjectTypeDB::bind_method(_MD("push_underline"), &RichTextLabel::push_underline);
+ ObjectTypeDB::bind_method(_MD("push_table", "columns"), &RichTextLabel::push_table);
+ ObjectTypeDB::bind_method(_MD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::set_table_column_expand);
+ ObjectTypeDB::bind_method(_MD("push_cell"), &RichTextLabel::push_cell);
+ ObjectTypeDB::bind_method(_MD("pop"), &RichTextLabel::pop);
- ObjectTypeDB::bind_method(_MD("_input_event"),&RichTextLabel::_input_event);
- ObjectTypeDB::bind_method(_MD("_scroll_changed"),&RichTextLabel::_scroll_changed);
- ObjectTypeDB::bind_method(_MD("get_text"),&RichTextLabel::get_text);
- ObjectTypeDB::bind_method(_MD("add_text","text"),&RichTextLabel::add_text);
- ObjectTypeDB::bind_method(_MD("add_image","image:Texture"),&RichTextLabel::add_image);
- ObjectTypeDB::bind_method(_MD("newline"),&RichTextLabel::add_newline);
- ObjectTypeDB::bind_method(_MD("remove_line"),&RichTextLabel::remove_line);
- ObjectTypeDB::bind_method(_MD("push_font","font"),&RichTextLabel::push_font);
- ObjectTypeDB::bind_method(_MD("push_color","color"),&RichTextLabel::push_color);
- ObjectTypeDB::bind_method(_MD("push_align","align"),&RichTextLabel::push_align);
- ObjectTypeDB::bind_method(_MD("push_indent","level"),&RichTextLabel::push_indent);
- ObjectTypeDB::bind_method(_MD("push_list","type"),&RichTextLabel::push_list);
- ObjectTypeDB::bind_method(_MD("push_meta","data"),&RichTextLabel::push_meta);
- ObjectTypeDB::bind_method(_MD("push_underline"),&RichTextLabel::push_underline);
- ObjectTypeDB::bind_method(_MD("push_table","columns"),&RichTextLabel::push_table);
- ObjectTypeDB::bind_method(_MD("set_table_column_expand","column","expand","ratio"),&RichTextLabel::set_table_column_expand);
- ObjectTypeDB::bind_method(_MD("push_cell"),&RichTextLabel::push_cell);
- ObjectTypeDB::bind_method(_MD("pop"),&RichTextLabel::pop);
-
- ObjectTypeDB::bind_method(_MD("clear"),&RichTextLabel::clear);
+ ObjectTypeDB::bind_method(_MD("clear"), &RichTextLabel::clear);
- ObjectTypeDB::bind_method(_MD("set_meta_underline","enable"),&RichTextLabel::set_meta_underline);
- ObjectTypeDB::bind_method(_MD("is_meta_underlined"),&RichTextLabel::is_meta_underlined);
+ ObjectTypeDB::bind_method(_MD("set_meta_underline", "enable"), &RichTextLabel::set_meta_underline);
+ ObjectTypeDB::bind_method(_MD("is_meta_underlined"), &RichTextLabel::is_meta_underlined);
- ObjectTypeDB::bind_method(_MD("set_scroll_active","active"),&RichTextLabel::set_scroll_active);
- ObjectTypeDB::bind_method(_MD("is_scroll_active"),&RichTextLabel::is_scroll_active);
+ ObjectTypeDB::bind_method(_MD("set_scroll_active", "active"), &RichTextLabel::set_scroll_active);
+ ObjectTypeDB::bind_method(_MD("is_scroll_active"), &RichTextLabel::is_scroll_active);
- ObjectTypeDB::bind_method(_MD("set_scroll_follow","follow"),&RichTextLabel::set_scroll_follow);
- ObjectTypeDB::bind_method(_MD("is_scroll_following"),&RichTextLabel::is_scroll_following);
+ ObjectTypeDB::bind_method(_MD("set_scroll_follow", "follow"), &RichTextLabel::set_scroll_follow);
+ ObjectTypeDB::bind_method(_MD("is_scroll_following"), &RichTextLabel::is_scroll_following);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&RichTextLabel::get_v_scroll);
+ ObjectTypeDB::bind_method(_MD("get_v_scroll"), &RichTextLabel::get_v_scroll);
- ObjectTypeDB::bind_method(_MD("scroll_to_line","line"),&RichTextLabel::scroll_to_line);
+ ObjectTypeDB::bind_method(_MD("scroll_to_line", "line"), &RichTextLabel::scroll_to_line);
- ObjectTypeDB::bind_method(_MD("set_tab_size","spaces"),&RichTextLabel::set_tab_size);
- ObjectTypeDB::bind_method(_MD("get_tab_size"),&RichTextLabel::get_tab_size);
+ ObjectTypeDB::bind_method(_MD("set_tab_size", "spaces"), &RichTextLabel::set_tab_size);
+ ObjectTypeDB::bind_method(_MD("get_tab_size"), &RichTextLabel::get_tab_size);
- ObjectTypeDB::bind_method(_MD("set_selection_enabled","enabled"),&RichTextLabel::set_selection_enabled);
- ObjectTypeDB::bind_method(_MD("is_selection_enabled"),&RichTextLabel::is_selection_enabled);
+ ObjectTypeDB::bind_method(_MD("set_selection_enabled", "enabled"), &RichTextLabel::set_selection_enabled);
+ ObjectTypeDB::bind_method(_MD("is_selection_enabled"), &RichTextLabel::is_selection_enabled);
- ObjectTypeDB::bind_method(_MD("parse_bbcode", "bbcode"),&RichTextLabel::parse_bbcode);
- ObjectTypeDB::bind_method(_MD("append_bbcode", "bbcode"),&RichTextLabel::append_bbcode);
+ ObjectTypeDB::bind_method(_MD("parse_bbcode", "bbcode"), &RichTextLabel::parse_bbcode);
+ ObjectTypeDB::bind_method(_MD("append_bbcode", "bbcode"), &RichTextLabel::append_bbcode);
- ObjectTypeDB::bind_method(_MD("set_bbcode","text"),&RichTextLabel::set_bbcode);
- ObjectTypeDB::bind_method(_MD("get_bbcode"),&RichTextLabel::get_bbcode);
+ ObjectTypeDB::bind_method(_MD("set_bbcode", "text"), &RichTextLabel::set_bbcode);
+ ObjectTypeDB::bind_method(_MD("get_bbcode"), &RichTextLabel::get_bbcode);
- ObjectTypeDB::bind_method(_MD("set_visible_characters","amount"),&RichTextLabel::set_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_visible_characters"),&RichTextLabel::get_visible_characters);
+ ObjectTypeDB::bind_method(_MD("set_visible_characters", "amount"), &RichTextLabel::set_visible_characters);
+ ObjectTypeDB::bind_method(_MD("get_visible_characters"), &RichTextLabel::get_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_total_character_count"),&RichTextLabel::get_total_character_count);
+ ObjectTypeDB::bind_method(_MD("get_total_character_count"), &RichTextLabel::get_total_character_count);
- ObjectTypeDB::bind_method(_MD("set_use_bbcode","enable"),&RichTextLabel::set_use_bbcode);
- ObjectTypeDB::bind_method(_MD("is_using_bbcode"),&RichTextLabel::is_using_bbcode);
+ ObjectTypeDB::bind_method(_MD("set_use_bbcode", "enable"), &RichTextLabel::set_use_bbcode);
+ ObjectTypeDB::bind_method(_MD("is_using_bbcode"), &RichTextLabel::is_using_bbcode);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"bbcode/enabled"),_SCS("set_use_bbcode"),_SCS("is_using_bbcode"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"bbcode/bbcode",PROPERTY_HINT_MULTILINE_TEXT),_SCS("set_bbcode"),_SCS("get_bbcode"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"visible_characters",PROPERTY_HINT_RANGE,"-1,128000,1"),_SCS("set_visible_characters"),_SCS("get_visible_characters"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bbcode/enabled"), _SCS("set_use_bbcode"), _SCS("is_using_bbcode"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "bbcode/bbcode", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_bbcode"), _SCS("get_bbcode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "visible_characters", PROPERTY_HINT_RANGE, "-1,128000,1"), _SCS("set_visible_characters"), _SCS("get_visible_characters"));
- ADD_SIGNAL( MethodInfo("meta_clicked",PropertyInfo(Variant::NIL,"meta")));
+ ADD_SIGNAL(MethodInfo("meta_clicked", PropertyInfo(Variant::NIL, "meta")));
- BIND_CONSTANT( ALIGN_LEFT );
- BIND_CONSTANT( ALIGN_CENTER );
- BIND_CONSTANT( ALIGN_RIGHT );
- BIND_CONSTANT( ALIGN_FILL );
+ BIND_CONSTANT(ALIGN_LEFT);
+ BIND_CONSTANT(ALIGN_CENTER);
+ BIND_CONSTANT(ALIGN_RIGHT);
+ BIND_CONSTANT(ALIGN_FILL);
- BIND_CONSTANT( LIST_NUMBERS );
- BIND_CONSTANT( LIST_LETTERS );
- BIND_CONSTANT( LIST_DOTS );
-
- BIND_CONSTANT( ITEM_FRAME );
- BIND_CONSTANT( ITEM_TEXT );
- BIND_CONSTANT( ITEM_IMAGE );
- BIND_CONSTANT( ITEM_NEWLINE );
- BIND_CONSTANT( ITEM_FONT );
- BIND_CONSTANT( ITEM_COLOR );
- BIND_CONSTANT( ITEM_UNDERLINE );
- BIND_CONSTANT( ITEM_ALIGN );
- BIND_CONSTANT( ITEM_INDENT );
- BIND_CONSTANT( ITEM_LIST );
- BIND_CONSTANT( ITEM_META );
+ BIND_CONSTANT(LIST_NUMBERS);
+ BIND_CONSTANT(LIST_LETTERS);
+ BIND_CONSTANT(LIST_DOTS);
+ BIND_CONSTANT(ITEM_FRAME);
+ BIND_CONSTANT(ITEM_TEXT);
+ BIND_CONSTANT(ITEM_IMAGE);
+ BIND_CONSTANT(ITEM_NEWLINE);
+ BIND_CONSTANT(ITEM_FONT);
+ BIND_CONSTANT(ITEM_COLOR);
+ BIND_CONSTANT(ITEM_UNDERLINE);
+ BIND_CONSTANT(ITEM_ALIGN);
+ BIND_CONSTANT(ITEM_INDENT);
+ BIND_CONSTANT(ITEM_LIST);
+ BIND_CONSTANT(ITEM_META);
}
-
void RichTextLabel::set_visible_characters(int p_visible) {
- visible_characters=p_visible;
+ visible_characters = p_visible;
update();
}
@@ -2040,57 +1922,54 @@ int RichTextLabel::get_visible_characters() const {
}
int RichTextLabel::get_total_character_count() const {
- int tc=0;
- for(int i=0;i<current_frame->lines.size();i++)
- tc+=current_frame->lines[i].char_count;
+ int tc = 0;
+ for (int i = 0; i < current_frame->lines.size(); i++)
+ tc += current_frame->lines[i].char_count;
return tc;
}
-
RichTextLabel::RichTextLabel() {
-
- main = memnew( ItemFrame );
- main->index=0;
- current=main;
+ main = memnew(ItemFrame);
+ main->index = 0;
+ current = main;
main->lines.resize(1);
- main->lines[0].from=main;
- main->first_invalid_line=0;
- current_frame=main;
- tab_size=4;
- default_align=ALIGN_LEFT;
- underline_meta=true;
+ main->lines[0].from = main;
+ main->first_invalid_line = 0;
+ current_frame = main;
+ tab_size = 4;
+ default_align = ALIGN_LEFT;
+ underline_meta = true;
- scroll_visible=false;
- scroll_follow=false;
- scroll_following=false;
- updating_scroll=false;
- scroll_active=true;
- scroll_w=0;
+ scroll_visible = false;
+ scroll_follow = false;
+ scroll_following = false;
+ updating_scroll = false;
+ scroll_active = true;
+ scroll_w = 0;
- vscroll = memnew( VScrollBar );
+ vscroll = memnew(VScrollBar);
add_child(vscroll);
vscroll->set_drag_slave(String(".."));
vscroll->set_step(1);
- vscroll->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 0);
- vscroll->set_anchor_and_margin( MARGIN_BOTTOM, ANCHOR_END, 0);
- vscroll->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, 0);
- vscroll->connect("value_changed",this,"_scroll_changed");
+ vscroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
+ vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
+ vscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ vscroll->connect("value_changed", this, "_scroll_changed");
vscroll->set_step(1);
vscroll->hide();
- current_idx=1;
- use_bbcode=false;
-
- selection.click=NULL;
- selection.active=false;
- selection.enabled=false;
+ current_idx = 1;
+ use_bbcode = false;
- visible_characters=-1;
+ selection.click = NULL;
+ selection.active = false;
+ selection.enabled = false;
+ visible_characters = -1;
}
RichTextLabel::~RichTextLabel() {
- memdelete( main );
+ memdelete(main);
}
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index ae1ac4882..cf7b346ea 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -29,14 +29,13 @@
#ifndef RICH_TEXT_LABEL_H
#define RICH_TEXT_LABEL_H
-
#include "scene/gui/scroll_bar.h"
class RichTextLabel : public Control {
- OBJ_TYPE( RichTextLabel, Control );
-public:
+ OBJ_TYPE(RichTextLabel, Control);
+public:
enum Align {
ALIGN_LEFT,
@@ -69,10 +68,9 @@ public:
};
protected:
-
static void _bind_methods();
-private:
+private:
struct Item;
struct Line {
@@ -86,27 +84,37 @@ private:
int char_count;
int minimum_width;
- Line() { from=NULL; char_count=0; }
+ Line() {
+ from = NULL;
+ char_count = 0;
+ }
};
-
-
struct Item {
int index;
Item *parent;
ItemType type;
- List<Item*> subitems;
- List<Item*>::Element *E;
+ List<Item *> subitems;
+ List<Item *>::Element *E;
int line;
- void _clear_children() { while (subitems.size()) { memdelete(subitems.front()->get()); subitems.pop_front(); } }
+ void _clear_children() {
+ while (subitems.size()) {
+ memdelete(subitems.front()->get());
+ subitems.pop_front();
+ }
+ }
- Item() { parent=NULL; E=NULL; line=0;}
- virtual ~Item() { _clear_children(); }
+ Item() {
+ parent = NULL;
+ E = NULL;
+ line = 0;
+ }
+ virtual ~Item() { _clear_children(); }
};
- struct ItemFrame : public Item{
+ struct ItemFrame : public Item {
int parent_line;
bool cell;
@@ -114,71 +122,74 @@ private:
int first_invalid_line;
ItemFrame *parent_frame;
- ItemFrame() { type=ITEM_FRAME; parent_frame=NULL; cell=false; parent_line=0; }
+ ItemFrame() {
+ type = ITEM_FRAME;
+ parent_frame = NULL;
+ cell = false;
+ parent_line = 0;
+ }
};
-
struct ItemText : public Item {
String text;
- ItemText() { type=ITEM_TEXT; }
+ ItemText() { type = ITEM_TEXT; }
};
struct ItemImage : public Item {
Ref<Texture> image;
- ItemImage() { type=ITEM_IMAGE; }
+ ItemImage() { type = ITEM_IMAGE; }
};
struct ItemFont : public Item {
Ref<Font> font;
- ItemFont() { type=ITEM_FONT; }
+ ItemFont() { type = ITEM_FONT; }
};
struct ItemColor : public Item {
Color color;
- ItemColor() { type=ITEM_COLOR; }
+ ItemColor() { type = ITEM_COLOR; }
};
struct ItemUnderline : public Item {
- ItemUnderline() { type=ITEM_UNDERLINE; }
+ ItemUnderline() { type = ITEM_UNDERLINE; }
};
struct ItemMeta : public Item {
Variant meta;
- ItemMeta() { type=ITEM_META; }
+ ItemMeta() { type = ITEM_META; }
};
struct ItemAlign : public Item {
Align align;
- ItemAlign() { type=ITEM_ALIGN; }
+ ItemAlign() { type = ITEM_ALIGN; }
};
struct ItemIndent : public Item {
int level;
- ItemIndent() { type=ITEM_INDENT; }
+ ItemIndent() { type = ITEM_INDENT; }
};
struct ItemList : public Item {
ListType list_type;
- ItemList() { type=ITEM_LIST; }
+ ItemList() { type = ITEM_LIST; }
};
struct ItemNewline : public Item {
int line;
- ItemNewline() { type=ITEM_NEWLINE; }
+ ItemNewline() { type = ITEM_NEWLINE; }
};
-
- struct ItemTable : public Item{
+ struct ItemTable : public Item {
struct Column {
bool expand;
@@ -189,7 +200,7 @@ private:
Vector<Column> columns;
int total_width;
- ItemTable() { type=ITEM_TABLE; }
+ ItemTable() { type = ITEM_TABLE; }
};
ItemFrame *main;
@@ -198,7 +209,6 @@ private:
VScrollBar *vscroll;
-
bool scroll_visible;
bool scroll_follow;
bool scroll_following;
@@ -207,7 +217,6 @@ private:
bool updating_scroll;
int current_idx;
-
int tab_size;
bool underline_meta;
@@ -216,12 +225,9 @@ private:
void _invalidate_current_line(ItemFrame *p_frame);
void _validate_line_caches(ItemFrame *p_frame);
- void _add_item(Item *p_item, bool p_enter=false,bool p_ensure_newline=false);
+ void _add_item(Item *p_item, bool p_enter = false, bool p_ensure_newline = false);
void _remove_item(Item *p_item, const int p_line, const int p_subitem_line);
-
-
-
struct ProcessState {
int line_width;
@@ -250,26 +256,23 @@ private:
Selection selection;
-
int visible_characters;
-
- void _process_line(ItemFrame *p_frame,const Vector2& p_ofs,int &y, int p_width, int p_line, ProcessMode p_mode,const Ref<Font> &p_base_font,const Color &p_base_color,const Point2i& p_click_pos=Point2i(),Item **r_click_item=NULL,int *r_click_char=NULL,bool *r_outside=NULL,int p_char_count=0);
- void _find_click(ItemFrame *p_frame, const Point2i& p_click,Item **r_click_item=NULL,int *r_click_char=NULL,bool *r_outside=NULL);
-
+ void _process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos = Point2i(), Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL, int p_char_count = 0);
+ void _find_click(ItemFrame *p_frame, const Point2i &p_click, Item **r_click_item = NULL, int *r_click_char = NULL, bool *r_outside = NULL);
Ref<Font> _find_font(Item *p_item);
- int _find_margin(Item *p_item,const Ref<Font>& p_base_font);
+ int _find_margin(Item *p_item, const Ref<Font> &p_base_font);
Align _find_align(Item *p_item);
- Color _find_color(Item *p_item,const Color& p_default_color);
+ Color _find_color(Item *p_item, const Color &p_default_color);
bool _find_underline(Item *p_item);
- bool _find_meta(Item *p_item,Variant *r_meta);
+ bool _find_meta(Item *p_item, Variant *r_meta);
void _update_scroll();
void _scroll_changed(double);
void _input_event(InputEvent p_event);
- Item *_get_next_item(Item* p_item, bool p_free=false);
+ Item *_get_next_item(Item *p_item, bool p_free = false);
bool use_bbcode;
String bbcode;
@@ -280,21 +283,20 @@ protected:
void _notification(int p_what);
public:
-
String get_text();
- void add_text(const String& p_text);
- void add_image(const Ref<Texture>& p_image);
+ void add_text(const String &p_text);
+ void add_image(const Ref<Texture> &p_image);
void add_newline();
bool remove_line(const int p_line);
- void push_font(const Ref<Font>& p_font);
- void push_color(const Color& p_color);
+ void push_font(const Ref<Font> &p_font);
+ void push_color(const Color &p_color);
void push_underline();
void push_align(Align p_align);
void push_indent(int p_level);
void push_list(ListType p_list);
- void push_meta(const Variant& p_data);
+ void push_meta(const Variant &p_data);
void push_table(int p_columns);
- void set_table_column_expand(int p_column, bool p_expand, int p_ratio=1);
+ void set_table_column_expand(int p_column, bool p_expand, int p_ratio = 1);
int get_current_table_column() const;
void push_cell();
void pop();
@@ -315,29 +317,26 @@ public:
void set_tab_size(int p_spaces);
int get_tab_size() const;
-
-
- bool search(const String& p_string,bool p_from_selection=false);
+ bool search(const String &p_string, bool p_from_selection = false);
void scroll_to_line(int p_line);
int get_line_count() const;
VScrollBar *get_v_scroll() { return vscroll; }
- virtual CursorShape get_cursor_shape(const Point2& p_pos) const;
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos) const;
void set_selection_enabled(bool p_enabled);
bool is_selection_enabled() const;
void selection_copy();
-
- Error parse_bbcode(const String& p_bbcode);
- Error append_bbcode(const String& p_bbcode);
+ Error parse_bbcode(const String &p_bbcode);
+ Error append_bbcode(const String &p_bbcode);
void set_use_bbcode(bool p_enable);
bool is_using_bbcode() const;
- void set_bbcode(const String& p_bbcode);
+ void set_bbcode(const String &p_bbcode);
String get_bbcode() const;
void set_visible_characters(int p_visible);
@@ -348,8 +347,8 @@ public:
~RichTextLabel();
};
-VARIANT_ENUM_CAST( RichTextLabel::Align );
-VARIANT_ENUM_CAST( RichTextLabel::ListType );
-VARIANT_ENUM_CAST( RichTextLabel::ItemType );
+VARIANT_ENUM_CAST(RichTextLabel::Align);
+VARIANT_ENUM_CAST(RichTextLabel::ListType);
+VARIANT_ENUM_CAST(RichTextLabel::ItemType);
#endif // RICH_TEXT_LABEL_H
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index b49aa520d..2100b8756 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -28,162 +28,149 @@
/*************************************************************************/
#include "scroll_bar.h"
#include "os/keyboard.h"
-#include "print_string.h"
#include "os/os.h"
-bool ScrollBar::focus_by_default=false;
-
-
+#include "print_string.h"
+bool ScrollBar::focus_by_default = false;
void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
- focus_by_default=p_can_focus;
+ focus_by_default = p_can_focus;
}
void ScrollBar::_input_event(InputEvent p_event) {
-
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &b=p_event.mouse_button;
+ const InputEventMouseButton &b = p_event.mouse_button;
accept_event();
- if (b.button_index==5 && b.pressed) {
+ if (b.button_index == 5 && b.pressed) {
//if (orientation==VERTICAL)
// set_val( get_val() + get_page() / 4.0 );
//else
- set_val( get_val() + get_page() / 4.0 );
+ set_val(get_val() + get_page() / 4.0);
accept_event();
-
}
- if (b.button_index==4 && b.pressed) {
+ if (b.button_index == 4 && b.pressed) {
//if (orientation==HORIZONTAL)
// set_val( get_val() - get_page() / 4.0 );
//else
- set_val( get_val() - get_page() / 4.0 );
+ set_val(get_val() - get_page() / 4.0);
accept_event();
}
- if (b.button_index!=1)
+ if (b.button_index != 1)
return;
-
if (b.pressed) {
-
- double ofs = orientation==VERTICAL ? b.y : b.x ;
+ double ofs = orientation == VERTICAL ? b.y : b.x;
Ref<Texture> decr = get_icon("decrement");
Ref<Texture> incr = get_icon("increment");
- double decr_size = orientation==VERTICAL ? decr->get_height() : decr->get_width();
- double incr_size = orientation==VERTICAL ? incr->get_height() : incr->get_width();
+ double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
+ double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width();
double grabber_ofs = get_grabber_offset();
double grabber_size = get_grabber_size();
- double total = orientation==VERTICAL ? get_size().height : get_size().width;
+ double total = orientation == VERTICAL ? get_size().height : get_size().width;
- if (ofs < decr_size ) {
+ if (ofs < decr_size) {
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() - (custom_step >= 0 ? custom_step : get_step()));
break;
}
- if (ofs > total-incr_size ) {
+ if (ofs > total - incr_size) {
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() + (custom_step >= 0 ? custom_step : get_step()));
break;
}
- ofs-=decr_size;
+ ofs -= decr_size;
- if ( ofs < grabber_ofs ) {
+ if (ofs < grabber_ofs) {
- set_val( get_val() - get_page() );
+ set_val(get_val() - get_page());
break;
-
}
- ofs-=grabber_ofs;
+ ofs -= grabber_ofs;
- if (ofs < grabber_size ) {
+ if (ofs < grabber_size) {
- drag.active=true;
- drag.pos_at_click=grabber_ofs+ofs;
- drag.value_at_click=get_unit_value();
+ drag.active = true;
+ drag.pos_at_click = grabber_ofs + ofs;
+ drag.value_at_click = get_unit_value();
update();
} else {
-
- set_val( get_val() + get_page() );
+ set_val(get_val() + get_page());
}
-
} else {
- drag.active=false;
+ drag.active = false;
update();
}
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &m=p_event.mouse_motion;
+ const InputEventMouseMotion &m = p_event.mouse_motion;
accept_event();
-
if (drag.active) {
- double ofs = orientation==VERTICAL ? m.y : m.x ;
+ double ofs = orientation == VERTICAL ? m.y : m.x;
Ref<Texture> decr = get_icon("decrement");
- double decr_size = orientation==VERTICAL ? decr->get_height() : decr->get_width();
- ofs-=decr_size;
+ double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
+ ofs -= decr_size;
- double diff = (ofs-drag.pos_at_click) / get_area_size();
+ double diff = (ofs - drag.pos_at_click) / get_area_size();
- set_unit_value( drag.value_at_click + diff );
+ set_unit_value(drag.value_at_click + diff);
} else {
-
- double ofs = orientation==VERTICAL ? m.y : m.x ;
+ double ofs = orientation == VERTICAL ? m.y : m.x;
Ref<Texture> decr = get_icon("decrement");
Ref<Texture> incr = get_icon("increment");
- double decr_size = orientation==VERTICAL ? decr->get_height() : decr->get_width();
- double incr_size = orientation==VERTICAL ? incr->get_height() : incr->get_width();
- double total = orientation==VERTICAL ? get_size().height : get_size().width;
+ double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width();
+ double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width();
+ double total = orientation == VERTICAL ? get_size().height : get_size().width;
HiliteStatus new_hilite;
- if (ofs < decr_size ) {
+ if (ofs < decr_size) {
- new_hilite=HILITE_DECR;
+ new_hilite = HILITE_DECR;
- } else if (ofs > total-incr_size ) {
+ } else if (ofs > total - incr_size) {
- new_hilite=HILITE_INCR;
+ new_hilite = HILITE_INCR;
} else {
- new_hilite=HILITE_RANGE;
+ new_hilite = HILITE_RANGE;
}
- if (new_hilite!=hilite) {
+ if (new_hilite != hilite) {
- hilite=new_hilite;
+ hilite = new_hilite;
update();
-
}
-
}
} break;
case InputEvent::KEY: {
- const InputEventKey &k=p_event.key;
+ const InputEventKey &k = p_event.key;
if (!k.pressed)
return;
@@ -192,317 +179,296 @@ void ScrollBar::_input_event(InputEvent p_event) {
case KEY_LEFT: {
- if (orientation!=HORIZONTAL)
+ if (orientation != HORIZONTAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() - (custom_step >= 0 ? custom_step : get_step()));
} break;
case KEY_RIGHT: {
- if (orientation!=HORIZONTAL)
+ if (orientation != HORIZONTAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() + (custom_step >= 0 ? custom_step : get_step()));
} break;
case KEY_UP: {
- if (orientation!=VERTICAL)
+ if (orientation != VERTICAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
-
+ set_val(get_val() - (custom_step >= 0 ? custom_step : get_step()));
} break;
case KEY_DOWN: {
- if (orientation!=VERTICAL)
+ if (orientation != VERTICAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() + (custom_step >= 0 ? custom_step : get_step()));
} break;
case KEY_HOME: {
- set_val( get_min() );
+ set_val(get_min());
} break;
case KEY_END: {
- set_val( get_max() );
+ set_val(get_max());
} break;
-
- } break;
+ }
+ break;
}
}
}
void ScrollBar::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
- Ref<Texture> decr = hilite==HILITE_DECR ? get_icon("decrement_hilite") : get_icon("decrement");
- Ref<Texture> incr = hilite==HILITE_INCR ? get_icon("increment_hilite") : get_icon("increment");
+ Ref<Texture> decr = hilite == HILITE_DECR ? get_icon("decrement_hilite") : get_icon("decrement");
+ Ref<Texture> incr = hilite == HILITE_INCR ? get_icon("increment_hilite") : get_icon("increment");
Ref<StyleBox> bg = has_focus() ? get_stylebox("scroll_focus") : get_stylebox("scroll");
- Ref<StyleBox> grabber = (drag.active || hilite==HILITE_RANGE) ? get_stylebox("grabber_hilite") : get_stylebox("grabber");
+ Ref<StyleBox> grabber = (drag.active || hilite == HILITE_RANGE) ? get_stylebox("grabber_hilite") : get_stylebox("grabber");
Point2 ofs;
VisualServer *vs = VisualServer::get_singleton();
- vs->canvas_item_add_texture_rect( ci, Rect2( Point2(), decr->get_size()),decr->get_rid() );
+ vs->canvas_item_add_texture_rect(ci, Rect2(Point2(), decr->get_size()), decr->get_rid());
- if (orientation==HORIZONTAL)
- ofs.x+=decr->get_width();
+ if (orientation == HORIZONTAL)
+ ofs.x += decr->get_width();
else
- ofs.y+=decr->get_height();
+ ofs.y += decr->get_height();
- Size2 area=get_size();
+ Size2 area = get_size();
- if (orientation==HORIZONTAL)
- area.width-=incr->get_width()+decr->get_width();
+ if (orientation == HORIZONTAL)
+ area.width -= incr->get_width() + decr->get_width();
else
- area.height-=incr->get_height()+decr->get_height();
+ area.height -= incr->get_height() + decr->get_height();
- bg->draw(ci,Rect2(ofs,area));
+ bg->draw(ci, Rect2(ofs, area));
- if (orientation==HORIZONTAL)
- ofs.width+=area.width;
+ if (orientation == HORIZONTAL)
+ ofs.width += area.width;
else
- ofs.height+=area.height;
+ ofs.height += area.height;
- vs->canvas_item_add_texture_rect( ci, Rect2( ofs, decr->get_size()),incr->get_rid() );
+ vs->canvas_item_add_texture_rect(ci, Rect2(ofs, decr->get_size()), incr->get_rid());
Rect2 grabber_rect;
- if (orientation==HORIZONTAL) {
+ if (orientation == HORIZONTAL) {
- grabber_rect.size.width=get_grabber_size();
- grabber_rect.size.height=get_size().height;
- grabber_rect.pos.y=0;
- grabber_rect.pos.x=get_grabber_offset()+decr->get_width()+bg->get_margin( MARGIN_LEFT );
+ grabber_rect.size.width = get_grabber_size();
+ grabber_rect.size.height = get_size().height;
+ grabber_rect.pos.y = 0;
+ grabber_rect.pos.x = get_grabber_offset() + decr->get_width() + bg->get_margin(MARGIN_LEFT);
} else {
- grabber_rect.size.width=get_size().width;
- grabber_rect.size.height=get_grabber_size();
- grabber_rect.pos.y=get_grabber_offset()+decr->get_height()+bg->get_margin( MARGIN_TOP );
- grabber_rect.pos.x=0;
+ grabber_rect.size.width = get_size().width;
+ grabber_rect.size.height = get_grabber_size();
+ grabber_rect.pos.y = get_grabber_offset() + decr->get_height() + bg->get_margin(MARGIN_TOP);
+ grabber_rect.pos.x = 0;
}
- grabber->draw(ci,grabber_rect);
-
+ grabber->draw(ci, grabber_rect);
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
-
+ if (p_what == NOTIFICATION_ENTER_TREE) {
if (has_node(drag_slave_path)) {
Node *n = get_node(drag_slave_path);
- drag_slave=n->cast_to<Control>();
+ drag_slave = n->cast_to<Control>();
}
if (drag_slave) {
- drag_slave->connect("input_event",this,"_drag_slave_input");
- drag_slave->connect("exit_tree",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
+ drag_slave->connect("input_event", this, "_drag_slave_input");
+ drag_slave->connect("exit_tree", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
}
-
-
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
- drag_slave->disconnect("exit_tree",this,"_drag_slave_exit");
+ drag_slave->disconnect("input_event", this, "_drag_slave_input");
+ drag_slave->disconnect("exit_tree", this, "_drag_slave_exit");
}
- drag_slave=NULL;
-
+ drag_slave = NULL;
}
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
- if (drag_slave_touching) {
+ if (drag_slave_touching) {
if (drag_slave_touching_deaccel) {
- Vector2 pos = Vector2(orientation==HORIZONTAL?get_val():0,orientation==VERTICAL?get_val():0);
- pos+=drag_slave_speed*get_fixed_process_delta_time();
+ Vector2 pos = Vector2(orientation == HORIZONTAL ? get_val() : 0, orientation == VERTICAL ? get_val() : 0);
+ pos += drag_slave_speed * get_fixed_process_delta_time();
- bool turnoff=false;
+ bool turnoff = false;
- if (orientation==HORIZONTAL) {
+ if (orientation == HORIZONTAL) {
- if (pos.x<0) {
- pos.x=0;
- turnoff=true;
+ if (pos.x < 0) {
+ pos.x = 0;
+ turnoff = true;
}
- if (pos.x > (get_max()-get_page())) {
- pos.x=get_max()-get_page();
- turnoff=true;
+ if (pos.x > (get_max() - get_page())) {
+ pos.x = get_max() - get_page();
+ turnoff = true;
}
set_val(pos.x);
- float sgn_x = drag_slave_speed.x<0? -1 : 1;
+ float sgn_x = drag_slave_speed.x < 0 ? -1 : 1;
float val_x = Math::abs(drag_slave_speed.x);
- val_x-=1000*get_fixed_process_delta_time();
+ val_x -= 1000 * get_fixed_process_delta_time();
- if (val_x<0) {
- turnoff=true;
+ if (val_x < 0) {
+ turnoff = true;
}
- drag_slave_speed.x=sgn_x*val_x;
+ drag_slave_speed.x = sgn_x * val_x;
} else {
-
- if (pos.y<0) {
- pos.y=0;
- turnoff=true;
+ if (pos.y < 0) {
+ pos.y = 0;
+ turnoff = true;
}
- if (pos.y > (get_max()-get_page())) {
- pos.y=get_max()-get_page();
- turnoff=true;
+ if (pos.y > (get_max() - get_page())) {
+ pos.y = get_max() - get_page();
+ turnoff = true;
}
set_val(pos.y);
- float sgn_y = drag_slave_speed.y<0? -1 : 1;
+ float sgn_y = drag_slave_speed.y < 0 ? -1 : 1;
float val_y = Math::abs(drag_slave_speed.y);
- val_y-=1000*get_fixed_process_delta_time();
+ val_y -= 1000 * get_fixed_process_delta_time();
- if (val_y<0) {
- turnoff=true;
+ if (val_y < 0) {
+ turnoff = true;
}
- drag_slave_speed.y=sgn_y*val_y;
+ drag_slave_speed.y = sgn_y * val_y;
}
-
if (turnoff) {
set_fixed_process(false);
- drag_slave_touching=false;
- drag_slave_touching_deaccel=false;
+ drag_slave_touching = false;
+ drag_slave_touching_deaccel = false;
}
-
} else {
-
- if (time_since_motion==0 || time_since_motion>0.1) {
+ if (time_since_motion == 0 || time_since_motion > 0.1) {
Vector2 diff = drag_slave_accum - last_drag_slave_accum;
- last_drag_slave_accum=drag_slave_accum;
- drag_slave_speed=diff/get_fixed_process_delta_time();
+ last_drag_slave_accum = drag_slave_accum;
+ drag_slave_speed = diff / get_fixed_process_delta_time();
}
- time_since_motion+=get_fixed_process_delta_time();
+ time_since_motion += get_fixed_process_delta_time();
}
}
-
-
}
- if (p_what==NOTIFICATION_MOUSE_EXIT) {
+ if (p_what == NOTIFICATION_MOUSE_EXIT) {
- hilite=HILITE_NONE;
+ hilite = HILITE_NONE;
update();
}
}
double ScrollBar::get_grabber_min_size() const {
- Ref<StyleBox> grabber=get_stylebox("grabber");
- Size2 gminsize=grabber->get_minimum_size()+grabber->get_center_size();
- return (orientation==VERTICAL)?gminsize.height:gminsize.width;
+ Ref<StyleBox> grabber = get_stylebox("grabber");
+ Size2 gminsize = grabber->get_minimum_size() + grabber->get_center_size();
+ return (orientation == VERTICAL) ? gminsize.height : gminsize.width;
}
double ScrollBar::get_grabber_size() const {
- float range = get_max()-get_min();
- if (range<=0)
+ float range = get_max() - get_min();
+ if (range <= 0)
return 0;
- float page = (get_page()>0)? get_page() : 0;
-// if (grabber_range < get_step())
-// grabber_range=get_step();
+ float page = (get_page() > 0) ? get_page() : 0;
+ // if (grabber_range < get_step())
+ // grabber_range=get_step();
- double area_size=get_area_size();
+ double area_size = get_area_size();
double grabber_size = page / range * area_size;
- return grabber_size+get_grabber_min_size();
-
+ return grabber_size + get_grabber_min_size();
}
double ScrollBar::get_area_size() const {
- if (orientation==VERTICAL) {
+ if (orientation == VERTICAL) {
- double area=get_size().height;
- area-=get_stylebox("scroll")->get_minimum_size().height;
- area-=get_icon("increment")->get_height();
- area-=get_icon("decrement")->get_height();
- area-=get_grabber_min_size();
+ double area = get_size().height;
+ area -= get_stylebox("scroll")->get_minimum_size().height;
+ area -= get_icon("increment")->get_height();
+ area -= get_icon("decrement")->get_height();
+ area -= get_grabber_min_size();
return area;
- } else if (orientation==HORIZONTAL) {
+ } else if (orientation == HORIZONTAL) {
- double area=get_size().width;
- area-=get_stylebox("scroll")->get_minimum_size().width;
- area-=get_icon("increment")->get_width();
- area-=get_icon("decrement")->get_width();
- area-=get_grabber_min_size();
+ double area = get_size().width;
+ area -= get_stylebox("scroll")->get_minimum_size().width;
+ area -= get_icon("increment")->get_width();
+ area -= get_icon("decrement")->get_width();
+ area -= get_grabber_min_size();
return area;
} else {
return 0;
}
-
}
double ScrollBar::get_area_offset() const {
- double ofs=0;
-
- if (orientation==VERTICAL) {
+ double ofs = 0;
- ofs+=get_stylebox("hscroll")->get_margin( MARGIN_TOP );
- ofs+=get_icon("decrement")->get_height();
+ if (orientation == VERTICAL) {
+ ofs += get_stylebox("hscroll")->get_margin(MARGIN_TOP);
+ ofs += get_icon("decrement")->get_height();
}
- if (orientation==HORIZONTAL) {
+ if (orientation == HORIZONTAL) {
- ofs+=get_stylebox("hscroll")->get_margin( MARGIN_LEFT );
- ofs+=get_icon("decrement")->get_width();
+ ofs += get_stylebox("hscroll")->get_margin(MARGIN_LEFT);
+ ofs += get_icon("decrement")->get_width();
}
return ofs;
}
-double ScrollBar::get_click_pos(const Point2& p_pos) const {
+double ScrollBar::get_click_pos(const Point2 &p_pos) const {
+ float pos = (orientation == VERTICAL) ? p_pos.y : p_pos.x;
+ pos -= get_area_offset();
- float pos=(orientation==VERTICAL)?p_pos.y:p_pos.x;
- pos-=get_area_offset();
-
- float area=get_area_size();
- if (area==0)
+ float area = get_area_size();
+ if (area == 0)
return 0;
else
- return pos/area;
-
+ return pos / area;
}
double ScrollBar::get_grabber_offset() const {
-
return (get_area_size()) * get_unit_value();
-
}
-
-
Size2 ScrollBar::get_minimum_size() const {
Ref<Texture> incr = get_icon("increment");
@@ -510,31 +476,30 @@ Size2 ScrollBar::get_minimum_size() const {
Ref<StyleBox> bg = get_stylebox("scroll");
Size2 minsize;
- if (orientation==VERTICAL) {
+ if (orientation == VERTICAL) {
- minsize.width=MAX(incr->get_size().width,(bg->get_minimum_size()+bg->get_center_size()).width);
- minsize.height+=incr->get_size().height;
- minsize.height+=decr->get_size().height;
- minsize.height+=bg->get_minimum_size().height;
- minsize.height+=get_grabber_min_size();
+ minsize.width = MAX(incr->get_size().width, (bg->get_minimum_size() + bg->get_center_size()).width);
+ minsize.height += incr->get_size().height;
+ minsize.height += decr->get_size().height;
+ minsize.height += bg->get_minimum_size().height;
+ minsize.height += get_grabber_min_size();
}
- if (orientation==HORIZONTAL) {
+ if (orientation == HORIZONTAL) {
- minsize.height=MAX(incr->get_size().height,(bg->get_center_size()+bg->get_minimum_size()).height);
- minsize.width+=incr->get_size().width;
- minsize.width+=decr->get_size().width;
- minsize.width+=bg->get_minimum_size().width;
- minsize.width+=get_grabber_min_size();
+ minsize.height = MAX(incr->get_size().height, (bg->get_center_size() + bg->get_minimum_size()).height);
+ minsize.width += incr->get_size().width;
+ minsize.width += decr->get_size().width;
+ minsize.width += bg->get_minimum_size().width;
+ minsize.width += get_grabber_min_size();
}
return minsize;
-
}
void ScrollBar::set_custom_step(float p_custom_step) {
- custom_step=p_custom_step;
+ custom_step = p_custom_step;
}
float ScrollBar::get_custom_step() const {
@@ -542,53 +507,50 @@ float ScrollBar::get_custom_step() const {
return custom_step;
}
-
void ScrollBar::_drag_slave_exit() {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
+ drag_slave->disconnect("input_event", this, "_drag_slave_input");
}
- drag_slave=NULL;
+ drag_slave = NULL;
}
+void ScrollBar::_drag_slave_input(const InputEvent &p_input) {
-void ScrollBar::_drag_slave_input(const InputEvent& p_input) {
-
- switch(p_input.type) {
+ switch (p_input.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_input.mouse_button;
+ const InputEventMouseButton &mb = p_input.mouse_button;
- if (mb.button_index!=1)
+ if (mb.button_index != 1)
break;
if (mb.pressed) {
if (drag_slave_touching) {
set_fixed_process(false);
- drag_slave_touching_deaccel=false;
- drag_slave_touching=false;
- drag_slave_speed=Vector2();
- drag_slave_accum=Vector2();
- last_drag_slave_accum=Vector2();
- drag_slave_from=Vector2();
+ drag_slave_touching_deaccel = false;
+ drag_slave_touching = false;
+ drag_slave_speed = Vector2();
+ drag_slave_accum = Vector2();
+ last_drag_slave_accum = Vector2();
+ drag_slave_from = Vector2();
}
if (true) {
- drag_slave_speed=Vector2();
- drag_slave_accum=Vector2();
- last_drag_slave_accum=Vector2();
+ drag_slave_speed = Vector2();
+ drag_slave_accum = Vector2();
+ last_drag_slave_accum = Vector2();
//drag_slave_from=Vector2(h_scroll->get_val(),v_scroll->get_val());
- drag_slave_from= Vector2(orientation==HORIZONTAL?get_val():0,orientation==VERTICAL?get_val():0);
+ drag_slave_from = Vector2(orientation == HORIZONTAL ? get_val() : 0, orientation == VERTICAL ? get_val() : 0);
- drag_slave_touching=OS::get_singleton()->has_touchscreen_ui_hint();
- drag_slave_touching_deaccel=false;
- time_since_motion=0;
+ drag_slave_touching = OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_slave_touching_deaccel = false;
+ time_since_motion = 0;
if (drag_slave_touching) {
set_fixed_process(true);
- time_since_motion=0;
-
+ time_since_motion = 0;
}
}
@@ -596,78 +558,75 @@ void ScrollBar::_drag_slave_input(const InputEvent& p_input) {
if (drag_slave_touching) {
- if (drag_slave_speed==Vector2()) {
- drag_slave_touching_deaccel=false;
- drag_slave_touching=false;
+ if (drag_slave_speed == Vector2()) {
+ drag_slave_touching_deaccel = false;
+ drag_slave_touching = false;
set_fixed_process(false);
} else {
- drag_slave_touching_deaccel=true;
+ drag_slave_touching_deaccel = true;
}
}
}
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_input.mouse_motion;
+ const InputEventMouseMotion &mm = p_input.mouse_motion;
- if (drag_slave_touching && ! drag_slave_touching_deaccel) {
+ if (drag_slave_touching && !drag_slave_touching_deaccel) {
- Vector2 motion = Vector2(mm.relative_x,mm.relative_y);
+ Vector2 motion = Vector2(mm.relative_x, mm.relative_y);
- drag_slave_accum-=motion;
- Vector2 diff = drag_slave_from+drag_slave_accum;
+ drag_slave_accum -= motion;
+ Vector2 diff = drag_slave_from + drag_slave_accum;
- if (orientation==HORIZONTAL)
+ if (orientation == HORIZONTAL)
set_val(diff.x);
//else
// drag_slave_accum.x=0;
- if (orientation==VERTICAL)
+ if (orientation == VERTICAL)
set_val(diff.y);
//else
// drag_slave_accum.y=0;
- time_since_motion=0;
+ time_since_motion = 0;
}
} break;
}
}
-void ScrollBar::set_drag_slave(const NodePath& p_path) {
+void ScrollBar::set_drag_slave(const NodePath &p_path) {
if (is_inside_tree()) {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
- drag_slave->disconnect("exit_tree",this,"_drag_slave_exit");
+ drag_slave->disconnect("input_event", this, "_drag_slave_input");
+ drag_slave->disconnect("exit_tree", this, "_drag_slave_exit");
}
}
- drag_slave=NULL;
- drag_slave_path=p_path;
+ drag_slave = NULL;
+ drag_slave_path = p_path;
if (is_inside_tree()) {
if (has_node(p_path)) {
Node *n = get_node(p_path);
- drag_slave=n->cast_to<Control>();
+ drag_slave = n->cast_to<Control>();
}
if (drag_slave) {
- drag_slave->connect("input_event",this,"_drag_slave_input");
- drag_slave->connect("exit_tree",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
+ drag_slave->connect("input_event", this, "_drag_slave_input");
+ drag_slave->connect("exit_tree", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
}
}
}
-NodePath ScrollBar::get_drag_slave() const{
-
+NodePath ScrollBar::get_drag_slave() const {
return drag_slave_path;
}
-
-
#if 0
void ScrollBar::mouse_button(const Point2& p_pos, int b.button_index,bool b.pressed,int p_modifier_mask) {
@@ -798,48 +757,36 @@ bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b.pr
return true;
}
-
-
#endif
void ScrollBar::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&ScrollBar::_input_event);
- ObjectTypeDB::bind_method(_MD("set_custom_step","step"),&ScrollBar::set_custom_step);
- ObjectTypeDB::bind_method(_MD("get_custom_step"),&ScrollBar::get_custom_step);
- ObjectTypeDB::bind_method(_MD("_drag_slave_input"),&ScrollBar::_drag_slave_input);
- ObjectTypeDB::bind_method(_MD("_drag_slave_exit"),&ScrollBar::_drag_slave_exit);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_step",PROPERTY_HINT_RANGE,"-1,4096"), _SCS("set_custom_step"),_SCS("get_custom_step"));
+ ObjectTypeDB::bind_method(_MD("_input_event"), &ScrollBar::_input_event);
+ ObjectTypeDB::bind_method(_MD("set_custom_step", "step"), &ScrollBar::set_custom_step);
+ ObjectTypeDB::bind_method(_MD("get_custom_step"), &ScrollBar::get_custom_step);
+ ObjectTypeDB::bind_method(_MD("_drag_slave_input"), &ScrollBar::_drag_slave_input);
+ ObjectTypeDB::bind_method(_MD("_drag_slave_exit"), &ScrollBar::_drag_slave_exit);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "custom_step", PROPERTY_HINT_RANGE, "-1,4096"), _SCS("set_custom_step"), _SCS("get_custom_step"));
}
+ScrollBar::ScrollBar(Orientation p_orientation) {
-ScrollBar::ScrollBar(Orientation p_orientation)
-{
+ orientation = p_orientation;
+ hilite = HILITE_NONE;
+ custom_step = -1;
+ drag_slave = NULL;
+ drag.active = false;
- orientation=p_orientation;
- hilite=HILITE_NONE;
- custom_step=-1;
- drag_slave=NULL;
-
- drag.active=false;
-
- drag_slave_speed=Vector2();
- drag_slave_touching=false;
- drag_slave_touching_deaccel=false;
+ drag_slave_speed = Vector2();
+ drag_slave_touching = false;
+ drag_slave_touching_deaccel = false;
if (focus_by_default)
- set_focus_mode( FOCUS_ALL );
+ set_focus_mode(FOCUS_ALL);
set_step(0);
-
}
-
-
-ScrollBar::~ScrollBar()
-{
+ScrollBar::~ScrollBar() {
}
-
-
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index 0e7991205..7f078a1cb 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -31,13 +31,12 @@
#include "scene/gui/range.h"
-
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class ScrollBar : public Range {
- OBJ_TYPE( ScrollBar, Range );
+ OBJ_TYPE(ScrollBar, Range);
enum HiliteStatus {
HILITE_NONE,
@@ -61,17 +60,16 @@ class ScrollBar : public Range {
float value_at_click;
} drag;
-
double get_grabber_size() const;
double get_grabber_min_size() const;
double get_area_size() const;
double get_area_offset() const;
- double get_click_pos(const Point2& p_pos) const;
+ double get_click_pos(const Point2 &p_pos) const;
double get_grabber_offset() const;
static void set_can_focus_by_default(bool p_can_focus);
- Node* drag_slave;
+ Node *drag_slave;
NodePath drag_slave_path;
Vector2 drag_slave_speed;
@@ -85,43 +83,43 @@ class ScrollBar : public Range {
bool click_handled;
void _drag_slave_exit();
- void _drag_slave_input(const InputEvent& p_input);
+ void _drag_slave_input(const InputEvent &p_input);
void _input_event(InputEvent p_event);
+
protected:
void _notification(int p_what);
static void _bind_methods();
public:
-
void set_custom_step(float p_custom_step);
float get_custom_step() const;
- void set_drag_slave(const NodePath& p_path);
+ void set_drag_slave(const NodePath &p_path);
NodePath get_drag_slave() const;
virtual Size2 get_minimum_size() const;
- ScrollBar(Orientation p_orientation=VERTICAL);
+ ScrollBar(Orientation p_orientation = VERTICAL);
~ScrollBar();
-
};
class HScrollBar : public ScrollBar {
- OBJ_TYPE( HScrollBar, ScrollBar );
-public:
+ OBJ_TYPE(HScrollBar, ScrollBar);
- HScrollBar() : ScrollBar(HORIZONTAL) { set_v_size_flags(0); }
+public:
+ HScrollBar()
+ : ScrollBar(HORIZONTAL) { set_v_size_flags(0); }
};
class VScrollBar : public ScrollBar {
- OBJ_TYPE( VScrollBar, ScrollBar );
-public:
+ OBJ_TYPE(VScrollBar, ScrollBar);
- VScrollBar() : ScrollBar(VERTICAL) { set_h_size_flags(0); }
+public:
+ VScrollBar()
+ : ScrollBar(VERTICAL) { set_h_size_flags(0); }
};
-
#endif
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index c92f57392..686ab3921 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -35,10 +35,9 @@ bool ScrollContainer::clips_input() const {
Size2 ScrollContainer::get_minimum_size() const {
-
Size2 min_size;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -49,161 +48,150 @@ Size2 ScrollContainer::get_minimum_size() const {
continue;
Size2 minsize = c->get_combined_minimum_size();
-
if (!scroll_h) {
min_size.x = MAX(min_size.x, minsize.x);
}
if (!scroll_v) {
min_size.y = MAX(min_size.y, minsize.y);
-
}
}
if (h_scroll->is_visible()) {
- min_size.y+=h_scroll->get_minimum_size().y;
+ min_size.y += h_scroll->get_minimum_size().y;
}
if (v_scroll->is_visible()) {
- min_size.x+=v_scroll->get_minimum_size().x;
+ min_size.x += v_scroll->get_minimum_size().x;
}
return min_size;
};
-
void ScrollContainer::_cancel_drag() {
set_fixed_process(false);
- drag_touching_deaccel=false;
- drag_touching=false;
- drag_speed=Vector2();
- drag_accum=Vector2();
- last_drag_accum=Vector2();
- drag_from=Vector2();
+ drag_touching_deaccel = false;
+ drag_touching = false;
+ drag_speed = Vector2();
+ drag_accum = Vector2();
+ last_drag_accum = Vector2();
+ drag_from = Vector2();
}
-void ScrollContainer::_input_event(const InputEvent& p_input_event) {
+void ScrollContainer::_input_event(const InputEvent &p_input_event) {
-
- switch(p_input_event.type) {
+ switch (p_input_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_input_event.mouse_button;
+ const InputEventMouseButton &mb = p_input_event.mouse_button;
- if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) {
- if (h_scroll->is_visible() && !v_scroll->is_visible()){
+ if (mb.button_index == BUTTON_WHEEL_UP && mb.pressed) {
+ if (h_scroll->is_visible() && !v_scroll->is_visible()) {
// only horizontal is enabled, scroll horizontally
- h_scroll->set_val( h_scroll->get_val()-h_scroll->get_page()/8 );
+ h_scroll->set_val(h_scroll->get_val() - h_scroll->get_page() / 8);
} else if (v_scroll->is_visible()) {
- v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 );
+ v_scroll->set_val(v_scroll->get_val() - v_scroll->get_page() / 8);
}
}
- if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) {
- if (h_scroll->is_visible() && !v_scroll->is_visible()){
+ if (mb.button_index == BUTTON_WHEEL_DOWN && mb.pressed) {
+ if (h_scroll->is_visible() && !v_scroll->is_visible()) {
// only horizontal is enabled, scroll horizontally
- h_scroll->set_val( h_scroll->get_val()+h_scroll->get_page()/8 );
+ h_scroll->set_val(h_scroll->get_val() + h_scroll->get_page() / 8);
} else if (v_scroll->is_visible()) {
- v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 );
+ v_scroll->set_val(v_scroll->get_val() + v_scroll->get_page() / 8);
}
}
- if(!OS::get_singleton()->has_touchscreen_ui_hint())
+ if (!OS::get_singleton()->has_touchscreen_ui_hint())
return;
- if (mb.button_index!=BUTTON_LEFT)
+ if (mb.button_index != BUTTON_LEFT)
break;
if (mb.pressed) {
if (drag_touching) {
set_fixed_process(false);
- drag_touching_deaccel=false;
- drag_touching=false;
- drag_speed=Vector2();
- drag_accum=Vector2();
- last_drag_accum=Vector2();
- drag_from=Vector2();
+ drag_touching_deaccel = false;
+ drag_touching = false;
+ drag_speed = Vector2();
+ drag_accum = Vector2();
+ last_drag_accum = Vector2();
+ drag_from = Vector2();
}
if (true) {
- drag_speed=Vector2();
- drag_accum=Vector2();
- last_drag_accum=Vector2();
- drag_from=Vector2(h_scroll->get_val(),v_scroll->get_val());
- drag_touching=OS::get_singleton()->has_touchscreen_ui_hint();
- drag_touching_deaccel=false;
- time_since_motion=0;
+ drag_speed = Vector2();
+ drag_accum = Vector2();
+ last_drag_accum = Vector2();
+ drag_from = Vector2(h_scroll->get_val(), v_scroll->get_val());
+ drag_touching = OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_touching_deaccel = false;
+ time_since_motion = 0;
if (drag_touching) {
set_fixed_process(true);
- time_since_motion=0;
-
+ time_since_motion = 0;
}
}
-
} else {
if (drag_touching) {
- if (drag_speed==Vector2()) {
- drag_touching_deaccel=false;
- drag_touching=false;
+ if (drag_speed == Vector2()) {
+ drag_touching_deaccel = false;
+ drag_touching = false;
set_fixed_process(false);
} else {
- drag_touching_deaccel=true;
+ drag_touching_deaccel = true;
}
}
}
-
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_input_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_input_event.mouse_motion;
- if (drag_touching && ! drag_touching_deaccel) {
+ if (drag_touching && !drag_touching_deaccel) {
- Vector2 motion = Vector2(mm.relative_x,mm.relative_y);
- drag_accum-=motion;
- Vector2 diff = drag_from+drag_accum;
+ Vector2 motion = Vector2(mm.relative_x, mm.relative_y);
+ drag_accum -= motion;
+ Vector2 diff = drag_from + drag_accum;
if (scroll_h)
h_scroll->set_val(diff.x);
else
- drag_accum.x=0;
+ drag_accum.x = 0;
if (scroll_v)
v_scroll->set_val(diff.y);
else
- drag_accum.y=0;
- time_since_motion=0;
+ drag_accum.y = 0;
+ time_since_motion = 0;
}
} break;
}
-
}
-
void ScrollContainer::_update_scrollbar_pos() {
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
- v_scroll->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,vmin.width);
- v_scroll->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,0);
- v_scroll->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,0);
- v_scroll->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,0);
+ v_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, vmin.width);
+ v_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ v_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0);
+ v_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
- h_scroll->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,0);
- h_scroll->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,0);
- h_scroll->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,hmin.height);
- h_scroll->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,0);
+ h_scroll->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 0);
+ h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
+ h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, hmin.height);
+ h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
h_scroll->raise();
v_scroll->raise();
-
}
-
void ScrollContainer::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
@@ -211,18 +199,17 @@ void ScrollContainer::_notification(int p_what) {
call_deferred("_update_scrollbar_pos");
};
-
- if (p_what==NOTIFICATION_SORT_CHILDREN) {
+ if (p_what == NOTIFICATION_SORT_CHILDREN) {
child_max_size = Size2(0, 0);
Size2 size = get_size();
if (h_scroll->is_visible())
- size.y-=h_scroll->get_minimum_size().y;
+ size.y -= h_scroll->get_minimum_size().y;
if (v_scroll->is_visible())
- size.x-=h_scroll->get_minimum_size().x;
+ size.x -= h_scroll->get_minimum_size().x;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -235,24 +222,23 @@ void ScrollContainer::_notification(int p_what) {
child_max_size.x = MAX(child_max_size.x, minsize.x);
child_max_size.y = MAX(child_max_size.y, minsize.y);
- Rect2 r = Rect2(-scroll,minsize);
- if (!scroll_h || (!h_scroll->is_visible() && c->get_h_size_flags()&SIZE_EXPAND)) {
- r.pos.x=0;
- if (c->get_h_size_flags()&SIZE_EXPAND)
- r.size.width=MAX(size.width,minsize.width);
+ Rect2 r = Rect2(-scroll, minsize);
+ if (!scroll_h || (!h_scroll->is_visible() && c->get_h_size_flags() & SIZE_EXPAND)) {
+ r.pos.x = 0;
+ if (c->get_h_size_flags() & SIZE_EXPAND)
+ r.size.width = MAX(size.width, minsize.width);
else
- r.size.width=minsize.width;
+ r.size.width = minsize.width;
}
- if (!scroll_v || (!v_scroll->is_visible() && c->get_v_size_flags()&SIZE_EXPAND)) {
- r.pos.y=0;
- r.size.height=size.height;
- if (c->get_v_size_flags()&SIZE_EXPAND)
- r.size.height=MAX(size.height,minsize.height);
+ if (!scroll_v || (!v_scroll->is_visible() && c->get_v_size_flags() & SIZE_EXPAND)) {
+ r.pos.y = 0;
+ r.size.height = size.height;
+ if (c->get_v_size_flags() & SIZE_EXPAND)
+ r.size.height = MAX(size.height, minsize.height);
else
- r.size.height=minsize.height;
-
+ r.size.height = minsize.height;
}
- fit_child_in_rect(c,r);
+ fit_child_in_rect(c, r);
}
update();
};
@@ -261,37 +247,37 @@ void ScrollContainer::_notification(int p_what) {
update_scrollbars();
- VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
+ VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
}
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
- if (drag_touching) {
+ if (drag_touching) {
if (drag_touching_deaccel) {
- Vector2 pos = Vector2(h_scroll->get_val(),v_scroll->get_val());
- pos+=drag_speed*get_fixed_process_delta_time();
+ Vector2 pos = Vector2(h_scroll->get_val(), v_scroll->get_val());
+ pos += drag_speed * get_fixed_process_delta_time();
- bool turnoff_h=false;
- bool turnoff_v=false;
+ bool turnoff_h = false;
+ bool turnoff_v = false;
- if (pos.x<0) {
- pos.x=0;
- turnoff_h=true;
+ if (pos.x < 0) {
+ pos.x = 0;
+ turnoff_h = true;
}
- if (pos.x > (h_scroll->get_max()-h_scroll->get_page())) {
- pos.x=h_scroll->get_max()-h_scroll->get_page();
- turnoff_h=true;
+ if (pos.x > (h_scroll->get_max() - h_scroll->get_page())) {
+ pos.x = h_scroll->get_max() - h_scroll->get_page();
+ turnoff_h = true;
}
- if (pos.y<0) {
- pos.y=0;
- turnoff_v=true;
+ if (pos.y < 0) {
+ pos.y = 0;
+ turnoff_v = true;
}
- if (pos.y > (v_scroll->get_max()-v_scroll->get_page())) {
- pos.y=v_scroll->get_max()-v_scroll->get_page();
- turnoff_v=true;
+ if (pos.y > (v_scroll->get_max() - v_scroll->get_page())) {
+ pos.y = v_scroll->get_max() - v_scroll->get_page();
+ turnoff_v = true;
}
if (scroll_h)
@@ -299,48 +285,43 @@ void ScrollContainer::_notification(int p_what) {
if (scroll_v)
v_scroll->set_val(pos.y);
- float sgn_x = drag_speed.x<0? -1 : 1;
+ float sgn_x = drag_speed.x < 0 ? -1 : 1;
float val_x = Math::abs(drag_speed.x);
- val_x-=1000*get_fixed_process_delta_time();
+ val_x -= 1000 * get_fixed_process_delta_time();
- if (val_x<0) {
- turnoff_h=true;
+ if (val_x < 0) {
+ turnoff_h = true;
}
-
- float sgn_y = drag_speed.y<0? -1 : 1;
+ float sgn_y = drag_speed.y < 0 ? -1 : 1;
float val_y = Math::abs(drag_speed.y);
- val_y-=1000*get_fixed_process_delta_time();
+ val_y -= 1000 * get_fixed_process_delta_time();
- if (val_y<0) {
- turnoff_v=true;
+ if (val_y < 0) {
+ turnoff_v = true;
}
-
- drag_speed=Vector2(sgn_x*val_x,sgn_y*val_y);
+ drag_speed = Vector2(sgn_x * val_x, sgn_y * val_y);
if (turnoff_h && turnoff_v) {
set_fixed_process(false);
- drag_touching=false;
- drag_touching_deaccel=false;
+ drag_touching = false;
+ drag_touching_deaccel = false;
}
-
} else {
-
- if (time_since_motion==0 || time_since_motion>0.1) {
+ if (time_since_motion == 0 || time_since_motion > 0.1) {
Vector2 diff = drag_accum - last_drag_accum;
- last_drag_accum=drag_accum;
- drag_speed=diff/get_fixed_process_delta_time();
+ last_drag_accum = drag_accum;
+ drag_speed = diff / get_fixed_process_delta_time();
}
- time_since_motion+=get_fixed_process_delta_time();
+ time_since_motion += get_fixed_process_delta_time();
}
}
}
-
};
void ScrollContainer::update_scrollbars() {
@@ -355,66 +336,62 @@ void ScrollContainer::update_scrollbars() {
if (!scroll_v || min.height <= size.height - hmin.height) {
v_scroll->hide();
- scroll.y=0;
+ scroll.y = 0;
} else {
v_scroll->show();
- scroll.y=v_scroll->get_val();
-
+ scroll.y = v_scroll->get_val();
}
v_scroll->set_max(min.height);
v_scroll->set_page(size.height - hmin.height);
-
if (!scroll_h || min.width <= size.width - vmin.width) {
h_scroll->hide();
- scroll.x=0;
+ scroll.x = 0;
} else {
h_scroll->show();
h_scroll->set_max(min.width);
h_scroll->set_page(size.width - vmin.width);
- scroll.x=h_scroll->get_val();
+ scroll.x = h_scroll->get_val();
}
}
void ScrollContainer::_scroll_moved(float) {
- scroll.x=h_scroll->get_val();
- scroll.y=v_scroll->get_val();
+ scroll.x = h_scroll->get_val();
+ scroll.y = v_scroll->get_val();
queue_sort();
update();
};
-
void ScrollContainer::set_enable_h_scroll(bool p_enable) {
- scroll_h=p_enable;
+ scroll_h = p_enable;
queue_sort();
}
-bool ScrollContainer::is_h_scroll_enabled() const{
+bool ScrollContainer::is_h_scroll_enabled() const {
return scroll_h;
}
void ScrollContainer::set_enable_v_scroll(bool p_enable) {
- scroll_v=p_enable;
+ scroll_v = p_enable;
queue_sort();
}
-bool ScrollContainer::is_v_scroll_enabled() const{
+bool ScrollContainer::is_v_scroll_enabled() const {
return scroll_v;
}
int ScrollContainer::get_v_scroll() const {
-
return v_scroll->get_val();
}
void ScrollContainer::set_v_scroll(int p_pos) {
@@ -431,27 +408,24 @@ void ScrollContainer::set_h_scroll(int p_pos) {
h_scroll->set_val(p_pos);
_cancel_drag();
-
}
-
void ScrollContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&ScrollContainer::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_input_event"),&ScrollContainer::_input_event);
- ObjectTypeDB::bind_method(_MD("set_enable_h_scroll","enable"),&ScrollContainer::set_enable_h_scroll);
- ObjectTypeDB::bind_method(_MD("is_h_scroll_enabled"),&ScrollContainer::is_h_scroll_enabled);
- ObjectTypeDB::bind_method(_MD("set_enable_v_scroll","enable"),&ScrollContainer::set_enable_v_scroll);
- ObjectTypeDB::bind_method(_MD("is_v_scroll_enabled"),&ScrollContainer::is_v_scroll_enabled);
- ObjectTypeDB::bind_method(_MD("_update_scrollbar_pos"),&ScrollContainer::_update_scrollbar_pos);
- ObjectTypeDB::bind_method(_MD("set_h_scroll","val"),&ScrollContainer::set_h_scroll);
- ObjectTypeDB::bind_method(_MD("get_h_scroll"),&ScrollContainer::get_h_scroll);
- ObjectTypeDB::bind_method(_MD("set_v_scroll","val"),&ScrollContainer::set_v_scroll);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&ScrollContainer::get_v_scroll);
-
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll/horizontal"), _SCS("set_enable_h_scroll"),_SCS("is_h_scroll_enabled"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll/vertical"), _SCS("set_enable_v_scroll"),_SCS("is_v_scroll_enabled"));
+ ObjectTypeDB::bind_method(_MD("_scroll_moved"), &ScrollContainer::_scroll_moved);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &ScrollContainer::_input_event);
+ ObjectTypeDB::bind_method(_MD("set_enable_h_scroll", "enable"), &ScrollContainer::set_enable_h_scroll);
+ ObjectTypeDB::bind_method(_MD("is_h_scroll_enabled"), &ScrollContainer::is_h_scroll_enabled);
+ ObjectTypeDB::bind_method(_MD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll);
+ ObjectTypeDB::bind_method(_MD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled);
+ ObjectTypeDB::bind_method(_MD("_update_scrollbar_pos"), &ScrollContainer::_update_scrollbar_pos);
+ ObjectTypeDB::bind_method(_MD("set_h_scroll", "val"), &ScrollContainer::set_h_scroll);
+ ObjectTypeDB::bind_method(_MD("get_h_scroll"), &ScrollContainer::get_h_scroll);
+ ObjectTypeDB::bind_method(_MD("set_v_scroll", "val"), &ScrollContainer::set_v_scroll);
+ ObjectTypeDB::bind_method(_MD("get_v_scroll"), &ScrollContainer::get_v_scroll);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll/horizontal"), _SCS("set_enable_h_scroll"), _SCS("is_h_scroll_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scroll/vertical"), _SCS("set_enable_v_scroll"), _SCS("is_v_scroll_enabled"));
};
ScrollContainer::ScrollContainer() {
@@ -464,15 +438,12 @@ ScrollContainer::ScrollContainer() {
v_scroll->set_name("_v_scroll");
add_child(v_scroll);
- h_scroll->connect("value_changed", this,"_scroll_moved");
- v_scroll->connect("value_changed", this,"_scroll_moved");
-
- drag_speed=Vector2();
- drag_touching=false;
- drag_touching_deaccel=false;
- scroll_h=true;
- scroll_v=true;
-
+ h_scroll->connect("value_changed", this, "_scroll_moved");
+ v_scroll->connect("value_changed", this, "_scroll_moved");
+ drag_speed = Vector2();
+ drag_touching = false;
+ drag_touching_deaccel = false;
+ scroll_h = true;
+ scroll_v = true;
};
-
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index f6832acf6..813bfd965 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -37,8 +37,8 @@ class ScrollContainer : public Container {
OBJ_TYPE(ScrollContainer, Container);
- HScrollBar* h_scroll;
- VScrollBar* v_scroll;
+ HScrollBar *h_scroll;
+ VScrollBar *v_scroll;
Size2 child_max_size;
Size2 scroll;
@@ -63,16 +63,15 @@ class ScrollContainer : public Container {
protected:
Size2 get_minimum_size() const;
-
- void _input_event(const InputEvent& p_input_event);
+ void _input_event(const InputEvent &p_input_event);
void _notification(int p_what);
void _scroll_moved(float);
static void _bind_methods();
void _update_scrollbar_pos();
-public:
+public:
int get_v_scroll() const;
void set_v_scroll(int p_pos);
diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp
index 32bd2239f..e256b8f92 100644
--- a/scene/gui/separator.cpp
+++ b/scene/gui/separator.cpp
@@ -28,54 +28,47 @@
/*************************************************************************/
#include "separator.h"
-
Size2 Separator::get_minimum_size() const {
- Size2 ms(3,3);
- ms[orientation]=get_constant("separation");
+ Size2 ms(3, 3);
+ ms[orientation] = get_constant("separation");
return ms;
-
-
}
void Separator::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
Size2i size = get_size();
Ref<StyleBox> style = get_stylebox("separator");
- Size2i ssize=style->get_minimum_size()+style->get_center_size();
+ Size2i ssize = style->get_minimum_size() + style->get_center_size();
- if (orientation==VERTICAL) {
+ if (orientation == VERTICAL) {
- style->draw(get_canvas_item(),Rect2( (size.x-ssize.x)/2,0,ssize.x,size.y ));
+ style->draw(get_canvas_item(), Rect2((size.x - ssize.x) / 2, 0, ssize.x, size.y));
} else {
- style->draw(get_canvas_item(),Rect2( 0,(size.y-ssize.y)/2,size.x,ssize.y ));
+ style->draw(get_canvas_item(), Rect2(0, (size.y - ssize.y) / 2, size.x, ssize.y));
}
} break;
}
}
-Separator::Separator()
-{
+Separator::Separator() {
}
-
-Separator::~Separator()
-{
+Separator::~Separator() {
}
HSeparator::HSeparator() {
- orientation=HORIZONTAL;
+ orientation = HORIZONTAL;
}
VSeparator::VSeparator() {
- orientation=VERTICAL;
+ orientation = VERTICAL;
}
diff --git a/scene/gui/separator.h b/scene/gui/separator.h
index 2d57b197c..229f5788f 100644
--- a/scene/gui/separator.h
+++ b/scene/gui/separator.h
@@ -36,40 +36,33 @@
#include "scene/gui/control.h"
class Separator : public Control {
- OBJ_TYPE( Separator, Control );
-
+ OBJ_TYPE(Separator, Control);
protected:
-
Orientation orientation;
void _notification(int p_what);
-public:
+public:
virtual Size2 get_minimum_size() const;
Separator();
~Separator();
-
};
class VSeparator : public Separator {
- OBJ_TYPE( VSeparator, Separator );
+ OBJ_TYPE(VSeparator, Separator);
public:
-
VSeparator();
-
};
class HSeparator : public Separator {
- OBJ_TYPE( HSeparator, Separator );
+ OBJ_TYPE(HSeparator, Separator);
public:
-
HSeparator();
-
};
#endif
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 8747cc965..6a308451c 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -29,91 +29,88 @@
#include "slider.h"
#include "os/keyboard.h"
-
Size2 Slider::get_minimum_size() const {
Ref<StyleBox> style = get_stylebox("slider");
- Size2i ms = style->get_minimum_size()+style->get_center_size();
+ Size2i ms = style->get_minimum_size() + style->get_center_size();
return ms;
}
void Slider::_input_event(InputEvent p_event) {
-
-
- if (p_event.type==InputEvent::MOUSE_BUTTON) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON) {
InputEventMouseButton &mb = p_event.mouse_button;
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
- if (mb.pressed) {
- Ref<Texture> grabber = get_icon(mouse_inside||has_focus()?"grabber_hilite":"grabber");
- grab.pos=orientation==VERTICAL?mb.y:mb.x;
+ if (mb.pressed) {
+ Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_hilite" : "grabber");
+ grab.pos = orientation == VERTICAL ? mb.y : mb.x;
double grab_width = (double)grabber->get_size().width;
double grab_height = (double)grabber->get_size().height;
- double max = orientation==VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
- if (orientation==VERTICAL)
- set_unit_value( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
+ double max = orientation == VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
+ if (orientation == VERTICAL)
+ set_unit_value(1 - (((double)grab.pos - (grab_height / 2.0)) / max));
else
- set_unit_value(((double)grab.pos - (grab_width/2.0)) / max);
- grab.active=true;
- grab.uvalue=get_unit_value();
+ set_unit_value(((double)grab.pos - (grab_width / 2.0)) / max);
+ grab.active = true;
+ grab.uvalue = get_unit_value();
} else {
- grab.active=false;
+ grab.active = false;
}
- } else if (mb.pressed && mb.button_index==BUTTON_WHEEL_UP) {
+ } else if (mb.pressed && mb.button_index == BUTTON_WHEEL_UP) {
- set_val( get_val() + get_step());
- } else if (mb.pressed && mb.button_index==BUTTON_WHEEL_DOWN) {
- set_val( get_val() - get_step());
+ set_val(get_val() + get_step());
+ } else if (mb.pressed && mb.button_index == BUTTON_WHEEL_DOWN) {
+ set_val(get_val() - get_step());
}
- } else if (p_event.type==InputEvent::MOUSE_MOTION) {
+ } else if (p_event.type == InputEvent::MOUSE_MOTION) {
if (grab.active) {
Size2i size = get_size();
Ref<Texture> grabber = get_icon("grabber");
- float motion = (orientation==VERTICAL?p_event.mouse_motion.y:p_event.mouse_motion.x) - grab.pos;
- if (orientation==VERTICAL)
- motion=-motion;
- float areasize = orientation==VERTICAL?size.height - grabber->get_size().height:size.width - grabber->get_size().width;
- if (areasize<=0)
+ float motion = (orientation == VERTICAL ? p_event.mouse_motion.y : p_event.mouse_motion.x) - grab.pos;
+ if (orientation == VERTICAL)
+ motion = -motion;
+ float areasize = orientation == VERTICAL ? size.height - grabber->get_size().height : size.width - grabber->get_size().width;
+ if (areasize <= 0)
return;
float umotion = motion / float(areasize);
- set_unit_value( grab.uvalue + umotion );
+ set_unit_value(grab.uvalue + umotion);
}
} else {
if (p_event.is_action("ui_left") && p_event.is_pressed()) {
- if (orientation!=HORIZONTAL)
+ if (orientation != HORIZONTAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() - (custom_step >= 0 ? custom_step : get_step()));
accept_event();
} else if (p_event.is_action("ui_right") && p_event.is_pressed()) {
- if (orientation!=HORIZONTAL)
+ if (orientation != HORIZONTAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() + (custom_step >= 0 ? custom_step : get_step()));
accept_event();
} else if (p_event.is_action("ui_up") && p_event.is_pressed()) {
- if (orientation!=VERTICAL)
+ if (orientation != VERTICAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() + (custom_step >= 0 ? custom_step : get_step()));
accept_event();
} else if (p_event.is_action("ui_down") && p_event.is_pressed()) {
- if (orientation!=VERTICAL)
+ if (orientation != VERTICAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_val(get_val() - (custom_step >= 0 ? custom_step : get_step()));
accept_event();
- } else if (p_event.type==InputEvent::KEY) {
+ } else if (p_event.type == InputEvent::KEY) {
- const InputEventKey &k=p_event.key;
+ const InputEventKey &k = p_event.key;
if (!k.pressed)
return;
@@ -122,35 +119,32 @@ void Slider::_input_event(InputEvent p_event) {
case KEY_HOME: {
- set_val( get_min() );
+ set_val(get_min());
accept_event();
} break;
case KEY_END: {
- set_val( get_max() );
+ set_val(get_max());
accept_event();
} break;
-
- } ;
+ };
}
}
-
}
void Slider::_notification(int p_what) {
-
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_MOUSE_ENTER: {
- mouse_inside=true;
+ mouse_inside = true;
update();
} break;
case NOTIFICATION_MOUSE_EXIT: {
- mouse_inside=false;
+ mouse_inside = false;
update();
} break;
case NOTIFICATION_DRAW: {
@@ -158,41 +152,39 @@ void Slider::_notification(int p_what) {
Size2i size = get_size();
Ref<StyleBox> style = get_stylebox("slider");
Ref<StyleBox> focus = get_stylebox("focus");
- Ref<Texture> grabber = get_icon(mouse_inside||has_focus()?"grabber_hilite":"grabber");
+ Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_hilite" : "grabber");
Ref<Texture> tick = get_icon("tick");
- if (orientation==VERTICAL) {
+ if (orientation == VERTICAL) {
- style->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
+ style->draw(ci, Rect2i(Point2i(), Size2i(style->get_minimum_size().width + style->get_center_size().width, size.height)));
//if (mouse_inside||has_focus())
// focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
float areasize = size.height - grabber->get_size().height;
- if (ticks>1) {
+ if (ticks > 1) {
int tickarea = size.height - tick->get_height();
- for(int i=0;i<ticks;i++) {
- if( ! ticks_on_borders && (i == 0 || i + 1 == ticks) ) continue;
- int ofs = i*tickarea/(ticks-1);
- tick->draw(ci,Point2(0,ofs));
+ for (int i = 0; i < ticks; i++) {
+ if (!ticks_on_borders && (i == 0 || i + 1 == ticks)) continue;
+ int ofs = i * tickarea / (ticks - 1);
+ tick->draw(ci, Point2(0, ofs));
}
-
}
- grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_unit_value()*areasize - grabber->get_size().height));
+ grabber->draw(ci, Point2i(size.width / 2 - grabber->get_size().width / 2, size.height - get_unit_value() * areasize - grabber->get_size().height));
} else {
- style->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
+ style->draw(ci, Rect2i(Point2i(), Size2i(size.width, style->get_minimum_size().height + style->get_center_size().height)));
//if (mouse_inside||has_focus())
// focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
float areasize = size.width - grabber->get_size().width;
- if (ticks>1) {
+ if (ticks > 1) {
int tickarea = size.width - tick->get_width();
- for(int i=0;i<ticks;i++) {
- if( (! ticks_on_borders) && ( (i == 0) || ((i + 1) == ticks)) ) continue;
- int ofs = i*tickarea/(ticks-1);
- tick->draw(ci,Point2(ofs,0));
+ for (int i = 0; i < ticks; i++) {
+ if ((!ticks_on_borders) && ((i == 0) || ((i + 1) == ticks))) continue;
+ int ofs = i * tickarea / (ticks - 1);
+ tick->draw(ci, Point2(ofs, 0));
}
-
}
- grabber->draw(ci,Point2i(get_unit_value()*areasize,size.height/2-grabber->get_size().height/2));
+ grabber->draw(ci, Point2i(get_unit_value() * areasize, size.height / 2 - grabber->get_size().height / 2));
}
} break;
@@ -201,7 +193,7 @@ void Slider::_notification(int p_what) {
void Slider::set_custom_step(float p_custom_step) {
- custom_step=p_custom_step;
+ custom_step = p_custom_step;
}
float Slider::get_custom_step() const {
@@ -211,7 +203,7 @@ float Slider::get_custom_step() const {
void Slider::set_ticks(int p_count) {
- ticks=p_count;
+ ticks = p_count;
update();
}
@@ -220,35 +212,34 @@ int Slider::get_ticks() const {
return ticks;
}
-bool Slider::get_ticks_on_borders() const{
+bool Slider::get_ticks_on_borders() const {
return ticks_on_borders;
}
-void Slider::set_ticks_on_borders(bool _tob){
+void Slider::set_ticks_on_borders(bool _tob) {
ticks_on_borders = _tob;
update();
}
void Slider::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&Slider::_input_event);
- ObjectTypeDB::bind_method(_MD("set_ticks","count"),&Slider::set_ticks);
- ObjectTypeDB::bind_method(_MD("get_ticks"),&Slider::get_ticks);
-
- ObjectTypeDB::bind_method(_MD("get_ticks_on_borders"),&Slider::get_ticks_on_borders);
- ObjectTypeDB::bind_method(_MD("set_ticks_on_borders","ticks_on_border"),&Slider::set_ticks_on_borders);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &Slider::_input_event);
+ ObjectTypeDB::bind_method(_MD("set_ticks", "count"), &Slider::set_ticks);
+ ObjectTypeDB::bind_method(_MD("get_ticks"), &Slider::get_ticks);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "tick_count", PROPERTY_HINT_RANGE,"0,4096,1"), _SCS("set_ticks"), _SCS("get_ticks") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "ticks_on_borders" ), _SCS("set_ticks_on_borders"), _SCS("get_ticks_on_borders") );
- ADD_PROPERTY( PropertyInfo( Variant::INT,"focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_focus_mode"), _SCS("get_focus_mode") );
+ ObjectTypeDB::bind_method(_MD("get_ticks_on_borders"), &Slider::get_ticks_on_borders);
+ ObjectTypeDB::bind_method(_MD("set_ticks_on_borders", "ticks_on_border"), &Slider::set_ticks_on_borders);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "tick_count", PROPERTY_HINT_RANGE, "0,4096,1"), _SCS("set_ticks"), _SCS("get_ticks"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ticks_on_borders"), _SCS("set_ticks_on_borders"), _SCS("get_ticks_on_borders"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), _SCS("set_focus_mode"), _SCS("get_focus_mode"));
}
Slider::Slider(Orientation p_orientation) {
- orientation=p_orientation;
- mouse_inside=false;
- grab.active=false;
- ticks=0;
- custom_step=-1;
+ orientation = p_orientation;
+ mouse_inside = false;
+ grab.active = false;
+ ticks = 0;
+ custom_step = -1;
set_focus_mode(FOCUS_ALL);
}
diff --git a/scene/gui/slider.h b/scene/gui/slider.h
index 31cc9f90d..549f8356b 100644
--- a/scene/gui/slider.h
+++ b/scene/gui/slider.h
@@ -33,7 +33,7 @@
class Slider : public Range {
- OBJ_TYPE( Slider, Range );
+ OBJ_TYPE(Slider, Range);
struct Grab {
int pos;
@@ -46,16 +46,13 @@ class Slider : public Range {
Orientation orientation;
float custom_step;
-
protected:
-
void _input_event(InputEvent p_event);
void _notification(int p_what);
static void _bind_methods();
bool ticks_on_borders;
public:
-
virtual Size2 get_minimum_size() const;
void set_custom_step(float p_custom_step);
@@ -67,25 +64,25 @@ public:
void set_ticks_on_borders(bool);
bool get_ticks_on_borders() const;
- Slider(Orientation p_orientation=VERTICAL);
+ Slider(Orientation p_orientation = VERTICAL);
};
-
-
class HSlider : public Slider {
- OBJ_TYPE( HSlider, Slider );
-public:
+ OBJ_TYPE(HSlider, Slider);
- HSlider() : Slider(HORIZONTAL) { set_v_size_flags(0);}
+public:
+ HSlider()
+ : Slider(HORIZONTAL) { set_v_size_flags(0); }
};
class VSlider : public Slider {
- OBJ_TYPE( VSlider, Slider );
-public:
+ OBJ_TYPE(VSlider, Slider);
- VSlider() : Slider(VERTICAL) { set_h_size_flags(0);}
+public:
+ VSlider()
+ : Slider(VERTICAL) { set_h_size_flags(0); }
};
#endif // SLIDER_H
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 7eeca6a3d..48200fba6 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -32,51 +32,45 @@
Size2 SpinBox::get_minimum_size() const {
Size2 ms = line_edit->get_combined_minimum_size();
- ms.width+=last_w;
+ ms.width += last_w;
return ms;
}
-
void SpinBox::_value_changed(double) {
- String value = String::num(get_val(),Math::step_decimals(get_step()));
- if (prefix!="")
- value=prefix+" "+value;
- if (suffix!="")
- value+=" "+suffix;
+ String value = String::num(get_val(), Math::step_decimals(get_step()));
+ if (prefix != "")
+ value = prefix + " " + value;
+ if (suffix != "")
+ value += " " + suffix;
line_edit->set_text(value);
}
-void SpinBox::_text_entered(const String& p_string) {
+void SpinBox::_text_entered(const String &p_string) {
//if (!p_string.is_numeric())
// return;
String value = p_string;
- if (prefix!="" && p_string.begins_with(prefix))
- value = p_string.substr(prefix.length(), p_string.length()-prefix.length());
- set_val( value.to_double() );
+ if (prefix != "" && p_string.begins_with(prefix))
+ value = p_string.substr(prefix.length(), p_string.length() - prefix.length());
+ set_val(value.to_double());
_value_changed(0);
}
-
LineEdit *SpinBox::get_line_edit() {
return line_edit;
}
-
-void SpinBox::_line_edit_input(const InputEvent& p_event) {
-
-
-
+void SpinBox::_line_edit_input(const InputEvent &p_event) {
}
void SpinBox::_range_click_timeout() {
if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
- bool up = get_local_mouse_pos().y < (get_size().height/2);
- set_val( get_val() + (up?get_step():-get_step()));
+ bool up = get_local_mouse_pos().y < (get_size().height / 2);
+ set_val(get_val() + (up ? get_step() : -get_step()));
if (range_click_timer->is_one_shot()) {
range_click_timer->set_wait_time(0.075);
@@ -89,23 +83,21 @@ void SpinBox::_range_click_timeout() {
}
}
-
-void SpinBox::_input_event(const InputEvent& p_event) {
+void SpinBox::_input_event(const InputEvent &p_event) {
if (!is_editable()) {
return;
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed) {
- const InputEventMouseButton &mb=p_event.mouse_button;
-
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed) {
+ const InputEventMouseButton &mb = p_event.mouse_button;
- bool up = mb.y < (get_size().height/2);
+ bool up = mb.y < (get_size().height / 2);
- switch(mb.button_index) {
+ switch (mb.button_index) {
case BUTTON_LEFT: {
- set_val( get_val() + (up?get_step():-get_step()));
+ set_val(get_val() + (up ? get_step() : -get_step()));
range_click_timer->set_wait_time(0.6);
range_click_timer->set_one_shot(true);
@@ -115,70 +107,68 @@ void SpinBox::_input_event(const InputEvent& p_event) {
} break;
case BUTTON_RIGHT: {
- set_val( (up?get_max():get_min()) );
+ set_val((up ? get_max() : get_min()));
line_edit->grab_focus();
} break;
case BUTTON_WHEEL_UP: {
if (line_edit->has_focus()) {
- set_val( get_val() + get_step() );
+ set_val(get_val() + get_step());
accept_event();
}
} break;
case BUTTON_WHEEL_DOWN: {
if (line_edit->has_focus()) {
- set_val( get_val() - get_step() );
+ set_val(get_val() - get_step());
accept_event();
}
} break;
}
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index==1) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index == 1) {
//set_default_cursor_shape(CURSOR_VSIZE);
- Vector2 cpos = Vector2(p_event.mouse_button.x,p_event.mouse_button.y);
- drag.mouse_pos=cpos;
+ Vector2 cpos = Vector2(p_event.mouse_button.x, p_event.mouse_button.y);
+ drag.mouse_pos = cpos;
}
- if (p_event.type==InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index==1) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index == 1) {
//set_default_cursor_shape(CURSOR_ARROW);
range_click_timer->stop();
if (drag.enabled) {
- drag.enabled=false;
+ drag.enabled = false;
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(drag.capture_pos);
}
}
- if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_button.button_mask&1) {
+ if (p_event.type == InputEvent::MOUSE_MOTION && p_event.mouse_button.button_mask & 1) {
- Vector2 cpos = Vector2(p_event.mouse_motion.x,p_event.mouse_motion.y);
+ Vector2 cpos = Vector2(p_event.mouse_motion.x, p_event.mouse_motion.y);
if (drag.enabled) {
float diff_y = drag.mouse_pos.y - cpos.y;
- diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y);
- diff_y*=0.1;
+ diff_y = Math::pow(ABS(diff_y), 1.8) * SGN(diff_y);
+ diff_y *= 0.1;
- drag.mouse_pos=cpos;
- drag.base_val=CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max());
+ drag.mouse_pos = cpos;
+ drag.base_val = CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max());
- set_val( drag.base_val);
+ set_val(drag.base_val);
- } else if (drag.mouse_pos.distance_to(cpos)>2) {
+ } else if (drag.mouse_pos.distance_to(cpos) > 2) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
- drag.enabled=true;
- drag.base_val=get_val();
- drag.mouse_pos=cpos;
- drag.capture_pos=cpos;
-
+ drag.enabled = true;
+ drag.base_val = get_val();
+ drag.mouse_pos = cpos;
+ drag.capture_pos = cpos;
}
}
}
-
void SpinBox::_line_edit_focus_exit() {
_text_entered(line_edit->get_text());
@@ -186,54 +176,48 @@ void SpinBox::_line_edit_focus_exit() {
void SpinBox::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
Ref<Texture> updown = get_icon("updown");
int w = updown->get_width();
- if (w!=last_w) {
- line_edit->set_margin(MARGIN_RIGHT,w);
- last_w=w;
+ if (w != last_w) {
+ line_edit->set_margin(MARGIN_RIGHT, w);
+ last_w = w;
}
RID ci = get_canvas_item();
Size2i size = get_size();
- updown->draw(ci,Point2i(size.width-updown->get_width(),(size.height-updown->get_height())/2));
-
- } else if (p_what==NOTIFICATION_FOCUS_EXIT) {
+ updown->draw(ci, Point2i(size.width - updown->get_width(), (size.height - updown->get_height()) / 2));
+ } else if (p_what == NOTIFICATION_FOCUS_EXIT) {
//_value_changed(0);
- } else if (p_what==NOTIFICATION_ENTER_TREE) {
+ } else if (p_what == NOTIFICATION_ENTER_TREE) {
_value_changed(0);
}
-
}
+void SpinBox::set_suffix(const String &p_suffix) {
-void SpinBox::set_suffix(const String& p_suffix) {
-
- suffix=p_suffix;
+ suffix = p_suffix;
_value_changed(0);
-
}
-String SpinBox::get_suffix() const{
+String SpinBox::get_suffix() const {
return suffix;
}
+void SpinBox::set_prefix(const String &p_prefix) {
-void SpinBox::set_prefix(const String& p_prefix) {
-
- prefix=p_prefix;
+ prefix = p_prefix;
_value_changed(0);
-
}
-String SpinBox::get_prefix() const{
+String SpinBox::get_prefix() const {
return prefix;
}
@@ -250,41 +234,38 @@ bool SpinBox::is_editable() const {
void SpinBox::_bind_methods() {
//ObjectTypeDB::bind_method(_MD("_value_changed"),&SpinBox::_value_changed);
- ObjectTypeDB::bind_method(_MD("_input_event"),&SpinBox::_input_event);
- ObjectTypeDB::bind_method(_MD("_text_entered"),&SpinBox::_text_entered);
- ObjectTypeDB::bind_method(_MD("set_suffix","suffix"),&SpinBox::set_suffix);
- ObjectTypeDB::bind_method(_MD("get_suffix"),&SpinBox::get_suffix);
- ObjectTypeDB::bind_method(_MD("set_prefix","prefix"),&SpinBox::set_prefix);
- ObjectTypeDB::bind_method(_MD("get_prefix"),&SpinBox::get_prefix);
- ObjectTypeDB::bind_method(_MD("set_editable","editable"),&SpinBox::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable"),&SpinBox::is_editable);
- ObjectTypeDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit);
- ObjectTypeDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit);
- ObjectTypeDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input);
- ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout);
-
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"editable"),_SCS("set_editable"),_SCS("is_editable"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"prefix"),_SCS("set_prefix"),_SCS("get_prefix"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"suffix"),_SCS("set_suffix"),_SCS("get_suffix"));
-
+ ObjectTypeDB::bind_method(_MD("_input_event"), &SpinBox::_input_event);
+ ObjectTypeDB::bind_method(_MD("_text_entered"), &SpinBox::_text_entered);
+ ObjectTypeDB::bind_method(_MD("set_suffix", "suffix"), &SpinBox::set_suffix);
+ ObjectTypeDB::bind_method(_MD("get_suffix"), &SpinBox::get_suffix);
+ ObjectTypeDB::bind_method(_MD("set_prefix", "prefix"), &SpinBox::set_prefix);
+ ObjectTypeDB::bind_method(_MD("get_prefix"), &SpinBox::get_prefix);
+ ObjectTypeDB::bind_method(_MD("set_editable", "editable"), &SpinBox::set_editable);
+ ObjectTypeDB::bind_method(_MD("is_editable"), &SpinBox::is_editable);
+ ObjectTypeDB::bind_method(_MD("_line_edit_focus_exit"), &SpinBox::_line_edit_focus_exit);
+ ObjectTypeDB::bind_method(_MD("get_line_edit"), &SpinBox::get_line_edit);
+ ObjectTypeDB::bind_method(_MD("_line_edit_input"), &SpinBox::_line_edit_input);
+ ObjectTypeDB::bind_method(_MD("_range_click_timeout"), &SpinBox::_range_click_timeout);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), _SCS("set_editable"), _SCS("is_editable"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "prefix"), _SCS("set_prefix"), _SCS("get_prefix"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "suffix"), _SCS("set_suffix"), _SCS("get_suffix"));
}
SpinBox::SpinBox() {
last_w = 0;
- line_edit = memnew( LineEdit );
+ line_edit = memnew(LineEdit);
add_child(line_edit);
line_edit->set_area_as_parent_rect();
//connect("value_changed",this,"_value_changed");
- line_edit->connect("text_entered",this,"_text_entered",Vector<Variant>(),CONNECT_DEFERRED);
- line_edit->connect("focus_exit",this,"_line_edit_focus_exit",Vector<Variant>(),CONNECT_DEFERRED);
- line_edit->connect("input_event",this,"_line_edit_input");
- drag.enabled=false;
+ line_edit->connect("text_entered", this, "_text_entered", Vector<Variant>(), CONNECT_DEFERRED);
+ line_edit->connect("focus_exit", this, "_line_edit_focus_exit", Vector<Variant>(), CONNECT_DEFERRED);
+ line_edit->connect("input_event", this, "_line_edit_input");
+ drag.enabled = false;
- range_click_timer = memnew( Timer );
- range_click_timer->connect("timeout",this,"_range_click_timeout");
+ range_click_timer = memnew(Timer);
+ range_click_timer->connect("timeout", this, "_range_click_timeout");
add_child(range_click_timer);
}
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index 7b33d562b..709d9ff6d 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -35,7 +35,7 @@
class SpinBox : public Range {
- OBJ_TYPE( SpinBox, Range );
+ OBJ_TYPE(SpinBox, Range);
LineEdit *line_edit;
int last_w;
@@ -43,35 +43,31 @@ class SpinBox : public Range {
Timer *range_click_timer;
void _range_click_timeout();
- void _text_entered(const String& p_string);
+ void _text_entered(const String &p_string);
virtual void _value_changed(double);
String prefix;
String suffix;
- void _line_edit_input(const InputEvent& p_event);
-
+ void _line_edit_input(const InputEvent &p_event);
struct Drag {
float base_val;
bool enabled;
Vector2 from;
- Vector2 mouse_pos;
+ Vector2 mouse_pos;
Vector2 capture_pos;
} drag;
-
void _line_edit_focus_exit();
protected:
-
- void _input_event(const InputEvent& p_event);
-
+ void _input_event(const InputEvent &p_event);
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
LineEdit *get_line_edit();
virtual Size2 get_minimum_size() const;
@@ -79,10 +75,10 @@ public:
void set_editable(bool p_editable);
bool is_editable() const;
- void set_suffix(const String& p_suffix);
+ void set_suffix(const String &p_suffix);
String get_suffix() const;
- void set_prefix(const String& p_prefix);
+ void set_prefix(const String &p_prefix);
String get_prefix() const;
SpinBox();
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 2c81bd19f..38b03255b 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -28,10 +28,8 @@
/*************************************************************************/
#include "split_container.h"
-#include "margin_container.h"
#include "label.h"
-
-
+#include "margin_container.h"
struct _MinSizeCache {
@@ -40,235 +38,208 @@ struct _MinSizeCache {
int final_size;
};
-
Control *SplitContainer::_getch(int p_idx) const {
- int idx=0;
+ int idx = 0;
- for(int i=0;i<get_child_count();i++) {
- Control *c=get_child(i)->cast_to<Control>();
+ for (int i = 0; i < get_child_count(); i++) {
+ Control *c = get_child(i)->cast_to<Control>();
if (!c || !c->is_visible())
continue;
if (c->is_set_as_toplevel())
continue;
- if (idx==p_idx)
+ if (idx == p_idx)
return c;
idx++;
}
return NULL;
-
}
-
void SplitContainer::_resort() {
/** First pass, determine minimum size AND amount of stretchable elements */
- int axis = vertical?1:0;
+ int axis = vertical ? 1 : 0;
- bool has_first=_getch(0);
- bool has_second=_getch(1);
+ bool has_first = _getch(0);
+ bool has_second = _getch(1);
if (!has_first && !has_second) {
return;
- } else if (! (has_first && has_second)) {
+ } else if (!(has_first && has_second)) {
if (has_first)
- fit_child_in_rect(_getch(0),Rect2(Point2(),get_size()));
+ fit_child_in_rect(_getch(0), Rect2(Point2(), get_size()));
else
- fit_child_in_rect(_getch(1),Rect2(Point2(),get_size()));
+ fit_child_in_rect(_getch(1), Rect2(Point2(), get_size()));
return;
}
+ Control *first = _getch(0);
+ Control *second = _getch(1);
-
- Control *first=_getch(0);
- Control *second=_getch(1);
-
-
- bool ratiomode=false;
- bool expand_first_mode=false;
-
-
-
+ bool ratiomode = false;
+ bool expand_first_mode = false;
if (vertical) {
- ratiomode=first->get_v_size_flags()&SIZE_EXPAND && second->get_v_size_flags()&SIZE_EXPAND;
- expand_first_mode=first->get_v_size_flags()&SIZE_EXPAND && !(second->get_v_size_flags()&SIZE_EXPAND);
+ ratiomode = first->get_v_size_flags() & SIZE_EXPAND && second->get_v_size_flags() & SIZE_EXPAND;
+ expand_first_mode = first->get_v_size_flags() & SIZE_EXPAND && !(second->get_v_size_flags() & SIZE_EXPAND);
} else {
- ratiomode=first->get_h_size_flags()&SIZE_EXPAND && second->get_h_size_flags()&SIZE_EXPAND;
- expand_first_mode=first->get_h_size_flags()&SIZE_EXPAND && !(second->get_h_size_flags()&SIZE_EXPAND);
+ ratiomode = first->get_h_size_flags() & SIZE_EXPAND && second->get_h_size_flags() & SIZE_EXPAND;
+ expand_first_mode = first->get_h_size_flags() & SIZE_EXPAND && !(second->get_h_size_flags() & SIZE_EXPAND);
}
-
- int sep=get_constant("separation");
+ int sep = get_constant("separation");
Ref<Texture> g = get_icon("grabber");
- if (dragger_visibility==DRAGGER_HIDDEN_COLLAPSED) {
- sep=0;
+ if (dragger_visibility == DRAGGER_HIDDEN_COLLAPSED) {
+ sep = 0;
} else {
- sep=MAX(sep,vertical?g->get_height():g->get_width());
+ sep = MAX(sep, vertical ? g->get_height() : g->get_width());
}
- int total = vertical?get_size().height:get_size().width;
+ int total = vertical ? get_size().height : get_size().width;
- total-=sep;
+ total -= sep;
- int minimum=0;
+ int minimum = 0;
Size2 ms_first = first->get_combined_minimum_size();
Size2 ms_second = second->get_combined_minimum_size();
if (vertical) {
- minimum=ms_first.height+ms_second.height;
+ minimum = ms_first.height + ms_second.height;
} else {
- minimum=ms_first.width+ms_second.width;
+ minimum = ms_first.width + ms_second.width;
}
- int available=total-minimum;
- if (available<0)
- available=0;
-
+ int available = total - minimum;
+ if (available < 0)
+ available = 0;
- middle_sep=0;
+ middle_sep = 0;
if (collapsed) {
-
if (ratiomode) {
- middle_sep=ms_first[axis]+available/2;
-
+ middle_sep = ms_first[axis] + available / 2;
} else if (expand_first_mode) {
- middle_sep=get_size()[axis]-ms_second[axis]-sep;
+ middle_sep = get_size()[axis] - ms_second[axis] - sep;
} else {
- middle_sep=ms_first[axis];
+ middle_sep = ms_first[axis];
}
-
} else if (ratiomode) {
- if (expand_ofs<-(available/2))
- expand_ofs=-(available/2);
- else if (expand_ofs>(available/2))
- expand_ofs=(available/2);
-
- middle_sep=ms_first[axis]+available/2+expand_ofs;
+ if (expand_ofs < -(available / 2))
+ expand_ofs = -(available / 2);
+ else if (expand_ofs > (available / 2))
+ expand_ofs = (available / 2);
+ middle_sep = ms_first[axis] + available / 2 + expand_ofs;
} else if (expand_first_mode) {
- if (expand_ofs>0)
- expand_ofs=0;
+ if (expand_ofs > 0)
+ expand_ofs = 0;
if (expand_ofs < -available)
- expand_ofs=-available;
+ expand_ofs = -available;
- middle_sep=get_size()[axis]-ms_second[axis]-sep+expand_ofs;
+ middle_sep = get_size()[axis] - ms_second[axis] - sep + expand_ofs;
} else {
- if (expand_ofs<0)
- expand_ofs=0;
+ if (expand_ofs < 0)
+ expand_ofs = 0;
if (expand_ofs > available)
- expand_ofs=available;
-
- middle_sep=ms_first[axis]+expand_ofs;
+ expand_ofs = available;
+ middle_sep = ms_first[axis] + expand_ofs;
}
-
-
if (vertical) {
- fit_child_in_rect(first,Rect2(Point2(0,0),Size2(get_size().width,middle_sep)));
- int sofs=middle_sep+sep;
- fit_child_in_rect(second,Rect2(Point2(0,sofs),Size2(get_size().width,get_size().height-sofs)));
+ fit_child_in_rect(first, Rect2(Point2(0, 0), Size2(get_size().width, middle_sep)));
+ int sofs = middle_sep + sep;
+ fit_child_in_rect(second, Rect2(Point2(0, sofs), Size2(get_size().width, get_size().height - sofs)));
} else {
-
- fit_child_in_rect(first,Rect2(Point2(0,0),Size2(middle_sep,get_size().height)));
- int sofs=middle_sep+sep;
- fit_child_in_rect(second,Rect2(Point2(sofs,0),Size2(get_size().width-sofs,get_size().height)));
+ fit_child_in_rect(first, Rect2(Point2(0, 0), Size2(middle_sep, get_size().height)));
+ int sofs = middle_sep + sep;
+ fit_child_in_rect(second, Rect2(Point2(sofs, 0), Size2(get_size().width - sofs, get_size().height)));
}
update();
_change_notify("split/offset");
-
}
-
-
-
Size2 SplitContainer::get_minimum_size() const {
-
/* Calculate MINIMUM SIZE */
Size2i minimum;
- int sep=get_constant("separation");
+ int sep = get_constant("separation");
Ref<Texture> g = get_icon("grabber");
- sep=(dragger_visibility!=DRAGGER_HIDDEN_COLLAPSED)?MAX(sep,vertical?g->get_height():g->get_width()):0;
+ sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0;
- for(int i=0;i<2;i++) {
+ for (int i = 0; i < 2; i++) {
if (!_getch(i))
break;
- if (i==1) {
+ if (i == 1) {
if (vertical)
- minimum.height+=sep;
+ minimum.height += sep;
else
- minimum.width+=sep;
+ minimum.width += sep;
}
Size2 ms = _getch(i)->get_combined_minimum_size();
if (vertical) {
- minimum.height+=ms.height;
- minimum.width=MAX(minimum.width,ms.width);
+ minimum.height += ms.height;
+ minimum.width = MAX(minimum.width, ms.width);
} else {
- minimum.width+=ms.width;
- minimum.height=MAX(minimum.height,ms.height);
+ minimum.width += ms.width;
+ minimum.height = MAX(minimum.height, ms.height);
}
-
}
return minimum;
-
-
}
void SplitContainer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_SORT_CHILDREN: {
_resort();
} break;
case NOTIFICATION_MOUSE_ENTER: {
- mouse_inside=true;
+ mouse_inside = true;
update();
} break;
case NOTIFICATION_MOUSE_EXIT: {
- mouse_inside=false;
+ mouse_inside = false;
update();
} break;
case NOTIFICATION_DRAW: {
@@ -278,111 +249,105 @@ void SplitContainer::_notification(int p_what) {
if (collapsed || (!mouse_inside && get_constant("autohide")))
return;
- int sep=dragger_visibility!=DRAGGER_HIDDEN_COLLAPSED?get_constant("separation"):0;
+ int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_constant("separation") : 0;
Ref<Texture> tex = get_icon("grabber");
- Size2 size=get_size();
+ Size2 size = get_size();
if (vertical) {
//draw_style_box( get_stylebox("bg"), Rect2(0,middle_sep,get_size().width,sep));
- if (dragger_visibility==DRAGGER_VISIBLE)
- draw_texture(tex,Point2i((size.x-tex->get_width())/2,middle_sep+(sep-tex->get_height())/2));
+ if (dragger_visibility == DRAGGER_VISIBLE)
+ draw_texture(tex, Point2i((size.x - tex->get_width()) / 2, middle_sep + (sep - tex->get_height()) / 2));
} else {
//draw_style_box( get_stylebox("bg"), Rect2(middle_sep,0,sep,get_size().height));
- if (dragger_visibility==DRAGGER_VISIBLE)
- draw_texture(tex,Point2i(middle_sep+(sep-tex->get_width())/2,(size.y-tex->get_height())/2));
-
+ if (dragger_visibility == DRAGGER_VISIBLE)
+ draw_texture(tex, Point2i(middle_sep + (sep - tex->get_width()) / 2, (size.y - tex->get_height()) / 2));
}
} break;
}
}
-void SplitContainer::_input_event(const InputEvent& p_event) {
+void SplitContainer::_input_event(const InputEvent &p_event) {
- if (collapsed || !_getch(0) || !_getch(1) || dragger_visibility!=DRAGGER_VISIBLE)
+ if (collapsed || !_getch(0) || !_getch(1) || dragger_visibility != DRAGGER_VISIBLE)
return;
- if (p_event.type==InputEvent::MOUSE_BUTTON) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON) {
- const InputEventMouseButton &mb=p_event.mouse_button;
+ const InputEventMouseButton &mb = p_event.mouse_button;
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
if (mb.pressed) {
- int sep=get_constant("separation");
+ int sep = get_constant("separation");
if (vertical) {
-
- if (mb.y > middle_sep && mb.y < middle_sep+sep) {
- dragging=true;
- drag_from=mb.y;
- drag_ofs=expand_ofs;
+ if (mb.y > middle_sep && mb.y < middle_sep + sep) {
+ dragging = true;
+ drag_from = mb.y;
+ drag_ofs = expand_ofs;
}
} else {
- if (mb.x > middle_sep && mb.x < middle_sep+sep) {
- dragging=true;
- drag_from=mb.x;
- drag_ofs=expand_ofs;
+ if (mb.x > middle_sep && mb.x < middle_sep + sep) {
+ dragging = true;
+ drag_from = mb.x;
+ drag_ofs = expand_ofs;
}
}
} else {
- dragging=false;
+ dragging = false;
}
-
}
}
- if (p_event.type==InputEvent::MOUSE_MOTION) {
+ if (p_event.type == InputEvent::MOUSE_MOTION) {
- const InputEventMouseMotion &mm=p_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_event.mouse_motion;
if (dragging) {
- expand_ofs=drag_ofs+((vertical?mm.y:mm.x)-drag_from);
+ expand_ofs = drag_ofs + ((vertical ? mm.y : mm.x) - drag_from);
queue_sort();
- emit_signal("dragged",get_split_offset());
+ emit_signal("dragged", get_split_offset());
}
}
-
}
-Control::CursorShape SplitContainer::get_cursor_shape(const Point2& p_pos) const {
+Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const {
if (collapsed)
return Control::get_cursor_shape(p_pos);
if (dragging)
- return (vertical?CURSOR_VSIZE:CURSOR_HSIZE);
+ return (vertical ? CURSOR_VSIZE : CURSOR_HSIZE);
- int sep=get_constant("separation");
+ int sep = get_constant("separation");
if (vertical) {
-
- if (p_pos.y > middle_sep && p_pos.y < middle_sep+sep) {
+ if (p_pos.y > middle_sep && p_pos.y < middle_sep + sep) {
return CURSOR_VSIZE;
}
} else {
- if (p_pos.x > middle_sep && p_pos.x < middle_sep+sep) {
+ if (p_pos.x > middle_sep && p_pos.x < middle_sep + sep) {
return CURSOR_HSIZE;
}
}
return Control::get_cursor_shape(p_pos);
-
}
void SplitContainer::set_split_offset(int p_offset) {
- if (expand_ofs==p_offset)
+ if (expand_ofs == p_offset)
return;
- expand_ofs=p_offset;
+ expand_ofs = p_offset;
queue_sort();
}
@@ -393,16 +358,15 @@ int SplitContainer::get_split_offset() const {
void SplitContainer::set_collapsed(bool p_collapsed) {
- if (collapsed==p_collapsed)
+ if (collapsed == p_collapsed)
return;
- collapsed=p_collapsed;
+ collapsed = p_collapsed;
queue_sort();
-
}
void SplitContainer::set_dragger_visibility(DraggerVisibility p_visibility) {
- dragger_visibility=p_visibility;
+ dragger_visibility = p_visibility;
queue_sort();
update();
}
@@ -412,49 +376,41 @@ SplitContainer::DraggerVisibility SplitContainer::get_dragger_visibility() const
return dragger_visibility;
}
-
bool SplitContainer::is_collapsed() const {
-
return collapsed;
}
-
void SplitContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&SplitContainer::_input_event);
- ObjectTypeDB::bind_method(_MD("set_split_offset","offset"),&SplitContainer::set_split_offset);
- ObjectTypeDB::bind_method(_MD("get_split_offset"),&SplitContainer::get_split_offset);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &SplitContainer::_input_event);
+ ObjectTypeDB::bind_method(_MD("set_split_offset", "offset"), &SplitContainer::set_split_offset);
+ ObjectTypeDB::bind_method(_MD("get_split_offset"), &SplitContainer::get_split_offset);
- ObjectTypeDB::bind_method(_MD("set_collapsed","collapsed"),&SplitContainer::set_collapsed);
- ObjectTypeDB::bind_method(_MD("is_collapsed"),&SplitContainer::is_collapsed);
+ ObjectTypeDB::bind_method(_MD("set_collapsed", "collapsed"), &SplitContainer::set_collapsed);
+ ObjectTypeDB::bind_method(_MD("is_collapsed"), &SplitContainer::is_collapsed);
- ObjectTypeDB::bind_method(_MD("set_dragger_visibility","mode"),&SplitContainer::set_dragger_visibility);
- ObjectTypeDB::bind_method(_MD("get_dragger_visibility"),&SplitContainer::get_dragger_visibility);
+ ObjectTypeDB::bind_method(_MD("set_dragger_visibility", "mode"), &SplitContainer::set_dragger_visibility);
+ ObjectTypeDB::bind_method(_MD("get_dragger_visibility"), &SplitContainer::get_dragger_visibility);
- ADD_SIGNAL( MethodInfo("dragged",PropertyInfo(Variant::INT,"offset")));
+ ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::INT, "offset")));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"split/offset"),_SCS("set_split_offset"),_SCS("get_split_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"split/collapsed"),_SCS("set_collapsed"),_SCS("is_collapsed"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"split/dragger_visibility",PROPERTY_HINT_ENUM,"Visible,Hidden,Hidden & Collapsed"),_SCS("set_dragger_visibility"),_SCS("get_dragger_visibility"));
-
- BIND_CONSTANT( DRAGGER_VISIBLE );
- BIND_CONSTANT( DRAGGER_HIDDEN );
- BIND_CONSTANT( DRAGGER_HIDDEN_COLLAPSED );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "split/offset"), _SCS("set_split_offset"), _SCS("get_split_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "split/collapsed"), _SCS("set_collapsed"), _SCS("is_collapsed"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "split/dragger_visibility", PROPERTY_HINT_ENUM, "Visible,Hidden,Hidden & Collapsed"), _SCS("set_dragger_visibility"), _SCS("get_dragger_visibility"));
+ BIND_CONSTANT(DRAGGER_VISIBLE);
+ BIND_CONSTANT(DRAGGER_HIDDEN);
+ BIND_CONSTANT(DRAGGER_HIDDEN_COLLAPSED);
}
SplitContainer::SplitContainer(bool p_vertical) {
-
- mouse_inside=false;
- expand_ofs=0;
- middle_sep=0;
- vertical=p_vertical;
- dragging=false;
- collapsed=false;
- dragger_visibility=DRAGGER_VISIBLE;
-
+ mouse_inside = false;
+ expand_ofs = 0;
+ middle_sep = 0;
+ vertical = p_vertical;
+ dragging = false;
+ collapsed = false;
+ dragger_visibility = DRAGGER_VISIBLE;
}
-
-
diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h
index 5893043bb..a2e949955 100644
--- a/scene/gui/split_container.h
+++ b/scene/gui/split_container.h
@@ -31,16 +31,17 @@
#include "scene/gui/container.h"
-
class SplitContainer : public Container {
- OBJ_TYPE(SplitContainer,Container);
+ OBJ_TYPE(SplitContainer, Container);
+
public:
enum DraggerVisibility {
DRAGGER_VISIBLE,
DRAGGER_HIDDEN,
DRAGGER_HIDDEN_COLLAPSED
};
+
private:
bool vertical;
int expand_ofs;
@@ -52,20 +53,16 @@ private:
DraggerVisibility dragger_visibility;
bool mouse_inside;
-
Control *_getch(int p_idx) const;
void _resort();
-protected:
-
- void _input_event(const InputEvent& p_event);
+protected:
+ void _input_event(const InputEvent &p_event);
void _notification(int p_what);
static void _bind_methods();
-public:
-
-
+public:
void set_split_offset(int p_offset);
int get_split_offset() const;
@@ -75,32 +72,31 @@ public:
void set_dragger_visibility(DraggerVisibility p_visibility);
DraggerVisibility get_dragger_visibility() const;
- virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
virtual Size2 get_minimum_size() const;
- SplitContainer(bool p_vertical=false);
+ SplitContainer(bool p_vertical = false);
};
VARIANT_ENUM_CAST(SplitContainer::DraggerVisibility);
class HSplitContainer : public SplitContainer {
- OBJ_TYPE(HSplitContainer,SplitContainer);
+ OBJ_TYPE(HSplitContainer, SplitContainer);
public:
-
- HSplitContainer() : SplitContainer(false) {set_default_cursor_shape(CURSOR_HSPLIT);}
+ HSplitContainer()
+ : SplitContainer(false) { set_default_cursor_shape(CURSOR_HSPLIT); }
};
-
class VSplitContainer : public SplitContainer {
- OBJ_TYPE(VSplitContainer,SplitContainer);
+ OBJ_TYPE(VSplitContainer, SplitContainer);
public:
-
- VSplitContainer() : SplitContainer(true) {set_default_cursor_shape(CURSOR_VSPLIT);}
+ VSplitContainer()
+ : SplitContainer(true) { set_default_cursor_shape(CURSOR_VSPLIT); }
};
#endif // SPLIT_CONTAINER_H
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 3f5b690bf..980fd764f 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -30,18 +30,16 @@
#include "message_queue.h"
-
-
int TabContainer::_get_top_margin() const {
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
Ref<Font> font = get_font("font");
- int h = MAX( tab_bg->get_minimum_size().height,tab_fg->get_minimum_size().height);
+ int h = MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height);
int ch = font->get_height();
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -54,31 +52,28 @@ int TabContainer::_get_top_margin() const {
Ref<Texture> tex = c->get_meta("_tab_icon");
if (!tex.is_valid())
continue;
- ch = MAX( ch, tex->get_size().height );
+ ch = MAX(ch, tex->get_size().height);
}
- h+=ch;
+ h += ch;
return h;
-
}
+void TabContainer::_input_event(const InputEvent &p_event) {
-
-void TabContainer::_input_event(const InputEvent& p_event) {
-
- if (p_event.type==InputEvent::MOUSE_BUTTON &&
- p_event.mouse_button.pressed &&
- p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON &&
+ p_event.mouse_button.pressed &&
+ p_event.mouse_button.button_index == BUTTON_LEFT) {
// clicks
- Point2 pos( p_event.mouse_button.x, p_event.mouse_button.y );
+ Point2 pos(p_event.mouse_button.x, p_event.mouse_button.y);
int top_margin = _get_top_margin();
- if (pos.y>top_margin)
+ if (pos.y > top_margin)
return; // no click (too far down)
- if (pos.x<tabs_ofs_cache)
+ if (pos.x < tabs_ofs_cache)
return; // no click (too far left)
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
@@ -89,26 +84,25 @@ void TabContainer::_input_event(const InputEvent& p_event) {
Ref<Texture> menu = get_icon("menu");
Ref<Texture> menu_hl = get_icon("menu_hl");
- if (popup && pos.x>get_size().width-menu->get_width()) {
-
+ if (popup && pos.x > get_size().width - menu->get_width()) {
emit_signal("pre_popup_pressed");
Vector2 pp_pos = get_global_pos();
- pp_pos.x+=get_size().width;
- pp_pos.x-=popup->get_size().width;
- pp_pos.y+=menu->get_height();
+ pp_pos.x += get_size().width;
+ pp_pos.x -= popup->get_size().width;
+ pp_pos.y += menu->get_height();
- popup->set_global_pos( pp_pos );
+ popup->set_global_pos(pp_pos);
popup->popup();
return;
}
- pos.x-=tabs_ofs_cache;
+ pos.x -= tabs_ofs_cache;
- int idx=0;
- int found=-1;
- bool rightroom=false;
+ int idx = 0;
+ int found = -1;
+ bool rightroom = false;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -116,77 +110,71 @@ void TabContainer::_input_event(const InputEvent& p_event) {
if (c->is_set_as_toplevel())
continue;
- if (idx<tab_display_ofs) {
+ if (idx < tab_display_ofs) {
idx++;
continue;
}
- if (idx>last_tab_cache) {
- rightroom=true;
+ if (idx > last_tab_cache) {
+ rightroom = true;
break;
}
- String s = c->has_meta("_tab_name")?String(XL_MESSAGE(String(c->get_meta("_tab_name")))):String(c->get_name());
- int tab_width=font->get_string_size(s).width;
+ String s = c->has_meta("_tab_name") ? String(XL_MESSAGE(String(c->get_meta("_tab_name")))) : String(c->get_name());
+ int tab_width = font->get_string_size(s).width;
if (c->has_meta("_tab_icon")) {
Ref<Texture> icon = c->get_meta("_tab_icon");
if (icon.is_valid()) {
- tab_width+=icon->get_width();
- if (s!="")
- tab_width+=get_constant("hseparation");
-
+ tab_width += icon->get_width();
+ if (s != "")
+ tab_width += get_constant("hseparation");
}
}
- if (idx==current) {
+ if (idx == current) {
- tab_width+=tab_fg->get_minimum_size().width;
+ tab_width += tab_fg->get_minimum_size().width;
} else {
- tab_width+=tab_bg->get_minimum_size().width;
+ tab_width += tab_bg->get_minimum_size().width;
}
if (pos.x < tab_width) {
- found=idx;
+ found = idx;
break;
}
- pos.x-=tab_width;
+ pos.x -= tab_width;
idx++;
}
if (buttons_visible_cache) {
- if (p_event.mouse_button.x>get_size().width-incr->get_width()) {
+ if (p_event.mouse_button.x > get_size().width - incr->get_width()) {
if (rightroom) {
- tab_display_ofs+=1;
+ tab_display_ofs += 1;
update();
}
- } else if (p_event.mouse_button.x>get_size().width-incr->get_width()-decr->get_width()) {
+ } else if (p_event.mouse_button.x > get_size().width - incr->get_width() - decr->get_width()) {
- if (tab_display_ofs>0) {
- tab_display_ofs-=1;
+ if (tab_display_ofs > 0) {
+ tab_display_ofs -= 1;
update();
}
-
}
}
-
- if (found!=-1) {
+ if (found != -1) {
set_current_tab(found);
}
}
-
}
void TabContainer::_notification(int p_what) {
-
- switch(p_what) {
-
+ switch (p_what) {
case NOTIFICATION_DRAW: {
@@ -196,12 +184,10 @@ void TabContainer::_notification(int p_what) {
if (!tabs_visible) {
- panel->draw(ci, Rect2( 0, 0, size.width, size.height));
+ panel->draw(ci, Rect2(0, 0, size.width, size.height));
return;
}
-
-
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
Ref<Texture> incr = get_icon("increment");
@@ -215,179 +201,165 @@ void TabContainer::_notification(int p_what) {
int side_margin = get_constant("side_margin");
int top_margin = _get_top_margin();
+ Size2 top_size = Size2(size.width, top_margin);
- Size2 top_size = Size2( size.width, top_margin );
-
-
-
- int w=0;
- int idx=0;
+ int w = 0;
+ int idx = 0;
Vector<int> offsets;
- Vector<Control*> controls;
- int from=0;
- int limit=get_size().width;
+ Vector<Control *> controls;
+ int from = 0;
+ int limit = get_size().width;
if (popup) {
- top_size.width-=menu->get_width();
- limit-=menu->get_width();
+ top_size.width -= menu->get_width();
+ limit -= menu->get_width();
}
- bool notdone=false;
- last_tab_cache=-1;
+ bool notdone = false;
+ last_tab_cache = -1;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- if (idx<tab_display_ofs) {
+ if (idx < tab_display_ofs) {
idx++;
- from=idx;
+ from = idx;
continue;
}
- if (w>=get_size().width) {
- buttons_visible_cache=true;
- notdone=true;
+ if (w >= get_size().width) {
+ buttons_visible_cache = true;
+ notdone = true;
break;
}
offsets.push_back(w);
controls.push_back(c);
- String s = c->has_meta("_tab_name")?String(XL_MESSAGE(String(c->get_meta("_tab_name")))):String(c->get_name());
- w+=font->get_string_size(s).width;
+ String s = c->has_meta("_tab_name") ? String(XL_MESSAGE(String(c->get_meta("_tab_name")))) : String(c->get_name());
+ w += font->get_string_size(s).width;
if (c->has_meta("_tab_icon")) {
Ref<Texture> icon = c->get_meta("_tab_icon");
if (icon.is_valid()) {
- w+=icon->get_width();
- if (s!="")
- w+=get_constant("hseparation");
-
+ w += icon->get_width();
+ if (s != "")
+ w += get_constant("hseparation");
}
}
- if (idx==current) {
+ if (idx == current) {
- w+=tab_fg->get_minimum_size().width;
+ w += tab_fg->get_minimum_size().width;
} else {
- w+=tab_bg->get_minimum_size().width;
+ w += tab_bg->get_minimum_size().width;
}
- if (idx<tab_display_ofs) {
-
+ if (idx < tab_display_ofs) {
}
- last_tab_cache=idx;
+ last_tab_cache = idx;
idx++;
}
-
int ofs;
- switch(align) {
+ switch (align) {
case ALIGN_LEFT: ofs = side_margin; break;
- case ALIGN_CENTER: ofs = (int(limit) - w)/2; break;
+ case ALIGN_CENTER: ofs = (int(limit) - w) / 2; break;
case ALIGN_RIGHT: ofs = int(limit) - w - side_margin; break;
};
- tab_display_ofs=0;
+ tab_display_ofs = 0;
+ tabs_ofs_cache = ofs;
+ idx = 0;
- tabs_ofs_cache=ofs;
- idx=0;
+ for (int i = 0; i < controls.size(); i++) {
-
-
- for(int i=0;i<controls.size();i++) {
-
- idx=i+from;
- if (current>=from && current<from+controls.size()-1) {
+ idx = i + from;
+ if (current >= from && current < from + controls.size() - 1) {
//current is visible! draw it last.
- if (i==controls.size()-1) {
- idx=current;
- } else if (idx>=current) {
- idx+=1;
+ if (i == controls.size() - 1) {
+ idx = current;
+ } else if (idx >= current) {
+ idx += 1;
}
}
- Control *c = controls[idx-from];
+ Control *c = controls[idx - from];
- String s = c->has_meta("_tab_name")?String(c->get_meta("_tab_name")):String(c->get_name());
- int w=font->get_string_size(s).width;
+ String s = c->has_meta("_tab_name") ? String(c->get_meta("_tab_name")) : String(c->get_name());
+ int w = font->get_string_size(s).width;
Ref<Texture> icon;
if (c->has_meta("_tab_icon")) {
icon = c->get_meta("_tab_icon");
if (icon.is_valid()) {
- w+=icon->get_width();
- if (s!="")
- w+=get_constant("hseparation");
-
+ w += icon->get_width();
+ if (s != "")
+ w += get_constant("hseparation");
}
}
-
Ref<StyleBox> sb;
Color col;
- if (idx==current) {
+ if (idx == current) {
- sb=tab_fg;
- col=color_fg;
+ sb = tab_fg;
+ col = color_fg;
} else {
- sb=tab_bg;
- col=color_bg;
+ sb = tab_bg;
+ col = color_bg;
}
- int lofs = ofs + offsets[idx-from];
+ int lofs = ofs + offsets[idx - from];
Size2i sb_ms = sb->get_minimum_size();
- Rect2 sb_rect = Rect2( lofs, 0, w+sb_ms.width, top_margin);
-
+ Rect2 sb_rect = Rect2(lofs, 0, w + sb_ms.width, top_margin);
- sb->draw(ci, sb_rect );
+ sb->draw(ci, sb_rect);
Point2i lpos = sb_rect.pos;
- lpos.x+=sb->get_margin(MARGIN_LEFT);
+ lpos.x += sb->get_margin(MARGIN_LEFT);
if (icon.is_valid()) {
- icon->draw(ci, Point2i( lpos.x, sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-icon->get_height())/2 ) );
- if (s!="")
- lpos.x+=icon->get_width()+get_constant("hseparation");
-
+ icon->draw(ci, Point2i(lpos.x, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2));
+ if (s != "")
+ lpos.x += icon->get_width() + get_constant("hseparation");
}
- font->draw(ci, Point2i( lpos.x, sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-font->get_height())/2+font->get_ascent() ), s, col );
+ font->draw(ci, Point2i(lpos.x, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - font->get_height()) / 2 + font->get_ascent()), s, col);
idx++;
}
-
if (buttons_visible_cache) {
- int vofs = (top_margin-incr->get_height())/2;
- decr->draw(ci,Point2(limit,vofs),Color(1,1,1,tab_display_ofs==0?0.5:1.0));
- incr->draw(ci,Point2(limit+incr->get_width(),vofs),Color(1,1,1,notdone?1.0:0.5));
+ int vofs = (top_margin - incr->get_height()) / 2;
+ decr->draw(ci, Point2(limit, vofs), Color(1, 1, 1, tab_display_ofs == 0 ? 0.5 : 1.0));
+ incr->draw(ci, Point2(limit + incr->get_width(), vofs), Color(1, 1, 1, notdone ? 1.0 : 0.5));
}
if (popup) {
- int from = get_size().width-menu->get_width();
+ int from = get_size().width - menu->get_width();
if (mouse_x_cache > from)
- menu_hl->draw(get_canvas_item(),Size2(from,0));
+ menu_hl->draw(get_canvas_item(), Size2(from, 0));
else
- menu->draw(get_canvas_item(),Size2(from,0));
+ menu->draw(get_canvas_item(), Size2(from, 0));
}
- panel->draw(ci, Rect2( 0, top_size.height, size.width, size.height-top_size.height));
+ panel->draw(ci, Rect2(0, top_size.height, size.width, size.height - top_size.height));
} break;
case NOTIFICATION_THEME_CHANGED: {
if (get_tab_count() > 0) {
- call_deferred("set_current_tab",get_current_tab()); //wait until all changed theme
+ call_deferred("set_current_tab", get_current_tab()); //wait until all changed theme
}
} break;
}
@@ -400,16 +372,15 @@ void TabContainer::_child_renamed_callback() {
void TabContainer::add_child_notify(Node *p_child) {
-
Control *c = p_child->cast_to<Control>();
if (!c)
return;
if (c->is_set_as_toplevel())
return;
- bool first=false;
+ bool first = false;
- if (get_tab_count()!=1)
+ if (get_tab_count() != 1)
c->hide();
else {
c->show();
@@ -420,23 +391,22 @@ void TabContainer::add_child_notify(Node *p_child) {
}
c->set_area_as_parent_rect();
if (tabs_visible)
- c->set_margin(MARGIN_TOP,_get_top_margin());
+ c->set_margin(MARGIN_TOP, _get_top_margin());
Ref<StyleBox> sb = get_stylebox("panel");
- for(int i=0;i<4;i++)
- c->set_margin(Margin(i),c->get_margin(Margin(i))+sb->get_margin(Margin(i)));
-
+ for (int i = 0; i < 4; i++)
+ c->set_margin(Margin(i), c->get_margin(Margin(i)) + sb->get_margin(Margin(i)));
update();
- p_child->connect("renamed", this,"_child_renamed_callback");
- if(first)
- emit_signal("tab_changed",current);
+ p_child->connect("renamed", this, "_child_renamed_callback");
+ if (first)
+ emit_signal("tab_changed", current);
}
int TabContainer::get_tab_count() const {
- int count=0;
+ int count = 0;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -447,32 +417,30 @@ int TabContainer::get_tab_count() const {
return count;
}
-
void TabContainer::set_current_tab(int p_current) {
- ERR_FAIL_INDEX( p_current, get_tab_count() );
+ ERR_FAIL_INDEX(p_current, get_tab_count());
int pending_previous = current;
current = p_current;
- int idx=0;
+ int idx = 0;
- Ref<StyleBox> sb=get_stylebox("panel");
- for(int i=0;i<get_child_count();i++) {
+ Ref<StyleBox> sb = get_stylebox("panel");
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- if (idx==current) {
+ if (idx == current) {
c->show();
c->set_area_as_parent_rect();
if (tabs_visible)
- c->set_margin(MARGIN_TOP,_get_top_margin());
- for(int i=0;i<4;i++)
- c->set_margin(Margin(i),c->get_margin(Margin(i))+sb->get_margin(Margin(i)));
-
+ c->set_margin(MARGIN_TOP, _get_top_margin());
+ for (int i = 0; i < 4; i++)
+ c->set_margin(Margin(i), c->get_margin(Margin(i)) + sb->get_margin(Margin(i)));
} else
c->hide();
@@ -480,7 +448,7 @@ void TabContainer::set_current_tab(int p_current) {
}
_change_notify("current_tab");
-
+
if (pending_previous != current)
previous = pending_previous;
@@ -496,25 +464,23 @@ int TabContainer::get_current_tab() const {
}
int TabContainer::get_previous_tab() const {
-
- return previous;
-}
-Control* TabContainer::get_tab_control(int p_idx) const {
+ return previous;
+}
- int idx=0;
+Control *TabContainer::get_tab_control(int p_idx) const {
+ int idx = 0;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- if (idx==p_idx) {
+ if (idx == p_idx) {
return c;
-
}
idx++;
}
@@ -522,21 +488,19 @@ Control* TabContainer::get_tab_control(int p_idx) const {
return NULL;
}
-Control* TabContainer::get_current_tab_control() const {
-
- int idx=0;
+Control *TabContainer::get_current_tab_control() const {
+ int idx = 0;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- if (idx==current) {
+ if (idx == current) {
return c;
-
}
idx++;
}
@@ -547,24 +511,24 @@ Control* TabContainer::get_current_tab_control() const {
void TabContainer::remove_child_notify(Node *p_child) {
int tc = get_tab_count();
- if (current==tc-1) {
+ if (current == tc - 1) {
current--;
- if (current<0)
- current=0;
+ if (current < 0)
+ current = 0;
else {
- call_deferred("set_current_tab",current);
+ call_deferred("set_current_tab", current);
}
}
- p_child->disconnect("renamed", this,"_child_renamed_callback");
+ p_child->disconnect("renamed", this, "_child_renamed_callback");
update();
}
void TabContainer::set_tab_align(TabAlign p_align) {
- ERR_FAIL_INDEX(p_align,3);
- align=p_align;
+ ERR_FAIL_INDEX(p_align, 3);
+ align = p_align;
update();
_change_notify("tab_align");
@@ -577,21 +541,20 @@ TabContainer::TabAlign TabContainer::get_tab_align() const {
void TabContainer::set_tabs_visible(bool p_visibe) {
- if (p_visibe==tabs_visible)
+ if (p_visibe == tabs_visible)
return;
- tabs_visible=p_visibe;
+ tabs_visible = p_visibe;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (p_visibe)
- c->set_margin(MARGIN_TOP,_get_top_margin());
+ c->set_margin(MARGIN_TOP, _get_top_margin());
else
- c->set_margin(MARGIN_TOP,0);
-
+ c->set_margin(MARGIN_TOP, 0);
}
update();
}
@@ -599,60 +562,53 @@ void TabContainer::set_tabs_visible(bool p_visibe) {
bool TabContainer::are_tabs_visible() const {
return tabs_visible;
-
}
-
Control *TabContainer::_get_tab(int p_idx) const {
- int idx=0;
+ int idx = 0;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
continue;
if (c->is_set_as_toplevel())
continue;
- if (idx==p_idx)
+ if (idx == p_idx)
return c;
idx++;
-
}
return NULL;
-
}
-void TabContainer::set_tab_title(int p_tab,const String& p_title) {
+void TabContainer::set_tab_title(int p_tab, const String &p_title) {
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
- child->set_meta("_tab_name",p_title);
-
+ child->set_meta("_tab_name", p_title);
}
-String TabContainer::get_tab_title(int p_tab) const{
+String TabContainer::get_tab_title(int p_tab) const {
Control *child = _get_tab(p_tab);
- ERR_FAIL_COND_V(!child,"");
+ ERR_FAIL_COND_V(!child, "");
if (child->has_meta("_tab_name"))
return child->get_meta("_tab_name");
else
return child->get_name();
-
}
-void TabContainer::set_tab_icon(int p_tab,const Ref<Texture>& p_icon){
+void TabContainer::set_tab_icon(int p_tab, const Ref<Texture> &p_icon) {
Control *child = _get_tab(p_tab);
ERR_FAIL_COND(!child);
- child->set_meta("_tab_icon",p_icon);
-
+ child->set_meta("_tab_icon", p_icon);
}
-Ref<Texture> TabContainer::get_tab_icon(int p_tab) const{
+Ref<Texture> TabContainer::get_tab_icon(int p_tab) const {
Control *child = _get_tab(p_tab);
- ERR_FAIL_COND_V(!child,Ref<Texture>());
+ ERR_FAIL_COND_V(!child, Ref<Texture>());
if (child->has_meta("_tab_icon"))
return child->get_meta("_tab_icon");
else
@@ -661,7 +617,7 @@ Ref<Texture> TabContainer::get_tab_icon(int p_tab) const{
void TabContainer::get_translatable_strings(List<String> *p_strings) const {
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -674,17 +630,16 @@ void TabContainer::get_translatable_strings(List<String> *p_strings) const {
String name = c->get_meta("_tab_name");
- if (name!="")
+ if (name != "")
p_strings->push_back(name);
}
}
-
Size2 TabContainer::get_minimum_size() const {
Size2 ms;
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
Control *c = get_child(i)->cast_to<Control>();
if (!c)
@@ -696,52 +651,51 @@ Size2 TabContainer::get_minimum_size() const {
continue;
Size2 cms = c->get_combined_minimum_size();
- ms.x=MAX(ms.x,cms.x);
- ms.y=MAX(ms.y,cms.y);
+ ms.x = MAX(ms.x, cms.x);
+ ms.y = MAX(ms.y, cms.y);
}
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
Ref<Font> font = get_font("font");
- ms.y+=MAX(tab_bg->get_minimum_size().y,tab_fg->get_minimum_size().y);
- ms.y+=font->get_height();
+ ms.y += MAX(tab_bg->get_minimum_size().y, tab_fg->get_minimum_size().y);
+ ms.y += font->get_height();
Ref<StyleBox> sb = get_stylebox("panel");
- ms+=sb->get_minimum_size();
+ ms += sb->get_minimum_size();
return ms;
}
void TabContainer::set_popup(Node *p_popup) {
ERR_FAIL_NULL(p_popup);
- popup=p_popup->cast_to<Popup>();
+ popup = p_popup->cast_to<Popup>();
update();
}
-Popup* TabContainer::get_popup() const {
+Popup *TabContainer::get_popup() const {
return popup;
}
-
void TabContainer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_input_event"), &TabContainer::_input_event);
ObjectTypeDB::bind_method(_MD("get_tab_count"), &TabContainer::get_tab_count);
- ObjectTypeDB::bind_method(_MD("set_current_tab","tab_idx"), &TabContainer::set_current_tab);
+ ObjectTypeDB::bind_method(_MD("set_current_tab", "tab_idx"), &TabContainer::set_current_tab);
ObjectTypeDB::bind_method(_MD("get_current_tab"), &TabContainer::get_current_tab);
ObjectTypeDB::bind_method(_MD("get_previous_tab"), &TabContainer::get_previous_tab);
ObjectTypeDB::bind_method(_MD("get_current_tab_control:Control"), &TabContainer::get_current_tab_control);
- ObjectTypeDB::bind_method(_MD("get_tab_control:Control","idx"), &TabContainer::get_tab_control);
- ObjectTypeDB::bind_method(_MD("set_tab_align","align"), &TabContainer::set_tab_align);
+ ObjectTypeDB::bind_method(_MD("get_tab_control:Control", "idx"), &TabContainer::get_tab_control);
+ ObjectTypeDB::bind_method(_MD("set_tab_align", "align"), &TabContainer::set_tab_align);
ObjectTypeDB::bind_method(_MD("get_tab_align"), &TabContainer::get_tab_align);
- ObjectTypeDB::bind_method(_MD("set_tabs_visible","visible"), &TabContainer::set_tabs_visible);
+ ObjectTypeDB::bind_method(_MD("set_tabs_visible", "visible"), &TabContainer::set_tabs_visible);
ObjectTypeDB::bind_method(_MD("are_tabs_visible"), &TabContainer::are_tabs_visible);
- ObjectTypeDB::bind_method(_MD("set_tab_title","tab_idx","title"), &TabContainer::set_tab_title);
- ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"), &TabContainer::get_tab_title);
- ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"), &TabContainer::set_tab_icon);
- ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"), &TabContainer::get_tab_icon);
- ObjectTypeDB::bind_method(_MD("set_popup","popup:Popup"), &TabContainer::set_popup);
+ ObjectTypeDB::bind_method(_MD("set_tab_title", "tab_idx", "title"), &TabContainer::set_tab_title);
+ ObjectTypeDB::bind_method(_MD("get_tab_title", "tab_idx"), &TabContainer::get_tab_title);
+ ObjectTypeDB::bind_method(_MD("set_tab_icon", "tab_idx", "icon:Texture"), &TabContainer::set_tab_icon);
+ ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture", "tab_idx"), &TabContainer::get_tab_icon);
+ ObjectTypeDB::bind_method(_MD("set_popup", "popup:Popup"), &TabContainer::set_popup);
ObjectTypeDB::bind_method(_MD("get_popup:Popup"), &TabContainer::get_popup);
ObjectTypeDB::bind_method(_MD("_child_renamed_callback"), &TabContainer::_child_renamed_callback);
@@ -750,10 +704,9 @@ void TabContainer::_bind_methods() {
ADD_SIGNAL(MethodInfo("tab_selected", PropertyInfo(Variant::INT, "tab")));
ADD_SIGNAL(MethodInfo("pre_popup_pressed"));
- ADD_PROPERTY( PropertyInfo(Variant::INT, "tab_align", PROPERTY_HINT_ENUM,"Left,Center,Right"), _SCS("set_tab_align"), _SCS("get_tab_align") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE,"-1,4096,1",PROPERTY_USAGE_EDITOR), _SCS("set_current_tab"), _SCS("get_current_tab") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "tabs_visible"), _SCS("set_tabs_visible"), _SCS("are_tabs_visible") );
-
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "tab_align", PROPERTY_HINT_ENUM, "Left,Center,Right"), _SCS("set_tab_align"), _SCS("get_tab_align"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1", PROPERTY_USAGE_EDITOR), _SCS("set_current_tab"), _SCS("get_current_tab"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tabs_visible"), _SCS("set_tabs_visible"), _SCS("are_tabs_visible"));
}
TabContainer::TabContainer() {
@@ -767,5 +720,4 @@ TabContainer::TabContainer() {
align = ALIGN_CENTER;
tabs_visible = true;
popup = NULL;
-
}
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index 2142d4b82..c93eca6cf 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -29,22 +29,21 @@
#ifndef TAB_CONTAINER_H
#define TAB_CONTAINER_H
-
#include "scene/gui/control.h"
#include "scene/gui/popup.h"
class TabContainer : public Control {
- OBJ_TYPE( TabContainer, Control );
-public:
+ OBJ_TYPE(TabContainer, Control);
+public:
enum TabAlign {
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHT
};
-private:
+private:
int mouse_x_cache;
int tab_display_ofs;
int tabs_ofs_cache;
@@ -58,11 +57,9 @@ private:
int _get_top_margin() const;
Popup *popup;
-
protected:
-
void _child_renamed_callback();
- void _input_event(const InputEvent& p_event);
+ void _input_event(const InputEvent &p_event);
void _notification(int p_what);
virtual void add_child_notify(Node *p_child);
virtual void remove_child_notify(Node *p_child);
@@ -70,40 +67,36 @@ protected:
static void _bind_methods();
public:
-
-
void set_tab_align(TabAlign p_align);
TabAlign get_tab_align() const;
void set_tabs_visible(bool p_visibe);
bool are_tabs_visible() const;
- void set_tab_title(int p_tab,const String& p_title);
+ void set_tab_title(int p_tab, const String &p_title);
String get_tab_title(int p_tab) const;
- void set_tab_icon(int p_tab,const Ref<Texture>& p_icon);
+ void set_tab_icon(int p_tab, const Ref<Texture> &p_icon);
Ref<Texture> get_tab_icon(int p_tab) const;
int get_tab_count() const;
void set_current_tab(int p_current);
int get_current_tab() const;
int get_previous_tab() const;
-
- Control* get_tab_control(int p_idx) const;
- Control* get_current_tab_control() const;
+
+ Control *get_tab_control(int p_idx) const;
+ Control *get_current_tab_control() const;
virtual Size2 get_minimum_size() const;
virtual void get_translatable_strings(List<String> *p_strings) const;
void set_popup(Node *p_popup);
- Popup* get_popup() const;
-
+ Popup *get_popup() const;
TabContainer();
};
-
-VARIANT_ENUM_CAST( TabContainer::TabAlign );
+VARIANT_ENUM_CAST(TabContainer::TabAlign);
#endif // TAB_CONTAINER_H
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 83e51eb6c..5d72166cb 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -36,150 +36,144 @@ Size2 Tabs::get_minimum_size() const {
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
Ref<Font> font = get_font("font");
- Size2 ms(0, MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height)+font->get_height());
+ Size2 ms(0, MAX(tab_bg->get_minimum_size().height, tab_fg->get_minimum_size().height) + font->get_height());
- for(int i=0;i<tabs.size();i++) {
+ for (int i = 0; i < tabs.size(); i++) {
Ref<Texture> tex = tabs[i].icon;
if (tex.is_valid()) {
ms.height = MAX(ms.height, tex->get_size().height);
- if (tabs[i].text!="")
- ms.width+=get_constant("hseparation");
+ if (tabs[i].text != "")
+ ms.width += get_constant("hseparation");
}
- ms.width+=font->get_string_size(tabs[i].text).width;
+ ms.width += font->get_string_size(tabs[i].text).width;
- if (current==i)
- ms.width+=tab_fg->get_minimum_size().width;
+ if (current == i)
+ ms.width += tab_fg->get_minimum_size().width;
else
- ms.width+=tab_bg->get_minimum_size().width;
+ ms.width += tab_bg->get_minimum_size().width;
if (tabs[i].right_button.is_valid()) {
- Ref<Texture> rb=tabs[i].right_button;
+ Ref<Texture> rb = tabs[i].right_button;
Size2 bms = rb->get_size();
- bms.width+=get_constant("hseparation");
- ms.width+=bms.width;
- ms.height=MAX(bms.height+tab_bg->get_minimum_size().height,ms.height);
+ bms.width += get_constant("hseparation");
+ ms.width += bms.width;
+ ms.height = MAX(bms.height + tab_bg->get_minimum_size().height, ms.height);
}
- if (cb_displaypolicy==CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy==CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i==current)) {
- Ref<Texture> cb=get_icon("close");
+ if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) {
+ Ref<Texture> cb = get_icon("close");
Size2 bms = cb->get_size();
- bms.width+=get_constant("hseparation");
- ms.width+=bms.width;
- ms.height=MAX(bms.height+tab_bg->get_minimum_size().height,ms.height);
+ bms.width += get_constant("hseparation");
+ ms.width += bms.width;
+ ms.height = MAX(bms.height + tab_bg->get_minimum_size().height, ms.height);
}
}
- ms.width=0; //TODO: should make this optional
+ ms.width = 0; //TODO: should make this optional
return ms;
}
+void Tabs::_input_event(const InputEvent &p_event) {
-void Tabs::_input_event(const InputEvent& p_event) {
+ if (p_event.type == InputEvent::MOUSE_MOTION) {
- if (p_event.type==InputEvent::MOUSE_MOTION) {
+ Point2 pos(p_event.mouse_motion.x, p_event.mouse_motion.y);
- Point2 pos( p_event.mouse_motion.x, p_event.mouse_motion.y );
-
- hilite_arrow=-1;
+ hilite_arrow = -1;
if (buttons_visible) {
Ref<Texture> incr = get_icon("increment");
Ref<Texture> decr = get_icon("decrement");
- int limit=get_size().width-incr->get_width()-decr->get_width();
+ int limit = get_size().width - incr->get_width() - decr->get_width();
- if (pos.x>limit+decr->get_width()) {
- hilite_arrow=1;
- } else if (pos.x>limit) {
- hilite_arrow=0;
+ if (pos.x > limit + decr->get_width()) {
+ hilite_arrow = 1;
+ } else if (pos.x > limit) {
+ hilite_arrow = 0;
}
}
// test hovering to display right or close button
- int hover_buttons=-1;
- hover=-1;
- for(int i=0;i<tabs.size();i++) {
+ int hover_buttons = -1;
+ hover = -1;
+ for (int i = 0; i < tabs.size(); i++) {
- if (i<offset)
+ if (i < offset)
continue;
if (tabs[i].rb_rect.has_point(pos)) {
- rb_hover=i;
- cb_hover=-1;
+ rb_hover = i;
+ cb_hover = -1;
hover_buttons = i;
break;
- }
- else if (tabs[i].cb_rect.has_point(pos)) {
- cb_hover=i;
- rb_hover=-1;
+ } else if (tabs[i].cb_rect.has_point(pos)) {
+ cb_hover = i;
+ rb_hover = -1;
hover_buttons = i;
break;
}
-
}
if (hover_buttons == -1) { // no hover
- rb_hover= hover_buttons;
- cb_hover= hover_buttons;
+ rb_hover = hover_buttons;
+ cb_hover = hover_buttons;
}
update();
return;
}
+ if (rb_pressing && p_event.type == InputEvent::MOUSE_BUTTON &&
+ !p_event.mouse_button.pressed &&
+ p_event.mouse_button.button_index == BUTTON_LEFT) {
- if (rb_pressing && p_event.type==InputEvent::MOUSE_BUTTON &&
- !p_event.mouse_button.pressed &&
- p_event.mouse_button.button_index==BUTTON_LEFT) {
-
- if (rb_hover!=-1) {
+ if (rb_hover != -1) {
//pressed
- emit_signal("right_button_pressed",rb_hover);
+ emit_signal("right_button_pressed", rb_hover);
}
- rb_pressing=false;
+ rb_pressing = false;
update();
}
+ if (cb_pressing && p_event.type == InputEvent::MOUSE_BUTTON &&
+ !p_event.mouse_button.pressed &&
+ p_event.mouse_button.button_index == BUTTON_LEFT) {
- if (cb_pressing && p_event.type==InputEvent::MOUSE_BUTTON &&
- !p_event.mouse_button.pressed &&
- p_event.mouse_button.button_index==BUTTON_LEFT) {
-
- if (cb_hover!=-1) {
+ if (cb_hover != -1) {
//pressed
- emit_signal("tab_close",cb_hover);
+ emit_signal("tab_close", cb_hover);
}
- cb_pressing=false;
+ cb_pressing = false;
update();
}
-
- if (p_event.type==InputEvent::MOUSE_BUTTON &&
- p_event.mouse_button.pressed &&
- p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON &&
+ p_event.mouse_button.pressed &&
+ p_event.mouse_button.button_index == BUTTON_LEFT) {
// clicks
- Point2 pos( p_event.mouse_button.x, p_event.mouse_button.y );
+ Point2 pos(p_event.mouse_button.x, p_event.mouse_button.y);
if (buttons_visible) {
Ref<Texture> incr = get_icon("increment");
Ref<Texture> decr = get_icon("decrement");
- int limit=get_size().width-incr->get_width()-decr->get_width();
+ int limit = get_size().width - incr->get_width() - decr->get_width();
- if (pos.x>limit+decr->get_width()) {
+ if (pos.x > limit + decr->get_width()) {
if (missing_right) {
offset++;
update();
}
return;
- } else if (pos.x>limit) {
- if (offset>0) {
+ } else if (pos.x > limit) {
+ if (offset > 0) {
offset--;
update();
}
@@ -187,49 +181,46 @@ void Tabs::_input_event(const InputEvent& p_event) {
}
}
- int found=-1;
- for(int i=0;i<tabs.size();i++) {
+ int found = -1;
+ for (int i = 0; i < tabs.size(); i++) {
- if (i<offset)
+ if (i < offset)
continue;
if (tabs[i].rb_rect.has_point(pos)) {
- rb_pressing=true;
+ rb_pressing = true;
update();
return;
}
if (tabs[i].cb_rect.has_point(pos)) {
- cb_pressing=true;
+ cb_pressing = true;
update();
return;
}
- if (pos.x >=tabs[i].ofs_cache && pos.x<tabs[i].ofs_cache+tabs[i].size_cache) {
- found=i;
+ if (pos.x >= tabs[i].ofs_cache && pos.x < tabs[i].ofs_cache + tabs[i].size_cache) {
+ found = i;
break;
}
}
-
- if (found!=-1) {
+ if (found != -1) {
set_current_tab(found);
- emit_signal("tab_changed",found);
+ emit_signal("tab_changed", found);
}
}
-
}
-
void Tabs::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_MOUSE_EXIT: {
- rb_hover=-1;
- cb_hover=-1;
- hover=-1;
+ rb_hover = -1;
+ cb_hover = -1;
+ hover = -1;
update();
} break;
case NOTIFICATION_RESIZED: {
@@ -245,27 +236,26 @@ void Tabs::_notification(int p_what) {
Ref<Font> font = get_font("font");
Color color_fg = get_color("font_color_fg");
Color color_bg = get_color("font_color_bg");
- Ref<Texture> close=get_icon("close");
+ Ref<Texture> close = get_icon("close");
int h = get_size().height;
int w = 0;
int mw = 0;
- for(int i=0;i<tabs.size();i++) {
+ for (int i = 0; i < tabs.size(); i++) {
tabs[i].ofs_cache = mw;
mw += get_tab_width(i);
}
-
- if (tab_align==ALIGN_CENTER) {
- w=(get_size().width-mw)/2;
- } else if (tab_align==ALIGN_RIGHT) {
- w=get_size().width-mw;
+ if (tab_align == ALIGN_CENTER) {
+ w = (get_size().width - mw) / 2;
+ } else if (tab_align == ALIGN_RIGHT) {
+ w = get_size().width - mw;
}
- if (w<0) {
- w=0;
+ if (w < 0) {
+ w = 0;
}
Ref<Texture> incr = get_icon("increment");
@@ -273,134 +263,129 @@ void Tabs::_notification(int p_what) {
Ref<Texture> incr_hl = get_icon("increment_hilite");
Ref<Texture> decr_hl = get_icon("decrement_hilite");
- int limit=get_size().width - incr->get_size().width - decr->get_size().width;
+ int limit = get_size().width - incr->get_size().width - decr->get_size().width;
- missing_right=false;
+ missing_right = false;
- for(int i=0;i<tabs.size();i++) {
+ for (int i = 0; i < tabs.size(); i++) {
- if (i<offset)
+ if (i < offset)
continue;
- tabs[i].ofs_cache=w;
+ tabs[i].ofs_cache = w;
int lsize = get_tab_width(i);
String text = tabs[i].text;
int slen = font->get_string_size(text).width;
- if (w+lsize > limit) {
- max_drawn_tab=i-1;
- missing_right=true;
+ if (w + lsize > limit) {
+ max_drawn_tab = i - 1;
+ missing_right = true;
break;
} else {
- max_drawn_tab=i;
+ max_drawn_tab = i;
}
-
Ref<StyleBox> sb;
Color col;
- if (i==current) {
- sb=tab_fg;
- col=color_fg;
+ if (i == current) {
+ sb = tab_fg;
+ col = color_fg;
} else {
- sb=tab_bg;
- col=color_bg;
+ sb = tab_bg;
+ col = color_bg;
}
-
Rect2 sb_rect = Rect2(w, 0, lsize, h);
sb->draw(ci, sb_rect);
- w+=sb->get_margin(MARGIN_LEFT);
+ w += sb->get_margin(MARGIN_LEFT);
Size2i sb_ms = sb->get_minimum_size();
Ref<Texture> icon = tabs[i].icon;
if (icon.is_valid()) {
- icon->draw(ci, Point2i( w, sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-icon->get_height())/2 ) );
- if (text!="")
- w+=icon->get_width()+get_constant("hseparation");
-
+ icon->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2));
+ if (text != "")
+ w += icon->get_width() + get_constant("hseparation");
}
- font->draw(ci, Point2i( w, sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-font->get_height())/2+font->get_ascent() ), text, col );
+ font->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - font->get_height()) / 2 + font->get_ascent()), text, col);
- w+=slen;
+ w += slen;
if (tabs[i].right_button.is_valid()) {
Ref<StyleBox> style = get_stylebox("button");
- Ref<Texture> rb=tabs[i].right_button;
+ Ref<Texture> rb = tabs[i].right_button;
- w+=get_constant("hseparation");
+ w += get_constant("hseparation");
Rect2 rb_rect;
- rb_rect.size=style->get_minimum_size()+rb->get_size();
- rb_rect.pos.x=w;
- rb_rect.pos.y=sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-(rb_rect.size.y))/2;
+ rb_rect.size = style->get_minimum_size() + rb->get_size();
+ rb_rect.pos.x = w;
+ rb_rect.pos.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (rb_rect.size.y)) / 2;
- if (rb_hover==i) {
+ if (rb_hover == i) {
if (rb_pressing)
- get_stylebox("button_pressed")->draw(ci,rb_rect);
+ get_stylebox("button_pressed")->draw(ci, rb_rect);
else
- style->draw(ci,rb_rect);
+ style->draw(ci, rb_rect);
}
- rb->draw(ci,Point2i( w+style->get_margin(MARGIN_LEFT), rb_rect.pos.y+style->get_margin(MARGIN_TOP) ));
- w+=rb->get_width();
- tabs[i].rb_rect=rb_rect;
-
+ rb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), rb_rect.pos.y + style->get_margin(MARGIN_TOP)));
+ w += rb->get_width();
+ tabs[i].rb_rect = rb_rect;
}
- if (cb_displaypolicy==CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy==CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i==current)) {
+ if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) {
Ref<StyleBox> style = get_stylebox("button");
- Ref<Texture> cb=close;
+ Ref<Texture> cb = close;
- w+=get_constant("hseparation");
+ w += get_constant("hseparation");
Rect2 cb_rect;
- cb_rect.size=style->get_minimum_size()+cb->get_size();
- cb_rect.pos.x=w;
- cb_rect.pos.y=sb->get_margin(MARGIN_TOP)+((sb_rect.size.y-sb_ms.y)-(cb_rect.size.y))/2;
+ cb_rect.size = style->get_minimum_size() + cb->get_size();
+ cb_rect.pos.x = w;
+ cb_rect.pos.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (cb_rect.size.y)) / 2;
- if (cb_hover==i) {
+ if (cb_hover == i) {
if (cb_pressing)
- get_stylebox("button_pressed")->draw(ci,cb_rect);
+ get_stylebox("button_pressed")->draw(ci, cb_rect);
else
- style->draw(ci,cb_rect);
+ style->draw(ci, cb_rect);
}
- cb->draw(ci,Point2i( w+style->get_margin(MARGIN_LEFT), cb_rect.pos.y+style->get_margin(MARGIN_TOP) ));
- w+=cb->get_width();
- tabs[i].cb_rect=cb_rect;
+ cb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), cb_rect.pos.y + style->get_margin(MARGIN_TOP)));
+ w += cb->get_width();
+ tabs[i].cb_rect = cb_rect;
}
- w+=sb->get_margin(MARGIN_RIGHT);
-
- tabs[i].size_cache=w-tabs[i].ofs_cache;
+ w += sb->get_margin(MARGIN_RIGHT);
+ tabs[i].size_cache = w - tabs[i].ofs_cache;
}
- if (offset>0 || missing_right) {
+ if (offset > 0 || missing_right) {
- int vofs = (get_size().height-incr->get_size().height)/2;
+ int vofs = (get_size().height - incr->get_size().height) / 2;
- if (offset>0)
- draw_texture(hilite_arrow==0 ? decr_hl : decr, Point2(limit,vofs));
+ if (offset > 0)
+ draw_texture(hilite_arrow == 0 ? decr_hl : decr, Point2(limit, vofs));
else
- draw_texture(decr,Point2(limit,vofs), Color(1,1,1,0.5));
+ draw_texture(decr, Point2(limit, vofs), Color(1, 1, 1, 0.5));
if (missing_right)
- draw_texture(hilite_arrow==1 ? incr_hl : incr, Point2(limit+decr->get_size().width,vofs));
+ draw_texture(hilite_arrow == 1 ? incr_hl : incr, Point2(limit + decr->get_size().width, vofs));
else
- draw_texture(incr,Point2(limit+decr->get_size().width,vofs), Color(1,1,1,0.5));
+ draw_texture(incr, Point2(limit + decr->get_size().width, vofs), Color(1, 1, 1, 0.5));
- buttons_visible=true;
+ buttons_visible = true;
} else {
- buttons_visible=false;
+ buttons_visible = false;
}
} break;
@@ -412,12 +397,11 @@ int Tabs::get_tab_count() const {
return tabs.size();
}
-
void Tabs::set_current_tab(int p_current) {
- ERR_FAIL_INDEX( p_current, get_tab_count() );
+ ERR_FAIL_INDEX(p_current, get_tab_count());
- current=p_current;
+ current = p_current;
_change_notify("current_tab");
update();
@@ -428,98 +412,85 @@ int Tabs::get_current_tab() const {
return current;
}
+void Tabs::set_tab_title(int p_tab, const String &p_title) {
-void Tabs::set_tab_title(int p_tab,const String& p_title) {
-
- ERR_FAIL_INDEX(p_tab,tabs.size());
- tabs[p_tab].text=p_title;
+ ERR_FAIL_INDEX(p_tab, tabs.size());
+ tabs[p_tab].text = p_title;
update();
minimum_size_changed();
-
}
-String Tabs::get_tab_title(int p_tab) const{
+String Tabs::get_tab_title(int p_tab) const {
- ERR_FAIL_INDEX_V(p_tab,tabs.size(),"");
+ ERR_FAIL_INDEX_V(p_tab, tabs.size(), "");
return tabs[p_tab].text;
-
}
+void Tabs::set_tab_icon(int p_tab, const Ref<Texture> &p_icon) {
-void Tabs::set_tab_icon(int p_tab,const Ref<Texture>& p_icon){
-
- ERR_FAIL_INDEX(p_tab,tabs.size());
- tabs[p_tab].icon=p_icon;
+ ERR_FAIL_INDEX(p_tab, tabs.size());
+ tabs[p_tab].icon = p_icon;
update();
minimum_size_changed();
-
}
-Ref<Texture> Tabs::get_tab_icon(int p_tab) const{
+Ref<Texture> Tabs::get_tab_icon(int p_tab) const {
- ERR_FAIL_INDEX_V(p_tab,tabs.size(),Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture>());
return tabs[p_tab].icon;
-
}
+void Tabs::set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button) {
-void Tabs::set_tab_right_button(int p_tab,const Ref<Texture>& p_right_button){
-
- ERR_FAIL_INDEX(p_tab,tabs.size());
- tabs[p_tab].right_button=p_right_button;
+ ERR_FAIL_INDEX(p_tab, tabs.size());
+ tabs[p_tab].right_button = p_right_button;
update();
minimum_size_changed();
-
}
-Ref<Texture> Tabs::get_tab_right_button(int p_tab) const{
+Ref<Texture> Tabs::get_tab_right_button(int p_tab) const {
- ERR_FAIL_INDEX_V(p_tab,tabs.size(),Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture>());
return tabs[p_tab].right_button;
-
}
-
-void Tabs::add_tab(const String& p_str,const Ref<Texture>& p_icon) {
+void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) {
Tab t;
- t.text=p_str;
- t.icon=p_icon;
+ t.text = p_str;
+ t.icon = p_icon;
tabs.push_back(t);
update();
minimum_size_changed();
-
}
void Tabs::clear_tabs() {
tabs.clear();
- current=0;
+ current = 0;
update();
}
void Tabs::remove_tab(int p_idx) {
- ERR_FAIL_INDEX(p_idx,tabs.size());
+ ERR_FAIL_INDEX(p_idx, tabs.size());
tabs.remove(p_idx);
- if (current>=p_idx)
+ if (current >= p_idx)
current--;
update();
minimum_size_changed();
- if (current<0)
- current=0;
- if (current>=tabs.size())
- current=tabs.size()-1;
+ if (current < 0)
+ current = 0;
+ if (current >= tabs.size())
+ current = tabs.size() - 1;
_ensure_no_over_offset();
-
}
-
void Tabs::set_tab_align(TabAlign p_align) {
- tab_align=p_align;
+ tab_align = p_align;
update();
}
@@ -530,46 +501,43 @@ Tabs::TabAlign Tabs::get_tab_align() const {
int Tabs::get_tab_width(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,tabs.size(),0);
+ ERR_FAIL_INDEX_V(p_idx, tabs.size(), 0);
Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
Ref<Font> font = get_font("font");
-
- int x=0;
+ int x = 0;
Ref<Texture> tex = tabs[p_idx].icon;
if (tex.is_valid()) {
- x+=tex->get_width();
- if (tabs[p_idx].text!="")
- x+=get_constant("hseparation");
-
+ x += tex->get_width();
+ if (tabs[p_idx].text != "")
+ x += get_constant("hseparation");
}
- x+=font->get_string_size(tabs[p_idx].text).width;
+ x += font->get_string_size(tabs[p_idx].text).width;
- if (current==p_idx)
- x+=tab_fg->get_minimum_size().width;
+ if (current == p_idx)
+ x += tab_fg->get_minimum_size().width;
else
- x+=tab_bg->get_minimum_size().width;
+ x += tab_bg->get_minimum_size().width;
if (tabs[p_idx].right_button.is_valid()) {
- Ref<Texture> rb=tabs[p_idx].right_button;
- x+=rb->get_width();
- x+=get_constant("hseparation");
+ Ref<Texture> rb = tabs[p_idx].right_button;
+ x += rb->get_width();
+ x += get_constant("hseparation");
}
- if (cb_displaypolicy==CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy==CLOSE_BUTTON_SHOW_ACTIVE_ONLY && p_idx==current)) {
- Ref<Texture> cb=get_icon("close");
- x+=cb->get_width();
- x+=get_constant("hseparation");
+ if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && p_idx == current)) {
+ Ref<Texture> cb = get_icon("close");
+ x += cb->get_width();
+ x += get_constant("hseparation");
}
return x;
}
-
void Tabs::_ensure_no_over_offset() {
if (!is_inside_tree())
@@ -578,17 +546,17 @@ void Tabs::_ensure_no_over_offset() {
Ref<Texture> incr = get_icon("increment");
Ref<Texture> decr = get_icon("decrement");
- int limit=get_size().width-incr->get_width()-decr->get_width();
+ int limit = get_size().width - incr->get_width() - decr->get_width();
- while(offset>0) {
+ while (offset > 0) {
- int total_w=0;
- for(int i=0;i<tabs.size();i++) {
+ int total_w = 0;
+ for (int i = 0; i < tabs.size(); i++) {
- if (i<offset-1)
+ if (i < offset - 1)
continue;
- total_w+=get_tab_width(i);
+ total_w += get_tab_width(i);
}
if (total_w < limit) {
@@ -598,44 +566,40 @@ void Tabs::_ensure_no_over_offset() {
break;
}
}
-
}
-
void Tabs::ensure_tab_visible(int p_idx) {
if (!is_inside_tree())
return;
- ERR_FAIL_INDEX(p_idx,tabs.size());
+ ERR_FAIL_INDEX(p_idx, tabs.size());
_ensure_no_over_offset();
- if (p_idx<=offset) {
- offset=p_idx;
+ if (p_idx <= offset) {
+ offset = p_idx;
update();
return;
}
Ref<Texture> incr = get_icon("increment");
Ref<Texture> decr = get_icon("decrement");
- int limit=get_size().width-incr->get_width()-decr->get_width();
-
+ int limit = get_size().width - incr->get_width() - decr->get_width();
- int x=0;
- for(int i=0;i<tabs.size();i++) {
+ int x = 0;
+ for (int i = 0; i < tabs.size(); i++) {
- if (i<offset)
+ if (i < offset)
continue;
int sz = get_tab_width(i);
- tabs[i].x_cache=x;
- tabs[i].x_size_cache=sz;
- x+=sz;
-
+ tabs[i].x_cache = x;
+ tabs[i].x_size_cache = sz;
+ x += sz;
}
- while(offset<tabs.size() && ( (tabs[p_idx].x_cache + tabs[p_idx].x_size_cache) - tabs[offset].x_cache) > limit) {
+ while (offset < tabs.size() && ((tabs[p_idx].x_cache + tabs[p_idx].x_size_cache) - tabs[offset].x_cache) > limit) {
offset++;
}
@@ -643,55 +607,52 @@ void Tabs::ensure_tab_visible(int p_idx) {
}
void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
- cb_displaypolicy=p_policy;
+ cb_displaypolicy = p_policy;
update();
}
void Tabs::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&Tabs::_input_event);
- ObjectTypeDB::bind_method(_MD("get_tab_count"),&Tabs::get_tab_count);
- ObjectTypeDB::bind_method(_MD("set_current_tab","tab_idx"),&Tabs::set_current_tab);
- ObjectTypeDB::bind_method(_MD("get_current_tab"),&Tabs::get_current_tab);
- ObjectTypeDB::bind_method(_MD("set_tab_title","tab_idx","title"),&Tabs::set_tab_title);
- ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"),&Tabs::get_tab_title);
- ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon);
- ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon);
- ObjectTypeDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab);
- ObjectTypeDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab);
- ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align);
- ObjectTypeDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align);
- ObjectTypeDB::bind_method(_MD("ensure_tab_visible","idx"),&Tabs::ensure_tab_visible);
-
- ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
- ADD_SIGNAL(MethodInfo("right_button_pressed",PropertyInfo(Variant::INT,"tab")));
- ADD_SIGNAL(MethodInfo("tab_close",PropertyInfo(Variant::INT,"tab")));
+ ObjectTypeDB::bind_method(_MD("_input_event"), &Tabs::_input_event);
+ ObjectTypeDB::bind_method(_MD("get_tab_count"), &Tabs::get_tab_count);
+ ObjectTypeDB::bind_method(_MD("set_current_tab", "tab_idx"), &Tabs::set_current_tab);
+ ObjectTypeDB::bind_method(_MD("get_current_tab"), &Tabs::get_current_tab);
+ ObjectTypeDB::bind_method(_MD("set_tab_title", "tab_idx", "title"), &Tabs::set_tab_title);
+ ObjectTypeDB::bind_method(_MD("get_tab_title", "tab_idx"), &Tabs::get_tab_title);
+ ObjectTypeDB::bind_method(_MD("set_tab_icon", "tab_idx", "icon:Texture"), &Tabs::set_tab_icon);
+ ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture", "tab_idx"), &Tabs::get_tab_icon);
+ ObjectTypeDB::bind_method(_MD("remove_tab", "tab_idx"), &Tabs::remove_tab);
+ ObjectTypeDB::bind_method(_MD("add_tab", "title", "icon:Texture"), &Tabs::add_tab);
+ ObjectTypeDB::bind_method(_MD("set_tab_align", "align"), &Tabs::set_tab_align);
+ ObjectTypeDB::bind_method(_MD("get_tab_align"), &Tabs::get_tab_align);
+ ObjectTypeDB::bind_method(_MD("ensure_tab_visible", "idx"), &Tabs::ensure_tab_visible);
- ADD_PROPERTY( PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE,"-1,4096,1",PROPERTY_USAGE_EDITOR), _SCS("set_current_tab"), _SCS("get_current_tab") );
+ ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab")));
+ ADD_SIGNAL(MethodInfo("right_button_pressed", PropertyInfo(Variant::INT, "tab")));
+ ADD_SIGNAL(MethodInfo("tab_close", PropertyInfo(Variant::INT, "tab")));
- BIND_CONSTANT( ALIGN_LEFT );
- BIND_CONSTANT( ALIGN_CENTER );
- BIND_CONSTANT( ALIGN_RIGHT );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1", PROPERTY_USAGE_EDITOR), _SCS("set_current_tab"), _SCS("get_current_tab"));
- BIND_CONSTANT( CLOSE_BUTTON_SHOW_ACTIVE_ONLY );
- BIND_CONSTANT( CLOSE_BUTTON_SHOW_ALWAYS );
- BIND_CONSTANT( CLOSE_BUTTON_SHOW_NEVER );
+ BIND_CONSTANT(ALIGN_LEFT);
+ BIND_CONSTANT(ALIGN_CENTER);
+ BIND_CONSTANT(ALIGN_RIGHT);
+ BIND_CONSTANT(CLOSE_BUTTON_SHOW_ACTIVE_ONLY);
+ BIND_CONSTANT(CLOSE_BUTTON_SHOW_ALWAYS);
+ BIND_CONSTANT(CLOSE_BUTTON_SHOW_NEVER);
}
-
Tabs::Tabs() {
- current=0;
- tab_align=ALIGN_CENTER;
- rb_hover=-1;
- rb_pressing=false;
- hilite_arrow=-1;
+ current = 0;
+ tab_align = ALIGN_CENTER;
+ rb_hover = -1;
+ rb_pressing = false;
+ hilite_arrow = -1;
- cb_hover=-1;
- cb_pressing=false;
+ cb_hover = -1;
+ cb_pressing = false;
cb_displaypolicy = CLOSE_BUTTON_SHOW_NEVER;
- offset=0;
- max_drawn_tab=0;
-
+ offset = 0;
+ max_drawn_tab = 0;
}
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index adbddd56e..efd1db822 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -33,9 +33,9 @@
class Tabs : public Control {
- OBJ_TYPE( Tabs, Control );
-public:
+ OBJ_TYPE(Tabs, Control);
+public:
enum TabAlign {
ALIGN_LEFT,
@@ -49,9 +49,8 @@ public:
CLOSE_BUTTON_SHOW_ACTIVE_ONLY,
CLOSE_BUTTON_SHOW_ALWAYS,
};
-private:
-
+private:
struct Tab {
String text;
@@ -64,10 +63,8 @@ private:
Ref<Texture> right_button;
Rect2 rb_rect;
Rect2 cb_rect;
-
};
-
int offset;
int max_drawn_tab;
int hilite_arrow;
@@ -85,28 +82,26 @@ private:
bool cb_pressing;
CloseButtonDisplayPolicy cb_displaypolicy;
- int hover; // hovered tab
+ int hover; // hovered tab
int get_tab_width(int p_idx) const;
void _ensure_no_over_offset();
protected:
-
- void _input_event(const InputEvent& p_event);
+ void _input_event(const InputEvent &p_event);
void _notification(int p_what);
static void _bind_methods();
public:
+ void add_tab(const String &p_str = "", const Ref<Texture> &p_icon = Ref<Texture>());
- void add_tab(const String& p_str="",const Ref<Texture>& p_icon=Ref<Texture>());
-
- void set_tab_title(int p_tab,const String& p_title);
+ void set_tab_title(int p_tab, const String &p_title);
String get_tab_title(int p_tab) const;
- void set_tab_icon(int p_tab,const Ref<Texture>& p_icon);
+ void set_tab_icon(int p_tab, const Ref<Texture> &p_icon);
Ref<Texture> get_tab_icon(int p_tab) const;
- void set_tab_right_button(int p_tab,const Ref<Texture>& p_right_button);
+ void set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button);
Ref<Texture> get_tab_right_button(int p_tab) const;
void set_tab_align(TabAlign p_align);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index fb8c87e56..73e1fdbf9 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -28,8 +28,8 @@
/*************************************************************************/
#include "text_edit.h"
-#include "os/keyboard.h"
#include "os/input.h"
+#include "os/keyboard.h"
#include "os/os.h"
#include "globals.h"
@@ -39,17 +39,17 @@
static bool _is_text_char(CharType c) {
- return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_';
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
}
static bool _is_symbol(CharType c) {
- return c!='_' && ((c>='!' && c<='/') || (c>=':' && c<='@') || (c>='[' && c<='`') || (c>='{' && c<='~') || c=='\t' || c==' ');
+ return c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t' || c == ' ');
}
static bool _is_char(CharType c) {
- return (c>='a' && c<='z') || (c>='A' && c<='Z') || c=='_';
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
}
static bool _is_number(CharType c) {
@@ -61,21 +61,19 @@ static bool _is_hex_symbol(CharType c) {
}
static bool _is_pair_right_symbol(CharType c) {
- return
- c == '"' ||
- c == '\'' ||
- c == ')' ||
- c == ']' ||
- c == '}';
+ return c == '"' ||
+ c == '\'' ||
+ c == ')' ||
+ c == ']' ||
+ c == '}';
}
static bool _is_pair_left_symbol(CharType c) {
- return
- c == '"' ||
- c == '\'' ||
- c == '(' ||
- c == '[' ||
- c == '{';
+ return c == '"' ||
+ c == '\'' ||
+ c == '(' ||
+ c == '[' ||
+ c == '{';
}
static bool _is_pair_symbol(CharType c) {
@@ -83,89 +81,88 @@ static bool _is_pair_symbol(CharType c) {
}
static CharType _get_right_pair_symbol(CharType c) {
- if(c == '"')
+ if (c == '"')
return '"';
- if(c == '\'')
+ if (c == '\'')
return '\'';
- if(c == '(')
+ if (c == '(')
return ')';
- if(c == '[')
+ if (c == '[')
return ']';
- if(c == '{')
+ if (c == '{')
return '}';
return 0;
}
-void TextEdit::Text::set_font(const Ref<Font>& p_font) {
+void TextEdit::Text::set_font(const Ref<Font> &p_font) {
- font=p_font;
+ font = p_font;
}
void TextEdit::Text::set_tab_size(int p_tab_size) {
- tab_size=p_tab_size;
+ tab_size = p_tab_size;
}
void TextEdit::Text::_update_line_cache(int p_line) const {
int w = 0;
- int tab_w=font->get_char_size(' ').width*tab_size;
+ int tab_w = font->get_char_size(' ').width * tab_size;
int len = text[p_line].data.length();
const CharType *str = text[p_line].data.c_str();
//update width
- for(int i=0;i<len;i++) {
- if (str[i]=='\t') {
+ for (int i = 0; i < len; i++) {
+ if (str[i] == '\t') {
- int left = w%tab_w;
- if (left==0)
- w+=tab_w;
+ int left = w % tab_w;
+ if (left == 0)
+ w += tab_w;
else
- w+=tab_w-w%tab_w; // is right...
+ w += tab_w - w % tab_w; // is right...
} else {
- w+=font->get_char_size(str[i],str[i+1]).width;
+ w += font->get_char_size(str[i], str[i + 1]).width;
}
}
-
- text[p_line].width_cache=w;
+ text[p_line].width_cache = w;
//update regions
text[p_line].region_info.clear();
- for(int i=0;i<len;i++) {
+ for (int i = 0; i < len; i++) {
if (!_is_symbol(str[i]))
continue;
- if (str[i]=='\\') {
+ if (str[i] == '\\') {
i++; //skip quoted anything
continue;
}
- int left=len-i;
+ int left = len - i;
- for(int j=0;j<color_regions->size();j++) {
+ for (int j = 0; j < color_regions->size(); j++) {
- const ColorRegion& cr=color_regions->operator [](j);
+ const ColorRegion &cr = color_regions->operator[](j);
/* BEGIN */
- int lr=cr.begin_key.length();
- if (lr==0 || lr>left)
+ int lr = cr.begin_key.length();
+ if (lr == 0 || lr > left)
continue;
- const CharType* kc = cr.begin_key.c_str();
+ const CharType *kc = cr.begin_key.c_str();
- bool match=true;
+ bool match = true;
- for(int k=0;k<lr;k++) {
- if (kc[k]!=str[i+k]) {
- match=false;
+ for (int k = 0; k < lr; k++) {
+ if (kc[k] != str[i + k]) {
+ match = false;
break;
}
}
@@ -173,26 +170,26 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
if (match) {
ColorRegionInfo cri;
- cri.end=false;
- cri.region=j;
- text[p_line].region_info[i]=cri;
- i+=lr-1;
+ cri.end = false;
+ cri.region = j;
+ text[p_line].region_info[i] = cri;
+ i += lr - 1;
break;
}
/* END */
- lr=cr.end_key.length();
- if (lr==0 || lr>left)
+ lr = cr.end_key.length();
+ if (lr == 0 || lr > left)
continue;
kc = cr.end_key.c_str();
- match=true;
+ match = true;
- for(int k=0;k<lr;k++) {
- if (kc[k]!=str[i+k]) {
- match=false;
+ for (int k = 0; k < lr; k++) {
+ if (kc[k] != str[i + k]) {
+ match = false;
break;
}
}
@@ -200,25 +197,22 @@ void TextEdit::Text::_update_line_cache(int p_line) const {
if (match) {
ColorRegionInfo cri;
- cri.end=true;
- cri.region=j;
- text[p_line].region_info[i]=cri;
- i+=lr-1;
+ cri.end = true;
+ cri.region = j;
+ text[p_line].region_info[i] = cri;
+ i += lr - 1;
break;
}
-
}
}
-
-
}
-const Map<int,TextEdit::Text::ColorRegionInfo>& TextEdit::Text::get_color_region_info(int p_line) {
+const Map<int, TextEdit::Text::ColorRegionInfo> &TextEdit::Text::get_color_region_info(int p_line) {
- Map<int,ColorRegionInfo> *cri=NULL;
- ERR_FAIL_INDEX_V(p_line,text.size(),*cri); //enjoy your crash
+ Map<int, ColorRegionInfo> *cri = NULL;
+ ERR_FAIL_INDEX_V(p_line, text.size(), *cri); //enjoy your crash
- if (text[p_line].width_cache==-1) {
+ if (text[p_line].width_cache == -1) {
_update_line_cache(p_line);
}
@@ -227,9 +221,9 @@ const Map<int,TextEdit::Text::ColorRegionInfo>& TextEdit::Text::get_color_region
int TextEdit::Text::get_line_width(int p_line) const {
- ERR_FAIL_INDEX_V(p_line,text.size(),-1);
+ ERR_FAIL_INDEX_V(p_line, text.size(), -1);
- if (text[p_line].width_cache==-1) {
+ if (text[p_line].width_cache == -1) {
_update_line_cache(p_line);
}
@@ -238,16 +232,14 @@ int TextEdit::Text::get_line_width(int p_line) const {
void TextEdit::Text::clear_caches() {
- for(int i=0;i<text.size();i++)
- text[i].width_cache=-1;
-
+ for (int i = 0; i < text.size(); i++)
+ text[i].width_cache = -1;
}
void TextEdit::Text::clear() {
-
text.clear();
- insert(0,"");
+ insert(0, "");
}
int TextEdit::Text::get_max_width() const {
@@ -255,29 +247,27 @@ int TextEdit::Text::get_max_width() const {
int max = 0;
- for(int i=0;i<text.size();i++)
- max=MAX(max,get_line_width(i));
+ for (int i = 0; i < text.size(); i++)
+ max = MAX(max, get_line_width(i));
return max;
-
}
-void TextEdit::Text::set(int p_line,const String& p_text) {
+void TextEdit::Text::set(int p_line, const String &p_text) {
- ERR_FAIL_INDEX(p_line,text.size());
+ ERR_FAIL_INDEX(p_line, text.size());
- text[p_line].width_cache=-1;
- text[p_line].data=p_text;
+ text[p_line].width_cache = -1;
+ text[p_line].data = p_text;
}
-
-void TextEdit::Text::insert(int p_at,const String& p_text) {
+void TextEdit::Text::insert(int p_at, const String &p_text) {
Line line;
- line.marked=false;
- line.breakpoint=false;
- line.width_cache=-1;
- line.data=p_text;
- text.insert(p_at,line);
+ line.marked = false;
+ line.breakpoint = false;
+ line.width_cache = -1;
+ line.data = p_text;
+ text.insert(p_at, line);
}
void TextEdit::Text::remove(int p_at) {
@@ -286,21 +276,17 @@ void TextEdit::Text::remove(int p_at) {
void TextEdit::_update_scrollbars() {
-
Size2 size = get_size();
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
+ v_scroll->set_begin(Point2(size.width - vmin.width, cache.style_normal->get_margin(MARGIN_TOP)));
+ v_scroll->set_end(Point2(size.width, size.height - cache.style_normal->get_margin(MARGIN_TOP) - cache.style_normal->get_margin(MARGIN_BOTTOM)));
+ h_scroll->set_begin(Point2(0, size.height - hmin.height));
+ h_scroll->set_end(Point2(size.width - vmin.width, size.height));
- v_scroll->set_begin( Point2(size.width - vmin.width, cache.style_normal->get_margin(MARGIN_TOP)) );
- v_scroll->set_end( Point2(size.width, size.height - cache.style_normal->get_margin(MARGIN_TOP) - cache.style_normal->get_margin(MARGIN_BOTTOM)) );
-
- h_scroll->set_begin( Point2( 0, size.height - hmin.height) );
- h_scroll->set_end( Point2(size.width-vmin.width, size.height) );
-
-
- int hscroll_rows = ((hmin.height-1)/get_row_height())+1;
+ int hscroll_rows = ((hmin.height - 1) / get_row_height()) + 1;
int visible_rows = get_visible_rows();
int total_rows = text.size();
if (scroll_past_end_of_file_enabled) {
@@ -318,28 +304,28 @@ void TextEdit::_update_scrollbars() {
total_width += cache.breakpoint_gutter_width;
}
- bool use_hscroll=true;
- bool use_vscroll=true;
+ bool use_hscroll = true;
+ bool use_vscroll = true;
if (total_rows <= visible_rows && total_width <= visible_width) {
//thanks yessopie for this clever bit of logic
- use_hscroll=false;
- use_vscroll=false;
+ use_hscroll = false;
+ use_vscroll = false;
} else {
if (total_rows > visible_rows && total_width <= visible_width - vscroll_pixels) {
//thanks yessopie for this clever bit of logic
- use_hscroll=false;
+ use_hscroll = false;
}
if (total_rows <= visible_rows - hscroll_rows && total_width > visible_width) {
//thanks yessopie for this clever bit of logic
- use_vscroll=false;
+ use_vscroll = false;
}
}
- updating_scrolls=true;
+ updating_scrolls = true;
if (use_vscroll) {
@@ -348,7 +334,7 @@ void TextEdit::_update_scrollbars() {
v_scroll->set_page(visible_rows);
v_scroll->set_val(cursor.line_ofs);
- } else {
+ } else {
cursor.line_ofs = 0;
v_scroll->hide();
}
@@ -365,24 +351,22 @@ void TextEdit::_update_scrollbars() {
h_scroll->hide();
}
-
-
- updating_scrolls=false;
+ updating_scrolls = false;
}
void TextEdit::_click_selection_held() {
- if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode!=Selection::MODE_NONE) {
+ if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode != Selection::MODE_NONE) {
- Point2 mp = Input::get_singleton()->get_mouse_pos()-get_global_pos();
+ Point2 mp = Input::get_singleton()->get_mouse_pos() - get_global_pos();
- int row,col;
- _get_mouse_pos(Point2i(mp.x,mp.y), row,col);
+ int row, col;
+ _get_mouse_pos(Point2i(mp.x, mp.y), row, col);
- select(selection.selecting_line,selection.selecting_column,row,col);
+ select(selection.selecting_line, selection.selecting_column, row, col);
- cursor_set_line( row );
- cursor_set_column( col );
+ cursor_set_line(row);
+ cursor_set_column(col);
update();
click_select_held->start();
@@ -393,25 +377,23 @@ void TextEdit::_click_selection_held() {
}
}
-
void TextEdit::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
_update_caches();
if (cursor_changed_dirty)
- MessageQueue::get_singleton()->push_call(this,"_cursor_changed_emit");
+ MessageQueue::get_singleton()->push_call(this, "_cursor_changed_emit");
if (text_changed_dirty)
- MessageQueue::get_singleton()->push_call(this,"_text_changed_emit");
+ MessageQueue::get_singleton()->push_call(this, "_text_changed_emit");
} break;
case NOTIFICATION_RESIZED: {
- cache.size=get_size();
+ cache.size = get_size();
adjust_viewport_to_cursor();
-
} break;
case NOTIFICATION_THEME_CHANGED: {
@@ -440,136 +422,130 @@ void TextEdit::_notification(int p_what) {
cache.breakpoint_gutter_width = 0;
}
- int line_number_char_count=0;
+ int line_number_char_count = 0;
{
- int lc=text.size()+1;
- cache.line_number_w=0;
- while(lc) {
- cache.line_number_w+=1;
- lc/=10;
+ int lc = text.size() + 1;
+ cache.line_number_w = 0;
+ while (lc) {
+ cache.line_number_w += 1;
+ lc /= 10;
};
if (line_numbers) {
- line_number_char_count=cache.line_number_w;
- cache.line_number_w=(cache.line_number_w+1)*cache.font->get_char_size('0').width;
+ line_number_char_count = cache.line_number_w;
+ cache.line_number_w = (cache.line_number_w + 1) * cache.font->get_char_size('0').width;
} else {
- cache.line_number_w=0;
+ cache.line_number_w = 0;
}
-
-
}
_update_scrollbars();
-
RID ci = get_canvas_item();
- int xmargin_beg=cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w+cache.breakpoint_gutter_width;
- int xmargin_end=cache.size.width-cache.style_normal->get_margin(MARGIN_RIGHT);
+ int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width;
+ int xmargin_end = cache.size.width - cache.style_normal->get_margin(MARGIN_RIGHT);
//let's do it easy for now:
- cache.style_normal->draw(ci,Rect2(Point2(),cache.size));
+ cache.style_normal->draw(ci, Rect2(Point2(), cache.size));
if (has_focus())
- cache.style_focus->draw(ci,Rect2(Point2(),cache.size));
-
+ cache.style_focus->draw(ci, Rect2(Point2(), cache.size));
- int ascent=cache.font->get_ascent();
+ int ascent = cache.font->get_ascent();
int visible_rows = get_visible_rows();
- int tab_w = cache.font->get_char_size(' ').width*tab_size;
+ int tab_w = cache.font->get_char_size(' ').width * tab_size;
Color color = cache.font_color;
- int in_region=-1;
+ int in_region = -1;
if (syntax_coloring) {
- if (custom_bg_color.a>0.01) {
+ if (custom_bg_color.a > 0.01) {
- Point2i ofs = Point2i(cache.style_normal->get_offset())/2.0;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),custom_bg_color);
+ Point2i ofs = Point2i(cache.style_normal->get_offset()) / 2.0;
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs, get_size() - cache.style_normal->get_minimum_size() + ofs), custom_bg_color);
}
//compute actual region to start (may be inside say, a comment).
//slow in very large documments :( but ok for source!
- for(int i=0;i<cursor.line_ofs;i++) {
+ for (int i = 0; i < cursor.line_ofs; i++) {
- const Map<int,Text::ColorRegionInfo>& cri_map=text.get_color_region_info(i);
+ const Map<int, Text::ColorRegionInfo> &cri_map = text.get_color_region_info(i);
- if (in_region>=0 && color_regions[in_region].line_only) {
- in_region=-1; //reset regions that end at end of line
+ if (in_region >= 0 && color_regions[in_region].line_only) {
+ in_region = -1; //reset regions that end at end of line
}
- for( const Map<int,Text::ColorRegionInfo>::Element* E= cri_map.front();E;E=E->next() ) {
+ for (const Map<int, Text::ColorRegionInfo>::Element *E = cri_map.front(); E; E = E->next()) {
- const Text::ColorRegionInfo &cri=E->get();
+ const Text::ColorRegionInfo &cri = E->get();
- if (in_region==-1) {
+ if (in_region == -1) {
if (!cri.end) {
- in_region=cri.region;
+ in_region = cri.region;
}
- } else if (in_region==cri.region && !color_regions[cri.region].line_only) { //ignore otherwise
+ } else if (in_region == cri.region && !color_regions[cri.region].line_only) { //ignore otherwise
if (cri.end || color_regions[cri.region].eq) {
- in_region=-1;
+ in_region = -1;
}
}
}
}
}
- int brace_open_match_line=-1;
- int brace_open_match_column=-1;
- bool brace_open_matching=false;
- bool brace_open_mismatch=false;
- int brace_close_match_line=-1;
- int brace_close_match_column=-1;
- bool brace_close_matching=false;
- bool brace_close_mismatch=false;
-
+ int brace_open_match_line = -1;
+ int brace_open_match_column = -1;
+ bool brace_open_matching = false;
+ bool brace_open_mismatch = false;
+ int brace_close_match_line = -1;
+ int brace_close_match_column = -1;
+ bool brace_close_matching = false;
+ bool brace_close_mismatch = false;
if (brace_matching_enabled) {
- if (cursor.column<text[cursor.line].length()) {
+ if (cursor.column < text[cursor.line].length()) {
//check for open
CharType c = text[cursor.line][cursor.column];
- CharType closec=0;
+ CharType closec = 0;
- if (c=='[') {
- closec=']';
- } else if (c=='{') {
- closec='}';
- } else if (c=='(') {
- closec=')';
+ if (c == '[') {
+ closec = ']';
+ } else if (c == '{') {
+ closec = '}';
+ } else if (c == '(') {
+ closec = ')';
}
- if (closec!=0) {
-
- int stack=1;
+ if (closec != 0) {
+ int stack = 1;
- for(int i=cursor.line;i<text.size();i++) {
+ for (int i = cursor.line; i < text.size(); i++) {
- int from = i==cursor.line?cursor.column+1:0;
- for(int j=from;j<text[i].length();j++) {
+ int from = i == cursor.line ? cursor.column + 1 : 0;
+ for (int j = from; j < text[i].length(); j++) {
CharType cc = text[i][j];
//ignore any brackets inside a string
- if (cc== '"' || cc == '\'') {
+ if (cc == '"' || cc == '\'') {
CharType quotation = cc;
do {
j++;
- if (!(j<text[i].length())) {
+ if (!(j < text[i].length())) {
break;
}
- cc=text[i][j];
+ cc = text[i][j];
//skip over escaped quotation marks inside strings
- if (cc=='\\') {
+ if (cc == '\\') {
bool escaped = true;
- while (j+1<text[i].length() && text[i][j+1]=='\\') {
- escaped=!escaped;
+ while (j + 1 < text[i].length() && text[i][j + 1] == '\\') {
+ escaped = !escaped;
j++;
}
if (escaped) {
@@ -577,108 +553,98 @@ void TextEdit::_notification(int p_what) {
continue;
}
}
- } while (cc!= quotation);
- } else if (cc==c)
+ } while (cc != quotation);
+ } else if (cc == c)
stack++;
- else if (cc==closec)
+ else if (cc == closec)
stack--;
- if (stack==0) {
- brace_open_match_line=i;
- brace_open_match_column=j;
- brace_open_matching=true;
+ if (stack == 0) {
+ brace_open_match_line = i;
+ brace_open_match_column = j;
+ brace_open_matching = true;
break;
}
}
- if (brace_open_match_line!=-1)
+ if (brace_open_match_line != -1)
break;
}
if (!brace_open_matching)
- brace_open_mismatch=true;
-
-
+ brace_open_mismatch = true;
}
}
- if (cursor.column>0) {
- CharType c = text[cursor.line][cursor.column-1];
- CharType closec=0;
-
+ if (cursor.column > 0) {
+ CharType c = text[cursor.line][cursor.column - 1];
+ CharType closec = 0;
-
- if (c==']') {
- closec='[';
- } else if (c=='}') {
- closec='{';
- } else if (c==')') {
- closec='(';
+ if (c == ']') {
+ closec = '[';
+ } else if (c == '}') {
+ closec = '{';
+ } else if (c == ')') {
+ closec = '(';
}
- if (closec!=0) {
-
- int stack=1;
+ if (closec != 0) {
+ int stack = 1;
- for(int i=cursor.line;i>=0;i--) {
+ for (int i = cursor.line; i >= 0; i--) {
- int from = i==cursor.line?cursor.column-2:text[i].length()-1;
- for(int j=from;j>=0;j--) {
+ int from = i == cursor.line ? cursor.column - 2 : text[i].length() - 1;
+ for (int j = from; j >= 0; j--) {
CharType cc = text[i][j];
//ignore any brackets inside a string
- if (cc== '"' || cc == '\'') {
+ if (cc == '"' || cc == '\'') {
CharType quotation = cc;
do {
j--;
- if (!(j>=0)) {
+ if (!(j >= 0)) {
break;
}
- cc=text[i][j];
+ cc = text[i][j];
//skip over escaped quotation marks inside strings
- if (cc==quotation) {
+ if (cc == quotation) {
bool escaped = false;
- while (j-1>=0 && text[i][j-1]=='\\') {
- escaped=!escaped;
+ while (j - 1 >= 0 && text[i][j - 1] == '\\') {
+ escaped = !escaped;
j--;
}
if (escaped) {
j--;
- cc='\\';
+ cc = '\\';
continue;
}
}
- } while (cc!= quotation);
- } else if (cc==c)
+ } while (cc != quotation);
+ } else if (cc == c)
stack++;
- else if (cc==closec)
+ else if (cc == closec)
stack--;
- if (stack==0) {
- brace_close_match_line=i;
- brace_close_match_column=j;
- brace_close_matching=true;
+ if (stack == 0) {
+ brace_close_match_line = i;
+ brace_close_match_column = j;
+ brace_close_matching = true;
break;
}
}
- if (brace_close_match_line!=-1)
+ if (brace_close_match_line != -1)
break;
}
if (!brace_close_matching)
- brace_close_mismatch=true;
-
-
+ brace_close_mismatch = true;
}
-
-
}
}
-
- int deregion=0; //force it to clear inrgion
+ int deregion = 0; //force it to clear inrgion
Point2 cursor_pos;
// get the highlighted words
@@ -686,21 +652,21 @@ void TextEdit::_notification(int p_what) {
String line_num_padding = line_numbers_zero_padded ? "0" : " ";
- for (int i=0;i<visible_rows;i++) {
+ for (int i = 0; i < visible_rows; i++) {
- int line=i+cursor.line_ofs;
+ int line = i + cursor.line_ofs;
- if (line<0 || line>=(int)text.size())
+ if (line < 0 || line >= (int)text.size())
continue;
- const String &str=text[line];
+ const String &str = text[line];
- int char_margin=xmargin_beg-cursor.x_ofs;
- int char_ofs=0;
- int ofs_y=i*get_row_height()+cache.line_spacing/2;
- bool prev_is_char=false;
+ int char_margin = xmargin_beg - cursor.x_ofs;
+ int char_ofs = 0;
+ int ofs_y = i * get_row_height() + cache.line_spacing / 2;
+ bool prev_is_char = false;
bool prev_is_number = false;
- bool in_keyword=false;
+ bool in_keyword = false;
bool in_word = false;
bool in_function_name = false;
bool in_member_variable = false;
@@ -715,23 +681,22 @@ void TextEdit::_notification(int p_what) {
search_text_col = _get_column_pos_of_word(search_text, str, search_flags, 0);
if (highlighted_text.length() != 0 && highlighted_text != search_text)
- highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE|SEARCH_WHOLE_WORDS, 0);
-
- const Map<int,Text::ColorRegionInfo>& cri_map=text.get_color_region_info(line);
+ highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, 0);
+ const Map<int, Text::ColorRegionInfo> &cri_map = text.get_color_region_info(line);
if (text.is_marked(line)) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(xmargin_beg, ofs_y,xmargin_end-xmargin_beg,get_row_height()),cache.mark_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color);
}
if (text.is_breakpoint(line)) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(xmargin_beg, ofs_y,xmargin_end-xmargin_beg,get_row_height()),cache.breakpoint_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color);
}
- if (line==cursor.line) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(0, ofs_y,xmargin_end,get_row_height()),cache.current_line_color);
+ if (line == cursor.line) {
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_end, get_row_height()), cache.current_line_color);
}
// draw breakpoint marker
@@ -742,39 +707,37 @@ void TextEdit::_notification(int p_what) {
int marker_height = get_row_height() - (vertical_gap * 2);
int marker_width = cache.breakpoint_gutter_width - (horizontal_gap * 2);
// no transparency on marker
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2, ofs_y + vertical_gap ,marker_width, marker_height),Color(cache.breakpoint_color.r, cache.breakpoint_color.g, cache.breakpoint_color.b));
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + horizontal_gap - 2, ofs_y + vertical_gap, marker_width, marker_height), Color(cache.breakpoint_color.r, cache.breakpoint_color.g, cache.breakpoint_color.b));
}
}
-
if (cache.line_number_w) {
- String fc = String::num(line+1);
+ String fc = String::num(line + 1);
while (fc.length() < line_number_char_count) {
- fc=line_num_padding+fc;
+ fc = line_num_padding + fc;
}
- cache.font->draw(ci,Point2(cache.style_normal->get_margin(MARGIN_LEFT)+cache.breakpoint_gutter_width,ofs_y+cache.font->get_ascent()),fc,cache.line_number_color);
+ cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width, ofs_y + cache.font->get_ascent()), fc, cache.line_number_color);
}
- for (int j=0;j<str.length();j++) {
+ for (int j = 0; j < str.length(); j++) {
//look for keyword
- if (deregion>0) {
+ if (deregion > 0) {
deregion--;
- if (deregion==0)
- in_region=-1;
+ if (deregion == 0)
+ in_region = -1;
}
- if (syntax_coloring && deregion==0) {
-
+ if (syntax_coloring && deregion == 0) {
color = cache.font_color; //reset
//find keyword
- bool is_char = _is_text_char(str[j]);
+ bool is_char = _is_text_char(str[j]);
bool is_symbol = _is_symbol(str[j]);
bool is_number = _is_number(str[j]);
- if (j==0 && in_region>=0 && color_regions[in_region].line_only) {
- in_region=-1; //reset regions that end at end of line
+ if (j == 0 && in_region >= 0 && color_regions[in_region].line_only) {
+ in_region = -1; //reset regions that end at end of line
}
// allow ABCDEF in hex notation
@@ -785,11 +748,11 @@ void TextEdit::_notification(int p_what) {
}
// check for dot or 'x' for hex notation in floating point number
- if ((str[j] == '.' || str[j] == 'x') && !in_word && prev_is_number && !is_number) {
+ if ((str[j] == '.' || str[j] == 'x') && !in_word && prev_is_number && !is_number) {
is_number = true;
is_symbol = false;
- if (str[j] == 'x' && str[j-1] == '0') {
+ if (str[j] == 'x' && str[j - 1] == '0') {
is_hex_notation = true;
}
}
@@ -808,49 +771,48 @@ void TextEdit::_notification(int p_what) {
if (is_symbol && cri_map.has(j)) {
+ const Text::ColorRegionInfo &cri = cri_map[j];
- const Text::ColorRegionInfo &cri=cri_map[j];
-
- if (in_region==-1) {
+ if (in_region == -1) {
if (!cri.end) {
- in_region=cri.region;
+ in_region = cri.region;
}
- } else if (in_region==cri.region && !color_regions[cri.region].line_only) { //ignore otherwise
+ } else if (in_region == cri.region && !color_regions[cri.region].line_only) { //ignore otherwise
if (cri.end || color_regions[cri.region].eq) {
- deregion=color_regions[cri.region].eq?color_regions[cri.region].begin_key.length():color_regions[cri.region].end_key.length();
+ deregion = color_regions[cri.region].eq ? color_regions[cri.region].begin_key.length() : color_regions[cri.region].end_key.length();
}
}
}
if (!is_char)
- in_keyword=false;
+ in_keyword = false;
- if (in_region==-1 && !in_keyword && is_char && !prev_is_char) {
+ if (in_region == -1 && !in_keyword && is_char && !prev_is_char) {
- int to=j;
- while(to<str.length() && _is_text_char(str[to]))
+ int to = j;
+ while (to < str.length() && _is_text_char(str[to]))
to++;
- uint32_t hash = String::hash(&str[j],to-j);
- StrRange range(&str[j],to-j);
+ uint32_t hash = String::hash(&str[j], to - j);
+ StrRange range(&str[j], to - j);
- const Color *col=keywords.custom_getptr(range,hash);
+ const Color *col = keywords.custom_getptr(range, hash);
if (col) {
- in_keyword=true;
- keyword_color=*col;
+ in_keyword = true;
+ keyword_color = *col;
}
}
if (!in_function_name && in_word && !in_keyword) {
int k = j;
- while(k < str.length() && !_is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') {
+ while (k < str.length() && !_is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') {
k++;
}
@@ -866,7 +828,7 @@ void TextEdit::_notification(int p_what) {
if (!in_function_name && !in_member_variable && !in_keyword && !is_number && in_word) {
int k = j;
- while(k > 0 && !_is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') {
+ while (k > 0 && !_is_symbol(str[k]) && str[k] != '\t' && str[k] != ' ') {
k--;
}
@@ -880,165 +842,160 @@ void TextEdit::_notification(int p_what) {
in_member_variable = false;
}
- if (in_region>=0)
- color=color_regions[in_region].color;
+ if (in_region >= 0)
+ color = color_regions[in_region].color;
else if (in_keyword)
- color=keyword_color;
+ color = keyword_color;
else if (in_member_variable)
- color=cache.member_variable_color;
+ color = cache.member_variable_color;
else if (in_function_name)
- color=cache.function_color;
+ color = cache.function_color;
else if (is_symbol)
- color=symbol_color;
+ color = symbol_color;
else if (is_number)
- color=cache.number_color;
-
- prev_is_char=is_char;
- prev_is_number=is_number;
+ color = cache.number_color;
+ prev_is_char = is_char;
+ prev_is_number = is_number;
}
int char_w;
//handle tabulator
-
- if (str[j]=='\t') {
- int left = char_ofs%tab_w;
- if (left==0)
- char_w=tab_w;
+ if (str[j] == '\t') {
+ int left = char_ofs % tab_w;
+ if (left == 0)
+ char_w = tab_w;
else
- char_w=tab_w-char_ofs%tab_w; // is right...
+ char_w = tab_w - char_ofs % tab_w; // is right...
} else {
- char_w=cache.font->get_char_size(str[j],str[j+1]).width;
+ char_w = cache.font->get_char_size(str[j], str[j + 1]).width;
}
- if ( (char_ofs+char_margin)<xmargin_beg) {
- char_ofs+=char_w;
+ if ((char_ofs + char_margin) < xmargin_beg) {
+ char_ofs += char_w;
continue;
}
- if ( (char_ofs+char_margin+char_w)>=xmargin_end) {
+ if ((char_ofs + char_margin + char_w) >= xmargin_end) {
if (syntax_coloring)
continue;
else
break;
}
- bool in_search_result=false;
+ bool in_search_result = false;
if (search_text_col != -1) {
// if we are at the end check for new search result on same line
- if (j >= search_text_col+search_text.length())
+ if (j >= search_text_col + search_text.length())
search_text_col = _get_column_pos_of_word(search_text, str, search_flags, j);
- in_search_result = j >= search_text_col && j < search_text_col+search_text.length();
+ in_search_result = j >= search_text_col && j < search_text_col + search_text.length();
if (in_search_result) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y ), Size2i(char_w, get_row_height())),cache.search_result_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.search_result_color);
}
}
- bool in_selection = (selection.active && line>=selection.from_line && line<=selection.to_line && (line>selection.from_line || j>=selection.from_column) && (line<selection.to_line || j<selection.to_column));
+ bool in_selection = (selection.active && line >= selection.from_line && line <= selection.to_line && (line > selection.from_line || j >= selection.from_column) && (line < selection.to_line || j < selection.to_column));
if (in_selection) {
//inside selection!
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y ), Size2i(char_w,get_row_height())),cache.selection_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.selection_color);
}
if (in_search_result) {
- Color border_color=(line==search_result_line && j>=search_result_col && j<search_result_col+search_text.length())?cache.font_color:cache.search_result_border_color;
+ Color border_color = (line == search_result_line && j >= search_result_col && j < search_result_col + search_text.length()) ? cache.font_color : cache.search_result_border_color;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y ), Size2i(char_w,1)),border_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y+get_row_height()-1 ), Size2i(char_w,1)),border_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, 1)), border_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y + get_row_height() - 1), Size2i(char_w, 1)), border_color);
- if (j==search_text_col)
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y ), Size2i(1,get_row_height())),border_color);
- if (j==search_text_col+search_text.length()-1)
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin+char_w-1, ofs_y ), Size2i(1,get_row_height())),border_color);
+ if (j == search_text_col)
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(1, get_row_height())), border_color);
+ if (j == search_text_col + search_text.length() - 1)
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + char_w - 1, ofs_y), Size2i(1, get_row_height())), border_color);
}
if (highlight_all_occurrences) {
if (highlighted_text_col != -1) {
// if we are at the end check for new word on same line
- if (j > highlighted_text_col+highlighted_text.length()) {
- highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE|SEARCH_WHOLE_WORDS, j);
+ if (j > highlighted_text_col + highlighted_text.length()) {
+ highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, j);
}
- bool in_highlighted_word = (j >= highlighted_text_col && j < highlighted_text_col+highlighted_text.length());
+ bool in_highlighted_word = (j >= highlighted_text_col && j < highlighted_text_col + highlighted_text.length());
/* if this is the original highlighted text we don't want to highlight it again */
- if (cursor.line==line && (cursor.column >= highlighted_text_col && cursor.column <= highlighted_text_col+highlighted_text.length())) {
+ if (cursor.line == line && (cursor.column >= highlighted_text_col && cursor.column <= highlighted_text_col + highlighted_text.length())) {
in_highlighted_word = false;
}
if (in_highlighted_word) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y ), Size2i(char_w, get_row_height())),cache.word_highlighted_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.word_highlighted_color);
}
}
}
if (brace_matching_enabled) {
- if ( (brace_open_match_line==line && brace_open_match_column==j) ||
- (cursor.column==j && cursor.line==line && (brace_open_matching||brace_open_mismatch))) {
+ if ((brace_open_match_line == line && brace_open_match_column == j) ||
+ (cursor.column == j && cursor.line == line && (brace_open_matching || brace_open_mismatch))) {
if (brace_open_mismatch)
- color=cache.brace_mismatch_color;
- cache.font->draw_char(ci,Point2i( char_ofs+char_margin, ofs_y+ascent),'_',str[j+1],in_selection?cache.font_selected_color:color);
-
+ color = cache.brace_mismatch_color;
+ cache.font->draw_char(ci, Point2i(char_ofs + char_margin, ofs_y + ascent), '_', str[j + 1], in_selection ? cache.font_selected_color : color);
}
if (
- (brace_close_match_line==line && brace_close_match_column==j) ||
- (cursor.column==j+1 && cursor.line==line && (brace_close_matching||brace_close_mismatch))) {
-
+ (brace_close_match_line == line && brace_close_match_column == j) ||
+ (cursor.column == j + 1 && cursor.line == line && (brace_close_matching || brace_close_mismatch))) {
if (brace_close_mismatch)
- color=cache.brace_mismatch_color;
- cache.font->draw_char(ci,Point2i( char_ofs+char_margin, ofs_y+ascent),'_',str[j+1],in_selection?cache.font_selected_color:color);
-
+ color = cache.brace_mismatch_color;
+ cache.font->draw_char(ci, Point2i(char_ofs + char_margin, ofs_y + ascent), '_', str[j + 1], in_selection ? cache.font_selected_color : color);
}
}
- if (cursor.column==j && cursor.line==line) {
+ if (cursor.column == j && cursor.line == line) {
- cursor_pos = Point2i( char_ofs+char_margin, ofs_y );
+ cursor_pos = Point2i(char_ofs + char_margin, ofs_y);
if (insert_mode) {
cursor_pos.y += (get_row_height() - 3);
}
- int caret_w = (str[j]=='\t') ? cache.font->get_char_size(' ').width : char_w;
+ int caret_w = (str[j] == '\t') ? cache.font->get_char_size(' ').width : char_w;
if (draw_caret) {
if (insert_mode) {
int caret_h = (block_caret) ? 4 : 1;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(caret_w,caret_h)),cache.caret_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, caret_h)), cache.caret_color);
} else {
caret_w = (block_caret) ? caret_w : 1;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(caret_w,get_row_height())),cache.caret_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, get_row_height())), cache.caret_color);
}
}
}
- if (cursor.column==j && cursor.line==line && block_caret && draw_caret && !insert_mode) {
+ if (cursor.column == j && cursor.line == line && block_caret && draw_caret && !insert_mode) {
color = cache.caret_background_color;
}
- if (str[j]>=32)
- cache.font->draw_char(ci,Point2i( char_ofs+char_margin, ofs_y+ascent),str[j],str[j+1],in_selection?cache.font_selected_color:color);
+ if (str[j] >= 32)
+ cache.font->draw_char(ci, Point2i(char_ofs + char_margin, ofs_y + ascent), str[j], str[j + 1], in_selection ? cache.font_selected_color : color);
- else if (draw_tabs && str[j]=='\t') {
- int yofs= (get_row_height() - cache.tab_icon->get_height())/2;
- cache.tab_icon->draw(ci, Point2(char_ofs+char_margin,ofs_y+yofs),in_selection?cache.font_selected_color:color);
+ else if (draw_tabs && str[j] == '\t') {
+ int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2;
+ cache.tab_icon->draw(ci, Point2(char_ofs + char_margin, ofs_y + yofs), in_selection ? cache.font_selected_color : color);
}
- char_ofs+=char_w;
+ char_ofs += char_w;
}
- if (cursor.column==str.length() && cursor.line==line && (char_ofs+char_margin)>=xmargin_beg) {
+ if (cursor.column == str.length() && cursor.line == line && (char_ofs + char_margin) >= xmargin_beg) {
- cursor_pos=Point2i( char_ofs+char_margin, ofs_y );
+ cursor_pos = Point2i(char_ofs + char_margin, ofs_y);
if (insert_mode) {
cursor_pos.y += (get_row_height() - 3);
@@ -1048,191 +1005,172 @@ void TextEdit::_notification(int p_what) {
if (insert_mode) {
int char_w = cache.font->get_char_size(' ').width;
int caret_h = (block_caret) ? 4 : 1;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(char_w,caret_h)),cache.caret_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(char_w, caret_h)), cache.caret_color);
} else {
int char_w = cache.font->get_char_size(' ').width;
int caret_w = (block_caret) ? char_w : 1;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(caret_w,get_row_height())),cache.caret_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(cursor_pos, Size2i(caret_w, get_row_height())), cache.caret_color);
}
}
}
}
if (line_length_guideline) {
- int x=xmargin_beg+cache.font->get_char_size('0').width*line_length_guideline_col-cursor.x_ofs;
- if (x>xmargin_beg && x<xmargin_end) {
- VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(x,0),Point2(x,cache.size.height),cache.line_length_guideline_color);
+ int x = xmargin_beg + cache.font->get_char_size('0').width * line_length_guideline_col - cursor.x_ofs;
+ if (x > xmargin_beg && x < xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(x, 0), Point2(x, cache.size.height), cache.line_length_guideline_color);
}
}
-
bool completion_below = false;
if (completion_active) {
// code completion box
Ref<StyleBox> csb = get_stylebox("completion");
int maxlines = get_constant("completion_lines");
- int cmax_width = get_constant("completion_max_width")*cache.font->get_char_size('x').x;
+ int cmax_width = get_constant("completion_max_width") * cache.font->get_char_size('x').x;
int scrollw = get_constant("completion_scroll_width");
Color scrollc = get_color("completion_scroll_color");
-
-
- int lines = MIN(completion_options.size(),maxlines);
- int w=0;
- int h=lines*get_row_height();
+ int lines = MIN(completion_options.size(), maxlines);
+ int w = 0;
+ int h = lines * get_row_height();
int nofs = cache.font->get_string_size(completion_base).width;
-
if (completion_options.size() < 50) {
- for(int i=0;i<completion_options.size();i++) {
- int w2=MIN(cache.font->get_string_size(completion_options[i]).x,cmax_width);
- if (w2>w)
- w=w2;
+ for (int i = 0; i < completion_options.size(); i++) {
+ int w2 = MIN(cache.font->get_string_size(completion_options[i]).x, cmax_width);
+ if (w2 > w)
+ w = w2;
}
} else {
- w=cmax_width;
+ w = cmax_width;
}
int th = h + csb->get_minimum_size().y;
- if (cursor_pos.y+get_row_height()+th > get_size().height) {
- completion_rect.pos.y=cursor_pos.y-th;
+ if (cursor_pos.y + get_row_height() + th > get_size().height) {
+ completion_rect.pos.y = cursor_pos.y - th;
} else {
- completion_rect.pos.y=cursor_pos.y+get_row_height()+csb->get_offset().y;
+ completion_rect.pos.y = cursor_pos.y + get_row_height() + csb->get_offset().y;
completion_below = true;
}
- if (cursor_pos.x-nofs+w+scrollw > get_size().width) {
- completion_rect.pos.x=get_size().width-w-scrollw;
+ if (cursor_pos.x - nofs + w + scrollw > get_size().width) {
+ completion_rect.pos.x = get_size().width - w - scrollw;
} else {
- completion_rect.pos.x=cursor_pos.x-nofs;
+ completion_rect.pos.x = cursor_pos.x - nofs;
}
- completion_rect.size.width=w+2;
- completion_rect.size.height=h;
- if (completion_options.size()<=maxlines)
- scrollw=0;
+ completion_rect.size.width = w + 2;
+ completion_rect.size.height = h;
+ if (completion_options.size() <= maxlines)
+ scrollw = 0;
- draw_style_box(csb,Rect2(completion_rect.pos-csb->get_offset(),completion_rect.size+csb->get_minimum_size()+Size2(scrollw,0)));
+ draw_style_box(csb, Rect2(completion_rect.pos - csb->get_offset(), completion_rect.size + csb->get_minimum_size() + Size2(scrollw, 0)));
- if (cache.completion_background_color.a>0.01) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(completion_rect.pos,completion_rect.size+Size2(scrollw,0)),cache.completion_background_color);
+ if (cache.completion_background_color.a > 0.01) {
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.pos, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color);
}
- int line_from = CLAMP(completion_index - lines/2, 0, completion_options.size() - lines);
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2(completion_rect.pos.x,completion_rect.pos.y+(completion_index-line_from)*get_row_height()),Size2(completion_rect.size.width,get_row_height())),cache.completion_selected_color);
- draw_rect(Rect2(completion_rect.pos,Size2(nofs,completion_rect.size.height)),cache.completion_existing_color);
-
+ int line_from = CLAMP(completion_index - lines / 2, 0, completion_options.size() - lines);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.pos.x, completion_rect.pos.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color);
+ draw_rect(Rect2(completion_rect.pos, Size2(nofs, completion_rect.size.height)), cache.completion_existing_color);
-
-
- for(int i=0;i<lines;i++) {
+ for (int i = 0; i < lines; i++) {
int l = line_from + i;
- ERR_CONTINUE( l < 0 || l>= completion_options.size());
+ ERR_CONTINUE(l < 0 || l >= completion_options.size());
Color text_color = cache.completion_font_color;
- for(int j=0;j<color_regions.size();j++) {
+ for (int j = 0; j < color_regions.size(); j++) {
if (completion_options[l].begins_with(color_regions[j].begin_key)) {
- text_color=color_regions[j].color;
+ text_color = color_regions[j].color;
}
}
- draw_string(cache.font,Point2(completion_rect.pos.x,completion_rect.pos.y+i*get_row_height()+cache.font->get_ascent()),completion_options[l],text_color,completion_rect.size.width);
+ draw_string(cache.font, Point2(completion_rect.pos.x, completion_rect.pos.y + i * get_row_height() + cache.font->get_ascent()), completion_options[l], text_color, completion_rect.size.width);
}
if (scrollw) {
//draw a small scroll rectangle to show a position in the options
float r = maxlines / (float)completion_options.size();
float o = line_from / (float)completion_options.size();
- draw_rect(Rect2(completion_rect.pos.x+completion_rect.size.width,completion_rect.pos.y+o*completion_rect.size.y,scrollw,completion_rect.size.y*r),scrollc);
+ draw_rect(Rect2(completion_rect.pos.x + completion_rect.size.width, completion_rect.pos.y + o * completion_rect.size.y, scrollw, completion_rect.size.y * r), scrollc);
}
- completion_line_ofs=line_from;
-
+ completion_line_ofs = line_from;
}
// check to see if the hint should be drawn
bool show_hint = false;
- if (completion_hint!="") {
+ if (completion_hint != "") {
if (completion_active) {
if (completion_below && !callhint_below) {
show_hint = true;
- }
- else if (!completion_below && callhint_below) {
+ } else if (!completion_below && callhint_below) {
show_hint = true;
}
- }
- else {
+ } else {
show_hint = true;
}
}
if (show_hint) {
- Ref<StyleBox> sb = get_stylebox("panel","TooltipPanel");
+ Ref<StyleBox> sb = get_stylebox("panel", "TooltipPanel");
Ref<Font> font = cache.font;
- Color font_color = get_color("font_color","TooltipLabel");
-
+ Color font_color = get_color("font_color", "TooltipLabel");
- int max_w=0;
+ int max_w = 0;
int sc = completion_hint.get_slice_count("\n");
- int offset=0;
- int spacing=0;
- for(int i=0;i<sc;i++) {
+ int offset = 0;
+ int spacing = 0;
+ for (int i = 0; i < sc; i++) {
- String l = completion_hint.get_slice("\n",i);
- int len = font->get_string_size(l).x;
- max_w = MAX(len,max_w);
- if (i==0) {
- offset = font->get_string_size(l.substr(0,l.find(String::chr(0xFFFF)))).x;
+ String l = completion_hint.get_slice("\n", i);
+ int len = font->get_string_size(l).x;
+ max_w = MAX(len, max_w);
+ if (i == 0) {
+ offset = font->get_string_size(l.substr(0, l.find(String::chr(0xFFFF)))).x;
} else {
- spacing+=cache.line_spacing;
+ spacing += cache.line_spacing;
}
-
-
}
+ Size2 size = Size2(max_w, sc * font->get_height() + spacing);
+ Size2 minsize = size + sb->get_minimum_size();
-
- Size2 size = Size2(max_w,sc*font->get_height()+spacing);
- Size2 minsize = size+sb->get_minimum_size();
-
-
- if (completion_hint_offset==-0xFFFF) {
- completion_hint_offset=cursor_pos.x-offset;
+ if (completion_hint_offset == -0xFFFF) {
+ completion_hint_offset = cursor_pos.x - offset;
}
-
- Point2 hint_ofs = Vector2(completion_hint_offset,cursor_pos.y) + callhint_offset;
+ Point2 hint_ofs = Vector2(completion_hint_offset, cursor_pos.y) + callhint_offset;
if (callhint_below) {
hint_ofs.y += get_row_height() + sb->get_offset().y;
- }
- else {
+ } else {
hint_ofs.y -= minsize.y + sb->get_offset().y;
}
- draw_style_box(sb,Rect2(hint_ofs,minsize));
+ draw_style_box(sb, Rect2(hint_ofs, minsize));
- spacing=0;
- for(int i=0;i<sc;i++) {
- int begin=0;
- int end=0;
- String l = completion_hint.get_slice("\n",i);
+ spacing = 0;
+ for (int i = 0; i < sc; i++) {
+ int begin = 0;
+ int end = 0;
+ String l = completion_hint.get_slice("\n", i);
- if (l.find(String::chr(0xFFFF))!=-1) {
- begin = font->get_string_size(l.substr(0,l.find(String::chr(0xFFFF)))).x;
- end = font->get_string_size(l.substr(0,l.rfind(String::chr(0xFFFF)))).x;
+ if (l.find(String::chr(0xFFFF)) != -1) {
+ begin = font->get_string_size(l.substr(0, l.find(String::chr(0xFFFF)))).x;
+ end = font->get_string_size(l.substr(0, l.rfind(String::chr(0xFFFF)))).x;
}
- draw_string(font,hint_ofs+sb->get_offset()+Vector2(0,font->get_ascent()+font->get_height()*i+spacing),l.replace(String::chr(0xFFFF),""),font_color);
- if (end>0) {
- Vector2 b = hint_ofs+sb->get_offset()+Vector2(begin,font->get_height()+font->get_height()*i+spacing-1);
- draw_line(b,b+Vector2(end-begin,0),font_color);
+ draw_string(font, hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent() + font->get_height() * i + spacing), l.replace(String::chr(0xFFFF), ""), font_color);
+ if (end > 0) {
+ Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font->get_height() + font->get_height() * i + spacing - 1);
+ draw_line(b, b + Vector2(end - begin, 0), font_color);
}
- spacing+=cache.line_spacing;
+ spacing += cache.line_spacing;
}
}
-
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -1240,7 +1178,7 @@ void TextEdit::_notification(int p_what) {
draw_caret = true;
}
if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect());
+ OS::get_singleton()->show_virtual_keyboard(get_text(), get_global_rect());
if (raised_from_completion) {
VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
}
@@ -1261,27 +1199,27 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
int cursor_position_to_move = cursor_get_column() + 1;
- CharType ch_single[2] = {ch, 0};
- CharType ch_single_pair[2] = {_get_right_pair_symbol(ch), 0};
- CharType ch_pair[3] = {ch, _get_right_pair_symbol(ch), 0};
+ CharType ch_single[2] = { ch, 0 };
+ CharType ch_single_pair[2] = { _get_right_pair_symbol(ch), 0 };
+ CharType ch_pair[3] = { ch, _get_right_pair_symbol(ch), 0 };
- if(is_selection_active()) {
+ if (is_selection_active()) {
- int new_column,new_line;
+ int new_column, new_line;
begin_complex_operation();
_insert_text(get_selection_from_line(), get_selection_from_column(),
- ch_single,
- &new_line, &new_column);
+ ch_single,
+ &new_line, &new_column);
int to_col_offset = 0;
- if(get_selection_from_line() == get_selection_to_line())
+ if (get_selection_from_line() == get_selection_to_line())
to_col_offset = 1;
_insert_text(get_selection_to_line(),
- get_selection_to_column() + to_col_offset,
- ch_single_pair,
- &new_line,&new_column);
+ get_selection_to_column() + to_col_offset,
+ ch_single_pair,
+ &new_line, &new_column);
end_complex_operation();
cursor_set_line(get_selection_to_line());
@@ -1292,78 +1230,71 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
return;
}
- if( (ch == '\'' || ch == '"') &&
+ if ((ch == '\'' || ch == '"') &&
cursor_get_column() > 0 &&
- _is_text_char(text[cursor.line][cursor_get_column() - 1])
- ) {
+ _is_text_char(text[cursor.line][cursor_get_column() - 1])) {
insert_text_at_cursor(ch_single);
cursor_set_column(cursor_position_to_move);
return;
}
- if(cursor_get_column() < text[cursor.line].length()) {
- if(_is_text_char(text[cursor.line][cursor_get_column()])) {
+ if (cursor_get_column() < text[cursor.line].length()) {
+ if (_is_text_char(text[cursor.line][cursor_get_column()])) {
insert_text_at_cursor(ch_single);
cursor_set_column(cursor_position_to_move);
return;
}
- if( _is_pair_right_symbol(ch) &&
- text[cursor.line][cursor_get_column()] == ch
- ) {
+ if (_is_pair_right_symbol(ch) &&
+ text[cursor.line][cursor_get_column()] == ch) {
cursor_set_column(cursor_position_to_move);
return;
}
}
-
insert_text_at_cursor(ch_pair);
cursor_set_column(cursor_position_to_move);
return;
-
}
void TextEdit::_consume_backspace_for_pair_symbol(int prev_line, int prev_column) {
bool remove_right_symbol = false;
- if(cursor.column < text[cursor.line].length() && cursor.column > 0) {
+ if (cursor.column < text[cursor.line].length() && cursor.column > 0) {
CharType left_char = text[cursor.line][cursor.column - 1];
CharType right_char = text[cursor.line][cursor.column];
- if(right_char == _get_right_pair_symbol(left_char)) {
+ if (right_char == _get_right_pair_symbol(left_char)) {
remove_right_symbol = true;
}
-
}
- if(remove_right_symbol) {
- _remove_text(prev_line,prev_column,cursor.line,cursor.column + 1);
+ if (remove_right_symbol) {
+ _remove_text(prev_line, prev_column, cursor.line, cursor.column + 1);
} else {
- _remove_text(prev_line,prev_column,cursor.line,cursor.column);
+ _remove_text(prev_line, prev_column, cursor.line, cursor.column);
}
-
}
void TextEdit::backspace_at_cursor() {
if (readonly)
return;
- if (cursor.column==0 && cursor.line==0)
+ if (cursor.column == 0 && cursor.line == 0)
return;
- int prev_line = cursor.column?cursor.line:cursor.line-1;
- int prev_column = cursor.column?(cursor.column-1):(text[cursor.line-1].length());
- if(auto_brace_completion_enabled &&
+ int prev_line = cursor.column ? cursor.line : cursor.line - 1;
+ int prev_column = cursor.column ? (cursor.column - 1) : (text[cursor.line - 1].length());
+ if (auto_brace_completion_enabled &&
cursor.column > 0 &&
_is_pair_left_symbol(text[cursor.line][cursor.column - 1])) {
_consume_backspace_for_pair_symbol(prev_line, prev_column);
} else {
- _remove_text(prev_line,prev_column,cursor.line,cursor.column);
+ _remove_text(prev_line, prev_column, cursor.line, cursor.column);
}
cursor_set_line(prev_line);
cursor_set_column(prev_column);
-
}
void TextEdit::indent_selection_right() {
@@ -1427,68 +1358,67 @@ void TextEdit::indent_selection_left() {
update();
}
-void TextEdit::_get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const {
+void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const {
- float rows=p_mouse.y;
- rows-=cache.style_normal->get_margin(MARGIN_TOP);
- rows/=get_row_height();
- int row=cursor.line_ofs+rows;
+ float rows = p_mouse.y;
+ rows -= cache.style_normal->get_margin(MARGIN_TOP);
+ rows /= get_row_height();
+ int row = cursor.line_ofs + rows;
- if (row<0)
- row=0;
+ if (row < 0)
+ row = 0;
- int col=0;
+ int col = 0;
- if (row>=text.size()) {
+ if (row >= text.size()) {
- row=text.size()-1;
- col=text[row].size();
+ row = text.size() - 1;
+ col = text[row].size();
} else {
- col=p_mouse.x-(cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w+cache.breakpoint_gutter_width);
- col+=cursor.x_ofs;
- col=get_char_pos_for( col, get_line(row) );
+ col = p_mouse.x - (cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width);
+ col += cursor.x_ofs;
+ col = get_char_pos_for(col, get_line(row));
}
- r_row=row;
- r_col=col;
+ r_row = row;
+ r_col = col;
}
-void TextEdit::_input_event(const InputEvent& p_input_event) {
+void TextEdit::_input_event(const InputEvent &p_input_event) {
- switch(p_input_event.type) {
+ switch (p_input_event.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_input_event.mouse_button;
+ const InputEventMouseButton &mb = p_input_event.mouse_button;
- if (completion_active && completion_rect.has_point(Point2(mb.x,mb.y))) {
+ if (completion_active && completion_rect.has_point(Point2(mb.x, mb.y))) {
if (!mb.pressed)
return;
- if (mb.button_index==BUTTON_WHEEL_UP) {
- if (completion_index>0) {
+ if (mb.button_index == BUTTON_WHEEL_UP) {
+ if (completion_index > 0) {
completion_index--;
- completion_current=completion_options[completion_index];
+ completion_current = completion_options[completion_index];
update();
}
-
}
- if (mb.button_index==BUTTON_WHEEL_DOWN) {
+ if (mb.button_index == BUTTON_WHEEL_DOWN) {
- if (completion_index<completion_options.size()-1) {
+ if (completion_index < completion_options.size() - 1) {
completion_index++;
- completion_current=completion_options[completion_index];
+ completion_current = completion_options[completion_index];
update();
}
}
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
- completion_index=CLAMP(completion_line_ofs+(mb.y-completion_rect.pos.y)/get_row_height(),0,completion_options.size()-1);
+ completion_index = CLAMP(completion_line_ofs + (mb.y - completion_rect.pos.y) / get_row_height(), 0, completion_options.size() - 1);
- completion_current=completion_options[completion_index];
+ completion_current = completion_options[completion_index];
update();
if (mb.doubleclick)
_confirm_completion();
@@ -1500,28 +1430,28 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
if (mb.pressed) {
- if (mb.button_index==BUTTON_WHEEL_UP && !mb.mod.command) {
- v_scroll->set_val( v_scroll->get_val() -3 );
+ if (mb.button_index == BUTTON_WHEEL_UP && !mb.mod.command) {
+ v_scroll->set_val(v_scroll->get_val() - 3);
}
- if (mb.button_index==BUTTON_WHEEL_DOWN && !mb.mod.command) {
- v_scroll->set_val( v_scroll->get_val() +3 );
+ if (mb.button_index == BUTTON_WHEEL_DOWN && !mb.mod.command) {
+ v_scroll->set_val(v_scroll->get_val() + 3);
}
- if (mb.button_index==BUTTON_WHEEL_LEFT) {
- h_scroll->set_val( h_scroll->get_val() -3 );
+ if (mb.button_index == BUTTON_WHEEL_LEFT) {
+ h_scroll->set_val(h_scroll->get_val() - 3);
}
- if (mb.button_index==BUTTON_WHEEL_RIGHT) {
- h_scroll->set_val( h_scroll->get_val() +3 );
+ if (mb.button_index == BUTTON_WHEEL_RIGHT) {
+ h_scroll->set_val(h_scroll->get_val() + 3);
}
- if (mb.button_index==BUTTON_LEFT) {
+ if (mb.button_index == BUTTON_LEFT) {
_reset_caret_blink_timer();
- int row,col;
- _get_mouse_pos(Point2i(mb.x,mb.y), row,col);
+ int row, col;
+ _get_mouse_pos(Point2i(mb.x, mb.y), row, col);
// toggle breakpoint on gutter click
if (draw_breakpoint_gutter) {
- int gutter=cache.style_normal->get_margin(MARGIN_LEFT);
+ int gutter = cache.style_normal->get_margin(MARGIN_LEFT);
if (mb.x > gutter && mb.x <= gutter + cache.breakpoint_gutter_width + 3) {
set_line_as_breakpoint(row, !is_line_set_as_breakpoint(row));
emit_signal("breakpoint_toggled", row);
@@ -1529,131 +1459,120 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
}
- int prev_col=cursor.column;
- int prev_line=cursor.line;
-
+ int prev_col = cursor.column;
+ int prev_line = cursor.line;
+ cursor_set_line(row);
+ cursor_set_column(col);
- cursor_set_line( row );
- cursor_set_column( col );
-
- if (mb.mod.shift && (cursor.column!=prev_col || cursor.line!=prev_line)) {
+ if (mb.mod.shift && (cursor.column != prev_col || cursor.line != prev_line)) {
if (!selection.active) {
- selection.active=true;
- selection.selecting_mode=Selection::MODE_POINTER;
- selection.from_column=prev_col;
- selection.from_line=prev_line;
- selection.to_column=cursor.column;
- selection.to_line=cursor.line;
+ selection.active = true;
+ selection.selecting_mode = Selection::MODE_POINTER;
+ selection.from_column = prev_col;
+ selection.from_line = prev_line;
+ selection.to_column = cursor.column;
+ selection.to_line = cursor.line;
- if (selection.from_line>selection.to_line || (selection.from_line==selection.to_line && selection.from_column>selection.to_column)) {
- SWAP(selection.from_column,selection.to_column);
- SWAP(selection.from_line,selection.to_line);
- selection.shiftclick_left=false;
+ if (selection.from_line > selection.to_line || (selection.from_line == selection.to_line && selection.from_column > selection.to_column)) {
+ SWAP(selection.from_column, selection.to_column);
+ SWAP(selection.from_line, selection.to_line);
+ selection.shiftclick_left = false;
} else {
- selection.shiftclick_left=true;
+ selection.shiftclick_left = true;
}
- selection.selecting_line=prev_line;
- selection.selecting_column=prev_col;
+ selection.selecting_line = prev_line;
+ selection.selecting_column = prev_col;
update();
} else {
- if (cursor.line<selection.selecting_line || (cursor.line==selection.selecting_line && cursor.column<selection.selecting_column)) {
+ if (cursor.line < selection.selecting_line || (cursor.line == selection.selecting_line && cursor.column < selection.selecting_column)) {
if (selection.shiftclick_left) {
- SWAP(selection.from_column,selection.to_column);
- SWAP(selection.from_line,selection.to_line);
+ SWAP(selection.from_column, selection.to_column);
+ SWAP(selection.from_line, selection.to_line);
selection.shiftclick_left = !selection.shiftclick_left;
}
- selection.from_column=cursor.column;
- selection.from_line=cursor.line;
+ selection.from_column = cursor.column;
+ selection.from_line = cursor.line;
- } else if (cursor.line>selection.selecting_line || (cursor.line==selection.selecting_line && cursor.column>selection.selecting_column)) {
+ } else if (cursor.line > selection.selecting_line || (cursor.line == selection.selecting_line && cursor.column > selection.selecting_column)) {
if (!selection.shiftclick_left) {
- SWAP(selection.from_column,selection.to_column);
- SWAP(selection.from_line,selection.to_line);
+ SWAP(selection.from_column, selection.to_column);
+ SWAP(selection.from_line, selection.to_line);
selection.shiftclick_left = !selection.shiftclick_left;
}
- selection.to_column=cursor.column;
- selection.to_line=cursor.line;
+ selection.to_column = cursor.column;
+ selection.to_line = cursor.line;
} else {
- selection.active=false;
+ selection.active = false;
}
update();
}
-
-
-
-
-
-
} else {
//if sel active and dblick last time < something
//else
- selection.active=false;
- selection.selecting_mode=Selection::MODE_POINTER;
- selection.selecting_line=row;
- selection.selecting_column=col;
+ selection.active = false;
+ selection.selecting_mode = Selection::MODE_POINTER;
+ selection.selecting_line = row;
+ selection.selecting_column = col;
}
-
- if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec()-last_dblclk)<600 && cursor.line==prev_line) {
+ if (!mb.doubleclick && (OS::get_singleton()->get_ticks_msec() - last_dblclk) < 600 && cursor.line == prev_line) {
//tripleclick select line
- select(cursor.line,0,cursor.line,text[cursor.line].length());
- selection.selecting_column=0;
- last_dblclk=0;
+ select(cursor.line, 0, cursor.line, text[cursor.line].length());
+ selection.selecting_column = 0;
+ last_dblclk = 0;
} else if (mb.doubleclick && text[cursor.line].length()) {
//doubleclick select world
String s = text[cursor.line];
- int beg=CLAMP(cursor.column,0,s.length());
- int end=beg;
+ int beg = CLAMP(cursor.column, 0, s.length());
+ int end = beg;
- if (s[beg]>32 || beg==s.length()) {
+ if (s[beg] > 32 || beg == s.length()) {
- bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
+ bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
- while(beg>0 && s[beg-1]>32 && (symbol==_is_symbol(s[beg-1]))) {
+ while (beg > 0 && s[beg - 1] > 32 && (symbol == _is_symbol(s[beg - 1]))) {
beg--;
}
- while(end<s.length() && s[end+1]>32 && (symbol==_is_symbol(s[end+1]))) {
+ while (end < s.length() && s[end + 1] > 32 && (symbol == _is_symbol(s[end + 1]))) {
end++;
}
- if (end<s.length())
- end+=1;
+ if (end < s.length())
+ end += 1;
- select(cursor.line,beg,cursor.line,end);
+ select(cursor.line, beg, cursor.line, end);
- selection.selecting_column=beg;
+ selection.selecting_column = beg;
}
last_dblclk = OS::get_singleton()->get_ticks_msec();
-
}
update();
}
- if (mb.button_index==BUTTON_RIGHT) {
+ if (mb.button_index == BUTTON_RIGHT) {
menu->set_pos(get_global_transform().xform(get_local_mouse_pos()));
- menu->set_size(Vector2(1,1));
+ menu->set_size(Vector2(1, 1));
menu->popup();
grab_focus();
-
}
} else {
- if (mb.button_index==BUTTON_LEFT)
+ if (mb.button_index == BUTTON_LEFT)
click_select_held->stop();
// notify to show soft keyboard
@@ -1663,34 +1582,32 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_input_event.mouse_motion;
+ const InputEventMouseMotion &mm = p_input_event.mouse_motion;
- if (mm.button_mask&BUTTON_MASK_LEFT) {
+ if (mm.button_mask & BUTTON_MASK_LEFT) {
- if (selection.selecting_mode!=Selection::MODE_NONE) {
+ if (selection.selecting_mode != Selection::MODE_NONE) {
_reset_caret_blink_timer();
- int row,col;
- _get_mouse_pos(Point2i(mm.x,mm.y), row,col);
+ int row, col;
+ _get_mouse_pos(Point2i(mm.x, mm.y), row, col);
- select(selection.selecting_line,selection.selecting_column,row,col);
+ select(selection.selecting_line, selection.selecting_column, row, col);
- cursor_set_line( row );
- cursor_set_column( col );
+ cursor_set_line(row);
+ cursor_set_column(col);
update();
click_select_held->start();
-
}
-
}
} break;
case InputEvent::KEY: {
- InputEventKey k=p_input_event.key;
+ InputEventKey k = p_input_event.key;
if (!k.pressed)
return;
@@ -1699,97 +1616,94 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (readonly)
break;
- bool valid=true;
+ bool valid = true;
if (k.mod.command || k.mod.meta)
- valid=false;
+ valid = false;
if (valid) {
if (!k.mod.alt) {
- if (k.scancode==KEY_UP) {
+ if (k.scancode == KEY_UP) {
- if (completion_index>0) {
+ if (completion_index > 0) {
completion_index--;
- completion_current=completion_options[completion_index];
+ completion_current = completion_options[completion_index];
update();
}
accept_event();
return;
}
+ if (k.scancode == KEY_DOWN) {
- if (k.scancode==KEY_DOWN) {
-
- if (completion_index<completion_options.size()-1) {
+ if (completion_index < completion_options.size() - 1) {
completion_index++;
- completion_current=completion_options[completion_index];
+ completion_current = completion_options[completion_index];
update();
}
accept_event();
return;
}
- if (k.scancode==KEY_PAGEUP) {
+ if (k.scancode == KEY_PAGEUP) {
- completion_index-=get_constant("completion_lines");
- if (completion_index<0)
- completion_index=0;
- completion_current=completion_options[completion_index];
+ completion_index -= get_constant("completion_lines");
+ if (completion_index < 0)
+ completion_index = 0;
+ completion_current = completion_options[completion_index];
update();
accept_event();
return;
}
+ if (k.scancode == KEY_PAGEDOWN) {
- if (k.scancode==KEY_PAGEDOWN) {
-
- completion_index+=get_constant("completion_lines");
- if (completion_index>=completion_options.size())
- completion_index=completion_options.size()-1;
- completion_current=completion_options[completion_index];
+ completion_index += get_constant("completion_lines");
+ if (completion_index >= completion_options.size())
+ completion_index = completion_options.size() - 1;
+ completion_current = completion_options[completion_index];
update();
accept_event();
return;
}
- if (k.scancode==KEY_HOME && completion_index>0) {
+ if (k.scancode == KEY_HOME && completion_index > 0) {
- completion_index=0;
- completion_current=completion_options[completion_index];
+ completion_index = 0;
+ completion_current = completion_options[completion_index];
update();
accept_event();
return;
}
- if (k.scancode==KEY_END && completion_index<completion_options.size()-1) {
+ if (k.scancode == KEY_END && completion_index < completion_options.size() - 1) {
- completion_index=completion_options.size()-1;
- completion_current=completion_options[completion_index];
+ completion_index = completion_options.size() - 1;
+ completion_current = completion_options[completion_index];
update();
accept_event();
return;
}
+ if (k.scancode == KEY_DOWN) {
- if (k.scancode==KEY_DOWN) {
-
- if (completion_index<completion_options.size()-1) {
+ if (completion_index < completion_options.size() - 1) {
completion_index++;
- completion_current=completion_options[completion_index];
+ completion_current = completion_options[completion_index];
update();
}
accept_event();
return;
}
- if (k.scancode==KEY_ENTER || k.scancode==KEY_RETURN || k.scancode==KEY_TAB) {
+ if (k.scancode == KEY_ENTER || k.scancode == KEY_RETURN || k.scancode == KEY_TAB) {
_confirm_completion();
accept_event();
return;
}
- if (k.scancode==KEY_BACKSPACE) {
+ if (k.scancode == KEY_BACKSPACE) {
_reset_caret_blink_timer();
@@ -1799,19 +1713,18 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
return;
}
-
- if (k.scancode==KEY_SHIFT) {
+ if (k.scancode == KEY_SHIFT) {
accept_event();
return;
}
}
- if (k.unicode>32) {
+ if (k.unicode > 32) {
_reset_caret_blink_timer();
- const CharType chr[2] = {(CharType)k.unicode, 0};
- if(auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
+ const CharType chr[2] = { (CharType)k.unicode, 0 };
+ if (auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
_consume_pair_symbol(chr[0]);
} else {
@@ -1839,21 +1752,20 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
_cancel_completion();
-
}
/* TEST CONTROL FIRST!! */
// some remaps for duplicate functions..
- if (k.mod.command && !k.mod.shift && !k.mod.alt && !k.mod.meta && k.scancode==KEY_INSERT) {
+ if (k.mod.command && !k.mod.shift && !k.mod.alt && !k.mod.meta && k.scancode == KEY_INSERT) {
- k.scancode=KEY_C;
+ k.scancode = KEY_C;
}
- if (!k.mod.command && k.mod.shift && !k.mod.alt && !k.mod.meta && k.scancode==KEY_INSERT) {
+ if (!k.mod.command && k.mod.shift && !k.mod.alt && !k.mod.meta && k.scancode == KEY_INSERT) {
- k.scancode=KEY_V;
- k.mod.command=true;
- k.mod.shift=false;
+ k.scancode = KEY_V;
+ k.mod.command = true;
+ k.mod.shift = false;
}
if (!k.mod.command) {
@@ -1868,11 +1780,11 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (readonly)
break;
- bool clear=false;
- bool unselect=false;
- bool dobreak=false;
+ bool clear = false;
+ bool unselect = false;
+ bool dobreak = false;
- switch(k.scancode) {
+ switch (k.scancode) {
case KEY_TAB: {
if (k.mod.shift) {
@@ -1880,25 +1792,27 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} else {
indent_selection_right();
}
- dobreak=true;
+ dobreak = true;
accept_event();
} break;
case KEY_X:
case KEY_C:
//special keys often used with control, wait...
- clear=(!k.mod.command || k.mod.shift || k.mod.alt );
+ clear = (!k.mod.command || k.mod.shift || k.mod.alt);
break;
case KEY_DELETE:
if (!k.mod.shift) {
accept_event();
- clear=true; dobreak=true;
+ clear = true;
+ dobreak = true;
} else if (k.mod.command || k.mod.alt) {
- dobreak=true;
+ dobreak = true;
}
break;
case KEY_BACKSPACE:
accept_event();
- clear=true; dobreak=true;
+ clear = true;
+ dobreak = true;
break;
case KEY_LEFT:
case KEY_RIGHT:
@@ -1911,19 +1825,19 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
// ignore arrows if any modifiers are held (shift = selecting, others may be used for editor hotkeys)
if (k.mod.command || k.mod.shift || k.mod.alt)
break;
- unselect=true;
+ unselect = true;
break;
default:
- if (k.unicode>=32 && !k.mod.command && !k.mod.alt && !k.mod.meta)
- clear=true;
+ if (k.unicode >= 32 && !k.mod.command && !k.mod.alt && !k.mod.meta)
+ clear = true;
if (auto_brace_completion_enabled && _is_pair_left_symbol(k.unicode))
- clear=false;
+ clear = false;
}
if (unselect) {
- selection.active=false;
- selection.selecting_mode=Selection::MODE_NONE;
+ selection.active = false;
+ selection.selecting_mode = Selection::MODE_NONE;
update();
}
if (clear) {
@@ -1931,9 +1845,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (!dobreak) {
begin_complex_operation();
}
- selection.active=false;
+ selection.active = false;
update();
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
update();
@@ -1942,9 +1856,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
- selection.selecting_text=false;
+ selection.selecting_text = false;
- bool scancode_handled=true;
+ bool scancode_handled = true;
// special scancode test...
@@ -1956,20 +1870,20 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (readonly)
break;
- String ins="\n";
+ String ins = "\n";
//keep indentation
- for(int i=0;i<text[cursor.line].length();i++) {
- if (text[cursor.line][i]=='\t')
- ins+="\t";
+ for (int i = 0; i < text[cursor.line].length(); i++) {
+ if (text[cursor.line][i] == '\t')
+ ins += "\t";
else
break;
}
- if(auto_indent){
+ if (auto_indent) {
// indent once again if previous line will end with ':'
// (i.e. colon precedes current cursor position)
- if(cursor.column>0 && text[cursor.line][cursor.column-1]==':') {
- ins+="\t";
+ if (cursor.column > 0 && text[cursor.line][cursor.column - 1] == ':') {
+ ins += "\t";
}
}
@@ -1979,13 +1893,11 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (cursor.line > 0) {
cursor_set_line(cursor.line - 1);
cursor_set_column(text[cursor.line].length());
- }
- else {
+ } else {
cursor_set_column(0);
first_line = true;
}
- }
- else {
+ } else {
cursor_set_column(text[cursor.line].length());
}
}
@@ -1999,11 +1911,11 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break;
case KEY_ESCAPE: {
- if (completion_hint!="") {
- completion_hint="";
+ if (completion_hint != "") {
+ completion_hint = "";
update();
} else {
- scancode_handled=false;
+ scancode_handled = false;
}
} break;
case KEY_TAB: {
@@ -2014,12 +1926,11 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (selection.active) {
-
} else {
if (k.mod.shift) {
int cc = cursor.column;
- if (cc>0 && cc<=text[cursor.line].length() && text[cursor.line][cursor.column-1]=='\t') {
+ if (cc > 0 && cc <= text[cursor.line].length() && text[cursor.line][cursor.column - 1] == '\t') {
//simple unindent
backspace_at_cursor();
@@ -2039,23 +1950,23 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (k.mod.alt) {
#else
if (k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
} else if (k.mod.command) {
#endif
- int line=cursor.line;
- int column=cursor.column;
+ int line = cursor.line;
+ int column = cursor.column;
- bool prev_char=false;
- bool only_whitespace=true;
+ bool prev_char = false;
+ bool only_whitespace = true;
while (only_whitespace && line > 0) {
- while (column>0) {
- CharType c=text[line][column-1];
+ while (column > 0) {
+ CharType c = text[line][column - 1];
if (c != '\t' && c != ' ') {
- only_whitespace=false;
+ only_whitespace = false;
break;
}
@@ -2064,19 +1975,18 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (only_whitespace) {
line--;
- column=text[line].length();
+ column = text[line].length();
}
}
- while (column>0) {
- bool ischar=_is_text_char(text[line][column-1]);
+ while (column > 0) {
+ bool ischar = _is_text_char(text[line][column - 1]);
if (prev_char && !ischar)
break;
- prev_char=ischar;
+ prev_char = ischar;
column--;
-
}
_remove_text(line, column, cursor.line, cursor.column);
@@ -2114,34 +2024,33 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
#else
if (k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
} else if (k.mod.command) {
#endif
- bool prev_char=false;
- int cc=cursor.column;
- while (cc>0) {
+ bool prev_char = false;
+ int cc = cursor.column;
+ while (cc > 0) {
- bool ischar=_is_text_char(text[cursor.line][cc-1]);
+ bool ischar = _is_text_char(text[cursor.line][cc - 1]);
if (prev_char && !ischar)
break;
- prev_char=ischar;
+ prev_char = ischar;
cc--;
-
}
cursor_set_column(cc);
- } else if (cursor.column==0) {
+ } else if (cursor.column == 0) {
- if (cursor.line>0) {
- cursor_set_line(cursor.line-1);
+ if (cursor.line > 0) {
+ cursor_set_line(cursor.line - 1);
cursor_set_column(text[cursor.line].length());
}
} else {
- cursor_set_column(cursor_get_column()-1);
+ cursor_set_column(cursor_get_column() - 1);
}
if (k.mod.shift)
@@ -2172,32 +2081,32 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} else if (k.mod.alt) {
#else
if (k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
} else if (k.mod.command) {
#endif
- bool prev_char=false;
- int cc=cursor.column;
- while (cc<text[cursor.line].length()) {
+ bool prev_char = false;
+ int cc = cursor.column;
+ while (cc < text[cursor.line].length()) {
- bool ischar=_is_text_char(text[cursor.line][cc]);
+ bool ischar = _is_text_char(text[cursor.line][cc]);
if (prev_char && !ischar)
break;
- prev_char=ischar;
+ prev_char = ischar;
cc++;
}
cursor_set_column(cc);
- } else if (cursor.column==text[cursor.line].length()) {
+ } else if (cursor.column == text[cursor.line].length()) {
- if (cursor.line<text.size()-1) {
- cursor_set_line(cursor.line+1);
+ if (cursor.line < text.size() - 1) {
+ cursor_set_line(cursor.line + 1);
cursor_set_column(0);
}
} else {
- cursor_set_column(cursor_get_column()+1);
+ cursor_set_column(cursor_get_column() + 1);
}
if (k.mod.shift)
@@ -2216,7 +2125,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (k.mod.shift)
_pre_shift_selection();
if (k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
}
#ifndef APPLE_STYLE_KEYS
@@ -2234,7 +2143,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
cursor_set_line(0);
else
#endif
- cursor_set_line(cursor_get_line()-1);
+ cursor_set_line(cursor_get_line() - 1);
if (k.mod.shift)
_post_shift_selection();
@@ -2253,7 +2162,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (k.mod.shift)
_pre_shift_selection();
if (k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
}
#ifndef APPLE_STYLE_KEYS
@@ -2268,10 +2177,10 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
if (k.mod.command)
- cursor_set_line(text.size()-1);
+ cursor_set_line(text.size() - 1);
else
#endif
- cursor_set_line(cursor_get_line()+1);
+ cursor_set_line(cursor_get_line() + 1);
if (k.mod.shift)
_post_shift_selection();
@@ -2291,35 +2200,35 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
int curline_len = text[cursor.line].length();
- if (cursor.line==text.size()-1 && cursor.column==curline_len)
+ if (cursor.line == text.size() - 1 && cursor.column == curline_len)
break; //nothing to do
- int next_line=cursor.column<curline_len?cursor.line:cursor.line+1;
+ int next_line = cursor.column < curline_len ? cursor.line : cursor.line + 1;
int next_column;
#ifdef APPLE_STYLE_KEYS
if (k.mod.alt) {
#else
if (k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
} else if (k.mod.command) {
#endif
- int last_line=text.size()-1;
+ int last_line = text.size() - 1;
- int line=cursor.line;
- int column=cursor.column;
+ int line = cursor.line;
+ int column = cursor.column;
- bool prev_char=false;
- bool only_whitespace=true;
+ bool prev_char = false;
+ bool only_whitespace = true;
while (only_whitespace && line < last_line) {
- while (column<text[line].length()) {
- CharType c=text[line][column];
+ while (column < text[line].length()) {
+ CharType c = text[line][column];
if (c != '\t' && c != ' ') {
- only_whitespace=false;
+ only_whitespace = false;
break;
}
@@ -2328,27 +2237,27 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (only_whitespace) {
line++;
- column=0;
+ column = 0;
}
}
- while (column<text[line].length()) {
+ while (column < text[line].length()) {
- bool ischar=_is_text_char(text[line][column]);
+ bool ischar = _is_text_char(text[line][column]);
if (prev_char && !ischar)
break;
- prev_char=ischar;
+ prev_char = ischar;
column++;
}
- next_line=line;
- next_column=column;
+ next_line = line;
+ next_column = column;
} else {
- next_column=cursor.column<curline_len?(cursor.column+1):0;
+ next_column = cursor.column < curline_len ? (cursor.column + 1) : 0;
}
- _remove_text(cursor.line,cursor.column,next_line,next_column);
+ _remove_text(cursor.line, cursor.column, next_line, next_column);
update();
} break;
@@ -2362,7 +2271,6 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
#ifdef APPLE_STYLE_KEYS
case KEY_HOME: {
-
if (k.mod.shift)
_pre_shift_selection();
@@ -2370,43 +2278,41 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (k.mod.shift)
_post_shift_selection();
- else if(k.mod.command || k.mod.control)
+ else if (k.mod.command || k.mod.control)
deselect();
} break;
#else
case KEY_HOME: {
-
if (k.mod.shift)
_pre_shift_selection();
if (k.mod.command) {
cursor_set_line(0);
cursor_set_column(0);
- }
- else {
+ } else {
// compute whitespace symbols seq length
int current_line_whitespace_len = 0;
- while( current_line_whitespace_len < text[cursor.line].length() ) {
- CharType c = text[cursor.line][current_line_whitespace_len];
- if( c != '\t' && c != ' ' )
- break;
- current_line_whitespace_len++;
+ while (current_line_whitespace_len < text[cursor.line].length()) {
+ CharType c = text[cursor.line][current_line_whitespace_len];
+ if (c != '\t' && c != ' ')
+ break;
+ current_line_whitespace_len++;
}
- if( cursor_get_column() == current_line_whitespace_len )
- cursor_set_column(0);
+ if (cursor_get_column() == current_line_whitespace_len)
+ cursor_set_column(0);
else
- cursor_set_column(current_line_whitespace_len);
+ cursor_set_column(current_line_whitespace_len);
}
if (k.mod.shift)
_post_shift_selection();
- else if(k.mod.command || k.mod.control)
+ else if (k.mod.command || k.mod.control)
deselect();
_cancel_completion();
- completion_hint="";
+ completion_hint = "";
} break;
#endif
@@ -2423,11 +2329,11 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (k.mod.shift)
_pre_shift_selection();
- cursor_set_line(text.size()-1);
+ cursor_set_line(text.size() - 1);
if (k.mod.shift)
_post_shift_selection();
- else if(k.mod.command || k.mod.control)
+ else if (k.mod.command || k.mod.control)
deselect();
} break;
@@ -2438,16 +2344,16 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
_pre_shift_selection();
if (k.mod.command)
- cursor_set_line(text.size()-1);
+ cursor_set_line(text.size() - 1);
cursor_set_column(text[cursor.line].length());
if (k.mod.shift)
_post_shift_selection();
- else if(k.mod.command || k.mod.control)
+ else if (k.mod.command || k.mod.control)
deselect();
_cancel_completion();
- completion_hint="";
+ completion_hint = "";
} break;
#endif
@@ -2463,14 +2369,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (k.mod.shift)
_pre_shift_selection();
- cursor_set_line(cursor_get_line()-get_visible_rows());
+ cursor_set_line(cursor_get_line() - get_visible_rows());
if (k.mod.shift)
_post_shift_selection();
_cancel_completion();
- completion_hint="";
-
+ completion_hint = "";
} break;
case KEY_KP_3: {
@@ -2485,20 +2390,19 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (k.mod.shift)
_pre_shift_selection();
- cursor_set_line(cursor_get_line()+get_visible_rows());
+ cursor_set_line(cursor_get_line() + get_visible_rows());
if (k.mod.shift)
_post_shift_selection();
_cancel_completion();
- completion_hint="";
-
+ completion_hint = "";
} break;
case KEY_A: {
if (!k.mod.command || k.mod.shift || k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
}
@@ -2510,7 +2414,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
if (!k.mod.command || k.mod.shift || k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
}
@@ -2520,7 +2424,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
case KEY_C: {
if (!k.mod.command || k.mod.shift || k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
}
@@ -2530,7 +2434,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
case KEY_Z: {
if (!k.mod.command) {
- scancode_handled=false;
+ scancode_handled = false;
break;
}
@@ -2544,7 +2448,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
if (!k.mod.command || k.mod.shift || k.mod.alt) {
- scancode_handled=false;
+ scancode_handled = false;
break;
}
@@ -2559,41 +2463,38 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
#endif
query_code_comple();
- scancode_handled=true;
+ scancode_handled = true;
} else {
- scancode_handled=false;
+ scancode_handled = false;
}
} break;
- case KEY_U:{
+ case KEY_U: {
if (!k.mod.command || k.mod.shift) {
- scancode_handled=false;
+ scancode_handled = false;
break;
- }
- else {
+ } else {
if (selection.active) {
int ini = selection.from_line;
int end = selection.to_line;
- for (int i=ini; i<= end; i++)
- {
+ for (int i = ini; i <= end; i++) {
if (text[i][0] == '#')
- _remove_text(i,0,i,1);
+ _remove_text(i, 0, i, 1);
}
- }
- else{
+ } else {
if (text[cursor.line][0] == '#')
- _remove_text(cursor.line,0,cursor.line,1);
+ _remove_text(cursor.line, 0, cursor.line, 1);
}
update();
}
- break;}
+ break;
+ }
default: {
- scancode_handled=false;
+ scancode_handled = false;
} break;
-
}
if (scancode_handled)
@@ -2613,7 +2514,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
}
*/
- if (k.scancode==KEY_INSERT) {
+ if (k.scancode == KEY_INSERT) {
set_insert_mode(!insert_mode);
accept_event();
return;
@@ -2621,7 +2522,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (!scancode_handled && !k.mod.command) { //for german kbds
- if (k.unicode>=32) {
+ if (k.unicode >= 32) {
if (readonly)
break;
@@ -2636,12 +2537,12 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
}
- const CharType chr[2] = {(CharType)k.unicode, 0};
+ const CharType chr[2] = { (CharType)k.unicode, 0 };
- if (completion_hint!="" && k.unicode==')') {
- completion_hint="";
+ if (completion_hint != "" && k.unicode == ')') {
+ completion_hint = "";
}
- if(auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
+ if (auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
_consume_pair_symbol(chr[0]);
} else {
_insert_text_at_cursor(chr);
@@ -2663,36 +2564,30 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
return;
} break;
-
}
-
}
-
void TextEdit::_pre_shift_selection() {
+ if (!selection.active || selection.selecting_mode == Selection::MODE_NONE) {
- if (!selection.active || selection.selecting_mode==Selection::MODE_NONE) {
-
- selection.selecting_line=cursor.line;
- selection.selecting_column=cursor.column;
- selection.active=true;
+ selection.selecting_line = cursor.line;
+ selection.selecting_column = cursor.column;
+ selection.active = true;
}
- selection.selecting_mode=Selection::MODE_SHIFT;
+ selection.selecting_mode = Selection::MODE_SHIFT;
}
void TextEdit::_post_shift_selection() {
+ if (selection.active && selection.selecting_mode == Selection::MODE_SHIFT) {
- if (selection.active && selection.selecting_mode==Selection::MODE_SHIFT) {
-
- select(selection.selecting_line,selection.selecting_column,cursor.line,cursor.column);
+ select(selection.selecting_line, selection.selecting_column, cursor.line, cursor.column);
update();
}
-
- selection.selecting_text=true;
+ selection.selecting_text = true;
}
void TextEdit::_scroll_lines_up() {
@@ -2727,109 +2622,106 @@ void TextEdit::_scroll_lines_down() {
/**** TEXT EDIT CORE API ****/
-void TextEdit::_base_insert_text(int p_line, int p_char,const String& p_text,int &r_end_line,int &r_end_column) {
+void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, int &r_end_line, int &r_end_column) {
//save for undo...
- ERR_FAIL_INDEX(p_line,text.size());
- ERR_FAIL_COND(p_char<0);
+ ERR_FAIL_INDEX(p_line, text.size());
+ ERR_FAIL_COND(p_char < 0);
/* STEP 1 add spaces if the char is greater than the end of the line */
- while(p_char>text[p_line].length()) {
+ while (p_char > text[p_line].length()) {
- text.set(p_line,text[p_line]+String::chr(' '));
+ text.set(p_line, text[p_line] + String::chr(' '));
}
/* STEP 2 separate dest string in pre and post text */
- String preinsert_text = text[p_line].substr(0,p_char);
- String postinsert_text = text[p_line].substr(p_char,text[p_line].size());
+ String preinsert_text = text[p_line].substr(0, p_char);
+ String postinsert_text = text[p_line].substr(p_char, text[p_line].size());
/* STEP 3 remove \r from source text and separate in substrings */
//buh bye \r and split
- Vector<String> substrings = p_text.replace("\r","").split("\n");
-
+ Vector<String> substrings = p_text.replace("\r", "").split("\n");
- for(int i=0;i<substrings.size();i++) {
+ for (int i = 0; i < substrings.size(); i++) {
//insert the substrings
- if (i==0) {
+ if (i == 0) {
- text.set(p_line,preinsert_text+substrings[i]);
+ text.set(p_line, preinsert_text + substrings[i]);
} else {
- text.insert(p_line+i,substrings[i]);
+ text.insert(p_line + i, substrings[i]);
}
- if (i==substrings.size()-1){
+ if (i == substrings.size() - 1) {
- text.set(p_line+i,text[p_line+i]+postinsert_text);
+ text.set(p_line + i, text[p_line + i] + postinsert_text);
}
}
- r_end_line=p_line+substrings.size()-1;
- r_end_column=text[r_end_line].length()-postinsert_text.length();
+ r_end_line = p_line + substrings.size() - 1;
+ r_end_column = text[r_end_line].length() - postinsert_text.length();
if (!text_changed_dirty && !setting_text) {
if (is_inside_tree())
- MessageQueue::get_singleton()->push_call(this,"_text_changed_emit");
- text_changed_dirty=true;
+ MessageQueue::get_singleton()->push_call(this, "_text_changed_emit");
+ text_changed_dirty = true;
}
-
}
-String TextEdit::_base_get_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column) const {
+String TextEdit::_base_get_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) const {
- ERR_FAIL_INDEX_V(p_from_line,text.size(),String());
- ERR_FAIL_INDEX_V(p_from_column,text[p_from_line].length()+1,String());
- ERR_FAIL_INDEX_V(p_to_line,text.size(),String());
- ERR_FAIL_INDEX_V(p_to_column,text[p_to_line].length()+1,String());
- ERR_FAIL_COND_V(p_to_line < p_from_line ,String()); // from > to
- ERR_FAIL_COND_V(p_to_line == p_from_line && p_to_column<p_from_column,String()); // from > to
+ ERR_FAIL_INDEX_V(p_from_line, text.size(), String());
+ ERR_FAIL_INDEX_V(p_from_column, text[p_from_line].length() + 1, String());
+ ERR_FAIL_INDEX_V(p_to_line, text.size(), String());
+ ERR_FAIL_INDEX_V(p_to_column, text[p_to_line].length() + 1, String());
+ ERR_FAIL_COND_V(p_to_line < p_from_line, String()); // from > to
+ ERR_FAIL_COND_V(p_to_line == p_from_line && p_to_column < p_from_column, String()); // from > to
String ret;
- for(int i=p_from_line;i<=p_to_line;i++) {
+ for (int i = p_from_line; i <= p_to_line; i++) {
- int begin = (i==p_from_line)?p_from_column:0;
- int end = (i==p_to_line)?p_to_column:text[i].length();
+ int begin = (i == p_from_line) ? p_from_column : 0;
+ int end = (i == p_to_line) ? p_to_column : text[i].length();
- if (i>p_from_line)
- ret+="\n";
- ret+=text[i].substr(begin,end-begin);
+ if (i > p_from_line)
+ ret += "\n";
+ ret += text[i].substr(begin, end - begin);
}
return ret;
}
-void TextEdit::_base_remove_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column) {
-
- ERR_FAIL_INDEX(p_from_line,text.size());
- ERR_FAIL_INDEX(p_from_column,text[p_from_line].length()+1);
- ERR_FAIL_INDEX(p_to_line,text.size());
- ERR_FAIL_INDEX(p_to_column,text[p_to_line].length()+1);
- ERR_FAIL_COND(p_to_line < p_from_line ); // from > to
- ERR_FAIL_COND(p_to_line == p_from_line && p_to_column<p_from_column); // from > to
+void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) {
+ ERR_FAIL_INDEX(p_from_line, text.size());
+ ERR_FAIL_INDEX(p_from_column, text[p_from_line].length() + 1);
+ ERR_FAIL_INDEX(p_to_line, text.size());
+ ERR_FAIL_INDEX(p_to_column, text[p_to_line].length() + 1);
+ ERR_FAIL_COND(p_to_line < p_from_line); // from > to
+ ERR_FAIL_COND(p_to_line == p_from_line && p_to_column < p_from_column); // from > to
- String pre_text = text[p_from_line].substr(0,p_from_column);
- String post_text = text[p_to_line].substr(p_to_column,text[p_to_line].length());
+ String pre_text = text[p_from_line].substr(0, p_from_column);
+ String post_text = text[p_to_line].substr(p_to_column, text[p_to_line].length());
- for(int i=p_from_line;i<p_to_line;i++) {
+ for (int i = p_from_line; i < p_to_line; i++) {
- text.remove(p_from_line+1);
+ text.remove(p_from_line + 1);
}
- text.set(p_from_line,pre_text+post_text);
+ text.set(p_from_line, pre_text + post_text);
if (!text_changed_dirty && !setting_text) {
if (is_inside_tree())
- MessageQueue::get_singleton()->push_call(this,"_text_changed_emit");
- text_changed_dirty=true;
+ MessageQueue::get_singleton()->push_call(this, "_text_changed_emit");
+ text_changed_dirty = true;
}
}
-void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_end_line,int *r_end_column) {
+void TextEdit::_insert_text(int p_line, int p_char, const String &p_text, int *r_end_line, int *r_end_column) {
if (!setting_text)
idle_detect->start();
@@ -2838,53 +2730,52 @@ void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_e
_clear_redo();
}
- int retline,retchar;
- _base_insert_text(p_line,p_char,p_text,retline,retchar);
+ int retline, retchar;
+ _base_insert_text(p_line, p_char, p_text, retline, retchar);
if (r_end_line)
- *r_end_line=retline;
+ *r_end_line = retline;
if (r_end_column)
- *r_end_column=retchar;
+ *r_end_column = retchar;
if (!undo_enabled)
return;
/* UNDO!! */
TextOperation op;
- op.type=TextOperation::TYPE_INSERT;
- op.from_line=p_line;
- op.from_column=p_char;
- op.to_line=retline;
- op.to_column=retchar;
- op.text=p_text;
- op.version=++version;
- op.chain_forward=false;
- op.chain_backward=false;
+ op.type = TextOperation::TYPE_INSERT;
+ op.from_line = p_line;
+ op.from_column = p_char;
+ op.to_line = retline;
+ op.to_column = retchar;
+ op.text = p_text;
+ op.version = ++version;
+ op.chain_forward = false;
+ op.chain_backward = false;
//see if it shold just be set as current op
- if (current_op.type!=op.type) {
+ if (current_op.type != op.type) {
op.prev_version = get_version();
_push_current_op();
- current_op=op;
+ current_op = op;
return; //set as current op, return
}
//see if it can be merged
- if (current_op.to_line!=p_line || current_op.to_column!=p_char) {
+ if (current_op.to_line != p_line || current_op.to_column != p_char) {
op.prev_version = get_version();
_push_current_op();
- current_op=op;
+ current_op = op;
return; //set as current op, return
}
//merge current op
- current_op.text+=p_text;
- current_op.to_column=retchar;
- current_op.to_line=retline;
- current_op.version=op.version;
-
+ current_op.text += p_text;
+ current_op.to_column = retchar;
+ current_op.to_line = retline;
+ current_op.version = op.version;
}
-void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column) {
+void TextEdit::_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) {
if (!setting_text)
idle_detect->start();
@@ -2892,42 +2783,42 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int
String text;
if (undo_enabled) {
_clear_redo();
- text=_base_get_text(p_from_line,p_from_column,p_to_line,p_to_column);
+ text = _base_get_text(p_from_line, p_from_column, p_to_line, p_to_column);
}
- _base_remove_text(p_from_line,p_from_column,p_to_line,p_to_column);
+ _base_remove_text(p_from_line, p_from_column, p_to_line, p_to_column);
if (!undo_enabled)
return;
/* UNDO!! */
TextOperation op;
- op.type=TextOperation::TYPE_REMOVE;
- op.from_line=p_from_line;
- op.from_column=p_from_column;
- op.to_line=p_to_line;
- op.to_column=p_to_column;
- op.text=text;
- op.version=++version;
- op.chain_forward=false;
- op.chain_backward=false;
+ op.type = TextOperation::TYPE_REMOVE;
+ op.from_line = p_from_line;
+ op.from_column = p_from_column;
+ op.to_line = p_to_line;
+ op.to_column = p_to_column;
+ op.text = text;
+ op.version = ++version;
+ op.chain_forward = false;
+ op.chain_backward = false;
//see if it shold just be set as current op
- if (current_op.type!=op.type) {
+ if (current_op.type != op.type) {
op.prev_version = get_version();
_push_current_op();
- current_op=op;
+ current_op = op;
return; //set as current op, return
}
//see if it can be merged
- if (current_op.from_line==p_to_line && current_op.from_column==p_to_column) {
+ if (current_op.from_line == p_to_line && current_op.from_column == p_to_column) {
//basckace or similar
- current_op.text=text+current_op.text;
- current_op.from_line=p_from_line;
- current_op.from_column=p_from_column;
+ current_op.text = text + current_op.text;
+ current_op.from_line = p_from_line;
+ current_op.from_column = p_from_column;
return; //update current op
}
- if (current_op.from_line==p_from_line && current_op.from_column==p_from_column) {
+ if (current_op.from_line == p_from_line && current_op.from_column == p_from_column) {
//current_op.text=text+current_op.text;
//current_op.from_line=p_from_line;
@@ -2937,33 +2828,28 @@ void TextEdit::_remove_text(int p_from_line, int p_from_column,int p_to_line,int
op.prev_version = get_version();
_push_current_op();
- current_op=op;
-
+ current_op = op;
}
+void TextEdit::_insert_text_at_cursor(const String &p_text) {
-void TextEdit::_insert_text_at_cursor(const String& p_text) {
-
- int new_column,new_line;
- _insert_text(cursor.line,cursor.column,p_text,&new_line,&new_column);
+ int new_column, new_line;
+ _insert_text(cursor.line, cursor.column, p_text, &new_line, &new_column);
cursor_set_line(new_line);
cursor_set_column(new_column);
update();
}
-
-
-
int TextEdit::get_char_count() {
- int totalsize=0;
+ int totalsize = 0;
- for (int i=0;i<text.size();i++) {
+ for (int i = 0; i < text.size(); i++) {
- if (i>0)
+ if (i > 0)
totalsize++; // incliude \n
- totalsize+=text[i].length();
+ totalsize += text[i].length();
}
return totalsize; // omit last \n
@@ -2975,40 +2861,39 @@ Size2 TextEdit::get_minimum_size() const {
}
int TextEdit::get_visible_rows() const {
- int total=cache.size.height;
- total-=cache.style_normal->get_minimum_size().height;
- total/=get_row_height();
+ int total = cache.size.height;
+ total -= cache.style_normal->get_minimum_size().height;
+ total /= get_row_height();
return total;
}
void TextEdit::adjust_viewport_to_cursor() {
- if (cursor.line_ofs>cursor.line)
- cursor.line_ofs=cursor.line;
+ if (cursor.line_ofs > cursor.line)
+ cursor.line_ofs = cursor.line;
- int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
+ int visible_width = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width;
if (v_scroll->is_visible())
- visible_width-=v_scroll->get_combined_minimum_size().width;
- visible_width-=20; // give it a little more space
-
+ visible_width -= v_scroll->get_combined_minimum_size().width;
+ visible_width -= 20; // give it a little more space
//printf("rowofs %i, visrows %i, cursor.line %i\n",cursor.line_ofs,get_visible_rows(),cursor.line);
int visible_rows = get_visible_rows();
if (h_scroll->is_visible())
- visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height());
+ visible_rows -= ((h_scroll->get_combined_minimum_size().height - 1) / get_row_height());
- if (cursor.line>=(cursor.line_ofs+visible_rows))
- cursor.line_ofs=cursor.line-visible_rows+1;
- if (cursor.line<cursor.line_ofs)
- cursor.line_ofs=cursor.line;
+ if (cursor.line >= (cursor.line_ofs + visible_rows))
+ cursor.line_ofs = cursor.line - visible_rows + 1;
+ if (cursor.line < cursor.line_ofs)
+ cursor.line_ofs = cursor.line;
- int cursor_x = get_column_x_offset( cursor.column, text[cursor.line] );
+ int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]);
- if (cursor_x>(cursor.x_ofs+visible_width))
- cursor.x_ofs=cursor_x-visible_width+1;
+ if (cursor_x > (cursor.x_ofs + visible_width))
+ cursor.x_ofs = cursor_x - visible_width + 1;
if (cursor_x < cursor.x_ofs)
- cursor.x_ofs=cursor_x;
+ cursor.x_ofs = cursor_x;
update();
/*
@@ -3018,98 +2903,89 @@ void TextEdit::adjust_viewport_to_cursor() {
get_range()->set((int)cursor.line_ofs);
*/
-
-
}
void TextEdit::center_viewport_to_cursor() {
- if (cursor.line_ofs>cursor.line)
- cursor.line_ofs=cursor.line;
+ if (cursor.line_ofs > cursor.line)
+ cursor.line_ofs = cursor.line;
- int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
+ int visible_width = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width;
if (v_scroll->is_visible())
- visible_width-=v_scroll->get_combined_minimum_size().width;
- visible_width-=20; // give it a little more space
+ visible_width -= v_scroll->get_combined_minimum_size().width;
+ visible_width -= 20; // give it a little more space
int visible_rows = get_visible_rows();
if (h_scroll->is_visible())
- visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height());
+ visible_rows -= ((h_scroll->get_combined_minimum_size().height - 1) / get_row_height());
- int max_ofs = text.size()-(scroll_past_end_of_file_enabled?1:visible_rows);
- cursor.line_ofs=CLAMP(cursor.line-(visible_rows/2),0,max_ofs);
+ int max_ofs = text.size() - (scroll_past_end_of_file_enabled ? 1 : visible_rows);
+ cursor.line_ofs = CLAMP(cursor.line - (visible_rows / 2), 0, max_ofs);
- int cursor_x = get_column_x_offset( cursor.column, text[cursor.line] );
+ int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]);
- if (cursor_x>(cursor.x_ofs+visible_width))
- cursor.x_ofs=cursor_x-visible_width+1;
+ if (cursor_x > (cursor.x_ofs + visible_width))
+ cursor.x_ofs = cursor_x - visible_width + 1;
if (cursor_x < cursor.x_ofs)
- cursor.x_ofs=cursor_x;
+ cursor.x_ofs = cursor_x;
update();
}
void TextEdit::cursor_set_column(int p_col, bool p_adjust_viewport) {
- if (p_col<0)
- p_col=0;
+ if (p_col < 0)
+ p_col = 0;
- cursor.column=p_col;
- if (cursor.column > get_line( cursor.line ).length())
- cursor.column=get_line( cursor.line ).length();
+ cursor.column = p_col;
+ if (cursor.column > get_line(cursor.line).length())
+ cursor.column = get_line(cursor.line).length();
- cursor.last_fit_x=get_column_x_offset(cursor.column,get_line(cursor.line));
+ cursor.last_fit_x = get_column_x_offset(cursor.column, get_line(cursor.line));
if (p_adjust_viewport)
adjust_viewport_to_cursor();
if (!cursor_changed_dirty) {
if (is_inside_tree())
- MessageQueue::get_singleton()->push_call(this,"_cursor_changed_emit");
- cursor_changed_dirty=true;
+ MessageQueue::get_singleton()->push_call(this, "_cursor_changed_emit");
+ cursor_changed_dirty = true;
}
-
}
-
void TextEdit::cursor_set_line(int p_row, bool p_adjust_viewport) {
if (setting_row)
return;
- setting_row=true;
- if (p_row<0)
- p_row=0;
+ setting_row = true;
+ if (p_row < 0)
+ p_row = 0;
+ if (p_row >= (int)text.size())
+ p_row = (int)text.size() - 1;
- if (p_row>=(int)text.size())
- p_row=(int)text.size()-1;
-
- cursor.line=p_row;
- cursor.column=get_char_pos_for( cursor.last_fit_x, get_line( cursor.line) );
+ cursor.line = p_row;
+ cursor.column = get_char_pos_for(cursor.last_fit_x, get_line(cursor.line));
if (p_adjust_viewport)
adjust_viewport_to_cursor();
- setting_row=false;
-
+ setting_row = false;
if (!cursor_changed_dirty) {
if (is_inside_tree())
- MessageQueue::get_singleton()->push_call(this,"_cursor_changed_emit");
- cursor_changed_dirty=true;
+ MessageQueue::get_singleton()->push_call(this, "_cursor_changed_emit");
+ cursor_changed_dirty = true;
}
-
}
-
int TextEdit::cursor_get_column() const {
return cursor.column;
}
-
int TextEdit::cursor_get_line() const {
return cursor.line;
@@ -3130,7 +3006,6 @@ void TextEdit::cursor_set_blink_enabled(const bool p_enabled) {
draw_caret = true;
}
-
float TextEdit::cursor_get_blink_speed() const {
return caret_blink_timer->get_wait_time();
}
@@ -3140,7 +3015,7 @@ void TextEdit::cursor_set_blink_speed(const float p_speed) {
caret_blink_timer->set_wait_time(p_speed);
}
-void TextEdit::cursor_set_block_mode(const bool p_enable){
+void TextEdit::cursor_set_block_mode(const bool p_enable) {
block_caret = p_enable;
update();
}
@@ -3149,131 +3024,122 @@ bool TextEdit::cursor_is_block_mode() const {
return block_caret;
}
-
void TextEdit::_scroll_moved(double p_to_val) {
if (updating_scrolls)
return;
if (h_scroll->is_visible())
- cursor.x_ofs=h_scroll->get_val();
+ cursor.x_ofs = h_scroll->get_val();
if (v_scroll->is_visible())
- cursor.line_ofs=v_scroll->get_val();
+ cursor.line_ofs = v_scroll->get_val();
update();
}
-
-
-
-
int TextEdit::get_row_height() const {
- return cache.font->get_height()+cache.line_spacing;
+ return cache.font->get_height() + cache.line_spacing;
}
-int TextEdit::get_char_pos_for(int p_px,String p_str) const {
+int TextEdit::get_char_pos_for(int p_px, String p_str) const {
- int px=0;
- int c=0;
+ int px = 0;
+ int c = 0;
- int tab_w = cache.font->get_char_size(' ').width*tab_size;
+ int tab_w = cache.font->get_char_size(' ').width * tab_size;
- while (c<p_str.length()) {
+ while (c < p_str.length()) {
- int w=0;
+ int w = 0;
- if (p_str[c]=='\t') {
+ if (p_str[c] == '\t') {
- int left = px%tab_w;
- if (left==0)
- w=tab_w;
+ int left = px % tab_w;
+ if (left == 0)
+ w = tab_w;
else
- w=tab_w-px%tab_w; // is right...
+ w = tab_w - px % tab_w; // is right...
} else {
- w=cache.font->get_char_size(p_str[c],p_str[c+1]).width;
+ w = cache.font->get_char_size(p_str[c], p_str[c + 1]).width;
}
- if (p_px<(px+w/2))
+ if (p_px < (px + w / 2))
break;
- px+=w;
+ px += w;
c++;
}
return c;
}
-int TextEdit::get_column_x_offset(int p_char,String p_str) {
+int TextEdit::get_column_x_offset(int p_char, String p_str) {
- int px=0;
+ int px = 0;
- int tab_w = cache.font->get_char_size(' ').width*tab_size;
+ int tab_w = cache.font->get_char_size(' ').width * tab_size;
- for (int i=0;i<p_char;i++) {
+ for (int i = 0; i < p_char; i++) {
- if (i>=p_str.length())
+ if (i >= p_str.length())
break;
- if (p_str[i]=='\t') {
+ if (p_str[i] == '\t') {
- int left = px%tab_w;
- if (left==0)
- px+=tab_w;
+ int left = px % tab_w;
+ if (left == 0)
+ px += tab_w;
else
- px+=tab_w-px%tab_w; // is right...
+ px += tab_w - px % tab_w; // is right...
} else {
- px+=cache.font->get_char_size(p_str[i],p_str[i+1]).width;
+ px += cache.font->get_char_size(p_str[i], p_str[i + 1]).width;
}
}
return px;
-
}
-void TextEdit::insert_text_at_cursor(const String& p_text) {
+void TextEdit::insert_text_at_cursor(const String &p_text) {
if (selection.active) {
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- selection.active=false;
- selection.selecting_mode=Selection::MODE_NONE;
-
+ _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
+ selection.active = false;
+ selection.selecting_mode = Selection::MODE_NONE;
}
_insert_text_at_cursor(p_text);
update();
-
}
-Control::CursorShape TextEdit::get_cursor_shape(const Point2& p_pos) const {
- int gutter=cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w+cache.breakpoint_gutter_width;
- if((completion_active && completion_rect.has_point(p_pos)) || p_pos.x < gutter) {
+Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
+ int gutter = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width;
+ if ((completion_active && completion_rect.has_point(p_pos)) || p_pos.x < gutter) {
return CURSOR_ARROW;
}
return CURSOR_IBEAM;
}
+void TextEdit::set_text(String p_text) {
-void TextEdit::set_text(String p_text){
-
- setting_text=true;
+ setting_text = true;
clear();
_insert_text_at_cursor(p_text);
clear_undo_history();
- cursor.column=0;
- cursor.line=0;
- cursor.x_ofs=0;
- cursor.line_ofs=0;
- cursor.last_fit_x=0;
+ cursor.column = 0;
+ cursor.line = 0;
+ cursor.x_ofs = 0;
+ cursor.line_ofs = 0;
+ cursor.last_fit_x = 0;
cursor_set_line(0);
cursor_set_column(0);
update();
- setting_text=false;
+ setting_text = false;
//get_range()->set(0);
};
@@ -3281,87 +3147,77 @@ void TextEdit::set_text(String p_text){
String TextEdit::get_text() {
String longthing;
int len = text.size();
- for (int i=0;i<len;i++) {
-
+ for (int i = 0; i < len; i++) {
- longthing+=text[i];
- if (i!=len-1)
- longthing+="\n";
+ longthing += text[i];
+ if (i != len - 1)
+ longthing += "\n";
}
return longthing;
-
};
String TextEdit::get_text_for_completion() {
String longthing;
int len = text.size();
- for (int i=0;i<len;i++) {
+ for (int i = 0; i < len; i++) {
- if (i==cursor.line) {
- longthing+=text[i].substr(0,cursor.column);
- longthing+=String::chr(0xFFFF); //not unicode, represents the cursor
- longthing+=text[i].substr(cursor.column,text[i].size());
+ if (i == cursor.line) {
+ longthing += text[i].substr(0, cursor.column);
+ longthing += String::chr(0xFFFF); //not unicode, represents the cursor
+ longthing += text[i].substr(cursor.column, text[i].size());
} else {
- longthing+=text[i];
+ longthing += text[i];
}
-
- if (i!=len-1)
- longthing+="\n";
+ if (i != len - 1)
+ longthing += "\n";
}
return longthing;
-
};
-
String TextEdit::get_line(int line) const {
- if (line<0 || line>=text.size())
+ if (line < 0 || line >= text.size())
return "";
- return text[line];
-
+ return text[line];
};
void TextEdit::_clear() {
clear_undo_history();
text.clear();
- cursor.column=0;
- cursor.line=0;
- cursor.x_ofs=0;
- cursor.line_ofs=0;
- cursor.last_fit_x=0;
+ cursor.column = 0;
+ cursor.line = 0;
+ cursor.x_ofs = 0;
+ cursor.line_ofs = 0;
+ cursor.last_fit_x = 0;
}
-
-
void TextEdit::clear() {
- setting_text=true;
+ setting_text = true;
_clear();
- setting_text=false;
-
+ setting_text = false;
};
void TextEdit::set_readonly(bool p_readonly) {
-
- readonly=p_readonly;
+ readonly = p_readonly;
}
void TextEdit::set_wrap(bool p_wrap) {
- wrap=p_wrap;
+ wrap = p_wrap;
}
void TextEdit::set_max_chars(int p_max_chars) {
- max_chars=p_max_chars;
+ max_chars = p_max_chars;
}
void TextEdit::_reset_caret_blink_timer() {
@@ -3382,77 +3238,74 @@ void TextEdit::_toggle_draw_caret() {
void TextEdit::_update_caches() {
- cache.style_normal=get_stylebox("normal");
- cache.style_focus=get_stylebox("focus");
- cache.completion_background_color=get_color("completion_background_color");
- cache.completion_selected_color=get_color("completion_selected_color");
- cache.completion_existing_color=get_color("completion_existing_color");
- cache.completion_font_color=get_color("completion_font_color");
- cache.font=get_font("font");
- cache.caret_color=get_color("caret_color");
- cache.caret_background_color=get_color("caret_background_color");
- cache.line_number_color=get_color("line_number_color");
- cache.font_color=get_color("font_color");
- cache.font_selected_color=get_color("font_selected_color");
- cache.keyword_color=get_color("keyword_color");
- cache.function_color=get_color("function_color");
- cache.member_variable_color=get_color("member_variable_color");
- cache.number_color=get_color("number_color");
- cache.selection_color=get_color("selection_color");
- cache.mark_color=get_color("mark_color");
- cache.current_line_color=get_color("current_line_color");
- cache.line_length_guideline_color=get_color("line_length_guideline_color");
- cache.breakpoint_color=get_color("breakpoint_color");
- cache.brace_mismatch_color=get_color("brace_mismatch_color");
- cache.word_highlighted_color=get_color("word_highlighted_color");
- cache.search_result_color=get_color("search_result_color");
- cache.search_result_border_color=get_color("search_result_border_color");
- cache.line_spacing=get_constant("line_spacing");
+ cache.style_normal = get_stylebox("normal");
+ cache.style_focus = get_stylebox("focus");
+ cache.completion_background_color = get_color("completion_background_color");
+ cache.completion_selected_color = get_color("completion_selected_color");
+ cache.completion_existing_color = get_color("completion_existing_color");
+ cache.completion_font_color = get_color("completion_font_color");
+ cache.font = get_font("font");
+ cache.caret_color = get_color("caret_color");
+ cache.caret_background_color = get_color("caret_background_color");
+ cache.line_number_color = get_color("line_number_color");
+ cache.font_color = get_color("font_color");
+ cache.font_selected_color = get_color("font_selected_color");
+ cache.keyword_color = get_color("keyword_color");
+ cache.function_color = get_color("function_color");
+ cache.member_variable_color = get_color("member_variable_color");
+ cache.number_color = get_color("number_color");
+ cache.selection_color = get_color("selection_color");
+ cache.mark_color = get_color("mark_color");
+ cache.current_line_color = get_color("current_line_color");
+ cache.line_length_guideline_color = get_color("line_length_guideline_color");
+ cache.breakpoint_color = get_color("breakpoint_color");
+ cache.brace_mismatch_color = get_color("brace_mismatch_color");
+ cache.word_highlighted_color = get_color("word_highlighted_color");
+ cache.search_result_color = get_color("search_result_color");
+ cache.search_result_border_color = get_color("search_result_border_color");
+ cache.line_spacing = get_constant("line_spacing");
cache.row_height = cache.font->get_height() + cache.line_spacing;
- cache.tab_icon=get_icon("tab");
+ cache.tab_icon = get_icon("tab");
text.set_font(cache.font);
-
}
-
void TextEdit::clear_colors() {
keywords.clear();
- color_regions.clear();;
+ color_regions.clear();
+ ;
text.clear_caches();
- custom_bg_color=Color(0,0,0,0);
+ custom_bg_color = Color(0, 0, 0, 0);
}
-void TextEdit::set_custom_bg_color(const Color& p_color) {
+void TextEdit::set_custom_bg_color(const Color &p_color) {
- custom_bg_color=p_color;
+ custom_bg_color = p_color;
update();
}
-void TextEdit::add_keyword_color(const String& p_keyword,const Color& p_color) {
+void TextEdit::add_keyword_color(const String &p_keyword, const Color &p_color) {
- keywords[p_keyword]=p_color;
+ keywords[p_keyword] = p_color;
update();
-
}
-void TextEdit::add_color_region(const String& p_begin_key,const String& p_end_key,const Color &p_color,bool p_line_only) {
+void TextEdit::add_color_region(const String &p_begin_key, const String &p_end_key, const Color &p_color, bool p_line_only) {
- color_regions.push_back(ColorRegion(p_begin_key,p_end_key,p_color,p_line_only));
+ color_regions.push_back(ColorRegion(p_begin_key, p_end_key, p_color, p_line_only));
text.clear_caches();
update();
-
}
-void TextEdit::set_symbol_color(const Color& p_color) {
+void TextEdit::set_symbol_color(const Color &p_color) {
- symbol_color=p_color;
+ symbol_color = p_color;
update();
}
void TextEdit::set_syntax_coloring(bool p_enabled) {
- syntax_coloring=p_enabled;
+ syntax_coloring = p_enabled;
update();
}
@@ -3473,24 +3326,24 @@ void TextEdit::cut() {
OS::get_singleton()->set_clipboard(clipboard);
cursor_set_line(cursor.line);
cursor_set_column(0);
- _remove_text(cursor.line,0,cursor.line,text[cursor.line].length());
+ _remove_text(cursor.line, 0, cursor.line, text[cursor.line].length());
backspace_at_cursor();
update();
- cursor_set_line(cursor.line+1);
+ cursor_set_line(cursor.line + 1);
cut_copy_line = true;
} else {
- String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
OS::get_singleton()->set_clipboard(clipboard);
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- selection.active=false;
- selection.selecting_mode=Selection::MODE_NONE;
+ _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
+ selection.active = false;
+ selection.selecting_mode = Selection::MODE_NONE;
update();
cut_copy_line = false;
}
@@ -3502,11 +3355,11 @@ void TextEdit::copy() {
return;
if (!selection.active) {
- String clipboard = _base_get_text(cursor.line,0,cursor.line,text[cursor.line].length());
+ String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
OS::get_singleton()->set_clipboard(clipboard);
cut_copy_line = true;
} else {
- String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
OS::get_singleton()->set_clipboard(clipboard);
cut_copy_line = false;
}
@@ -3518,16 +3371,16 @@ void TextEdit::paste() {
if (selection.active) {
- selection.active=false;
- selection.selecting_mode=Selection::MODE_NONE;
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ selection.active = false;
+ selection.selecting_mode = Selection::MODE_NONE;
+ _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
} else if (cut_copy_line) {
cursor_set_column(0);
- String ins="\n";
+ String ins = "\n";
clipboard += ins;
}
@@ -3537,74 +3390,71 @@ void TextEdit::paste() {
void TextEdit::select_all() {
- if (text.size()==1 && text[0].length()==0)
+ if (text.size() == 1 && text[0].length() == 0)
return;
- selection.active=true;
- selection.from_line=0;
- selection.from_column=0;
- selection.selecting_line=0;
- selection.selecting_column=0;
- selection.to_line=text.size()-1;
- selection.to_column=text[selection.to_line].length();
- selection.selecting_mode=Selection::MODE_SHIFT;
- selection.shiftclick_left=true;
- cursor_set_line( selection.to_line, false );
- cursor_set_column( selection.to_column, false );
+ selection.active = true;
+ selection.from_line = 0;
+ selection.from_column = 0;
+ selection.selecting_line = 0;
+ selection.selecting_column = 0;
+ selection.to_line = text.size() - 1;
+ selection.to_column = text[selection.to_line].length();
+ selection.selecting_mode = Selection::MODE_SHIFT;
+ selection.shiftclick_left = true;
+ cursor_set_line(selection.to_line, false);
+ cursor_set_column(selection.to_column, false);
update();
-
}
-
void TextEdit::deselect() {
- selection.active=false;
+ selection.active = false;
update();
}
-void TextEdit::select(int p_from_line,int p_from_column,int p_to_line,int p_to_column) {
+void TextEdit::select(int p_from_line, int p_from_column, int p_to_line, int p_to_column) {
- if (p_from_line>=text.size())
- p_from_line=text.size()-1;
- if (p_from_column>=text[p_from_line].length())
- p_from_column=text[p_from_line].length();
+ if (p_from_line >= text.size())
+ p_from_line = text.size() - 1;
+ if (p_from_column >= text[p_from_line].length())
+ p_from_column = text[p_from_line].length();
- if (p_to_line>=text.size())
- p_to_line=text.size()-1;
- if (p_to_column>=text[p_to_line].length())
- p_to_column=text[p_to_line].length();
+ if (p_to_line >= text.size())
+ p_to_line = text.size() - 1;
+ if (p_to_column >= text[p_to_line].length())
+ p_to_column = text[p_to_line].length();
- selection.from_line=p_from_line;
- selection.from_column=p_from_column;
- selection.to_line=p_to_line;
- selection.to_column=p_to_column;
+ selection.from_line = p_from_line;
+ selection.from_column = p_from_column;
+ selection.to_line = p_to_line;
+ selection.to_column = p_to_column;
- selection.active=true;
+ selection.active = true;
- if (selection.from_line==selection.to_line) {
+ if (selection.from_line == selection.to_line) {
- if (selection.from_column==selection.to_column) {
+ if (selection.from_column == selection.to_column) {
- selection.active=false;
+ selection.active = false;
- } else if (selection.from_column>selection.to_column) {
+ } else if (selection.from_column > selection.to_column) {
selection.shiftclick_left = false;
- SWAP( selection.from_column, selection.to_column );
+ SWAP(selection.from_column, selection.to_column);
} else {
selection.shiftclick_left = true;
}
- } else if (selection.from_line>selection.to_line) {
+ } else if (selection.from_line > selection.to_line) {
selection.shiftclick_left = false;
- SWAP( selection.from_line, selection.to_line );
- SWAP( selection.from_column, selection.to_column );
+ SWAP(selection.from_line, selection.to_line);
+ SWAP(selection.from_column, selection.to_column);
} else {
selection.shiftclick_left = true;
}
-
update();
}
@@ -3614,27 +3464,23 @@ bool TextEdit::is_selection_active() const {
}
int TextEdit::get_selection_from_line() const {
- ERR_FAIL_COND_V(!selection.active,-1);
+ ERR_FAIL_COND_V(!selection.active, -1);
return selection.from_line;
-
}
int TextEdit::get_selection_from_column() const {
- ERR_FAIL_COND_V(!selection.active,-1);
+ ERR_FAIL_COND_V(!selection.active, -1);
return selection.from_column;
-
}
int TextEdit::get_selection_to_line() const {
- ERR_FAIL_COND_V(!selection.active,-1);
+ ERR_FAIL_COND_V(!selection.active, -1);
return selection.to_line;
-
}
int TextEdit::get_selection_to_column() const {
- ERR_FAIL_COND_V(!selection.active,-1);
+ ERR_FAIL_COND_V(!selection.active, -1);
return selection.to_column;
-
}
String TextEdit::get_selection_text() const {
@@ -3642,30 +3488,29 @@ String TextEdit::get_selection_text() const {
if (!selection.active)
return "";
- return _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
-
+ return _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
}
String TextEdit::get_word_under_cursor() const {
int prev_cc = cursor.column;
- while(prev_cc >0) {
- bool is_char = _is_text_char(text[cursor.line][prev_cc-1]);
+ while (prev_cc > 0) {
+ bool is_char = _is_text_char(text[cursor.line][prev_cc - 1]);
if (!is_char)
break;
--prev_cc;
}
int next_cc = cursor.column;
- while(next_cc<text[cursor.line].length()) {
+ while (next_cc < text[cursor.line].length()) {
bool is_char = _is_text_char(text[cursor.line][next_cc]);
- if(!is_char)
+ if (!is_char)
break;
- ++ next_cc;
+ ++next_cc;
}
if (prev_cc == cursor.column || next_cc == cursor.column)
return "";
- return text[cursor.line].substr(prev_cc, next_cc-prev_cc);
+ return text[cursor.line].substr(prev_cc, next_cc - prev_cc);
}
void TextEdit::set_search_text(const String &p_search_text) {
@@ -3700,37 +3545,37 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc
}
while (col == -1 && p_from_column <= p_search.length()) {
- if (p_search_flags&SEARCH_MATCH_CASE) {
- col = p_search.find(p_key,p_from_column);
+ if (p_search_flags & SEARCH_MATCH_CASE) {
+ col = p_search.find(p_key, p_from_column);
} else {
- col = p_search.findn(p_key,p_from_column);
+ col = p_search.findn(p_key, p_from_column);
}
// whole words only
- if (col != -1 && p_search_flags&SEARCH_WHOLE_WORDS) {
- p_from_column=col;
+ if (col != -1 && p_search_flags & SEARCH_WHOLE_WORDS) {
+ p_from_column = col;
- if (col > 0 && _is_text_char(p_search[col-1])) {
+ if (col > 0 && _is_text_char(p_search[col - 1])) {
col = -1;
- } else if ((col + p_key.length()) < p_search.length() && _is_text_char(p_search[col+p_key.length()])) {
+ } else if ((col + p_key.length()) < p_search.length() && _is_text_char(p_search[col + p_key.length()])) {
col = -1;
}
}
- p_from_column+=1;
+ p_from_column += 1;
}
}
return col;
}
-DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const {
+DVector<int> TextEdit::_search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const {
- int col,line;
- if (search(p_key,p_search_flags,p_from_line,p_from_column,col,line)) {
+ int col, line;
+ if (search(p_key, p_search_flags, p_from_line, p_from_column, col, line)) {
DVector<int> result;
result.resize(2);
- result.set(0,line);
- result.set(1,col);
+ result.set(0, line);
+ result.set(1, col);
return result;
} else {
@@ -3739,108 +3584,104 @@ DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags,
}
}
-bool TextEdit::search(const String &p_key,uint32_t p_search_flags, int p_from_line, int p_from_column,int &r_line,int &r_column) const {
+bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column, int &r_line, int &r_column) const {
- if (p_key.length()==0)
+ if (p_key.length() == 0)
return false;
- ERR_FAIL_INDEX_V(p_from_line,text.size(),false);
- ERR_FAIL_INDEX_V(p_from_column,text[p_from_line].length()+1,false);
+ ERR_FAIL_INDEX_V(p_from_line, text.size(), false);
+ ERR_FAIL_INDEX_V(p_from_column, text[p_from_line].length() + 1, false);
//search through the whole documment, but start by current line
- int line=-1;
- int pos=-1;
+ int line = -1;
+ int pos = -1;
- line=p_from_line;
+ line = p_from_line;
- for(int i=0;i<text.size()+1;i++) {
+ for (int i = 0; i < text.size() + 1; i++) {
//backwards is broken...
//int idx=(p_search_flags&SEARCH_BACKWARDS)?(text.size()-i):i; //do backwards seearch
-
- if (line<0) {
- line=text.size()-1;
+ if (line < 0) {
+ line = text.size() - 1;
}
- if (line==text.size()) {
- line=0;
+ if (line == text.size()) {
+ line = 0;
}
String text_line = text[line];
- int from_column=0;
- if (line==p_from_line) {
+ int from_column = 0;
+ if (line == p_from_line) {
- if (i==text.size()) {
+ if (i == text.size()) {
//wrapped
- if (p_search_flags&SEARCH_BACKWARDS) {
- from_column=text_line.length();
+ if (p_search_flags & SEARCH_BACKWARDS) {
+ from_column = text_line.length();
} else {
- from_column=0;
+ from_column = 0;
}
} else {
- from_column=p_from_column;
+ from_column = p_from_column;
}
-
} else {
- if (p_search_flags&SEARCH_BACKWARDS)
- from_column=text_line.length()-1;
+ if (p_search_flags & SEARCH_BACKWARDS)
+ from_column = text_line.length() - 1;
else
- from_column=0;
+ from_column = 0;
}
- pos=-1;
+ pos = -1;
- int pos_from=0;
- int last_pos=-1;
- while ((last_pos=(p_search_flags&SEARCH_MATCH_CASE)?text_line.find(p_key,pos_from):text_line.findn(p_key,pos_from))!=-1) {
+ int pos_from = 0;
+ int last_pos = -1;
+ while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) {
- if (p_search_flags&SEARCH_BACKWARDS) {
+ if (p_search_flags & SEARCH_BACKWARDS) {
- if (last_pos>from_column)
+ if (last_pos > from_column)
break;
- pos=last_pos;
+ pos = last_pos;
} else {
- if (last_pos>=from_column) {
- pos=last_pos;
+ if (last_pos >= from_column) {
+ pos = last_pos;
break;
}
}
- pos_from=last_pos+p_key.length();
+ pos_from = last_pos + p_key.length();
}
- if (pos!=-1 && (p_search_flags&SEARCH_WHOLE_WORDS)) {
+ if (pos != -1 && (p_search_flags & SEARCH_WHOLE_WORDS)) {
//validate for whole words
- if (pos>0 && _is_text_char(text_line[pos-1]))
- pos=-1;
- else if (_is_text_char(text_line[pos+p_key.length()]))
- pos=-1;
+ if (pos > 0 && _is_text_char(text_line[pos - 1]))
+ pos = -1;
+ else if (_is_text_char(text_line[pos + p_key.length()]))
+ pos = -1;
}
- if (pos!=-1)
+ if (pos != -1)
break;
- if (p_search_flags&SEARCH_BACKWARDS)
+ if (p_search_flags & SEARCH_BACKWARDS)
line--;
else
line++;
-
}
- if (pos==-1) {
- r_line=-1;
- r_column=-1;
+ if (pos == -1) {
+ r_line = -1;
+ r_column = -1;
return false;
}
- r_line=line;
- r_column=pos;
-
+ r_line = line;
+ r_column = pos;
return true;
}
@@ -3848,40 +3689,38 @@ bool TextEdit::search(const String &p_key,uint32_t p_search_flags, int p_from_li
void TextEdit::_cursor_changed_emit() {
emit_signal("cursor_changed");
- cursor_changed_dirty=false;
+ cursor_changed_dirty = false;
}
void TextEdit::_text_changed_emit() {
emit_signal("text_changed");
- text_changed_dirty=false;
+ text_changed_dirty = false;
}
-void TextEdit::set_line_as_marked(int p_line,bool p_marked) {
+void TextEdit::set_line_as_marked(int p_line, bool p_marked) {
- ERR_FAIL_INDEX(p_line,text.size());
- text.set_marked(p_line,p_marked);
+ ERR_FAIL_INDEX(p_line, text.size());
+ text.set_marked(p_line, p_marked);
update();
}
bool TextEdit::is_line_set_as_breakpoint(int p_line) const {
- ERR_FAIL_INDEX_V(p_line,text.size(),false);
+ ERR_FAIL_INDEX_V(p_line, text.size(), false);
return text.is_breakpoint(p_line);
-
}
-void TextEdit::set_line_as_breakpoint(int p_line,bool p_breakpoint) {
+void TextEdit::set_line_as_breakpoint(int p_line, bool p_breakpoint) {
-
- ERR_FAIL_INDEX(p_line,text.size());
- text.set_breakpoint(p_line,p_breakpoint);
+ ERR_FAIL_INDEX(p_line, text.size());
+ text.set_breakpoint(p_line, p_breakpoint);
update();
}
void TextEdit::get_breakpoints(List<int> *p_breakpoints) const {
- for(int i=0;i<text.size();i++) {
+ for (int i = 0; i < text.size(); i++) {
if (text.is_breakpoint(i))
p_breakpoints->push_back(i);
}
@@ -3892,64 +3731,62 @@ int TextEdit::get_line_count() const {
return text.size();
}
-void TextEdit::_do_text_op(const TextOperation& p_op, bool p_reverse) {
+void TextEdit::_do_text_op(const TextOperation &p_op, bool p_reverse) {
- ERR_FAIL_COND(p_op.type==TextOperation::TYPE_NONE);
+ ERR_FAIL_COND(p_op.type == TextOperation::TYPE_NONE);
- bool insert = p_op.type==TextOperation::TYPE_INSERT;
+ bool insert = p_op.type == TextOperation::TYPE_INSERT;
if (p_reverse)
- insert=!insert;
+ insert = !insert;
if (insert) {
int check_line;
int check_column;
- _base_insert_text(p_op.from_line,p_op.from_column,p_op.text,check_line,check_column);
- ERR_FAIL_COND( check_line != p_op.to_line ); // BUG
- ERR_FAIL_COND( check_column != p_op.to_column ); // BUG
+ _base_insert_text(p_op.from_line, p_op.from_column, p_op.text, check_line, check_column);
+ ERR_FAIL_COND(check_line != p_op.to_line); // BUG
+ ERR_FAIL_COND(check_column != p_op.to_column); // BUG
} else {
- _base_remove_text(p_op.from_line,p_op.from_column,p_op.to_line,p_op.to_column);
+ _base_remove_text(p_op.from_line, p_op.from_column, p_op.to_line, p_op.to_column);
}
-
}
void TextEdit::_clear_redo() {
- if (undo_stack_pos==NULL)
+ if (undo_stack_pos == NULL)
return; //nothing to clear
_push_current_op();
- while (undo_stack_pos) {
+ while (undo_stack_pos) {
List<TextOperation>::Element *elem = undo_stack_pos;
- undo_stack_pos=undo_stack_pos->next();
+ undo_stack_pos = undo_stack_pos->next();
undo_stack.erase(elem);
}
}
-
void TextEdit::undo() {
_push_current_op();
- if (undo_stack_pos==NULL) {
+ if (undo_stack_pos == NULL) {
if (!undo_stack.size())
return; //nothing to undo
- undo_stack_pos=undo_stack.back();
+ undo_stack_pos = undo_stack.back();
- } else if (undo_stack_pos==undo_stack.front())
+ } else if (undo_stack_pos == undo_stack.front())
return; // at the bottom of the undo stack
else
- undo_stack_pos=undo_stack_pos->prev();
+ undo_stack_pos = undo_stack_pos->prev();
TextOperation op = undo_stack_pos->get();
_do_text_op(op, true);
- current_op.version=op.prev_version;
- if(undo_stack_pos->get().chain_backward) {
- while(true) {
+ current_op.version = op.prev_version;
+ if (undo_stack_pos->get().chain_backward) {
+ while (true) {
ERR_BREAK(!undo_stack_pos->prev());
undo_stack_pos = undo_stack_pos->prev();
op = undo_stack_pos->get();
@@ -3976,17 +3813,17 @@ void TextEdit::redo() {
_push_current_op();
- if (undo_stack_pos==NULL)
+ if (undo_stack_pos == NULL)
return; //nothing to do.
TextOperation op = undo_stack_pos->get();
_do_text_op(op, false);
current_op.version = op.version;
- if(undo_stack_pos->get().chain_forward) {
+ if (undo_stack_pos->get().chain_forward) {
- while(true) {
+ while (true) {
ERR_BREAK(!undo_stack_pos->next());
- undo_stack_pos=undo_stack_pos->next();
+ undo_stack_pos = undo_stack_pos->next();
op = undo_stack_pos->get();
_do_text_op(op, false);
current_op.version = op.version;
@@ -3996,22 +3833,21 @@ void TextEdit::redo() {
}
cursor_set_line(undo_stack_pos->get().to_line);
cursor_set_column(undo_stack_pos->get().to_column);
- undo_stack_pos=undo_stack_pos->next();
+ undo_stack_pos = undo_stack_pos->next();
update();
}
void TextEdit::clear_undo_history() {
- saved_version=0;
- current_op.type=TextOperation::TYPE_NONE;
- undo_stack_pos=NULL;
+ saved_version = 0;
+ current_op.type = TextOperation::TYPE_NONE;
+ undo_stack_pos = NULL;
undo_stack.clear();
-
}
void TextEdit::begin_complex_operation() {
_push_current_op();
- next_operation_is_complex=true;
+ next_operation_is_complex = true;
}
void TextEdit::end_complex_operation() {
@@ -4019,29 +3855,28 @@ void TextEdit::end_complex_operation() {
_push_current_op();
ERR_FAIL_COND(undo_stack.size() == 0);
- if(undo_stack.back()->get().chain_forward) {
- undo_stack.back()->get().chain_forward=false;
+ if (undo_stack.back()->get().chain_forward) {
+ undo_stack.back()->get().chain_forward = false;
return;
}
- undo_stack.back()->get().chain_backward=true;
+ undo_stack.back()->get().chain_backward = true;
}
void TextEdit::_push_current_op() {
- if (current_op.type==TextOperation::TYPE_NONE)
+ if (current_op.type == TextOperation::TYPE_NONE)
return; // do nothing
- if(next_operation_is_complex) {
- current_op.chain_forward=true;
- next_operation_is_complex=false;
+ if (next_operation_is_complex) {
+ current_op.chain_forward = true;
+ next_operation_is_complex = false;
}
undo_stack.push_back(current_op);
- current_op.type=TextOperation::TYPE_NONE;
- current_op.text="";
- current_op.chain_forward=false;
-
+ current_op.type = TextOperation::TYPE_NONE;
+ current_op.text = "";
+ current_op.chain_forward = false;
}
void TextEdit::set_tab_size(const int p_size) {
@@ -4053,10 +3888,10 @@ void TextEdit::set_tab_size(const int p_size) {
void TextEdit::set_draw_tabs(bool p_draw) {
- draw_tabs=p_draw;
+ draw_tabs = p_draw;
}
-bool TextEdit::is_drawing_tabs() const{
+bool TextEdit::is_drawing_tabs() const {
return draw_tabs;
}
@@ -4079,7 +3914,7 @@ uint32_t TextEdit::get_saved_version() const {
}
void TextEdit::tag_saved_version() {
- saved_version=get_version();
+ saved_version = get_version();
}
int TextEdit::get_v_scroll() const {
@@ -4089,7 +3924,7 @@ int TextEdit::get_v_scroll() const {
void TextEdit::set_v_scroll(int p_scroll) {
v_scroll->set_val(p_scroll);
- cursor.line_ofs=p_scroll;
+ cursor.line_ofs = p_scroll;
}
int TextEdit::get_h_scroll() const {
@@ -4101,11 +3936,11 @@ void TextEdit::set_h_scroll(int p_scroll) {
h_scroll->set_val(p_scroll);
}
-void TextEdit::set_completion(bool p_enabled,const Vector<String>& p_prefixes) {
+void TextEdit::set_completion(bool p_enabled, const Vector<String> &p_prefixes) {
completion_prefixes.clear();
- completion_enabled=p_enabled;
- for(int i=0;i<p_prefixes.size();i++)
+ completion_enabled = p_enabled;
+ for (int i = 0; i < p_prefixes.size(); i++)
completion_prefixes.insert(p_prefixes[i]);
}
@@ -4127,12 +3962,11 @@ void TextEdit::_confirm_completion() {
_cancel_completion();
}
-
void TextEdit::_cancel_code_hint() {
VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
raised_from_completion = false;
- completion_hint="";
+ completion_hint = "";
update();
}
@@ -4143,72 +3977,69 @@ void TextEdit::_cancel_completion() {
if (!completion_active)
return;
- completion_active=false;
+ completion_active = false;
update();
-
}
static bool _is_completable(CharType c) {
- return !_is_symbol(c) || c=='"' || c=='\'';
+ return !_is_symbol(c) || c == '"' || c == '\'';
}
-
void TextEdit::_update_completion_candidates() {
String l = text[cursor.line];
- int cofs = CLAMP(cursor.column,0,l.length());
-
+ int cofs = CLAMP(cursor.column, 0, l.length());
String s;
//look for keywords first
- bool inquote=false;
- int first_quote=-1;
+ bool inquote = false;
+ int first_quote = -1;
- int c=cofs-1;
- while(c>=0) {
- if (l[c]=='"' || l[c]=='\'') {
- inquote=!inquote;
- if (first_quote==-1)
- first_quote=c;
+ int c = cofs - 1;
+ while (c >= 0) {
+ if (l[c] == '"' || l[c] == '\'') {
+ inquote = !inquote;
+ if (first_quote == -1)
+ first_quote = c;
}
c--;
}
- bool pre_keyword=false;
- bool cancel=false;
+ bool pre_keyword = false;
+ bool cancel = false;
//print_line("inquote: "+itos(inquote)+"first quote "+itos(first_quote)+" cofs-1 "+itos(cofs-1));
- if (!inquote && first_quote==cofs-1) {
+ if (!inquote && first_quote == cofs - 1) {
//no completion here
//print_line("cancel!");
- cancel=true;
- } if (inquote && first_quote!=-1) {
+ cancel = true;
+ }
+ if (inquote && first_quote != -1) {
- s=l.substr(first_quote,cofs-first_quote);
+ s = l.substr(first_quote, cofs - first_quote);
//print_line("s: 1"+s);
- } else if (cofs>0 && l[cofs-1]==' ') {
- int kofs=cofs-1;
+ } else if (cofs > 0 && l[cofs - 1] == ' ') {
+ int kofs = cofs - 1;
String kw;
- while (kofs>=0 && l[kofs]==' ')
+ while (kofs >= 0 && l[kofs] == ' ')
kofs--;
- while(kofs>=0 && l[kofs]>32 && _is_completable(l[kofs])) {
- kw=String::chr(l[kofs])+kw;
+ while (kofs >= 0 && l[kofs] > 32 && _is_completable(l[kofs])) {
+ kw = String::chr(l[kofs]) + kw;
kofs--;
}
- pre_keyword=keywords.has(kw);
+ pre_keyword = keywords.has(kw);
//print_line("KW "+kw+"? "+itos(pre_keyword));
} else {
-
- while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) {
- s=String::chr(l[cofs-1])+s;
- if (l[cofs-1]=='\'' || l[cofs-1]=='"')
+ while (cofs > 0 && l[cofs - 1] > 32 && _is_completable(l[cofs - 1])) {
+ s = String::chr(l[cofs - 1]) + s;
+ if (l[cofs - 1] == '\'' || l[cofs - 1] == '"')
break;
cofs--;
@@ -4221,17 +4052,17 @@ void TextEdit::_update_completion_candidates() {
update();
- if (cancel || (!pre_keyword && s=="" && (cofs==0 || !completion_prefixes.has(String::chr(l[cofs-1]))))) {
+ if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !completion_prefixes.has(String::chr(l[cofs - 1]))))) {
//none to complete, cancel
_cancel_completion();
return;
}
completion_options.clear();
- completion_index=0;
- completion_base=s;
+ completion_index = 0;
+ completion_base = s;
Vector<float> sim_cache;
- for(int i=0;i<completion_strings.size();i++) {
+ for (int i = 0; i < completion_strings.size(); i++) {
if (s == completion_strings[i]) {
// A perfect match, stop completion
_cancel_completion();
@@ -4261,7 +4092,7 @@ void TextEdit::_update_completion_candidates() {
int pos = 0;
do {
comp_sim = sim_cache[pos++];
- } while(pos < comp_size && similarity < comp_sim);
+ } while (pos < comp_size && similarity < comp_sim);
pos = similarity > comp_sim ? pos - 1 : pos; // Pos will be off by one
completion_options.insert(pos, completion_strings[i]);
sim_cache.insert(pos, similarity);
@@ -4269,19 +4100,16 @@ void TextEdit::_update_completion_candidates() {
}
}
-
-
- if (completion_options.size()==0) {
+ if (completion_options.size() == 0) {
//no options to complete, cancel
_cancel_completion();
return;
-
}
// The top of the list is the best match
- completion_current=completion_options[0];
+ completion_current = completion_options[0];
-#if 0 // even there's only one option, user still get the chance to choose using it or not
+#if 0 // even there's only one option, user still get the chance to choose using it or not
if (completion_options.size()==1) {
//one option to complete, just complete it automagically
_confirm_completion();
@@ -4292,37 +4120,33 @@ void TextEdit::_update_completion_candidates() {
}
#endif
- completion_enabled=true;
+ completion_enabled = true;
}
-
-
void TextEdit::query_code_comple() {
String l = text[cursor.line];
- int ofs = CLAMP(cursor.column,0,l.length());
+ int ofs = CLAMP(cursor.column, 0, l.length());
- bool inquote=false;
+ bool inquote = false;
- int c=ofs-1;
- while(c>=0) {
- if (l[c]=='"' || l[c]=='\'')
- inquote=!inquote;
+ int c = ofs - 1;
+ while (c >= 0) {
+ if (l[c] == '"' || l[c] == '\'')
+ inquote = !inquote;
c--;
}
- if (ofs>0 && (inquote || _is_completable(l[ofs-1]) || completion_prefixes.has(String::chr(l[ofs-1]))))
+ if (ofs > 0 && (inquote || _is_completable(l[ofs - 1]) || completion_prefixes.has(String::chr(l[ofs - 1]))))
emit_signal("request_completion");
-
}
-
-void TextEdit::set_code_hint(const String& p_hint) {
+void TextEdit::set_code_hint(const String &p_hint) {
VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
raised_from_completion = true;
- completion_hint=p_hint;
- completion_hint_offset=-0xFFFF;
+ completion_hint = p_hint;
+ completion_hint_offset = -0xFFFF;
update();
}
@@ -4330,87 +4154,81 @@ void TextEdit::code_complete(const Vector<String> &p_strings) {
VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
raised_from_completion = true;
- completion_strings=p_strings;
- completion_active=true;
- completion_current="";
- completion_index=0;
+ completion_strings = p_strings;
+ completion_active = true;
+ completion_current = "";
+ completion_index = 0;
_update_completion_candidates();
//
}
-
-String TextEdit::get_tooltip(const Point2& p_pos) const {
+String TextEdit::get_tooltip(const Point2 &p_pos) const {
if (!tooltip_obj)
return Control::get_tooltip(p_pos);
- int row,col;
+ int row, col;
_get_mouse_pos(p_pos, row, col);
String s = text[row];
- if (s.length()==0)
+ if (s.length() == 0)
return Control::get_tooltip(p_pos);
- int beg=CLAMP(col,0,s.length());
- int end=beg;
-
+ int beg = CLAMP(col, 0, s.length());
+ int end = beg;
- if (s[beg]>32 || beg==s.length()) {
+ if (s[beg] > 32 || beg == s.length()) {
- bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
+ bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this
- while(beg>0 && s[beg-1]>32 && (symbol==_is_symbol(s[beg-1]))) {
+ while (beg > 0 && s[beg - 1] > 32 && (symbol == _is_symbol(s[beg - 1]))) {
beg--;
}
- while(end<s.length() && s[end+1]>32 && (symbol==_is_symbol(s[end+1]))) {
+ while (end < s.length() && s[end + 1] > 32 && (symbol == _is_symbol(s[end + 1]))) {
end++;
}
- if (end<s.length())
- end+=1;
+ if (end < s.length())
+ end += 1;
- String tt = tooltip_obj->call(tooltip_func,s.substr(beg,end-beg),tooltip_ud);
+ String tt = tooltip_obj->call(tooltip_func, s.substr(beg, end - beg), tooltip_ud);
return tt;
-
}
return Control::get_tooltip(p_pos);
-
}
-void TextEdit::set_tooltip_request_func(Object *p_obj, const StringName& p_function,const Variant& p_udata) {
+void TextEdit::set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata) {
- tooltip_obj=p_obj;
- tooltip_func=p_function;
- tooltip_ud=p_udata;
+ tooltip_obj = p_obj;
+ tooltip_func = p_function;
+ tooltip_ud = p_udata;
}
-void TextEdit::set_line(int line, String new_text)
-{
+void TextEdit::set_line(int line, String new_text) {
if (line < 0 || line > text.size())
return;
_remove_text(line, 0, line, text[line].length());
_insert_text(line, 0, new_text);
- if (cursor.line==line) {
- cursor.column=MIN(cursor.column,new_text.length());
+ if (cursor.line == line) {
+ cursor.column = MIN(cursor.column, new_text.length());
}
}
-void TextEdit::insert_at(const String &p_text, int at)
-{
+void TextEdit::insert_at(const String &p_text, int at) {
cursor_set_column(0);
cursor_set_line(at);
- _insert_text(at, 0, p_text+"\n");
+ _insert_text(at, 0, p_text + "\n");
}
void TextEdit::set_show_line_numbers(bool p_show) {
- line_numbers=p_show;
+ line_numbers = p_show;
update();
}
void TextEdit::set_line_numbers_zero_padded(bool p_zero_padded) {
- line_numbers_zero_padded=p_zero_padded;
+ line_numbers_zero_padded = p_zero_padded;
update();
}
@@ -4419,12 +4237,12 @@ bool TextEdit::is_show_line_numbers_enabled() const {
}
void TextEdit::set_show_line_length_guideline(bool p_show) {
- line_length_guideline=p_show;
+ line_length_guideline = p_show;
update();
}
void TextEdit::set_line_length_guideline_column(int p_column) {
- line_length_guideline_col=p_column;
+ line_length_guideline_col = p_column;
update();
}
@@ -4448,12 +4266,12 @@ int TextEdit::get_breakpoint_gutter_width() const {
bool TextEdit::is_text_field() const {
- return true;
+ return true;
}
void TextEdit::menu_option(int p_option) {
- switch( p_option ) {
+ switch (p_option) {
case MENU_CUT: {
if (!readonly) {
cut();
@@ -4478,7 +4296,6 @@ void TextEdit::menu_option(int p_option) {
case MENU_UNDO: {
undo();
} break;
-
};
}
@@ -4488,65 +4305,64 @@ PopupMenu *TextEdit::get_menu() const {
void TextEdit::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("_input_event"), &TextEdit::_input_event);
+ ObjectTypeDB::bind_method(_MD("_scroll_moved"), &TextEdit::_scroll_moved);
+ ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"), &TextEdit::_cursor_changed_emit);
+ ObjectTypeDB::bind_method(_MD("_text_changed_emit"), &TextEdit::_text_changed_emit);
+ ObjectTypeDB::bind_method(_MD("_push_current_op"), &TextEdit::_push_current_op);
+ ObjectTypeDB::bind_method(_MD("_click_selection_held"), &TextEdit::_click_selection_held);
+ ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"), &TextEdit::_toggle_draw_caret);
- ObjectTypeDB::bind_method(_MD("_input_event"),&TextEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&TextEdit::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
- ObjectTypeDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
- ObjectTypeDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
- ObjectTypeDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held);
- ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"),&TextEdit::_toggle_draw_caret);
-
- BIND_CONSTANT( SEARCH_MATCH_CASE );
- BIND_CONSTANT( SEARCH_WHOLE_WORDS );
- BIND_CONSTANT( SEARCH_BACKWARDS );
+ BIND_CONSTANT(SEARCH_MATCH_CASE);
+ BIND_CONSTANT(SEARCH_WHOLE_WORDS);
+ BIND_CONSTANT(SEARCH_BACKWARDS);
/*
ObjectTypeDB::bind_method(_MD("delete_char"),&TextEdit::delete_char);
ObjectTypeDB::bind_method(_MD("delete_line"),&TextEdit::delete_line);
*/
- ObjectTypeDB::bind_method(_MD("set_text","text"),&TextEdit::set_text);
- ObjectTypeDB::bind_method(_MD("insert_text_at_cursor","text"),&TextEdit::insert_text_at_cursor);
+ ObjectTypeDB::bind_method(_MD("set_text", "text"), &TextEdit::set_text);
+ ObjectTypeDB::bind_method(_MD("insert_text_at_cursor", "text"), &TextEdit::insert_text_at_cursor);
- ObjectTypeDB::bind_method(_MD("get_line_count"),&TextEdit::get_line_count);
- ObjectTypeDB::bind_method(_MD("get_text"),&TextEdit::get_text);
- ObjectTypeDB::bind_method(_MD("get_line","line"),&TextEdit::get_line);
+ ObjectTypeDB::bind_method(_MD("get_line_count"), &TextEdit::get_line_count);
+ ObjectTypeDB::bind_method(_MD("get_text"), &TextEdit::get_text);
+ ObjectTypeDB::bind_method(_MD("get_line", "line"), &TextEdit::get_line);
- ObjectTypeDB::bind_method(_MD("cursor_set_column","column","adjust_viewport"),&TextEdit::cursor_set_column,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("cursor_set_line","line","adjust_viewport"),&TextEdit::cursor_set_line,DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("cursor_set_column", "column", "adjust_viewport"), &TextEdit::cursor_set_column, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("cursor_set_line", "line", "adjust_viewport"), &TextEdit::cursor_set_line, DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("cursor_get_column"),&TextEdit::cursor_get_column);
- ObjectTypeDB::bind_method(_MD("cursor_get_line"),&TextEdit::cursor_get_line);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&TextEdit::cursor_set_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_enabled"),&TextEdit::cursor_get_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&TextEdit::cursor_set_blink_speed);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_speed"),&TextEdit::cursor_get_blink_speed);
+ ObjectTypeDB::bind_method(_MD("cursor_get_column"), &TextEdit::cursor_get_column);
+ ObjectTypeDB::bind_method(_MD("cursor_get_line"), &TextEdit::cursor_get_line);
+ ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"), &TextEdit::cursor_set_blink_enabled);
+ ObjectTypeDB::bind_method(_MD("cursor_get_blink_enabled"), &TextEdit::cursor_get_blink_enabled);
+ ObjectTypeDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"), &TextEdit::cursor_set_blink_speed);
+ ObjectTypeDB::bind_method(_MD("cursor_get_blink_speed"), &TextEdit::cursor_get_blink_speed);
ObjectTypeDB::bind_method(_MD("cursor_set_block_mode", "enable"), &TextEdit::cursor_set_block_mode);
ObjectTypeDB::bind_method(_MD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
- ObjectTypeDB::bind_method(_MD("set_readonly","enable"),&TextEdit::set_readonly);
- ObjectTypeDB::bind_method(_MD("set_wrap","enable"),&TextEdit::set_wrap);
- ObjectTypeDB::bind_method(_MD("set_max_chars","amount"),&TextEdit::set_max_chars);
+ ObjectTypeDB::bind_method(_MD("set_readonly", "enable"), &TextEdit::set_readonly);
+ ObjectTypeDB::bind_method(_MD("set_wrap", "enable"), &TextEdit::set_wrap);
+ ObjectTypeDB::bind_method(_MD("set_max_chars", "amount"), &TextEdit::set_max_chars);
- ObjectTypeDB::bind_method(_MD("cut"),&TextEdit::cut);
- ObjectTypeDB::bind_method(_MD("copy"),&TextEdit::copy);
- ObjectTypeDB::bind_method(_MD("paste"),&TextEdit::paste);
- ObjectTypeDB::bind_method(_MD("select_all"),&TextEdit::select_all);
- ObjectTypeDB::bind_method(_MD("select","from_line","from_column","to_line","to_column"),&TextEdit::select);
+ ObjectTypeDB::bind_method(_MD("cut"), &TextEdit::cut);
+ ObjectTypeDB::bind_method(_MD("copy"), &TextEdit::copy);
+ ObjectTypeDB::bind_method(_MD("paste"), &TextEdit::paste);
+ ObjectTypeDB::bind_method(_MD("select_all"), &TextEdit::select_all);
+ ObjectTypeDB::bind_method(_MD("select", "from_line", "from_column", "to_line", "to_column"), &TextEdit::select);
- ObjectTypeDB::bind_method(_MD("is_selection_active"),&TextEdit::is_selection_active);
- ObjectTypeDB::bind_method(_MD("get_selection_from_line"),&TextEdit::get_selection_from_line);
- ObjectTypeDB::bind_method(_MD("get_selection_from_column"),&TextEdit::get_selection_from_column);
- ObjectTypeDB::bind_method(_MD("get_selection_to_line"),&TextEdit::get_selection_to_line);
- ObjectTypeDB::bind_method(_MD("get_selection_to_column"),&TextEdit::get_selection_to_column);
- ObjectTypeDB::bind_method(_MD("get_selection_text"),&TextEdit::get_selection_text);
- ObjectTypeDB::bind_method(_MD("get_word_under_cursor"),&TextEdit::get_word_under_cursor);
- ObjectTypeDB::bind_method(_MD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind);
+ ObjectTypeDB::bind_method(_MD("is_selection_active"), &TextEdit::is_selection_active);
+ ObjectTypeDB::bind_method(_MD("get_selection_from_line"), &TextEdit::get_selection_from_line);
+ ObjectTypeDB::bind_method(_MD("get_selection_from_column"), &TextEdit::get_selection_from_column);
+ ObjectTypeDB::bind_method(_MD("get_selection_to_line"), &TextEdit::get_selection_to_line);
+ ObjectTypeDB::bind_method(_MD("get_selection_to_column"), &TextEdit::get_selection_to_column);
+ ObjectTypeDB::bind_method(_MD("get_selection_text"), &TextEdit::get_selection_text);
+ ObjectTypeDB::bind_method(_MD("get_word_under_cursor"), &TextEdit::get_word_under_cursor);
+ ObjectTypeDB::bind_method(_MD("search", "flags", "from_line", "from_column", "to_line", "to_column"), &TextEdit::_search_bind);
- ObjectTypeDB::bind_method(_MD("undo"),&TextEdit::undo);
- ObjectTypeDB::bind_method(_MD("redo"),&TextEdit::redo);
- ObjectTypeDB::bind_method(_MD("clear_undo_history"),&TextEdit::clear_undo_history);
+ ObjectTypeDB::bind_method(_MD("undo"), &TextEdit::undo);
+ ObjectTypeDB::bind_method(_MD("redo"), &TextEdit::redo);
+ ObjectTypeDB::bind_method(_MD("clear_undo_history"), &TextEdit::clear_undo_history);
ObjectTypeDB::bind_method(_MD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
ObjectTypeDB::bind_method(_MD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
@@ -4554,17 +4370,16 @@ void TextEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences);
ObjectTypeDB::bind_method(_MD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled);
- ObjectTypeDB::bind_method(_MD("set_syntax_coloring","enable"),&TextEdit::set_syntax_coloring);
- ObjectTypeDB::bind_method(_MD("is_syntax_coloring_enabled"),&TextEdit::is_syntax_coloring_enabled);
+ ObjectTypeDB::bind_method(_MD("set_syntax_coloring", "enable"), &TextEdit::set_syntax_coloring);
+ ObjectTypeDB::bind_method(_MD("is_syntax_coloring_enabled"), &TextEdit::is_syntax_coloring_enabled);
-
- ObjectTypeDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color);
- ObjectTypeDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_symbol_color","color"),&TextEdit::set_symbol_color);
- ObjectTypeDB::bind_method(_MD("set_custom_bg_color","color"),&TextEdit::set_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors);
- ObjectTypeDB::bind_method(_MD("menu_option"),&TextEdit::menu_option);
- ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu);
+ ObjectTypeDB::bind_method(_MD("add_keyword_color", "keyword", "color"), &TextEdit::add_keyword_color);
+ ObjectTypeDB::bind_method(_MD("add_color_region", "begin_key", "end_key", "color", "line_only"), &TextEdit::add_color_region, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("set_symbol_color", "color"), &TextEdit::set_symbol_color);
+ ObjectTypeDB::bind_method(_MD("set_custom_bg_color", "color"), &TextEdit::set_custom_bg_color);
+ ObjectTypeDB::bind_method(_MD("clear_colors"), &TextEdit::clear_colors);
+ ObjectTypeDB::bind_method(_MD("menu_option"), &TextEdit::menu_option);
+ ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"), &TextEdit::get_menu);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), _SCS("set_syntax_coloring"), _SCS("is_syntax_coloring_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), _SCS("set_show_line_numbers"), _SCS("is_show_line_numbers_enabled"));
@@ -4572,90 +4387,88 @@ void TextEdit::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/block_caret"), _SCS("cursor_set_block_mode"), _SCS("cursor_is_block_mode"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed", PROPERTY_HINT_RANGE, "0.1,10,0.1"), _SCS("cursor_set_blink_speed"), _SCS("cursor_get_blink_speed"));
ADD_SIGNAL(MethodInfo("cursor_changed"));
ADD_SIGNAL(MethodInfo("text_changed"));
ADD_SIGNAL(MethodInfo("request_completion"));
- ADD_SIGNAL(MethodInfo("breakpoint_toggled", PropertyInfo( Variant::INT, "row")));
-
- BIND_CONSTANT( MENU_CUT );
- BIND_CONSTANT( MENU_COPY );
- BIND_CONSTANT( MENU_PASTE );
- BIND_CONSTANT( MENU_CLEAR );
- BIND_CONSTANT( MENU_SELECT_ALL );
- BIND_CONSTANT( MENU_UNDO );
- BIND_CONSTANT( MENU_MAX );
-
+ ADD_SIGNAL(MethodInfo("breakpoint_toggled", PropertyInfo(Variant::INT, "row")));
+ BIND_CONSTANT(MENU_CUT);
+ BIND_CONSTANT(MENU_COPY);
+ BIND_CONSTANT(MENU_PASTE);
+ BIND_CONSTANT(MENU_CLEAR);
+ BIND_CONSTANT(MENU_SELECT_ALL);
+ BIND_CONSTANT(MENU_UNDO);
+ BIND_CONSTANT(MENU_MAX);
}
-TextEdit::TextEdit() {
+TextEdit::TextEdit() {
- readonly=false;
- setting_row=false;
- draw_tabs=false;
- draw_caret=true;
- max_chars=0;
+ readonly = false;
+ setting_row = false;
+ draw_tabs = false;
+ draw_caret = true;
+ max_chars = 0;
clear();
- wrap=false;
+ wrap = false;
set_focus_mode(FOCUS_ALL);
_update_caches();
- cache.size=Size2(1,1);
- cache.row_height=1;
- cache.line_spacing=1;
- cache.line_number_w=1;
- cache.breakpoint_gutter_width=0;
+ cache.size = Size2(1, 1);
+ cache.row_height = 1;
+ cache.line_spacing = 1;
+ cache.line_number_w = 1;
+ cache.breakpoint_gutter_width = 0;
breakpoint_gutter_width = 0;
- tab_size=4;
+ tab_size = 4;
text.set_tab_size(tab_size);
text.clear();
// text.insert(1,"Mongolia..");
// text.insert(2,"PAIS GENEROSO!!");
text.set_color_regions(&color_regions);
- h_scroll = memnew( HScrollBar );
- v_scroll = memnew( VScrollBar );
+ h_scroll = memnew(HScrollBar);
+ v_scroll = memnew(VScrollBar);
add_child(h_scroll);
add_child(v_scroll);
- updating_scrolls=false;
- selection.active=false;
+ updating_scrolls = false;
+ selection.active = false;
- h_scroll->connect("value_changed", this,"_scroll_moved");
- v_scroll->connect("value_changed", this,"_scroll_moved");
+ h_scroll->connect("value_changed", this, "_scroll_moved");
+ v_scroll->connect("value_changed", this, "_scroll_moved");
- cursor_changed_dirty=false;
- text_changed_dirty=false;
+ cursor_changed_dirty = false;
+ text_changed_dirty = false;
- selection.selecting_mode=Selection::MODE_NONE;
- selection.selecting_line=0;
- selection.selecting_column=0;
- selection.selecting_text=false;
- selection.active=false;
- syntax_coloring=false;
+ selection.selecting_mode = Selection::MODE_NONE;
+ selection.selecting_line = 0;
+ selection.selecting_column = 0;
+ selection.selecting_text = false;
+ selection.active = false;
+ syntax_coloring = false;
- block_caret=false;
- caret_blink_enabled=false;
+ block_caret = false;
+ caret_blink_enabled = false;
caret_blink_timer = memnew(Timer);
add_child(caret_blink_timer);
caret_blink_timer->set_wait_time(0.65);
- caret_blink_timer->connect("timeout", this,"_toggle_draw_caret");
+ caret_blink_timer->connect("timeout", this, "_toggle_draw_caret");
cursor_set_blink_enabled(false);
- custom_bg_color=Color(0,0,0,0);
- idle_detect = memnew( Timer );
+ custom_bg_color = Color(0, 0, 0, 0);
+ idle_detect = memnew(Timer);
add_child(idle_detect);
idle_detect->set_one_shot(true);
- idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3));
- idle_detect->connect("timeout", this,"_push_current_op");
+ idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec", 3));
+ idle_detect->connect("timeout", this, "_push_current_op");
- click_select_held = memnew( Timer );
+ click_select_held = memnew(Timer);
add_child(click_select_held);
click_select_held->set_wait_time(0.05);
- click_select_held->connect("timeout", this,"_click_selection_held");
+ click_select_held->connect("timeout", this, "_click_selection_held");
#if 0
syntax_coloring=true;
@@ -4675,50 +4488,47 @@ TextEdit::TextEdit() {
#endif
- current_op.type=TextOperation::TYPE_NONE;
- undo_enabled=true;
- undo_stack_pos=NULL;
- setting_text=false;
- last_dblclk=0;
- current_op.version=0;
- version=0;
- saved_version=0;
+ current_op.type = TextOperation::TYPE_NONE;
+ undo_enabled = true;
+ undo_stack_pos = NULL;
+ setting_text = false;
+ last_dblclk = 0;
+ current_op.version = 0;
+ version = 0;
+ saved_version = 0;
- completion_enabled=false;
- completion_active=false;
- completion_line_ofs=0;
- tooltip_obj=NULL;
- line_numbers=false;
- line_numbers_zero_padded=false;
- line_length_guideline=false;
- line_length_guideline_col=80;
- draw_breakpoint_gutter=false;
- next_operation_is_complex=false;
- scroll_past_end_of_file_enabled=false;
- auto_brace_completion_enabled=false;
- brace_matching_enabled=false;
- highlight_all_occurrences=false;
- auto_indent=false;
+ completion_enabled = false;
+ completion_active = false;
+ completion_line_ofs = 0;
+ tooltip_obj = NULL;
+ line_numbers = false;
+ line_numbers_zero_padded = false;
+ line_length_guideline = false;
+ line_length_guideline_col = 80;
+ draw_breakpoint_gutter = false;
+ next_operation_is_complex = false;
+ scroll_past_end_of_file_enabled = false;
+ auto_brace_completion_enabled = false;
+ brace_matching_enabled = false;
+ highlight_all_occurrences = false;
+ auto_indent = false;
insert_mode = false;
- window_has_focus=true;
+ window_has_focus = true;
raised_from_completion = false;
- menu = memnew( PopupMenu );
+ menu = memnew(PopupMenu);
add_child(menu);
- menu->add_item(TTR("Cut"),MENU_CUT,KEY_MASK_CMD|KEY_X);
- menu->add_item(TTR("Copy"),MENU_COPY,KEY_MASK_CMD|KEY_C);
- menu->add_item(TTR("Paste"),MENU_PASTE,KEY_MASK_CMD|KEY_V);
+ menu->add_item(TTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X);
+ menu->add_item(TTR("Copy"), MENU_COPY, KEY_MASK_CMD | KEY_C);
+ menu->add_item(TTR("Paste"), MENU_PASTE, KEY_MASK_CMD | KEY_V);
menu->add_separator();
- menu->add_item(TTR("Select All"),MENU_SELECT_ALL,KEY_MASK_CMD|KEY_A);
- menu->add_item(TTR("Clear"),MENU_CLEAR);
+ menu->add_item(TTR("Select All"), MENU_SELECT_ALL, KEY_MASK_CMD | KEY_A);
+ menu->add_item(TTR("Clear"), MENU_CLEAR);
menu->add_separator();
- menu->add_item(TTR("Undo"),MENU_UNDO,KEY_MASK_CMD|KEY_Z);
- menu->connect("item_pressed",this,"menu_option");
-
-
+ menu->add_item(TTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z);
+ menu->connect("item_pressed", this, "menu_option");
}
-TextEdit::~TextEdit()
-{
+TextEdit::~TextEdit() {
}
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index b7ddaddc4..135062344 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -30,19 +30,18 @@
#define TEXT_EDIT_H
#include "scene/gui/control.h"
-#include "scene/gui/scroll_bar.h"
#include "scene/gui/popup_menu.h"
+#include "scene/gui/scroll_bar.h"
#include "scene/main/timer.h"
+class TextEdit : public Control {
-class TextEdit : public Control {
-
- OBJ_TYPE( TextEdit, Control );
+ OBJ_TYPE(TextEdit, Control);
struct Cursor {
int last_fit_x;
- int line,column; ///< cursor
- int x_ofs,line_ofs;
+ int line, column; ///< cursor
+ int x_ofs, line_ofs;
} cursor;
struct Selection {
@@ -55,14 +54,13 @@ class TextEdit : public Control {
};
Mode selecting_mode;
- int selecting_line,selecting_column;
+ int selecting_line, selecting_column;
bool selecting_text;
-
bool active;
- int from_line,from_column;
- int to_line,to_column;
+ int from_line, from_column;
+ int to_line, to_column;
bool shiftclick_left;
@@ -111,7 +109,13 @@ class TextEdit : public Control {
String end_key;
bool line_only;
bool eq;
- ColorRegion(const String& p_begin_key="",const String& p_end_key="",const Color &p_color=Color(),bool p_line_only=false) { begin_key=p_begin_key; end_key=p_end_key; color=p_color; line_only=p_line_only || p_end_key==""; eq=begin_key==end_key; }
+ ColorRegion(const String &p_begin_key = "", const String &p_end_key = "", const Color &p_color = Color(), bool p_line_only = false) {
+ begin_key = p_begin_key;
+ end_key = p_end_key;
+ color = p_color;
+ line_only = p_line_only || p_end_key == "";
+ eq = begin_key == end_key;
+ }
};
class Text {
@@ -122,43 +126,42 @@ class TextEdit : public Control {
bool end;
};
- struct Line {
- int width_cache : 24;
- bool marked : 1;
- bool breakpoint : 1;
- Map<int,ColorRegionInfo> region_info;
- String data;
- };
+ struct Line {
+ int width_cache : 24;
+ bool marked : 1;
+ bool breakpoint : 1;
+ Map<int, ColorRegionInfo> region_info;
+ String data;
+ };
+
private:
- const Vector<ColorRegion> *color_regions;
- mutable Vector<Line> text;
- Ref<Font> font;
- int tab_size;
+ const Vector<ColorRegion> *color_regions;
+ mutable Vector<Line> text;
+ Ref<Font> font;
+ int tab_size;
- void _update_line_cache(int p_line) const;
+ void _update_line_cache(int p_line) const;
public:
-
-
void set_tab_size(int p_tab_size);
- void set_font(const Ref<Font>& p_font);
- void set_color_regions(const Vector<ColorRegion>*p_regions) { color_regions=p_regions; }
+ void set_font(const Ref<Font> &p_font);
+ void set_color_regions(const Vector<ColorRegion> *p_regions) { color_regions = p_regions; }
int get_line_width(int p_line) const;
int get_max_width() const;
- const Map<int,ColorRegionInfo>& get_color_region_info(int p_line);
- void set(int p_line,const String& p_string);
- void set_marked(int p_line,bool p_marked) { text[p_line].marked=p_marked; }
+ const Map<int, ColorRegionInfo> &get_color_region_info(int p_line);
+ void set(int p_line, const String &p_string);
+ void set_marked(int p_line, bool p_marked) { text[p_line].marked = p_marked; }
bool is_marked(int p_line) const { return text[p_line].marked; }
- void set_breakpoint(int p_line,bool p_breakpoint) { text[p_line].breakpoint=p_breakpoint; }
+ void set_breakpoint(int p_line, bool p_breakpoint) { text[p_line].breakpoint = p_breakpoint; }
bool is_breakpoint(int p_line) const { return text[p_line].breakpoint; }
- void insert(int p_at,const String& p_text);
+ void insert(int p_at, const String &p_text);
void remove(int p_at);
int size() const { return text.size(); }
void clear();
void clear_caches();
- _FORCE_INLINE_ const String& operator[](int p_line) const { return text[p_line].data; }
- Text() { tab_size=4; }
- };
+ _FORCE_INLINE_ const String &operator[](int p_line) const { return text[p_line].data; }
+ Text() { tab_size = 4; }
+ };
struct TextOperation {
@@ -169,7 +172,7 @@ class TextEdit : public Control {
};
Type type;
- int from_line,from_column;
+ int from_line, from_column;
int to_line, to_column;
String text;
uint32_t prev_version;
@@ -181,15 +184,14 @@ class TextEdit : public Control {
TextOperation current_op;
List<TextOperation> undo_stack;
- List<TextOperation>::Element *undo_stack_pos;
+ List<TextOperation>::Element *undo_stack_pos;
void _clear_redo();
- void _do_text_op(const TextOperation& p_op, bool p_reverse);
-
+ void _do_text_op(const TextOperation &p_op, bool p_reverse);
//syntax coloring
Color symbol_color;
- HashMap<String,Color> keywords;
+ HashMap<String, Color> keywords;
Color custom_bg_color;
Vector<ColorRegion> color_regions;
@@ -257,7 +259,6 @@ class TextEdit : public Control {
VScrollBar *v_scroll;
bool updating_scrolls;
-
Object *tooltip_obj;
StringName tooltip_func;
Variant tooltip_ud;
@@ -276,8 +277,8 @@ class TextEdit : public Control {
int get_char_count();
- int get_char_pos_for(int p_px,String p_pos) const;
- int get_column_x_offset(int p_column,String p_pos);
+ int get_char_pos_for(int p_px, String p_pos) const;
+ int get_column_x_offset(int p_column, String p_pos);
void adjust_viewport_to_cursor();
void _scroll_moved(double);
@@ -290,7 +291,7 @@ class TextEdit : public Control {
void _scroll_lines_up();
void _scroll_lines_down();
-// void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
+ // void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
Size2 get_minimum_size() const;
int get_row_height() const;
@@ -306,13 +307,13 @@ class TextEdit : public Control {
/* super internal api, undo/redo builds on it */
- void _base_insert_text(int p_line, int p_column,const String& p_text,int &r_end_line,int &r_end_column);
- String _base_get_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column) const;
- void _base_remove_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column);
+ void _base_insert_text(int p_line, int p_column, const String &p_text, int &r_end_line, int &r_end_column);
+ String _base_get_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column) const;
+ void _base_remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
int _get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column);
- DVector<int> _search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const;
+ DVector<int> _search_bind(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column) const;
PopupMenu *menu;
@@ -322,16 +323,15 @@ class TextEdit : public Control {
void _confirm_completion();
void _update_completion_candidates();
- void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
+ void _get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) const;
protected:
+ virtual String get_tooltip(const Point2 &p_pos) const;
- virtual String get_tooltip(const Point2& p_pos) const;
-
- void _insert_text(int p_line, int p_column,const String& p_text,int *r_end_line=NULL,int *r_end_char=NULL);
- void _remove_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column);
- void _insert_text_at_cursor(const String& p_text);
- void _input_event(const InputEvent& p_input);
+ void _insert_text(int p_line, int p_column, const String &p_text, int *r_end_line = NULL, int *r_end_char = NULL);
+ void _remove_text(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
+ void _insert_text_at_cursor(const String &p_text);
+ void _input_event(const InputEvent &p_input);
void _notification(int p_what);
void _consume_pair_symbol(CharType ch);
@@ -339,10 +339,7 @@ protected:
static void _bind_methods();
-
-
public:
-
enum MenuItems {
MENU_CUT,
MENU_COPY,
@@ -356,12 +353,12 @@ public:
enum SearchFlags {
- SEARCH_MATCH_CASE=1,
- SEARCH_WHOLE_WORDS=2,
- SEARCH_BACKWARDS=4
+ SEARCH_MATCH_CASE = 1,
+ SEARCH_WHOLE_WORDS = 2,
+ SEARCH_BACKWARDS = 4
};
- virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
+ virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
//void delete_char();
//void delete_line();
@@ -370,16 +367,16 @@ public:
void end_complex_operation();
void set_text(String p_text);
- void insert_text_at_cursor(const String& p_text);
- void insert_at(const String& p_text, int at);
+ void insert_text_at_cursor(const String &p_text);
+ void insert_at(const String &p_text, int at);
int get_line_count() const;
- void set_line_as_marked(int p_line,bool p_marked);
- void set_line_as_breakpoint(int p_line,bool p_breakpoint);
+ void set_line_as_marked(int p_line, bool p_marked);
+ void set_line_as_breakpoint(int p_line, bool p_breakpoint);
bool is_line_set_as_breakpoint(int p_line) const;
void get_breakpoints(List<int> *p_breakpoints) const;
String get_text();
String get_line(int line) const;
- void set_line(int line, String new_text);
+ void set_line(int line, String new_text);
void backspace_at_cursor();
void indent_selection_left();
@@ -393,7 +390,7 @@ public:
auto_brace_completion_enabled = p_enabled;
}
inline void set_brace_matching(bool p_enabled) {
- brace_matching_enabled=p_enabled;
+ brace_matching_enabled = p_enabled;
update();
}
inline void set_callhint_settings(bool below, Vector2 offset) {
@@ -404,8 +401,8 @@ public:
void center_viewport_to_cursor();
- void cursor_set_column(int p_col, bool p_adjust_viewport=true);
- void cursor_set_line(int p_row, bool p_adjust_viewport=true);
+ void cursor_set_column(int p_col, bool p_adjust_viewport = true);
+ void cursor_set_line(int p_row, bool p_adjust_viewport = true);
int cursor_get_column() const;
int cursor_get_line() const;
@@ -433,10 +430,10 @@ public:
void copy();
void paste();
void select_all();
- void select(int p_from_line,int p_from_column,int p_to_line,int p_to_column);
+ void select(int p_from_line, int p_from_column, int p_to_line, int p_to_column);
void deselect();
- void set_search_text(const String& p_search_text);
+ void set_search_text(const String &p_search_text);
void set_search_flags(uint32_t p_flags);
void set_current_search_result(int line, int col);
@@ -444,14 +441,14 @@ public:
bool is_highlight_all_occurrences_enabled() const;
bool is_selection_active() const;
int get_selection_from_line() const;
- int get_selection_from_column() const;
+ int get_selection_from_column() const;
int get_selection_to_line() const;
int get_selection_to_column() const;
String get_selection_text() const;
String get_word_under_cursor() const;
- bool search(const String &p_key,uint32_t p_search_flags, int p_from_line, int p_from_column,int &r_line,int &r_column) const;
+ bool search(const String &p_key, uint32_t p_search_flags, int p_from_line, int p_from_column, int &r_line, int &r_column) const;
void undo();
void redo();
@@ -464,10 +461,10 @@ public:
void set_insert_mode(bool p_enabled);
bool is_insert_mode() const;
- void add_keyword_color(const String& p_keyword,const Color& p_color);
- void add_color_region(const String& p_begin_key=String(),const String& p_end_key=String(),const Color &p_color=Color(),bool p_line_only=false);
- void set_symbol_color(const Color& p_color);
- void set_custom_bg_color(const Color& p_color);
+ void add_keyword_color(const String &p_keyword, const Color &p_color);
+ void add_color_region(const String &p_begin_key = String(), const String &p_end_key = String(), const Color &p_color = Color(), bool p_line_only = false);
+ void set_symbol_color(const Color &p_color);
+ void set_custom_bg_color(const Color &p_color);
void clear_colors();
int get_v_scroll() const;
@@ -496,21 +493,20 @@ public:
void set_breakpoint_gutter_width(int p_gutter_width);
int get_breakpoint_gutter_width() const;
- void set_tooltip_request_func(Object *p_obj, const StringName& p_function, const Variant& p_udata);
+ void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata);
- void set_completion(bool p_enabled,const Vector<String>& p_prefixes);
+ void set_completion(bool p_enabled, const Vector<String> &p_prefixes);
void code_complete(const Vector<String> &p_strings);
- void set_code_hint(const String& p_hint);
+ void set_code_hint(const String &p_hint);
void query_code_comple();
PopupMenu *get_menu() const;
String get_text_for_completion();
- virtual bool is_text_field() const;
+ virtual bool is_text_field() const;
TextEdit();
~TextEdit();
};
-
#endif // TEXT_EDIT_H
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index 18d3f9072..8ece388c2 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -31,34 +31,34 @@
Size2 TextureButton::get_minimum_size() const {
Size2 size = Control::get_minimum_size();
- if(resize_mode == RESIZE_SCALE) {
+ if (resize_mode == RESIZE_SCALE) {
if (normal.is_null()) {
if (pressed.is_null()) {
if (hover.is_null())
if (click_mask.is_null())
- size=Size2();
+ size = Size2();
else
- size=click_mask->get_size();
+ size = click_mask->get_size();
else
- size=hover->get_size();
+ size = hover->get_size();
} else
- size=pressed->get_size();
+ size = pressed->get_size();
} else
- size=normal->get_size();
- size=size*scale.abs();
+ size = normal->get_size();
+ size = size * scale.abs();
}
return size;
}
-bool TextureButton::has_point(const Point2& p_point) const {
- if ( resize_mode == RESIZE_SCALE && (scale[0] == 0 || scale[1] == 0)) {
+bool TextureButton::has_point(const Point2 &p_point) const {
+ if (resize_mode == RESIZE_SCALE && (scale[0] == 0 || scale[1] == 0)) {
return false;
}
- Point2 ppos = (resize_mode == RESIZE_SCALE) ? (p_point/scale.abs()) : p_point;
+ Point2 ppos = (resize_mode == RESIZE_SCALE) ? (p_point / scale.abs()) : p_point;
if (click_mask.is_valid()) {
Point2i p = ppos;
- if (p.x<0 || p.x>=click_mask->get_size().width || p.y<0 || p.y>=click_mask->get_size().height)
+ if (p.x < 0 || p.x >= click_mask->get_size().width || p.y < 0 || p.y >= click_mask->get_size().height)
return false;
return click_mask->get_bit(p);
@@ -67,10 +67,9 @@ bool TextureButton::has_point(const Point2& p_point) const {
return Control::has_point(p_point);
}
-
void TextureButton::_notification(int p_what) {
- switch( p_what ) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
DrawMode draw_mode = get_draw_mode();
@@ -81,37 +80,37 @@ void TextureButton::_notification(int p_what) {
case DRAW_NORMAL: {
if (normal.is_valid())
- texdraw=normal;
+ texdraw = normal;
} break;
case DRAW_PRESSED: {
if (pressed.is_null()) {
if (hover.is_null()) {
if (normal.is_valid())
- texdraw=normal;
+ texdraw = normal;
} else
- texdraw=hover;
+ texdraw = hover;
} else
- texdraw=pressed;
+ texdraw = pressed;
} break;
case DRAW_HOVER: {
if (hover.is_null()) {
if (pressed.is_valid() && is_pressed())
- texdraw=pressed;
+ texdraw = pressed;
else if (normal.is_valid())
- texdraw=normal;
+ texdraw = normal;
} else
- texdraw=hover;
+ texdraw = hover;
} break;
case DRAW_DISABLED: {
if (disabled.is_null()) {
if (normal.is_valid())
- texdraw=normal;
+ texdraw = normal;
} else
- texdraw=disabled;
+ texdraw = disabled;
} break;
}
@@ -120,7 +119,7 @@ void TextureButton::_notification(int p_what) {
Size2 size = texdraw->get_size();
Rect2 tex_regin = Rect2(Point2(), texdraw->get_size());
bool tile = false;
- if(resize_mode == RESIZE_STRETCH) {
+ if (resize_mode == RESIZE_STRETCH) {
switch (stretch_mode) {
case STRETCH_KEEP:
size = texdraw->get_size();
@@ -134,12 +133,12 @@ void TextureButton::_notification(int p_what) {
tile = true;
break;
case STRETCH_KEEP_CENTERED:
- ofs = (get_size() - texdraw->get_size())/2;
+ ofs = (get_size() - texdraw->get_size()) / 2;
size = texdraw->get_size();
break;
case STRETCH_KEEP_ASPECT_CENTERED:
case STRETCH_KEEP_ASPECT: {
- Size2 _size=get_size();
+ Size2 _size = get_size();
float tex_width = texdraw->get_width() * _size.height / texdraw->get_height();
float tex_height = _size.height;
@@ -148,37 +147,35 @@ void TextureButton::_notification(int p_what) {
tex_height = texdraw->get_height() * tex_width / texdraw->get_width();
}
- if (stretch_mode==STRETCH_KEEP_ASPECT_CENTERED) {
- ofs.x = (_size.width - tex_width)/2;
- ofs.y = (_size.height - tex_height)/2;
+ if (stretch_mode == STRETCH_KEEP_ASPECT_CENTERED) {
+ ofs.x = (_size.width - tex_width) / 2;
+ ofs.y = (_size.height - tex_height) / 2;
}
size.width = tex_width;
size.height = tex_height;
} break;
- case STRETCH_KEEP_ASPECT_COVERED:{
+ case STRETCH_KEEP_ASPECT_COVERED: {
size = get_size();
Size2 tex_size = texdraw->get_size();
- Size2 scaleSize(size.width/tex_size.width, size.height/tex_size.height);
- float scale = scaleSize.width > scaleSize.height? scaleSize.width : scaleSize.height;
+ Size2 scaleSize(size.width / tex_size.width, size.height / tex_size.height);
+ float scale = scaleSize.width > scaleSize.height ? scaleSize.width : scaleSize.height;
Size2 scaledTexSize = tex_size * scale;
Point2 ofs = ((scaledTexSize - size) / scale).abs() / 2.0f;
- tex_regin = Rect2(ofs, size/scale);
+ tex_regin = Rect2(ofs, size / scale);
} break;
}
- }
- else {
- size = texdraw->get_size()*scale;
+ } else {
+ size = texdraw->get_size() * scale;
}
if (tile)
- draw_texture_rect(texdraw,Rect2(ofs,size),tile,modulate);
+ draw_texture_rect(texdraw, Rect2(ofs, size), tile, modulate);
else
draw_texture_rect_region(texdraw, Rect2(ofs, size), tex_regin, modulate);
}
if (has_focus() && focused.is_valid()) {
Rect2 drect(Point2(), get_size());
- draw_texture_rect(focused,drect,false,modulate);
-
+ draw_texture_rect(focused, drect, false, modulate);
};
} break;
}
@@ -186,38 +183,38 @@ void TextureButton::_notification(int p_what) {
void TextureButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_normal_texture","texture:Texture"),&TextureButton::set_normal_texture);
- ObjectTypeDB::bind_method(_MD("set_pressed_texture","texture:Texture"),&TextureButton::set_pressed_texture);
- ObjectTypeDB::bind_method(_MD("set_hover_texture","texture:Texture"),&TextureButton::set_hover_texture);
- ObjectTypeDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture);
- ObjectTypeDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture);
- ObjectTypeDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask);
- ObjectTypeDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale);
- ObjectTypeDB::bind_method(_MD("set_modulate","color"),&TextureButton::set_modulate);
- ObjectTypeDB::bind_method(_MD("set_resize_mode","p_mode"), &TextureButton::set_resize_mode);
- ObjectTypeDB::bind_method(_MD("set_stretch_mode","p_mode"), & TextureButton::set_stretch_mode );
+ ObjectTypeDB::bind_method(_MD("set_normal_texture", "texture:Texture"), &TextureButton::set_normal_texture);
+ ObjectTypeDB::bind_method(_MD("set_pressed_texture", "texture:Texture"), &TextureButton::set_pressed_texture);
+ ObjectTypeDB::bind_method(_MD("set_hover_texture", "texture:Texture"), &TextureButton::set_hover_texture);
+ ObjectTypeDB::bind_method(_MD("set_disabled_texture", "texture:Texture"), &TextureButton::set_disabled_texture);
+ ObjectTypeDB::bind_method(_MD("set_focused_texture", "texture:Texture"), &TextureButton::set_focused_texture);
+ ObjectTypeDB::bind_method(_MD("set_click_mask", "mask:BitMap"), &TextureButton::set_click_mask);
+ ObjectTypeDB::bind_method(_MD("set_texture_scale", "scale"), &TextureButton::set_texture_scale);
+ ObjectTypeDB::bind_method(_MD("set_modulate", "color"), &TextureButton::set_modulate);
+ ObjectTypeDB::bind_method(_MD("set_resize_mode", "p_mode"), &TextureButton::set_resize_mode);
+ ObjectTypeDB::bind_method(_MD("set_stretch_mode", "p_mode"), &TextureButton::set_stretch_mode);
- ObjectTypeDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture);
- ObjectTypeDB::bind_method(_MD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture);
- ObjectTypeDB::bind_method(_MD("get_hover_texture:Texture"),&TextureButton::get_hover_texture);
- ObjectTypeDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture);
- ObjectTypeDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture);
- ObjectTypeDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask);
- ObjectTypeDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate);
- ObjectTypeDB::bind_method(_MD("get_resize_mode"), & TextureButton::get_resize_mode);
+ ObjectTypeDB::bind_method(_MD("get_normal_texture:Texture"), &TextureButton::get_normal_texture);
+ ObjectTypeDB::bind_method(_MD("get_pressed_texture:Texture"), &TextureButton::get_pressed_texture);
+ ObjectTypeDB::bind_method(_MD("get_hover_texture:Texture"), &TextureButton::get_hover_texture);
+ ObjectTypeDB::bind_method(_MD("get_disabled_texture:Texture"), &TextureButton::get_disabled_texture);
+ ObjectTypeDB::bind_method(_MD("get_focused_texture:Texture"), &TextureButton::get_focused_texture);
+ ObjectTypeDB::bind_method(_MD("get_click_mask:BitMap"), &TextureButton::get_click_mask);
+ ObjectTypeDB::bind_method(_MD("get_texture_scale"), &TextureButton::get_texture_scale);
+ ObjectTypeDB::bind_method(_MD("get_modulate"), &TextureButton::get_modulate);
+ ObjectTypeDB::bind_method(_MD("get_resize_mode"), &TextureButton::get_resize_mode);
ObjectTypeDB::bind_method(_MD("get_stretch_mode"), &TextureButton::get_stretch_mode);
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
- ADD_PROPERTY(PropertyInfo(Variant::INT, "params/resize_mode",PROPERTY_HINT_ENUM,"Scale (Compat),Stretch"), _SCS("set_resize_mode"), _SCS("get_resize_mode"));
- ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
- ADD_PROPERTY(PropertyInfo(Variant::INT, "params/stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode"));
- ADD_PROPERTYNO(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "textures/normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "textures/pressed", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "textures/hover", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "textures/disabled", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "textures/focused", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "textures/click_mask", PROPERTY_HINT_RESOURCE_TYPE, "BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "params/resize_mode", PROPERTY_HINT_ENUM, "Scale (Compat),Stretch"), _SCS("set_resize_mode"), _SCS("get_resize_mode"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "params/scale", PROPERTY_HINT_RANGE, "0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "params/stretch_mode", PROPERTY_HINT_ENUM, "Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), _SCS("set_stretch_mode"), _SCS("get_stretch_mode"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "params/modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
BIND_CONSTANT(STRETCH_SCALE_ON_EXPAND);
BIND_CONSTANT(STRETCH_SCALE);
@@ -229,36 +226,31 @@ void TextureButton::_bind_methods() {
BIND_CONSTANT(STRETCH_KEEP_ASPECT_COVERED);
}
+void TextureButton::set_normal_texture(const Ref<Texture> &p_normal) {
-void TextureButton::set_normal_texture(const Ref<Texture>& p_normal) {
-
- normal=p_normal;
+ normal = p_normal;
update();
minimum_size_changed();
-
}
-void TextureButton::set_pressed_texture(const Ref<Texture>& p_pressed) {
+void TextureButton::set_pressed_texture(const Ref<Texture> &p_pressed) {
- pressed=p_pressed;
+ pressed = p_pressed;
update();
-
}
-void TextureButton::set_hover_texture(const Ref<Texture>& p_hover) {
+void TextureButton::set_hover_texture(const Ref<Texture> &p_hover) {
- hover=p_hover;
+ hover = p_hover;
update();
-
}
-void TextureButton::set_disabled_texture(const Ref<Texture>& p_disabled) {
+void TextureButton::set_disabled_texture(const Ref<Texture> &p_disabled) {
- disabled=p_disabled;
+ disabled = p_disabled;
update();
-
}
-void TextureButton::set_click_mask(const Ref<BitMap>& p_click_mask) {
+void TextureButton::set_click_mask(const Ref<BitMap> &p_click_mask) {
- click_mask=p_click_mask;
+ click_mask = p_click_mask;
update();
}
@@ -288,13 +280,13 @@ Ref<Texture> TextureButton::get_focused_texture() const {
return focused;
};
-void TextureButton::set_focused_texture(const Ref<Texture>& p_focused) {
+void TextureButton::set_focused_texture(const Ref<Texture> &p_focused) {
focused = p_focused;
};
-void TextureButton::set_modulate(const Color& p_modulate) {
- modulate=p_modulate;
+void TextureButton::set_modulate(const Color &p_modulate) {
+ modulate = p_modulate;
update();
}
@@ -331,10 +323,9 @@ TextureButton::StretchMode TextureButton::get_stretch_mode() const {
return stretch_mode;
}
-
TextureButton::TextureButton() {
- modulate=Color(1,1,1);
- resize_mode=RESIZE_SCALE;
- scale=Size2(1.0, 1.0);
- stretch_mode=STRETCH_SCALE_ON_EXPAND;
+ modulate = Color(1, 1, 1);
+ resize_mode = RESIZE_SCALE;
+ scale = Size2(1.0, 1.0);
+ stretch_mode = STRETCH_SCALE_ON_EXPAND;
}
diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h
index 84651880a..8a65446e2 100644
--- a/scene/gui/texture_button.h
+++ b/scene/gui/texture_button.h
@@ -34,7 +34,8 @@
class TextureButton : public BaseButton {
- OBJ_TYPE( TextureButton, BaseButton );
+ OBJ_TYPE(TextureButton, BaseButton);
+
public:
enum ResizeMode {
RESIZE_SCALE, // for backwards compatibility
@@ -65,20 +66,18 @@ private:
StretchMode stretch_mode;
protected:
-
- virtual bool has_point(const Point2& p_point) const;
+ virtual bool has_point(const Point2 &p_point) const;
virtual Size2 get_minimum_size() const;
void _notification(int p_what);
static void _bind_methods();
public:
-
- void set_normal_texture(const Ref<Texture>& p_normal);
- void set_pressed_texture(const Ref<Texture>& p_pressed);
- void set_hover_texture(const Ref<Texture>& p_hover);
- void set_disabled_texture(const Ref<Texture>& p_disabled);
- void set_focused_texture(const Ref<Texture>& p_focused);
- void set_click_mask(const Ref<BitMap>& p_image);
+ void set_normal_texture(const Ref<Texture> &p_normal);
+ void set_pressed_texture(const Ref<Texture> &p_pressed);
+ void set_hover_texture(const Ref<Texture> &p_hover);
+ void set_disabled_texture(const Ref<Texture> &p_disabled);
+ void set_focused_texture(const Ref<Texture> &p_focused);
+ void set_click_mask(const Ref<BitMap> &p_image);
Ref<Texture> get_normal_texture() const;
Ref<Texture> get_pressed_texture() const;
@@ -87,7 +86,7 @@ public:
Ref<Texture> get_focused_texture() const;
Ref<BitMap> get_click_mask() const;
- void set_modulate(const Color& p_modulate);
+ void set_modulate(const Color &p_modulate);
Color get_modulate() const;
ResizeMode get_resize_mode() const;
@@ -102,6 +101,6 @@ public:
TextureButton();
};
-VARIANT_ENUM_CAST( TextureButton::ResizeMode );
-VARIANT_ENUM_CAST( TextureButton::StretchMode );
+VARIANT_ENUM_CAST(TextureButton::ResizeMode);
+VARIANT_ENUM_CAST(TextureButton::StretchMode);
#endif // TEXTURE_BUTTON_H
diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_frame.cpp
index 278fff996..86c6cd6a6 100644
--- a/scene/gui/texture_frame.cpp
+++ b/scene/gui/texture_frame.cpp
@@ -31,67 +31,65 @@
void TextureFrame::_notification(int p_what) {
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
if (texture.is_null())
return;
-
- switch(stretch_mode) {
+ switch (stretch_mode) {
case STRETCH_SCALE_ON_EXPAND: {
- Size2 s=expand?get_size():texture->get_size();
- draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+ Size2 s = expand ? get_size() : texture->get_size();
+ draw_texture_rect(texture, Rect2(Point2(), s), false, modulate);
} break;
case STRETCH_SCALE: {
- draw_texture_rect(texture,Rect2(Point2(),get_size()),false,modulate);
+ draw_texture_rect(texture, Rect2(Point2(), get_size()), false, modulate);
} break;
case STRETCH_TILE: {
- draw_texture_rect(texture,Rect2(Point2(),get_size()),true,modulate);
+ draw_texture_rect(texture, Rect2(Point2(), get_size()), true, modulate);
} break;
case STRETCH_KEEP: {
- draw_texture_rect(texture,Rect2(Point2(),texture->get_size()),false,modulate);
+ draw_texture_rect(texture, Rect2(Point2(), texture->get_size()), false, modulate);
} break;
case STRETCH_KEEP_CENTERED: {
- Vector2 ofs = (get_size() - texture->get_size())/2;
- draw_texture_rect(texture,Rect2(ofs,texture->get_size()),false,modulate);
+ Vector2 ofs = (get_size() - texture->get_size()) / 2;
+ draw_texture_rect(texture, Rect2(ofs, texture->get_size()), false, modulate);
} break;
case STRETCH_KEEP_ASPECT_CENTERED:
case STRETCH_KEEP_ASPECT: {
- Size2 size=get_size();
- int tex_width = texture->get_width() * size.height / texture ->get_height();
+ Size2 size = get_size();
+ int tex_width = texture->get_width() * size.height / texture->get_height();
int tex_height = size.height;
- if (tex_width>size.width) {
- tex_width=size.width;
- tex_height=texture->get_height() * tex_width / texture->get_width();
+ if (tex_width > size.width) {
+ tex_width = size.width;
+ tex_height = texture->get_height() * tex_width / texture->get_width();
}
int ofs_x = 0;
int ofs_y = 0;
- if (stretch_mode==STRETCH_KEEP_ASPECT_CENTERED) {
- ofs_x+=(size.width - tex_width)/2;
- ofs_y+=(size.height - tex_height)/2;
+ if (stretch_mode == STRETCH_KEEP_ASPECT_CENTERED) {
+ ofs_x += (size.width - tex_width) / 2;
+ ofs_y += (size.height - tex_height) / 2;
}
- draw_texture_rect(texture,Rect2(ofs_x,ofs_y,tex_width,tex_height),false,modulate);
+ draw_texture_rect(texture, Rect2(ofs_x, ofs_y, tex_width, tex_height), false, modulate);
} break;
case STRETCH_KEEP_ASPECT_COVERED: {
Size2 size = get_size();
Size2 tex_size = texture->get_size();
- Size2 scaleSize(size.width/tex_size.width, size.height/tex_size.height);
- float scale = scaleSize.width > scaleSize.height? scaleSize.width : scaleSize.height;
+ Size2 scaleSize(size.width / tex_size.width, size.height / tex_size.height);
+ float scale = scaleSize.width > scaleSize.height ? scaleSize.width : scaleSize.height;
Size2 scaledTexSize = tex_size * scale;
Point2 ofs = ((scaledTexSize - size) / scale).abs() / 2.0f;
- draw_texture_rect_region(texture, Rect2(Point2(), size), Rect2(ofs, size/scale), modulate);
+ draw_texture_rect_region(texture, Rect2(Point2(), size), Rect2(ofs, size / scale), modulate);
} break;
}
-
}
}
@@ -104,35 +102,33 @@ Size2 TextureFrame::get_minimum_size() const {
}
void TextureFrame::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_texture", "texture"), &TextureFrame::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture"), &TextureFrame::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_modulate", "modulate"), &TextureFrame::set_modulate);
+ ObjectTypeDB::bind_method(_MD("get_modulate"), &TextureFrame::get_modulate);
+ ObjectTypeDB::bind_method(_MD("set_expand", "enable"), &TextureFrame::set_expand);
+ ObjectTypeDB::bind_method(_MD("has_expand"), &TextureFrame::has_expand);
+ ObjectTypeDB::bind_method(_MD("set_stretch_mode", "stretch_mode"), &TextureFrame::set_stretch_mode);
+ ObjectTypeDB::bind_method(_MD("get_stretch_mode"), &TextureFrame::get_stretch_mode);
- ObjectTypeDB::bind_method(_MD("set_texture","texture"), & TextureFrame::set_texture );
- ObjectTypeDB::bind_method(_MD("get_texture"), & TextureFrame::get_texture );
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"), & TextureFrame::set_modulate );
- ObjectTypeDB::bind_method(_MD("get_modulate"), & TextureFrame::get_modulate );
- ObjectTypeDB::bind_method(_MD("set_expand","enable"), & TextureFrame::set_expand );
- ObjectTypeDB::bind_method(_MD("has_expand"), & TextureFrame::has_expand );
- ObjectTypeDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureFrame::set_stretch_mode );
- ObjectTypeDB::bind_method(_MD("get_stretch_mode"), & TextureFrame::get_stretch_mode );
-
- ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
- ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::COLOR, "modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "expand"), _SCS("set_expand"), _SCS("has_expand"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), _SCS("set_stretch_mode"), _SCS("get_stretch_mode"));
- BIND_CONSTANT( STRETCH_SCALE_ON_EXPAND );
- BIND_CONSTANT( STRETCH_SCALE );
- BIND_CONSTANT( STRETCH_TILE );
- BIND_CONSTANT( STRETCH_KEEP );
- BIND_CONSTANT( STRETCH_KEEP_CENTERED );
- BIND_CONSTANT( STRETCH_KEEP_ASPECT );
- BIND_CONSTANT( STRETCH_KEEP_ASPECT_CENTERED );
- BIND_CONSTANT( STRETCH_KEEP_ASPECT_COVERED );
+ BIND_CONSTANT(STRETCH_SCALE_ON_EXPAND);
+ BIND_CONSTANT(STRETCH_SCALE);
+ BIND_CONSTANT(STRETCH_TILE);
+ BIND_CONSTANT(STRETCH_KEEP);
+ BIND_CONSTANT(STRETCH_KEEP_CENTERED);
+ BIND_CONSTANT(STRETCH_KEEP_ASPECT);
+ BIND_CONSTANT(STRETCH_KEEP_ASPECT_CENTERED);
+ BIND_CONSTANT(STRETCH_KEEP_ASPECT_COVERED);
}
+void TextureFrame::set_texture(const Ref<Texture> &p_tex) {
-void TextureFrame::set_texture(const Ref<Texture>& p_tex) {
-
- texture=p_tex;
+ texture = p_tex;
update();
//if (texture.is_valid())
// texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
@@ -144,21 +140,20 @@ Ref<Texture> TextureFrame::get_texture() const {
return texture;
}
-void TextureFrame::set_modulate(const Color& p_tex) {
+void TextureFrame::set_modulate(const Color &p_tex) {
- modulate=p_tex;
+ modulate = p_tex;
update();
}
-Color TextureFrame::get_modulate() const{
+Color TextureFrame::get_modulate() const {
return modulate;
}
-
void TextureFrame::set_expand(bool p_expand) {
- expand=p_expand;
+ expand = p_expand;
update();
minimum_size_changed();
}
@@ -169,7 +164,7 @@ bool TextureFrame::has_expand() const {
void TextureFrame::set_stretch_mode(StretchMode p_mode) {
- stretch_mode=p_mode;
+ stretch_mode = p_mode;
update();
}
@@ -180,14 +175,11 @@ TextureFrame::StretchMode TextureFrame::get_stretch_mode() const {
TextureFrame::TextureFrame() {
-
- expand=false;
- modulate=Color(1,1,1,1);
+ expand = false;
+ modulate = Color(1, 1, 1, 1);
set_ignore_mouse(true);
- stretch_mode=STRETCH_SCALE_ON_EXPAND;
+ stretch_mode = STRETCH_SCALE_ON_EXPAND;
}
-
-TextureFrame::~TextureFrame()
-{
+TextureFrame::~TextureFrame() {
}
diff --git a/scene/gui/texture_frame.h b/scene/gui/texture_frame.h
index b3385612c..91ede0f16 100644
--- a/scene/gui/texture_frame.h
+++ b/scene/gui/texture_frame.h
@@ -35,7 +35,8 @@
*/
class TextureFrame : public Control {
- OBJ_TYPE(TextureFrame,Control);
+ OBJ_TYPE(TextureFrame, Control);
+
public:
enum StretchMode {
STRETCH_SCALE_ON_EXPAND, //default, for backwards compatibility
@@ -47,23 +48,23 @@ public:
STRETCH_KEEP_ASPECT_CENTERED,
STRETCH_KEEP_ASPECT_COVERED,
};
+
private:
bool expand;
Color modulate;
Ref<Texture> texture;
StretchMode stretch_mode;
-protected:
+protected:
void _notification(int p_what);
virtual Size2 get_minimum_size() const;
static void _bind_methods();
public:
-
- void set_texture(const Ref<Texture>& p_tex);
+ void set_texture(const Ref<Texture> &p_tex);
Ref<Texture> get_texture() const;
- void set_modulate(const Color& p_tex);
+ void set_modulate(const Color &p_tex);
Color get_modulate() const;
void set_expand(bool p_expand);
@@ -74,8 +75,7 @@ public:
TextureFrame();
~TextureFrame();
-
};
-VARIANT_ENUM_CAST( TextureFrame::StretchMode );
+VARIANT_ENUM_CAST(TextureFrame::StretchMode);
#endif // TEXTURE_FRAME_H
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index ba9fec03d..f39c88d0d 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -28,31 +28,28 @@
/*************************************************************************/
#include "texture_progress.h"
+void TextureProgress::set_under_texture(const Ref<Texture> &p_texture) {
-void TextureProgress::set_under_texture(const Ref<Texture>& p_texture) {
-
- under=p_texture;
+ under = p_texture;
update();
minimum_size_changed();
}
-Ref<Texture> TextureProgress::get_under_texture() const{
+Ref<Texture> TextureProgress::get_under_texture() const {
return under;
-
}
-void TextureProgress::set_over_texture(const Ref<Texture>& p_texture) {
+void TextureProgress::set_over_texture(const Ref<Texture> &p_texture) {
- over=p_texture;
+ over = p_texture;
update();
minimum_size_changed();
}
-Ref<Texture> TextureProgress::get_over_texture() const{
+Ref<Texture> TextureProgress::get_over_texture() const {
return over;
-
}
Size2 TextureProgress::get_minimum_size() const {
@@ -64,240 +61,224 @@ Size2 TextureProgress::get_minimum_size() const {
else if (progress.is_valid())
return progress->get_size();
- return Size2(1,1);
+ return Size2(1, 1);
}
-void TextureProgress::set_progress_texture(const Ref<Texture>& p_texture) {
+void TextureProgress::set_progress_texture(const Ref<Texture> &p_texture) {
- progress=p_texture;
+ progress = p_texture;
update();
minimum_size_changed();
}
-Ref<Texture> TextureProgress::get_progress_texture() const{
+Ref<Texture> TextureProgress::get_progress_texture() const {
return progress;
-
}
Point2 TextureProgress::unit_val_to_uv(float val) {
if (progress.is_null())
return Point2();
- if (val<0)
- val+=1;
- if (val>1)
- val-=1;
+ if (val < 0)
+ val += 1;
+ if (val > 1)
+ val -= 1;
- Point2 p=get_relative_center();
+ Point2 p = get_relative_center();
- if (val<0.125)
- return Point2(p.x+(1-p.x)*val*8,0);
- if (val<0.25)
- return Point2(1,p.y*(val-0.125)*8);
- if (val<0.375)
- return Point2(1,p.y+(1-p.y)*(val-0.25)*8);
- if (val<0.5)
- return Point2(1-(1-p.x)*(val-0.375)*8,1);
- if (val<0.625)
- return Point2(p.x*(1-(val-0.5)*8),1);
- if (val<0.75)
- return Point2(0,1-((1-p.y)*(val-0.625)*8));
- if (val<0.875)
- return Point2(0,p.y-p.y*(val-0.75)*8);
+ if (val < 0.125)
+ return Point2(p.x + (1 - p.x) * val * 8, 0);
+ if (val < 0.25)
+ return Point2(1, p.y * (val - 0.125) * 8);
+ if (val < 0.375)
+ return Point2(1, p.y + (1 - p.y) * (val - 0.25) * 8);
+ if (val < 0.5)
+ return Point2(1 - (1 - p.x) * (val - 0.375) * 8, 1);
+ if (val < 0.625)
+ return Point2(p.x * (1 - (val - 0.5) * 8), 1);
+ if (val < 0.75)
+ return Point2(0, 1 - ((1 - p.y) * (val - 0.625) * 8));
+ if (val < 0.875)
+ return Point2(0, p.y - p.y * (val - 0.75) * 8);
else
- return Point2(p.x*(val-0.875)*8,0);
+ return Point2(p.x * (val - 0.875) * 8, 0);
}
-Point2 TextureProgress::get_relative_center()
-{
+Point2 TextureProgress::get_relative_center() {
if (progress.is_null())
return Point2();
- Point2 p = progress->get_size()/2;
- p+=rad_center_off;
- p.x/=progress->get_width();
- p.y/=progress->get_height();
- p.x=CLAMP(p.x,0,1);
- p.y=CLAMP(p.y,0,1);
+ Point2 p = progress->get_size() / 2;
+ p += rad_center_off;
+ p.x /= progress->get_width();
+ p.y /= progress->get_height();
+ p.x = CLAMP(p.x, 0, 1);
+ p.y = CLAMP(p.y, 0, 1);
return p;
}
-void TextureProgress::_notification(int p_what){
- const float corners[12]={-0.125,-0.375,-0.625,-0.875,0.125,0.375,0.625,0.875,1.125,1.375,1.625,1.875};
- switch(p_what) {
+void TextureProgress::_notification(int p_what) {
+ const float corners[12] = { -0.125, -0.375, -0.625, -0.875, 0.125, 0.375, 0.625, 0.875, 1.125, 1.375, 1.625, 1.875 };
+ switch (p_what) {
case NOTIFICATION_DRAW: {
-
if (under.is_valid())
- draw_texture(under,Point2());
+ draw_texture(under, Point2());
if (progress.is_valid()) {
Size2 s = progress->get_size();
switch (mode) {
- case FILL_LEFT_TO_RIGHT: {
- Rect2 region=Rect2(Point2(),Size2(s.x*get_unit_value(),s.y));
- draw_texture_rect_region(progress,region,region);
- } break;
- case FILL_RIGHT_TO_LEFT: {
- Rect2 region=Rect2(Point2(s.x-s.x*get_unit_value(),0),Size2(s.x*get_unit_value(),s.y));
- draw_texture_rect_region(progress,region,region);
- } break;
- case FILL_TOP_TO_BOTTOM: {
- Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_unit_value()));
- draw_texture_rect_region(progress,region,region);
- } break;
- case FILL_BOTTOM_TO_TOP: {
- Rect2 region=Rect2(Point2(0,s.y-s.y*get_unit_value()),Size2(s.x,s.y*get_unit_value()));
- draw_texture_rect_region(progress,region,region);
- } break;
- case FILL_CLOCKWISE:
- case FILL_COUNTER_CLOCKWISE: {
- float val=get_unit_value()*rad_max_degrees/360;
- if (val==1) {
- Rect2 region=Rect2(Point2(),s);
- draw_texture_rect_region(progress,region,region);
- } else if (val!=0) {
- Array pts;
- float direction=mode==FILL_CLOCKWISE?1:-1;
- float start=rad_init_angle/360;
- float end=start+direction*val;
- pts.append(start);
- pts.append(end);
- float from=MIN(start,end);
- float to=MAX(start,end);
- for (int i=0;i<12;i++)
- if (corners[i]>from&&corners[i]<to)
- pts.append(corners[i]);
- pts.sort();
- Vector<Point2> uvs;
- Vector<Point2> points;
- uvs.push_back(get_relative_center());
- points.push_back(Point2(s.x*get_relative_center().x,s.y*get_relative_center().y));
- for (int i=0;i<pts.size();i++) {
- Point2 uv=unit_val_to_uv(pts[i]);
- if (uvs.find(uv)>=0)
- continue;
- uvs.push_back(uv);
- points.push_back(Point2(uv.x*s.x,uv.y*s.y));
+ case FILL_LEFT_TO_RIGHT: {
+ Rect2 region = Rect2(Point2(), Size2(s.x * get_unit_value(), s.y));
+ draw_texture_rect_region(progress, region, region);
+ } break;
+ case FILL_RIGHT_TO_LEFT: {
+ Rect2 region = Rect2(Point2(s.x - s.x * get_unit_value(), 0), Size2(s.x * get_unit_value(), s.y));
+ draw_texture_rect_region(progress, region, region);
+ } break;
+ case FILL_TOP_TO_BOTTOM: {
+ Rect2 region = Rect2(Point2(), Size2(s.x, s.y * get_unit_value()));
+ draw_texture_rect_region(progress, region, region);
+ } break;
+ case FILL_BOTTOM_TO_TOP: {
+ Rect2 region = Rect2(Point2(0, s.y - s.y * get_unit_value()), Size2(s.x, s.y * get_unit_value()));
+ draw_texture_rect_region(progress, region, region);
+ } break;
+ case FILL_CLOCKWISE:
+ case FILL_COUNTER_CLOCKWISE: {
+ float val = get_unit_value() * rad_max_degrees / 360;
+ if (val == 1) {
+ Rect2 region = Rect2(Point2(), s);
+ draw_texture_rect_region(progress, region, region);
+ } else if (val != 0) {
+ Array pts;
+ float direction = mode == FILL_CLOCKWISE ? 1 : -1;
+ float start = rad_init_angle / 360;
+ float end = start + direction * val;
+ pts.append(start);
+ pts.append(end);
+ float from = MIN(start, end);
+ float to = MAX(start, end);
+ for (int i = 0; i < 12; i++)
+ if (corners[i] > from && corners[i] < to)
+ pts.append(corners[i]);
+ pts.sort();
+ Vector<Point2> uvs;
+ Vector<Point2> points;
+ uvs.push_back(get_relative_center());
+ points.push_back(Point2(s.x * get_relative_center().x, s.y * get_relative_center().y));
+ for (int i = 0; i < pts.size(); i++) {
+ Point2 uv = unit_val_to_uv(pts[i]);
+ if (uvs.find(uv) >= 0)
+ continue;
+ uvs.push_back(uv);
+ points.push_back(Point2(uv.x * s.x, uv.y * s.y));
+ }
+ draw_polygon(points, Vector<Color>(), uvs, progress);
}
- draw_polygon(points,Vector<Color>(),uvs,progress);
- }
- if (get_tree()->is_editor_hint()) {
- Point2 p=progress->get_size();
- p.x*=get_relative_center().x;
- p.y*=get_relative_center().y;
- p=p.floor();
- draw_line(p-Point2(8,0),p+Point2(8,0),Color(0.9,0.5,0.5),2);
- draw_line(p-Point2(0,8),p+Point2(0,8),Color(0.9,0.5,0.5),2);
- }
- } break;
- default:
- draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)),Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)));
+ if (get_tree()->is_editor_hint()) {
+ Point2 p = progress->get_size();
+ p.x *= get_relative_center().x;
+ p.y *= get_relative_center().y;
+ p = p.floor();
+ draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2);
+ draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2);
+ }
+ } break;
+ default:
+ draw_texture_rect_region(progress, Rect2(Point2(), Size2(s.x * get_unit_value(), s.y)), Rect2(Point2(), Size2(s.x * get_unit_value(), s.y)));
}
-
-
}
if (over.is_valid())
- draw_texture(over,Point2());
+ draw_texture(over, Point2());
} break;
}
}
-void TextureProgress::set_fill_mode(int p_fill)
-{
- ERR_FAIL_INDEX(p_fill,6);
- mode=(FillMode)p_fill;
+void TextureProgress::set_fill_mode(int p_fill) {
+ ERR_FAIL_INDEX(p_fill, 6);
+ mode = (FillMode)p_fill;
update();
}
-int TextureProgress::get_fill_mode()
-{
+int TextureProgress::get_fill_mode() {
return mode;
}
-void TextureProgress::set_radial_initial_angle(float p_angle)
-{
- while(p_angle>360)
- p_angle-=360;
- while (p_angle<0)
- p_angle+=360;
- rad_init_angle=p_angle;
+void TextureProgress::set_radial_initial_angle(float p_angle) {
+ while (p_angle > 360)
+ p_angle -= 360;
+ while (p_angle < 0)
+ p_angle += 360;
+ rad_init_angle = p_angle;
update();
}
-float TextureProgress::get_radial_initial_angle()
-{
+float TextureProgress::get_radial_initial_angle() {
return rad_init_angle;
}
-void TextureProgress::set_fill_degrees(float p_angle)
-{
- rad_max_degrees=CLAMP(p_angle,0,360);
+void TextureProgress::set_fill_degrees(float p_angle) {
+ rad_max_degrees = CLAMP(p_angle, 0, 360);
update();
}
-float TextureProgress::get_fill_degrees()
-{
+float TextureProgress::get_fill_degrees() {
return rad_max_degrees;
}
-void TextureProgress::set_radial_center_offset(const Point2 &p_off)
-{
- rad_center_off=p_off;
+void TextureProgress::set_radial_center_offset(const Point2 &p_off) {
+ rad_center_off = p_off;
update();
}
-Point2 TextureProgress::get_radial_center_offset()
-{
+Point2 TextureProgress::get_radial_center_offset() {
return rad_center_off;
}
void TextureProgress::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_under_texture","tex"),&TextureProgress::set_under_texture);
- ObjectTypeDB::bind_method(_MD("get_under_texture"),&TextureProgress::get_under_texture);
+ ObjectTypeDB::bind_method(_MD("set_under_texture", "tex"), &TextureProgress::set_under_texture);
+ ObjectTypeDB::bind_method(_MD("get_under_texture"), &TextureProgress::get_under_texture);
- ObjectTypeDB::bind_method(_MD("set_progress_texture","tex"),&TextureProgress::set_progress_texture);
- ObjectTypeDB::bind_method(_MD("get_progress_texture"),&TextureProgress::get_progress_texture);
+ ObjectTypeDB::bind_method(_MD("set_progress_texture", "tex"), &TextureProgress::set_progress_texture);
+ ObjectTypeDB::bind_method(_MD("get_progress_texture"), &TextureProgress::get_progress_texture);
- ObjectTypeDB::bind_method(_MD("set_over_texture","tex"),&TextureProgress::set_over_texture);
- ObjectTypeDB::bind_method(_MD("get_over_texture"),&TextureProgress::get_over_texture);
+ ObjectTypeDB::bind_method(_MD("set_over_texture", "tex"), &TextureProgress::set_over_texture);
+ ObjectTypeDB::bind_method(_MD("get_over_texture"), &TextureProgress::get_over_texture);
- ObjectTypeDB::bind_method(_MD("set_fill_mode","mode"),&TextureProgress::set_fill_mode);
+ ObjectTypeDB::bind_method(_MD("set_fill_mode", "mode"), &TextureProgress::set_fill_mode);
ObjectTypeDB::bind_method(_MD("get_fill_mode"), &TextureProgress::get_fill_mode);
- ObjectTypeDB::bind_method(_MD("set_radial_initial_angle","mode"),&TextureProgress::set_radial_initial_angle);
+ ObjectTypeDB::bind_method(_MD("set_radial_initial_angle", "mode"), &TextureProgress::set_radial_initial_angle);
ObjectTypeDB::bind_method(_MD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
- ObjectTypeDB::bind_method(_MD("set_radial_center_offset","mode"),&TextureProgress::set_radial_center_offset);
+ ObjectTypeDB::bind_method(_MD("set_radial_center_offset", "mode"), &TextureProgress::set_radial_center_offset);
ObjectTypeDB::bind_method(_MD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
- ObjectTypeDB::bind_method(_MD("set_fill_degrees","mode"),&TextureProgress::set_fill_degrees);
+ ObjectTypeDB::bind_method(_MD("set_fill_degrees", "mode"), &TextureProgress::set_fill_degrees);
ObjectTypeDB::bind_method(_MD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/under",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_under_texture"),_SCS("get_under_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/over",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_over_texture"),_SCS("get_over_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/progress",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_progress_texture"),_SCS("get_progress_texture"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise"),_SCS("set_fill_mode"),_SCS("get_fill_mode"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill/initial_angle",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_radial_initial_angle"),_SCS("get_radial_initial_angle"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill/fill_degrees",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_fill_degrees"),_SCS("get_fill_degrees"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"radial_fill/center_offset"),_SCS("set_radial_center_offset"),_SCS("get_radial_center_offset"));
-
- BIND_CONSTANT( FILL_LEFT_TO_RIGHT );
- BIND_CONSTANT( FILL_RIGHT_TO_LEFT );
- BIND_CONSTANT( FILL_TOP_TO_BOTTOM );
- BIND_CONSTANT( FILL_BOTTOM_TO_TOP );
- BIND_CONSTANT( FILL_CLOCKWISE );
- BIND_CONSTANT( FILL_COUNTER_CLOCKWISE );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture/under", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_under_texture"), _SCS("get_under_texture"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture/over", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_over_texture"), _SCS("get_over_texture"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture/progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_progress_texture"), _SCS("get_progress_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise"), _SCS("set_fill_mode"), _SCS("get_fill_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_fill/initial_angle", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), _SCS("set_radial_initial_angle"), _SCS("get_radial_initial_angle"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "radial_fill/fill_degrees", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider"), _SCS("set_fill_degrees"), _SCS("get_fill_degrees"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "radial_fill/center_offset"), _SCS("set_radial_center_offset"), _SCS("get_radial_center_offset"));
+ BIND_CONSTANT(FILL_LEFT_TO_RIGHT);
+ BIND_CONSTANT(FILL_RIGHT_TO_LEFT);
+ BIND_CONSTANT(FILL_TOP_TO_BOTTOM);
+ BIND_CONSTANT(FILL_BOTTOM_TO_TOP);
+ BIND_CONSTANT(FILL_CLOCKWISE);
+ BIND_CONSTANT(FILL_COUNTER_CLOCKWISE);
}
-
-TextureProgress::TextureProgress()
-{
- mode=FILL_LEFT_TO_RIGHT;
- rad_init_angle=0;
- rad_center_off=Point2();
- rad_max_degrees=360;
+TextureProgress::TextureProgress() {
+ mode = FILL_LEFT_TO_RIGHT;
+ rad_init_angle = 0;
+ rad_center_off = Point2();
+ rad_max_degrees = 360;
}
diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h
index 17faa606f..3819e1590 100644
--- a/scene/gui/texture_progress.h
+++ b/scene/gui/texture_progress.h
@@ -33,20 +33,19 @@
class TextureProgress : public Range {
- OBJ_TYPE( TextureProgress, Range );
+ OBJ_TYPE(TextureProgress, Range);
Ref<Texture> under;
Ref<Texture> progress;
Ref<Texture> over;
protected:
-
static void _bind_methods();
void _notification(int p_what);
-public:
+public:
enum FillMode {
- FILL_LEFT_TO_RIGHT=0,
+ FILL_LEFT_TO_RIGHT = 0,
FILL_RIGHT_TO_LEFT,
FILL_TOP_TO_BOTTOM,
FILL_BOTTOM_TO_TOP,
@@ -66,13 +65,13 @@ public:
void set_radial_center_offset(const Point2 &p_off);
Point2 get_radial_center_offset();
- void set_under_texture(const Ref<Texture>& p_texture);
+ void set_under_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_under_texture() const;
- void set_progress_texture(const Ref<Texture>& p_texture);
+ void set_progress_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_progress_texture() const;
- void set_over_texture(const Ref<Texture>& p_texture);
+ void set_over_texture(const Ref<Texture> &p_texture);
Ref<Texture> get_over_texture() const;
Size2 get_minimum_size() const;
@@ -80,7 +79,6 @@ public:
TextureProgress();
private:
-
FillMode mode;
float rad_init_angle;
float rad_max_degrees;
diff --git a/scene/gui/tool_button.h b/scene/gui/tool_button.h
index bce4657e8..f005f99eb 100644
--- a/scene/gui/tool_button.h
+++ b/scene/gui/tool_button.h
@@ -32,7 +32,8 @@
#include "scene/gui/button.h"
class ToolButton : public Button {
- OBJ_TYPE(ToolButton,Button);
+ OBJ_TYPE(ToolButton, Button);
+
public:
ToolButton();
};
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 8159797f7..902cf86b1 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -27,23 +27,21 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "tree.h"
-#include "print_string.h"
-#include "os/os.h"
-#include "os/keyboard.h"
#include "globals.h"
#include "os/input.h"
+#include "os/keyboard.h"
+#include "os/os.h"
+#include "print_string.h"
#include "scene/main/viewport.h"
-
-
void TreeItem::move_to_top() {
- if (!parent || parent->childs==this)
+ if (!parent || parent->childs == this)
return; //already on top
TreeItem *prev = get_prev();
- prev->next=next;
- next=parent->childs;
- parent->childs=this;
+ prev->next = next;
+ next = parent->childs;
+ parent->childs = this;
}
void TreeItem::move_to_bottom() {
@@ -51,261 +49,241 @@ void TreeItem::move_to_bottom() {
if (!parent || !next)
return;
- while(next) {
+ while (next) {
- if (parent->childs==this)
- parent->childs=next;
- TreeItem *n=next;
- next=n->next;
- n->next=this;
+ if (parent->childs == this)
+ parent->childs = next;
+ TreeItem *n = next;
+ next = n->next;
+ n->next = this;
}
}
-
Size2 TreeItem::Cell::get_icon_size() const {
if (icon.is_null())
return Size2();
- if (icon_region==Rect2i())
+ if (icon_region == Rect2i())
return icon->get_size();
else
return icon_region.size;
}
-void TreeItem::Cell::draw_icon(const RID& p_where, const Point2& p_pos, const Size2& p_size) const{
+void TreeItem::Cell::draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size) const {
if (icon.is_null())
return;
- Size2i dsize=(p_size==Size2()) ? icon->get_size() : p_size;
+ Size2i dsize = (p_size == Size2()) ? icon->get_size() : p_size;
- if (icon_region==Rect2i()) {
+ if (icon_region == Rect2i()) {
- icon->draw_rect_region(p_where,Rect2(p_pos,dsize),Rect2(Point2(),icon->get_size()));
+ icon->draw_rect_region(p_where, Rect2(p_pos, dsize), Rect2(Point2(), icon->get_size()));
} else {
- icon->draw_rect_region(p_where,Rect2(p_pos,dsize),icon_region);
+ icon->draw_rect_region(p_where, Rect2(p_pos, dsize), icon_region);
}
-
}
-
void TreeItem::_changed_notify(int p_cell) {
- tree->item_changed(p_cell,this);
+ tree->item_changed(p_cell, this);
}
void TreeItem::_changed_notify() {
- tree->item_changed(-1,this);
+ tree->item_changed(-1, this);
}
void TreeItem::_cell_selected(int p_cell) {
- tree->item_selected(p_cell,this);
+ tree->item_selected(p_cell, this);
}
void TreeItem::_cell_deselected(int p_cell) {
- tree->item_deselected(p_cell,this);
+ tree->item_deselected(p_cell, this);
}
/* cell mode */
-void TreeItem::set_cell_mode( int p_column, TreeCellMode p_mode ) {
+void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- Cell&c=cells[p_column];
- c.mode=p_mode;
- c.min=0;
- c.max=100;
- c.step=1;
- c.val=0;
- c.checked=false;
- c.icon=Ref<Texture>();
- c.text="";
- c.icon_max_w=0;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ Cell &c = cells[p_column];
+ c.mode = p_mode;
+ c.min = 0;
+ c.max = 100;
+ c.step = 1;
+ c.val = 0;
+ c.checked = false;
+ c.icon = Ref<Texture>();
+ c.text = "";
+ c.icon_max_w = 0;
_changed_notify(p_column);
}
-TreeItem::TreeCellMode TreeItem::get_cell_mode( int p_column ) const {
+TreeItem::TreeCellMode TreeItem::get_cell_mode(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), TreeItem::CELL_MODE_STRING );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), TreeItem::CELL_MODE_STRING);
return cells[p_column].mode;
}
-
/* check mode */
-void TreeItem::set_checked(int p_column,bool p_checked) {
+void TreeItem::set_checked(int p_column, bool p_checked) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].checked=p_checked;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].checked = p_checked;
_changed_notify(p_column);
-
}
bool TreeItem::is_checked(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), false );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].checked;
}
+void TreeItem::set_text(int p_column, String p_text) {
-void TreeItem::set_text(int p_column,String p_text) {
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].text = p_text;
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].text=p_text;
+ if (cells[p_column].mode == TreeItem::CELL_MODE_RANGE || cells[p_column].mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
- if (cells[p_column].mode==TreeItem::CELL_MODE_RANGE || cells[p_column].mode==TreeItem::CELL_MODE_RANGE_EXPRESSION) {
-
- cells[p_column].min=0;
- cells[p_column].max=p_text.get_slice_count(",");
- cells[p_column].step=0;
+ cells[p_column].min = 0;
+ cells[p_column].max = p_text.get_slice_count(",");
+ cells[p_column].step = 0;
}
_changed_notify(p_column);
-
}
String TreeItem::get_text(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), "" );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), "");
return cells[p_column].text;
-
}
+void TreeItem::set_icon(int p_column, const Ref<Texture> &p_icon) {
-void TreeItem::set_icon(int p_column,const Ref<Texture>& p_icon) {
-
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].icon=p_icon;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].icon = p_icon;
_changed_notify(p_column);
-
}
Ref<Texture> TreeItem::get_icon(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), Ref<Texture>() );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture>());
return cells[p_column].icon;
-
}
-void TreeItem::set_icon_region(int p_column,const Rect2& p_icon_region) {
+void TreeItem::set_icon_region(int p_column, const Rect2 &p_icon_region) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].icon_region=p_icon_region;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].icon_region = p_icon_region;
_changed_notify(p_column);
}
Rect2 TreeItem::get_icon_region(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), Rect2() );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), Rect2());
return cells[p_column].icon_region;
}
-void TreeItem::set_icon_max_width(int p_column,int p_max) {
+void TreeItem::set_icon_max_width(int p_column, int p_max) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].icon_max_w=p_max;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].icon_max_w = p_max;
_changed_notify(p_column);
}
int TreeItem::get_icon_max_width(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), 0);
+ ERR_FAIL_INDEX_V(p_column, cells.size(), 0);
return cells[p_column].icon_max_w;
-
}
-
/* range works for mode number or mode combo */
-void TreeItem::set_range(int p_column,double p_value) {
+void TreeItem::set_range(int p_column, double p_value) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- if (cells[p_column].step>0)
- p_value=Math::stepify( p_value, cells[p_column].step );
- if (p_value<cells[p_column].min)
- p_value=cells[p_column].min;
- if (p_value>cells[p_column].max)
- p_value=cells[p_column].max;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ if (cells[p_column].step > 0)
+ p_value = Math::stepify(p_value, cells[p_column].step);
+ if (p_value < cells[p_column].min)
+ p_value = cells[p_column].min;
+ if (p_value > cells[p_column].max)
+ p_value = cells[p_column].max;
- cells[p_column].val=p_value;
+ cells[p_column].val = p_value;
_changed_notify(p_column);
-
}
double TreeItem::get_range(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), 0 );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), 0);
return cells[p_column].val;
}
-
bool TreeItem::is_range_exponential(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), false);
+ ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].expr;
-
}
-void TreeItem::set_range_config(int p_column,double p_min,double p_max,double p_step,bool p_exp) {
+void TreeItem::set_range_config(int p_column, double p_min, double p_max, double p_step, bool p_exp) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].min=p_min;
- cells[p_column].max=p_max;
- cells[p_column].step=p_step;
- cells[p_column].expr=p_exp;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].min = p_min;
+ cells[p_column].max = p_max;
+ cells[p_column].step = p_step;
+ cells[p_column].expr = p_exp;
_changed_notify(p_column);
-
}
-void TreeItem::get_range_config(int p_column,double& r_min,double& r_max,double &r_step) const {
-
- ERR_FAIL_INDEX( p_column, cells.size() );
- r_min=cells[p_column].min;
- r_max=cells[p_column].max;
- r_step=cells[p_column].step;
+void TreeItem::get_range_config(int p_column, double &r_min, double &r_max, double &r_step) const {
+ ERR_FAIL_INDEX(p_column, cells.size());
+ r_min = cells[p_column].min;
+ r_max = cells[p_column].max;
+ r_step = cells[p_column].step;
}
-void TreeItem::set_metadata(int p_column,const Variant& p_meta) {
-
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].meta=p_meta;
+void TreeItem::set_metadata(int p_column, const Variant &p_meta) {
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].meta = p_meta;
}
Variant TreeItem::get_metadata(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), Variant() );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), Variant());
return cells[p_column].meta;
}
-void TreeItem::set_custom_draw(int p_column,Object *p_object,const StringName& p_callback) {
+void TreeItem::set_custom_draw(int p_column, Object *p_object, const StringName &p_callback) {
- ERR_FAIL_INDEX( p_column, cells.size() );
+ ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_NULL(p_object);
- cells[p_column].custom_draw_obj=p_object->get_instance_ID();
- cells[p_column].custom_draw_callback=p_callback;
-
+ cells[p_column].custom_draw_obj = p_object->get_instance_ID();
+ cells[p_column].custom_draw_callback = p_callback;
}
void TreeItem::set_collapsed(bool p_collapsed) {
- if (collapsed==p_collapsed)
+ if (collapsed == p_collapsed)
return;
- collapsed=p_collapsed;
+ collapsed = p_collapsed;
TreeItem *ci = tree->selected_item;
if (ci) {
- while (ci && ci!=this) {
+ while (ci && ci != this) {
- ci=ci->parent;
+ ci = ci->parent;
}
if (ci) { // collapsing cursor/selectd, move it!
- if (tree->select_mode==Tree::SELECT_MULTI) {
+ if (tree->select_mode == Tree::SELECT_MULTI) {
- tree->selected_item=this;
+ tree->selected_item = this;
emit_signal("cell_selected");
} else {
@@ -314,13 +292,11 @@ void TreeItem::set_collapsed(bool p_collapsed) {
tree->update();
}
-
}
_changed_notify();
if (tree)
- tree->emit_signal("item_collapsed",this);
-
+ tree->emit_signal("item_collapsed", this);
}
bool TreeItem::is_collapsed() {
@@ -328,7 +304,6 @@ bool TreeItem::is_collapsed() {
return collapsed;
}
-
TreeItem *TreeItem::get_next() {
return next;
@@ -336,12 +311,12 @@ TreeItem *TreeItem::get_next() {
TreeItem *TreeItem::get_prev() {
- if (!parent || parent->childs==this)
+ if (!parent || parent->childs == this)
return NULL;
TreeItem *prev = parent->childs;
- while(prev && prev->next!=this)
- prev=prev->next;
+ while (prev && prev->next != this)
+ prev = prev->next;
return prev;
}
@@ -356,61 +331,54 @@ TreeItem *TreeItem::get_children() {
return childs;
}
-
TreeItem *TreeItem::get_prev_visible() {
- TreeItem *current=this;
+ TreeItem *current = this;
TreeItem *prev = current->get_prev();
-
if (!prev) {
- current=current->parent;
- if (!current || (current==tree->root && tree->hide_root))
+ current = current->parent;
+ if (!current || (current == tree->root && tree->hide_root))
return NULL;
} else {
-
- current=prev;
- while( !current->collapsed && current->childs ) {
+ current = prev;
+ while (!current->collapsed && current->childs) {
//go to the very end
current = current->childs;
while (current->next)
- current=current->next;
+ current = current->next;
}
-
-
}
return current;
}
-
TreeItem *TreeItem::get_next_visible() {
- TreeItem *current=this;
-
+ TreeItem *current = this;
if (!current->collapsed && current->childs) {
- current=current->childs;
+ current = current->childs;
} else if (current->next) {
- current=current->next;
+ current = current->next;
} else {
- while(current && !current->next) {
+ while (current && !current->next) {
- current=current->parent;
+ current = current->parent;
}
- if (current==NULL)
+ if (current == NULL)
return NULL;
else
- current=current->next;
+ current = current->next;
}
return current;
@@ -419,117 +387,111 @@ TreeItem *TreeItem::get_next_visible() {
void TreeItem::remove_child(TreeItem *p_item) {
ERR_FAIL_NULL(p_item);
- TreeItem **c=&childs;
+ TreeItem **c = &childs;
while (*c) {
- if ( (*c) == p_item ) {
+ if ((*c) == p_item) {
TreeItem *aux = *c;
- *c=(*c)->next;
+ *c = (*c)->next;
aux->parent = NULL;
return;
}
- c=&(*c)->next;
+ c = &(*c)->next;
}
ERR_FAIL();
}
+void TreeItem::set_selectable(int p_column, bool p_selectable) {
-void TreeItem::set_selectable(int p_column,bool p_selectable) {
-
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].selectable=p_selectable;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].selectable = p_selectable;
}
bool TreeItem::is_selectable(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), false );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].selectable;
-
}
bool TreeItem::is_selected(int p_column) {
- ERR_FAIL_INDEX_V( p_column, cells.size(), false );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].selectable && cells[p_column].selected;
}
void TreeItem::set_as_cursor(int p_column) {
- ERR_FAIL_INDEX( p_column, cells.size() );
+ ERR_FAIL_INDEX(p_column, cells.size());
if (!tree)
return;
- if (tree->select_mode!=Tree::SELECT_MULTI)
+ if (tree->select_mode != Tree::SELECT_MULTI)
return;
- tree->selected_item=this;
- tree->selected_col=p_column;
+ tree->selected_item = this;
+ tree->selected_col = p_column;
tree->update();
}
void TreeItem::select(int p_column) {
- ERR_FAIL_INDEX( p_column, cells.size() );
+ ERR_FAIL_INDEX(p_column, cells.size());
_cell_selected(p_column);
}
void TreeItem::deselect(int p_column) {
- ERR_FAIL_INDEX( p_column, cells.size() );
+ ERR_FAIL_INDEX(p_column, cells.size());
_cell_deselected(p_column);
}
-void TreeItem::add_button(int p_column, const Ref<Texture>& p_button, int p_id, bool p_disabled) {
-
+void TreeItem::add_button(int p_column, const Ref<Texture> &p_button, int p_id, bool p_disabled) {
- ERR_FAIL_INDEX( p_column, cells.size() );
+ ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_COND(!p_button.is_valid());
TreeItem::Cell::Button button;
- button.texture=p_button;
- if (p_id<0)
- p_id=cells[p_column].buttons.size();
- button.id=p_id;
- button.disabled=p_disabled;
+ button.texture = p_button;
+ if (p_id < 0)
+ p_id = cells[p_column].buttons.size();
+ button.id = p_id;
+ button.disabled = p_disabled;
cells[p_column].buttons.push_back(button);
_changed_notify(p_column);
}
int TreeItem::get_button_count(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), -1 );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), -1);
return cells[p_column].buttons.size();
-
}
-Ref<Texture> TreeItem::get_button(int p_column,int p_idx) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), Ref<Texture>() );
- ERR_FAIL_INDEX_V( p_idx, cells[p_column].buttons.size(), Ref<Texture>() );
+Ref<Texture> TreeItem::get_button(int p_column, int p_idx) const {
+ ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), Ref<Texture>());
return cells[p_column].buttons[p_idx].texture;
-
}
-int TreeItem::get_button_id(int p_column,int p_idx) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), -1 );
- ERR_FAIL_INDEX_V( p_idx, cells[p_column].buttons.size(), -1 );
+int TreeItem::get_button_id(int p_column, int p_idx) const {
+ ERR_FAIL_INDEX_V(p_column, cells.size(), -1);
+ ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), -1);
return cells[p_column].buttons[p_idx].id;
-
}
-void TreeItem::erase_button(int p_column,int p_idx) {
+void TreeItem::erase_button(int p_column, int p_idx) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- ERR_FAIL_INDEX( p_idx, cells[p_column].buttons.size() );
+ ERR_FAIL_INDEX(p_column, cells.size());
+ ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
cells[p_column].buttons.remove(p_idx);
_changed_notify(p_column);
}
-int TreeItem::get_button_by_id(int p_column,int p_id) const {
+int TreeItem::get_button_by_id(int p_column, int p_id) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(),-1 );
- for(int i=0;i<cells[p_column].buttons.size();i++) {
+ ERR_FAIL_INDEX_V(p_column, cells.size(), -1);
+ for (int i = 0; i < cells[p_column].buttons.size(); i++) {
- if (cells[p_column].buttons[i].id==p_id)
+ if (cells[p_column].buttons[i].id == p_id)
return i;
}
@@ -538,200 +500,190 @@ int TreeItem::get_button_by_id(int p_column,int p_id) const {
bool TreeItem::is_button_disabled(int p_column, int p_idx) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), false );
- ERR_FAIL_INDEX_V( p_idx, cells[p_column].buttons.size(), false );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), false);
+ ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), false);
return cells[p_column].buttons[p_idx].disabled;
-
}
-void TreeItem::set_button(int p_column,int p_idx,const Ref<Texture>& p_button){
+void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture> &p_button) {
- ERR_FAIL_COND( p_button.is_null() );
- ERR_FAIL_INDEX( p_column, cells.size() );
- ERR_FAIL_INDEX( p_idx, cells[p_column].buttons.size() );
- cells[p_column].buttons[p_idx].texture=p_button;
+ ERR_FAIL_COND(p_button.is_null());
+ ERR_FAIL_INDEX(p_column, cells.size());
+ ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
+ cells[p_column].buttons[p_idx].texture = p_button;
_changed_notify(p_column);
-
}
-void TreeItem::set_button_color(int p_column,int p_idx,const Color& p_color) {
+void TreeItem::set_button_color(int p_column, int p_idx, const Color &p_color) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- ERR_FAIL_INDEX( p_idx, cells[p_column].buttons.size() );
- cells[p_column].buttons[p_idx].color=p_color;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ ERR_FAIL_INDEX(p_idx, cells[p_column].buttons.size());
+ cells[p_column].buttons[p_idx].color = p_color;
_changed_notify(p_column);
-
}
-void TreeItem::set_editable(int p_column,bool p_editable) {
+void TreeItem::set_editable(int p_column, bool p_editable) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].editable=p_editable;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].editable = p_editable;
_changed_notify(p_column);
}
bool TreeItem::is_editable(int p_column) {
- ERR_FAIL_INDEX_V( p_column, cells.size(), false );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), false);
return cells[p_column].editable;
}
+void TreeItem::set_custom_color(int p_column, const Color &p_color) {
-void TreeItem::set_custom_color(int p_column,const Color& p_color) {
-
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].custom_color=true;
- cells[p_column].color=p_color;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].custom_color = true;
+ cells[p_column].color = p_color;
_changed_notify(p_column);
}
Color TreeItem::get_custom_color(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), Color() );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), Color());
if (!cells[p_column].custom_color)
return Color();
return cells[p_column].color;
-
}
void TreeItem::clear_custom_color(int p_column) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].custom_color=false;
- cells[p_column].color=Color();
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].custom_color = false;
+ cells[p_column].color = Color();
_changed_notify(p_column);
}
+void TreeItem::set_tooltip(int p_column, const String &p_tooltip) {
-void TreeItem::set_tooltip(int p_column, const String& p_tooltip) {
-
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].tooltip=p_tooltip;
-
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].tooltip = p_tooltip;
}
-String TreeItem::get_tooltip(int p_column) const{
+String TreeItem::get_tooltip(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), "" );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), "");
return cells[p_column].tooltip;
}
-void TreeItem::set_custom_bg_color(int p_column,const Color& p_color,bool p_bg_outline) {
+void TreeItem::set_custom_bg_color(int p_column, const Color &p_color, bool p_bg_outline) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].custom_bg_color=true;
- cells[p_column].custom_bg_outline=p_bg_outline;
- cells[p_column].bg_color=p_color;
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].custom_bg_color = true;
+ cells[p_column].custom_bg_outline = p_bg_outline;
+ cells[p_column].bg_color = p_color;
_changed_notify(p_column);
}
void TreeItem::clear_custom_bg_color(int p_column) {
- ERR_FAIL_INDEX( p_column, cells.size() );
- cells[p_column].custom_bg_color=false;
- cells[p_column].bg_color=Color();
+ ERR_FAIL_INDEX(p_column, cells.size());
+ cells[p_column].custom_bg_color = false;
+ cells[p_column].bg_color = Color();
_changed_notify(p_column);
}
Color TreeItem::get_custom_bg_color(int p_column) const {
- ERR_FAIL_INDEX_V( p_column, cells.size(), Color() );
+ ERR_FAIL_INDEX_V(p_column, cells.size(), Color());
if (!cells[p_column].custom_bg_color)
return Color();
return cells[p_column].bg_color;
-
}
void TreeItem::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_cell_mode","column","mode"),&TreeItem::set_cell_mode);
- ObjectTypeDB::bind_method(_MD("get_cell_mode","column"),&TreeItem::get_cell_mode);
-
- ObjectTypeDB::bind_method(_MD("set_checked","column","checked"),&TreeItem::set_checked);
- ObjectTypeDB::bind_method(_MD("is_checked","column"),&TreeItem::is_checked);
+ ObjectTypeDB::bind_method(_MD("set_cell_mode", "column", "mode"), &TreeItem::set_cell_mode);
+ ObjectTypeDB::bind_method(_MD("get_cell_mode", "column"), &TreeItem::get_cell_mode);
- ObjectTypeDB::bind_method(_MD("set_text","column","text"),&TreeItem::set_text);
- ObjectTypeDB::bind_method(_MD("get_text","column"),&TreeItem::get_text);
+ ObjectTypeDB::bind_method(_MD("set_checked", "column", "checked"), &TreeItem::set_checked);
+ ObjectTypeDB::bind_method(_MD("is_checked", "column"), &TreeItem::is_checked);
- ObjectTypeDB::bind_method(_MD("set_icon","column","texture:Texture"),&TreeItem::set_icon);
- ObjectTypeDB::bind_method(_MD("get_icon:Texture","column"),&TreeItem::get_icon);
+ ObjectTypeDB::bind_method(_MD("set_text", "column", "text"), &TreeItem::set_text);
+ ObjectTypeDB::bind_method(_MD("get_text", "column"), &TreeItem::get_text);
- ObjectTypeDB::bind_method(_MD("set_icon_region","column","region"),&TreeItem::set_icon_region);
- ObjectTypeDB::bind_method(_MD("get_icon_region","column"),&TreeItem::get_icon_region);
+ ObjectTypeDB::bind_method(_MD("set_icon", "column", "texture:Texture"), &TreeItem::set_icon);
+ ObjectTypeDB::bind_method(_MD("get_icon:Texture", "column"), &TreeItem::get_icon);
- ObjectTypeDB::bind_method(_MD("set_icon_max_width","column","width"),&TreeItem::set_icon_max_width);
- ObjectTypeDB::bind_method(_MD("get_icon_max_width","column"),&TreeItem::get_icon_max_width);
+ ObjectTypeDB::bind_method(_MD("set_icon_region", "column", "region"), &TreeItem::set_icon_region);
+ ObjectTypeDB::bind_method(_MD("get_icon_region", "column"), &TreeItem::get_icon_region);
- ObjectTypeDB::bind_method(_MD("set_range","column","value"),&TreeItem::set_range);
- ObjectTypeDB::bind_method(_MD("get_range","column"),&TreeItem::get_range);
- ObjectTypeDB::bind_method(_MD("set_range_config","column","min","max","step","expr"),&TreeItem::set_range_config,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_range_config","column"),&TreeItem::_get_range_config);
+ ObjectTypeDB::bind_method(_MD("set_icon_max_width", "column", "width"), &TreeItem::set_icon_max_width);
+ ObjectTypeDB::bind_method(_MD("get_icon_max_width", "column"), &TreeItem::get_icon_max_width);
- ObjectTypeDB::bind_method(_MD("set_metadata","column","meta"),&TreeItem::set_metadata);
- ObjectTypeDB::bind_method(_MD("get_metadata","column"),&TreeItem::get_metadata);
+ ObjectTypeDB::bind_method(_MD("set_range", "column", "value"), &TreeItem::set_range);
+ ObjectTypeDB::bind_method(_MD("get_range", "column"), &TreeItem::get_range);
+ ObjectTypeDB::bind_method(_MD("set_range_config", "column", "min", "max", "step", "expr"), &TreeItem::set_range_config, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_range_config", "column"), &TreeItem::_get_range_config);
- ObjectTypeDB::bind_method(_MD("set_custom_draw","column","object","callback"),&TreeItem::set_custom_draw);
+ ObjectTypeDB::bind_method(_MD("set_metadata", "column", "meta"), &TreeItem::set_metadata);
+ ObjectTypeDB::bind_method(_MD("get_metadata", "column"), &TreeItem::get_metadata);
- ObjectTypeDB::bind_method(_MD("set_collapsed","enable"),&TreeItem::set_collapsed);
- ObjectTypeDB::bind_method(_MD("is_collapsed"),&TreeItem::is_collapsed);
+ ObjectTypeDB::bind_method(_MD("set_custom_draw", "column", "object", "callback"), &TreeItem::set_custom_draw);
- ObjectTypeDB::bind_method(_MD("get_next:TreeItem"),&TreeItem::get_next);
- ObjectTypeDB::bind_method(_MD("get_prev:TreeItem"),&TreeItem::get_prev);
- ObjectTypeDB::bind_method(_MD("get_parent:TreeItem"),&TreeItem::get_parent);
- ObjectTypeDB::bind_method(_MD("get_children:TreeItem"),&TreeItem::get_children);
+ ObjectTypeDB::bind_method(_MD("set_collapsed", "enable"), &TreeItem::set_collapsed);
+ ObjectTypeDB::bind_method(_MD("is_collapsed"), &TreeItem::is_collapsed);
- ObjectTypeDB::bind_method(_MD("get_next_visible:TreeItem"),&TreeItem::get_next_visible);
- ObjectTypeDB::bind_method(_MD("get_prev_visible:TreeItem"),&TreeItem::get_prev_visible);
+ ObjectTypeDB::bind_method(_MD("get_next:TreeItem"), &TreeItem::get_next);
+ ObjectTypeDB::bind_method(_MD("get_prev:TreeItem"), &TreeItem::get_prev);
+ ObjectTypeDB::bind_method(_MD("get_parent:TreeItem"), &TreeItem::get_parent);
+ ObjectTypeDB::bind_method(_MD("get_children:TreeItem"), &TreeItem::get_children);
- ObjectTypeDB::bind_method(_MD("remove_child:TreeItem","child"),&TreeItem::_remove_child);
+ ObjectTypeDB::bind_method(_MD("get_next_visible:TreeItem"), &TreeItem::get_next_visible);
+ ObjectTypeDB::bind_method(_MD("get_prev_visible:TreeItem"), &TreeItem::get_prev_visible);
- ObjectTypeDB::bind_method(_MD("set_selectable","column","selectable"),&TreeItem::set_selectable);
- ObjectTypeDB::bind_method(_MD("is_selectable","column"),&TreeItem::is_selectable);
+ ObjectTypeDB::bind_method(_MD("remove_child:TreeItem", "child"), &TreeItem::_remove_child);
- ObjectTypeDB::bind_method(_MD("is_selected","column"),&TreeItem::is_selected);
- ObjectTypeDB::bind_method(_MD("select","column"),&TreeItem::select);
- ObjectTypeDB::bind_method(_MD("deselect","column"),&TreeItem::deselect);
+ ObjectTypeDB::bind_method(_MD("set_selectable", "column", "selectable"), &TreeItem::set_selectable);
+ ObjectTypeDB::bind_method(_MD("is_selectable", "column"), &TreeItem::is_selectable);
- ObjectTypeDB::bind_method(_MD("set_editable","column","enabled"),&TreeItem::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable","column"),&TreeItem::is_editable);
+ ObjectTypeDB::bind_method(_MD("is_selected", "column"), &TreeItem::is_selected);
+ ObjectTypeDB::bind_method(_MD("select", "column"), &TreeItem::select);
+ ObjectTypeDB::bind_method(_MD("deselect", "column"), &TreeItem::deselect);
- ObjectTypeDB::bind_method(_MD("set_custom_color","column","color"),&TreeItem::set_custom_color);
- ObjectTypeDB::bind_method(_MD("clear_custom_color","column"),&TreeItem::clear_custom_color);
+ ObjectTypeDB::bind_method(_MD("set_editable", "column", "enabled"), &TreeItem::set_editable);
+ ObjectTypeDB::bind_method(_MD("is_editable", "column"), &TreeItem::is_editable);
- ObjectTypeDB::bind_method(_MD("set_custom_bg_color","column","color","just_outline"),&TreeItem::set_custom_bg_color,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color);
+ ObjectTypeDB::bind_method(_MD("set_custom_color", "column", "color"), &TreeItem::set_custom_color);
+ ObjectTypeDB::bind_method(_MD("clear_custom_color", "column"), &TreeItem::clear_custom_color);
- ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count);
- ObjectTypeDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button);
- ObjectTypeDB::bind_method(_MD("set_button","column","button_idx","button:Texture"),&TreeItem::set_button);
- ObjectTypeDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button);
- ObjectTypeDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled);
+ ObjectTypeDB::bind_method(_MD("set_custom_bg_color", "column", "color", "just_outline"), &TreeItem::set_custom_bg_color, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("clear_custom_bg_color", "column"), &TreeItem::clear_custom_bg_color);
+ ObjectTypeDB::bind_method(_MD("get_custom_bg_color", "column"), &TreeItem::get_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip);
- ObjectTypeDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip);
+ ObjectTypeDB::bind_method(_MD("add_button", "column", "button:Texture", "button_idx", "disabled"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_button_count", "column"), &TreeItem::get_button_count);
+ ObjectTypeDB::bind_method(_MD("get_button:Texture", "column", "button_idx"), &TreeItem::get_button);
+ ObjectTypeDB::bind_method(_MD("set_button", "column", "button_idx", "button:Texture"), &TreeItem::set_button);
+ ObjectTypeDB::bind_method(_MD("erase_button", "column", "button_idx"), &TreeItem::erase_button);
+ ObjectTypeDB::bind_method(_MD("is_button_disabled", "column", "button_idx"), &TreeItem::is_button_disabled);
- ObjectTypeDB::bind_method(_MD("move_to_top"),&TreeItem::move_to_top);
- ObjectTypeDB::bind_method(_MD("move_to_bottom"),&TreeItem::move_to_bottom);
-
- BIND_CONSTANT( CELL_MODE_STRING );
- BIND_CONSTANT( CELL_MODE_CHECK );
- BIND_CONSTANT( CELL_MODE_RANGE );
- BIND_CONSTANT( CELL_MODE_RANGE_EXPRESSION );
- BIND_CONSTANT( CELL_MODE_ICON );
- BIND_CONSTANT( CELL_MODE_CUSTOM );
+ ObjectTypeDB::bind_method(_MD("set_tooltip", "column", "tooltip"), &TreeItem::set_tooltip);
+ ObjectTypeDB::bind_method(_MD("get_tooltip", "column"), &TreeItem::get_tooltip);
+ ObjectTypeDB::bind_method(_MD("move_to_top"), &TreeItem::move_to_top);
+ ObjectTypeDB::bind_method(_MD("move_to_bottom"), &TreeItem::move_to_bottom);
+ BIND_CONSTANT(CELL_MODE_STRING);
+ BIND_CONSTANT(CELL_MODE_CHECK);
+ BIND_CONSTANT(CELL_MODE_RANGE);
+ BIND_CONSTANT(CELL_MODE_RANGE_EXPRESSION);
+ BIND_CONSTANT(CELL_MODE_ICON);
+ BIND_CONSTANT(CELL_MODE_CUSTOM);
}
void TreeItem::clear_children() {
- TreeItem *c=childs;
+ TreeItem *c = childs;
while (c) {
- TreeItem *aux=c;
- c=c->get_next();
- aux->parent=0; // so it wont try to recursively autoremove from me in here
- memdelete( aux );
+ TreeItem *aux = c;
+ c = c->get_next();
+ aux->parent = 0; // so it wont try to recursively autoremove from me in here
+ memdelete(aux);
}
childs = 0;
@@ -739,13 +691,12 @@ void TreeItem::clear_children() {
TreeItem::TreeItem(Tree *p_tree) {
- tree=p_tree;
- collapsed=false;
-
- parent=0; // parent item
- next=0; // next in list
- childs=0; //child items
+ tree = p_tree;
+ collapsed = false;
+ parent = 0; // parent item
+ next = 0; // next in list
+ childs = 0; //child items
}
TreeItem::~TreeItem() {
@@ -755,33 +706,29 @@ TreeItem::~TreeItem() {
if (parent)
parent->remove_child(this);
- if (tree && tree->root==this) {
+ if (tree && tree->root == this) {
- tree->root=0;
+ tree->root = 0;
}
- if (tree && tree->popup_edited_item==this) {
- tree->popup_edited_item=NULL;
- tree->pressing_for_editor=false;
-
+ if (tree && tree->popup_edited_item == this) {
+ tree->popup_edited_item = NULL;
+ tree->pressing_for_editor = false;
}
- if (tree && tree->selected_item==this)
- tree->selected_item=NULL;
-
+ if (tree && tree->selected_item == this)
+ tree->selected_item = NULL;
- if (tree && tree->drop_mode_over==this)
- tree->drop_mode_over=NULL;
+ if (tree && tree->drop_mode_over == this)
+ tree->drop_mode_over = NULL;
- if (tree && tree->single_select_defer==this)
- tree->single_select_defer=NULL;
+ if (tree && tree->single_select_defer == this)
+ tree->single_select_defer = NULL;
- if (tree && tree->edited_item==this) {
- tree->edited_item=NULL;
- tree->pressing_for_editor=false;
+ if (tree && tree->edited_item == this) {
+ tree->edited_item = NULL;
+ tree->pressing_for_editor = false;
}
-
-
}
/**********************************************/
@@ -791,41 +738,37 @@ TreeItem::~TreeItem() {
/**********************************************/
/**********************************************/
-
-
-
-
void Tree::update_cache() {
cache.font = get_font("font");
cache.tb_font = get_font("title_button_font");
cache.bg = get_stylebox("bg");
- cache.selected= get_stylebox("selected");
- cache.selected_focus= get_stylebox("selected_focus");
+ cache.selected = get_stylebox("selected");
+ cache.selected_focus = get_stylebox("selected_focus");
cache.cursor = get_stylebox("cursor");
cache.cursor_unfocus = get_stylebox("cursor_unfocused");
- cache.button_pressed= get_stylebox("button_pressed");
+ cache.button_pressed = get_stylebox("button_pressed");
- cache.checked=get_icon("checked");
- cache.unchecked=get_icon("unchecked");
- cache.arrow_collapsed=get_icon("arrow_collapsed");
- cache.arrow =get_icon("arrow");
- cache.select_arrow =get_icon("select_arrow");
- cache.updown=get_icon("updown");
+ cache.checked = get_icon("checked");
+ cache.unchecked = get_icon("unchecked");
+ cache.arrow_collapsed = get_icon("arrow_collapsed");
+ cache.arrow = get_icon("arrow");
+ cache.select_arrow = get_icon("select_arrow");
+ cache.updown = get_icon("updown");
- cache.font_color=get_color("font_color");
- cache.font_color_selected=get_color("font_color_selected");
- cache.guide_color=get_color("guide_color");
- cache.drop_position_color=get_color("drop_position_color");
- cache.hseparation=get_constant("hseparation");
- cache.vseparation=get_constant("vseparation");
- cache.item_margin=get_constant("item_margin");
- cache.button_margin=get_constant("button_margin");
- cache.guide_width=get_constant("guide_width");
- cache.draw_relationship_lines=get_constant("draw_relationship_lines");
- cache.relationship_line_color=get_color("relationship_line_color");
- cache.scroll_border=get_constant("scroll_border");
- cache.scroll_speed=get_constant("scroll_speed");
+ cache.font_color = get_color("font_color");
+ cache.font_color_selected = get_color("font_color_selected");
+ cache.guide_color = get_color("guide_color");
+ cache.drop_position_color = get_color("drop_position_color");
+ cache.hseparation = get_constant("hseparation");
+ cache.vseparation = get_constant("vseparation");
+ cache.item_margin = get_constant("item_margin");
+ cache.button_margin = get_constant("button_margin");
+ cache.guide_width = get_constant("guide_width");
+ cache.draw_relationship_lines = get_constant("draw_relationship_lines");
+ cache.relationship_line_color = get_color("relationship_line_color");
+ cache.scroll_border = get_constant("scroll_border");
+ cache.scroll_speed = get_constant("scroll_speed");
cache.title_button = get_stylebox("title_button_normal");
cache.title_button_pressed = get_stylebox("title_button_pressed");
@@ -833,39 +776,32 @@ void Tree::update_cache() {
cache.title_button_color = get_color("title_button_color");
v_scroll->set_custom_step(cache.font->get_height());
-
}
int Tree::compute_item_height(TreeItem *p_item) const {
- if (p_item==root && hide_root)
+ if (p_item == root && hide_root)
return 0;
- int height=cache.font->get_height();
-
-
- for (int i=0;i<columns.size();i++) {
-
+ int height = cache.font->get_height();
- for(int j=0;j<p_item->cells[i].buttons.size();j++) {
+ for (int i = 0; i < columns.size(); i++) {
+ for (int j = 0; j < p_item->cells[i].buttons.size(); j++) {
- Size2i s;// = cache.button_pressed->get_minimum_size();
- s+= p_item->cells[i].buttons[j].texture->get_size();
- if (s.height>height)
- height=s.height;
+ Size2i s; // = cache.button_pressed->get_minimum_size();
+ s += p_item->cells[i].buttons[j].texture->get_size();
+ if (s.height > height)
+ height = s.height;
}
- switch(p_item->cells[i].mode) {
+ switch (p_item->cells[i].mode) {
case TreeItem::CELL_MODE_CHECK: {
int check_icon_h = cache.checked->get_height();
- if (height<check_icon_h)
- height=check_icon_h;
-
-
-
+ if (height < check_icon_h)
+ height = check_icon_h;
}
case TreeItem::CELL_MODE_STRING:
case TreeItem::CELL_MODE_CUSTOM:
@@ -875,11 +811,11 @@ int Tree::compute_item_height(TreeItem *p_item) const {
if (!icon.is_null()) {
Size2i s = p_item->cells[i].get_icon_size();
- if (p_item->cells[i].icon_max_w>0 && s.width > p_item->cells[i].icon_max_w ) {
- s.height=s.height * p_item->cells[i].icon_max_w / s.width;
+ if (p_item->cells[i].icon_max_w > 0 && s.width > p_item->cells[i].icon_max_w) {
+ s.height = s.height * p_item->cells[i].icon_max_w / s.width;
}
- if (s.height > height )
- height=s.height;
+ if (s.height > height)
+ height = s.height;
}
} break;
@@ -887,61 +823,56 @@ int Tree::compute_item_height(TreeItem *p_item) const {
}
}
-
height += cache.vseparation;
return height;
-
}
int Tree::get_item_height(TreeItem *p_item) const {
- int height=compute_item_height(p_item);
- height+=cache.vseparation;
+ int height = compute_item_height(p_item);
+ height += cache.vseparation;
if (!p_item->collapsed) { /* if not collapsed, check the childs */
- TreeItem *c=p_item->childs;
+ TreeItem *c = p_item->childs;
while (c) {
- height += get_item_height( c );
+ height += get_item_height(c);
- c=c->next;
+ c = c->next;
}
}
return height;
}
+void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color) {
-void Tree::draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,const Color& p_color) {
-
- Rect2i rect=p_rect;
+ Rect2i rect = p_rect;
RID ci = get_canvas_item();
if (!p_cell.icon.is_null()) {
Size2i bmsize = p_cell.get_icon_size();
- if (p_cell.icon_max_w>0 && bmsize.width > p_cell.icon_max_w) {
+ if (p_cell.icon_max_w > 0 && bmsize.width > p_cell.icon_max_w) {
bmsize.height = bmsize.height * p_cell.icon_max_w / bmsize.width;
- bmsize.width=p_cell.icon_max_w;
+ bmsize.width = p_cell.icon_max_w;
}
- p_cell.draw_icon(ci,rect.pos + Size2i(0,Math::floor((rect.size.y-bmsize.y)/2)),bmsize);
- rect.pos.x+=bmsize.x+cache.hseparation;
- rect.size.x-=bmsize.x+cache.hseparation;
-
+ p_cell.draw_icon(ci, rect.pos + Size2i(0, Math::floor((rect.size.y - bmsize.y) / 2)), bmsize);
+ rect.pos.x += bmsize.x + cache.hseparation;
+ rect.size.x -= bmsize.x + cache.hseparation;
}
-// if (p_tool)
-// rect.size.x-=Math::floor(rect.size.y/2);
+ // if (p_tool)
+ // rect.size.x-=Math::floor(rect.size.y/2);
Ref<Font> font = cache.font;
- rect.pos.y+=Math::floor((rect.size.y-font->get_height())/2.0) +font->get_ascent();
- font->draw(ci,rect.pos,p_cell.text,p_color,rect.size.x);
-
+ rect.pos.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent();
+ font->draw(ci, rect.pos, p_cell.text, p_color, rect.size.x);
}
#if 0
@@ -970,27 +901,25 @@ void Tree::draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_ma
font->draw(ci,p_rect.pos,p_text,p_color,p_rect.size.x);
}
#endif
-int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& p_draw_size,TreeItem *p_item) {
+int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item) {
- if (p_pos.y-cache.offset.y > (p_draw_size.height))
+ if (p_pos.y - cache.offset.y > (p_draw_size.height))
return -1; //draw no more!
RID ci = get_canvas_item();
- int htotal=0;
+ int htotal = 0;
- int label_h=compute_item_height( p_item );
+ int label_h = compute_item_height(p_item);
/* Calculate height of the label part */
- label_h+=cache.vseparation;
+ label_h += cache.vseparation;
/* Draw label, if height fits */
+ bool skip = (p_item == root && hide_root);
- bool skip=(p_item==root && hide_root);
-
-
- if (!skip && (p_pos.y+label_h-cache.offset.y)>0) {
+ if (!skip && (p_pos.y + label_h - cache.offset.y) > 0) {
if (!hide_folding && p_item->childs) { //has childs, draw the guide box
@@ -998,178 +927,169 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
if (p_item->collapsed) {
- arrow=cache.arrow_collapsed;
+ arrow = cache.arrow_collapsed;
} else {
- arrow=cache.arrow;
-
+ arrow = cache.arrow;
}
- arrow->draw( ci , p_pos+p_draw_ofs+Point2i(0,(label_h-arrow->get_height())/2)-cache.offset);
-
-
+ arrow->draw(ci, p_pos + p_draw_ofs + Point2i(0, (label_h - arrow->get_height()) / 2) - cache.offset);
}
//draw separation.
-// if (p_item->get_parent()!=root || !hide_root)
+ // if (p_item->get_parent()!=root || !hide_root)
Ref<Font> font = cache.font;
- int font_ascent=font->get_ascent();
+ int font_ascent = font->get_ascent();
- int ofs = p_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
- for (int i=0;i<columns.size();i++) {
+ int ofs = p_pos.x + (hide_folding ? cache.hseparation : cache.item_margin);
+ for (int i = 0; i < columns.size(); i++) {
int w = get_column_width(i);
- if (i==0) {
+ if (i == 0) {
- w-=ofs;
+ w -= ofs;
- if (w<=0) {
+ if (w <= 0) {
- ofs=get_column_width(0);
+ ofs = get_column_width(0);
continue;
}
} else {
- ofs+=cache.hseparation;
- w-=cache.hseparation;
+ ofs += cache.hseparation;
+ w -= cache.hseparation;
}
- int bw=0;
- for(int j=p_item->cells[i].buttons.size()-1;j>=0;j--) {
- Ref<Texture> b=p_item->cells[i].buttons[j].texture;
+ int bw = 0;
+ for (int j = p_item->cells[i].buttons.size() - 1; j >= 0; j--) {
+ Ref<Texture> b = p_item->cells[i].buttons[j].texture;
Size2 s = b->get_size() + cache.button_pressed->get_minimum_size();
- Point2i o = Point2i( ofs+w-s.width, p_pos.y )-cache.offset+p_draw_ofs;
+ Point2i o = Point2i(ofs + w - s.width, p_pos.y) - cache.offset + p_draw_ofs;
- if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i && cache.click_index==j && !p_item->cells[i].buttons[j].disabled) {
+ if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item == p_item && cache.click_column == i && cache.click_index == j && !p_item->cells[i].buttons[j].disabled) {
//being pressed
- cache.button_pressed->draw(get_canvas_item(),Rect2(o,s));
+ cache.button_pressed->draw(get_canvas_item(), Rect2(o, s));
}
- o.y+=(label_h-s.height)/2;
- o+=cache.button_pressed->get_offset();
+ o.y += (label_h - s.height) / 2;
+ o += cache.button_pressed->get_offset();
- b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):p_item->cells[i].buttons[j].color);
- w-=s.width+cache.button_margin;
- bw+=s.width+cache.button_margin;
+ b->draw(ci, o, p_item->cells[i].buttons[j].disabled ? Color(1, 1, 1, 0.5) : p_item->cells[i].buttons[j].color);
+ w -= s.width + cache.button_margin;
+ bw += s.width + cache.button_margin;
}
- Rect2i item_rect = Rect2i( Point2i( ofs, p_pos.y )-cache.offset+p_draw_ofs, Size2i( w, label_h ));
- Rect2i cell_rect=item_rect;
- if (i!=0) {
- cell_rect.pos.x-=cache.hseparation;
- cell_rect.size.x+=cache.hseparation;
+ Rect2i item_rect = Rect2i(Point2i(ofs, p_pos.y) - cache.offset + p_draw_ofs, Size2i(w, label_h));
+ Rect2i cell_rect = item_rect;
+ if (i != 0) {
+ cell_rect.pos.x -= cache.hseparation;
+ cell_rect.size.x += cache.hseparation;
}
+ VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(cell_rect.pos.x, cell_rect.pos.y + cell_rect.size.height), cell_rect.pos + cell_rect.size, cache.guide_color, 1);
+ if (i == 0) {
- VisualServer::get_singleton()->canvas_item_add_line(ci,Point2i(cell_rect.pos.x,cell_rect.pos.y+cell_rect.size.height),cell_rect.pos+cell_rect.size,cache.guide_color,1);
-
- if (i==0) {
-
- if (p_item->cells[0].selected && select_mode==SELECT_ROW) {
- Rect2i row_rect = Rect2i( Point2i( cache.bg->get_margin(MARGIN_LEFT), item_rect.pos.y), Size2i( get_size().width-cache.bg->get_minimum_size().width, item_rect.size.y ));
+ if (p_item->cells[0].selected && select_mode == SELECT_ROW) {
+ Rect2i row_rect = Rect2i(Point2i(cache.bg->get_margin(MARGIN_LEFT), item_rect.pos.y), Size2i(get_size().width - cache.bg->get_minimum_size().width, item_rect.size.y));
//Rect2 r = Rect2i(row_rect.pos,row_rect.size);
//r.grow(cache.selected->get_margin(MARGIN_LEFT));
if (has_focus())
- cache.selected_focus->draw(ci,row_rect );
+ cache.selected_focus->draw(ci, row_rect);
else
- cache.selected->draw(ci,row_rect );
+ cache.selected->draw(ci, row_rect);
}
-
}
- if (p_item->cells[i].selected && select_mode!=SELECT_ROW) {
+ if (p_item->cells[i].selected && select_mode != SELECT_ROW) {
- Rect2i r(item_rect.pos,item_rect.size);
- if (p_item->cells[i].text.size() > 0){
+ Rect2i r(item_rect.pos, item_rect.size);
+ if (p_item->cells[i].text.size() > 0) {
float icon_width = p_item->cells[i].get_icon_size().width;
r.pos.x += icon_width;
r.size.x -= icon_width;
}
//r.grow(cache.selected->get_margin(MARGIN_LEFT));
- if (has_focus()){
- cache.selected_focus->draw(ci,r );
- p_item->set_meta("__focus_rect", Rect2(r.pos,r.size));
+ if (has_focus()) {
+ cache.selected_focus->draw(ci, r);
+ p_item->set_meta("__focus_rect", Rect2(r.pos, r.size));
} else {
- cache.selected->draw(ci,r );
+ cache.selected->draw(ci, r);
}
- if (text_editor->is_visible()){
+ if (text_editor->is_visible()) {
text_editor->set_pos(get_global_pos() + r.pos);
}
}
if (p_item->cells[i].custom_bg_color) {
- Rect2 r=cell_rect;
- r.pos.x-=cache.hseparation;
- r.size.x+=cache.hseparation;
+ Rect2 r = cell_rect;
+ r.pos.x -= cache.hseparation;
+ r.size.x += cache.hseparation;
if (p_item->cells[i].custom_bg_outline) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(r.pos.x,r.pos.y,r.size.x,1),p_item->cells[i].bg_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(r.pos.x,r.pos.y+r.size.y-1,r.size.x,1),p_item->cells[i].bg_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(r.pos.x,r.pos.y,1,r.size.y),p_item->cells[i].bg_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(r.pos.x+r.size.x-1,r.pos.y,1,r.size.y),p_item->cells[i].bg_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y, r.size.x, 1), p_item->cells[i].bg_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y + r.size.y - 1, r.size.x, 1), p_item->cells[i].bg_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y, 1, r.size.y), p_item->cells[i].bg_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x + r.size.x - 1, r.pos.y, 1, r.size.y), p_item->cells[i].bg_color);
} else {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,r,p_item->cells[i].bg_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, r, p_item->cells[i].bg_color);
}
}
- if (drop_mode_flags && drop_mode_over==p_item) {
-
- Rect2 r=cell_rect;
+ if (drop_mode_flags && drop_mode_over == p_item) {
- if (drop_mode_section==-1 || drop_mode_section==0) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(r.pos.x,r.pos.y,r.size.x,1),cache.drop_position_color);
+ Rect2 r = cell_rect;
+ if (drop_mode_section == -1 || drop_mode_section == 0) {
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y, r.size.x, 1), cache.drop_position_color);
}
- if (drop_mode_section==0) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(r.pos.x,r.pos.y,1,r.size.y),cache.drop_position_color);
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(r.pos.x+r.size.x-1,r.pos.y,1,r.size.y),cache.drop_position_color);
-
+ if (drop_mode_section == 0) {
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y, 1, r.size.y), cache.drop_position_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x + r.size.x - 1, r.pos.y, 1, r.size.y), cache.drop_position_color);
}
- if (drop_mode_section==1 || drop_mode_section==0) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(r.pos.x,r.pos.y+r.size.y,r.size.x,1),cache.drop_position_color);
+ if (drop_mode_section == 1 || drop_mode_section == 0) {
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y + r.size.y, r.size.x, 1), cache.drop_position_color);
}
}
- Color col=p_item->cells[i].custom_color?p_item->cells[i].color:get_color( p_item->cells[i].selected?"font_color_selected":"font_color");
+ Color col = p_item->cells[i].custom_color ? p_item->cells[i].color : get_color(p_item->cells[i].selected ? "font_color_selected" : "font_color");
- Point2i text_pos=item_rect.pos;
- text_pos.y+=Math::floor((item_rect.size.y-font->get_height())/2) + font_ascent;
+ Point2i text_pos = item_rect.pos;
+ text_pos.y += Math::floor((item_rect.size.y - font->get_height()) / 2) + font_ascent;
switch (p_item->cells[i].mode) {
case TreeItem::CELL_MODE_STRING: {
- draw_item_rect(p_item->cells[i],item_rect,col);
+ draw_item_rect(p_item->cells[i], item_rect, col);
} break;
case TreeItem::CELL_MODE_CHECK: {
Ref<Texture> checked = cache.checked;
Ref<Texture> unchecked = cache.unchecked;
- Point2i check_ofs=item_rect.pos;
- check_ofs.y+=Math::floor((item_rect.size.y-checked->get_height())/2);
+ Point2i check_ofs = item_rect.pos;
+ check_ofs.y += Math::floor((item_rect.size.y - checked->get_height()) / 2);
if (p_item->cells[i].checked) {
- checked->draw( ci, check_ofs );
+ checked->draw(ci, check_ofs);
} else {
- unchecked->draw( ci, check_ofs );
-
+ unchecked->draw(ci, check_ofs);
}
- int check_w = checked->get_width()+cache.hseparation;
+ int check_w = checked->get_width() + cache.hseparation;
- text_pos.x+=check_w;
+ text_pos.x += check_w;
- item_rect.size.x-=check_w;
- item_rect.pos.x+=check_w;
+ item_rect.size.x -= check_w;
+ item_rect.pos.x += check_w;
- draw_item_rect(p_item->cells[i],item_rect,col);
+ draw_item_rect(p_item->cells[i], item_rect, col);
//font->draw( ci, text_pos, p_item->cells[i].text, col,item_rect.size.x-check_w );
@@ -1177,7 +1097,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
case TreeItem::CELL_MODE_RANGE:
case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
- if (p_item->cells[i].text!="") {
+ if (p_item->cells[i].text != "") {
if (!p_item->cells[i].editable)
break;
@@ -1185,34 +1105,34 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
int option = (int)p_item->cells[i].val;
String s = p_item->cells[i].text;
- s=s.get_slicec(',',option);
+ s = s.get_slicec(',', option);
Ref<Texture> downarrow = cache.select_arrow;
- font->draw(ci, text_pos, s, col,item_rect.size.x-downarrow->get_width() );
+ font->draw(ci, text_pos, s, col, item_rect.size.x - downarrow->get_width());
//?
- Point2i arrow_pos=item_rect.pos;
- arrow_pos.x+=item_rect.size.x-downarrow->get_width();
- arrow_pos.y+=Math::floor(((item_rect.size.y-downarrow->get_height()))/2.0);
+ Point2i arrow_pos = item_rect.pos;
+ arrow_pos.x += item_rect.size.x - downarrow->get_width();
+ arrow_pos.y += Math::floor(((item_rect.size.y - downarrow->get_height())) / 2.0);
- downarrow->draw( ci, arrow_pos );
+ downarrow->draw(ci, arrow_pos);
} else {
Ref<Texture> updown = cache.updown;
- String valtext = String::num( p_item->cells[i].val, Math::step_decimals( p_item->cells[i].step ) );
+ String valtext = String::num(p_item->cells[i].val, Math::step_decimals(p_item->cells[i].step));
//String valtext = rtos( p_item->cells[i].val );
- font->draw( ci, text_pos, valtext, col, item_rect.size.x-updown->get_width());
+ font->draw(ci, text_pos, valtext, col, item_rect.size.x - updown->get_width());
if (!p_item->cells[i].editable)
break;
- Point2i updown_pos=item_rect.pos;
- updown_pos.x+=item_rect.size.x-updown->get_width();
- updown_pos.y+=Math::floor(((item_rect.size.y-updown->get_height()))/2.0);
+ Point2i updown_pos = item_rect.pos;
+ updown_pos.x += item_rect.size.x - updown->get_width();
+ updown_pos.y += Math::floor(((item_rect.size.y - updown->get_height())) / 2.0);
- updown->draw( ci, updown_pos );
+ updown->draw(ci, updown_pos);
}
} break;
@@ -1221,268 +1141,248 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
if (p_item->cells[i].icon.is_null())
break;
Size2i icon_size = p_item->cells[i].get_icon_size();
- if (p_item->cells[i].icon_max_w>0 && icon_size.width >p_item->cells[i].icon_max_w) {
+ if (p_item->cells[i].icon_max_w > 0 && icon_size.width > p_item->cells[i].icon_max_w) {
icon_size.height = icon_size.height * p_item->cells[i].icon_max_w / icon_size.width;
- icon_size.width=p_item->cells[i].icon_max_w;
+ icon_size.width = p_item->cells[i].icon_max_w;
}
- Point2i icon_ofs = (item_rect.size-icon_size)/2;
- icon_ofs+=item_rect.pos;
+ Point2i icon_ofs = (item_rect.size - icon_size) / 2;
+ icon_ofs += item_rect.pos;
-
- draw_texture_rect(p_item->cells[i].icon,Rect2(icon_ofs,icon_size));
+ draw_texture_rect(p_item->cells[i].icon, Rect2(icon_ofs, icon_size));
//p_item->cells[i].icon->draw(ci, icon_ofs);
} break;
case TreeItem::CELL_MODE_CUSTOM: {
- // int option = (int)p_item->cells[i].val;
-
-
+ // int option = (int)p_item->cells[i].val;
if (p_item->cells[i].custom_draw_obj) {
- Object* cdo = ObjectDB::get_instance(p_item->cells[i].custom_draw_obj);
+ Object *cdo = ObjectDB::get_instance(p_item->cells[i].custom_draw_obj);
if (cdo)
- cdo->call(p_item->cells[i].custom_draw_callback,p_item,Rect2(item_rect));
+ cdo->call(p_item->cells[i].custom_draw_callback, p_item, Rect2(item_rect));
}
if (!p_item->cells[i].editable) {
- draw_item_rect(p_item->cells[i],item_rect,col);
+ draw_item_rect(p_item->cells[i], item_rect, col);
break;
}
Ref<Texture> downarrow = cache.select_arrow;
- Rect2i ir=item_rect;
- ir.size.width-=downarrow->get_width();
- draw_item_rect(p_item->cells[i],ir,col);
+ Rect2i ir = item_rect;
+ ir.size.width -= downarrow->get_width();
+ draw_item_rect(p_item->cells[i], ir, col);
- Point2i arrow_pos=item_rect.pos;
- arrow_pos.x+=item_rect.size.x-downarrow->get_width();
- arrow_pos.y+=Math::floor(((item_rect.size.y-downarrow->get_height()))/2.0);
+ Point2i arrow_pos = item_rect.pos;
+ arrow_pos.x += item_rect.size.x - downarrow->get_width();
+ arrow_pos.y += Math::floor(((item_rect.size.y - downarrow->get_height())) / 2.0);
- downarrow->draw( ci, arrow_pos );
+ downarrow->draw(ci, arrow_pos);
} break;
}
- if (i==0) {
+ if (i == 0) {
- ofs=get_column_width(0);
+ ofs = get_column_width(0);
} else {
- ofs+=w+bw;
+ ofs += w + bw;
}
- if (select_mode==SELECT_MULTI && selected_item==p_item && selected_col==i) {
+ if (select_mode == SELECT_MULTI && selected_item == p_item && selected_col == i) {
if (has_focus())
- cache.cursor->draw(ci,cell_rect);
+ cache.cursor->draw(ci, cell_rect);
else
- cache.cursor_unfocus->draw(ci,cell_rect);
+ cache.cursor_unfocus->draw(ci, cell_rect);
}
-
}
//separator
//get_painter()->draw_fill_rect( Point2i(0,pos.y),Size2i(get_size().width,1),color( COLOR_TREE_GRID) );
//pos=p_pos; //reset pos
-
}
-
- Point2 children_pos=p_pos;
+ Point2 children_pos = p_pos;
if (!skip) {
- children_pos.x+=cache.item_margin;
- htotal+=label_h;
- children_pos.y+=htotal;
-
+ children_pos.x += cache.item_margin;
+ htotal += label_h;
+ children_pos.y += htotal;
}
-
if (!p_item->collapsed) { /* if not collapsed, check the childs */
- TreeItem *c=p_item->childs;
+ TreeItem *c = p_item->childs;
while (c) {
- if (cache.draw_relationship_lines == 1){
- int root_ofs = children_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
- int parent_ofs = p_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
- Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h/2)-cache.offset+p_draw_ofs;
+ if (cache.draw_relationship_lines == 1) {
+ int root_ofs = children_pos.x + (hide_folding ? cache.hseparation : cache.item_margin);
+ int parent_ofs = p_pos.x + (hide_folding ? cache.hseparation : cache.item_margin);
+ Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs;
if (c->get_children() != NULL)
- root_pos -= Point2i(cache.arrow->get_width(),0);
+ root_pos -= Point2i(cache.arrow->get_width(), 0);
- Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width()/2, p_pos.y + label_h/2 + cache.arrow->get_height()/2)-cache.offset+p_draw_ofs;
+ Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width() / 2, p_pos.y + label_h / 2 + cache.arrow->get_height() / 2) - cache.offset + p_draw_ofs;
VisualServer::get_singleton()->canvas_item_add_line(ci, root_pos, Point2i(parent_pos.x, root_pos.y), cache.relationship_line_color);
VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(parent_pos.x, root_pos.y), parent_pos, cache.relationship_line_color);
}
- int child_h=draw_item(children_pos, p_draw_ofs, p_draw_size, c );
+ int child_h = draw_item(children_pos, p_draw_ofs, p_draw_size, c);
- if (child_h<0 && cache.draw_relationship_lines == 0)
+ if (child_h < 0 && cache.draw_relationship_lines == 0)
return -1; // break, stop drawing, no need to anymore
- htotal+=child_h;
- children_pos.y+=child_h;
- c=c->next;
+ htotal += child_h;
+ children_pos.y += child_h;
+ c = c->next;
}
}
-
return htotal;
-
-
}
-int Tree::_count_selected_items(TreeItem* p_from) const {
+int Tree::_count_selected_items(TreeItem *p_from) const {
- int count=0;
- for(int i=0;i<columns.size();i++) {
+ int count = 0;
+ for (int i = 0; i < columns.size(); i++) {
if (p_from->is_selected(i))
count++;
}
if (p_from->get_children()) {
- count+=_count_selected_items(p_from->get_children());
+ count += _count_selected_items(p_from->get_children());
}
if (p_from->get_next()) {
- count+=_count_selected_items(p_from->get_next());
+ count += _count_selected_items(p_from->get_next());
}
return count;
-
}
void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev, bool *r_in_range, bool p_force_deselect) {
- TreeItem::Cell &selected_cell=p_selected->cells[p_col];
+ TreeItem::Cell &selected_cell = p_selected->cells[p_col];
- bool switched=false;
- if (r_in_range && !*r_in_range && (p_current==p_selected || p_current==p_prev)) {
- *r_in_range=true;
- switched=true;
+ bool switched = false;
+ if (r_in_range && !*r_in_range && (p_current == p_selected || p_current == p_prev)) {
+ *r_in_range = true;
+ switched = true;
}
- bool emitted_row=false;
+ bool emitted_row = false;
- for (int i=0;i<columns.size();i++) {
+ for (int i = 0; i < columns.size(); i++) {
- TreeItem::Cell &c=p_current->cells[i];
+ TreeItem::Cell &c = p_current->cells[i];
if (!c.selectable)
continue;
- if (select_mode==SELECT_ROW) {
+ if (select_mode == SELECT_ROW) {
- if (p_selected==p_current && !c.selected) {
- c.selected=true;
- selected_item=p_selected;
- selected_col=0;
- selected_item=p_selected;
- if (!emitted_row) {
- emit_signal("item_selected");
- emitted_row=true;
- }
- //if (p_col==i)
- // p_current->selected_signal.call(p_col);
+ if (p_selected == p_current && !c.selected) {
+ c.selected = true;
+ selected_item = p_selected;
+ selected_col = 0;
+ selected_item = p_selected;
+ if (!emitted_row) {
+ emit_signal("item_selected");
+ emitted_row = true;
+ }
+ //if (p_col==i)
+ // p_current->selected_signal.call(p_col);
} else if (c.selected) {
- c.selected=false;
- //p_current->deselected_signal.call(p_col);
+ c.selected = false;
+ //p_current->deselected_signal.call(p_col);
}
- } else if (select_mode==SELECT_SINGLE || select_mode==SELECT_MULTI) {
+ } else if (select_mode == SELECT_SINGLE || select_mode == SELECT_MULTI) {
- if (!r_in_range && &selected_cell==&c) {
+ if (!r_in_range && &selected_cell == &c) {
if (!selected_cell.selected) {
- selected_cell.selected=true;
+ selected_cell.selected = true;
- selected_item=p_selected;
- selected_col=i;
+ selected_item = p_selected;
+ selected_col = i;
emit_signal("cell_selected");
- if (select_mode==SELECT_MULTI)
- emit_signal("multi_selected",p_current,i,true);
- else if(select_mode == SELECT_SINGLE)
+ if (select_mode == SELECT_MULTI)
+ emit_signal("multi_selected", p_current, i, true);
+ else if (select_mode == SELECT_SINGLE)
emit_signal("item_selected");
- } else if (select_mode==SELECT_MULTI && (selected_item!=p_selected || selected_col!=i)) {
+ } else if (select_mode == SELECT_MULTI && (selected_item != p_selected || selected_col != i)) {
- selected_item=p_selected;
- selected_col=i;
+ selected_item = p_selected;
+ selected_col = i;
emit_signal("cell_selected");
-
}
} else {
-
if (r_in_range && *r_in_range && !p_force_deselect) {
-
if (!c.selected && c.selectable) {
- c.selected=true;
- emit_signal("multi_selected",p_current,i,true);
+ c.selected = true;
+ emit_signal("multi_selected", p_current, i, true);
}
- } else if (!r_in_range || p_force_deselect){
- if (select_mode==SELECT_MULTI && c.selected)
- emit_signal("multi_selected",p_current,i,false);
- c.selected=false;
+ } else if (!r_in_range || p_force_deselect) {
+ if (select_mode == SELECT_MULTI && c.selected)
+ emit_signal("multi_selected", p_current, i, false);
+ c.selected = false;
}
//p_current->deselected_signal.call(p_col);
}
}
-
}
- if (!switched && r_in_range && *r_in_range && (p_current==p_selected || p_current==p_prev)) {
- *r_in_range=false;
+ if (!switched && r_in_range && *r_in_range && (p_current == p_selected || p_current == p_prev)) {
+ *r_in_range = false;
}
- TreeItem *c=p_current->childs;
+ TreeItem *c = p_current->childs;
while (c) {
- select_single_item(p_selected,c,p_col,p_prev,r_in_range,p_current->is_collapsed() || p_force_deselect);
- c=c->next;
+ select_single_item(p_selected, c, p_col, p_prev, r_in_range, p_current->is_collapsed() || p_force_deselect);
+ c = c->next;
}
-
}
-
Rect2 Tree::search_item_rect(TreeItem *p_from, TreeItem *p_item) {
-
return Rect2();
}
-
void Tree::_range_click_timeout() {
if (range_item_last && !range_drag_enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
- Point2 pos = get_local_mouse_pos()-cache.bg->get_offset();
+ Point2 pos = get_local_mouse_pos() - cache.bg->get_offset();
if (show_column_titles) {
- pos.y-=_get_title_button_height();
+ pos.y -= _get_title_button_height();
- if (pos.y<0) {
+ if (pos.y < 0) {
range_click_timer->stop();
return;
}
}
- click_handled=false;
+ click_handled = false;
InputModifierState mod = InputModifierState(); // should be irrelevant..
blocked++;
- propagate_mouse_event(pos+cache.offset, 0, 0, false, root, BUTTON_LEFT, mod);
+ propagate_mouse_event(pos + cache.offset, 0, 0, false, root, BUTTON_LEFT, mod);
blocked--;
if (range_click_timer->is_one_shot()) {
@@ -1499,120 +1399,112 @@ void Tree::_range_click_timeout() {
}
}
+int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const InputModifierState &p_mod) {
-int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_doubleclick,TreeItem *p_item,int p_button,const InputModifierState& p_mod) {
-
- int item_h=compute_item_height( p_item )+cache.vseparation;
+ int item_h = compute_item_height(p_item) + cache.vseparation;
- bool skip=(p_item==root && hide_root);
+ bool skip = (p_item == root && hide_root);
- if (!skip && p_pos.y<item_h) {
+ if (!skip && p_pos.y < item_h) {
// check event!
if (range_click_timer->get_time_left() > 0 && p_item != range_item_last) {
return -1;
}
- if (!hide_folding && (p_pos.x >=x_ofs && p_pos.x < (x_ofs+cache.item_margin) )) {
-
+ if (!hide_folding && (p_pos.x >= x_ofs && p_pos.x < (x_ofs + cache.item_margin))) {
if (p_item->childs)
- p_item->set_collapsed( ! p_item->is_collapsed() );
+ p_item->set_collapsed(!p_item->is_collapsed());
return -1; //handled!
}
- int x=p_pos.x;
+ int x = p_pos.x;
/* find clicked column */
- int col=-1;
- int col_ofs=0;
- int col_width=0;
- for (int i=0;i<columns.size();i++) {
+ int col = -1;
+ int col_ofs = 0;
+ int col_width = 0;
+ for (int i = 0; i < columns.size(); i++) {
- col_width=get_column_width(i);
- if (x>col_width) {
- col_ofs+=col_width;
- x-=col_width;
+ col_width = get_column_width(i);
+ if (x > col_width) {
+ col_ofs += col_width;
+ x -= col_width;
continue;
}
- col=i;
+ col = i;
break;
}
-
-
- if (col==-1)
+ if (col == -1)
return -1;
- else if (col==0) {
- int margin=x_ofs+cache.item_margin;//-cache.hseparation;
+ else if (col == 0) {
+ int margin = x_ofs + cache.item_margin; //-cache.hseparation;
//int lm = cache.bg->get_margin(MARGIN_LEFT);
- col_width-=margin;
- col_ofs+=margin;
- x-=margin;
+ col_width -= margin;
+ col_ofs += margin;
+ x -= margin;
} else {
- col_width-=cache.hseparation;
- x-=cache.hseparation;
-
+ col_width -= cache.hseparation;
+ x -= cache.hseparation;
}
TreeItem::Cell &c = p_item->cells[col];
+ bool already_selected = c.selected;
+ bool already_cursor = (p_item == selected_item) && col == selected_col;
- bool already_selected=c.selected;
- bool already_cursor=(p_item==selected_item) && col == selected_col;
-
-
- for(int j=c.buttons.size()-1;j>=0;j--) {
- Ref<Texture> b=c.buttons[j].texture;
+ for (int j = c.buttons.size() - 1; j >= 0; j--) {
+ Ref<Texture> b = c.buttons[j].texture;
int w = b->get_size().width + cache.button_pressed->get_minimum_size().width;
- if (x>col_width-w) {
+ if (x > col_width - w) {
if (c.buttons[j].disabled) {
- pressed_button=-1;
- cache.click_type=Cache::CLICK_NONE;
+ pressed_button = -1;
+ cache.click_type = Cache::CLICK_NONE;
return -1;
}
- pressed_button=j;
- cache.click_type=Cache::CLICK_BUTTON;
- cache.click_index=j;
- cache.click_id=c.buttons[j].id;
- cache.click_item=p_item;
- cache.click_column=col;
- cache.click_pos=get_global_mouse_pos()-get_global_pos();
+ pressed_button = j;
+ cache.click_type = Cache::CLICK_BUTTON;
+ cache.click_index = j;
+ cache.click_id = c.buttons[j].id;
+ cache.click_item = p_item;
+ cache.click_column = col;
+ cache.click_pos = get_global_mouse_pos() - get_global_pos();
update();
//emit_signal("button_pressed");
return -1;
}
- col_width-=w+cache.button_margin;
+ col_width -= w + cache.button_margin;
}
- if (p_button==BUTTON_LEFT || (p_button==BUTTON_RIGHT && allow_rmb_select)) {
+ if (p_button == BUTTON_LEFT || (p_button == BUTTON_RIGHT && allow_rmb_select)) {
/* process selection */
- if (p_doubleclick && (!c.editable || c.mode==TreeItem::CELL_MODE_CUSTOM || c.mode==TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it' s confusing for check
+ if (p_doubleclick && (!c.editable || c.mode == TreeItem::CELL_MODE_CUSTOM || c.mode == TreeItem::CELL_MODE_ICON /*|| c.mode==TreeItem::CELL_MODE_CHECK*/)) { //it' s confusing for check
emit_signal("item_activated");
return -1;
}
- if (select_mode==SELECT_MULTI && p_mod.command && c.selectable) {
+ if (select_mode == SELECT_MULTI && p_mod.command && c.selectable) {
- if (!c.selected || p_button==BUTTON_RIGHT) {
+ if (!c.selected || p_button == BUTTON_RIGHT) {
p_item->select(col);
- emit_signal("multi_selected",p_item,col,true);
- if (p_button==BUTTON_RIGHT) {
- emit_signal("item_rmb_selected",get_local_mouse_pos());
+ emit_signal("multi_selected", p_item, col, true);
+ if (p_button == BUTTON_RIGHT) {
+ emit_signal("item_rmb_selected", get_local_mouse_pos());
}
-
//p_item->selected_signal.call(col);
} else {
p_item->deselect(col);
- emit_signal("multi_selected",p_item,col,false);
+ emit_signal("multi_selected", p_item, col, false);
//p_item->deselected_signal.call(col);
}
@@ -1620,29 +1512,29 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
if (c.selectable) {
- if (select_mode==SELECT_MULTI && p_mod.shift && selected_item && selected_item!=p_item) {
+ if (select_mode == SELECT_MULTI && p_mod.shift && selected_item && selected_item != p_item) {
- bool inrange=false;
+ bool inrange = false;
- select_single_item( p_item, root, col,selected_item,&inrange );
- if (p_button==BUTTON_RIGHT) {
- emit_signal("item_rmb_selected",get_local_mouse_pos());
+ select_single_item(p_item, root, col, selected_item, &inrange);
+ if (p_button == BUTTON_RIGHT) {
+ emit_signal("item_rmb_selected", get_local_mouse_pos());
}
} else {
int icount = _count_selected_items(root);
- if (select_mode==SELECT_MULTI && icount>1 && p_button!=BUTTON_RIGHT) {
- single_select_defer=p_item;
- single_select_defer_column=col;
+ if (select_mode == SELECT_MULTI && icount > 1 && p_button != BUTTON_RIGHT) {
+ single_select_defer = p_item;
+ single_select_defer_column = col;
} else {
- if (p_button!=BUTTON_RIGHT || !c.selected) {
- select_single_item( p_item, root, col );
+ if (p_button != BUTTON_RIGHT || !c.selected) {
+ select_single_item(p_item, root, col);
}
- if (p_button==BUTTON_RIGHT) {
- emit_signal("item_rmb_selected",get_local_mouse_pos());
+ if (p_button == BUTTON_RIGHT) {
+ emit_signal("item_rmb_selected", get_local_mouse_pos());
}
}
}
@@ -1652,41 +1544,36 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
//}
update();
}
-
-
}
}
-
-
if (!c.editable)
return -1; // if cell is not editable, don't bother
/* editing */
- bool bring_up_editor=force_select_on_already_selected ? (c.selected && already_selected) : c.selected;
- String editor_text=c.text;
+ bool bring_up_editor = force_select_on_already_selected ? (c.selected && already_selected) : c.selected;
+ String editor_text = c.text;
switch (c.mode) {
case TreeItem::CELL_MODE_STRING: {
//nothing in particular
- if (select_mode==SELECT_MULTI && (get_tree()->get_last_event_id() == focus_in_id || !already_cursor)) {
- bring_up_editor=false;
+ if (select_mode == SELECT_MULTI && (get_tree()->get_last_event_id() == focus_in_id || !already_cursor)) {
+ bring_up_editor = false;
}
} break;
case TreeItem::CELL_MODE_CHECK: {
Ref<Texture> checked = cache.checked;
- bring_up_editor=false; //checkboxes are not edited with editor
- if (x>=0 && x<= checked->get_width()+cache.hseparation ) {
-
+ bring_up_editor = false; //checkboxes are not edited with editor
+ if (x >= 0 && x <= checked->get_width() + cache.hseparation) {
- p_item->set_checked(col,!c.checked);
- item_edited(col,p_item);
- click_handled=true;
+ p_item->set_checked(col, !c.checked);
+ item_edited(col, p_item);
+ click_handled = true;
//p_item->edited_signal.call(col);
}
@@ -1694,38 +1581,36 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
case TreeItem::CELL_MODE_RANGE:
case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
-
- if (c.text!="") {
+ if (c.text != "") {
//if (x >= (get_column_width(col)-item_h/2)) {
popup_menu->clear();
- for (int i=0;i<c.text.get_slice_count(",");i++) {
-
- String s = c.text.get_slicec(',',i);
- popup_menu->add_item(s,i);
+ for (int i = 0; i < c.text.get_slice_count(","); i++) {
+ String s = c.text.get_slicec(',', i);
+ popup_menu->add_item(s, i);
}
- popup_menu->set_size(Size2(col_width,0));
- popup_menu->set_pos( get_global_pos() + Point2i(col_ofs,_get_title_button_height()+y_ofs+item_h)-cache.offset );
+ popup_menu->set_size(Size2(col_width, 0));
+ popup_menu->set_pos(get_global_pos() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h) - cache.offset);
popup_menu->popup();
- popup_edited_item=p_item;
- popup_edited_item_col=col;
+ popup_edited_item = p_item;
+ popup_edited_item_col = col;
//}
- bring_up_editor=false;
+ bring_up_editor = false;
} else {
- if (x >= (col_width-item_h/2)) {
+ if (x >= (col_width - item_h / 2)) {
/* touching the combo */
- bool up=p_pos.y < (item_h /2);
+ bool up = p_pos.y < (item_h / 2);
- if (p_button==BUTTON_LEFT) {
+ if (p_button == BUTTON_LEFT) {
if (range_click_timer->get_time_left() == 0) {
- range_item_last=p_item;
- range_up_last=up;
+ range_item_last = p_item;
+ range_up_last = up;
range_click_timer->set_wait_time(0.6);
range_click_timer->set_one_shot(true);
@@ -1736,115 +1621,103 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
return -1; // break. avoid changing direction on mouse held
}
- p_item->set_range( col, c.val + (up?1.0:-1.0) * c.step );
+ p_item->set_range(col, c.val + (up ? 1.0 : -1.0) * c.step);
- item_edited(col,p_item);
+ item_edited(col, p_item);
- } else if (p_button==BUTTON_RIGHT) {
+ } else if (p_button == BUTTON_RIGHT) {
- p_item->set_range( col, (up?c.max:c.min) );
- item_edited(col,p_item);
- } else if (p_button==BUTTON_WHEEL_UP) {
+ p_item->set_range(col, (up ? c.max : c.min));
+ item_edited(col, p_item);
+ } else if (p_button == BUTTON_WHEEL_UP) {
- p_item->set_range( col, c.val + c.step );
- item_edited(col,p_item);
- } else if (p_button==BUTTON_WHEEL_DOWN) {
+ p_item->set_range(col, c.val + c.step);
+ item_edited(col, p_item);
+ } else if (p_button == BUTTON_WHEEL_DOWN) {
- p_item->set_range( col, c.val - c.step );
- item_edited(col,p_item);
+ p_item->set_range(col, c.val - c.step);
+ item_edited(col, p_item);
}
//p_item->edited_signal.call(col);
- bring_up_editor=false;
-
-
- } else {
+ bring_up_editor = false;
- editor_text=String::num( p_item->cells[col].val, Math::step_decimals( p_item->cells[col].step ) );
- if (select_mode==SELECT_MULTI && get_tree()->get_last_event_id() == focus_in_id)
- bring_up_editor=false;
+ } else {
+ editor_text = String::num(p_item->cells[col].val, Math::step_decimals(p_item->cells[col].step));
+ if (select_mode == SELECT_MULTI && get_tree()->get_last_event_id() == focus_in_id)
+ bring_up_editor = false;
}
-
}
- click_handled=true;
+ click_handled = true;
} break;
case TreeItem::CELL_MODE_ICON: {
- bring_up_editor=false;
+ bring_up_editor = false;
} break;
case TreeItem::CELL_MODE_CUSTOM: {
- edited_item=p_item;
- edited_col=col;
- custom_popup_rect=Rect2i(get_global_pos() + Point2i(col_ofs,_get_title_button_height()+y_ofs+item_h-cache.offset.y), Size2(get_column_width(col),item_h));
- emit_signal("custom_popup_edited",((bool)(x >= (col_width-item_h/2))));
+ edited_item = p_item;
+ edited_col = col;
+ custom_popup_rect = Rect2i(get_global_pos() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h));
+ emit_signal("custom_popup_edited", ((bool)(x >= (col_width - item_h / 2))));
- bring_up_editor=false;
- item_edited(col,p_item);
- click_handled=true;
+ bring_up_editor = false;
+ item_edited(col, p_item);
+ click_handled = true;
return -1;
} break;
-
};
- if (!bring_up_editor || p_button!=BUTTON_LEFT)
+ if (!bring_up_editor || p_button != BUTTON_LEFT)
return -1;
+ click_handled = true;
+ popup_edited_item = p_item;
+ popup_edited_item_col = col;
-
- click_handled=true;
- popup_edited_item=p_item;
- popup_edited_item_col=col;
-
- pressing_item_rect=Rect2(get_global_pos() + Point2i(col_ofs,_get_title_button_height()+y_ofs)-cache.offset,Size2(col_width,item_h));
- pressing_for_editor_text=editor_text;
- pressing_for_editor=true;
+ pressing_item_rect = Rect2(get_global_pos() + Point2i(col_ofs, _get_title_button_height() + y_ofs) - cache.offset, Size2(col_width, item_h));
+ pressing_for_editor_text = editor_text;
+ pressing_for_editor = true;
return -1; //select
} else {
- Point2i new_pos=p_pos;
+ Point2i new_pos = p_pos;
if (!skip) {
- x_ofs+=cache.item_margin;
+ x_ofs += cache.item_margin;
//new_pos.x-=cache.item_margin;
- y_ofs+=item_h;
- new_pos.y-=item_h;
+ y_ofs += item_h;
+ new_pos.y -= item_h;
}
-
if (!p_item->collapsed) { /* if not collapsed, check the childs */
- TreeItem *c=p_item->childs;
+ TreeItem *c = p_item->childs;
while (c) {
- int child_h=propagate_mouse_event( new_pos,x_ofs,y_ofs,p_doubleclick,c,p_button,p_mod);
+ int child_h = propagate_mouse_event(new_pos, x_ofs, y_ofs, p_doubleclick, c, p_button, p_mod);
- if (child_h<0)
+ if (child_h < 0)
return -1; // break, stop propagating, no need to anymore
- new_pos.y-=child_h;
- y_ofs+=child_h;
- c=c->next;
- item_h+=child_h;
+ new_pos.y -= child_h;
+ y_ofs += child_h;
+ c = c->next;
+ item_h += child_h;
}
}
-
-
-
}
return item_h; // nothing found
-
}
-
void Tree::_text_editor_modal_close() {
- if ( Input::get_singleton()->is_key_pressed(KEY_ESCAPE) ||
- Input::get_singleton()->is_key_pressed(KEY_ENTER) ||
- Input::get_singleton()->is_key_pressed(KEY_RETURN) ) {
+ if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE) ||
+ Input::get_singleton()->is_key_pressed(KEY_ENTER) ||
+ Input::get_singleton()->is_key_pressed(KEY_RETURN)) {
return;
}
@@ -1855,52 +1728,49 @@ void Tree::_text_editor_modal_close() {
text_editor_enter(text_editor->get_text());
}
-
void Tree::text_editor_enter(String p_text) {
-
text_editor->hide();
value_editor->hide();
if (!popup_edited_item)
return;
- if (popup_edited_item_col<0 || popup_edited_item_col>columns.size())
+ if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size())
return;
- TreeItem::Cell &c=popup_edited_item->cells[popup_edited_item_col];
- switch( c.mode ) {
+ TreeItem::Cell &c = popup_edited_item->cells[popup_edited_item_col];
+ switch (c.mode) {
case TreeItem::CELL_MODE_STRING: {
- c.text=p_text;
+ c.text = p_text;
//popup_edited_item->edited_signal.call( popup_edited_item_col );
} break;
case TreeItem::CELL_MODE_RANGE: {
- c.val=p_text.to_double();
- if (c.step>0)
- c.val=Math::stepify(c.val,c.step);
- if (c.val<c.min)
- c.val=c.min;
- else if (c.val>c.max)
- c.val=c.max;
+ c.val = p_text.to_double();
+ if (c.step > 0)
+ c.val = Math::stepify(c.val, c.step);
+ if (c.val < c.min)
+ c.val = c.min;
+ else if (c.val > c.max)
+ c.val = c.max;
//popup_edited_item->edited_signal.call( popup_edited_item_col );
} break;
case TreeItem::CELL_MODE_RANGE_EXPRESSION: {
- if(evaluator)
- c.val=evaluator->eval(p_text);
+ if (evaluator)
+ c.val = evaluator->eval(p_text);
else
- c.val=p_text.to_double();
+ c.val = p_text.to_double();
} break;
- default: { ERR_FAIL(); }
+ default: { ERR_FAIL(); }
}
- item_edited(popup_edited_item_col,popup_edited_item);
+ item_edited(popup_edited_item_col, popup_edited_item);
update();
-
}
void Tree::value_editor_changed(double p_value) {
@@ -1912,9 +1782,9 @@ void Tree::value_editor_changed(double p_value) {
return;
}
- TreeItem::Cell &c=popup_edited_item->cells[popup_edited_item_col];
- c.val=p_value;
- item_edited(popup_edited_item_col,popup_edited_item);
+ TreeItem::Cell &c = popup_edited_item->cells[popup_edited_item_col];
+ c.val = p_value;
+ item_edited(popup_edited_item_col, popup_edited_item);
update();
}
@@ -1923,18 +1793,15 @@ void Tree::popup_select(int p_option) {
if (!popup_edited_item)
return;
- if (popup_edited_item_col<0 || popup_edited_item_col>columns.size())
+ if (popup_edited_item_col < 0 || popup_edited_item_col > columns.size())
return;
-
- popup_edited_item->cells[popup_edited_item_col].val=p_option;
+ popup_edited_item->cells[popup_edited_item_col].val = p_option;
//popup_edited_item->edited_signal.call( popup_edited_item_col );
update();
- item_edited(popup_edited_item_col,popup_edited_item);
+ item_edited(popup_edited_item_col, popup_edited_item);
}
-
-
void Tree::_input_event(InputEvent p_event) {
switch (p_event.type) {
@@ -1943,7 +1810,7 @@ void Tree::_input_event(InputEvent p_event) {
if (!p_event.key.pressed)
break;
- if (p_event.key.mod.alt || p_event.key.mod.command || (p_event.key.mod.shift && p_event.key.unicode==0) || p_event.key.mod.meta)
+ if (p_event.key.mod.alt || p_event.key.mod.command || (p_event.key.mod.shift && p_event.key.unicode == 0) || p_event.key.mod.meta)
break;
if (!root)
return;
@@ -1951,23 +1818,27 @@ void Tree::_input_event(InputEvent p_event) {
if (hide_root && !root->get_next_visible())
return;
- switch(p_event.key.scancode) {
-#define EXIT_BREAK { if (!cursor_can_exit_tree) accept_event(); break; }
+ switch (p_event.key.scancode) {
+#define EXIT_BREAK \
+ { \
+ if (!cursor_can_exit_tree) accept_event(); \
+ break; \
+ }
case KEY_RIGHT: {
//TreeItem *next = NULL;
if (!selected_item)
break;
- if (select_mode==SELECT_ROW)
+ if (select_mode == SELECT_ROW)
EXIT_BREAK;
- if (selected_col>=(columns.size()-1))
+ if (selected_col >= (columns.size() - 1))
EXIT_BREAK;
- if (select_mode==SELECT_MULTI) {
+ if (select_mode == SELECT_MULTI) {
selected_col++;
emit_signal("cell_selected");
} else {
- selected_item->select(selected_col+1);
+ selected_item->select(selected_col + 1);
}
update();
@@ -1977,19 +1848,19 @@ void Tree::_input_event(InputEvent p_event) {
} break;
case KEY_LEFT: {
-// TreeItem *next = NULL;
+ // TreeItem *next = NULL;
if (!selected_item)
break;
- if (select_mode==SELECT_ROW)
+ if (select_mode == SELECT_ROW)
EXIT_BREAK;
- if (selected_col<=0)
+ if (selected_col <= 0)
EXIT_BREAK;
- if (select_mode==SELECT_MULTI) {
+ if (select_mode == SELECT_MULTI) {
selected_col--;
emit_signal("cell_selected");
} else {
- selected_item->select(selected_col-1);
+ selected_item->select(selected_col - 1);
}
update();
@@ -2001,43 +1872,41 @@ void Tree::_input_event(InputEvent p_event) {
TreeItem *next = NULL;
if (!selected_item) {
- next=hide_root?root->get_next_visible():root;
- selected_item=0;
+ next = hide_root ? root->get_next_visible() : root;
+ selected_item = 0;
} else {
- next=selected_item->get_next_visible();
+ next = selected_item->get_next_visible();
-// if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) {
- if (last_keypress!=0) {
+ // if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) {
+ if (last_keypress != 0) {
//incr search next
int col;
- next=_search_item_text(next,incr_search,&col,true);
+ next = _search_item_text(next, incr_search, &col, true);
if (!next) {
accept_event();
return;
}
-
}
}
- if (select_mode==SELECT_MULTI) {
+ if (select_mode == SELECT_MULTI) {
if (!next)
EXIT_BREAK;
- selected_item=next;
+ selected_item = next;
emit_signal("cell_selected");
update();
} else {
- int col=selected_col<0?0:selected_col;
+ int col = selected_col < 0 ? 0 : selected_col;
while (next && !next->cells[col].selectable)
- next=next->get_next_visible();
+ next = next->get_next_visible();
if (!next)
EXIT_BREAK; // do nothing..
next->select(col);
-
}
ensure_cursor_is_visible();
@@ -2046,47 +1915,43 @@ void Tree::_input_event(InputEvent p_event) {
} break;
case KEY_UP: {
- TreeItem *prev = NULL;
- if (!selected_item) {
- prev = get_last_item();
- selected_col=0;
- } else {
-
- prev=selected_item->get_prev_visible();
- if (last_keypress!=0) {
- //incr search next
- int col;
- prev=_search_item_text(prev,incr_search,&col,true,true);
- if (!prev) {
- accept_event();
- return;
- }
+ TreeItem *prev = NULL;
+ if (!selected_item) {
+ prev = get_last_item();
+ selected_col = 0;
+ } else {
+ prev = selected_item->get_prev_visible();
+ if (last_keypress != 0) {
+ //incr search next
+ int col;
+ prev = _search_item_text(prev, incr_search, &col, true, true);
+ if (!prev) {
+ accept_event();
+ return;
}
-
}
+ }
- if (select_mode==SELECT_MULTI) {
-
-
- if (!prev)
- break;
- selected_item=prev;
- emit_signal("cell_selected");
- update();
- } else {
+ if (select_mode == SELECT_MULTI) {
- int col=selected_col<0?0:selected_col;
- while (prev && !prev->cells[col].selectable)
- prev=prev->get_prev_visible();
- if (!prev)
- break; // do nothing..
- prev->select(col);
+ if (!prev)
+ break;
+ selected_item = prev;
+ emit_signal("cell_selected");
+ update();
+ } else {
- }
+ int col = selected_col < 0 ? 0 : selected_col;
+ while (prev && !prev->cells[col].selectable)
+ prev = prev->get_prev_visible();
+ if (!prev)
+ break; // do nothing..
+ prev->select(col);
+ }
- ensure_cursor_is_visible();
- accept_event();
+ ensure_cursor_is_visible();
+ accept_event();
} break;
case KEY_PAGEDOWN: {
@@ -2094,73 +1959,69 @@ void Tree::_input_event(InputEvent p_event) {
TreeItem *next = NULL;
if (!selected_item)
break;
- next=selected_item;
+ next = selected_item;
- for(int i=0;i<10;i++) {
+ for (int i = 0; i < 10; i++) {
TreeItem *_n = next->get_next_visible();
if (_n) {
- next=_n;
+ next = _n;
} else {
break;
}
}
- if (next==selected_item)
+ if (next == selected_item)
break;
- if (select_mode==SELECT_MULTI) {
-
+ if (select_mode == SELECT_MULTI) {
- selected_item=next;
+ selected_item = next;
emit_signal("cell_selected");
update();
} else {
while (next && !next->cells[selected_col].selectable)
- next=next->get_next_visible();
+ next = next->get_next_visible();
if (!next)
EXIT_BREAK; // do nothing..
next->select(selected_col);
-
}
ensure_cursor_is_visible();
- } break;
+ } break;
case KEY_PAGEUP: {
TreeItem *prev = NULL;
if (!selected_item)
break;
- prev=selected_item;
+ prev = selected_item;
- for(int i=0;i<10;i++) {
+ for (int i = 0; i < 10; i++) {
TreeItem *_n = prev->get_prev_visible();
if (_n) {
- prev=_n;
+ prev = _n;
} else {
break;
}
}
- if (prev==selected_item)
+ if (prev == selected_item)
break;
- if (select_mode==SELECT_MULTI) {
+ if (select_mode == SELECT_MULTI) {
-
- selected_item=prev;
+ selected_item = prev;
emit_signal("cell_selected");
update();
} else {
while (prev && !prev->cells[selected_col].selectable)
- prev=prev->get_prev_visible();
+ prev = prev->get_prev_visible();
if (!prev)
EXIT_BREAK; // do nothing..
prev->select(selected_col);
-
}
ensure_cursor_is_visible();
@@ -2175,21 +2036,20 @@ void Tree::_input_event(InputEvent p_event) {
if (!edit_selected()) {
emit_signal("item_activated");
}
-
}
accept_event();
} break;
case KEY_SPACE: {
- if (select_mode==SELECT_MULTI) {
+ if (select_mode == SELECT_MULTI) {
if (!selected_item)
break;
if (selected_item->is_selected(selected_col)) {
selected_item->deselect(selected_col);
- emit_signal("multi_selected",selected_item,selected_col,false);
+ emit_signal("multi_selected", selected_item, selected_col, false);
} else if (selected_item->is_selectable(selected_col)) {
selected_item->select(selected_col);
- emit_signal("multi_selected",selected_item,selected_col,true);
+ emit_signal("multi_selected", selected_item, selected_col, true);
}
}
accept_event();
@@ -2197,19 +2057,19 @@ void Tree::_input_event(InputEvent p_event) {
} break;
default: {
- if (p_event.key.unicode>0) {
+ if (p_event.key.unicode > 0) {
_do_incr_search(String::chr(p_event.key.unicode));
accept_event();
return;
} else {
- if (p_event.key.scancode!=KEY_SHIFT)
- last_keypress=0;
+ if (p_event.key.scancode != KEY_SHIFT)
+ last_keypress = 0;
}
} break;
- last_keypress=0;
+ last_keypress = 0;
}
} break;
@@ -2218,119 +2078,107 @@ void Tree::_input_event(InputEvent p_event) {
if (cache.font.is_null()) // avoid a strange case that may fuckup stuff
update_cache();
- const InputEventMouseMotion& b=p_event.mouse_motion;
+ const InputEventMouseMotion &b = p_event.mouse_motion;
Ref<StyleBox> bg = cache.bg;
- Point2 pos = Point2(b.x,b.y) - bg->get_offset();
+ Point2 pos = Point2(b.x, b.y) - bg->get_offset();
Cache::ClickType old_hover = cache.hover_type;
int old_index = cache.hover_index;
- cache.hover_type=Cache::CLICK_NONE;
- cache.hover_index=0;
+ cache.hover_type = Cache::CLICK_NONE;
+ cache.hover_index = 0;
if (show_column_titles) {
- pos.y-=_get_title_button_height();
- if (pos.y<0) {
- pos.x+=cache.offset.x;
- int len=0;
- for(int i=0;i<columns.size();i++) {
+ pos.y -= _get_title_button_height();
+ if (pos.y < 0) {
+ pos.x += cache.offset.x;
+ int len = 0;
+ for (int i = 0; i < columns.size(); i++) {
- len+=get_column_width(i);
- if (pos.x<len) {
+ len += get_column_width(i);
+ if (pos.x < len) {
- cache.hover_type=Cache::CLICK_TITLE;
- cache.hover_index=i;
+ cache.hover_type = Cache::CLICK_TITLE;
+ cache.hover_index = i;
update();
break;
}
}
-
}
-
}
if (drop_mode_flags && root) {
- Point2 mpos=Point2(b.x,b.y);
+ Point2 mpos = Point2(b.x, b.y);
mpos -= cache.bg->get_offset();
- mpos.y-=_get_title_button_height();
- if (mpos.y>=0) {
+ mpos.y -= _get_title_button_height();
+ if (mpos.y >= 0) {
if (h_scroll->is_visible())
- mpos.x+=h_scroll->get_val();
+ mpos.x += h_scroll->get_val();
if (v_scroll->is_visible())
- mpos.y+=v_scroll->get_val();
+ mpos.y += v_scroll->get_val();
- int col,h,section;
- TreeItem *it = _find_item_at_pos(root,mpos,col,h,section);
+ int col, h, section;
+ TreeItem *it = _find_item_at_pos(root, mpos, col, h, section);
- if (it!=drop_mode_over || section!=drop_mode_section) {
- drop_mode_over=it;
- drop_mode_section=section;
+ if (it != drop_mode_over || section != drop_mode_section) {
+ drop_mode_over = it;
+ drop_mode_section = section;
update();
}
}
}
-
-
- if (cache.hover_type!=old_hover || cache.hover_index!=old_index) {
+ if (cache.hover_type != old_hover || cache.hover_index != old_index) {
update();
}
- if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col)==TreeItem::CELL_MODE_RANGE || popup_edited_item->get_cell_mode(popup_edited_item_col)==TreeItem::CELL_MODE_RANGE_EXPRESSION)) {
+ if (pressing_for_editor && popup_edited_item && (popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE || popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_RANGE_EXPRESSION)) {
//range drag
if (!range_drag_enabled) {
- Vector2 cpos = Vector2(b.x,b.y);
- if (cpos.distance_to(pressing_pos)>2) {
- range_drag_enabled=true;
- range_drag_capture_pos=cpos;
- range_drag_base=popup_edited_item->get_range(popup_edited_item_col);
+ Vector2 cpos = Vector2(b.x, b.y);
+ if (cpos.distance_to(pressing_pos) > 2) {
+ range_drag_enabled = true;
+ range_drag_capture_pos = cpos;
+ range_drag_base = popup_edited_item->get_range(popup_edited_item_col);
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
}
} else {
- TreeItem::Cell &c=popup_edited_item->cells[popup_edited_item_col];
+ TreeItem::Cell &c = popup_edited_item->cells[popup_edited_item_col];
float diff_y = -b.relative_y;
- diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y);
- diff_y*=0.1;
- range_drag_base=CLAMP(range_drag_base + c.step * diff_y, c.min, c.max);
- popup_edited_item->set_range(popup_edited_item_col,range_drag_base);
- item_edited(popup_edited_item_col,popup_edited_item);
-
+ diff_y = Math::pow(ABS(diff_y), 1.8) * SGN(diff_y);
+ diff_y *= 0.1;
+ range_drag_base = CLAMP(range_drag_base + c.step * diff_y, c.min, c.max);
+ popup_edited_item->set_range(popup_edited_item_col, range_drag_base);
+ item_edited(popup_edited_item_col, popup_edited_item);
}
-
}
- if (drag_touching && ! drag_touching_deaccel) {
-
-
- drag_accum-=b.relative_y;
- v_scroll->set_val(drag_from+drag_accum);
- drag_speed=-b.speed_y;
+ if (drag_touching && !drag_touching_deaccel) {
+ drag_accum -= b.relative_y;
+ v_scroll->set_val(drag_from + drag_accum);
+ drag_speed = -b.speed_y;
}
} break;
case InputEvent::MOUSE_BUTTON: {
-
-
if (cache.font.is_null()) // avoid a strange case that may fuckup stuff
update_cache();
- const InputEventMouseButton& b=p_event.mouse_button;
-
+ const InputEventMouseButton &b = p_event.mouse_button;
if (!b.pressed) {
- if (b.button_index==BUTTON_LEFT) {
-
+ if (b.button_index == BUTTON_LEFT) {
if (single_select_defer) {
- select_single_item( single_select_defer, root, single_select_defer_column );
- single_select_defer=NULL;
+ select_single_item(single_select_defer, root, single_select_defer_column);
+ single_select_defer = NULL;
}
range_click_timer->stop();
@@ -2339,72 +2187,65 @@ void Tree::_input_event(InputEvent p_event) {
if (range_drag_enabled) {
- range_drag_enabled=false;
+ range_drag_enabled = false;
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
} else
edit_selected();
- pressing_for_editor=false;
-
+ pressing_for_editor = false;
}
-
-
- if (cache.click_type==Cache::CLICK_BUTTON) {
+ if (cache.click_type == Cache::CLICK_BUTTON) {
// make sure in case of wrong reference after reconstructing whole TreeItems
- cache.click_item=get_item_at_pos(cache.click_pos);
- emit_signal("button_pressed",cache.click_item,cache.click_column,cache.click_id);
-
+ cache.click_item = get_item_at_pos(cache.click_pos);
+ emit_signal("button_pressed", cache.click_item, cache.click_column, cache.click_id);
}
- cache.click_type=Cache::CLICK_NONE;
- cache.click_index=-1;
- cache.click_id=-1;
- cache.click_item=NULL;
- cache.click_column=0;
+ cache.click_type = Cache::CLICK_NONE;
+ cache.click_index = -1;
+ cache.click_id = -1;
+ cache.click_item = NULL;
+ cache.click_column = 0;
if (drag_touching) {
-
- if (drag_speed==0) {
- drag_touching_deaccel=false;
- drag_touching=false;
+ if (drag_speed == 0) {
+ drag_touching_deaccel = false;
+ drag_touching = false;
set_fixed_process(false);
} else {
- drag_touching_deaccel=true;
+ drag_touching_deaccel = true;
}
-
}
update();
}
break;
-
}
if (range_drag_enabled)
break;
- switch(b.button_index) {
+ switch (b.button_index) {
case BUTTON_RIGHT:
case BUTTON_LEFT: {
Ref<StyleBox> bg = cache.bg;
- Point2 pos = Point2(b.x,b.y) - bg->get_offset();
- cache.click_type=Cache::CLICK_NONE;
- if (show_column_titles && b.button_index==BUTTON_LEFT) {
- pos.y-=_get_title_button_height();
+ Point2 pos = Point2(b.x, b.y) - bg->get_offset();
+ cache.click_type = Cache::CLICK_NONE;
+ if (show_column_titles && b.button_index == BUTTON_LEFT) {
+ pos.y -= _get_title_button_height();
- if (pos.y<0) {
- pos.x+=cache.offset.x;
- int len=0;
- for(int i=0;i<columns.size();i++) {
+ if (pos.y < 0) {
+ pos.x += cache.offset.x;
+ int len = 0;
+ for (int i = 0; i < columns.size(); i++) {
- len+=get_column_width(i);
- if (pos.x<len) {
+ len += get_column_width(i);
+ if (pos.x < len) {
- cache.click_type=Cache::CLICK_TITLE;
- cache.click_index=i;
+ cache.click_type = Cache::CLICK_TITLE;
+ cache.click_index = i;
//cache.click_id=;
update();
break;
@@ -2412,140 +2253,134 @@ void Tree::_input_event(InputEvent p_event) {
}
break;
}
-
}
if (!root || (!root->get_children() && hide_root)) {
- if (b.button_index==BUTTON_RIGHT && allow_rmb_select) {
- emit_signal("empty_tree_rmb_selected",get_local_mouse_pos());
+ if (b.button_index == BUTTON_RIGHT && allow_rmb_select) {
+ emit_signal("empty_tree_rmb_selected", get_local_mouse_pos());
}
break;
}
- click_handled=false;
- pressing_for_editor=false;
+ click_handled = false;
+ pressing_for_editor = false;
blocked++;
- bool handled = propagate_mouse_event(pos+cache.offset,0,0,b.doubleclick,root,b.button_index,b.mod);
+ bool handled = propagate_mouse_event(pos + cache.offset, 0, 0, b.doubleclick, root, b.button_index, b.mod);
blocked--;
if (pressing_for_editor) {
- pressing_pos=Point2(b.x,b.y);
+ pressing_pos = Point2(b.x, b.y);
}
-
- if (b.button_index==BUTTON_RIGHT)
+ if (b.button_index == BUTTON_RIGHT)
break;
if (drag_touching) {
set_fixed_process(false);
- drag_touching_deaccel=false;
- drag_touching=false;
- drag_speed=0;
- drag_from=0;
+ drag_touching_deaccel = false;
+ drag_touching = false;
+ drag_speed = 0;
+ drag_from = 0;
}
if (!click_handled) {
- drag_speed=0;
- drag_accum=0;
-// last_drag_accum=0;
- drag_from=v_scroll->get_val();
- drag_touching=OS::get_singleton()->has_touchscreen_ui_hint();
- drag_touching_deaccel=false;
+ drag_speed = 0;
+ drag_accum = 0;
+ // last_drag_accum=0;
+ drag_from = v_scroll->get_val();
+ drag_touching = OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_touching_deaccel = false;
if (drag_touching) {
set_fixed_process(true);
}
}
-
} break;
case BUTTON_WHEEL_UP: {
- v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 );
+ v_scroll->set_val(v_scroll->get_val() - v_scroll->get_page() / 8);
} break;
case BUTTON_WHEEL_DOWN: {
- v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 );
+ v_scroll->set_val(v_scroll->get_val() + v_scroll->get_page() / 8);
} break;
}
} break;
}
-
}
-
bool Tree::edit_selected() {
TreeItem *s = get_selected();
ERR_EXPLAIN("No item selected!");
- ERR_FAIL_COND_V(!s,false);
+ ERR_FAIL_COND_V(!s, false);
ensure_cursor_is_visible();
int col = get_selected_column();
ERR_EXPLAIN("No item column selected!");
- ERR_FAIL_INDEX_V(col,columns.size(),false);
+ ERR_FAIL_INDEX_V(col, columns.size(), false);
if (!s->cells[col].editable)
return false;
Rect2 rect = s->get_meta("__focus_rect");
- popup_edited_item=s;
- popup_edited_item_col=col;
+ popup_edited_item = s;
+ popup_edited_item_col = col;
TreeItem::Cell &c = s->cells[col];
- if (c.mode==TreeItem::CELL_MODE_CHECK) {
+ if (c.mode == TreeItem::CELL_MODE_CHECK) {
s->set_checked(col, !c.checked);
- item_edited(col,s);
+ item_edited(col, s);
return true;
- } else if (c.mode==TreeItem::CELL_MODE_CUSTOM) {
+ } else if (c.mode == TreeItem::CELL_MODE_CUSTOM) {
- edited_item=s;
- edited_col=col;
- custom_popup_rect=Rect2i( get_global_pos() + rect.pos, rect.size );
- emit_signal("custom_popup_edited",false);
- item_edited(col,s);
+ edited_item = s;
+ edited_col = col;
+ custom_popup_rect = Rect2i(get_global_pos() + rect.pos, rect.size);
+ emit_signal("custom_popup_edited", false);
+ item_edited(col, s);
return true;
- } else if ((c.mode==TreeItem::CELL_MODE_RANGE||c.mode==TreeItem::CELL_MODE_RANGE_EXPRESSION) && c.text!="") {
+ } else if ((c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) && c.text != "") {
popup_menu->clear();
- for (int i=0;i<c.text.get_slice_count(",");i++) {
-
- String s = c.text.get_slicec(',',i);
- popup_menu->add_item(s,i);
+ for (int i = 0; i < c.text.get_slice_count(","); i++) {
+ String s = c.text.get_slicec(',', i);
+ popup_menu->add_item(s, i);
}
- popup_menu->set_size(Size2(rect.size.width,0));
- popup_menu->set_pos( get_global_pos() + rect.pos + Point2i(0,rect.size.height) );
+ popup_menu->set_size(Size2(rect.size.width, 0));
+ popup_menu->set_pos(get_global_pos() + rect.pos + Point2i(0, rect.size.height));
popup_menu->popup();
- popup_edited_item=s;
- popup_edited_item_col=col;
+ popup_edited_item = s;
+ popup_edited_item_col = col;
return true;
- } else if (c.mode==TreeItem::CELL_MODE_STRING || c.mode==TreeItem::CELL_MODE_RANGE || c.mode==TreeItem::CELL_MODE_RANGE_EXPRESSION ) {
+ } else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
- Point2i textedpos=get_global_pos() + rect.pos;
- text_editor->set_pos( textedpos );
- text_editor->set_size( rect.size);
+ Point2i textedpos = get_global_pos() + rect.pos;
+ text_editor->set_pos(textedpos);
+ text_editor->set_size(rect.size);
text_editor->clear();
- text_editor->set_text( c.mode==TreeItem::CELL_MODE_STRING?c.text:String::num( c.val, Math::step_decimals( c.step ) ) );
+ text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::step_decimals(c.step)));
text_editor->select_all();
- if (c.mode==TreeItem::CELL_MODE_RANGE || c.mode==TreeItem::CELL_MODE_RANGE_EXPRESSION ) {
+ if (c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
- value_editor->set_pos(textedpos + Point2i(0,text_editor->get_size().height) );
- value_editor->set_size( Size2(rect.size.width,1));
+ value_editor->set_pos(textedpos + Point2i(0, text_editor->get_size().height));
+ value_editor->set_size(Size2(rect.size.width, 1));
value_editor->show_modal();
- updating_value_editor=true;
- value_editor->set_min( c.min );
- value_editor->set_max( c.max );
- value_editor->set_step( c.step );
- value_editor->set_val( c.val );
- value_editor->set_exp_unit_value( c.expr );
- updating_value_editor=false;
+ updating_value_editor = true;
+ value_editor->set_min(c.min);
+ value_editor->set_max(c.max);
+ value_editor->set_step(c.step);
+ value_editor->set_val(c.val);
+ value_editor->set_exp_unit_value(c.expr);
+ updating_value_editor = false;
}
text_editor->show_modal();
@@ -2558,12 +2393,12 @@ bool Tree::edit_selected() {
Size2 Tree::get_internal_min_size() const {
- Size2i size=cache.bg->get_offset();
+ Size2i size = cache.bg->get_offset();
if (root)
- size.height+=get_item_height(root);
- for (int i=0;i<columns.size();i++) {
+ size.height += get_item_height(root);
+ for (int i = 0; i < columns.size(); i++) {
- size.width+=columns[i].min_width;
+ size.width += columns[i].min_width;
}
return size;
@@ -2574,140 +2409,133 @@ void Tree::update_scrollbars() {
Size2 size = get_size();
int tbh;
if (show_column_titles) {
- tbh=_get_title_button_height();
+ tbh = _get_title_button_height();
} else {
- tbh=0;
+ tbh = 0;
}
Size2 hmin = h_scroll->get_combined_minimum_size();
Size2 vmin = v_scroll->get_combined_minimum_size();
+ v_scroll->set_begin(Point2(size.width - vmin.width, cache.bg->get_margin(MARGIN_TOP)));
+ v_scroll->set_end(Point2(size.width, size.height - cache.bg->get_margin(MARGIN_TOP) - cache.bg->get_margin(MARGIN_BOTTOM)));
-
- v_scroll->set_begin( Point2(size.width - vmin.width , cache.bg->get_margin(MARGIN_TOP)) );
- v_scroll->set_end( Point2(size.width, size.height-cache.bg->get_margin(MARGIN_TOP)-cache.bg->get_margin(MARGIN_BOTTOM)) );
-
- h_scroll->set_begin( Point2( 0, size.height - hmin.height) );
- h_scroll->set_end( Point2(size.width-vmin.width, size.height) );
-
+ h_scroll->set_begin(Point2(0, size.height - hmin.height));
+ h_scroll->set_end(Point2(size.width - vmin.width, size.height));
Size2 min = get_internal_min_size();
if (min.height < size.height - hmin.height) {
v_scroll->hide();
- cache.offset.y=0;
+ cache.offset.y = 0;
} else {
v_scroll->show();
v_scroll->set_max(min.height);
v_scroll->set_page(size.height - hmin.height - tbh);
- cache.offset.y=v_scroll->get_val();
+ cache.offset.y = v_scroll->get_val();
}
if (min.width < size.width - vmin.width) {
h_scroll->hide();
- cache.offset.x=0;
+ cache.offset.x = 0;
} else {
h_scroll->show();
h_scroll->set_max(min.width);
h_scroll->set_page(size.width - vmin.width);
- cache.offset.x=h_scroll->get_val();
+ cache.offset.x = h_scroll->get_val();
}
}
-
int Tree::_get_title_button_height() const {
- return show_column_titles?cache.font->get_height() + cache.title_button->get_minimum_size().height:0;
+ return show_column_titles ? cache.font->get_height() + cache.title_button->get_minimum_size().height : 0;
}
void Tree::_notification(int p_what) {
- if (p_what==NOTIFICATION_FOCUS_ENTER) {
+ if (p_what == NOTIFICATION_FOCUS_ENTER) {
- focus_in_id=get_tree()->get_last_event_id();
+ focus_in_id = get_tree()->get_last_event_id();
}
- if (p_what==NOTIFICATION_MOUSE_EXIT) {
+ if (p_what == NOTIFICATION_MOUSE_EXIT) {
- if (cache.hover_type!=Cache::CLICK_NONE) {
- cache.hover_type=Cache::CLICK_NONE;
+ if (cache.hover_type != Cache::CLICK_NONE) {
+ cache.hover_type = Cache::CLICK_NONE;
update();
}
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
- drag_touching=false;
+ drag_touching = false;
}
- if (p_what==NOTIFICATION_ENTER_TREE) {
+ if (p_what == NOTIFICATION_ENTER_TREE) {
update_cache();
}
- if (p_what==NOTIFICATION_DRAG_END) {
+ if (p_what == NOTIFICATION_DRAG_END) {
- drop_mode_flags=0;
+ drop_mode_flags = 0;
scrolling = false;
set_fixed_process(false);
update();
}
- if (p_what==NOTIFICATION_DRAG_BEGIN) {
+ if (p_what == NOTIFICATION_DRAG_BEGIN) {
- single_select_defer=NULL;
+ single_select_defer = NULL;
if (cache.scroll_speed > 0 && get_rect().has_point(get_viewport()->get_mouse_pos() - get_global_pos())) {
scrolling = true;
set_fixed_process(true);
}
}
- if (p_what==NOTIFICATION_FIXED_PROCESS) {
+ if (p_what == NOTIFICATION_FIXED_PROCESS) {
- if (drag_touching) {
+ if (drag_touching) {
if (drag_touching_deaccel) {
float pos = v_scroll->get_val();
- pos+=drag_speed*get_fixed_process_delta_time();
+ pos += drag_speed * get_fixed_process_delta_time();
- bool turnoff=false;
- if (pos<0) {
- pos=0;
- turnoff=true;
+ bool turnoff = false;
+ if (pos < 0) {
+ pos = 0;
+ turnoff = true;
set_fixed_process(false);
- drag_touching=false;
- drag_touching_deaccel=false;
+ drag_touching = false;
+ drag_touching_deaccel = false;
}
- if (pos > (v_scroll->get_max()-v_scroll->get_page())) {
- pos=v_scroll->get_max()-v_scroll->get_page();
- turnoff=true;
-
+ if (pos > (v_scroll->get_max() - v_scroll->get_page())) {
+ pos = v_scroll->get_max() - v_scroll->get_page();
+ turnoff = true;
}
v_scroll->set_val(pos);
- float sgn = drag_speed<0? -1 : 1;
+ float sgn = drag_speed < 0 ? -1 : 1;
float val = Math::abs(drag_speed);
- val-=1000*get_fixed_process_delta_time();
+ val -= 1000 * get_fixed_process_delta_time();
- if (val<0) {
- turnoff=true;
+ if (val < 0) {
+ turnoff = true;
}
- drag_speed=sgn*val;
+ drag_speed = sgn * val;
if (turnoff) {
set_fixed_process(false);
- drag_touching=false;
- drag_touching_deaccel=false;
+ drag_touching = false;
+ drag_touching_deaccel = false;
}
-
} else {
-
}
}
-
+
if (scrolling) {
Point2 point = get_viewport()->get_mouse_pos() - get_global_pos();
if (point.x < cache.scroll_border) {
@@ -2731,140 +2559,132 @@ void Tree::_notification(int p_what) {
}
}
- if (p_what==NOTIFICATION_DRAW) {
+ if (p_what == NOTIFICATION_DRAW) {
update_cache();
update_scrollbars();
RID ci = get_canvas_item();
- VisualServer::get_singleton()->canvas_item_set_clip(ci,true);
+ VisualServer::get_singleton()->canvas_item_set_clip(ci, true);
Ref<StyleBox> bg = cache.bg;
Ref<StyleBox> bg_focus = get_stylebox("bg_focus");
Point2 draw_ofs;
- draw_ofs+=bg->get_offset();
- Size2 draw_size=get_size()-bg->get_minimum_size();
+ draw_ofs += bg->get_offset();
+ Size2 draw_size = get_size() - bg->get_minimum_size();
- bg->draw( ci, Rect2( Point2(), get_size()) );
+ bg->draw(ci, Rect2(Point2(), get_size()));
if (has_focus()) {
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,true);
- bg_focus->draw( ci, Rect2( Point2(), get_size()) );
- VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,false);
+ VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true);
+ bg_focus->draw(ci, Rect2(Point2(), get_size()));
+ VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, false);
}
int tbh = _get_title_button_height();
- draw_ofs.y+=tbh;
- draw_size.y-=tbh;
+ draw_ofs.y += tbh;
+ draw_size.y -= tbh;
if (root) {
-
- draw_item( Point2(),draw_ofs,draw_size,root);
-
+ draw_item(Point2(), draw_ofs, draw_size, root);
}
- int ofs=0;
-// int from_y=exposed.pos.y+bg->get_margin(MARGIN_TOP);
-// int size_y=exposed.size.height-bg->get_minimum_size().height;
+ int ofs = 0;
+ // int from_y=exposed.pos.y+bg->get_margin(MARGIN_TOP);
+ // int size_y=exposed.size.height-bg->get_minimum_size().height;
- for (int i=0;i<(columns.size()-1-1);i++) {
+ for (int i = 0; i < (columns.size() - 1 - 1); i++) {
- ofs+=get_column_width(i);
+ ofs += get_column_width(i);
//get_painter()->draw_fill_rect( Point2(ofs+cache.hseparation/2, from_y), Size2( 1, size_y ),color( COLOR_TREE_GRID) );
}
if (show_column_titles) {
//title butons
- int ofs=cache.bg->get_margin(MARGIN_LEFT);
- for(int i=0;i<columns.size();i++) {
+ int ofs = cache.bg->get_margin(MARGIN_LEFT);
+ for (int i = 0; i < columns.size(); i++) {
- Ref<StyleBox> sb = (cache.click_type==Cache::CLICK_TITLE && cache.click_index==i)?cache.title_button_pressed:((cache.hover_type==Cache::CLICK_TITLE && cache.hover_index==i)?cache.title_button_hover:cache.title_button);
+ Ref<StyleBox> sb = (cache.click_type == Cache::CLICK_TITLE && cache.click_index == i) ? cache.title_button_pressed : ((cache.hover_type == Cache::CLICK_TITLE && cache.hover_index == i) ? cache.title_button_hover : cache.title_button);
Ref<Font> f = cache.tb_font;
- Rect2 tbrect = Rect2(ofs - cache.offset.x,bg->get_margin(MARGIN_TOP),get_column_width(i),tbh);
- sb->draw(ci,tbrect);
- ofs+=tbrect.size.width;
+ Rect2 tbrect = Rect2(ofs - cache.offset.x, bg->get_margin(MARGIN_TOP), get_column_width(i), tbh);
+ sb->draw(ci, tbrect);
+ ofs += tbrect.size.width;
//text
int clip_w = tbrect.size.width - sb->get_minimum_size().width;
- f->draw_halign(ci,tbrect.pos+Point2i(sb->get_offset().x,(tbrect.size.height-f->get_height())/2+f->get_ascent()),HALIGN_CENTER,clip_w,columns[i].title,cache.title_button_color);
+ f->draw_halign(ci, tbrect.pos + Point2i(sb->get_offset().x, (tbrect.size.height - f->get_height()) / 2 + f->get_ascent()), HALIGN_CENTER, clip_w, columns[i].title, cache.title_button_color);
}
}
}
- if (p_what==NOTIFICATION_THEME_CHANGED) {
+ if (p_what == NOTIFICATION_THEME_CHANGED) {
update_cache();
}
-
}
-
-
-
Size2 Tree::get_minimum_size() const {
- return Size2(1,1);
+ return Size2(1, 1);
}
TreeItem *Tree::create_item(TreeItem *p_parent) {
- ERR_FAIL_COND_V(blocked>0,NULL);
+ ERR_FAIL_COND_V(blocked > 0, NULL);
- TreeItem *ti = memnew( TreeItem(this) );
+ TreeItem *ti = memnew(TreeItem(this));
- ti->cells.resize( columns.size() );
- ERR_FAIL_COND_V(!ti,NULL);
+ ti->cells.resize(columns.size());
+ ERR_FAIL_COND_V(!ti, NULL);
if (p_parent) {
/* Always append at the end */
- TreeItem *last=0;
- TreeItem *c=p_parent->childs;
+ TreeItem *last = 0;
+ TreeItem *c = p_parent->childs;
- while(c) {
+ while (c) {
- last=c;
- c=c->next;
+ last = c;
+ c = c->next;
}
if (last) {
- last->next=ti;
+ last->next = ti;
} else {
- p_parent->childs=ti;
+ p_parent->childs = ti;
}
- ti->parent=p_parent;
+ ti->parent = p_parent;
} else {
if (root)
- ti->childs=root;
-
- root=ti;
+ ti->childs = root;
+ root = ti;
}
-
return ti;
}
-TreeItem* Tree::get_root() {
+TreeItem *Tree::get_root() {
return root;
}
-TreeItem* Tree::get_last_item() {
+TreeItem *Tree::get_last_item() {
- TreeItem *last=root;
+ TreeItem *last = root;
- while(last) {
+ while (last) {
if (last->next)
- last=last->next;
+ last = last->next;
else if (last->childs)
- last=last->childs;
+ last = last->childs;
else
break;
}
@@ -2872,54 +2692,52 @@ TreeItem* Tree::get_last_item() {
return last;
}
-void Tree::item_edited(int p_column,TreeItem *p_item) {
+void Tree::item_edited(int p_column, TreeItem *p_item) {
- edited_item=p_item;
- edited_col=p_column;
+ edited_item = p_item;
+ edited_col = p_column;
emit_signal("item_edited");
}
-void Tree::item_changed(int p_column,TreeItem *p_item) {
+void Tree::item_changed(int p_column, TreeItem *p_item) {
update();
}
-void Tree::item_selected(int p_column,TreeItem *p_item) {
+void Tree::item_selected(int p_column, TreeItem *p_item) {
-
- if (select_mode==SELECT_MULTI) {
+ if (select_mode == SELECT_MULTI) {
if (!p_item->cells[p_column].selectable)
return;
- p_item->cells[p_column].selected=true;
+ p_item->cells[p_column].selected = true;
//emit_signal("multi_selected",p_item,p_column,true); - NO this is for TreeItem::select
} else {
- select_single_item(p_item,root,p_column);
+ select_single_item(p_item, root, p_column);
}
update();
}
-void Tree::item_deselected(int p_column,TreeItem *p_item) {
+void Tree::item_deselected(int p_column, TreeItem *p_item) {
- if (select_mode==SELECT_MULTI || select_mode == SELECT_SINGLE) {
- p_item->cells[p_column].selected=false;
+ if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) {
+ p_item->cells[p_column].selected = false;
}
update();
}
-
void Tree::set_select_mode(SelectMode p_mode) {
- select_mode=p_mode;
+ select_mode = p_mode;
}
void Tree::clear() {
- if (blocked>0) {
+ if (blocked > 0) {
- ERR_FAIL_COND(blocked>0);
+ ERR_FAIL_COND(blocked > 0);
}
if (pressing_for_editor) {
@@ -2932,43 +2750,37 @@ void Tree::clear() {
}
if (root) {
- memdelete( root );
+ memdelete(root);
root = NULL;
};
- selected_item=NULL;
- edited_item=NULL;
- popup_edited_item=NULL;
+ selected_item = NULL;
+ edited_item = NULL;
+ popup_edited_item = NULL;
update();
};
-
-
void Tree::set_hide_root(bool p_enabled) {
-
-
- hide_root=p_enabled;
+ hide_root = p_enabled;
update();
}
-void Tree::set_column_min_width(int p_column,int p_min_width) {
+void Tree::set_column_min_width(int p_column, int p_min_width) {
+ ERR_FAIL_INDEX(p_column, columns.size());
- ERR_FAIL_INDEX(p_column,columns.size());
-
- if (p_min_width<1)
+ if (p_min_width < 1)
return;
- columns[p_column].min_width=p_min_width;
+ columns[p_column].min_width = p_min_width;
update();
-
}
-void Tree::set_column_expand(int p_column,bool p_expand) {
+void Tree::set_column_expand(int p_column, bool p_expand) {
- ERR_FAIL_INDEX(p_column,columns.size());
+ ERR_FAIL_INDEX(p_column, columns.size());
- columns[p_column].expand=p_expand;
+ columns[p_column].expand = p_expand;
update();
}
@@ -2992,42 +2804,40 @@ int Tree::get_edited_column() const {
return edited_col;
}
-TreeItem* Tree::get_next_selected( TreeItem* p_item) {
+TreeItem *Tree::get_next_selected(TreeItem *p_item) {
//if (!p_item)
// return NULL;
if (!root)
return NULL;
- while(true) {
-
+ while (true) {
if (!p_item) {
- p_item=root;
+ p_item = root;
} else {
if (p_item->childs) {
- p_item=p_item->childs;
+ p_item = p_item->childs;
} else if (p_item->next) {
- p_item=p_item->next;
+ p_item = p_item->next;
} else {
- while(!p_item->next) {
+ while (!p_item->next) {
- p_item=p_item->parent;
- if (p_item==NULL)
+ p_item = p_item->parent;
+ if (p_item == NULL)
return NULL;
}
- p_item=p_item->next;
+ p_item = p_item->next;
}
-
}
- for (int i=0;i<columns.size();i++)
+ for (int i = 0; i < columns.size(); i++)
if (p_item->cells[i].selected)
return p_item;
}
@@ -3037,64 +2847,62 @@ TreeItem* Tree::get_next_selected( TreeItem* p_item) {
int Tree::get_column_width(int p_column) const {
- ERR_FAIL_INDEX_V(p_column,columns.size(),-1);
-
+ ERR_FAIL_INDEX_V(p_column, columns.size(), -1);
if (!columns[p_column].expand)
return columns[p_column].min_width;
Ref<StyleBox> bg = cache.bg;
- int expand_area=get_size().width-(bg->get_margin(MARGIN_LEFT)+bg->get_margin(MARGIN_RIGHT));
+ int expand_area = get_size().width - (bg->get_margin(MARGIN_LEFT) + bg->get_margin(MARGIN_RIGHT));
if (v_scroll->is_visible())
- expand_area-=v_scroll->get_combined_minimum_size().width;
+ expand_area -= v_scroll->get_combined_minimum_size().width;
- int expanding_columns=0;
- int expanding_total=0;
+ int expanding_columns = 0;
+ int expanding_total = 0;
- for (int i=0;i<columns.size();i++) {
+ for (int i = 0; i < columns.size(); i++) {
if (!columns[i].expand) {
- expand_area-=columns[i].min_width;
+ expand_area -= columns[i].min_width;
} else {
- expanding_total+=columns[i].min_width;
+ expanding_total += columns[i].min_width;
expanding_columns++;
}
}
- if (expand_area<expanding_total)
+ if (expand_area < expanding_total)
return columns[p_column].min_width;
- ERR_FAIL_COND_V(expanding_columns==0,-1); // shouldnt happen
+ ERR_FAIL_COND_V(expanding_columns == 0, -1); // shouldnt happen
return expand_area * columns[p_column].min_width / expanding_total;
}
void Tree::propagate_set_columns(TreeItem *p_item) {
- p_item->cells.resize( columns.size() );
+ p_item->cells.resize(columns.size());
TreeItem *c = p_item->get_children();
- while(c) {
+ while (c) {
propagate_set_columns(c);
- c=c->get_next();
+ c = c->get_next();
}
}
void Tree::set_columns(int p_columns) {
- ERR_FAIL_COND(p_columns<1);
- ERR_FAIL_COND(blocked>0);
+ ERR_FAIL_COND(p_columns < 1);
+ ERR_FAIL_COND(blocked > 0);
columns.resize(p_columns);
if (root)
propagate_set_columns(root);
- if (selected_col>=p_columns)
- selected_col=p_columns-1;
+ if (selected_col >= p_columns)
+ selected_col = p_columns - 1;
update();
-
}
int Tree::get_columns() const {
@@ -3114,35 +2922,35 @@ Rect2 Tree::get_custom_popup_rect() const {
int Tree::get_item_offset(TreeItem *p_item) const {
- TreeItem *it=root;
- int ofs=_get_title_button_height();
+ TreeItem *it = root;
+ int ofs = _get_title_button_height();
if (!it)
return 0;
- while(true) {
+ while (true) {
- if (it==p_item)
+ if (it == p_item)
return ofs;
- ofs+=compute_item_height(it)+cache.vseparation;
+ ofs += compute_item_height(it) + cache.vseparation;
if (it->childs && !it->collapsed) {
- it=it->childs;
+ it = it->childs;
} else if (it->next) {
- it=it->next;
+ it = it->next;
} else {
- while(!it->next) {
+ while (!it->next) {
- it=it->parent;
- if (it==NULL)
+ it = it->parent;
+ if (it == NULL)
return 0;
}
- it=it->next;
+ it = it->next;
}
}
@@ -3158,13 +2966,13 @@ void Tree::ensure_cursor_is_visible() {
if (!selected)
return;
int ofs = get_item_offset(selected);
- if (ofs==-1)
+ if (ofs == -1)
return;
- int h = compute_item_height(selected)+cache.vseparation;
- int screenh=get_size().height-h_scroll->get_combined_minimum_size().height;
+ int h = compute_item_height(selected) + cache.vseparation;
+ int screenh = get_size().height - h_scroll->get_combined_minimum_size().height;
- if (ofs+h>v_scroll->get_val()+screenh)
- v_scroll->call_deferred("set_val", ofs-screenh+h);
+ if (ofs + h > v_scroll->get_val() + screenh)
+ v_scroll->call_deferred("set_val", ofs - screenh + h);
else if (ofs < v_scroll->get_val())
v_scroll->set_val(ofs);
}
@@ -3174,32 +2982,31 @@ int Tree::get_pressed_button() const {
return pressed_button;
}
+Rect2 Tree::get_item_rect(TreeItem *p_item, int p_column) const {
-Rect2 Tree::get_item_rect(TreeItem *p_item,int p_column) const {
-
- ERR_FAIL_NULL_V(p_item,Rect2());
- ERR_FAIL_COND_V(p_item->tree!=this,Rect2());
- if (p_column!=-1) {
- ERR_FAIL_INDEX_V(p_column,columns.size(),Rect2());
+ ERR_FAIL_NULL_V(p_item, Rect2());
+ ERR_FAIL_COND_V(p_item->tree != this, Rect2());
+ if (p_column != -1) {
+ ERR_FAIL_INDEX_V(p_column, columns.size(), Rect2());
}
int ofs = get_item_offset(p_item);
int height = compute_item_height(p_item);
Rect2 r;
- r.pos.y=ofs;
- r.size.height=height;
+ r.pos.y = ofs;
+ r.size.height = height;
- if (p_column==-1) {
- r.pos.x=0;
- r.size.x=get_size().width;
+ if (p_column == -1) {
+ r.pos.x = 0;
+ r.size.x = get_size().width;
} else {
- int accum=0;
- for(int i=0;i<p_column;i++) {
- accum+=get_column_width(i);
+ int accum = 0;
+ for (int i = 0; i < p_column; i++) {
+ accum += get_column_width(i);
}
- r.pos.x=accum;
- r.size.x=get_column_width(p_column);
+ r.pos.x = accum;
+ r.size.x = get_column_width(p_column);
}
return r;
@@ -3207,7 +3014,7 @@ Rect2 Tree::get_item_rect(TreeItem *p_item,int p_column) const {
void Tree::set_column_titles_visible(bool p_show) {
- show_column_titles=p_show;
+ show_column_titles = p_show;
update();
}
@@ -3216,16 +3023,16 @@ bool Tree::are_column_titles_visible() const {
return show_column_titles;
}
-void Tree::set_column_title(int p_column,const String& p_title) {
+void Tree::set_column_title(int p_column, const String &p_title) {
- ERR_FAIL_INDEX(p_column,columns.size());
- columns[p_column].title=p_title;
+ ERR_FAIL_INDEX(p_column, columns.size());
+ columns[p_column].title = p_title;
update();
}
String Tree::get_column_title(int p_column) const {
- ERR_FAIL_INDEX_V(p_column,columns.size(),"");
+ ERR_FAIL_INDEX_V(p_column, columns.size(), "");
return columns[p_column].title;
}
@@ -3233,153 +3040,137 @@ Point2 Tree::get_scroll() const {
Point2 ofs;
if (h_scroll->is_visible())
- ofs.x=h_scroll->get_val();
+ ofs.x = h_scroll->get_val();
if (v_scroll->is_visible())
- ofs.y=v_scroll->get_val();
+ ofs.y = v_scroll->get_val();
return ofs;
-
}
-TreeItem* Tree::_search_item_text(TreeItem *p_at, const String& p_find,int *r_col,bool p_selectable,bool p_backwards) {
-
-
+TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) {
- while(p_at) {
+ while (p_at) {
- for(int i=0;i<columns.size();i++) {
- if (p_at->get_text(i).findn(p_find)==0 && (!p_selectable || p_at->is_selectable(i))) {
+ for (int i = 0; i < columns.size(); i++) {
+ if (p_at->get_text(i).findn(p_find) == 0 && (!p_selectable || p_at->is_selectable(i))) {
if (r_col)
- *r_col=i;
+ *r_col = i;
return p_at;
}
}
if (p_backwards)
- p_at=p_at->get_prev_visible();
+ p_at = p_at->get_prev_visible();
else
- p_at=p_at->get_next_visible();
+ p_at = p_at->get_next_visible();
}
return NULL;
-
}
-
-TreeItem* Tree::search_item_text(const String& p_find,int *r_col,bool p_selectable) {
+TreeItem *Tree::search_item_text(const String &p_find, int *r_col, bool p_selectable) {
if (!root)
return NULL;
- return _search_item_text(root,p_find,r_col,p_selectable);
-
+ return _search_item_text(root, p_find, r_col, p_selectable);
}
-void Tree::_do_incr_search(const String& p_add) {
+void Tree::_do_incr_search(const String &p_add) {
uint64_t time = OS::get_singleton()->get_ticks_usec() / 1000; // convert to msec
uint64_t diff = time - last_keypress;
- if (diff > uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000)))
- incr_search=p_add;
+ if (diff > uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec", 2000)))
+ incr_search = p_add;
else
- incr_search+=p_add;
-
+ incr_search += p_add;
- last_keypress=time;
+ last_keypress = time;
int col;
- TreeItem *item = search_item_text(incr_search,&col,true);
+ TreeItem *item = search_item_text(incr_search, &col, true);
if (!item)
return;
item->select(col);
ensure_cursor_is_visible();
-
-
}
-TreeItem* Tree::_find_item_at_pos(TreeItem*p_item, const Point2& p_pos,int& r_column,int &h,int &section) const {
+TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_column, int &h, int &section) const {
Point2 pos = p_pos;
+ if (root != p_item || !hide_root) {
- if (root!=p_item || ! hide_root) {
+ h = compute_item_height(p_item) + cache.vseparation;
+ if (pos.y < h) {
- h = compute_item_height(p_item)+cache.vseparation;
- if (pos.y<h) {
-
- if (drop_mode_flags==DROP_MODE_ON_ITEM) {
- section=0;
- } else if (drop_mode_flags==DROP_MODE_INBETWEEN) {
- section=pos.y<h/2?-1:1;
- } else if (pos.y<h/4) {
- section=-1;
- } else if (pos.y>=(h*3/4)) {
- section=1;
+ if (drop_mode_flags == DROP_MODE_ON_ITEM) {
+ section = 0;
+ } else if (drop_mode_flags == DROP_MODE_INBETWEEN) {
+ section = pos.y < h / 2 ? -1 : 1;
+ } else if (pos.y < h / 4) {
+ section = -1;
+ } else if (pos.y >= (h * 3 / 4)) {
+ section = 1;
} else {
- section=0;
+ section = 0;
}
- for(int i=0;i<columns.size();i++) {
+ for (int i = 0; i < columns.size(); i++) {
int w = get_column_width(i);
if (pos.x < w) {
- r_column=i;
-
+ r_column = i;
return p_item;
}
- pos.x-=w;
+ pos.x -= w;
}
-
-
-
return NULL;
} else {
- pos.y-=h;
+ pos.y -= h;
}
} else {
- h=0;
+ h = 0;
}
if (p_item->is_collapsed())
return NULL; // do not try childs, it's collapsed
TreeItem *n = p_item->get_children();
- while(n) {
-
+ while (n) {
int ch;
- TreeItem *r = _find_item_at_pos(n,pos,r_column,ch,section);
- pos.y-=ch;
- h+=ch;
+ TreeItem *r = _find_item_at_pos(n, pos, r_column, ch, section);
+ pos.y -= ch;
+ h += ch;
if (r)
return r;
- n=n->get_next();
+ n = n->get_next();
}
return NULL;
-
}
-int Tree::get_column_at_pos(const Point2& p_pos) const {
+int Tree::get_column_at_pos(const Point2 &p_pos) const {
if (root) {
- Point2 pos=p_pos;
+ Point2 pos = p_pos;
pos -= cache.bg->get_offset();
- pos.y-=_get_title_button_height();
- if (pos.y<0)
+ pos.y -= _get_title_button_height();
+ if (pos.y < 0)
return -1;
if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
+ pos.x += h_scroll->get_val();
if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ pos.y += v_scroll->get_val();
- int col,h,section;
- TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
+ int col, h, section;
+ TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
if (it) {
return col;
@@ -3387,26 +3178,25 @@ int Tree::get_column_at_pos(const Point2& p_pos) const {
}
return -1;
-
}
-int Tree::get_drop_section_at_pos(const Point2& p_pos) const {
+int Tree::get_drop_section_at_pos(const Point2 &p_pos) const {
if (root) {
- Point2 pos=p_pos;
+ Point2 pos = p_pos;
pos -= cache.bg->get_offset();
- pos.y-=_get_title_button_height();
- if (pos.y<0)
+ pos.y -= _get_title_button_height();
+ if (pos.y < 0)
return -100;
if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
+ pos.x += h_scroll->get_val();
if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ pos.y += v_scroll->get_val();
- int col,h,section;
- TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
+ int col, h, section;
+ TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
if (it) {
return section;
@@ -3414,26 +3204,24 @@ int Tree::get_drop_section_at_pos(const Point2& p_pos) const {
}
return -100;
-
}
-TreeItem* Tree::get_item_at_pos(const Point2& p_pos) const {
-
+TreeItem *Tree::get_item_at_pos(const Point2 &p_pos) const {
if (root) {
- Point2 pos=p_pos;
+ Point2 pos = p_pos;
pos -= cache.bg->get_offset();
- pos.y-=_get_title_button_height();
- if (pos.y<0)
+ pos.y -= _get_title_button_height();
+ if (pos.y < 0)
return NULL;
if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
+ pos.x += h_scroll->get_val();
if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ pos.y += v_scroll->get_val();
- int col,h,section;
- TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
+ int col, h, section;
+ TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
if (it) {
@@ -3442,35 +3230,33 @@ TreeItem* Tree::get_item_at_pos(const Point2& p_pos) const {
}
return NULL;
-
}
-String Tree::get_tooltip(const Point2& p_pos) const {
+String Tree::get_tooltip(const Point2 &p_pos) const {
if (root) {
- Point2 pos=p_pos;
+ Point2 pos = p_pos;
pos -= cache.bg->get_offset();
- pos.y-=_get_title_button_height();
- if (pos.y<0)
+ pos.y -= _get_title_button_height();
+ if (pos.y < 0)
return Control::get_tooltip(p_pos);
if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
+ pos.x += h_scroll->get_val();
if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
-
- int col,h,section;
- TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
+ pos.y += v_scroll->get_val();
+ int col, h, section;
+ TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
if (it) {
String ret;
- if (it->get_tooltip(col)=="")
- ret=it->get_text(col);
+ if (it->get_tooltip(col) == "")
+ ret = it->get_text(col);
else
- ret=it->get_tooltip(col);
+ ret = it->get_tooltip(col);
return ret;
}
}
@@ -3480,7 +3266,7 @@ String Tree::get_tooltip(const Point2& p_pos) const {
void Tree::set_cursor_can_exit_tree(bool p_enable) {
- cursor_can_exit_tree=p_enable;
+ cursor_can_exit_tree = p_enable;
}
bool Tree::can_cursor_exit_tree() const {
@@ -3489,7 +3275,7 @@ bool Tree::can_cursor_exit_tree() const {
}
void Tree::set_hide_folding(bool p_hide) {
- hide_folding=p_hide;
+ hide_folding = p_hide;
update();
}
@@ -3503,11 +3289,11 @@ void Tree::set_value_evaluator(ValueEvaluator *p_evaluator) {
}
void Tree::set_drop_mode_flags(int p_flags) {
- if (drop_mode_flags==p_flags)
+ if (drop_mode_flags == p_flags)
return;
- drop_mode_flags=p_flags;
- if (drop_mode_flags==0) {
- drop_mode_over=NULL;
+ drop_mode_flags = p_flags;
+ if (drop_mode_flags == 0) {
+ drop_mode_over = NULL;
}
update();
@@ -3520,7 +3306,7 @@ int Tree::get_drop_mode_flags() const {
void Tree::set_single_select_cell_editing_only_when_already_selected(bool p_enable) {
- force_select_on_already_selected=p_enable;
+ force_select_on_already_selected = p_enable;
}
bool Tree::get_single_select_cell_editing_only_when_already_selected() const {
@@ -3528,190 +3314,184 @@ bool Tree::get_single_select_cell_editing_only_when_already_selected() const {
return force_select_on_already_selected;
}
-
void Tree::set_allow_rmb_select(bool p_allow) {
- allow_rmb_select=p_allow;
+ allow_rmb_select = p_allow;
}
-bool Tree::get_allow_rmb_select() const{
+bool Tree::get_allow_rmb_select() const {
return allow_rmb_select;
}
void Tree::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout);
- ObjectTypeDB::bind_method(_MD("_input_event"),&Tree::_input_event);
- ObjectTypeDB::bind_method(_MD("_popup_select"),&Tree::popup_select);
- ObjectTypeDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter);
- ObjectTypeDB::bind_method(_MD("_text_editor_modal_close"),&Tree::_text_editor_modal_close);
- ObjectTypeDB::bind_method(_MD("_value_editor_changed"),&Tree::value_editor_changed);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&Tree::_scroll_moved);
-
- ObjectTypeDB::bind_method(_MD("clear"),&Tree::clear);
- ObjectTypeDB::bind_method(_MD("create_item:TreeItem","parent:TreeItem"),&Tree::_create_item,DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("_range_click_timeout"), &Tree::_range_click_timeout);
+ ObjectTypeDB::bind_method(_MD("_input_event"), &Tree::_input_event);
+ ObjectTypeDB::bind_method(_MD("_popup_select"), &Tree::popup_select);
+ ObjectTypeDB::bind_method(_MD("_text_editor_enter"), &Tree::text_editor_enter);
+ ObjectTypeDB::bind_method(_MD("_text_editor_modal_close"), &Tree::_text_editor_modal_close);
+ ObjectTypeDB::bind_method(_MD("_value_editor_changed"), &Tree::value_editor_changed);
+ ObjectTypeDB::bind_method(_MD("_scroll_moved"), &Tree::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("get_root:TreeItem"),&Tree::get_root);
- ObjectTypeDB::bind_method(_MD("set_column_min_width","column","min_width"),&Tree::set_column_min_width);
- ObjectTypeDB::bind_method(_MD("set_column_expand","column","expand"),&Tree::set_column_expand);
- ObjectTypeDB::bind_method(_MD("get_column_width","column"),&Tree::get_column_width);
+ ObjectTypeDB::bind_method(_MD("clear"), &Tree::clear);
+ ObjectTypeDB::bind_method(_MD("create_item:TreeItem", "parent:TreeItem"), &Tree::_create_item, DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("set_hide_root","enable"),&Tree::set_hide_root);
- ObjectTypeDB::bind_method(_MD("get_next_selected:TreeItem","from:TreeItem"),&Tree::_get_next_selected);
- ObjectTypeDB::bind_method(_MD("get_selected:TreeItem"),&Tree::get_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_column"),&Tree::get_selected_column);
- ObjectTypeDB::bind_method(_MD("get_pressed_button"),&Tree::get_pressed_button);
- ObjectTypeDB::bind_method(_MD("set_select_mode","mode"),&Tree::set_select_mode);
+ ObjectTypeDB::bind_method(_MD("get_root:TreeItem"), &Tree::get_root);
+ ObjectTypeDB::bind_method(_MD("set_column_min_width", "column", "min_width"), &Tree::set_column_min_width);
+ ObjectTypeDB::bind_method(_MD("set_column_expand", "column", "expand"), &Tree::set_column_expand);
+ ObjectTypeDB::bind_method(_MD("get_column_width", "column"), &Tree::get_column_width);
- ObjectTypeDB::bind_method(_MD("set_columns","amount"),&Tree::set_columns);
- ObjectTypeDB::bind_method(_MD("get_columns"),&Tree::get_columns);
+ ObjectTypeDB::bind_method(_MD("set_hide_root", "enable"), &Tree::set_hide_root);
+ ObjectTypeDB::bind_method(_MD("get_next_selected:TreeItem", "from:TreeItem"), &Tree::_get_next_selected);
+ ObjectTypeDB::bind_method(_MD("get_selected:TreeItem"), &Tree::get_selected);
+ ObjectTypeDB::bind_method(_MD("get_selected_column"), &Tree::get_selected_column);
+ ObjectTypeDB::bind_method(_MD("get_pressed_button"), &Tree::get_pressed_button);
+ ObjectTypeDB::bind_method(_MD("set_select_mode", "mode"), &Tree::set_select_mode);
- ObjectTypeDB::bind_method(_MD("get_edited:TreeItem"),&Tree::get_edited);
- ObjectTypeDB::bind_method(_MD("get_edited_column"),&Tree::get_edited_column);
- ObjectTypeDB::bind_method(_MD("get_custom_popup_rect"),&Tree::get_custom_popup_rect);
- ObjectTypeDB::bind_method(_MD("get_item_area_rect","item:TreeItem","column"),&Tree::_get_item_rect,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_item_at_pos:TreeItem","pos"),&Tree::get_item_at_pos);
- ObjectTypeDB::bind_method(_MD("get_column_at_pos","pos"),&Tree::get_column_at_pos);
+ ObjectTypeDB::bind_method(_MD("set_columns", "amount"), &Tree::set_columns);
+ ObjectTypeDB::bind_method(_MD("get_columns"), &Tree::get_columns);
- ObjectTypeDB::bind_method(_MD("ensure_cursor_is_visible"),&Tree::ensure_cursor_is_visible);
+ ObjectTypeDB::bind_method(_MD("get_edited:TreeItem"), &Tree::get_edited);
+ ObjectTypeDB::bind_method(_MD("get_edited_column"), &Tree::get_edited_column);
+ ObjectTypeDB::bind_method(_MD("get_custom_popup_rect"), &Tree::get_custom_popup_rect);
+ ObjectTypeDB::bind_method(_MD("get_item_area_rect", "item:TreeItem", "column"), &Tree::_get_item_rect, DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("get_item_at_pos:TreeItem", "pos"), &Tree::get_item_at_pos);
+ ObjectTypeDB::bind_method(_MD("get_column_at_pos", "pos"), &Tree::get_column_at_pos);
- ObjectTypeDB::bind_method(_MD("set_column_titles_visible","visible"),&Tree::set_column_titles_visible);
- ObjectTypeDB::bind_method(_MD("are_column_titles_visible"),&Tree::are_column_titles_visible);
+ ObjectTypeDB::bind_method(_MD("ensure_cursor_is_visible"), &Tree::ensure_cursor_is_visible);
- ObjectTypeDB::bind_method(_MD("set_column_title","column","title"),&Tree::set_column_title);
- ObjectTypeDB::bind_method(_MD("get_column_title","column"),&Tree::get_column_title);
- ObjectTypeDB::bind_method(_MD("get_scroll"),&Tree::get_scroll);
+ ObjectTypeDB::bind_method(_MD("set_column_titles_visible", "visible"), &Tree::set_column_titles_visible);
+ ObjectTypeDB::bind_method(_MD("are_column_titles_visible"), &Tree::are_column_titles_visible);
- ObjectTypeDB::bind_method(_MD("set_hide_folding","hide"),&Tree::set_hide_folding);
- ObjectTypeDB::bind_method(_MD("is_folding_hidden"),&Tree::is_folding_hidden);
+ ObjectTypeDB::bind_method(_MD("set_column_title", "column", "title"), &Tree::set_column_title);
+ ObjectTypeDB::bind_method(_MD("get_column_title", "column"), &Tree::get_column_title);
+ ObjectTypeDB::bind_method(_MD("get_scroll"), &Tree::get_scroll);
- ObjectTypeDB::bind_method(_MD("set_drop_mode_flags","flags"),&Tree::set_drop_mode_flags);
- ObjectTypeDB::bind_method(_MD("get_drop_mode_flags"),&Tree::get_drop_mode_flags);
+ ObjectTypeDB::bind_method(_MD("set_hide_folding", "hide"), &Tree::set_hide_folding);
+ ObjectTypeDB::bind_method(_MD("is_folding_hidden"), &Tree::is_folding_hidden);
- ObjectTypeDB::bind_method(_MD("set_allow_rmb_select","allow"),&Tree::set_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"),&Tree::get_allow_rmb_select);
+ ObjectTypeDB::bind_method(_MD("set_drop_mode_flags", "flags"), &Tree::set_drop_mode_flags);
+ ObjectTypeDB::bind_method(_MD("get_drop_mode_flags"), &Tree::get_drop_mode_flags);
+ ObjectTypeDB::bind_method(_MD("set_allow_rmb_select", "allow"), &Tree::set_allow_rmb_select);
+ ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"), &Tree::get_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("set_single_select_cell_editing_only_when_already_selected","enable"),&Tree::set_single_select_cell_editing_only_when_already_selected);
- ObjectTypeDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
+ ObjectTypeDB::bind_method(_MD("set_single_select_cell_editing_only_when_already_selected", "enable"), &Tree::set_single_select_cell_editing_only_when_already_selected);
+ ObjectTypeDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"), &Tree::get_single_select_cell_editing_only_when_already_selected);
- ADD_SIGNAL( MethodInfo("item_selected"));
- ADD_SIGNAL( MethodInfo("cell_selected"));
- ADD_SIGNAL( MethodInfo("multi_selected",PropertyInfo(Variant::OBJECT,"item"),PropertyInfo(Variant::INT,"column"),PropertyInfo(Variant::BOOL,"selected")) );
- ADD_SIGNAL( MethodInfo("item_rmb_selected",PropertyInfo(Variant::VECTOR2,"pos")));
- ADD_SIGNAL( MethodInfo("empty_tree_rmb_selected",PropertyInfo(Variant::VECTOR2,"pos")));
- ADD_SIGNAL( MethodInfo("item_edited"));
- ADD_SIGNAL( MethodInfo("item_collapsed",PropertyInfo(Variant::OBJECT,"item")));
+ ADD_SIGNAL(MethodInfo("item_selected"));
+ ADD_SIGNAL(MethodInfo("cell_selected"));
+ ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::OBJECT, "item"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::BOOL, "selected")));
+ ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos")));
+ ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos")));
+ ADD_SIGNAL(MethodInfo("item_edited"));
+ ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item")));
//ADD_SIGNAL( MethodInfo("item_doubleclicked" ) );
- ADD_SIGNAL( MethodInfo("button_pressed",PropertyInfo(Variant::OBJECT,"item"),PropertyInfo(Variant::INT,"column"),PropertyInfo(Variant::INT,"id")));
- ADD_SIGNAL( MethodInfo("custom_popup_edited",PropertyInfo(Variant::BOOL,"arrow_clicked") ) );
- ADD_SIGNAL( MethodInfo("item_activated"));
+ ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::OBJECT, "item"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("custom_popup_edited", PropertyInfo(Variant::BOOL, "arrow_clicked")));
+ ADD_SIGNAL(MethodInfo("item_activated"));
- BIND_CONSTANT( SELECT_SINGLE );
- BIND_CONSTANT( SELECT_ROW );
- BIND_CONSTANT( SELECT_MULTI );
-
- BIND_CONSTANT( DROP_MODE_DISABLED );
- BIND_CONSTANT( DROP_MODE_ON_ITEM );
- BIND_CONSTANT( DROP_MODE_INBETWEEN );
+ BIND_CONSTANT(SELECT_SINGLE);
+ BIND_CONSTANT(SELECT_ROW);
+ BIND_CONSTANT(SELECT_MULTI);
+ BIND_CONSTANT(DROP_MODE_DISABLED);
+ BIND_CONSTANT(DROP_MODE_ON_ITEM);
+ BIND_CONSTANT(DROP_MODE_INBETWEEN);
}
Tree::Tree() {
- selected_col=0;
+ selected_col = 0;
columns.resize(1);
- selected_item=NULL;
- edited_item=NULL;
- selected_col=-1;
- edited_col=-1;
+ selected_item = NULL;
+ edited_item = NULL;
+ selected_col = -1;
+ edited_col = -1;
- hide_root=false;
- select_mode=SELECT_SINGLE;
- root=0;
- popup_menu=NULL;
- popup_edited_item=NULL;
- text_editor=NULL;
+ hide_root = false;
+ select_mode = SELECT_SINGLE;
+ root = 0;
+ popup_menu = NULL;
+ popup_edited_item = NULL;
+ text_editor = NULL;
set_focus_mode(FOCUS_ALL);
-
- popup_menu = memnew( PopupMenu );
+ popup_menu = memnew(PopupMenu);
popup_menu->hide();
add_child(popup_menu);
popup_menu->set_as_toplevel(true);
- text_editor = memnew( LineEdit );
+ text_editor = memnew(LineEdit);
add_child(text_editor);
text_editor->set_as_toplevel(true);
text_editor->hide();
- value_editor = memnew( HSlider );
+ value_editor = memnew(HSlider);
add_child(value_editor);
value_editor->set_as_toplevel(true);
value_editor->hide();
- h_scroll = memnew( HScrollBar );
- v_scroll = memnew( VScrollBar );
+ h_scroll = memnew(HScrollBar);
+ v_scroll = memnew(VScrollBar);
add_child(h_scroll);
add_child(v_scroll);
- range_click_timer = memnew( Timer );
- range_click_timer->connect("timeout",this,"_range_click_timeout");
+ range_click_timer = memnew(Timer);
+ range_click_timer->connect("timeout", this, "_range_click_timeout");
add_child(range_click_timer);
- h_scroll->connect("value_changed", this,"_scroll_moved");
- v_scroll->connect("value_changed", this,"_scroll_moved");
- text_editor->connect("text_entered", this,"_text_editor_enter");
- text_editor->connect("modal_close", this,"_text_editor_modal_close");
- popup_menu->connect("item_pressed", this,"_popup_select");
- value_editor->connect("value_changed", this,"_value_editor_changed");
+ h_scroll->connect("value_changed", this, "_scroll_moved");
+ v_scroll->connect("value_changed", this, "_scroll_moved");
+ text_editor->connect("text_entered", this, "_text_editor_enter");
+ text_editor->connect("modal_close", this, "_text_editor_modal_close");
+ popup_menu->connect("item_pressed", this, "_popup_select");
+ value_editor->connect("value_changed", this, "_value_editor_changed");
value_editor->set_as_toplevel(true);
text_editor->set_as_toplevel(true);
- updating_value_editor=false;
- pressed_button=-1;
- show_column_titles=false;
+ updating_value_editor = false;
+ pressed_button = -1;
+ show_column_titles = false;
cache.click_type = Cache::CLICK_NONE;
cache.hover_type = Cache::CLICK_NONE;
cache.hover_index = -1;
- cache.click_index=-1;
- cache.click_id=-1;
- cache.click_item=NULL;
- cache.click_column=0;
- last_keypress=0;
- focus_in_id=0;
+ cache.click_index = -1;
+ cache.click_id = -1;
+ cache.click_item = NULL;
+ cache.click_column = 0;
+ last_keypress = 0;
+ focus_in_id = 0;
- blocked=0;
+ blocked = 0;
- cursor_can_exit_tree=true;
+ cursor_can_exit_tree = true;
set_stop_mouse(true);
- drag_speed=0;
- drag_touching=false;
- drag_touching_deaccel=false;
- pressing_for_editor=false;
- range_drag_enabled=false;
+ drag_speed = 0;
+ drag_touching = false;
+ drag_touching_deaccel = false;
+ pressing_for_editor = false;
+ range_drag_enabled = false;
- hide_folding=false;
+ hide_folding = false;
- evaluator=NULL;
+ evaluator = NULL;
- drop_mode_flags=0;
- drop_mode_over=NULL;
- drop_mode_section=0;
- single_select_defer=NULL;
- force_select_on_already_selected=false;
+ drop_mode_flags = 0;
+ drop_mode_over = NULL;
+ drop_mode_section = 0;
+ single_select_defer = NULL;
+ force_select_on_already_selected = false;
- allow_rmb_select=false;
+ allow_rmb_select = false;
}
-
Tree::~Tree() {
if (root) {
- memdelete( root );
+ memdelete(root);
}
-
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 5ac6d4e89..b4e2e7f88 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -29,25 +29,24 @@
#ifndef TREE_H
#define TREE_H
+#include "core/helper/value_evaluator.h"
#include "scene/gui/control.h"
-#include "scene/gui/popup_menu.h"
#include "scene/gui/line_edit.h"
+#include "scene/gui/popup_menu.h"
#include "scene/gui/scroll_bar.h"
#include "scene/gui/slider.h"
-#include "core/helper/value_evaluator.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
class Tree;
class TreeItem : public Object {
- OBJ_TYPE(TreeItem,Object);
-public:
+ OBJ_TYPE(TreeItem, Object);
+public:
enum TreeCellMode {
CELL_MODE_STRING, ///< just a string
@@ -59,8 +58,7 @@ public:
};
private:
-friend class Tree;
-
+ friend class Tree;
struct Cell {
@@ -69,7 +67,7 @@ friend class Tree;
Ref<Texture> icon;
Rect2i icon_region;
String text;
- double min,max,step,val;
+ double min, max, step, val;
int icon_max_w;
bool expr;
bool checked;
@@ -93,33 +91,35 @@ friend class Tree;
bool disabled;
Ref<Texture> texture;
Color color;
- Button() { id=0; disabled=false; color=Color(1,1,1,1); }
+ Button() {
+ id = 0;
+ disabled = false;
+ color = Color(1, 1, 1, 1);
+ }
};
- Vector< Button > buttons;
+ Vector<Button> buttons;
Cell() {
- custom_draw_obj=0;
- mode=TreeItem::CELL_MODE_STRING;
- min=0;
- max=100;
- step=1;
- val=0;
- checked=false;
- editable=false;
- selected=false;
- selectable=true;
- custom_color=false;
- custom_bg_color=false;
- expr=false;
- icon_max_w=0;
+ custom_draw_obj = 0;
+ mode = TreeItem::CELL_MODE_STRING;
+ min = 0;
+ max = 100;
+ step = 1;
+ val = 0;
+ checked = false;
+ editable = false;
+ selected = false;
+ selectable = true;
+ custom_color = false;
+ custom_bg_color = false;
+ expr = false;
+ icon_max_w = 0;
}
-
Size2 get_icon_size() const;
- void draw_icon(const RID& p_where, const Point2& p_pos, const Size2& p_size=Size2()) const;
-
+ void draw_icon(const RID &p_where, const Point2 &p_pos, const Size2 &p_size = Size2()) const;
};
Vector<Cell> cells;
@@ -131,76 +131,73 @@ friend class Tree;
TreeItem *childs; //child items
Tree *tree; //tree (for reference)
-
-
TreeItem(Tree *p_tree);
-
void _changed_notify(int p_cell);
void _changed_notify();
void _cell_selected(int p_cell);
void _cell_deselected(int p_cell);
-protected:
+protected:
static void _bind_methods();
//bind helpers
- Dictionary _get_range_config( int p_column ) {
+ Dictionary _get_range_config(int p_column) {
Dictionary d;
- double min,max,step;
- get_range_config(p_column,min,max,step);
- d["min"]=min;
- d["max"]=max;
- d["step"]=step;
- d["expr"]=false;
+ double min, max, step;
+ get_range_config(p_column, min, max, step);
+ d["min"] = min;
+ d["max"] = max;
+ d["step"] = step;
+ d["expr"] = false;
return d;
}
- void _remove_child(Object *p_child) { remove_child( p_child->cast_to<TreeItem>() ); }
-public:
+ void _remove_child(Object *p_child) { remove_child(p_child->cast_to<TreeItem>()); }
+public:
/* cell mode */
- void set_cell_mode( int p_column, TreeCellMode p_mode );
- TreeCellMode get_cell_mode( int p_column ) const;
+ void set_cell_mode(int p_column, TreeCellMode p_mode);
+ TreeCellMode get_cell_mode(int p_column) const;
/* check mode */
- void set_checked(int p_column,bool p_checked);
+ void set_checked(int p_column, bool p_checked);
bool is_checked(int p_column) const;
- void set_text(int p_column,String p_text);
+ void set_text(int p_column, String p_text);
String get_text(int p_column) const;
- void set_icon(int p_column,const Ref<Texture>& p_icon);
+ void set_icon(int p_column, const Ref<Texture> &p_icon);
Ref<Texture> get_icon(int p_column) const;
- void set_icon_region(int p_column,const Rect2& p_icon_region);
+ void set_icon_region(int p_column, const Rect2 &p_icon_region);
Rect2 get_icon_region(int p_column) const;
- void set_icon_max_width(int p_column,int p_max);
+ void set_icon_max_width(int p_column, int p_max);
int get_icon_max_width(int p_column) const;
- void add_button(int p_column,const Ref<Texture>& p_button,int p_id=-1,bool p_disabled=false);
+ void add_button(int p_column, const Ref<Texture> &p_button, int p_id = -1, bool p_disabled = false);
int get_button_count(int p_column) const;
- Ref<Texture> get_button(int p_column,int p_idx) const;
- int get_button_id(int p_column,int p_idx) const;
- void erase_button(int p_column,int p_idx);
- int get_button_by_id(int p_column,int p_id) const;
- bool is_button_disabled(int p_column,int p_idx) const;
- void set_button(int p_column,int p_idx,const Ref<Texture>& p_button);
- void set_button_color(int p_column,int p_idx,const Color& p_color);
+ Ref<Texture> get_button(int p_column, int p_idx) const;
+ int get_button_id(int p_column, int p_idx) const;
+ void erase_button(int p_column, int p_idx);
+ int get_button_by_id(int p_column, int p_id) const;
+ bool is_button_disabled(int p_column, int p_idx) const;
+ void set_button(int p_column, int p_idx, const Ref<Texture> &p_button);
+ void set_button_color(int p_column, int p_idx, const Color &p_color);
/* range works for mode number or mode combo */
- void set_range(int p_column,double p_value);
+ void set_range(int p_column, double p_value);
double get_range(int p_column) const;
- void set_range_config(int p_column,double p_min,double p_max,double p_step,bool p_exp=false);
- void get_range_config(int p_column,double& r_min,double& r_max,double &r_step) const;
+ void set_range_config(int p_column, double p_min, double p_max, double p_step, bool p_exp = false);
+ void get_range_config(int p_column, double &r_min, double &r_max, double &r_step) const;
bool is_range_exponential(int p_column) const;
- void set_metadata(int p_column,const Variant& p_meta);
+ void set_metadata(int p_column, const Variant &p_meta);
Variant get_metadata(int p_column) const;
- void set_custom_draw(int p_column,Object *p_object,const StringName& p_callback);
+ void set_custom_draw(int p_column, Object *p_object, const StringName &p_callback);
void set_collapsed(bool p_collapsed);
bool is_collapsed();
@@ -215,7 +212,7 @@ public:
void remove_child(TreeItem *p_item);
- void set_selectable(int p_column,bool p_selectable);
+ void set_selectable(int p_column, bool p_selectable);
bool is_selectable(int p_column) const;
bool is_selected(int p_column);
@@ -223,52 +220,49 @@ public:
void deselect(int p_column);
void set_as_cursor(int p_column);
- void set_editable(int p_column,bool p_editable);
+ void set_editable(int p_column, bool p_editable);
bool is_editable(int p_column);
- void set_custom_color(int p_column,const Color& p_color);
+ void set_custom_color(int p_column, const Color &p_color);
Color get_custom_color(int p_column) const;
void clear_custom_color(int p_column);
- void set_custom_bg_color(int p_column, const Color& p_color, bool p_bg_outline=false);
+ void set_custom_bg_color(int p_column, const Color &p_color, bool p_bg_outline = false);
void clear_custom_bg_color(int p_column);
Color get_custom_bg_color(int p_column) const;
- void set_tooltip(int p_column, const String& p_tooltip);
+ void set_tooltip(int p_column, const String &p_tooltip);
String get_tooltip(int p_column) const;
-
void clear_children();
void move_to_top();
void move_to_bottom();
~TreeItem();
-
};
-
-VARIANT_ENUM_CAST( TreeItem::TreeCellMode );
-
+VARIANT_ENUM_CAST(TreeItem::TreeCellMode);
class Tree : public Control {
- OBJ_TYPE( Tree, Control );
+ OBJ_TYPE(Tree, Control);
+
public:
enum SelectMode {
- SELECT_SINGLE,
- SELECT_ROW,
- SELECT_MULTI
+ SELECT_SINGLE,
+ SELECT_ROW,
+ SELECT_MULTI
};
enum DropModeFlags {
- DROP_MODE_DISABLED=0,
- DROP_MODE_ON_ITEM=1,
- DROP_MODE_INBETWEEN=2
+ DROP_MODE_DISABLED = 0,
+ DROP_MODE_ON_ITEM = 1,
+ DROP_MODE_INBETWEEN = 2
};
private:
-friend class TreeItem;
+ friend class TreeItem;
TreeItem *root;
TreeItem *popup_edited_item;
@@ -291,7 +285,6 @@ friend class TreeItem;
bool range_drag_enabled;
Vector2 range_drag_capture_pos;
-
//TreeItem *cursor_item;
//int cursor_column;
@@ -311,7 +304,10 @@ friend class TreeItem;
int min_width;
bool expand;
String title;
- ColumnInfo() { min_width=1; expand=true; }
+ ColumnInfo() {
+ min_width = 1;
+ expand = true;
+ }
};
bool show_column_titles;
@@ -330,11 +326,11 @@ friend class TreeItem;
int compute_item_height(TreeItem *p_item) const;
int get_item_height(TreeItem *p_item) const;
-// void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
- void draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,const Color& p_color);
- int draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& p_draw_size,TreeItem *p_item);
- void select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev=NULL,bool *r_in_range=NULL,bool p_force_deselect=false);
- int propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_doubleclick,TreeItem *p_item,int p_button,const InputModifierState& p_mod);
+ // void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
+ void draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color);
+ int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item);
+ void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = NULL, bool *r_in_range = NULL, bool p_force_deselect = false);
+ int propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool p_doubleclick, TreeItem *p_item, int p_button, const InputModifierState &p_mod);
void text_editor_enter(String p_text);
void _text_editor_modal_close();
void value_editor_changed(double p_value);
@@ -346,10 +342,10 @@ friend class TreeItem;
Size2 get_minimum_size() const;
- void item_edited(int p_column,TreeItem *p_item);
- void item_changed(int p_column,TreeItem *p_item);
- void item_selected(int p_column,TreeItem *p_item);
- void item_deselected(int p_column,TreeItem *p_item);
+ void item_edited(int p_column, TreeItem *p_item);
+ void item_changed(int p_column, TreeItem *p_item);
+ void item_selected(int p_column, TreeItem *p_item);
+ void item_deselected(int p_column, TreeItem *p_item);
void propagate_set_columns(TreeItem *p_item);
@@ -409,7 +405,6 @@ friend class TreeItem;
} cache;
-
int _get_title_button_height() const;
void _scroll_moved(float p_value);
@@ -425,13 +420,13 @@ friend class TreeItem;
uint64_t last_keypress;
String incr_search;
bool cursor_can_exit_tree;
- void _do_incr_search(const String& p_add);
+ void _do_incr_search(const String &p_add);
- TreeItem* _search_item_text(TreeItem *p_at, const String& p_find,int *r_col,bool p_selectable,bool p_backwards=false);
+ TreeItem *_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards = false);
- TreeItem* _find_item_at_pos(TreeItem *p_current, const Point2& p_pos, int& r_column, int &h, int &section) const;
+ TreeItem *_find_item_at_pos(TreeItem *p_current, const Point2 &p_pos, int &r_column, int &h, int &section) const;
-/* float drag_speed;
+ /* float drag_speed;
float drag_accum;
float last_drag_accum;
@@ -454,37 +449,35 @@ friend class TreeItem;
ValueEvaluator *evaluator;
- int _count_selected_items(TreeItem* p_from) const;
+ int _count_selected_items(TreeItem *p_from) const;
protected:
static void _bind_methods();
//bind helpers
- Object* _create_item(Object *p_parent) { return create_item(p_parent->cast_to<TreeItem>() ); }
- TreeItem *_get_next_selected(Object *p_item) { return get_next_selected(p_item->cast_to<TreeItem>() ); }
- Rect2 _get_item_rect(Object *p_item,int p_column) const { return get_item_rect(p_item->cast_to<TreeItem>(),p_column ); }
-
+ Object *_create_item(Object *p_parent) { return create_item(p_parent->cast_to<TreeItem>()); }
+ TreeItem *_get_next_selected(Object *p_item) { return get_next_selected(p_item->cast_to<TreeItem>()); }
+ Rect2 _get_item_rect(Object *p_item, int p_column) const { return get_item_rect(p_item->cast_to<TreeItem>(), p_column); }
public:
+ virtual String get_tooltip(const Point2 &p_pos) const;
- virtual String get_tooltip(const Point2& p_pos) const;
-
- TreeItem* get_item_at_pos(const Point2& p_pos) const;
- int get_column_at_pos(const Point2& p_pos) const;
- int get_drop_section_at_pos(const Point2& p_pos) const;
+ TreeItem *get_item_at_pos(const Point2 &p_pos) const;
+ int get_column_at_pos(const Point2 &p_pos) const;
+ int get_drop_section_at_pos(const Point2 &p_pos) const;
void clear();
- TreeItem* create_item(TreeItem *p_parent=0);
- TreeItem* get_root();
- TreeItem* get_last_item();
+ TreeItem *create_item(TreeItem *p_parent = 0);
+ TreeItem *get_root();
+ TreeItem *get_last_item();
- void set_column_min_width(int p_column,int p_min_width);
- void set_column_expand(int p_column,bool p_expand);
+ void set_column_min_width(int p_column, int p_min_width);
+ void set_column_expand(int p_column, bool p_expand);
int get_column_width(int p_column) const;
void set_hide_root(bool p_eanbled);
- TreeItem *get_next_selected( TreeItem* p_item);
+ TreeItem *get_next_selected(TreeItem *p_item);
TreeItem *get_selected() const;
int get_selected_column() const;
int get_pressed_button() const;
@@ -493,7 +486,7 @@ public:
void set_columns(int p_columns);
int get_columns() const;
- void set_column_title(int p_column,const String& p_title);
+ void set_column_title(int p_column, const String &p_title);
String get_column_title(int p_column) const;
void set_column_titles_visible(bool p_show);
@@ -507,10 +500,10 @@ public:
Rect2 get_custom_popup_rect() const;
int get_item_offset(TreeItem *p_item) const;
- Rect2 get_item_rect(TreeItem *p_item,int p_column=-1) const;
+ Rect2 get_item_rect(TreeItem *p_item, int p_column = -1) const;
bool edit_selected();
- TreeItem* search_item_text(const String& p_find,int *r_col=NULL,bool p_selectable=false);
+ TreeItem *search_item_text(const String &p_find, int *r_col = NULL, bool p_selectable = false);
Point2 get_scroll() const;
@@ -535,8 +528,7 @@ public:
Tree();
~Tree();
-
};
-VARIANT_ENUM_CAST( Tree::SelectMode );
+VARIANT_ENUM_CAST(Tree::SelectMode);
#endif
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 46b7bc6cb..6a7f153fc 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -29,39 +29,37 @@
#include "video_player.h"
#include "os/os.h"
-
int VideoPlayer::InternalStream::get_channel_count() const {
return player->sp_get_channel_count();
}
-void VideoPlayer::InternalStream::set_mix_rate(int p_rate){
+void VideoPlayer::InternalStream::set_mix_rate(int p_rate) {
return player->sp_set_mix_rate(p_rate);
}
-bool VideoPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){
+bool VideoPlayer::InternalStream::mix(int32_t *p_buffer, int p_frames) {
- return player->sp_mix(p_buffer,p_frames);
+ return player->sp_mix(p_buffer, p_frames);
}
-void VideoPlayer::InternalStream::update(){
+void VideoPlayer::InternalStream::update() {
player->sp_update();
}
-
int VideoPlayer::sp_get_channel_count() const {
return playback->get_channels();
}
-void VideoPlayer::sp_set_mix_rate(int p_rate){
+void VideoPlayer::sp_set_mix_rate(int p_rate) {
- server_mix_rate=p_rate;
+ server_mix_rate = p_rate;
}
-bool VideoPlayer::sp_mix(int32_t *p_buffer,int p_frames) {
+bool VideoPlayer::sp_mix(int32_t *p_buffer, int p_frames) {
if (resampler.is_ready()) {
- return resampler.mix(p_buffer,p_frames);
+ return resampler.mix(p_buffer, p_frames);
}
return false;
@@ -92,24 +90,22 @@ void VideoPlayer::sp_update() {
#endif
}
-int VideoPlayer::_audio_mix_callback(void* p_udata,const int16_t *p_data,int p_frames) {
+int VideoPlayer::_audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames) {
- VideoPlayer *vp=(VideoPlayer*)p_udata;
+ VideoPlayer *vp = (VideoPlayer *)p_udata;
- int todo=MIN(vp->resampler.get_todo(),p_frames);
+ int todo = MIN(vp->resampler.get_todo(), p_frames);
int16_t *wb = vp->resampler.get_write_buffer();
int c = vp->resampler.get_channel_count();
- for(int i=0;i<todo*c;i++) {
- wb[i]=p_data[i];
+ for (int i = 0; i < todo * c; i++) {
+ wb[i] = p_data[i];
}
vp->resampler.write(todo);
return todo;
}
-
-
void VideoPlayer::_notification(int p_notification) {
switch (p_notification) {
@@ -132,12 +128,11 @@ void VideoPlayer::_notification(int p_notification) {
double audio_time = USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()); //AudioServer::get_singleton()->get_mix_time();
- double delta = last_audio_time==0?0:audio_time-last_audio_time;
- last_audio_time=audio_time;
- if (delta==0)
+ double delta = last_audio_time == 0 ? 0 : audio_time - last_audio_time;
+ last_audio_time = audio_time;
+ if (delta == 0)
return;
-
playback->update(delta);
} break;
@@ -149,17 +144,13 @@ void VideoPlayer::_notification(int p_notification) {
if (texture->get_width() == 0)
return;
- Size2 s=expand?get_size():texture->get_size();
- draw_texture_rect(texture,Rect2(Point2(),s),false);
+ Size2 s = expand ? get_size() : texture->get_size();
+ draw_texture_rect(texture, Rect2(Point2(), s), false);
} break;
};
-
};
-
-
-
Size2 VideoPlayer::get_minimum_size() const {
if (!expand && !texture.is_null())
@@ -170,7 +161,7 @@ Size2 VideoPlayer::get_minimum_size() const {
void VideoPlayer::set_expand(bool p_expand) {
- expand=p_expand;
+ expand = p_expand;
update();
minimum_size_changed();
}
@@ -180,35 +171,34 @@ bool VideoPlayer::has_expand() const {
return expand;
}
-
void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
stop();
- stream=p_stream;
- if (stream.is_valid()) {
- stream->set_audio_track(audio_track);
- playback=stream->instance_playback();
- } else {
- playback=Ref<VideoStreamPlayback>();
- }
+ stream = p_stream;
+ if (stream.is_valid()) {
+ stream->set_audio_track(audio_track);
+ playback = stream->instance_playback();
+ } else {
+ playback = Ref<VideoStreamPlayback>();
+ }
if (!playback.is_null()) {
playback->set_loop(loops);
playback->set_paused(paused);
- texture=playback->get_texture();
+ texture = playback->get_texture();
const int channels = playback->get_channels();
AudioServer::get_singleton()->lock();
if (channels > 0)
- resampler.setup(channels,playback->get_mix_rate(),server_mix_rate,buffering_ms,0);
+ resampler.setup(channels, playback->get_mix_rate(), server_mix_rate, buffering_ms, 0);
else
resampler.clear();
AudioServer::get_singleton()->unlock();
if (channels > 0)
- playback->set_mix_callback(_audio_mix_callback,this);
+ playback->set_mix_callback(_audio_mix_callback, this);
} else {
texture.unref();
@@ -218,7 +208,6 @@ void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
}
update();
-
};
Ref<VideoStream> VideoPlayer::get_stream() const {
@@ -234,9 +223,9 @@ void VideoPlayer::play() {
playback->stop();
playback->play();
set_process(true);
- AudioServer::get_singleton()->stream_set_active(stream_rid,true);
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
- last_audio_time=0;
+ AudioServer::get_singleton()->stream_set_active(stream_rid, true);
+ AudioServer::get_singleton()->stream_set_volume_scale(stream_rid, volume);
+ last_audio_time = 0;
};
void VideoPlayer::stop() {
@@ -247,10 +236,10 @@ void VideoPlayer::stop() {
return;
playback->stop();
- AudioServer::get_singleton()->stream_set_active(stream_rid,false);
+ AudioServer::get_singleton()->stream_set_active(stream_rid, false);
resampler.flush();
set_process(false);
- last_audio_time=0;
+ last_audio_time = 0;
};
bool VideoPlayer::is_playing() const {
@@ -263,7 +252,7 @@ bool VideoPlayer::is_playing() const {
void VideoPlayer::set_paused(bool p_paused) {
- paused=p_paused;
+ paused = p_paused;
if (playback.is_valid()) {
playback->set_paused(p_paused);
set_process(!p_paused);
@@ -278,27 +267,26 @@ bool VideoPlayer::is_paused() const {
void VideoPlayer::set_buffering_msec(int p_msec) {
- buffering_ms=p_msec;
+ buffering_ms = p_msec;
}
-int VideoPlayer::get_buffering_msec() const{
+int VideoPlayer::get_buffering_msec() const {
return buffering_ms;
}
void VideoPlayer::set_audio_track(int p_track) {
- audio_track=p_track;
+ audio_track = p_track;
}
int VideoPlayer::get_audio_track() const {
- return audio_track;
+ return audio_track;
}
-
void VideoPlayer::set_volume(float p_vol) {
- volume=p_vol;
+ volume = p_vol;
};
float VideoPlayer::get_volume() const {
@@ -308,7 +296,7 @@ float VideoPlayer::get_volume() const {
void VideoPlayer::set_volume_db(float p_db) {
- if (p_db<-79)
+ if (p_db < -79)
set_volume(0);
else
set_volume(Math::db2linear(p_db));
@@ -316,13 +304,12 @@ void VideoPlayer::set_volume_db(float p_db) {
float VideoPlayer::get_volume_db() const {
- if (volume==0)
+ if (volume == 0)
return -80;
else
return Math::linear2db(volume);
};
-
String VideoPlayer::get_stream_name() const {
if (stream.is_null())
@@ -342,12 +329,12 @@ Ref<Texture> VideoPlayer::get_video_texture() {
if (playback.is_valid())
return playback->get_texture();
- return Ref<Texture> ();
+ return Ref<Texture>();
}
void VideoPlayer::set_autoplay(bool p_enable) {
- autoplay=p_enable;
+ autoplay = p_enable;
};
bool VideoPlayer::has_autoplay() const {
@@ -357,69 +344,67 @@ bool VideoPlayer::has_autoplay() const {
void VideoPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:VideoStream"),&VideoPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:VideoStream"),&VideoPlayer::get_stream);
+ ObjectTypeDB::bind_method(_MD("set_stream", "stream:VideoStream"), &VideoPlayer::set_stream);
+ ObjectTypeDB::bind_method(_MD("get_stream:VideoStream"), &VideoPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play"),&VideoPlayer::play);
- ObjectTypeDB::bind_method(_MD("stop"),&VideoPlayer::stop);
+ ObjectTypeDB::bind_method(_MD("play"), &VideoPlayer::play);
+ ObjectTypeDB::bind_method(_MD("stop"), &VideoPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&VideoPlayer::is_playing);
+ ObjectTypeDB::bind_method(_MD("is_playing"), &VideoPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&VideoPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&VideoPlayer::is_paused);
+ ObjectTypeDB::bind_method(_MD("set_paused", "paused"), &VideoPlayer::set_paused);
+ ObjectTypeDB::bind_method(_MD("is_paused"), &VideoPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&VideoPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&VideoPlayer::get_volume);
+ ObjectTypeDB::bind_method(_MD("set_volume", "volume"), &VideoPlayer::set_volume);
+ ObjectTypeDB::bind_method(_MD("get_volume"), &VideoPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&VideoPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&VideoPlayer::get_volume_db);
+ ObjectTypeDB::bind_method(_MD("set_volume_db", "db"), &VideoPlayer::set_volume_db);
+ ObjectTypeDB::bind_method(_MD("get_volume_db"), &VideoPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("set_audio_track","track"),&VideoPlayer::set_audio_track);
- ObjectTypeDB::bind_method(_MD("get_audio_track"),&VideoPlayer::get_audio_track);
+ ObjectTypeDB::bind_method(_MD("set_audio_track", "track"), &VideoPlayer::set_audio_track);
+ ObjectTypeDB::bind_method(_MD("get_audio_track"), &VideoPlayer::get_audio_track);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&VideoPlayer::get_stream_name);
+ ObjectTypeDB::bind_method(_MD("get_stream_name"), &VideoPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_stream_pos"),&VideoPlayer::get_stream_pos);
+ ObjectTypeDB::bind_method(_MD("get_stream_pos"), &VideoPlayer::get_stream_pos);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&VideoPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&VideoPlayer::has_autoplay);
+ ObjectTypeDB::bind_method(_MD("set_autoplay", "enabled"), &VideoPlayer::set_autoplay);
+ ObjectTypeDB::bind_method(_MD("has_autoplay"), &VideoPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("set_expand","enable"), &VideoPlayer::set_expand );
- ObjectTypeDB::bind_method(_MD("has_expand"), &VideoPlayer::has_expand );
+ ObjectTypeDB::bind_method(_MD("set_expand", "enable"), &VideoPlayer::set_expand);
+ ObjectTypeDB::bind_method(_MD("has_expand"), &VideoPlayer::has_expand);
- ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
+ ObjectTypeDB::bind_method(_MD("set_buffering_msec", "msec"), &VideoPlayer::set_buffering_msec);
+ ObjectTypeDB::bind_method(_MD("get_buffering_msec"), &VideoPlayer::get_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture );
+ ObjectTypeDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture);
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") );
-// ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "stream/audio_track", PROPERTY_HINT_RANGE, "0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE, "VideoStream"), _SCS("set_stream"), _SCS("get_stream"));
+ // ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), _SCS("set_expand"), _SCS("has_expand"));
}
-
VideoPlayer::VideoPlayer() {
- volume=1;
+ volume = 1;
loops = false;
paused = false;
autoplay = false;
expand = true;
loops = false;
- audio_track=0;
-
- buffering_ms=500;
- server_mix_rate=44100;
+ audio_track = 0;
- internal_stream.player=this;
- stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
- last_audio_time=0;
+ buffering_ms = 500;
+ server_mix_rate = 44100;
+ internal_stream.player = this;
+ stream_rid = AudioServer::get_singleton()->audio_stream_create(&internal_stream);
+ last_audio_time = 0;
};
VideoPlayer::~VideoPlayer() {
@@ -428,4 +413,3 @@ VideoPlayer::~VideoPlayer() {
AudioServer::get_singleton()->free(stream_rid);
resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes
};
-
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index c1d2caee8..65ddcd251 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -29,33 +29,31 @@
#ifndef VIDEO_PLAYER_H
#define VIDEO_PLAYER_H
-#include "scene/resources/video_stream.h"
#include "scene/gui/control.h"
+#include "scene/resources/video_stream.h"
#include "servers/audio/audio_rb_resampler.h"
class VideoPlayer : public Control {
- OBJ_TYPE(VideoPlayer,Control);
+ OBJ_TYPE(VideoPlayer, Control);
struct InternalStream : public AudioServer::AudioStream {
VideoPlayer *player;
virtual int get_channel_count() const;
virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames);
+ virtual bool mix(int32_t *p_buffer, int p_frames);
virtual void update();
};
-
InternalStream internal_stream;
Ref<VideoStreamPlayback> playback;
Ref<VideoStream> stream;
int sp_get_channel_count() const;
void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate
- bool sp_mix(int32_t *p_buffer,int p_frames);
+ bool sp_mix(int32_t *p_buffer, int p_frames);
void sp_update();
-
RID stream_rid;
Ref<ImageTexture> texture;
@@ -70,24 +68,20 @@ class VideoPlayer : public Control {
bool expand;
bool loops;
int buffering_ms;
- int server_mix_rate;
- int audio_track;
-
- static int _audio_mix_callback(void* p_udata,const int16_t *p_data,int p_frames);
+ int server_mix_rate;
+ int audio_track;
+ static int _audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames);
protected:
-
static void _bind_methods();
void _notification(int p_notification);
public:
-
Size2 get_minimum_size() const;
void set_expand(bool p_expand);
bool has_expand() const;
-
Ref<Texture> get_video_texture();
void set_stream(const Ref<VideoStream> &p_stream);
diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp
index 597485cae..37fb26c33 100644
--- a/scene/io/resource_format_image.cpp
+++ b/scene/io/resource_format_image.cpp
@@ -27,50 +27,49 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_image.h"
-#include "scene/resources/texture.h"
-#include "io/image_loader.h"
#include "globals.h"
+#include "io/image_loader.h"
#include "os/os.h"
-RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) {
+#include "scene/resources/texture.h"
+RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_original_path, Error *r_error) {
if (r_error)
- *r_error=ERR_CANT_OPEN;
+ *r_error = ERR_CANT_OPEN;
- if (p_path.extension()=="cube") {
+ if (p_path.extension() == "cube") {
// open as cubemap txture
- CubeMap* ptr = memnew(CubeMap);
- Ref<CubeMap> cubemap( ptr );
+ CubeMap *ptr = memnew(CubeMap);
+ Ref<CubeMap> cubemap(ptr);
Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err);
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
if (err) {
- ERR_FAIL_COND_V( err, RES() );
+ ERR_FAIL_COND_V(err, RES());
}
- String base_path=p_path.substr( 0, p_path.find_last("/")+1 );
+ String base_path = p_path.substr(0, p_path.find_last("/") + 1);
- for(int i=0;i<6;i++) {
+ for (int i = 0; i < 6; i++) {
String file = f->get_line().strip_edges();
Image image;
- Error err = ImageLoader::load_image(base_path+file,&image);
-
+ Error err = ImageLoader::load_image(base_path + file, &image);
if (err) {
memdelete(f);
- ERR_FAIL_COND_V( err, RES() );
+ ERR_FAIL_COND_V(err, RES());
}
- if (i==0) {
+ if (i == 0) {
//cubemap->create(image.get_width(),image.get_height(),image.get_format(),Texture::FLAGS_DEFAULT|Texture::FLAG_CUBEMAP);
}
- static const CubeMap::Side cube_side[6]= {
+ static const CubeMap::Side cube_side[6] = {
CubeMap::SIDE_LEFT,
CubeMap::SIDE_RIGHT,
CubeMap::SIDE_BOTTOM,
@@ -79,22 +78,22 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
CubeMap::SIDE_BACK
};
- cubemap->set_side(cube_side[i],image);
+ cubemap->set_side(cube_side[i], image);
}
memdelete(f);
cubemap->set_name(p_path.get_file());
if (r_error)
- *r_error=OK;
+ *r_error = OK;
return cubemap;
} else {
// simple image
- ImageTexture* ptr = memnew(ImageTexture);
- Ref<ImageTexture> texture( ptr );
+ ImageTexture *ptr = memnew(ImageTexture);
+ Ref<ImageTexture> texture(ptr);
uint64_t begtime;
double total;
@@ -102,129 +101,119 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin
Image image;
if (debug_load_times)
- begtime=OS::get_singleton()->get_ticks_usec();
+ begtime = OS::get_singleton()->get_ticks_usec();
-
- Error err = ImageLoader::load_image(p_path,&image);
+ Error err = ImageLoader::load_image(p_path, &image);
if (!err && debug_load_times) {
- double total=USEC_TO_SEC((OS::get_singleton()->get_ticks_usec()-begtime));
- print_line("IMAGE: "+itos(image.get_width())+"x"+itos(image.get_height()));
- print_line(" -load: "+rtos(total));
+ double total = USEC_TO_SEC((OS::get_singleton()->get_ticks_usec() - begtime));
+ print_line("IMAGE: " + itos(image.get_width()) + "x" + itos(image.get_height()));
+ print_line(" -load: " + rtos(total));
}
-
- ERR_EXPLAIN("Failed loading image: "+p_path);
+ ERR_EXPLAIN("Failed loading image: " + p_path);
ERR_FAIL_COND_V(err, RES());
if (r_error)
- *r_error=ERR_FILE_CORRUPT;
+ *r_error = ERR_FILE_CORRUPT;
#ifdef DEBUG_ENABLED
#ifdef TOOLS_ENABLED
if (max_texture_size && (image.get_width() > max_texture_size || image.get_height() > max_texture_size)) {
-
if (bool(Globals::get_singleton()->get("debug/max_texture_size_alert"))) {
- OS::get_singleton()->alert("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".","BAD ARTIST, NO COOKIE!");
+ OS::get_singleton()->alert("Texture is too large: '" + p_path + "', at " + itos(image.get_width()) + "x" + itos(image.get_height()) + ". Max allowed size is: " + itos(max_texture_size) + "x" + itos(max_texture_size) + ".", "BAD ARTIST, NO COOKIE!");
}
- ERR_EXPLAIN("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".");
+ ERR_EXPLAIN("Texture is too large: '" + p_path + "', at " + itos(image.get_width()) + "x" + itos(image.get_height()) + ". Max allowed size is: " + itos(max_texture_size) + "x" + itos(max_texture_size) + ".");
ERR_FAIL_V(RES());
}
#endif
#endif
-
- uint32_t flags=load_image_flags(p_path);
+ uint32_t flags = load_image_flags(p_path);
if (debug_load_times)
- begtime=OS::get_singleton()->get_ticks_usec();
+ begtime = OS::get_singleton()->get_ticks_usec();
//print_line("img: "+p_path+" flags: "+itos(flags));
- texture->create_from_image( image,flags );
+ texture->create_from_image(image, flags);
texture->set_name(p_path.get_file());
-
if (debug_load_times) {
- total=USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()-begtime);
- print_line(" -make texture: "+rtos(total));
+ total = USEC_TO_SEC(OS::get_singleton()->get_ticks_usec() - begtime);
+ print_line(" -make texture: " + rtos(total));
}
if (r_error)
- *r_error=OK;
+ *r_error = OK;
- return RES( texture );
+ return RES(texture);
}
-
-
}
uint32_t ResourceFormatLoaderImage::load_image_flags(const String &p_path) {
-
- FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ);
- Map<String,bool> flags_found;
+ FileAccess *f2 = FileAccess::open(p_path + ".flags", FileAccess::READ);
+ Map<String, bool> flags_found;
if (f2) {
- while(!f2->eof_reached()) {
+ while (!f2->eof_reached()) {
String l2 = f2->get_line();
int eqpos = l2.find("=");
- if (eqpos!=-1) {
- String flag=l2.substr(0,eqpos).strip_edges();
- String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower();
- flags_found[flag]=(val=="true" || val=="1")?true:false;
+ if (eqpos != -1) {
+ String flag = l2.substr(0, eqpos).strip_edges();
+ String val = l2.substr(eqpos + 1, l2.length()).strip_edges().to_lower();
+ flags_found[flag] = (val == "true" || val == "1") ? true : false;
}
}
memdelete(f2);
}
-
- uint32_t flags=0;
+ uint32_t flags = 0;
if (flags_found.has("filter")) {
if (flags_found["filter"])
- flags|=Texture::FLAG_FILTER;
- } else if (bool(GLOBAL_DEF("image_loader/filter",true))) {
- flags|=Texture::FLAG_FILTER;
+ flags |= Texture::FLAG_FILTER;
+ } else if (bool(GLOBAL_DEF("image_loader/filter", true))) {
+ flags |= Texture::FLAG_FILTER;
}
-
if (flags_found.has("gen_mipmaps")) {
if (flags_found["gen_mipmaps"])
- flags|=Texture::FLAG_MIPMAPS;
- } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps",true))) {
- flags|=Texture::FLAG_MIPMAPS;
+ flags |= Texture::FLAG_MIPMAPS;
+ } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps", true))) {
+ flags |= Texture::FLAG_MIPMAPS;
}
if (flags_found.has("repeat")) {
if (flags_found["repeat"])
- flags|=Texture::FLAG_REPEAT;
- } else if (bool(GLOBAL_DEF("image_loader/repeat",true))) {
- flags|=Texture::FLAG_REPEAT;
+ flags |= Texture::FLAG_REPEAT;
+ } else if (bool(GLOBAL_DEF("image_loader/repeat", true))) {
+ flags |= Texture::FLAG_REPEAT;
}
if (flags_found.has("anisotropic")) {
if (flags_found["anisotropic"])
- flags|=Texture::FLAG_ANISOTROPIC_FILTER;
+ flags |= Texture::FLAG_ANISOTROPIC_FILTER;
}
if (flags_found.has("tolinear")) {
if (flags_found["tolinear"])
- flags|=Texture::FLAG_CONVERT_TO_LINEAR;
+ flags |= Texture::FLAG_CONVERT_TO_LINEAR;
}
if (flags_found.has("mirroredrepeat")) {
if (flags_found["mirroredrepeat"])
- flags|=Texture::FLAG_MIRRORED_REPEAT;
+ flags |= Texture::FLAG_MIRRORED_REPEAT;
}
return flags;
}
-bool ResourceFormatLoaderImage::handles_type(const String& p_type) const {
+bool ResourceFormatLoaderImage::handles_type(const String &p_type) const {
- return ObjectTypeDB::is_type(p_type,"Texture") || ObjectTypeDB::is_type(p_type,"CubeMap");
+ return ObjectTypeDB::is_type(p_type, "Texture") || ObjectTypeDB::is_type(p_type, "CubeMap");
}
void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extensions) const {
@@ -235,28 +224,26 @@ void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extens
String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const {
- String ext=p_path.extension().to_lower();
- if (ext=="cube")
+ String ext = p_path.extension().to_lower();
+ if (ext == "cube")
return "CubeMap";
List<String> extensions;
ImageLoader::get_recognized_extensions(&extensions);
- for(List<String>::Element *E=extensions.front();E;E=E->next()) {
- if (E->get()==ext)
+ for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
+ if (E->get() == ext)
return "ImageTexture";
}
return "";
}
-
ResourceFormatLoaderImage::ResourceFormatLoaderImage() {
- max_texture_size = GLOBAL_DEF("debug/max_texture_size",0);
- GLOBAL_DEF("debug/max_texture_size_alert",false);
- debug_load_times=GLOBAL_DEF("debug/image_load_times",false);
- GLOBAL_DEF("image_loader/filter",true);
- GLOBAL_DEF("image_loader/gen_mipmaps",true);
- GLOBAL_DEF("image_loader/repeat",false);
-
+ max_texture_size = GLOBAL_DEF("debug/max_texture_size", 0);
+ GLOBAL_DEF("debug/max_texture_size_alert", false);
+ debug_load_times = GLOBAL_DEF("debug/image_load_times", false);
+ GLOBAL_DEF("image_loader/filter", true);
+ GLOBAL_DEF("image_loader/gen_mipmaps", true);
+ GLOBAL_DEF("image_loader/repeat", false);
}
diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h
index 6e4ead2a0..27b8fadfe 100644
--- a/scene/io/resource_format_image.h
+++ b/scene/io/resource_format_image.h
@@ -38,11 +38,12 @@ class ResourceFormatLoaderImage : public ResourceFormatLoader {
bool debug_load_times;
int max_texture_size;
+
public:
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
static uint32_t load_image_flags(const String &p_path);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
+ virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
ResourceFormatLoaderImage();
diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp
index 3720aa13f..80e280ebb 100644
--- a/scene/io/resource_format_wav.cpp
+++ b/scene/io/resource_format_wav.cpp
@@ -30,73 +30,67 @@
#include "os/file_access.h"
#include "scene/resources/sample.h"
-
-RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original_path, Error *r_error) {
+RES ResourceFormatLoaderWAV::load(const String &p_path, const String &p_original_path, Error *r_error) {
if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
+ *r_error = ERR_FILE_CANT_OPEN;
Error err;
- FileAccess *file=FileAccess::open(p_path, FileAccess::READ,&err);
+ FileAccess *file = FileAccess::open(p_path, FileAccess::READ, &err);
- ERR_FAIL_COND_V( err!=OK, RES() );
+ ERR_FAIL_COND_V(err != OK, RES());
if (r_error)
- *r_error=ERR_FILE_CORRUPT;
+ *r_error = ERR_FILE_CORRUPT;
/* CHECK RIFF */
char riff[5];
- riff[4]=0;
- file->get_buffer((uint8_t*)&riff,4); //RIFF
+ riff[4] = 0;
+ file->get_buffer((uint8_t *)&riff, 4); //RIFF
- if (riff[0]!='R' || riff[1]!='I' || riff[2]!='F' || riff[3]!='F') {
+ if (riff[0] != 'R' || riff[1] != 'I' || riff[2] != 'F' || riff[3] != 'F') {
file->close();
memdelete(file);
- ERR_FAIL_V( RES() );
+ ERR_FAIL_V(RES());
}
-
/* GET FILESIZE */
- uint32_t filesize=file->get_32();
+ uint32_t filesize = file->get_32();
/* CHECK WAVE */
char wave[4];
- file->get_buffer((uint8_t*)&wave,4); //RIFF
-
- if (wave[0]!='W' || wave[1]!='A' || wave[2]!='V' || wave[3]!='E') {
+ file->get_buffer((uint8_t *)&wave, 4); //RIFF
+ if (wave[0] != 'W' || wave[1] != 'A' || wave[2] != 'V' || wave[3] != 'E') {
file->close();
memdelete(file);
ERR_EXPLAIN("Not a WAV file (no WAVE RIFF Header)")
- ERR_FAIL_V( RES() );
+ ERR_FAIL_V(RES());
}
- bool format_found=false;
- bool data_found=false;
- int format_bits=0;
- int format_channels=0;
- int format_freq=0;
- Sample::LoopFormat loop=Sample::LOOP_NONE;
- int loop_begin=0;
- int loop_end=0;
-
-
- Ref<Sample> sample( memnew( Sample ) );
+ bool format_found = false;
+ bool data_found = false;
+ int format_bits = 0;
+ int format_channels = 0;
+ int format_freq = 0;
+ Sample::LoopFormat loop = Sample::LOOP_NONE;
+ int loop_begin = 0;
+ int loop_end = 0;
+ Ref<Sample> sample(memnew(Sample));
while (!file->eof_reached()) {
-
/* chunk */
char chunkID[4];
- file->get_buffer((uint8_t*)&chunkID,4); //RIFF
+ file->get_buffer((uint8_t *)&chunkID, 4); //RIFF
/* chunk size */
- uint32_t chunksize=file->get_32();
- uint32_t file_pos=file->get_pos(); //save file pos, so we can skip to next chunk safely
+ uint32_t chunksize = file->get_32();
+ uint32_t file_pos = file->get_pos(); //save file pos, so we can skip to next chunk safely
if (file->eof_reached()) {
@@ -104,122 +98,113 @@ RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original
break;
}
- if (chunkID[0]=='f' && chunkID[1]=='m' && chunkID[2]=='t' && chunkID[3]==' ' && !format_found) {
+ if (chunkID[0] == 'f' && chunkID[1] == 'm' && chunkID[2] == 't' && chunkID[3] == ' ' && !format_found) {
/* IS FORMAT CHUNK */
- uint16_t compression_code=file->get_16();
-
+ uint16_t compression_code = file->get_16();
- if (compression_code!=1) {
+ if (compression_code != 1) {
ERR_PRINT("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead.");
break;
}
- format_channels=file->get_16();
- if (format_channels!=1 && format_channels !=2) {
+ format_channels = file->get_16();
+ if (format_channels != 1 && format_channels != 2) {
ERR_PRINT("Format not supported for WAVE file (not stereo or mono)");
break;
-
}
- format_freq=file->get_32(); //sampling rate
+ format_freq = file->get_32(); //sampling rate
file->get_32(); // average bits/second (unused)
file->get_16(); // block align (unused)
- format_bits=file->get_16(); // bits per sample
+ format_bits = file->get_16(); // bits per sample
- if (format_bits%8) {
+ if (format_bits % 8) {
ERR_PRINT("Strange number of bits in sample (not 8,16,24,32)");
break;
}
/* Dont need anything else, continue */
- format_found=true;
+ format_found = true;
}
-
- if (chunkID[0]=='d' && chunkID[1]=='a' && chunkID[2]=='t' && chunkID[3]=='a' && !data_found) {
+ if (chunkID[0] == 'd' && chunkID[1] == 'a' && chunkID[2] == 't' && chunkID[3] == 'a' && !data_found) {
/* IS FORMAT CHUNK */
- data_found=true;
+ data_found = true;
if (!format_found) {
ERR_PRINT("'data' chunk before 'format' chunk found.");
break;
-
}
- int frames=chunksize;
+ int frames = chunksize;
- frames/=format_channels;
- frames/=(format_bits>>3);
+ frames /= format_channels;
+ frames /= (format_bits >> 3);
/*print_line("chunksize: "+itos(chunksize));
print_line("channels: "+itos(format_channels));
print_line("bits: "+itos(format_bits));
*/
sample->create(
- (format_bits==8) ? Sample::FORMAT_PCM8 : Sample::FORMAT_PCM16,
- (format_channels==2)?true:false,
- frames );
- sample->set_mix_rate( format_freq );
+ (format_bits == 8) ? Sample::FORMAT_PCM8 : Sample::FORMAT_PCM16,
+ (format_channels == 2) ? true : false,
+ frames);
+ sample->set_mix_rate(format_freq);
- int len=frames;
- if (format_channels==2)
- len*=2;
- if (format_bits>8)
- len*=2;
+ int len = frames;
+ if (format_channels == 2)
+ len *= 2;
+ if (format_bits > 8)
+ len *= 2;
DVector<uint8_t> data;
data.resize(len);
DVector<uint8_t>::Write dataw = data.write();
- void * data_ptr = dataw.ptr();
+ void *data_ptr = dataw.ptr();
- for (int i=0;i<frames;i++) {
+ for (int i = 0; i < frames; i++) {
+ for (int c = 0; c < format_channels; c++) {
- for (int c=0;c<format_channels;c++) {
-
-
- if (format_bits==8) {
+ if (format_bits == 8) {
// 8 bit samples are UNSIGNED
uint8_t s = file->get_8();
- s-=128;
- int8_t *sp=(int8_t*)&s;
+ s -= 128;
+ int8_t *sp = (int8_t *)&s;
- int8_t *data_ptr8=&((int8_t*)data_ptr)[i*format_channels+c];
+ int8_t *data_ptr8 = &((int8_t *)data_ptr)[i * format_channels + c];
- *data_ptr8=*sp;
+ *data_ptr8 = *sp;
} else {
//16+ bits samples are SIGNED
// if sample is > 16 bits, just read extra bytes
- uint32_t data=0;
- for (int b=0;b<(format_bits>>3);b++) {
+ uint32_t data = 0;
+ for (int b = 0; b < (format_bits >> 3); b++) {
- data|=((uint32_t)file->get_8())<<(b*8);
+ data |= ((uint32_t)file->get_8()) << (b * 8);
}
- data<<=(32-format_bits);
-
+ data <<= (32 - format_bits);
- int32_t s=data;
+ int32_t s = data;
- int16_t *data_ptr16=&((int16_t*)data_ptr)[i*format_channels+c];
+ int16_t *data_ptr16 = &((int16_t *)data_ptr)[i * format_channels + c];
- *data_ptr16=s>>16;
+ *data_ptr16 = s >> 16;
}
}
-
}
- dataw=DVector<uint8_t>::Write();
+ dataw = DVector<uint8_t>::Write();
sample->set_data(data);
-
if (file->eof_reached()) {
file->close();
memdelete(file);
@@ -228,18 +213,17 @@ RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original
}
}
- if (chunkID[0]=='s' && chunkID[1]=='m' && chunkID[2]=='p' && chunkID[3]=='l') {
+ if (chunkID[0] == 's' && chunkID[1] == 'm' && chunkID[2] == 'p' && chunkID[3] == 'l') {
//loop point info!
- for(int i=0;i<10;i++)
+ for (int i = 0; i < 10; i++)
file->get_32(); // i wish to know why should i do this... no doc!
- loop=file->get_32()?Sample::LOOP_PING_PONG:Sample::LOOP_FORWARD;
- loop_begin=file->get_32();
- loop_end=file->get_32();
-
+ loop = file->get_32() ? Sample::LOOP_PING_PONG : Sample::LOOP_FORWARD;
+ loop_begin = file->get_32();
+ loop_end = file->get_32();
}
- file->seek( file_pos+chunksize );
+ file->seek(file_pos + chunksize);
}
sample->set_loop_format(loop);
@@ -250,25 +234,22 @@ RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original
memdelete(file);
if (r_error)
- *r_error=OK;
-
+ *r_error = OK;
return sample;
-
}
void ResourceFormatLoaderWAV::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("wav");
}
-bool ResourceFormatLoaderWAV::handles_type(const String& p_type) const {
+bool ResourceFormatLoaderWAV::handles_type(const String &p_type) const {
- return (p_type=="Sample");
+ return (p_type == "Sample");
}
String ResourceFormatLoaderWAV::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="wav")
+ if (p_path.extension().to_lower() == "wav")
return "Sample";
return "";
}
-
diff --git a/scene/io/resource_format_wav.h b/scene/io/resource_format_wav.h
index 3a278b455..5b10bc1d5 100644
--- a/scene/io/resource_format_wav.h
+++ b/scene/io/resource_format_wav.h
@@ -33,11 +33,10 @@
class ResourceFormatLoaderWAV : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
+ virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
-
};
#endif // RESOURCE_FORMAT_WAV_H
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 1de19959d..5898665ff 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -29,27 +29,24 @@
#include "canvas_layer.h"
#include "viewport.h"
-
void CanvasLayer::set_layer(int p_xform) {
- layer=p_xform;
+ layer = p_xform;
if (viewport.is_valid())
- VisualServer::get_singleton()->viewport_set_canvas_layer(viewport,canvas->get_canvas(),layer);
-
+ VisualServer::get_singleton()->viewport_set_canvas_layer(viewport, canvas->get_canvas(), layer);
}
-int CanvasLayer::get_layer() const{
+int CanvasLayer::get_layer() const {
return layer;
}
-void CanvasLayer::set_transform(const Matrix32& p_xform) {
+void CanvasLayer::set_transform(const Matrix32 &p_xform) {
- transform=p_xform;
- locrotscale_dirty=true;
+ transform = p_xform;
+ locrotscale_dirty = true;
if (viewport.is_valid())
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport,canvas->get_canvas(),transform);
-
+ VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas->get_canvas(), transform);
}
Matrix32 CanvasLayer::get_transform() const {
@@ -59,56 +56,50 @@ Matrix32 CanvasLayer::get_transform() const {
void CanvasLayer::_update_xform() {
- transform.set_rotation_and_scale(rot,scale);
+ transform.set_rotation_and_scale(rot, scale);
transform.set_origin(ofs);
if (viewport.is_valid())
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport,canvas->get_canvas(),transform);
-
+ VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas->get_canvas(), transform);
}
void CanvasLayer::_update_locrotscale() {
- ofs=transform.elements[2];
- rot=transform.get_rotation();
- scale=transform.get_scale();
- locrotscale_dirty=false;
+ ofs = transform.elements[2];
+ rot = transform.get_rotation();
+ scale = transform.get_scale();
+ locrotscale_dirty = false;
}
-
-void CanvasLayer::set_offset(const Vector2& p_offset) {
+void CanvasLayer::set_offset(const Vector2 &p_offset) {
if (locrotscale_dirty)
_update_locrotscale();
- ofs=p_offset;
+ ofs = p_offset;
_update_xform();
-
}
Vector2 CanvasLayer::get_offset() const {
if (locrotscale_dirty)
- const_cast<CanvasLayer*>(this)->_update_locrotscale();
+ const_cast<CanvasLayer *>(this)->_update_locrotscale();
return ofs;
}
-
void CanvasLayer::set_rotation(real_t p_radians) {
if (locrotscale_dirty)
_update_locrotscale();
-
- rot=p_radians;
+ rot = p_radians;
_update_xform();
-
}
real_t CanvasLayer::get_rotation() const {
if (locrotscale_dirty)
- const_cast<CanvasLayer*>(this)->_update_locrotscale();
+ const_cast<CanvasLayer *>(this)->_update_locrotscale();
return rot;
}
@@ -137,26 +128,23 @@ real_t CanvasLayer::_get_rotationd() const {
return get_rotationd();
}
-void CanvasLayer::set_scale(const Vector2& p_scale) {
+void CanvasLayer::set_scale(const Vector2 &p_scale) {
if (locrotscale_dirty)
_update_locrotscale();
- scale=p_scale;
+ scale = p_scale;
_update_xform();
-
}
Vector2 CanvasLayer::get_scale() const {
if (locrotscale_dirty)
- const_cast<CanvasLayer*>(this)->_update_locrotscale();
+ const_cast<CanvasLayer *>(this)->_update_locrotscale();
return scale;
}
-
-
Ref<World2D> CanvasLayer::get_world_2d() const {
return canvas;
@@ -164,30 +152,28 @@ Ref<World2D> CanvasLayer::get_world_2d() const {
void CanvasLayer::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (custom_viewport && ObjectDB::get_instance(custom_viewport_id)) {
- vp=custom_viewport;
+ vp = custom_viewport;
} else {
- vp=Node::get_viewport();
-
+ vp = Node::get_viewport();
}
ERR_FAIL_COND(!vp);
- viewport=vp->get_viewport();
-
- VisualServer::get_singleton()->viewport_attach_canvas(viewport,canvas->get_canvas());
- VisualServer::get_singleton()->viewport_set_canvas_layer(viewport,canvas->get_canvas(),layer);
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport,canvas->get_canvas(),transform);
+ viewport = vp->get_viewport();
+ VisualServer::get_singleton()->viewport_attach_canvas(viewport, canvas->get_canvas());
+ VisualServer::get_singleton()->viewport_set_canvas_layer(viewport, canvas->get_canvas(), layer);
+ VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas->get_canvas(), transform);
} break;
case NOTIFICATION_EXIT_TREE: {
- VisualServer::get_singleton()->viewport_remove_canvas(viewport,canvas->get_canvas());
- viewport=RID();
+ VisualServer::get_singleton()->viewport_remove_canvas(viewport, canvas->get_canvas());
+ viewport = RID();
} break;
}
@@ -196,14 +182,12 @@ void CanvasLayer::_notification(int p_what) {
Size2 CanvasLayer::get_viewport_size() const {
if (!is_inside_tree())
- return Size2(1,1);
-
+ return Size2(1, 1);
Rect2 r = vp->get_visible_rect();
return r.size;
}
-
RID CanvasLayer::get_viewport() const {
return viewport;
@@ -212,88 +196,83 @@ RID CanvasLayer::get_viewport() const {
void CanvasLayer::set_custom_viewport(Node *p_viewport) {
ERR_FAIL_NULL(p_viewport);
if (is_inside_tree()) {
- VisualServer::get_singleton()->viewport_remove_canvas(viewport,canvas->get_canvas());
- viewport=RID();
+ VisualServer::get_singleton()->viewport_remove_canvas(viewport, canvas->get_canvas());
+ viewport = RID();
}
- custom_viewport=p_viewport->cast_to<Viewport>();
+ custom_viewport = p_viewport->cast_to<Viewport>();
if (custom_viewport) {
- custom_viewport_id=custom_viewport->get_instance_ID();
+ custom_viewport_id = custom_viewport->get_instance_ID();
} else {
- custom_viewport_id=0;
+ custom_viewport_id = 0;
}
if (is_inside_tree()) {
-
if (custom_viewport)
- vp=custom_viewport;
+ vp = custom_viewport;
else
- vp=Node::get_viewport();
+ vp = Node::get_viewport();
viewport = vp->get_viewport();
- VisualServer::get_singleton()->viewport_attach_canvas(viewport,canvas->get_canvas());
- VisualServer::get_singleton()->viewport_set_canvas_layer(viewport,canvas->get_canvas(),layer);
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport,canvas->get_canvas(),transform);
+ VisualServer::get_singleton()->viewport_attach_canvas(viewport, canvas->get_canvas());
+ VisualServer::get_singleton()->viewport_set_canvas_layer(viewport, canvas->get_canvas(), layer);
+ VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas->get_canvas(), transform);
}
-
}
-Node* CanvasLayer::get_custom_viewport() const {
+Node *CanvasLayer::get_custom_viewport() const {
return custom_viewport;
}
-
void CanvasLayer::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_layer", "layer"), &CanvasLayer::set_layer);
+ ObjectTypeDB::bind_method(_MD("get_layer"), &CanvasLayer::get_layer);
- ObjectTypeDB::bind_method(_MD("set_layer","layer"),&CanvasLayer::set_layer);
- ObjectTypeDB::bind_method(_MD("get_layer"),&CanvasLayer::get_layer);
+ ObjectTypeDB::bind_method(_MD("set_transform", "transform"), &CanvasLayer::set_transform);
+ ObjectTypeDB::bind_method(_MD("get_transform"), &CanvasLayer::get_transform);
- ObjectTypeDB::bind_method(_MD("set_transform","transform"),&CanvasLayer::set_transform);
- ObjectTypeDB::bind_method(_MD("get_transform"),&CanvasLayer::get_transform);
+ ObjectTypeDB::bind_method(_MD("set_offset", "offset"), &CanvasLayer::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &CanvasLayer::get_offset);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&CanvasLayer::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&CanvasLayer::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_rotation", "radians"), &CanvasLayer::set_rotation);
+ ObjectTypeDB::bind_method(_MD("get_rotation"), &CanvasLayer::get_rotation);
- ObjectTypeDB::bind_method(_MD("set_rotation","radians"),&CanvasLayer::set_rotation);
- ObjectTypeDB::bind_method(_MD("get_rotation"),&CanvasLayer::get_rotation);
-
- ObjectTypeDB::bind_method(_MD("set_rotationd","degrees"),&CanvasLayer::set_rotationd);
- ObjectTypeDB::bind_method(_MD("get_rotationd"),&CanvasLayer::get_rotationd);
+ ObjectTypeDB::bind_method(_MD("set_rotationd", "degrees"), &CanvasLayer::set_rotationd);
+ ObjectTypeDB::bind_method(_MD("get_rotationd"), &CanvasLayer::get_rotationd);
// TODO: Obsolete those two methods (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_set_rotationd","degrees"),&CanvasLayer::_set_rotationd);
- ObjectTypeDB::bind_method(_MD("_get_rotationd"),&CanvasLayer::_get_rotationd);
+ ObjectTypeDB::bind_method(_MD("_set_rotationd", "degrees"), &CanvasLayer::_set_rotationd);
+ ObjectTypeDB::bind_method(_MD("_get_rotationd"), &CanvasLayer::_get_rotationd);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"),&CanvasLayer::set_scale);
- ObjectTypeDB::bind_method(_MD("get_scale"),&CanvasLayer::get_scale);
+ ObjectTypeDB::bind_method(_MD("set_scale", "scale"), &CanvasLayer::set_scale);
+ ObjectTypeDB::bind_method(_MD("get_scale"), &CanvasLayer::get_scale);
- ObjectTypeDB::bind_method(_MD("set_custom_viewport","viewport:Viewport"),&CanvasLayer::set_custom_viewport);
- ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"),&CanvasLayer::get_custom_viewport);
+ ObjectTypeDB::bind_method(_MD("set_custom_viewport", "viewport:Viewport"), &CanvasLayer::set_custom_viewport);
+ ObjectTypeDB::bind_method(_MD("get_custom_viewport:Viewport"), &CanvasLayer::get_custom_viewport);
- ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"),&CanvasLayer::get_world_2d);
-// ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasLayer::get_viewport);
+ ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"), &CanvasLayer::get_world_2d);
+ // ObjectTypeDB::bind_method(_MD("get_viewport"),&CanvasLayer::get_viewport);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"layer",PROPERTY_HINT_RANGE,"-128,128,1"),_SCS("set_layer"),_SCS("get_layer") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "layer", PROPERTY_HINT_RANGE, "-128,128,1"), _SCS("set_layer"), _SCS("get_layer"));
//ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),_SCS("set_transform"),_SCS("get_transform") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"rotation"),_SCS("set_rotationd"),_SCS("get_rotationd") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scale"),_SCS("set_scale"),_SCS("get_scale") );
-
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), _SCS("set_offset"), _SCS("get_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), _SCS("set_rotationd"), _SCS("get_rotationd"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), _SCS("set_scale"), _SCS("get_scale"));
}
CanvasLayer::CanvasLayer() {
- vp=NULL;
- scale=Vector2(1,1);
- rot=0;
- locrotscale_dirty=false;
- layer=1;
- canvas = Ref<World2D>( memnew(World2D) );
- custom_viewport=NULL;
- custom_viewport_id=0;
+ vp = NULL;
+ scale = Vector2(1, 1);
+ rot = 0;
+ locrotscale_dirty = false;
+ layer = 1;
+ canvas = Ref<World2D>(memnew(World2D));
+ custom_viewport = NULL;
+ custom_viewport_id = 0;
}
diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h
index 039db8823..0472b66ec 100644
--- a/scene/main/canvas_layer.h
+++ b/scene/main/canvas_layer.h
@@ -32,11 +32,10 @@
#include "scene/main/node.h"
#include "scene/resources/world_2d.h"
-
class Viewport;
class CanvasLayer : public Node {
- OBJ_TYPE( CanvasLayer, Node );
+ OBJ_TYPE(CanvasLayer, Node);
bool locrotscale_dirty;
Vector2 ofs;
@@ -59,20 +58,18 @@ class CanvasLayer : public Node {
void _update_xform();
void _update_locrotscale();
-
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_layer(int p_xform);
int get_layer() const;
- void set_transform(const Matrix32& p_xform);
+ void set_transform(const Matrix32 &p_xform);
Matrix32 get_transform() const;
- void set_offset(const Vector2& p_offset);
+ void set_offset(const Vector2 &p_offset);
Vector2 get_offset() const;
void set_rotation(real_t p_radians);
@@ -81,7 +78,7 @@ public:
void set_rotationd(real_t p_degrees);
real_t get_rotationd() const;
- void set_scale(const Size2& p_scale);
+ void set_scale(const Size2 &p_scale);
Size2 get_scale() const;
Ref<World2D> get_world_2d() const;
@@ -91,7 +88,7 @@ public:
RID get_viewport() const;
void set_custom_viewport(Node *p_viewport);
- Node* get_custom_viewport() const;
+ Node *get_custom_viewport() const;
CanvasLayer();
};
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 4203edda7..d977548d6 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -32,41 +32,39 @@ void HTTPRequest::set_ip_type(IP::Type p_type) {
client->set_ip_type(p_type);
}
-void HTTPRequest::_redirect_request(const String& p_new_url) {
-
-
+void HTTPRequest::_redirect_request(const String &p_new_url) {
}
Error HTTPRequest::_request() {
//print_line("Requesting:\n\tURL: "+url+"\n\tString: "+request_string+"\n\tPort: "+itos(port)+"\n\tSSL: "+itos(use_ssl)+"\n\tValidate SSL: "+itos(validate_ssl));
- return client->connect(url,port,use_ssl,validate_ssl);
+ return client->connect(url, port, use_ssl, validate_ssl);
}
-Error HTTPRequest::_parse_url(const String& p_url) {
+Error HTTPRequest::_parse_url(const String &p_url) {
- url=p_url;
- use_ssl=false;
+ url = p_url;
+ use_ssl = false;
- request_string="";
- port=80;
- request_sent=false;
- got_response=false;
- body_len=-1;
+ request_string = "";
+ port = 80;
+ request_sent = false;
+ got_response = false;
+ body_len = -1;
body.resize(0);
- downloaded=0;
- redirections=0;
+ downloaded = 0;
+ redirections = 0;
//print_line("1 url: "+url);
if (url.begins_with("http://")) {
- url=url.substr(7,url.length()-7);
+ url = url.substr(7, url.length() - 7);
//print_line("no SSL");
} else if (url.begins_with("https://")) {
- url=url.substr(8,url.length()-8);
- use_ssl=true;
- port=443;
+ url = url.substr(8, url.length() - 8);
+ use_ssl = true;
+ port = 443;
//print_line("yes SSL");
} else {
ERR_EXPLAIN("Malformed URL");
@@ -77,22 +75,22 @@ Error HTTPRequest::_parse_url(const String& p_url) {
int slash_pos = url.find("/");
- if (slash_pos!=-1) {
- request_string=url.substr(slash_pos,url.length());
- url=url.substr(0,slash_pos);
+ if (slash_pos != -1) {
+ request_string = url.substr(slash_pos, url.length());
+ url = url.substr(0, slash_pos);
//print_line("request string: "+request_string);
} else {
- request_string="/";
+ request_string = "/";
//print_line("no request");
}
//print_line("3 url: "+url);
int colon_pos = url.find(":");
- if (colon_pos!=-1) {
- port=url.substr(colon_pos+1,url.length()).to_int();
- url=url.substr(0,colon_pos);
- ERR_FAIL_COND_V(port<1 || port > 65535,ERR_INVALID_PARAMETER);
+ if (colon_pos != -1) {
+ port = url.substr(colon_pos + 1, url.length()).to_int();
+ url = url.substr(0, colon_pos);
+ ERR_FAIL_COND_V(port < 1 || port > 65535, ERR_INVALID_PARAMETER);
}
//print_line("4 url: "+url);
@@ -100,79 +98,76 @@ Error HTTPRequest::_parse_url(const String& p_url) {
return OK;
}
-Error HTTPRequest::request(const String& p_url, const Vector<String>& p_custom_headers, bool p_ssl_validate_domain, HTTPClient::Method p_method, const String& p_request_data) {
+Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_headers, bool p_ssl_validate_domain, HTTPClient::Method p_method, const String &p_request_data) {
- ERR_FAIL_COND_V(!is_inside_tree(),ERR_UNCONFIGURED);
- if ( requesting ) {
+ ERR_FAIL_COND_V(!is_inside_tree(), ERR_UNCONFIGURED);
+ if (requesting) {
ERR_EXPLAIN("HTTPRequest is processing a request. Wait for completion or cancel it before attempting a new one.");
ERR_FAIL_V(ERR_BUSY);
}
- method=p_method;
+ method = p_method;
Error err = _parse_url(p_url);
if (err)
return err;
- validate_ssl=p_ssl_validate_domain;
+ validate_ssl = p_ssl_validate_domain;
- bool has_user_agent=false;
- bool has_accept=false;
- headers=p_custom_headers;
+ bool has_user_agent = false;
+ bool has_accept = false;
+ headers = p_custom_headers;
request_data = p_request_data;
- for(int i=0;i<headers.size();i++) {
+ for (int i = 0; i < headers.size(); i++) {
- if (headers[i].findn("user-agent:")==0)
- has_user_agent=true;
- if (headers[i].findn("Accept:")==0)
- has_accept=true;
+ if (headers[i].findn("user-agent:") == 0)
+ has_user_agent = true;
+ if (headers[i].findn("Accept:") == 0)
+ has_accept = true;
}
if (!has_user_agent) {
- headers.push_back("User-Agent: GodotEngine/"+String(VERSION_MKSTRING)+" ("+OS::get_singleton()->get_name()+")");
+ headers.push_back("User-Agent: GodotEngine/" + String(VERSION_MKSTRING) + " (" + OS::get_singleton()->get_name() + ")");
}
if (!has_accept) {
headers.push_back("Accept: */*");
}
- requesting=true;
+ requesting = true;
if (use_threads) {
- thread_done=false;
- thread_request_quit=false;
+ thread_done = false;
+ thread_request_quit = false;
client->set_blocking_mode(true);
- thread=Thread::create(_thread_func,this);
+ thread = Thread::create(_thread_func, this);
} else {
client->set_blocking_mode(false);
err = _request();
- if (err!=OK) {
- call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
+ if (err != OK) {
+ call_deferred("_request_done", RESULT_CANT_CONNECT, 0, StringArray(), ByteArray());
return ERR_CANT_CONNECT;
}
set_process(true);
-
}
-
return OK;
}
-
void HTTPRequest::_thread_func(void *p_userdata) {
- HTTPRequest *hr = (HTTPRequest*)p_userdata;
+ HTTPRequest *hr = (HTTPRequest *)p_userdata;
Error err = hr->_request();
- if (err!=OK) {
- hr->call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
+ if (err != OK) {
+ hr->call_deferred("_request_done", RESULT_CANT_CONNECT, 0, StringArray(), ByteArray());
} else {
- while(!hr->thread_request_quit) {
+ while (!hr->thread_request_quit) {
bool exit = hr->_update_connection();
if (exit)
@@ -181,7 +176,7 @@ void HTTPRequest::_thread_func(void *p_userdata) {
}
}
- hr->thread_done=true;
+ hr->thread_done = true;
}
void HTTPRequest::cancel_request() {
@@ -192,90 +187,88 @@ void HTTPRequest::cancel_request() {
if (!use_threads) {
set_process(false);
} else {
- thread_request_quit=true;
+ thread_request_quit = true;
Thread::wait_to_finish(thread);
memdelete(thread);
- thread=NULL;
+ thread = NULL;
}
if (file) {
memdelete(file);
- file=NULL;
+ file = NULL;
}
client->close();
body.resize(0);
//downloaded=0;
- got_response=false;
- response_code=-1;
+ got_response = false;
+ response_code = -1;
//body_len=-1;
- request_sent=false;
- requesting=false;
+ request_sent = false;
+ requesting = false;
}
-
bool HTTPRequest::_handle_response(bool *ret_value) {
if (!client->has_response()) {
- call_deferred("_request_done",RESULT_NO_RESPONSE,0,StringArray(),ByteArray());
- *ret_value=true;
+ call_deferred("_request_done", RESULT_NO_RESPONSE, 0, StringArray(), ByteArray());
+ *ret_value = true;
return true;
}
- got_response=true;
- response_code=client->get_response_code();
+ got_response = true;
+ response_code = client->get_response_code();
List<String> rheaders;
client->get_response_headers(&rheaders);
response_headers.resize(0);
- downloaded=0;
- for (List<String>::Element *E=rheaders.front();E;E=E->next()) {
+ downloaded = 0;
+ for (List<String>::Element *E = rheaders.front(); E; E = E->next()) {
//print_line("HEADER: "+E->get());
response_headers.push_back(E->get());
}
- if (response_code==301 || response_code==302) {
+ if (response_code == 301 || response_code == 302) {
//redirect
- if (max_redirects>=0 && redirections>=max_redirects) {
+ if (max_redirects >= 0 && redirections >= max_redirects) {
- call_deferred("_request_done",RESULT_REDIRECT_LIMIT_REACHED,response_code,response_headers,ByteArray());
- *ret_value=true;
+ call_deferred("_request_done", RESULT_REDIRECT_LIMIT_REACHED, response_code, response_headers, ByteArray());
+ *ret_value = true;
return true;
}
String new_request;
- for (List<String>::Element *E=rheaders.front();E;E=E->next()) {
- if (E->get().findn("Location: ")!=-1) {
- new_request=E->get().substr(9,E->get().length()).strip_edges();
+ for (List<String>::Element *E = rheaders.front(); E; E = E->next()) {
+ if (E->get().findn("Location: ") != -1) {
+ new_request = E->get().substr(9, E->get().length()).strip_edges();
}
}
//print_line("NEW LOCATION: "+new_request);
- if (new_request!="") {
+ if (new_request != "") {
//process redirect
client->close();
- int new_redirs=redirections+1; //because _request() will clear it
+ int new_redirs = redirections + 1; //because _request() will clear it
Error err;
if (new_request.begins_with("http")) {
//new url, request all again
- err=_parse_url(new_request);
+ err = _parse_url(new_request);
} else {
- request_string=new_request;
+ request_string = new_request;
}
err = _request();
//print_line("new connection: "+itos(err));
- if (err==OK) {
- request_sent=false;
- got_response=false;
- body_len=-1;
+ if (err == OK) {
+ request_sent = false;
+ got_response = false;
+ body_len = -1;
body.resize(0);
- downloaded=0;
- redirections=new_redirs;
- *ret_value=false;
+ downloaded = 0;
+ redirections = new_redirs;
+ *ret_value = false;
return true;
-
}
}
}
@@ -283,12 +276,11 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
return false;
}
-
bool HTTPRequest::_update_connection() {
- switch( client->get_status() ) {
+ switch (client->get_status()) {
case HTTPClient::STATUS_DISCONNECTED: {
- call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
+ call_deferred("_request_done", RESULT_CANT_CONNECT, 0, StringArray(), ByteArray());
return true; //end it, since it's doing something
} break;
case HTTPClient::STATUS_RESOLVING: {
@@ -297,7 +289,7 @@ bool HTTPRequest::_update_connection() {
return false;
} break;
case HTTPClient::STATUS_CANT_RESOLVE: {
- call_deferred("_request_done",RESULT_CANT_RESOLVE,0,StringArray(),ByteArray());
+ call_deferred("_request_done", RESULT_CANT_RESOLVE, 0, StringArray(), ByteArray());
return true;
} break;
@@ -308,7 +300,7 @@ bool HTTPRequest::_update_connection() {
} break; //connecting to ip
case HTTPClient::STATUS_CANT_CONNECT: {
- call_deferred("_request_done",RESULT_CANT_CONNECT,0,StringArray(),ByteArray());
+ call_deferred("_request_done", RESULT_CANT_CONNECT, 0, StringArray(), ByteArray());
return true;
} break;
@@ -325,30 +317,28 @@ bool HTTPRequest::_update_connection() {
if (_handle_response(&ret_value))
return ret_value;
-
- call_deferred("_request_done",RESULT_SUCCESS,response_code,response_headers,ByteArray());
+ call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, ByteArray());
return true;
}
- if (got_response && body_len<0) {
+ if (got_response && body_len < 0) {
//chunked transfer is done
- call_deferred("_request_done",RESULT_SUCCESS,response_code,response_headers,body);
+ call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body);
return true;
-
}
- call_deferred("_request_done",RESULT_CHUNKED_BODY_SIZE_MISMATCH,response_code,response_headers,ByteArray());
+ call_deferred("_request_done", RESULT_CHUNKED_BODY_SIZE_MISMATCH, response_code, response_headers, ByteArray());
return true;
//request migh have been done
} else {
//did not request yet, do request
- Error err = client->request(method,request_string,headers,request_data);
- if (err!=OK) {
- call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,StringArray(),ByteArray());
+ Error err = client->request(method, request_string, headers, request_data);
+ if (err != OK) {
+ call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, StringArray(), ByteArray());
return true;
}
- request_sent=true;
+ request_sent = true;
return false;
}
} break; //connected: { } break requests only accepted here
@@ -362,67 +352,64 @@ bool HTTPRequest::_update_connection() {
if (!got_response) {
-
bool ret_value;
if (_handle_response(&ret_value))
return ret_value;
- if (!client->is_response_chunked() && client->get_response_body_length()==0) {
+ if (!client->is_response_chunked() && client->get_response_body_length() == 0) {
- call_deferred("_request_done",RESULT_SUCCESS,response_code,response_headers,ByteArray());
+ call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, ByteArray());
return true;
}
-
if (client->is_response_chunked()) {
- body_len=-1; //no body len because chunked, change your webserver configuration if you want body len
+ body_len = -1; //no body len because chunked, change your webserver configuration if you want body len
} else {
- body_len=client->get_response_body_length();
+ body_len = client->get_response_body_length();
- if (body_size_limit>=0 && body_len>body_size_limit) {
- call_deferred("_request_done",RESULT_BODY_SIZE_LIMIT_EXCEEDED,response_code,response_headers,ByteArray());
+ if (body_size_limit >= 0 && body_len > body_size_limit) {
+ call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, ByteArray());
return true;
}
}
- if (download_to_file!=String()) {
- file=FileAccess::open(download_to_file,FileAccess::WRITE);
+ if (download_to_file != String()) {
+ file = FileAccess::open(download_to_file, FileAccess::WRITE);
if (!file) {
- call_deferred("_request_done",RESULT_DOWNLOAD_FILE_CANT_OPEN,response_code,response_headers,ByteArray());
+ call_deferred("_request_done", RESULT_DOWNLOAD_FILE_CANT_OPEN, response_code, response_headers, ByteArray());
return true;
}
}
}
-
//print_line("BODY: "+itos(body.size()));
client->poll();
ByteArray chunk = client->read_response_body_chunk();
- downloaded+=chunk.size();
+ downloaded += chunk.size();
if (file) {
- ByteArray::Read r=chunk.read();
- file->store_buffer(r.ptr(),chunk.size());
- if (file->get_error()!=OK) {
- call_deferred("_request_done",RESULT_DOWNLOAD_FILE_WRITE_ERROR,response_code,response_headers,ByteArray());
+ ByteArray::Read r = chunk.read();
+ file->store_buffer(r.ptr(), chunk.size());
+ if (file->get_error() != OK) {
+ call_deferred("_request_done", RESULT_DOWNLOAD_FILE_WRITE_ERROR, response_code, response_headers, ByteArray());
return true;
}
} else {
body.append_array(chunk);
}
- if (body_size_limit>=0 && downloaded>body_size_limit) {
- call_deferred("_request_done",RESULT_BODY_SIZE_LIMIT_EXCEEDED,response_code,response_headers,ByteArray());
+ if (body_size_limit >= 0 && downloaded > body_size_limit) {
+ call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, ByteArray());
return true;
}
- if (body_len>=0) {
+ if (body_len >= 0) {
- if (downloaded==body_len) {
- call_deferred("_request_done",RESULT_SUCCESS,response_code,response_headers,body);
+ if (downloaded == body_len) {
+ call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body);
return true;
}
/*if (body.size()>=body_len) {
@@ -435,31 +422,27 @@ bool HTTPRequest::_update_connection() {
} break; // request resulted in body: { } break which must be read
case HTTPClient::STATUS_CONNECTION_ERROR: {
- call_deferred("_request_done",RESULT_CONNECTION_ERROR,0,StringArray(),ByteArray());
+ call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, StringArray(), ByteArray());
return true;
} break;
case HTTPClient::STATUS_SSL_HANDSHAKE_ERROR: {
- call_deferred("_request_done",RESULT_SSL_HANDSHAKE_ERROR,0,StringArray(),ByteArray());
+ call_deferred("_request_done", RESULT_SSL_HANDSHAKE_ERROR, 0, StringArray(), ByteArray());
return true;
} break;
-
}
ERR_FAIL_V(false);
}
-
-void HTTPRequest::_request_done(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data) {
-
+void HTTPRequest::_request_done(int p_status, int p_code, const StringArray &headers, const ByteArray &p_data) {
cancel_request();
- emit_signal("request_completed",p_status,p_code,headers,p_data);
+ emit_signal("request_completed", p_status, p_code, headers, p_data);
}
-
void HTTPRequest::_notification(int p_what) {
- if (p_what==NOTIFICATION_PROCESS) {
+ if (p_what == NOTIFICATION_PROCESS) {
if (use_threads)
return;
@@ -471,18 +454,17 @@ void HTTPRequest::_notification(int p_what) {
}
}
- if (p_what==NOTIFICATION_EXIT_TREE) {
+ if (p_what == NOTIFICATION_EXIT_TREE) {
if (requesting) {
cancel_request();
}
}
-
}
void HTTPRequest::set_use_threads(bool p_use) {
- ERR_FAIL_COND( status!=HTTPClient::STATUS_DISCONNECTED );
- use_threads=p_use;
+ ERR_FAIL_COND(status != HTTPClient::STATUS_DISCONNECTED);
+ use_threads = p_use;
}
bool HTTPRequest::is_using_threads() const {
@@ -492,9 +474,9 @@ bool HTTPRequest::is_using_threads() const {
void HTTPRequest::set_body_size_limit(int p_bytes) {
- ERR_FAIL_COND( status!=HTTPClient::STATUS_DISCONNECTED );
+ ERR_FAIL_COND(status != HTTPClient::STATUS_DISCONNECTED);
- body_size_limit=p_bytes;
+ body_size_limit = p_bytes;
}
int HTTPRequest::get_body_size_limit() const {
@@ -502,12 +484,11 @@ int HTTPRequest::get_body_size_limit() const {
return body_size_limit;
}
+void HTTPRequest::set_download_file(const String &p_file) {
-void HTTPRequest::set_download_file(const String& p_file) {
-
- ERR_FAIL_COND( status!=HTTPClient::STATUS_DISCONNECTED );
+ ERR_FAIL_COND(status != HTTPClient::STATUS_DISCONNECTED);
- download_to_file=p_file;
+ download_to_file = p_file;
}
String HTTPRequest::get_download_file() const {
@@ -520,10 +501,10 @@ HTTPClient::Status HTTPRequest::get_http_client_status() const {
void HTTPRequest::set_max_redirects(int p_max) {
- max_redirects=p_max;
+ max_redirects = p_max;
}
-int HTTPRequest::get_max_redirects() const{
+int HTTPRequest::get_max_redirects() const {
return max_redirects;
}
@@ -532,81 +513,77 @@ int HTTPRequest::get_downloaded_bytes() const {
return downloaded;
}
-int HTTPRequest::get_body_size() const{
+int HTTPRequest::get_body_size() const {
return body_len;
}
-
void HTTPRequest::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_ip_type","ip_type"),&HTTPRequest::set_ip_type);
- ObjectTypeDB::bind_method(_MD("request","url","custom_headers","ssl_validate_domain","method","request_data"),&HTTPRequest::request,DEFVAL(StringArray()),DEFVAL(true),DEFVAL(HTTPClient::METHOD_GET),DEFVAL(String()));
- ObjectTypeDB::bind_method(_MD("cancel_request"),&HTTPRequest::cancel_request);
+ ObjectTypeDB::bind_method(_MD("set_ip_type", "ip_type"), &HTTPRequest::set_ip_type);
+ ObjectTypeDB::bind_method(_MD("request", "url", "custom_headers", "ssl_validate_domain", "method", "request_data"), &HTTPRequest::request, DEFVAL(StringArray()), DEFVAL(true), DEFVAL(HTTPClient::METHOD_GET), DEFVAL(String()));
+ ObjectTypeDB::bind_method(_MD("cancel_request"), &HTTPRequest::cancel_request);
- ObjectTypeDB::bind_method(_MD("get_http_client_status"),&HTTPRequest::get_http_client_status);
+ ObjectTypeDB::bind_method(_MD("get_http_client_status"), &HTTPRequest::get_http_client_status);
- ObjectTypeDB::bind_method(_MD("set_use_threads","enable"),&HTTPRequest::set_use_threads);
- ObjectTypeDB::bind_method(_MD("is_using_threads"),&HTTPRequest::is_using_threads);
+ ObjectTypeDB::bind_method(_MD("set_use_threads", "enable"), &HTTPRequest::set_use_threads);
+ ObjectTypeDB::bind_method(_MD("is_using_threads"), &HTTPRequest::is_using_threads);
- ObjectTypeDB::bind_method(_MD("set_body_size_limit","bytes"),&HTTPRequest::set_body_size_limit);
- ObjectTypeDB::bind_method(_MD("get_body_size_limit"),&HTTPRequest::get_body_size_limit);
+ ObjectTypeDB::bind_method(_MD("set_body_size_limit", "bytes"), &HTTPRequest::set_body_size_limit);
+ ObjectTypeDB::bind_method(_MD("get_body_size_limit"), &HTTPRequest::get_body_size_limit);
- ObjectTypeDB::bind_method(_MD("set_max_redirects","amount"),&HTTPRequest::set_max_redirects);
- ObjectTypeDB::bind_method(_MD("get_max_redirects"),&HTTPRequest::get_max_redirects);
+ ObjectTypeDB::bind_method(_MD("set_max_redirects", "amount"), &HTTPRequest::set_max_redirects);
+ ObjectTypeDB::bind_method(_MD("get_max_redirects"), &HTTPRequest::get_max_redirects);
- ObjectTypeDB::bind_method(_MD("set_download_file","path"),&HTTPRequest::set_download_file);
- ObjectTypeDB::bind_method(_MD("get_download_file"),&HTTPRequest::get_download_file);
+ ObjectTypeDB::bind_method(_MD("set_download_file", "path"), &HTTPRequest::set_download_file);
+ ObjectTypeDB::bind_method(_MD("get_download_file"), &HTTPRequest::get_download_file);
- ObjectTypeDB::bind_method(_MD("get_downloaded_bytes"),&HTTPRequest::get_downloaded_bytes);
- ObjectTypeDB::bind_method(_MD("get_body_size"),&HTTPRequest::get_body_size);
+ ObjectTypeDB::bind_method(_MD("get_downloaded_bytes"), &HTTPRequest::get_downloaded_bytes);
+ ObjectTypeDB::bind_method(_MD("get_body_size"), &HTTPRequest::get_body_size);
- ObjectTypeDB::bind_method(_MD("_redirect_request"),&HTTPRequest::_redirect_request);
- ObjectTypeDB::bind_method(_MD("_request_done"),&HTTPRequest::_request_done);
+ ObjectTypeDB::bind_method(_MD("_redirect_request"), &HTTPRequest::_redirect_request);
+ ObjectTypeDB::bind_method(_MD("_request_done"), &HTTPRequest::_request_done);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"use_threads"),_SCS("set_use_threads"),_SCS("is_using_threads"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"body_size_limit",PROPERTY_HINT_RANGE,"-1,2000000000"),_SCS("set_body_size_limit"),_SCS("get_body_size_limit"));
- ADD_PROPERTY(PropertyInfo(Variant::INT,"max_redirects",PROPERTY_HINT_RANGE,"-1,1024"),_SCS("set_max_redirects"),_SCS("get_max_redirects"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_threads"), _SCS("set_use_threads"), _SCS("is_using_threads"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "body_size_limit", PROPERTY_HINT_RANGE, "-1,2000000000"), _SCS("set_body_size_limit"), _SCS("get_body_size_limit"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_redirects", PROPERTY_HINT_RANGE, "-1,1024"), _SCS("set_max_redirects"), _SCS("get_max_redirects"));
- ADD_SIGNAL(MethodInfo("request_completed",PropertyInfo(Variant::INT,"result"),PropertyInfo(Variant::INT,"response_code"),PropertyInfo(Variant::STRING_ARRAY,"headers"),PropertyInfo(Variant::RAW_ARRAY,"body")));
+ ADD_SIGNAL(MethodInfo("request_completed", PropertyInfo(Variant::INT, "result"), PropertyInfo(Variant::INT, "response_code"), PropertyInfo(Variant::STRING_ARRAY, "headers"), PropertyInfo(Variant::RAW_ARRAY, "body")));
- BIND_CONSTANT( RESULT_SUCCESS );
+ BIND_CONSTANT(RESULT_SUCCESS);
//BIND_CONSTANT( RESULT_NO_BODY );
- BIND_CONSTANT( RESULT_CHUNKED_BODY_SIZE_MISMATCH );
- BIND_CONSTANT( RESULT_CANT_CONNECT );
- BIND_CONSTANT( RESULT_CANT_RESOLVE );
- BIND_CONSTANT( RESULT_CONNECTION_ERROR );
- BIND_CONSTANT( RESULT_SSL_HANDSHAKE_ERROR );
- BIND_CONSTANT( RESULT_NO_RESPONSE );
- BIND_CONSTANT( RESULT_BODY_SIZE_LIMIT_EXCEEDED );
- BIND_CONSTANT( RESULT_REQUEST_FAILED );
- BIND_CONSTANT( RESULT_DOWNLOAD_FILE_CANT_OPEN );
- BIND_CONSTANT( RESULT_DOWNLOAD_FILE_WRITE_ERROR );
- BIND_CONSTANT( RESULT_REDIRECT_LIMIT_REACHED );
-
+ BIND_CONSTANT(RESULT_CHUNKED_BODY_SIZE_MISMATCH);
+ BIND_CONSTANT(RESULT_CANT_CONNECT);
+ BIND_CONSTANT(RESULT_CANT_RESOLVE);
+ BIND_CONSTANT(RESULT_CONNECTION_ERROR);
+ BIND_CONSTANT(RESULT_SSL_HANDSHAKE_ERROR);
+ BIND_CONSTANT(RESULT_NO_RESPONSE);
+ BIND_CONSTANT(RESULT_BODY_SIZE_LIMIT_EXCEEDED);
+ BIND_CONSTANT(RESULT_REQUEST_FAILED);
+ BIND_CONSTANT(RESULT_DOWNLOAD_FILE_CANT_OPEN);
+ BIND_CONSTANT(RESULT_DOWNLOAD_FILE_WRITE_ERROR);
+ BIND_CONSTANT(RESULT_REDIRECT_LIMIT_REACHED);
}
-HTTPRequest::HTTPRequest()
-{
+HTTPRequest::HTTPRequest() {
- thread=NULL;
+ thread = NULL;
- port=80;
- redirections=0;
- max_redirects=8;
- body_len=-1;
- got_response=false;
- validate_ssl=false;
- use_ssl=false;
- response_code=0;
- request_sent=false;
- requesting=false;
+ port = 80;
+ redirections = 0;
+ max_redirects = 8;
+ body_len = -1;
+ got_response = false;
+ validate_ssl = false;
+ use_ssl = false;
+ response_code = 0;
+ request_sent = false;
+ requesting = false;
client.instance();
- use_threads=false;
- thread_done=false;
- body_size_limit=-1;
- file=NULL;
- status=HTTPClient::STATUS_DISCONNECTED;
-
+ use_threads = false;
+ thread_done = false;
+ body_size_limit = -1;
+ file = NULL;
+ status = HTTPClient::STATUS_DISCONNECTED;
}
HTTPRequest::~HTTPRequest() {
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 5bf47111e..6a63fa66a 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -29,16 +29,16 @@
#ifndef HTTPREQUEST_H
#define HTTPREQUEST_H
-#include "node.h"
#include "io/http_client.h"
+#include "node.h"
#include "os/file_access.h"
#include "os/thread.h"
class HTTPRequest : public Node {
- OBJ_TYPE(HTTPRequest,Node);
-public:
+ OBJ_TYPE(HTTPRequest, Node);
+public:
enum Result {
RESULT_SUCCESS,
//RESULT_NO_BODY,
@@ -57,7 +57,6 @@ public:
};
private:
-
bool requesting;
String request_string;
@@ -94,12 +93,11 @@ private:
int max_redirects;
- void _redirect_request(const String& p_new_url);
-
+ void _redirect_request(const String &p_new_url);
bool _handle_response(bool *ret_value);
- Error _parse_url(const String& p_url);
+ Error _parse_url(const String &p_url);
Error _request();
volatile bool thread_done;
@@ -107,24 +105,23 @@ private:
Thread *thread;
- void _request_done(int p_status, int p_code, const StringArray& headers, const ByteArray& p_data);
+ void _request_done(int p_status, int p_code, const StringArray &headers, const ByteArray &p_data);
static void _thread_func(void *p_userdata);
protected:
-
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
void set_ip_type(IP::Type p_type);
- Error request(const String& p_url, const Vector<String>& p_custom_headers=Vector<String>(), bool p_ssl_validate_domain=true, HTTPClient::Method p_method=HTTPClient::METHOD_GET, const String& p_request_data=""); //connects to a full url and perform request
+ Error request(const String &p_url, const Vector<String> &p_custom_headers = Vector<String>(), bool p_ssl_validate_domain = true, HTTPClient::Method p_method = HTTPClient::METHOD_GET, const String &p_request_data = ""); //connects to a full url and perform request
void cancel_request();
HTTPClient::Status get_http_client_status() const;
void set_use_threads(bool p_use);
bool is_using_threads() const;
- void set_download_file(const String& p_file);
+ void set_download_file(const String &p_file);
String get_download_file() const;
void set_body_size_limit(int p_bytes);
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index ebba96ff8..ed3f23e65 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -28,51 +28,50 @@
/*************************************************************************/
#include "instance_placeholder.h"
-#include "scene/resources/packed_scene.h"
#include "io/resource_loader.h"
+#include "scene/resources/packed_scene.h"
-bool InstancePlaceholder::_set(const StringName& p_name, const Variant& p_value) {
+bool InstancePlaceholder::_set(const StringName &p_name, const Variant &p_value) {
PropSet ps;
- ps.name=p_name;
- ps.value=p_value;
+ ps.name = p_name;
+ ps.value = p_value;
stored_values.push_back(ps);
return true;
}
-bool InstancePlaceholder::_get(const StringName& p_name,Variant &r_ret) const{
+bool InstancePlaceholder::_get(const StringName &p_name, Variant &r_ret) const {
- for (const List<PropSet>::Element *E=stored_values.front();E;E=E->next()) {
- if (E->get().name==p_name) {
- r_ret=E->get().value;
+ for (const List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
+ if (E->get().name == p_name) {
+ r_ret = E->get().value;
return true;
}
}
return false;
}
-void InstancePlaceholder::_get_property_list( List<PropertyInfo> *p_list) const{
+void InstancePlaceholder::_get_property_list(List<PropertyInfo> *p_list) const {
- for (const List<PropSet>::Element *E=stored_values.front();E;E=E->next()) {
+ for (const List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
PropertyInfo pi;
- pi.name=E->get().name;
- pi.type=E->get().value.get_type();
- pi.usage=PROPERTY_USAGE_STORAGE;
+ pi.name = E->get().name;
+ pi.type = E->get().value.get_type();
+ pi.usage = PROPERTY_USAGE_STORAGE;
p_list->push_back(pi);
}
}
+void InstancePlaceholder::set_instance_path(const String &p_name) {
-void InstancePlaceholder::set_instance_path(const String& p_name) {
-
- path=p_name;
+ path = p_name;
}
String InstancePlaceholder::get_instance_path() const {
return path;
}
-void InstancePlaceholder::replace_by_instance(const Ref<PackedScene> &p_custom_scene){
+void InstancePlaceholder::replace_by_instance(const Ref<PackedScene> &p_custom_scene) {
ERR_FAIL_COND(!is_inside_tree());
@@ -84,7 +83,7 @@ void InstancePlaceholder::replace_by_instance(const Ref<PackedScene> &p_custom_s
if (p_custom_scene.is_valid())
ps = p_custom_scene;
else
- ps = ResourceLoader::load(path,"PackedScene");
+ ps = ResourceLoader::load(path, "PackedScene");
if (!ps.is_valid())
return;
@@ -92,15 +91,15 @@ void InstancePlaceholder::replace_by_instance(const Ref<PackedScene> &p_custom_s
scene->set_name(get_name());
int pos = get_position_in_parent();
- for(List<PropSet>::Element *E=stored_values.front();E;E=E->next()) {
- scene->set(E->get().name,E->get().value);
+ for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
+ scene->set(E->get().name, E->get().value);
}
queue_delete();
base->remove_child(this);
base->add_child(scene);
- base->move_child(scene,pos);
+ base->move_child(scene, pos);
}
Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) {
@@ -108,7 +107,7 @@ Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) {
Dictionary ret;
StringArray order;
- for(List<PropSet>::Element *E=stored_values.front();E;E=E->next()) {
+ for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
ret[E->get().name] = E->get().value;
if (p_with_order)
order.push_back(E->get().name);
@@ -122,12 +121,10 @@ Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) {
void InstancePlaceholder::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_stored_values","with_order"),&InstancePlaceholder::get_stored_values,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("replace_by_instance","custom_scene:PackedScene"),&InstancePlaceholder::replace_by_instance,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("get_instance_path"),&InstancePlaceholder::get_instance_path);
+ ObjectTypeDB::bind_method(_MD("get_stored_values", "with_order"), &InstancePlaceholder::get_stored_values, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("replace_by_instance", "custom_scene:PackedScene"), &InstancePlaceholder::replace_by_instance, DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("get_instance_path"), &InstancePlaceholder::get_instance_path);
}
InstancePlaceholder::InstancePlaceholder() {
-
-
}
diff --git a/scene/main/instance_placeholder.h b/scene/main/instance_placeholder.h
index 85de39324..8b2ec9a45 100644
--- a/scene/main/instance_placeholder.h
+++ b/scene/main/instance_placeholder.h
@@ -35,7 +35,7 @@ class PackedScene;
class InstancePlaceholder : public Node {
- OBJ_TYPE(InstancePlaceholder,Node);
+ OBJ_TYPE(InstancePlaceholder, Node);
String path;
struct PropSet {
@@ -46,20 +46,19 @@ class InstancePlaceholder : public Node {
List<PropSet> stored_values;
protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
- void set_instance_path(const String& p_name);
+ void set_instance_path(const String &p_name);
String get_instance_path() const;
Dictionary get_stored_values(bool p_with_order = false);
- void replace_by_instance(const Ref<PackedScene>& p_custom_scene=Ref<PackedScene>());
+ void replace_by_instance(const Ref<PackedScene> &p_custom_scene = Ref<PackedScene>());
InstancePlaceholder();
};
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 5702f5bb3..8f02de4c4 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -27,62 +27,59 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "node.h"
-#include "print_string.h"
+#include "instance_placeholder.h"
+#include "io/resource_loader.h"
#include "message_queue.h"
-#include "scene/scene_string_names.h"
+#include "print_string.h"
#include "scene/resources/packed_scene.h"
-#include "io/resource_loader.h"
+#include "scene/scene_string_names.h"
#include "viewport.h"
-#include "instance_placeholder.h"
VARIANT_ENUM_CAST(Node::PauseMode);
-
-
-
void Node::_notification(int p_notification) {
- switch(p_notification) {
+ switch (p_notification) {
case NOTIFICATION_PROCESS: {
if (get_script_instance()) {
- Variant time=get_process_delta_time();
- const Variant*ptr[1]={&time};
+ Variant time = get_process_delta_time();
+ const Variant *ptr[1] = { &time };
Variant::CallError err;
- get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_process,ptr,1);
+ get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_process, ptr, 1);
}
} break;
case NOTIFICATION_FIXED_PROCESS: {
if (get_script_instance()) {
- Variant time=get_fixed_process_delta_time();
- const Variant*ptr[1]={&time};
+ Variant time = get_fixed_process_delta_time();
+ const Variant *ptr[1] = { &time };
Variant::CallError err;
- get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_fixed_process,ptr,1);
+ get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_fixed_process, ptr, 1);
}
} break;
case NOTIFICATION_ENTER_TREE: {
- if (data.pause_mode==PAUSE_MODE_INHERIT) {
+ if (data.pause_mode == PAUSE_MODE_INHERIT) {
if (data.parent)
- data.pause_owner=data.parent->data.pause_owner;
+ data.pause_owner = data.parent->data.pause_owner;
else
- data.pause_owner=NULL;
+ data.pause_owner = NULL;
} else {
- data.pause_owner=this;
+ data.pause_owner = this;
}
if (data.input)
- add_to_group("_vp_input"+itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
if (data.unhandled_input)
- add_to_group("_vp_unhandled_input"+itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_ID()));
if (data.unhandled_key_input)
- add_to_group("_vp_unhandled_key_input"+itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
get_tree()->node_count++;
@@ -91,11 +88,11 @@ void Node::_notification(int p_notification) {
get_tree()->node_count--;
if (data.input)
- remove_from_group("_vp_input"+itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
if (data.unhandled_input)
- remove_from_group("_vp_unhandled_input"+itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_ID()));
if (data.unhandled_key_input)
- remove_from_group("_vp_unhandled_key_input"+itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
} break;
case NOTIFICATION_READY: {
@@ -103,19 +100,19 @@ void Node::_notification(int p_notification) {
if (get_script_instance()) {
Variant::CallError err;
- get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready,NULL,0);
+ get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready, NULL, 0);
}
//emit_signal(SceneStringNames::get_singleton()->enter_tree);
} break;
case NOTIFICATION_POSTINITIALIZE: {
- data.in_constructor=false;
+ data.in_constructor = false;
} break;
case NOTIFICATION_PREDELETE: {
set_owner(NULL);
- while ( data.owned.size() ) {
+ while (data.owned.size()) {
data.owned.front()->get()->set_owner(NULL);
}
@@ -126,69 +123,64 @@ void Node::_notification(int p_notification) {
}
// kill children as cleanly as possible
- while( data.children.size() ) {
+ while (data.children.size()) {
Node *child = data.children[0];
remove_child(child);
- memdelete( child );
+ memdelete(child);
}
} break;
}
}
-
void Node::_propagate_ready() {
- data.ready_notified=true;
+ data.ready_notified = true;
data.blocked++;
- for (int i=0;i<data.children.size();i++) {
+ for (int i = 0; i < data.children.size(); i++) {
data.children[i]->_propagate_ready();
}
data.blocked--;
notification(NOTIFICATION_READY);
-
}
-
void Node::_propagate_enter_tree() {
// this needs to happen to all childs before any enter_tree
if (data.parent) {
- data.tree=data.parent->data.tree;
- data.depth=data.parent->data.depth+1;
+ data.tree = data.parent->data.tree;
+ data.depth = data.parent->data.depth + 1;
} else {
- data.depth=1;
+ data.depth = 1;
}
data.viewport = cast_to<Viewport>();
if (!data.viewport)
data.viewport = data.parent->data.viewport;
- data.inside_tree=true;
+ data.inside_tree = true;
- for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
- E->get().group=data.tree->add_to_group(E->key(),this);
+ for (Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) {
+ E->get().group = data.tree->add_to_group(E->key(), this);
}
-
notification(NOTIFICATION_ENTER_TREE);
if (get_script_instance()) {
Variant::CallError err;
- get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree,NULL,0);
+ get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_enter_tree, NULL, 0);
}
emit_signal(SceneStringNames::get_singleton()->enter_tree);
-
data.blocked++;
//block while adding children
- for (int i=0;i<data.children.size();i++) {
+ for (int i = 0; i < data.children.size(); i++) {
if (!data.children[i]->is_inside_tree()) // could have been added in enter_tree
data.children[i]->_propagate_enter_tree();
@@ -198,7 +190,7 @@ void Node::_propagate_enter_tree() {
#ifdef DEBUG_ENABLED
- if (ScriptDebugger::get_singleton() && data.filename!=String()) {
+ if (ScriptDebugger::get_singleton() && data.filename != String()) {
//used for live edit
data.tree->live_scene_edit_cache[data.filename].insert(this);
}
@@ -206,27 +198,25 @@ void Node::_propagate_enter_tree() {
// enter groups
}
-
-
void Node::_propagate_exit_tree() {
- //block while removing children
+//block while removing children
#ifdef DEBUG_ENABLED
- if (ScriptDebugger::get_singleton() && data.filename!=String()) {
+ if (ScriptDebugger::get_singleton() && data.filename != String()) {
//used for live edit
- Map<String,Set<Node*> >::Element *E=data.tree->live_scene_edit_cache.find(data.filename);
+ Map<String, Set<Node *> >::Element *E = data.tree->live_scene_edit_cache.find(data.filename);
if (E) {
E->get().erase(this);
- if (E->get().size()==0) {
+ if (E->get().size() == 0) {
data.tree->live_scene_edit_cache.erase(E);
}
}
- Map<Node*,Map<ObjectID,Node*> >::Element *F=data.tree->live_edit_remove_list.find(this);
+ Map<Node *, Map<ObjectID, Node *> >::Element *F = data.tree->live_edit_remove_list.find(this);
if (F) {
- for (Map<ObjectID,Node*>::Element*G=F->get().front();G;G=G->next()) {
+ for (Map<ObjectID, Node *>::Element *G = F->get().front(); G; G = G->next()) {
memdelete(G->get());
}
@@ -236,7 +226,7 @@ void Node::_propagate_exit_tree() {
#endif
data.blocked++;
- for (int i=data.children.size()-1;i>=0;i--) {
+ for (int i = data.children.size() - 1; i >= 0; i--) {
data.children[i]->_propagate_exit_tree();
}
@@ -246,52 +236,45 @@ void Node::_propagate_exit_tree() {
if (get_script_instance()) {
Variant::CallError err;
- get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree,NULL,0);
+ get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, NULL, 0);
}
emit_signal(SceneStringNames::get_singleton()->exit_tree);
- notification(NOTIFICATION_EXIT_TREE,true);
+ notification(NOTIFICATION_EXIT_TREE, true);
if (data.tree)
data.tree->node_removed(this);
// exit groups
- for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
- data.tree->remove_from_group(E->key(),this);
- E->get().group=NULL;
+ for (Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) {
+ data.tree->remove_from_group(E->key(), this);
+ E->get().group = NULL;
}
-
data.viewport = NULL;
if (data.tree)
data.tree->tree_changed();
- data.inside_tree=false;
- data.tree=NULL;
- data.depth=-1;
-
+ data.inside_tree = false;
+ data.tree = NULL;
+ data.depth = -1;
}
-
-
-
-
-void Node::move_child(Node *p_child,int p_pos) {
+void Node::move_child(Node *p_child, int p_pos) {
ERR_FAIL_NULL(p_child);
- ERR_EXPLAIN("Invalid new child position: "+itos(p_pos));
- ERR_FAIL_INDEX( p_pos, data.children.size()+1 );
+ ERR_EXPLAIN("Invalid new child position: " + itos(p_pos));
+ ERR_FAIL_INDEX(p_pos, data.children.size() + 1);
ERR_EXPLAIN("child is not a child of this node.");
- ERR_FAIL_COND(p_child->data.parent!=this);
- if (data.blocked>0) {
+ ERR_FAIL_COND(p_child->data.parent != this);
+ if (data.blocked > 0) {
ERR_EXPLAIN("Parent node is busy setting up children, move_child() failed. Consider using call_deferred(\"move_child\") instead (or \"popup\" if this is from a popup).");
- ERR_FAIL_COND(data.blocked>0);
+ ERR_FAIL_COND(data.blocked > 0);
}
-
- data.children.remove( p_child->data.pos );
- data.children.insert( p_pos, p_child );
+ data.children.remove(p_child->data.pos);
+ data.children.insert(p_pos, p_child);
if (data.tree) {
data.tree->tree_changed();
@@ -299,22 +282,20 @@ void Node::move_child(Node *p_child,int p_pos) {
data.blocked++;
//new pos first
- for (int i=0;i<data.children.size();i++) {
+ for (int i = 0; i < data.children.size(); i++) {
- data.children[i]->data.pos=i;
+ data.children[i]->data.pos = i;
}
// notification second
move_child_notify(p_child);
- for (int i=0;i<data.children.size();i++) {
- data.children[i]->notification( NOTIFICATION_MOVED_IN_PARENT );
-
+ for (int i = 0; i < data.children.size(); i++) {
+ data.children[i]->notification(NOTIFICATION_MOVED_IN_PARENT);
}
- for (const Map< StringName, GroupData>::Element *E=p_child->data.grouped.front();E;E=E->next()) {
- E->get().group->changed=true;
+ for (const Map<StringName, GroupData>::Element *E = p_child->data.grouped.front(); E; E = E->next()) {
+ E->get().group->changed = true;
}
data.blocked--;
-
}
void Node::raise() {
@@ -322,8 +303,7 @@ void Node::raise() {
if (!data.parent)
return;
- data.parent->move_child(this,data.parent->data.children.size()-1);
-
+ data.parent->move_child(this, data.parent->data.children.size() - 1);
}
void Node::add_child_notify(Node *p_child) {
@@ -355,46 +335,43 @@ void Node::move_child_notify(Node *p_child) {
void Node::set_fixed_process(bool p_process) {
- if (data.fixed_process==p_process)
+ if (data.fixed_process == p_process)
return;
- data.fixed_process=p_process;
+ data.fixed_process = p_process;
if (data.fixed_process)
- add_to_group("fixed_process",false);
+ add_to_group("fixed_process", false);
else
remove_from_group("fixed_process");
- data.fixed_process=p_process;
+ data.fixed_process = p_process;
_change_notify("fixed_process");
}
void Node::set_pause_mode(PauseMode p_mode) {
- if (data.pause_mode==p_mode)
+ if (data.pause_mode == p_mode)
return;
- bool prev_inherits=data.pause_mode==PAUSE_MODE_INHERIT;
- data.pause_mode=p_mode;
+ bool prev_inherits = data.pause_mode == PAUSE_MODE_INHERIT;
+ data.pause_mode = p_mode;
if (!is_inside_tree())
return; //pointless
- if ((data.pause_mode==PAUSE_MODE_INHERIT) == prev_inherits)
+ if ((data.pause_mode == PAUSE_MODE_INHERIT) == prev_inherits)
return; ///nothing changed
- Node *owner=NULL;
+ Node *owner = NULL;
- if (data.pause_mode==PAUSE_MODE_INHERIT) {
+ if (data.pause_mode == PAUSE_MODE_INHERIT) {
if (data.parent)
- owner=data.parent->data.pause_owner;
+ owner = data.parent->data.pause_owner;
} else {
- owner=this;
+ owner = this;
}
_propagate_pause_owner(owner);
-
-
-
}
Node::PauseMode Node::get_pause_mode() const {
@@ -402,12 +379,12 @@ Node::PauseMode Node::get_pause_mode() const {
return data.pause_mode;
}
-void Node::_propagate_pause_owner(Node*p_owner) {
+void Node::_propagate_pause_owner(Node *p_owner) {
- if (data.pause_mode!=PAUSE_MODE_INHERIT)
+ if (data.pause_mode != PAUSE_MODE_INHERIT)
return;
- data.pause_owner=p_owner;
- for(int i=0;i<data.children.size();i++) {
+ data.pause_owner = p_owner;
+ for (int i = 0; i < data.children.size(); i++) {
data.children[i]->_propagate_pause_owner(p_owner);
}
@@ -415,32 +392,30 @@ void Node::_propagate_pause_owner(Node*p_owner) {
bool Node::can_process() const {
- ERR_FAIL_COND_V( !is_inside_tree(), false );
+ ERR_FAIL_COND_V(!is_inside_tree(), false);
if (get_tree()->is_paused()) {
- if (data.pause_mode==PAUSE_MODE_STOP)
+ if (data.pause_mode == PAUSE_MODE_STOP)
return false;
- if (data.pause_mode==PAUSE_MODE_PROCESS)
+ if (data.pause_mode == PAUSE_MODE_PROCESS)
return true;
- if (data.pause_mode==PAUSE_MODE_INHERIT) {
+ if (data.pause_mode == PAUSE_MODE_INHERIT) {
if (!data.pause_owner)
return false; //clearly no pause owner by default
- if (data.pause_owner->data.pause_mode==PAUSE_MODE_PROCESS)
+ if (data.pause_owner->data.pause_mode == PAUSE_MODE_PROCESS)
return true;
- if (data.pause_owner->data.pause_mode==PAUSE_MODE_STOP)
+ if (data.pause_owner->data.pause_mode == PAUSE_MODE_STOP)
return false;
}
-
}
return true;
}
-
float Node::get_fixed_process_delta_time() const {
if (data.tree)
@@ -451,17 +426,17 @@ float Node::get_fixed_process_delta_time() const {
void Node::set_process(bool p_idle_process) {
- if (data.idle_process==p_idle_process)
+ if (data.idle_process == p_idle_process)
return;
- data.idle_process=p_idle_process;
+ data.idle_process = p_idle_process;
if (data.idle_process)
- add_to_group("idle_process",false);
+ add_to_group("idle_process", false);
else
remove_from_group("idle_process");
- data.idle_process=p_idle_process;
+ data.idle_process = p_idle_process;
_change_notify("idle_process");
}
@@ -483,22 +458,19 @@ bool Node::is_processing() const {
return data.idle_process;
}
-
void Node::set_process_input(bool p_enable) {
- if (p_enable==data.input)
+ if (p_enable == data.input)
return;
- data.input=p_enable;
+ data.input = p_enable;
if (!is_inside_tree())
return;
if (p_enable)
- add_to_group("_vp_input"+itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
else
- remove_from_group("_vp_input"+itos(get_viewport()->get_instance_ID()));
-
-
+ remove_from_group("_vp_input" + itos(get_viewport()->get_instance_ID()));
}
bool Node::is_processing_input() const {
@@ -507,61 +479,56 @@ bool Node::is_processing_input() const {
void Node::set_process_unhandled_input(bool p_enable) {
- if (p_enable==data.unhandled_input)
+ if (p_enable == data.unhandled_input)
return;
- data.unhandled_input=p_enable;
+ data.unhandled_input = p_enable;
if (!is_inside_tree())
return;
if (p_enable)
- add_to_group("_vp_unhandled_input"+itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_ID()));
else
- remove_from_group("_vp_unhandled_input"+itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_unhandled_input" + itos(get_viewport()->get_instance_ID()));
}
-
bool Node::is_processing_unhandled_input() const {
return data.unhandled_input;
}
-
void Node::set_process_unhandled_key_input(bool p_enable) {
- if (p_enable==data.unhandled_key_input)
+ if (p_enable == data.unhandled_key_input)
return;
- data.unhandled_key_input=p_enable;
+ data.unhandled_key_input = p_enable;
if (!is_inside_tree())
return;
if (p_enable)
- add_to_group("_vp_unhandled_key_input"+itos(get_viewport()->get_instance_ID()));
+ add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
else
- remove_from_group("_vp_unhandled_key_input"+itos(get_viewport()->get_instance_ID()));
+ remove_from_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_ID()));
}
-
bool Node::is_processing_unhandled_key_input() const {
return data.unhandled_key_input;
}
-
StringName Node::get_name() const {
return data.name;
}
-void Node::_set_name_nocheck(const StringName& p_name) {
-
- data.name=p_name;
+void Node::_set_name_nocheck(const StringName &p_name) {
+ data.name = p_name;
}
-void Node::set_name(const String& p_name) {
+void Node::set_name(const String &p_name) {
- String name=p_name.replace(":","").replace("/","").replace("@","");
+ String name = p_name.replace(":", "").replace("/", "").replace("@", "");
- ERR_FAIL_COND(name=="");
- data.name=name;
+ ERR_FAIL_COND(name == "");
+ data.name = name;
if (data.parent) {
@@ -575,7 +542,7 @@ void Node::set_name(const String& p_name) {
}
}
-static bool node_hrcr=false;
+static bool node_hrcr = false;
static SafeRefCount node_hrcr_count;
void Node::init_node_hrcr() {
@@ -584,40 +551,37 @@ void Node::init_node_hrcr() {
void Node::set_human_readable_collision_renaming(bool p_enabled) {
- node_hrcr=p_enabled;
+ node_hrcr = p_enabled;
}
-
-
-String Node::validate_child_name(const String& p_name) const {
+String Node::validate_child_name(const String &p_name) const {
//this approach to autoset node names is human readable but very slow
//it's turned on while running in the editor
String basename = p_name;
- if (basename==String()) {
+ if (basename == String()) {
return String();
}
- int val=1;
+ int val = 1;
- for(;;) {
+ for (;;) {
- String attempted = val > 1 ? (basename + " " +itos(val) ) : basename;
+ String attempted = val > 1 ? (basename + " " + itos(val)) : basename;
- bool found=false;
+ bool found = false;
- for (int i=0;i<data.children.size();i++) {
+ for (int i = 0; i < data.children.size(); i++) {
//if (data.children[i]==p_child)
// continue;
if (data.children[i]->get_name() == attempted) {
- found=true;
+ found = true;
break;
}
-
}
if (found) {
@@ -631,7 +595,6 @@ String Node::validate_child_name(const String& p_name) const {
}
return basename;
-
}
void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
@@ -645,28 +608,27 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
String basename = p_child->data.name;
- if (basename=="") {
+ if (basename == "") {
basename = p_child->get_type();
}
- int val=1;
+ int val = 1;
- for(;;) {
+ for (;;) {
- String attempted = val > 1 ? (basename + " " +itos(val) ) : basename;
+ String attempted = val > 1 ? (basename + " " + itos(val)) : basename;
- bool found=false;
+ bool found = false;
- for (int i=0;i<data.children.size();i++) {
+ for (int i = 0; i < data.children.size(); i++) {
- if (data.children[i]==p_child)
+ if (data.children[i] == p_child)
continue;
if (data.children[i]->get_name() == attempted) {
- found=true;
+ found = true;
break;
}
-
}
if (found) {
@@ -675,7 +637,7 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
continue;
}
- p_child->data.name=attempted;
+ p_child->data.name = attempted;
break;
}
} else {
@@ -683,21 +645,21 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
//this approach to autoset node names is fast but not as readable
//it's the default and reserves the '@' character for unique names.
- bool unique=true;
+ bool unique = true;
- if (p_child->data.name==StringName() || p_child->data.name.operator String()[0]=='@') {
+ if (p_child->data.name == StringName() || p_child->data.name.operator String()[0] == '@') {
//new unique name must be assigned
- unique=false;
+ unique = false;
} else {
//check if exists
- Node **childs=data.children.ptr();
+ Node **childs = data.children.ptr();
int cc = data.children.size();
- for(int i=0;i<cc;i++) {
- if (childs[i]==p_child)
+ for (int i = 0; i < cc; i++) {
+ if (childs[i] == p_child)
continue;
- if (childs[i]->data.name==p_child->data.name) {
- unique=false;
+ if (childs[i]->data.name == p_child->data.name) {
+ unique = false;
break;
}
}
@@ -706,19 +668,19 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
if (!unique) {
node_hrcr_count.ref();
- String name = "@"+String(p_child->get_name())+"@"+itos(node_hrcr_count.get());
- p_child->data.name=name;
+ String name = "@" + String(p_child->get_name()) + "@" + itos(node_hrcr_count.get());
+ p_child->data.name = name;
}
}
}
-void Node::_add_child_nocheck(Node* p_child,const StringName& p_name) {
+void Node::_add_child_nocheck(Node *p_child, const StringName &p_name) {
//add a child node quickly, without name validation
- p_child->data.name=p_name;
- p_child->data.pos=data.children.size();
- data.children.push_back( p_child );
- p_child->data.parent=this;
+ p_child->data.name = p_name;
+ p_child->data.pos = data.children.size();
+ data.children.push_back(p_child);
+ p_child->data.parent = this;
p_child->notification(NOTIFICATION_PARENTED);
if (data.tree) {
@@ -727,37 +689,33 @@ void Node::_add_child_nocheck(Node* p_child,const StringName& p_name) {
/* Notify */
//recognize childs created in this node constructor
- p_child->data.parent_owned=data.in_constructor;
+ p_child->data.parent_owned = data.in_constructor;
add_child_notify(p_child);
-
-
}
-
void Node::add_child(Node *p_child, bool p_legible_unique_name) {
ERR_FAIL_NULL(p_child);
/* Fail if node has a parent */
- if (p_child==this) {
- ERR_EXPLAIN("Can't add child "+p_child->get_name()+" to itself.")
- ERR_FAIL_COND( p_child==this ); // adding to itself!
+ if (p_child == this) {
+ ERR_EXPLAIN("Can't add child " + p_child->get_name() + " to itself.")
+ ERR_FAIL_COND(p_child == this); // adding to itself!
}
ERR_EXPLAIN("Can't add child, already has a parent");
- ERR_FAIL_COND( p_child->data.parent );
+ ERR_FAIL_COND(p_child->data.parent);
- if (data.blocked>0) {
+ if (data.blocked > 0) {
ERR_EXPLAIN("Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\",child) instead.");
- ERR_FAIL_COND(data.blocked>0);
+ ERR_FAIL_COND(data.blocked > 0);
}
ERR_EXPLAIN("Can't add child while a notification is happening");
- ERR_FAIL_COND( data.blocked > 0 );
+ ERR_FAIL_COND(data.blocked > 0);
/* Validate name */
- _validate_child_name(p_child,p_legible_unique_name);
-
- _add_child_nocheck(p_child,p_child->data.name);
+ _validate_child_name(p_child, p_legible_unique_name);
+ _add_child_nocheck(p_child, p_child->data.name);
}
void Node::add_child_below_node(Node *p_node, Node *p_child, bool p_legible_unique_name) {
@@ -770,39 +728,32 @@ void Node::add_child_below_node(Node *p_node, Node *p_child, bool p_legible_uniq
}
}
-
void Node::_propagate_validate_owner() {
if (data.owner) {
- bool found=false;
+ bool found = false;
Node *parent = data.parent;
- while(parent) {
-
+ while (parent) {
- if (parent==data.owner) {
+ if (parent == data.owner) {
- found=true;
+ found = true;
break;
}
- parent=parent->data.parent;
+ parent = parent->data.parent;
}
-
if (!found) {
-
data.owner->data.owned.erase(data.OW);
- data.owner=NULL;
+ data.owner = NULL;
}
-
}
-
- for(int i=0;i<data.children.size();i++) {
-
+ for (int i = 0; i < data.children.size(); i++) {
data.children[i]->_propagate_validate_owner();
}
@@ -811,28 +762,27 @@ void Node::_propagate_validate_owner() {
void Node::remove_child(Node *p_child) {
ERR_FAIL_NULL(p_child);
- if (data.blocked>0) {
+ if (data.blocked > 0) {
ERR_EXPLAIN("Parent node is busy setting up children, remove_node() failed. Consider using call_deferred(\"remove_child\",child) instead.");
- ERR_FAIL_COND(data.blocked>0);
+ ERR_FAIL_COND(data.blocked > 0);
}
- int idx=-1;
- for (int i=0;i<data.children.size();i++) {
+ int idx = -1;
+ for (int i = 0; i < data.children.size(); i++) {
- if (data.children[i]==p_child) {
+ if (data.children[i] == p_child) {
- idx=i;
+ idx = i;
break;
}
}
- ERR_FAIL_COND( idx==-1 );
+ ERR_FAIL_COND(idx == -1);
//ERR_FAIL_COND( p_child->data.blocked > 0 );
-
//if (data.scene) { does not matter
- p_child->_set_tree(NULL);
+ p_child->_set_tree(NULL);
//}
remove_child_notify(p_child);
@@ -840,19 +790,16 @@ void Node::remove_child(Node *p_child) {
data.children.remove(idx);
- for (int i=idx;i<data.children.size();i++) {
+ for (int i = idx; i < data.children.size(); i++) {
- data.children[i]->data.pos=i;
+ data.children[i]->data.pos = i;
}
- p_child->data.parent=NULL;
- p_child->data.pos=-1;
-
-
+ p_child->data.parent = NULL;
+ p_child->data.pos = -1;
// validate owner
p_child->_propagate_validate_owner();
-
}
int Node::get_child_count() const {
@@ -861,75 +808,72 @@ int Node::get_child_count() const {
}
Node *Node::get_child(int p_index) const {
- ERR_FAIL_INDEX_V( p_index, data.children.size(), NULL );
+ ERR_FAIL_INDEX_V(p_index, data.children.size(), NULL);
return data.children[p_index];
}
+Node *Node::_get_child_by_name(const StringName &p_name) const {
-Node *Node::_get_child_by_name(const StringName& p_name) const {
+ int cc = data.children.size();
+ Node *const *cd = data.children.ptr();
- int cc=data.children.size();
- Node* const* cd=data.children.ptr();
-
- for(int i=0;i<cc;i++){
- if (cd[i]->data.name==p_name)
+ for (int i = 0; i < cc; i++) {
+ if (cd[i]->data.name == p_name)
return cd[i];
}
return NULL;
}
-Node *Node::_get_node(const NodePath& p_path) const {
+Node *Node::_get_node(const NodePath &p_path) const {
if (!data.inside_tree && p_path.is_absolute()) {
ERR_EXPLAIN("Can't use get_node() with absolute paths from outside the active scene tree.");
ERR_FAIL_V(NULL);
}
- Node *current=NULL;
- Node *root=NULL;
+ Node *current = NULL;
+ Node *root = NULL;
if (!p_path.is_absolute()) {
- current=const_cast<Node*>(this); //start from this
+ current = const_cast<Node *>(this); //start from this
} else {
- root=const_cast<Node*>(this);
+ root = const_cast<Node *>(this);
while (root->data.parent)
- root=root->data.parent; //start from root
+ root = root->data.parent; //start from root
}
-
- for(int i=0;i<p_path.get_name_count();i++) {
-
+ for (int i = 0; i < p_path.get_name_count(); i++) {
StringName name = p_path.get_name(i);
Node *next = NULL;
- if (name==SceneStringNames::get_singleton()->dot) { // .
+ if (name == SceneStringNames::get_singleton()->dot) { // .
- next=current;
+ next = current;
- } else if (name==SceneStringNames::get_singleton()->doubledot) { // ..
+ } else if (name == SceneStringNames::get_singleton()->doubledot) { // ..
- if (current==NULL || !current->data.parent)
+ if (current == NULL || !current->data.parent)
return NULL;
- next=current->data.parent;
- } else if (current==NULL) {
+ next = current->data.parent;
+ } else if (current == NULL) {
- if (name==root->get_name())
- next=root;
+ if (name == root->get_name())
+ next = root;
} else {
- next=NULL;
+ next = NULL;
- for(int j=0;j<current->data.children.size();j++) {
+ for (int j = 0; j < current->data.children.size(); j++) {
Node *child = current->data.children[j];
- if ( child->data.name == name ) {
+ if (child->data.name == name) {
next = child;
break;
@@ -939,33 +883,32 @@ Node *Node::_get_node(const NodePath& p_path) const {
return NULL;
};
}
- current=next;
+ current = next;
}
return current;
}
-Node *Node::get_node(const NodePath& p_path) const {
+Node *Node::get_node(const NodePath &p_path) const {
Node *node = _get_node(p_path);
if (!node) {
- ERR_EXPLAIN("Node not found: "+p_path);
- ERR_FAIL_COND_V(!node,NULL);
+ ERR_EXPLAIN("Node not found: " + p_path);
+ ERR_FAIL_COND_V(!node, NULL);
}
return node;
}
-bool Node::has_node(const NodePath& p_path) const {
+bool Node::has_node(const NodePath &p_path) const {
- return _get_node(p_path)!=NULL;
+ return _get_node(p_path) != NULL;
}
+Node *Node::find_node(const String &p_mask, bool p_recursive, bool p_owned) const {
-Node* Node::find_node(const String& p_mask,bool p_recursive,bool p_owned) const {
-
- Node * const*cptr = data.children.ptr();
+ Node *const *cptr = data.children.ptr();
int ccount = data.children.size();
- for(int i=0;i<ccount;i++) {
+ for (int i = 0; i < ccount; i++) {
if (p_owned && !cptr[i]->data.owner)
continue;
if (cptr[i]->data.name.operator String().match(p_mask))
@@ -974,12 +917,11 @@ Node* Node::find_node(const String& p_mask,bool p_recursive,bool p_owned) const
if (!p_recursive)
continue;
- Node* ret = cptr[i]->find_node(p_mask,true,p_owned);
+ Node *ret = cptr[i]->find_node(p_mask, true, p_owned);
if (ret)
return ret;
}
return NULL;
-
}
Node *Node::get_parent() const {
@@ -987,16 +929,15 @@ Node *Node::get_parent() const {
return data.parent;
}
-
bool Node::is_a_parent_of(const Node *p_node) const {
- ERR_FAIL_NULL_V(p_node,false);
- Node *p=p_node->data.parent;
- while(p) {
+ ERR_FAIL_NULL_V(p_node, false);
+ Node *p = p_node->data.parent;
+ while (p) {
- if (p==this)
+ if (p == this)
return true;
- p=p->data.parent;
+ p = p->data.parent;
}
return false;
@@ -1004,12 +945,12 @@ bool Node::is_a_parent_of(const Node *p_node) const {
bool Node::is_greater_than(const Node *p_node) const {
- ERR_FAIL_NULL_V(p_node,false);
- ERR_FAIL_COND_V( !data.inside_tree, false );
- ERR_FAIL_COND_V( !p_node->data.inside_tree, false );
+ ERR_FAIL_NULL_V(p_node, false);
+ ERR_FAIL_COND_V(!data.inside_tree, false);
+ ERR_FAIL_COND_V(!p_node->data.inside_tree, false);
- ERR_FAIL_COND_V( data.depth<0, false);
- ERR_FAIL_COND_V( p_node->data.depth<0, false);
+ ERR_FAIL_COND_V(data.depth < 0, false);
+ ERR_FAIL_COND_V(p_node->data.depth < 0, false);
#ifdef NO_ALLOCA
Vector<int> this_stack;
@@ -1019,46 +960,46 @@ bool Node::is_greater_than(const Node *p_node) const {
#else
- int *this_stack=(int*)alloca(sizeof(int)*data.depth);
- int *that_stack=(int*)alloca(sizeof(int)*p_node->data.depth);
+ int *this_stack = (int *)alloca(sizeof(int) * data.depth);
+ int *that_stack = (int *)alloca(sizeof(int) * p_node->data.depth);
#endif
const Node *n = this;
- int idx=data.depth-1;
- while(n) {
- ERR_FAIL_INDEX_V(idx, data.depth,false);
- this_stack[idx--]=n->data.pos;
- n=n->data.parent;
+ int idx = data.depth - 1;
+ while (n) {
+ ERR_FAIL_INDEX_V(idx, data.depth, false);
+ this_stack[idx--] = n->data.pos;
+ n = n->data.parent;
}
- ERR_FAIL_COND_V(idx!=-1,false);
+ ERR_FAIL_COND_V(idx != -1, false);
n = p_node;
- idx=p_node->data.depth-1;
- while(n) {
- ERR_FAIL_INDEX_V(idx, p_node->data.depth,false);
- that_stack[idx--]=n->data.pos;
+ idx = p_node->data.depth - 1;
+ while (n) {
+ ERR_FAIL_INDEX_V(idx, p_node->data.depth, false);
+ that_stack[idx--] = n->data.pos;
- n=n->data.parent;
+ n = n->data.parent;
}
- ERR_FAIL_COND_V(idx!=-1,false);
- idx=0;
+ ERR_FAIL_COND_V(idx != -1, false);
+ idx = 0;
bool res;
- while(true) {
+ while (true) {
// using -2 since out-of-tree or nonroot nodes have -1
- int this_idx = (idx >= data.depth)? -2 : this_stack[idx];
- int that_idx = (idx >= p_node->data.depth)? -2 : that_stack[idx];
+ int this_idx = (idx >= data.depth) ? -2 : this_stack[idx];
+ int that_idx = (idx >= p_node->data.depth) ? -2 : that_stack[idx];
if (this_idx > that_idx) {
- res=true;
+ res = true;
break;
} else if (this_idx < that_idx) {
- res=false;
+ res = false;
break;
- } else if (this_idx == -2 ) {
- res=false; // equal
+ } else if (this_idx == -2) {
+ res = false; // equal
break;
}
idx++;
@@ -1067,25 +1008,23 @@ bool Node::is_greater_than(const Node *p_node) const {
return res;
}
-void Node::get_owned_by(Node *p_by,List<Node*> *p_owned) {
+void Node::get_owned_by(Node *p_by, List<Node *> *p_owned) {
- if (data.owner==p_by)
+ if (data.owner == p_by)
p_owned->push_back(this);
- for (int i=0;i<get_child_count();i++)
- get_child(i)->get_owned_by(p_by,p_owned);
-
+ for (int i = 0; i < get_child_count(); i++)
+ get_child(i)->get_owned_by(p_by, p_owned);
}
+void Node::_set_owner_nocheck(Node *p_owner) {
-void Node::_set_owner_nocheck(Node* p_owner) {
-
- if (data.owner==p_owner)
+ if (data.owner == p_owner)
return;
ERR_FAIL_COND(data.owner);
- data.owner=p_owner;
- data.owner->data.owned.push_back( this );
+ data.owner = p_owner;
+ data.owner->data.owned.push_back(this);
data.OW = data.owner->data.owned.back();
}
@@ -1093,27 +1032,27 @@ void Node::set_owner(Node *p_owner) {
if (data.owner) {
- data.owner->data.owned.erase( data.OW );
- data.OW=NULL;
- data.owner=NULL;
+ data.owner->data.owned.erase(data.OW);
+ data.OW = NULL;
+ data.owner = NULL;
}
- ERR_FAIL_COND(p_owner==this);
+ ERR_FAIL_COND(p_owner == this);
if (!p_owner)
return;
- Node *check=this->get_parent();
- bool owner_valid=false;
+ Node *check = this->get_parent();
+ bool owner_valid = false;
- while(check) {
+ while (check) {
- if (check==p_owner) {
- owner_valid=true;
+ if (check == p_owner) {
+ owner_valid = true;
break;
}
- check=check->data.parent;
+ check = check->data.parent;
}
ERR_FAIL_COND(!owner_valid);
@@ -1125,115 +1064,113 @@ Node *Node::get_owner() const {
return data.owner;
}
+Node *Node::find_common_parent_with(const Node *p_node) const {
-Node* Node::find_common_parent_with(const Node *p_node) const {
+ if (this == p_node)
+ return const_cast<Node *>(p_node);
- if (this==p_node)
- return const_cast<Node*>(p_node);
+ Set<const Node *> visited;
- Set<const Node*> visited;
-
- const Node *n=this;
+ const Node *n = this;
- while(n) {
+ while (n) {
visited.insert(n);
- n=n->data.parent;
+ n = n->data.parent;
}
- const Node *common_parent=p_node;
+ const Node *common_parent = p_node;
- while(common_parent) {
+ while (common_parent) {
if (visited.has(common_parent))
break;
- common_parent=common_parent->data.parent;
+ common_parent = common_parent->data.parent;
}
if (!common_parent)
return NULL;
- return const_cast<Node*>(common_parent);
-
+ return const_cast<Node *>(common_parent);
}
NodePath Node::get_path_to(const Node *p_node) const {
- ERR_FAIL_NULL_V(p_node,NodePath());
+ ERR_FAIL_NULL_V(p_node, NodePath());
- if (this==p_node)
+ if (this == p_node)
return NodePath(".");
- Set<const Node*> visited;
+ Set<const Node *> visited;
- const Node *n=this;
+ const Node *n = this;
- while(n) {
+ while (n) {
visited.insert(n);
- n=n->data.parent;
+ n = n->data.parent;
}
- const Node *common_parent=p_node;
+ const Node *common_parent = p_node;
- while(common_parent) {
+ while (common_parent) {
if (visited.has(common_parent))
break;
- common_parent=common_parent->data.parent;
+ common_parent = common_parent->data.parent;
}
- ERR_FAIL_COND_V(!common_parent,NodePath()); //nodes not in the same tree
+ ERR_FAIL_COND_V(!common_parent, NodePath()); //nodes not in the same tree
visited.clear();
Vector<StringName> path;
- n=p_node;
+ n = p_node;
- while(n!=common_parent) {
+ while (n != common_parent) {
- path.push_back( n->get_name() );
- n=n->data.parent;
+ path.push_back(n->get_name());
+ n = n->data.parent;
}
- n=this;
- StringName up=String("..");
+ n = this;
+ StringName up = String("..");
- while(n!=common_parent) {
+ while (n != common_parent) {
- path.push_back( up );
- n=n->data.parent;
+ path.push_back(up);
+ n = n->data.parent;
}
path.invert();
- return NodePath(path,false);
+ return NodePath(path, false);
}
NodePath Node::get_path() const {
- ERR_FAIL_COND_V(!is_inside_tree(),NodePath());
+ ERR_FAIL_COND_V(!is_inside_tree(), NodePath());
const Node *n = this;
Vector<StringName> path;
- while(n) {
+ while (n) {
path.push_back(n->get_name());
- n=n->data.parent;
+ n = n->data.parent;
}
path.invert();
- return NodePath( path, true );
+ return NodePath(path, true);
}
-bool Node::is_in_group(const StringName& p_identifier) const {
+bool Node::is_in_group(const StringName &p_identifier) const {
return data.grouped.has(p_identifier);
}
-void Node::add_to_group(const StringName& p_identifier,bool p_persistent) {
+void Node::add_to_group(const StringName &p_identifier, bool p_persistent) {
ERR_FAIL_COND(!p_identifier.operator String().length());
@@ -1243,32 +1180,28 @@ void Node::add_to_group(const StringName& p_identifier,bool p_persistent) {
GroupData gd;
if (data.tree) {
- gd.group=data.tree->add_to_group(p_identifier,this);
+ gd.group = data.tree->add_to_group(p_identifier, this);
} else {
- gd.group=NULL;
+ gd.group = NULL;
}
- gd.persistent=p_persistent;
-
- data.grouped[p_identifier]=gd;
+ gd.persistent = p_persistent;
+ data.grouped[p_identifier] = gd;
}
-void Node::remove_from_group(const StringName& p_identifier) {
+void Node::remove_from_group(const StringName &p_identifier) {
+ ERR_FAIL_COND(!data.grouped.has(p_identifier));
- ERR_FAIL_COND(!data.grouped.has(p_identifier) );
-
-
- Map< StringName, GroupData>::Element *E=data.grouped.find(p_identifier);
+ Map<StringName, GroupData>::Element *E = data.grouped.find(p_identifier);
ERR_FAIL_COND(!E);
if (data.tree)
- data.tree->remove_from_group(E->key(),this);
+ data.tree->remove_from_group(E->key(), this);
data.grouped.erase(E);
-
}
Array Node::_get_groups() const {
@@ -1276,7 +1209,7 @@ Array Node::_get_groups() const {
Array groups;
List<GroupInfo> gi;
get_groups(&gi);
- for (List<GroupInfo>::Element *E=gi.front();E;E=E->next()) {
+ for (List<GroupInfo>::Element *E = gi.front(); E; E = E->next()) {
groups.push_back(E->get().name);
}
@@ -1285,33 +1218,27 @@ Array Node::_get_groups() const {
void Node::get_groups(List<GroupInfo> *p_groups) const {
-
- for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
+ for (const Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) {
GroupInfo gi;
- gi.name=E->key();
- gi.persistent=E->get().persistent;
+ gi.name = E->key();
+ gi.persistent = E->get().persistent;
p_groups->push_back(gi);
}
-
}
bool Node::has_persistent_groups() const {
-
- for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
+ for (const Map<StringName, GroupData>::Element *E = data.grouped.front(); E; E = E->next()) {
if (E->get().persistent)
return true;
}
-
return false;
-
-
}
void Node::_print_tree(const Node *p_node) {
print_line(String(p_node->get_path_to(this)));
- for (int i=0;i<data.children.size();i++)
+ for (int i = 0; i < data.children.size(); i++)
data.children[i]->_print_tree(p_node);
}
@@ -1320,16 +1247,15 @@ void Node::print_tree() {
_print_tree(this);
}
-
void Node::_propagate_reverse_notification(int p_notification) {
data.blocked++;
- for (int i=data.children.size()-1;i>=0;i--) {
+ for (int i = data.children.size() - 1; i >= 0; i--) {
data.children[i]->_propagate_reverse_notification(p_notification);
}
- notification(p_notification,true);
+ notification(p_notification, true);
data.blocked--;
}
@@ -1340,15 +1266,15 @@ void Node::_propagate_deferred_notification(int p_notification, bool p_reverse)
data.blocked++;
if (!p_reverse)
- MessageQueue::get_singleton()->push_notification(this,p_notification);
+ MessageQueue::get_singleton()->push_notification(this, p_notification);
- for (int i=0;i<data.children.size();i++) {
+ for (int i = 0; i < data.children.size(); i++) {
- data.children[i]->_propagate_deferred_notification(p_notification,p_reverse);
+ data.children[i]->_propagate_deferred_notification(p_notification, p_reverse);
}
if (p_reverse)
- MessageQueue::get_singleton()->push_notification(this,p_notification);
+ MessageQueue::get_singleton()->push_notification(this, p_notification);
data.blocked--;
}
@@ -1358,21 +1284,20 @@ void Node::propagate_notification(int p_notification) {
data.blocked++;
notification(p_notification);
- for (int i=0;i<data.children.size();i++) {
+ for (int i = 0; i < data.children.size(); i++) {
data.children[i]->propagate_notification(p_notification);
}
data.blocked--;
}
-
-void Node::_propagate_replace_owner(Node *p_owner,Node* p_by_owner) {
- if (get_owner()==p_owner)
+void Node::_propagate_replace_owner(Node *p_owner, Node *p_by_owner) {
+ if (get_owner() == p_owner)
set_owner(p_by_owner);
data.blocked++;
- for (int i=0;i<data.children.size();i++)
- data.children[i]->_propagate_replace_owner(p_owner,p_by_owner);
+ for (int i = 0; i < data.children.size(); i++)
+ data.children[i]->_propagate_replace_owner(p_owner, p_by_owner);
data.blocked--;
}
@@ -1384,21 +1309,21 @@ void Node::remove_and_skip() {
ERR_FAIL_COND(!data.parent);
- Node *new_owner=get_owner();
+ Node *new_owner = get_owner();
- List<Node*> children;
+ List<Node *> children;
- while(true) {
+ while (true) {
- bool clear=true;
- for (int i=0;i<data.children.size();i++) {
+ bool clear = true;
+ for (int i = 0; i < data.children.size(); i++) {
if (!data.children[i]->get_owner())
continue;
remove_child(data.children[i]);
- data.children[i]->_propagate_replace_owner(this,NULL);
+ data.children[i]->_propagate_replace_owner(this, NULL);
children.push_back(data.children[i]);
- clear=false;
+ clear = false;
break;
}
@@ -1406,27 +1331,27 @@ void Node::remove_and_skip() {
break;
}
- while(!children.empty()) {
+ while (!children.empty()) {
- Node *c=children.front()->get();
+ Node *c = children.front()->get();
data.parent->add_child(c);
- c->_propagate_replace_owner(NULL,new_owner);
+ c->_propagate_replace_owner(NULL, new_owner);
children.pop_front();
}
data.parent->remove_child(this);
}
-void Node::set_filename(const String& p_filename) {
+void Node::set_filename(const String &p_filename) {
- data.filename=p_filename;
+ data.filename = p_filename;
}
String Node::get_filename() const {
return data.filename;
}
-void Node::set_editable_instance(Node* p_node,bool p_editable) {
+void Node::set_editable_instance(Node *p_node, bool p_editable) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_COND(!is_a_parent_of(p_node));
@@ -1434,30 +1359,28 @@ void Node::set_editable_instance(Node* p_node,bool p_editable) {
if (!p_editable)
data.editable_instances.erase(p);
else
- data.editable_instances[p]=true;
-
+ data.editable_instances[p] = true;
}
bool Node::is_editable_instance(Node *p_node) const {
if (!p_node)
return false; //easier, null is never editable :)
- ERR_FAIL_COND_V(!is_a_parent_of(p_node),false);
+ ERR_FAIL_COND_V(!is_a_parent_of(p_node), false);
NodePath p = get_path_to(p_node);
return data.editable_instances.has(p);
}
-void Node::set_editable_instances(const HashMap<NodePath,int>& p_editable_instances) {
+void Node::set_editable_instances(const HashMap<NodePath, int> &p_editable_instances) {
- data.editable_instances=p_editable_instances;
+ data.editable_instances = p_editable_instances;
}
-HashMap<NodePath,int> Node::get_editable_instances() const {
+HashMap<NodePath, int> Node::get_editable_instances() const {
return data.editable_instances;
}
-
#if 0
void Node::generate_instance_state() {
@@ -1511,32 +1434,32 @@ Dictionary Node::get_instance_state() const {
#endif
-void Node::set_scene_instance_state(const Ref<SceneState>& p_state) {
+void Node::set_scene_instance_state(const Ref<SceneState> &p_state) {
- data.instance_state=p_state;
+ data.instance_state = p_state;
}
-Ref<SceneState> Node::get_scene_instance_state() const{
+Ref<SceneState> Node::get_scene_instance_state() const {
return data.instance_state;
}
-void Node::set_scene_inherited_state(const Ref<SceneState>& p_state) {
+void Node::set_scene_inherited_state(const Ref<SceneState> &p_state) {
- data.inherited_state=p_state;
+ data.inherited_state = p_state;
}
-Ref<SceneState> Node::get_scene_inherited_state() const{
+Ref<SceneState> Node::get_scene_inherited_state() const {
return data.inherited_state;
}
void Node::set_scene_instance_load_placeholder(bool p_enable) {
- data.use_placeholder=p_enable;
+ data.use_placeholder = p_enable;
}
-bool Node::get_scene_instance_load_placeholder() const{
+bool Node::get_scene_instance_load_placeholder() const {
return data.use_placeholder;
}
@@ -1546,43 +1469,39 @@ int Node::get_position_in_parent() const {
return data.pos;
}
+Node *Node::_duplicate(bool p_use_instancing, int p_flags) const {
+ Node *node = NULL;
-Node *Node::_duplicate(bool p_use_instancing,int p_flags) const {
-
-
- Node *node=NULL;
-
- bool instanced=false;
+ bool instanced = false;
if (cast_to<InstancePlaceholder>()) {
const InstancePlaceholder *ip = cast_to<const InstancePlaceholder>();
- InstancePlaceholder *nip = memnew( InstancePlaceholder );
- nip->set_instance_path( ip->get_instance_path() );
- node=nip;
+ InstancePlaceholder *nip = memnew(InstancePlaceholder);
+ nip->set_instance_path(ip->get_instance_path());
+ node = nip;
- } else if (p_use_instancing && get_filename()!=String()) {
+ } else if (p_use_instancing && get_filename() != String()) {
Ref<PackedScene> res = ResourceLoader::load(get_filename());
- ERR_FAIL_COND_V(res.is_null(),NULL);
- node=res->instance();
- ERR_FAIL_COND_V(!node,NULL);
+ ERR_FAIL_COND_V(res.is_null(), NULL);
+ node = res->instance();
+ ERR_FAIL_COND_V(!node, NULL);
- instanced=true;
+ instanced = true;
} else {
Object *obj = ObjectTypeDB::instance(get_type());
- ERR_FAIL_COND_V(!obj,NULL);
+ ERR_FAIL_COND_V(!obj, NULL);
node = obj->cast_to<Node>();
if (!node)
memdelete(obj);
- ERR_FAIL_COND_V(!node,NULL);
+ ERR_FAIL_COND_V(!node, NULL);
}
-
- if (get_filename()!="") { //an instance
+ if (get_filename() != "") { //an instance
node->set_filename(get_filename());
}
@@ -1590,16 +1509,15 @@ Node *Node::_duplicate(bool p_use_instancing,int p_flags) const {
get_property_list(&plist);
- for(List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
- if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- if (!(p_flags&DUPLICATE_SCRIPTS) && name=="script/script")
+ if (!(p_flags & DUPLICATE_SCRIPTS) && name == "script/script")
continue;
- node->set( name, get(name) );
-
+ node->set(name, get(name));
}
node->set_name(get_name());
@@ -1607,7 +1525,7 @@ Node *Node::_duplicate(bool p_use_instancing,int p_flags) const {
if (p_flags & DUPLICATE_GROUPS) {
List<GroupInfo> gi;
get_groups(&gi);
- for (List<GroupInfo>::Element *E=gi.front();E;E=E->next()) {
+ for (List<GroupInfo>::Element *E = gi.front(); E; E = E->next()) {
node->add_to_group(E->get().name, E->get().persistent);
}
@@ -1616,14 +1534,14 @@ Node *Node::_duplicate(bool p_use_instancing,int p_flags) const {
if (p_flags & DUPLICATE_SIGNALS)
_duplicate_signals(this, node);
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
if (get_child(i)->data.parent_owned)
continue;
- if (instanced && get_child(i)->data.owner==this)
+ if (instanced && get_child(i)->data.owner == this)
continue; //part of instance
- Node *dup = get_child(i)->duplicate(p_use_instancing,p_flags);
+ Node *dup = get_child(i)->duplicate(p_use_instancing, p_flags);
if (!dup) {
memdelete(node);
@@ -1633,40 +1551,38 @@ Node *Node::_duplicate(bool p_use_instancing,int p_flags) const {
node->add_child(dup);
}
-
return node;
}
-Node *Node::duplicate(bool p_use_instancing,int p_flags) const {
+Node *Node::duplicate(bool p_use_instancing, int p_flags) const {
- Node* dupe = _duplicate(p_use_instancing,p_flags);
+ Node *dupe = _duplicate(p_use_instancing, p_flags);
- if (dupe && (p_flags&DUPLICATE_SIGNALS)) {
- _duplicate_signals(this,dupe);
+ if (dupe && (p_flags & DUPLICATE_SIGNALS)) {
+ _duplicate_signals(this, dupe);
}
return dupe;
}
+void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const {
-void Node::_duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_reown_map) const {
-
- if (get_owner()!=get_parent()->get_owner())
+ if (get_owner() != get_parent()->get_owner())
return;
- Node *node=NULL;
+ Node *node = NULL;
- if (get_filename()!="") {
+ if (get_filename() != "") {
Ref<PackedScene> res = ResourceLoader::load(get_filename());
ERR_FAIL_COND(res.is_null());
- node=res->instance();
+ node = res->instance();
ERR_FAIL_COND(!node);
} else {
Object *obj = ObjectTypeDB::instance(get_type());
if (!obj) {
- print_line("could not duplicate: "+String(get_type()));
+ print_line("could not duplicate: " + String(get_type()));
}
ERR_FAIL_COND(!obj);
node = obj->cast_to<Node>();
@@ -1674,32 +1590,29 @@ void Node::_duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_re
memdelete(obj);
}
-
List<PropertyInfo> plist;
get_property_list(&plist);
- for(List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
- if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set( name, get(name) );
-
+ node->set(name, get(name));
}
node->set_name(get_name());
p_new_parent->add_child(node);
- Node *owner=get_owner();
+ Node *owner = get_owner();
if (p_reown_map.has(owner))
- owner=p_reown_map[owner];
-
+ owner = p_reown_map[owner];
if (owner) {
NodePath p = get_path_to(owner);
- if (owner!=this) {
+ if (owner != this) {
Node *new_owner = node->get_node(p);
if (new_owner) {
node->set_owner(new_owner);
@@ -1707,26 +1620,23 @@ void Node::_duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_re
}
}
- for(int i=0;i<get_child_count();i++) {
+ for (int i = 0; i < get_child_count(); i++) {
- get_child(i)->_duplicate_and_reown(node,p_reown_map);
+ get_child(i)->_duplicate_and_reown(node, p_reown_map);
}
-
}
+void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
-void Node::_duplicate_signals(const Node* p_original,Node* p_copy) const {
-
- if (this!=p_original && (get_owner()!=p_original && get_owner()!=p_original->get_owner()))
+ if (this != p_original && (get_owner() != p_original && get_owner() != p_original->get_owner()))
return;
List<Connection> conns;
get_all_signal_connections(&conns);
+ for (List<Connection>::Element *E = conns.front(); E; E = E->next()) {
- for (List<Connection>::Element *E=conns.front();E;E=E->next()) {
-
- if (E->get().flags&CONNECT_PERSIST) {
+ if (E->get().flags & CONNECT_PERSIST) {
//user connected
NodePath p = p_original->get_path_to(this);
Node *copy = p_copy->get_node(p);
@@ -1738,37 +1648,32 @@ void Node::_duplicate_signals(const Node* p_original,Node* p_copy) const {
NodePath ptarget = p_original->get_path_to(target);
Node *copytarget = p_copy->get_node(ptarget);
-
if (copy && copytarget) {
- copy->connect(E->get().signal,copytarget,E->get().method,E->get().binds,CONNECT_PERSIST);
+ copy->connect(E->get().signal, copytarget, E->get().method, E->get().binds, CONNECT_PERSIST);
}
-
}
}
- for(int i=0;i<get_child_count();i++) {
- get_child(i)->_duplicate_signals(p_original,p_copy);
+ for (int i = 0; i < get_child_count(); i++) {
+ get_child(i)->_duplicate_signals(p_original, p_copy);
}
-
}
+Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
-Node *Node::duplicate_and_reown(const Map<Node*,Node*>& p_reown_map) const {
-
-
- ERR_FAIL_COND_V(get_filename()!="",NULL);
+ ERR_FAIL_COND_V(get_filename() != "", NULL);
- Node *node=NULL;
+ Node *node = NULL;
Object *obj = ObjectTypeDB::instance(get_type());
if (!obj) {
- print_line("could not duplicate: "+String(get_type()));
+ print_line("could not duplicate: " + String(get_type()));
}
- ERR_FAIL_COND_V(!obj,NULL);
+ ERR_FAIL_COND_V(!obj, NULL);
node = obj->cast_to<Node>();
if (!node)
memdelete(obj);
- ERR_FAIL_COND_V(!node,NULL);
+ ERR_FAIL_COND_V(!node, NULL);
node->set_name(get_name());
@@ -1776,35 +1681,31 @@ Node *Node::duplicate_and_reown(const Map<Node*,Node*>& p_reown_map) const {
get_property_list(&plist);
- for(List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
- if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
String name = E->get().name;
- node->set( name, get(name) );
-
+ node->set(name, get(name));
}
+ for (int i = 0; i < get_child_count(); i++) {
- for(int i=0;i<get_child_count();i++) {
-
- get_child(i)->_duplicate_and_reown(node,p_reown_map);
+ get_child(i)->_duplicate_and_reown(node, p_reown_map);
}
- _duplicate_signals(this,node);
+ _duplicate_signals(this, node);
return node;
-
}
-static void find_owned_by(Node* p_by, Node* p_node, List<Node*> *p_owned) {
+static void find_owned_by(Node *p_by, Node *p_node, List<Node *> *p_owned) {
-
- if (p_node->get_owner()==p_by)
+ if (p_node->get_owner() == p_by)
p_owned->push_back(p_node);
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- find_owned_by(p_by,p_node->get_child(i),p_owned);
+ find_owned_by(p_by, p_node->get_child(i), p_owned);
}
}
@@ -1814,14 +1715,14 @@ struct _NodeReplaceByPair {
Variant value;
};
-void Node::replace_by(Node* p_node,bool p_keep_data) {
+void Node::replace_by(Node *p_node, bool p_keep_data) {
ERR_FAIL_NULL(p_node);
ERR_FAIL_COND(p_node->data.parent);
- List<Node*> owned = data.owned;
- List<Node*> owned_by_owner;
- Node *owner = (data.owner==this)?p_node:data.owner;
+ List<Node *> owned = data.owned;
+ List<Node *> owned_by_owner;
+ Node *owner = (data.owner == this) ? p_node : data.owner;
List<_NodeReplaceByPair> replace_data;
@@ -1830,27 +1731,27 @@ void Node::replace_by(Node* p_node,bool p_keep_data) {
List<PropertyInfo> plist;
get_property_list(&plist);
- for(List<PropertyInfo>::Element *E=plist.front();E;E=E->next() ) {
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
_NodeReplaceByPair rd;
- if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
- rd.name=E->get().name;
- rd.value=get(rd.name);
+ rd.name = E->get().name;
+ rd.value = get(rd.name);
}
List<GroupInfo> groups;
get_groups(&groups);
- for(List<GroupInfo>::Element *E=groups.front();E;E=E->next())
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next())
p_node->add_to_group(E->get().name, E->get().persistent);
}
_replace_connections_target(p_node);
if (data.owner) {
- for(int i=0;i<get_child_count();i++)
- find_owned_by(data.owner,get_child(i),&owned_by_owner);
+ for (int i = 0; i < get_child_count(); i++)
+ find_owned_by(data.owner, get_child(i), &owned_by_owner);
}
Node *parent = data.parent;
@@ -1860,73 +1761,70 @@ void Node::replace_by(Node* p_node,bool p_keep_data) {
parent->remove_child(this);
parent->add_child(p_node);
- parent->move_child(p_node,pos_in_parent);
+ parent->move_child(p_node, pos_in_parent);
}
- while(get_child_count()) {
+ while (get_child_count()) {
- Node * child = get_child(0);
+ Node *child = get_child(0);
remove_child(child);
p_node->add_child(child);
}
p_node->set_owner(owner);
- for(int i=0;i<owned.size();i++)
+ for (int i = 0; i < owned.size(); i++)
owned[i]->set_owner(p_node);
- for(int i=0;i<owned_by_owner.size();i++)
+ for (int i = 0; i < owned_by_owner.size(); i++)
owned_by_owner[i]->set_owner(owner);
p_node->set_filename(get_filename());
- for (List<_NodeReplaceByPair>::Element *E=replace_data.front();E;E=E->next()) {
+ for (List<_NodeReplaceByPair>::Element *E = replace_data.front(); E; E = E->next()) {
- p_node->set(E->get().name,E->get().value);
+ p_node->set(E->get().name, E->get().value);
}
-
}
-void Node::_replace_connections_target(Node* p_new_target) {
+void Node::_replace_connections_target(Node *p_new_target) {
List<Connection> cl;
get_signals_connected_to_this(&cl);
- for(List<Connection>::Element *E=cl.front();E;E=E->next()) {
+ for (List<Connection>::Element *E = cl.front(); E; E = E->next()) {
- Connection &c=E->get();
+ Connection &c = E->get();
- c.source->disconnect(c.signal,this,c.method);
- c.source->connect(c.signal,p_new_target,c.method,c.binds,c.flags);
+ c.source->disconnect(c.signal, this, c.method);
+ c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags);
}
}
Vector<Variant> Node::make_binds(VARIANT_ARG_DECLARE) {
-
Vector<Variant> ret;
- if (p_arg1.get_type()==Variant::NIL)
+ if (p_arg1.get_type() == Variant::NIL)
return ret;
else
ret.push_back(p_arg1);
- if (p_arg2.get_type()==Variant::NIL)
+ if (p_arg2.get_type() == Variant::NIL)
return ret;
else
ret.push_back(p_arg2);
-
- if (p_arg3.get_type()==Variant::NIL)
+ if (p_arg3.get_type() == Variant::NIL)
return ret;
else
ret.push_back(p_arg3);
- if (p_arg4.get_type()==Variant::NIL)
+ if (p_arg4.get_type() == Variant::NIL)
return ret;
else
ret.push_back(p_arg4);
- if (p_arg5.get_type()==Variant::NIL)
+ if (p_arg5.get_type() == Variant::NIL)
return ret;
else
ret.push_back(p_arg5);
@@ -1934,9 +1832,7 @@ Vector<Variant> Node::make_binds(VARIANT_ARG_DECLARE) {
return ret;
}
-
-
-bool Node::has_node_and_resource(const NodePath& p_path) const {
+bool Node::has_node_and_resource(const NodePath &p_path) const {
if (!has_node(p_path))
return false;
@@ -1945,23 +1841,21 @@ bool Node::has_node_and_resource(const NodePath& p_path) const {
if (p_path.get_subname_count()) {
RES r;
- for(int j=0;j<p_path.get_subname_count();j++) {
- r = j==0 ? node->get(p_path.get_subname(j)) : r->get(p_path.get_subname(j));
+ for (int j = 0; j < p_path.get_subname_count(); j++) {
+ r = j == 0 ? node->get(p_path.get_subname(j)) : r->get(p_path.get_subname(j));
if (r.is_null())
return false;
}
}
-
return true;
}
-
-Array Node::_get_node_and_resource(const NodePath& p_path) {
+Array Node::_get_node_and_resource(const NodePath &p_path) {
Node *node;
RES res;
- node = get_node_and_resource(p_path,res);
+ node = get_node_and_resource(p_path, res);
Array result;
if (node)
@@ -1977,7 +1871,7 @@ Array Node::_get_node_and_resource(const NodePath& p_path) {
return result;
}
-Node *Node::get_node_and_resource(const NodePath& p_path,RES& r_res) const {
+Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res) const {
Node *node = get_node(p_path);
r_res = RES();
@@ -1986,9 +1880,9 @@ Node *Node::get_node_and_resource(const NodePath& p_path,RES& r_res) const {
if (p_path.get_subname_count()) {
- for(int j=0;j<p_path.get_subname_count();j++) {
- r_res = j==0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j));
- ERR_FAIL_COND_V( r_res.is_null(), node );
+ for (int j = 0; j < p_path.get_subname_count(); j++) {
+ r_res = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j));
+ ERR_FAIL_COND_V(r_res.is_null(), node);
}
}
@@ -1997,40 +1891,35 @@ Node *Node::get_node_and_resource(const NodePath& p_path,RES& r_res) const {
void Node::_set_tree(SceneTree *p_tree) {
- SceneTree *tree_changed_a=NULL;
- SceneTree *tree_changed_b=NULL;
+ SceneTree *tree_changed_a = NULL;
+ SceneTree *tree_changed_b = NULL;
-// ERR_FAIL_COND(p_scene && data.parent && !data.parent->data.scene); //nobug if both are null
+ // ERR_FAIL_COND(p_scene && data.parent && !data.parent->data.scene); //nobug if both are null
if (data.tree) {
_propagate_exit_tree();
- tree_changed_a=data.tree;
+ tree_changed_a = data.tree;
}
-
- data.tree=p_tree;
+ data.tree = p_tree;
if (data.tree) {
-
_propagate_enter_tree();
if (!data.parent || data.parent->data.ready_notified) { // No parent (root) or parent ready
_propagate_ready(); //reverse_notification(NOTIFICATION_READY);
}
- tree_changed_b=data.tree;
-
+ tree_changed_b = data.tree;
}
if (tree_changed_a)
tree_changed_a->tree_changed();
if (tree_changed_b)
tree_changed_b->tree_changed();
-
}
-
static void _Node_debug_sn(Object *p_obj) {
Node *n = p_obj->cast_to<Node>();
@@ -2040,18 +1929,17 @@ static void _Node_debug_sn(Object *p_obj) {
if (n->is_inside_tree())
return;
- Node *p=n;
- while(p->get_parent()) {
- p=p->get_parent();
+ Node *p = n;
+ while (p->get_parent()) {
+ p = p->get_parent();
}
String path;
- if (p==n)
- path=n->get_name();
+ if (p == n)
+ path = n->get_name();
else
- path=String(p->get_name())+"/"+p->get_path_to(n);
- print_line(itos(p_obj->get_instance_ID())+"- Stray Node: "+path+" (Type: "+n->get_type()+")");
-
+ path = String(p->get_name()) + "/" + p->get_path_to(n);
+ print_line(itos(p_obj->get_instance_ID()) + "- Stray Node: " + path + " (Type: " + n->get_type() + ")");
}
void Node::_print_stray_nodes() {
@@ -2069,7 +1957,7 @@ void Node::print_stray_nodes() {
void Node::queue_delete() {
- ERR_FAIL_COND( !is_inside_tree() );
+ ERR_FAIL_COND(!is_inside_tree());
get_tree()->queue_delete(this);
}
@@ -2078,17 +1966,16 @@ Array Node::_get_children() const {
Array arr;
int cc = get_child_count();
arr.resize(cc);
- for(int i=0;i<cc;i++)
- arr[i]=get_child(i);
+ for (int i = 0; i < cc; i++)
+ arr[i] = get_child(i);
return arr;
}
#ifdef TOOLS_ENABLED
-void Node::set_import_path(const NodePath& p_import_path) {
+void Node::set_import_path(const NodePath &p_import_path) {
-
- data.import_path=p_import_path;
+ data.import_path = p_import_path;
}
NodePath Node::get_import_path() const {
@@ -2098,35 +1985,33 @@ NodePath Node::get_import_path() const {
#endif
-static void _add_nodes_to_options(const Node *p_base,const Node *p_node,List<String>*r_options) {
+static void _add_nodes_to_options(const Node *p_base, const Node *p_node, List<String> *r_options) {
- if (p_node!=p_base && !p_node->get_owner())
+ if (p_node != p_base && !p_node->get_owner())
return;
String n = p_base->get_path_to(p_node);
- r_options->push_back("\""+n+"\"");
- for(int i=0;i<p_node->get_child_count();i++) {
- _add_nodes_to_options(p_base,p_node->get_child(i),r_options);
+ r_options->push_back("\"" + n + "\"");
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ _add_nodes_to_options(p_base, p_node->get_child(i), r_options);
}
}
-void Node::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
+void Node::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
- String pf=p_function;
- if ((pf=="has_node" || pf=="get_node") && p_idx==0) {
+ String pf = p_function;
+ if ((pf == "has_node" || pf == "get_node") && p_idx == 0) {
- _add_nodes_to_options(this,this,r_options);
+ _add_nodes_to_options(this, this, r_options);
}
- Object::get_argument_options(p_function,p_idx,r_options);
+ Object::get_argument_options(p_function, p_idx, r_options);
}
-
void Node::clear_internal_tree_resource_paths() {
clear_internal_resource_paths();
- for(int i=0;i<data.children.size();i++) {
+ for (int i = 0; i < data.children.size(); i++) {
data.children[i]->clear_internal_tree_resource_paths();
}
-
}
String Node::get_configuration_warning() const {
@@ -2139,11 +2024,10 @@ void Node::update_configuration_warning() {
#ifdef TOOLS_ENABLED
if (!is_inside_tree())
return;
- if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root()==this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
- get_tree()->emit_signal(SceneStringNames::get_singleton()->node_configuration_warning_changed,this);
+ if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
+ get_tree()->emit_signal(SceneStringNames::get_singleton()->node_configuration_warning_changed, this);
}
#endif
-
}
bool Node::is_owned_by_parent() const {
@@ -2151,7 +2035,7 @@ bool Node::is_owned_by_parent() const {
}
void Node::set_display_folded(bool p_folded) {
- data.display_folded=p_folded;
+ data.display_folded = p_folded;
}
bool Node::is_displayed_folded() const {
@@ -2161,174 +2045,162 @@ bool Node::is_displayed_folded() const {
void Node::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("_add_child_below_node", "node:Node", "child_node:Node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_name","name"),&Node::set_name);
- ObjectTypeDB::bind_method(_MD("get_name"),&Node::get_name);
- ObjectTypeDB::bind_method(_MD("add_child","node:Node","legible_unique_name"),&Node::add_child,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("remove_child","node:Node"),&Node::remove_child);
+ ObjectTypeDB::bind_method(_MD("set_name", "name"), &Node::set_name);
+ ObjectTypeDB::bind_method(_MD("get_name"), &Node::get_name);
+ ObjectTypeDB::bind_method(_MD("add_child", "node:Node", "legible_unique_name"), &Node::add_child, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("remove_child", "node:Node"), &Node::remove_child);
//ObjectTypeDB::bind_method(_MD("remove_and_delete_child","node:Node"),&Node::remove_and_delete_child);
- ObjectTypeDB::bind_method(_MD("get_child_count"),&Node::get_child_count);
- ObjectTypeDB::bind_method(_MD("get_children"),&Node::_get_children);
- ObjectTypeDB::bind_method(_MD("get_child:Node","idx"),&Node::get_child);
- ObjectTypeDB::bind_method(_MD("has_node","path"),&Node::has_node);
- ObjectTypeDB::bind_method(_MD("get_node:Node","path"),&Node::get_node);
- ObjectTypeDB::bind_method(_MD("get_parent:Node"),&Node::get_parent);
- ObjectTypeDB::bind_method(_MD("find_node:Node","mask","recursive","owned"),&Node::find_node,DEFVAL(true),DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("has_node_and_resource","path"),&Node::has_node_and_resource);
- ObjectTypeDB::bind_method(_MD("get_node_and_resource","path"),&Node::_get_node_and_resource);
-
- ObjectTypeDB::bind_method(_MD("is_inside_tree"),&Node::is_inside_tree);
- ObjectTypeDB::bind_method(_MD("is_a_parent_of","node:Node"),&Node::is_a_parent_of);
- ObjectTypeDB::bind_method(_MD("is_greater_than","node:Node"),&Node::is_greater_than);
- ObjectTypeDB::bind_method(_MD("get_path"),&Node::get_path);
- ObjectTypeDB::bind_method(_MD("get_path_to","node:Node"),&Node::get_path_to);
- ObjectTypeDB::bind_method(_MD("add_to_group","group","persistent"),&Node::add_to_group,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("remove_from_group","group"),&Node::remove_from_group);
- ObjectTypeDB::bind_method(_MD("is_in_group","group"),&Node::is_in_group);
- ObjectTypeDB::bind_method(_MD("move_child","child_node:Node","to_pos"),&Node::move_child);
- ObjectTypeDB::bind_method(_MD("get_groups"),&Node::_get_groups);
- ObjectTypeDB::bind_method(_MD("raise"),&Node::raise);
- ObjectTypeDB::bind_method(_MD("set_owner","owner:Node"),&Node::set_owner);
- ObjectTypeDB::bind_method(_MD("get_owner:Node"),&Node::get_owner);
- ObjectTypeDB::bind_method(_MD("remove_and_skip"),&Node::remove_and_skip);
- ObjectTypeDB::bind_method(_MD("get_index"),&Node::get_index);
- ObjectTypeDB::bind_method(_MD("print_tree"),&Node::print_tree);
- ObjectTypeDB::bind_method(_MD("set_filename","filename"),&Node::set_filename);
- ObjectTypeDB::bind_method(_MD("get_filename"),&Node::get_filename);
- ObjectTypeDB::bind_method(_MD("propagate_notification","what"),&Node::propagate_notification);
- ObjectTypeDB::bind_method(_MD("set_fixed_process","enable"),&Node::set_fixed_process);
- ObjectTypeDB::bind_method(_MD("get_fixed_process_delta_time"),&Node::get_fixed_process_delta_time);
- ObjectTypeDB::bind_method(_MD("is_fixed_processing"),&Node::is_fixed_processing);
- ObjectTypeDB::bind_method(_MD("set_process","enable"),&Node::set_process);
- ObjectTypeDB::bind_method(_MD("get_process_delta_time"),&Node::get_process_delta_time);
- ObjectTypeDB::bind_method(_MD("is_processing"),&Node::is_processing);
- ObjectTypeDB::bind_method(_MD("set_process_input","enable"),&Node::set_process_input);
- ObjectTypeDB::bind_method(_MD("is_processing_input"),&Node::is_processing_input);
- ObjectTypeDB::bind_method(_MD("set_process_unhandled_input","enable"),&Node::set_process_unhandled_input);
- ObjectTypeDB::bind_method(_MD("is_processing_unhandled_input"),&Node::is_processing_unhandled_input);
- ObjectTypeDB::bind_method(_MD("set_process_unhandled_key_input","enable"),&Node::set_process_unhandled_key_input);
- ObjectTypeDB::bind_method(_MD("is_processing_unhandled_key_input"),&Node::is_processing_unhandled_key_input);
- ObjectTypeDB::bind_method(_MD("set_pause_mode","mode"),&Node::set_pause_mode);
- ObjectTypeDB::bind_method(_MD("get_pause_mode"),&Node::get_pause_mode);
- ObjectTypeDB::bind_method(_MD("can_process"),&Node::can_process);
- ObjectTypeDB::bind_method(_MD("print_stray_nodes"),&Node::_print_stray_nodes);
- ObjectTypeDB::bind_method(_MD("get_position_in_parent"),&Node::get_position_in_parent);
- ObjectTypeDB::bind_method(_MD("set_display_folded","fold"),&Node::set_display_folded);
- ObjectTypeDB::bind_method(_MD("is_displayed_folded"),&Node::is_displayed_folded);
+ ObjectTypeDB::bind_method(_MD("get_child_count"), &Node::get_child_count);
+ ObjectTypeDB::bind_method(_MD("get_children"), &Node::_get_children);
+ ObjectTypeDB::bind_method(_MD("get_child:Node", "idx"), &Node::get_child);
+ ObjectTypeDB::bind_method(_MD("has_node", "path"), &Node::has_node);
+ ObjectTypeDB::bind_method(_MD("get_node:Node", "path"), &Node::get_node);
+ ObjectTypeDB::bind_method(_MD("get_parent:Node"), &Node::get_parent);
+ ObjectTypeDB::bind_method(_MD("find_node:Node", "mask", "recursive", "owned"), &Node::find_node, DEFVAL(true), DEFVAL(true));
+ ObjectTypeDB::bind_method(_MD("has_node_and_resource", "path"), &Node::has_node_and_resource);
+ ObjectTypeDB::bind_method(_MD("get_node_and_resource", "path"), &Node::_get_node_and_resource);
- ObjectTypeDB::bind_method(_MD("get_tree:SceneTree"),&Node::get_tree);
+ ObjectTypeDB::bind_method(_MD("is_inside_tree"), &Node::is_inside_tree);
+ ObjectTypeDB::bind_method(_MD("is_a_parent_of", "node:Node"), &Node::is_a_parent_of);
+ ObjectTypeDB::bind_method(_MD("is_greater_than", "node:Node"), &Node::is_greater_than);
+ ObjectTypeDB::bind_method(_MD("get_path"), &Node::get_path);
+ ObjectTypeDB::bind_method(_MD("get_path_to", "node:Node"), &Node::get_path_to);
+ ObjectTypeDB::bind_method(_MD("add_to_group", "group", "persistent"), &Node::add_to_group, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("remove_from_group", "group"), &Node::remove_from_group);
+ ObjectTypeDB::bind_method(_MD("is_in_group", "group"), &Node::is_in_group);
+ ObjectTypeDB::bind_method(_MD("move_child", "child_node:Node", "to_pos"), &Node::move_child);
+ ObjectTypeDB::bind_method(_MD("get_groups"), &Node::_get_groups);
+ ObjectTypeDB::bind_method(_MD("raise"), &Node::raise);
+ ObjectTypeDB::bind_method(_MD("set_owner", "owner:Node"), &Node::set_owner);
+ ObjectTypeDB::bind_method(_MD("get_owner:Node"), &Node::get_owner);
+ ObjectTypeDB::bind_method(_MD("remove_and_skip"), &Node::remove_and_skip);
+ ObjectTypeDB::bind_method(_MD("get_index"), &Node::get_index);
+ ObjectTypeDB::bind_method(_MD("print_tree"), &Node::print_tree);
+ ObjectTypeDB::bind_method(_MD("set_filename", "filename"), &Node::set_filename);
+ ObjectTypeDB::bind_method(_MD("get_filename"), &Node::get_filename);
+ ObjectTypeDB::bind_method(_MD("propagate_notification", "what"), &Node::propagate_notification);
+ ObjectTypeDB::bind_method(_MD("set_fixed_process", "enable"), &Node::set_fixed_process);
+ ObjectTypeDB::bind_method(_MD("get_fixed_process_delta_time"), &Node::get_fixed_process_delta_time);
+ ObjectTypeDB::bind_method(_MD("is_fixed_processing"), &Node::is_fixed_processing);
+ ObjectTypeDB::bind_method(_MD("set_process", "enable"), &Node::set_process);
+ ObjectTypeDB::bind_method(_MD("get_process_delta_time"), &Node::get_process_delta_time);
+ ObjectTypeDB::bind_method(_MD("is_processing"), &Node::is_processing);
+ ObjectTypeDB::bind_method(_MD("set_process_input", "enable"), &Node::set_process_input);
+ ObjectTypeDB::bind_method(_MD("is_processing_input"), &Node::is_processing_input);
+ ObjectTypeDB::bind_method(_MD("set_process_unhandled_input", "enable"), &Node::set_process_unhandled_input);
+ ObjectTypeDB::bind_method(_MD("is_processing_unhandled_input"), &Node::is_processing_unhandled_input);
+ ObjectTypeDB::bind_method(_MD("set_process_unhandled_key_input", "enable"), &Node::set_process_unhandled_key_input);
+ ObjectTypeDB::bind_method(_MD("is_processing_unhandled_key_input"), &Node::is_processing_unhandled_key_input);
+ ObjectTypeDB::bind_method(_MD("set_pause_mode", "mode"), &Node::set_pause_mode);
+ ObjectTypeDB::bind_method(_MD("get_pause_mode"), &Node::get_pause_mode);
+ ObjectTypeDB::bind_method(_MD("can_process"), &Node::can_process);
+ ObjectTypeDB::bind_method(_MD("print_stray_nodes"), &Node::_print_stray_nodes);
+ ObjectTypeDB::bind_method(_MD("get_position_in_parent"), &Node::get_position_in_parent);
+ ObjectTypeDB::bind_method(_MD("set_display_folded", "fold"), &Node::set_display_folded);
+ ObjectTypeDB::bind_method(_MD("is_displayed_folded"), &Node::is_displayed_folded);
- ObjectTypeDB::bind_method(_MD("duplicate:Node","use_instancing","flags"),&Node::duplicate,DEFVAL(false),DEFVAL(DUPLICATE_SIGNALS|DUPLICATE_GROUPS|DUPLICATE_SCRIPTS));
- ObjectTypeDB::bind_method(_MD("replace_by","node:Node","keep_data"),&Node::replace_by,DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_tree:SceneTree"), &Node::get_tree);
- ObjectTypeDB::bind_method(_MD("set_scene_instance_load_placeholder","load_placeholder"),&Node::set_scene_instance_load_placeholder);
- ObjectTypeDB::bind_method(_MD("get_scene_instance_load_placeholder"),&Node::get_scene_instance_load_placeholder);
-
-
- ObjectTypeDB::bind_method(_MD("get_viewport"),&Node::get_viewport);
-
- ObjectTypeDB::bind_method(_MD("queue_free"),&Node::queue_delete);
+ ObjectTypeDB::bind_method(_MD("duplicate:Node", "use_instancing", "flags"), &Node::duplicate, DEFVAL(false), DEFVAL(DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS));
+ ObjectTypeDB::bind_method(_MD("replace_by", "node:Node", "keep_data"), &Node::replace_by, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("set_scene_instance_load_placeholder", "load_placeholder"), &Node::set_scene_instance_load_placeholder);
+ ObjectTypeDB::bind_method(_MD("get_scene_instance_load_placeholder"), &Node::get_scene_instance_load_placeholder);
+ ObjectTypeDB::bind_method(_MD("get_viewport"), &Node::get_viewport);
+ ObjectTypeDB::bind_method(_MD("queue_free"), &Node::queue_delete);
#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method(_MD("_set_import_path","import_path"),&Node::set_import_path);
- ObjectTypeDB::bind_method(_MD("_get_import_path"),&Node::get_import_path);
- ADD_PROPERTYNZ( PropertyInfo(Variant::NODE_PATH,"_import_path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_import_path"),_SCS("_get_import_path"));
+ ObjectTypeDB::bind_method(_MD("_set_import_path", "import_path"), &Node::set_import_path);
+ ObjectTypeDB::bind_method(_MD("_get_import_path"), &Node::get_import_path);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::NODE_PATH, "_import_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_import_path"), _SCS("_get_import_path"));
#endif
- BIND_CONSTANT( NOTIFICATION_ENTER_TREE );
- BIND_CONSTANT( NOTIFICATION_EXIT_TREE );
- BIND_CONSTANT( NOTIFICATION_MOVED_IN_PARENT );
+ BIND_CONSTANT(NOTIFICATION_ENTER_TREE);
+ BIND_CONSTANT(NOTIFICATION_EXIT_TREE);
+ BIND_CONSTANT(NOTIFICATION_MOVED_IN_PARENT);
//BIND_CONSTANT( NOTIFICATION_PARENT_DECONFIGURED );
- BIND_CONSTANT( NOTIFICATION_READY );
- BIND_CONSTANT( NOTIFICATION_FIXED_PROCESS );
- BIND_CONSTANT( NOTIFICATION_PROCESS );
- BIND_CONSTANT( NOTIFICATION_PARENTED );
- BIND_CONSTANT( NOTIFICATION_UNPARENTED );
- BIND_CONSTANT( NOTIFICATION_PAUSED );
- BIND_CONSTANT( NOTIFICATION_UNPAUSED );
- BIND_CONSTANT( NOTIFICATION_INSTANCED );
- BIND_CONSTANT( NOTIFICATION_DRAG_BEGIN );
- BIND_CONSTANT( NOTIFICATION_DRAG_END );
-
+ BIND_CONSTANT(NOTIFICATION_READY);
+ BIND_CONSTANT(NOTIFICATION_FIXED_PROCESS);
+ BIND_CONSTANT(NOTIFICATION_PROCESS);
+ BIND_CONSTANT(NOTIFICATION_PARENTED);
+ BIND_CONSTANT(NOTIFICATION_UNPARENTED);
+ BIND_CONSTANT(NOTIFICATION_PAUSED);
+ BIND_CONSTANT(NOTIFICATION_UNPAUSED);
+ BIND_CONSTANT(NOTIFICATION_INSTANCED);
+ BIND_CONSTANT(NOTIFICATION_DRAG_BEGIN);
+ BIND_CONSTANT(NOTIFICATION_DRAG_END);
+ BIND_CONSTANT(PAUSE_MODE_INHERIT);
+ BIND_CONSTANT(PAUSE_MODE_STOP);
+ BIND_CONSTANT(PAUSE_MODE_PROCESS);
- BIND_CONSTANT( PAUSE_MODE_INHERIT );
- BIND_CONSTANT( PAUSE_MODE_STOP );
- BIND_CONSTANT( PAUSE_MODE_PROCESS );
+ BIND_CONSTANT(DUPLICATE_SIGNALS);
+ BIND_CONSTANT(DUPLICATE_GROUPS);
+ BIND_CONSTANT(DUPLICATE_SCRIPTS);
- BIND_CONSTANT( DUPLICATE_SIGNALS );
- BIND_CONSTANT( DUPLICATE_GROUPS );
- BIND_CONSTANT( DUPLICATE_SCRIPTS );
+ ADD_SIGNAL(MethodInfo("renamed"));
+ ADD_SIGNAL(MethodInfo("enter_tree"));
+ ADD_SIGNAL(MethodInfo("exit_tree"));
- ADD_SIGNAL( MethodInfo("renamed") );
- ADD_SIGNAL( MethodInfo("enter_tree") );
- ADD_SIGNAL( MethodInfo("exit_tree") );
-
-// ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/process" ),_SCS("set_process"),_SCS("is_processing") );
-// ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/fixed_process" ), _SCS("set_fixed_process"),_SCS("is_fixed_processing") );
+ // ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/process" ),_SCS("set_process"),_SCS("is_processing") );
+ // ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/fixed_process" ), _SCS("set_fixed_process"),_SCS("is_fixed_processing") );
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/input" ), _SCS("set_process_input"),_SCS("is_processing_input" ) );
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/unhandled_input" ), _SCS("set_process_unhandled_input"),_SCS("is_processing_unhandled_input" ) );
- ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "process/pause_mode",PROPERTY_HINT_ENUM,"Inherit,Stop,Process" ), _SCS("set_pause_mode"),_SCS("get_pause_mode" ) );
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "editor/display_folded",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ), _SCS("set_display_folded"),_SCS("is_displayed_folded" ) );
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "process/pause_mode", PROPERTY_HINT_ENUM, "Inherit,Stop,Process"), _SCS("set_pause_mode"), _SCS("get_pause_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "editor/display_folded", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("set_display_folded"), _SCS("is_displayed_folded"));
- BIND_VMETHOD( MethodInfo("_process",PropertyInfo(Variant::REAL,"delta")) );
- BIND_VMETHOD( MethodInfo("_fixed_process",PropertyInfo(Variant::REAL,"delta")) );
- BIND_VMETHOD( MethodInfo("_enter_tree") );
- BIND_VMETHOD( MethodInfo("_exit_tree") );
- BIND_VMETHOD( MethodInfo("_ready") );
- BIND_VMETHOD( MethodInfo("_input",PropertyInfo(Variant::INPUT_EVENT,"event")) );
- BIND_VMETHOD( MethodInfo("_unhandled_input",PropertyInfo(Variant::INPUT_EVENT,"event")) );
- BIND_VMETHOD( MethodInfo("_unhandled_key_input",PropertyInfo(Variant::INPUT_EVENT,"key_event")) );
+ BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
+ BIND_VMETHOD(MethodInfo("_fixed_process", PropertyInfo(Variant::REAL, "delta")));
+ BIND_VMETHOD(MethodInfo("_enter_tree"));
+ BIND_VMETHOD(MethodInfo("_exit_tree"));
+ BIND_VMETHOD(MethodInfo("_ready"));
+ BIND_VMETHOD(MethodInfo("_input", PropertyInfo(Variant::INPUT_EVENT, "event")));
+ BIND_VMETHOD(MethodInfo("_unhandled_input", PropertyInfo(Variant::INPUT_EVENT, "event")));
+ BIND_VMETHOD(MethodInfo("_unhandled_key_input", PropertyInfo(Variant::INPUT_EVENT, "key_event")));
//ObjectTypeDB::bind_method(_MD("get_child",&Node::get_child,PH("index")));
//ObjectTypeDB::bind_method(_MD("get_node",&Node::get_node,PH("path")));
}
-
Node::Node() {
- data.pos=-1;
- data.depth=-1;
- data.blocked=0;
- data.parent=NULL;
- data.tree=NULL;
- data.fixed_process=false;
- data.idle_process=false;
- data.inside_tree=false;
- data.ready_notified=false;
+ data.pos = -1;
+ data.depth = -1;
+ data.blocked = 0;
+ data.parent = NULL;
+ data.tree = NULL;
+ data.fixed_process = false;
+ data.idle_process = false;
+ data.inside_tree = false;
+ data.ready_notified = false;
- data.owner=NULL;
- data.OW=NULL;
- data.input=false;
- data.unhandled_input=false;
- data.unhandled_key_input=false;
- data.pause_mode=PAUSE_MODE_INHERIT;
- data.pause_owner=NULL;
- data.parent_owned=false;
- data.in_constructor=true;
- data.viewport=NULL;
- data.use_placeholder=false;
- data.display_folded=false;
+ data.owner = NULL;
+ data.OW = NULL;
+ data.input = false;
+ data.unhandled_input = false;
+ data.unhandled_key_input = false;
+ data.pause_mode = PAUSE_MODE_INHERIT;
+ data.pause_owner = NULL;
+ data.parent_owned = false;
+ data.in_constructor = true;
+ data.viewport = NULL;
+ data.use_placeholder = false;
+ data.display_folded = false;
}
Node::~Node() {
-
data.grouped.clear();
data.owned.clear();
data.children.clear();
-
ERR_FAIL_COND(data.parent);
ERR_FAIL_COND(data.children.size());
-
-
}
-
////////////////////////////////
diff --git a/scene/main/node.h b/scene/main/node.h
index cf5d65786..29b8d9bf2 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -29,23 +29,21 @@
#ifndef NODE_H
#define NODE_H
-#include "object.h"
-#include "path_db.h"
#include "map.h"
+#include "object.h"
#include "object_type_db.h"
-#include "script_language.h"
+#include "path_db.h"
#include "scene/main/scene_main_loop.h"
-
+#include "script_language.h"
class Viewport;
class SceneState;
class Node : public Object {
- OBJ_TYPE( Node, Object );
+ OBJ_TYPE(Node, Object);
OBJ_CATEGORY("Nodes");
public:
-
enum PauseMode {
PAUSE_MODE_INHERIT,
@@ -55,23 +53,22 @@ public:
enum DuplicateFlags {
- DUPLICATE_SIGNALS=1,
- DUPLICATE_GROUPS=2,
- DUPLICATE_SCRIPTS=4
+ DUPLICATE_SIGNALS = 1,
+ DUPLICATE_GROUPS = 2,
+ DUPLICATE_SCRIPTS = 4
};
struct Comparator {
- bool operator()(const Node* p_a, const Node* p_b) const { return p_b->is_greater_than(p_a); }
+ bool operator()(const Node *p_a, const Node *p_b) const { return p_b->is_greater_than(p_a); }
};
private:
-
struct GroupData {
bool persistent;
SceneTree::Group *group;
- GroupData() { persistent=false; }
+ GroupData() { persistent = false; }
};
struct Data {
@@ -80,11 +77,11 @@ private:
Ref<SceneState> instance_state;
Ref<SceneState> inherited_state;
- HashMap<NodePath,int> editable_instances;
+ HashMap<NodePath, int> editable_instances;
Node *parent;
Node *owner;
- Vector<Node*> children; // list of children
+ Vector<Node *> children; // list of children
int pos;
int depth;
int blocked; // safeguard that throws an error when attempting to modify the tree in a harmful way while being traversed.
@@ -98,10 +95,9 @@ private:
Viewport *viewport;
-
- Map< StringName, GroupData> grouped;
- List<Node*>::Element *OW; // owned element
- List<Node*> owned;
+ Map<StringName, GroupData> grouped;
+ List<Node *>::Element *OW; // owned element
+ List<Node *> owned;
PauseMode pause_mode;
Node *pause_owner;
@@ -122,16 +118,15 @@ private:
} data;
-
void _print_tree(const Node *p_node);
virtual bool _use_builtin_script() const { return true; }
- Node *_get_node(const NodePath& p_path) const;
- Node *_get_child_by_name(const StringName& p_name) const;
+ Node *_get_node(const NodePath &p_path) const;
+ Node *_get_child_by_name(const StringName &p_name) const;
- void _replace_connections_target(Node* p_new_target);
+ void _replace_connections_target(Node *p_new_target);
- void _validate_child_name(Node *p_name, bool p_force_human_readable=false);
+ void _validate_child_name(Node *p_name, bool p_force_human_readable = false);
void _propagate_reverse_notification(int p_notification);
void _propagate_deferred_notification(int p_notification, bool p_reverse);
@@ -140,23 +135,23 @@ private:
void _propagate_exit_tree();
void _propagate_validate_owner();
void _print_stray_nodes();
- void _propagate_pause_owner(Node*p_owner);
- Array _get_node_and_resource(const NodePath& p_path);
+ void _propagate_pause_owner(Node *p_owner);
+ Array _get_node_and_resource(const NodePath &p_path);
- void _duplicate_signals(const Node* p_original,Node* p_copy) const;
- void _duplicate_and_reown(Node* p_new_parent, const Map<Node*,Node*>& p_reown_map) const;
- Node *_duplicate(bool p_use_instancing,int p_flags) const;
+ void _duplicate_signals(const Node *p_original, Node *p_copy) const;
+ void _duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const;
+ Node *_duplicate(bool p_use_instancing, int p_flags) const;
Array _get_children() const;
Array _get_groups() const;
-friend class SceneTree;
+ friend class SceneTree;
void _set_tree(SceneTree *p_tree);
-protected:
+protected:
void _block() { data.blocked++; }
- void _unblock() { data.blocked--; }
+ void _unblock() { data.blocked--; }
void _notification(int p_notification);
@@ -165,55 +160,57 @@ protected:
virtual void move_child_notify(Node *p_child);
//void remove_and_delete_child(Node *p_child);
- void _propagate_replace_owner(Node *p_owner,Node* p_by_owner);
+ void _propagate_replace_owner(Node *p_owner, Node *p_by_owner);
static void _bind_methods();
-friend class SceneState;
+ friend class SceneState;
- void _add_child_nocheck(Node* p_child,const StringName& p_name);
- void _set_owner_nocheck(Node* p_owner);
- void _set_name_nocheck(const StringName& p_name);
+ void _add_child_nocheck(Node *p_child, const StringName &p_name);
+ void _set_owner_nocheck(Node *p_owner);
+ void _set_name_nocheck(const StringName &p_name);
public:
-
enum {
// you can make your own, but don't use the same numbers as other notifications in other nodes
- NOTIFICATION_ENTER_TREE=10,
- NOTIFICATION_EXIT_TREE =11,
- NOTIFICATION_MOVED_IN_PARENT =12,
- NOTIFICATION_READY=13,
+ NOTIFICATION_ENTER_TREE = 10,
+ NOTIFICATION_EXIT_TREE = 11,
+ NOTIFICATION_MOVED_IN_PARENT = 12,
+ NOTIFICATION_READY = 13,
//NOTIFICATION_PARENT_DECONFIGURED =15, - it's confusing, it's going away
- NOTIFICATION_PAUSED=14,
- NOTIFICATION_UNPAUSED=15,
+ NOTIFICATION_PAUSED = 14,
+ NOTIFICATION_UNPAUSED = 15,
NOTIFICATION_FIXED_PROCESS = 16,
NOTIFICATION_PROCESS = 17,
- NOTIFICATION_PARENTED=18,
- NOTIFICATION_UNPARENTED=19,
- NOTIFICATION_INSTANCED=20,
- NOTIFICATION_DRAG_BEGIN=21,
- NOTIFICATION_DRAG_END=22,
+ NOTIFICATION_PARENTED = 18,
+ NOTIFICATION_UNPARENTED = 19,
+ NOTIFICATION_INSTANCED = 20,
+ NOTIFICATION_DRAG_BEGIN = 21,
+ NOTIFICATION_DRAG_END = 22,
};
/* NODE/TREE */
StringName get_name() const;
- void set_name(const String& p_name);
+ void set_name(const String &p_name);
- void add_child(Node *p_child,bool p_legible_unique_name=false);
- void add_child_below_node(Node *p_node, Node *p_child, bool p_legible_unique_name=false);
+ void add_child(Node *p_child, bool p_legible_unique_name = false);
+ void add_child_below_node(Node *p_node, Node *p_child, bool p_legible_unique_name = false);
void remove_child(Node *p_child);
int get_child_count() const;
Node *get_child(int p_index) const;
- bool has_node(const NodePath& p_path) const;
- Node *get_node(const NodePath& p_path) const;
- Node* find_node(const String& p_mask,bool p_recursive=true,bool p_owned=true) const;
- bool has_node_and_resource(const NodePath& p_path) const;
- Node *get_node_and_resource(const NodePath& p_path,RES& r_res) const;
+ bool has_node(const NodePath &p_path) const;
+ Node *get_node(const NodePath &p_path) const;
+ Node *find_node(const String &p_mask, bool p_recursive = true, bool p_owned = true) const;
+ bool has_node_and_resource(const NodePath &p_path) const;
+ Node *get_node_and_resource(const NodePath &p_path, RES &r_res) const;
Node *get_parent() const;
- _FORCE_INLINE_ SceneTree *get_tree() const { ERR_FAIL_COND_V( !data.tree, NULL ); return data.tree; }
+ _FORCE_INLINE_ SceneTree *get_tree() const {
+ ERR_FAIL_COND_V(!data.tree, NULL);
+ return data.tree;
+ }
_FORCE_INLINE_ bool is_inside_tree() const { return data.inside_tree; }
@@ -222,11 +219,11 @@ public:
NodePath get_path() const;
NodePath get_path_to(const Node *p_node) const;
- Node* find_common_parent_with(const Node *p_node) const;
+ Node *find_common_parent_with(const Node *p_node) const;
- void add_to_group(const StringName& p_identifier,bool p_persistent=false);
- void remove_from_group(const StringName& p_identifier);
- bool is_in_group(const StringName& p_identifier) const;
+ void add_to_group(const StringName &p_identifier, bool p_persistent = false);
+ void remove_from_group(const StringName &p_identifier);
+ bool is_in_group(const StringName &p_identifier) const;
struct GroupInfo {
@@ -237,27 +234,25 @@ public:
void get_groups(List<GroupInfo> *p_groups) const;
bool has_persistent_groups() const;
- void move_child(Node *p_child,int p_pos);
+ void move_child(Node *p_child, int p_pos);
void raise();
void set_owner(Node *p_owner);
Node *get_owner() const;
- void get_owned_by(Node *p_by,List<Node*> *p_owned);
-
+ void get_owned_by(Node *p_by, List<Node *> *p_owned);
void remove_and_skip();
int get_index() const;
void print_tree();
- void set_filename(const String& p_filename);
+ void set_filename(const String &p_filename);
String get_filename() const;
- void set_editable_instance(Node* p_node,bool p_editable);
- bool is_editable_instance(Node* p_node) const;
- void set_editable_instances(const HashMap<NodePath,int>& p_editable_instances);
- HashMap<NodePath,int> get_editable_instances() const;
-
+ void set_editable_instance(Node *p_node, bool p_editable);
+ bool is_editable_instance(Node *p_node) const;
+ void set_editable_instances(const HashMap<NodePath, int> &p_editable_instances);
+ HashMap<NodePath, int> get_editable_instances() const;
/* NOTIFICATIONS */
@@ -272,7 +267,6 @@ public:
float get_process_delta_time() const;
bool is_processing() const;
-
void set_process_input(bool p_enable);
bool is_processing_input() const;
@@ -284,16 +278,16 @@ public:
int get_position_in_parent() const;
- Node *duplicate(bool p_use_instancing=false,int p_flags=DUPLICATE_GROUPS|DUPLICATE_SIGNALS|DUPLICATE_SCRIPTS) const;
- Node *duplicate_and_reown(const Map<Node*,Node*>& p_reown_map) const;
+ Node *duplicate(bool p_use_instancing = false, int p_flags = DUPLICATE_GROUPS | DUPLICATE_SIGNALS | DUPLICATE_SCRIPTS) const;
+ Node *duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const;
//Node *clone_tree() const;
// used by editors, to save what has changed only
- void set_scene_instance_state(const Ref<SceneState>& p_state);
+ void set_scene_instance_state(const Ref<SceneState> &p_state);
Ref<SceneState> get_scene_instance_state() const;
- void set_scene_inherited_state(const Ref<SceneState>& p_state);
+ void set_scene_inherited_state(const Ref<SceneState> &p_state);
Ref<SceneState> get_scene_inherited_state() const;
void set_scene_instance_load_placeholder(bool p_enable);
@@ -301,7 +295,7 @@ public:
static Vector<Variant> make_binds(VARIANT_ARG_LIST);
- void replace_by(Node* p_node,bool p_keep_data=false);
+ void replace_by(Node *p_node, bool p_keep_data = false);
void set_pause_mode(PauseMode p_mode);
PauseMode get_pause_mode() const;
@@ -309,24 +303,24 @@ public:
static void print_stray_nodes();
- String validate_child_name(const String& p_name) const;
+ String validate_child_name(const String &p_name) const;
void queue_delete();
-//shitty hacks for speed
+ //shitty hacks for speed
static void set_human_readable_collision_renaming(bool p_enabled);
static void init_node_hrcr();
- void force_parent_owned() { data.parent_owned=true; } //hack to avoid duplicate nodes
+ void force_parent_owned() { data.parent_owned = true; } //hack to avoid duplicate nodes
#ifdef TOOLS_ENABLED
- void set_import_path(const NodePath& p_import_path); //path used when imported, used by scene editors to keep tracking
+ void set_import_path(const NodePath &p_import_path); //path used when imported, used by scene editors to keep tracking
NodePath get_import_path() const;
#endif
bool is_owned_by_parent() const;
- void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
+ void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
void clear_internal_tree_resource_paths();
@@ -344,8 +338,6 @@ public:
~Node();
};
-
-typedef Set<Node*,Node::Comparator> NodeSet;
-
+typedef Set<Node *, Node::Comparator> NodeSet;
#endif
diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp
index 49bf6106b..ac9ab68e3 100644
--- a/scene/main/resource_preloader.cpp
+++ b/scene/main/resource_preloader.cpp
@@ -28,26 +28,25 @@
/*************************************************************************/
#include "resource_preloader.h"
-void ResourcePreloader::_set_resources(const Array& p_data) {
+void ResourcePreloader::_set_resources(const Array &p_data) {
resources.clear();
- ERR_FAIL_COND(p_data.size()!=2);
- DVector<String> names=p_data[0];
- Array resdata=p_data[1];
+ ERR_FAIL_COND(p_data.size() != 2);
+ DVector<String> names = p_data[0];
+ Array resdata = p_data[1];
- ERR_FAIL_COND(names.size()!=resdata.size());
+ ERR_FAIL_COND(names.size() != resdata.size());
- for(int i=0;i<resdata.size();i++) {
+ for (int i = 0; i < resdata.size(); i++) {
- String name=names[i];
+ String name = names[i];
RES resource = resdata[i];
- ERR_CONTINUE( !resource.is_valid() );
- resources[name]=resource;
+ ERR_CONTINUE(!resource.is_valid());
+ resources[name] = resource;
//add_resource(name,resource);
}
-
}
Array ResourcePreloader::_get_resources() const {
@@ -59,15 +58,15 @@ Array ResourcePreloader::_get_resources() const {
Set<String> sorted_names;
- for(Map<StringName,RES >::Element *E=resources.front();E;E=E->next()) {
+ for (Map<StringName, RES>::Element *E = resources.front(); E; E = E->next()) {
sorted_names.insert(E->key());
}
- int i=0;
- for(Set<String>::Element *E=sorted_names.front();E;E=E->next()) {
+ int i = 0;
+ for (Set<String>::Element *E = sorted_names.front(); E; E = E->next()) {
- names.set(i,E->get());
- arr[i]=resources[E->get()];
+ names.set(i, E->get());
+ arr[i] = resources[E->get()];
i++;
}
@@ -77,65 +76,54 @@ Array ResourcePreloader::_get_resources() const {
return res;
}
-
-void ResourcePreloader::add_resource(const StringName& p_name,const RES& p_resource) {
-
+void ResourcePreloader::add_resource(const StringName &p_name, const RES &p_resource) {
ERR_FAIL_COND(p_resource.is_null());
if (resources.has(p_name)) {
-
StringName new_name;
- int idx=2;
+ int idx = 2;
- while(true) {
+ while (true) {
- new_name=p_name.operator String()+" "+itos(idx);
+ new_name = p_name.operator String() + " " + itos(idx);
if (resources.has(new_name)) {
idx++;
continue;
}
break;
-
}
- add_resource(new_name,p_resource);
+ add_resource(new_name, p_resource);
} else {
- resources[p_name]=p_resource;
+ resources[p_name] = p_resource;
}
-
-
-
}
-void ResourcePreloader::remove_resource(const StringName& p_name) {
+void ResourcePreloader::remove_resource(const StringName &p_name) {
- ERR_FAIL_COND( !resources.has(p_name) );
+ ERR_FAIL_COND(!resources.has(p_name));
resources.erase(p_name);
-
}
-void ResourcePreloader::rename_resource(const StringName& p_from_name,const StringName& p_to_name) {
+void ResourcePreloader::rename_resource(const StringName &p_from_name, const StringName &p_to_name) {
- ERR_FAIL_COND( !resources.has(p_from_name) );
+ ERR_FAIL_COND(!resources.has(p_from_name));
RES res = resources[p_from_name];
resources.erase(p_from_name);
- add_resource(p_to_name,res);
-
-
-
+ add_resource(p_to_name, res);
}
-bool ResourcePreloader::has_resource(const StringName& p_name) const {
+bool ResourcePreloader::has_resource(const StringName &p_name) const {
return resources.has(p_name);
}
-RES ResourcePreloader::get_resource(const StringName& p_name) const {
+RES ResourcePreloader::get_resource(const StringName &p_name) const {
- ERR_FAIL_COND_V(!resources.has(p_name),RES());
+ ERR_FAIL_COND_V(!resources.has(p_name), RES());
return resources[p_name];
}
@@ -143,9 +131,9 @@ DVector<String> ResourcePreloader::_get_resource_list() const {
DVector<String> res;
res.resize(resources.size());
- int i=0;
- for(Map<StringName,RES >::Element *E=resources.front();E;E=E->next(),i++) {
- res.set(i,E->key());
+ int i = 0;
+ for (Map<StringName, RES>::Element *E = resources.front(); E; E = E->next(), i++) {
+ res.set(i, E->key());
}
return res;
@@ -153,31 +141,26 @@ DVector<String> ResourcePreloader::_get_resource_list() const {
void ResourcePreloader::get_resource_list(List<StringName> *p_list) {
- for(Map<StringName,RES >::Element *E=resources.front();E;E=E->next()) {
+ for (Map<StringName, RES>::Element *E = resources.front(); E; E = E->next()) {
p_list->push_back(E->key());
}
-
}
-
void ResourcePreloader::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_set_resources"),&ResourcePreloader::_set_resources);
- ObjectTypeDB::bind_method(_MD("_get_resources"),&ResourcePreloader::_get_resources);
-
- ObjectTypeDB::bind_method(_MD("add_resource","name","resource"),&ResourcePreloader::add_resource);
- ObjectTypeDB::bind_method(_MD("remove_resource","name"),&ResourcePreloader::remove_resource);
- ObjectTypeDB::bind_method(_MD("rename_resource","name","newname"),&ResourcePreloader::rename_resource);
- ObjectTypeDB::bind_method(_MD("has_resource","name"),&ResourcePreloader::has_resource);
- ObjectTypeDB::bind_method(_MD("get_resource","name"),&ResourcePreloader::get_resource);
- ObjectTypeDB::bind_method(_MD("get_resource_list"),&ResourcePreloader::_get_resource_list);
-
+ ObjectTypeDB::bind_method(_MD("_set_resources"), &ResourcePreloader::_set_resources);
+ ObjectTypeDB::bind_method(_MD("_get_resources"), &ResourcePreloader::_get_resources);
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"resources",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_resources"), _SCS("_get_resources"));
+ ObjectTypeDB::bind_method(_MD("add_resource", "name", "resource"), &ResourcePreloader::add_resource);
+ ObjectTypeDB::bind_method(_MD("remove_resource", "name"), &ResourcePreloader::remove_resource);
+ ObjectTypeDB::bind_method(_MD("rename_resource", "name", "newname"), &ResourcePreloader::rename_resource);
+ ObjectTypeDB::bind_method(_MD("has_resource", "name"), &ResourcePreloader::has_resource);
+ ObjectTypeDB::bind_method(_MD("get_resource", "name"), &ResourcePreloader::get_resource);
+ ObjectTypeDB::bind_method(_MD("get_resource_list"), &ResourcePreloader::_get_resource_list);
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "resources", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_resources"), _SCS("_get_resources"));
}
-ResourcePreloader::ResourcePreloader()
-{
+ResourcePreloader::ResourcePreloader() {
}
diff --git a/scene/main/resource_preloader.h b/scene/main/resource_preloader.h
index f2d1461fb..7d0916a71 100644
--- a/scene/main/resource_preloader.h
+++ b/scene/main/resource_preloader.h
@@ -29,35 +29,30 @@
#ifndef RESOURCE_PRELOADER_H
#define RESOURCE_PRELOADER_H
-
#include "scene/main/node.h"
class ResourcePreloader : public Node {
- OBJ_TYPE(ResourcePreloader,Node);
-
- Map<StringName,RES > resources;
+ OBJ_TYPE(ResourcePreloader, Node);
+ Map<StringName, RES> resources;
- void _set_resources(const Array& p_data);
+ void _set_resources(const Array &p_data);
Array _get_resources() const;
DVector<String> _get_resource_list() const;
protected:
-
static void _bind_methods();
public:
-
- void add_resource(const StringName& p_name,const RES& p_resource);
- void remove_resource(const StringName& p_name);
- void rename_resource(const StringName& p_from_name,const StringName& p_to_name);
- bool has_resource(const StringName& p_name) const;
- RES get_resource(const StringName& p_name) const;
+ void add_resource(const StringName &p_name, const RES &p_resource);
+ void remove_resource(const StringName &p_name);
+ void rename_resource(const StringName &p_from_name, const StringName &p_to_name);
+ bool has_resource(const StringName &p_name) const;
+ RES get_resource(const StringName &p_name) const;
void get_resource_list(List<StringName> *p_list);
-
ResourcePreloader();
};
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index b0b586cfa..79a6b79f9 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -28,22 +28,22 @@
/*************************************************************************/
#include "scene_main_loop.h"
-#include "print_string.h"
-#include "os/os.h"
+#include "globals.h"
+#include "io/resource_loader.h"
#include "message_queue.h"
#include "node.h"
-#include "globals.h"
-#include <stdio.h>
#include "os/keyboard.h"
-#include "servers/spatial_sound_2d_server.h"
+#include "os/os.h"
+#include "print_string.h"
+#include "scene/resources/material.h"
+#include "scene/resources/mesh.h"
+#include "scene/resources/packed_scene.h"
+#include "scene/scene_string_names.h"
#include "servers/physics_2d_server.h"
#include "servers/physics_server.h"
-#include "scene/scene_string_names.h"
-#include "io/resource_loader.h"
+#include "servers/spatial_sound_2d_server.h"
#include "viewport.h"
-#include "scene/resources/packed_scene.h"
-#include "scene/resources/material.h"
-#include "scene/resources/mesh.h"
+#include <stdio.h>
void SceneTree::tree_changed() {
@@ -53,40 +53,36 @@ void SceneTree::tree_changed() {
void SceneTree::node_removed(Node *p_node) {
- if (current_scene==p_node) {
- current_scene=NULL;
+ if (current_scene == p_node) {
+ current_scene = NULL;
}
- emit_signal(node_removed_name,p_node);
- if (call_lock>0)
+ emit_signal(node_removed_name, p_node);
+ if (call_lock > 0)
call_skip.insert(p_node);
-
-
}
+SceneTree::Group *SceneTree::add_to_group(const StringName &p_group, Node *p_node) {
-SceneTree::Group *SceneTree::add_to_group(const StringName& p_group, Node *p_node) {
-
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E) {
- E=group_map.insert(p_group,Group());
+ E = group_map.insert(p_group, Group());
}
- if (E->get().nodes.find(p_node)!=-1) {
- ERR_EXPLAIN("Already in group: "+p_group);
+ if (E->get().nodes.find(p_node) != -1) {
+ ERR_EXPLAIN("Already in group: " + p_group);
ERR_FAIL_V(&E->get());
}
E->get().nodes.push_back(p_node);
//E->get().last_tree_version=0;
- E->get().changed=true;
+ E->get().changed = true;
return &E->get();
}
-void SceneTree::remove_from_group(const StringName& p_group, Node *p_node) {
+void SceneTree::remove_from_group(const StringName &p_group, Node *p_node) {
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
ERR_FAIL_COND(!E);
-
E->get().nodes.erase(p_node);
if (E->get().nodes.empty())
group_map.erase(E);
@@ -94,38 +90,38 @@ void SceneTree::remove_from_group(const StringName& p_group, Node *p_node) {
void SceneTree::_flush_transform_notifications() {
- SelfList<Node>* n = xform_change_list.first();
- while(n) {
+ SelfList<Node> *n = xform_change_list.first();
+ while (n) {
- Node *node=n->self();
- SelfList<Node>* nx = n->next();
+ Node *node = n->self();
+ SelfList<Node> *nx = n->next();
xform_change_list.remove(n);
- n=nx;
+ n = nx;
node->notification(NOTIFICATION_TRANSFORM_CHANGED);
}
}
void SceneTree::_flush_ugc() {
- ugc_locked=true;
+ ugc_locked = true;
while (unique_group_calls.size()) {
- Map<UGCall,Vector<Variant> >::Element *E=unique_group_calls.front();
+ Map<UGCall, Vector<Variant> >::Element *E = unique_group_calls.front();
Variant v[VARIANT_ARG_MAX];
- for(int i=0;i<E->get().size();i++)
- v[i]=E->get()[i];
+ for (int i = 0; i < E->get().size(); i++)
+ v[i] = E->get()[i];
- call_group(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]);
+ call_group(GROUP_CALL_REALTIME, E->key().group, E->key().call, v[0], v[1], v[2], v[3], v[4]);
unique_group_calls.erase(E);
}
- ugc_locked=false;
+ ugc_locked = false;
}
-void SceneTree::_update_group_order(Group& g) {
+void SceneTree::_update_group_order(Group &g) {
if (!g.changed)
return;
@@ -133,32 +129,29 @@ void SceneTree::_update_group_order(Group& g) {
return;
Node **nodes = &g.nodes[0];
- int node_count=g.nodes.size();
-
- SortArray<Node*,Node::Comparator> node_sort;
- node_sort.sort(nodes,node_count);
- g.changed=false;
+ int node_count = g.nodes.size();
+ SortArray<Node *, Node::Comparator> node_sort;
+ node_sort.sort(nodes, node_count);
+ g.changed = false;
}
+void SceneTree::call_group(uint32_t p_call_flags, const StringName &p_group, const StringName &p_function, VARIANT_ARG_DECLARE) {
-void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) {
-
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
return;
- Group &g=E->get();
+ Group &g = E->get();
if (g.nodes.empty())
return;
-
- if (p_call_flags&GROUP_CALL_UNIQUE && !(p_call_flags&GROUP_CALL_REALTIME)) {
+ if (p_call_flags & GROUP_CALL_UNIQUE && !(p_call_flags & GROUP_CALL_REALTIME)) {
ERR_FAIL_COND(ugc_locked);
UGCall ug;
- ug.call=p_function;
- ug.group=p_group;
+ ug.call = p_function;
+ ug.group = p_group;
if (unique_group_calls.has(ug))
return;
@@ -166,193 +159,186 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
VARIANT_ARGPTRS;
Vector<Variant> args;
- for(int i=0;i<VARIANT_ARG_MAX;i++) {
- if (argptr[i]->get_type()==Variant::NIL)
+ for (int i = 0; i < VARIANT_ARG_MAX; i++) {
+ if (argptr[i]->get_type() == Variant::NIL)
break;
args.push_back(*argptr[i]);
}
- unique_group_calls[ug]=args;
+ unique_group_calls[ug] = args;
return;
}
_update_group_order(g);
- Vector<Node*> nodes_copy = g.nodes;
+ Vector<Node *> nodes_copy = g.nodes;
Node **nodes = &nodes_copy[0];
- int node_count=nodes_copy.size();
+ int node_count = nodes_copy.size();
call_lock++;
- if (p_call_flags&GROUP_CALL_REVERSE) {
+ if (p_call_flags & GROUP_CALL_REVERSE) {
- for(int i=node_count-1;i>=0;i--) {
+ for (int i = node_count - 1; i >= 0; i--) {
if (call_lock && call_skip.has(nodes[i]))
continue;
- if (p_call_flags&GROUP_CALL_REALTIME) {
- if (p_call_flags&GROUP_CALL_MULIILEVEL)
- nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS);
+ if (p_call_flags & GROUP_CALL_REALTIME) {
+ if (p_call_flags & GROUP_CALL_MULIILEVEL)
+ nodes[i]->call_multilevel(p_function, VARIANT_ARG_PASS);
else
- nodes[i]->call(p_function,VARIANT_ARG_PASS);
+ nodes[i]->call(p_function, VARIANT_ARG_PASS);
} else
- MessageQueue::get_singleton()->push_call(nodes[i],p_function,VARIANT_ARG_PASS);
-
+ MessageQueue::get_singleton()->push_call(nodes[i], p_function, VARIANT_ARG_PASS);
}
} else {
- for(int i=0;i<node_count;i++) {
+ for (int i = 0; i < node_count; i++) {
if (call_lock && call_skip.has(nodes[i]))
continue;
- if (p_call_flags&GROUP_CALL_REALTIME) {
- if (p_call_flags&GROUP_CALL_MULIILEVEL)
- nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS);
+ if (p_call_flags & GROUP_CALL_REALTIME) {
+ if (p_call_flags & GROUP_CALL_MULIILEVEL)
+ nodes[i]->call_multilevel(p_function, VARIANT_ARG_PASS);
else
- nodes[i]->call(p_function,VARIANT_ARG_PASS);
+ nodes[i]->call(p_function, VARIANT_ARG_PASS);
} else
- MessageQueue::get_singleton()->push_call(nodes[i],p_function,VARIANT_ARG_PASS);
+ MessageQueue::get_singleton()->push_call(nodes[i], p_function, VARIANT_ARG_PASS);
}
-
}
call_lock--;
- if (call_lock==0)
+ if (call_lock == 0)
call_skip.clear();
}
-void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int p_notification) {
+void SceneTree::notify_group(uint32_t p_call_flags, const StringName &p_group, int p_notification) {
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
return;
- Group &g=E->get();
+ Group &g = E->get();
if (g.nodes.empty())
return;
_update_group_order(g);
- Vector<Node*> nodes_copy = g.nodes;
+ Vector<Node *> nodes_copy = g.nodes;
Node **nodes = &nodes_copy[0];
- int node_count=nodes_copy.size();
+ int node_count = nodes_copy.size();
call_lock++;
- if (p_call_flags&GROUP_CALL_REVERSE) {
+ if (p_call_flags & GROUP_CALL_REVERSE) {
- for(int i=node_count-1;i>=0;i--) {
+ for (int i = node_count - 1; i >= 0; i--) {
if (call_lock && call_skip.has(nodes[i]))
continue;
- if (p_call_flags&GROUP_CALL_REALTIME)
+ if (p_call_flags & GROUP_CALL_REALTIME)
nodes[i]->notification(p_notification);
else
- MessageQueue::get_singleton()->push_notification(nodes[i],p_notification);
+ MessageQueue::get_singleton()->push_notification(nodes[i], p_notification);
}
} else {
- for(int i=0;i<node_count;i++) {
+ for (int i = 0; i < node_count; i++) {
if (call_lock && call_skip.has(nodes[i]))
continue;
- if (p_call_flags&GROUP_CALL_REALTIME)
+ if (p_call_flags & GROUP_CALL_REALTIME)
nodes[i]->notification(p_notification);
else
- MessageQueue::get_singleton()->push_notification(nodes[i],p_notification);
+ MessageQueue::get_singleton()->push_notification(nodes[i], p_notification);
}
-
}
call_lock--;
- if (call_lock==0)
+ if (call_lock == 0)
call_skip.clear();
}
-void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) {
+void SceneTree::set_group(uint32_t p_call_flags, const StringName &p_group, const String &p_name, const Variant &p_value) {
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
return;
- Group &g=E->get();
+ Group &g = E->get();
if (g.nodes.empty())
return;
_update_group_order(g);
- Vector<Node*> nodes_copy = g.nodes;
+ Vector<Node *> nodes_copy = g.nodes;
Node **nodes = &nodes_copy[0];
- int node_count=nodes_copy.size();
+ int node_count = nodes_copy.size();
call_lock++;
- if (p_call_flags&GROUP_CALL_REVERSE) {
+ if (p_call_flags & GROUP_CALL_REVERSE) {
- for(int i=node_count-1;i>=0;i--) {
+ for (int i = node_count - 1; i >= 0; i--) {
if (call_lock && call_skip.has(nodes[i]))
continue;
- if (p_call_flags&GROUP_CALL_REALTIME)
- nodes[i]->set(p_name,p_value);
+ if (p_call_flags & GROUP_CALL_REALTIME)
+ nodes[i]->set(p_name, p_value);
else
- MessageQueue::get_singleton()->push_set(nodes[i],p_name,p_value);
+ MessageQueue::get_singleton()->push_set(nodes[i], p_name, p_value);
}
} else {
- for(int i=0;i<node_count;i++) {
+ for (int i = 0; i < node_count; i++) {
if (call_lock && call_skip.has(nodes[i]))
continue;
- if (p_call_flags&GROUP_CALL_REALTIME)
- nodes[i]->set(p_name,p_value);
+ if (p_call_flags & GROUP_CALL_REALTIME)
+ nodes[i]->set(p_name, p_value);
else
- MessageQueue::get_singleton()->push_set(nodes[i],p_name,p_value);
+ MessageQueue::get_singleton()->push_set(nodes[i], p_name, p_value);
}
-
}
call_lock--;
- if (call_lock==0)
+ if (call_lock == 0)
call_skip.clear();
}
void SceneTree::set_input_as_handled() {
- input_handled=true;
+ input_handled = true;
}
-void SceneTree::input_text( const String& p_text ) {
+void SceneTree::input_text(const String &p_text) {
root_lock++;
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check
+ call_group(GROUP_CALL_REALTIME, "_viewports", "_vp_input_text", p_text); //special one for GUI, as controls use their own process check
root_lock--;
-
}
-void SceneTree::input_event( const InputEvent& p_event ) {
+void SceneTree::input_event(const InputEvent &p_event) {
-
- if (is_editor_hint() && (p_event.type==InputEvent::JOYSTICK_MOTION || p_event.type==InputEvent::JOYSTICK_BUTTON))
+ if (is_editor_hint() && (p_event.type == InputEvent::JOYSTICK_MOTION || p_event.type == InputEvent::JOYSTICK_BUTTON))
return; //avoid joy input on editor
root_lock++;
//last_id=p_event.ID;
- input_handled=false;
-
+ input_handled = false;
InputEvent ev = p_event;
- ev.ID=++last_id; //this should work better
+ ev.ID = ++last_id; //this should work better
#if 0
switch(ev.type) {
@@ -428,10 +414,10 @@ void SceneTree::input_event( const InputEvent& p_event ) {
//transform for the rest
#else
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check
+ call_group(GROUP_CALL_REALTIME, "_viewports", "_vp_input", ev); //special one for GUI, as controls use their own process check
#endif
- if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote() && ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F8) {
+ if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote() && ev.type == InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode == KEY_F8) {
ScriptDebugger::get_singleton()->request_quit();
}
@@ -453,39 +439,34 @@ void SceneTree::input_event( const InputEvent& p_event ) {
}
#else
- call_group(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check
+ call_group(GROUP_CALL_REALTIME, "_viewports", "_vp_unhandled_input", ev); //special one for GUI, as controls use their own process check
#endif
- input_handled=true;
+ input_handled = true;
_flush_ugc();
root_lock--;
MessageQueue::get_singleton()->flush(); //small little hack
} else {
- input_handled=true;
+ input_handled = true;
root_lock--;
-
}
-
}
void SceneTree::init() {
//_quit=false;
- accept_quit=true;
- initialized=true;
- input_handled=false;
-
+ accept_quit = true;
+ initialized = true;
+ input_handled = false;
- pause=false;
+ pause = false;
root->_set_tree(this);
MainLoop::init();
-
}
bool SceneTree::iteration(float p_time) {
-
root_lock++;
current_frame++;
@@ -493,14 +474,14 @@ bool SceneTree::iteration(float p_time) {
_flush_transform_notifications();
MainLoop::iteration(p_time);
- fixed_process_time=p_time;
+ fixed_process_time = p_time;
emit_signal("fixed_frame");
- _notify_group_pause("fixed_process",Node::NOTIFICATION_FIXED_PROCESS);
+ _notify_group_pause("fixed_process", Node::NOTIFICATION_FIXED_PROCESS);
_flush_ugc();
_flush_transform_notifications();
- call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds");
+ call_group(GROUP_CALL_REALTIME, "_viewports", "update_worlds");
root_lock--;
_flush_delete_queue();
@@ -508,40 +489,36 @@ bool SceneTree::iteration(float p_time) {
return _quit;
}
-bool SceneTree::idle(float p_time){
+bool SceneTree::idle(float p_time) {
-
-// print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
-// print_line("node count: "+itos(get_node_count()));
-// print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED)));
+ // print_line("ram: "+itos(OS::get_singleton()->get_static_memory_usage())+" sram: "+itos(OS::get_singleton()->get_dynamic_memory_usage()));
+ // print_line("node count: "+itos(get_node_count()));
+ // print_line("TEXTURE RAM: "+itos(VS::get_singleton()->get_render_info(VS::INFO_TEXTURE_MEM_USED)));
root_lock++;
MainLoop::idle(p_time);
- idle_process_time=p_time;
+ idle_process_time = p_time;
emit_signal("idle_frame");
_flush_transform_notifications();
- _notify_group_pause("idle_process",Node::NOTIFICATION_PROCESS);
-
- Size2 win_size=Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height );
- if(win_size!=last_screen_size) {
+ _notify_group_pause("idle_process", Node::NOTIFICATION_PROCESS);
+ Size2 win_size = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height);
+ if (win_size != last_screen_size) {
- last_screen_size=win_size;
+ last_screen_size = win_size;
_update_root_rect();
-
emit_signal("screen_resized");
-
}
_flush_ugc();
_flush_transform_notifications(); //transforms after world update, to avoid unnecesary enter/exit notifications
- call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds");
+ call_group(GROUP_CALL_REALTIME, "_viewports", "update_worlds");
root_lock--;
@@ -556,7 +533,7 @@ void SceneTree::finish() {
_flush_ugc();
- initialized=false;
+ initialized = false;
MainLoop::finish();
@@ -564,27 +541,15 @@ void SceneTree::finish() {
root->_set_tree(NULL);
memdelete(root); //delete root
}
-
-
-
-
-
-
-
-
-
}
-
void SceneTree::quit() {
- _quit=true;
+ _quit = true;
}
void SceneTree::_notification(int p_notification) {
-
-
switch (p_notification) {
case NOTIFICATION_WM_QUIT_REQUEST: {
@@ -592,7 +557,7 @@ void SceneTree::_notification(int p_notification) {
get_root()->propagate_notification(p_notification);
if (accept_quit) {
- _quit=true;
+ _quit = true;
break;
}
} break;
@@ -604,7 +569,7 @@ void SceneTree::_notification(int p_notification) {
} break;
case NOTIFICATION_WM_UNFOCUS_REQUEST: {
- notify_group(GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST);
+ notify_group(GROUP_CALL_REALTIME | GROUP_CALL_MULIILEVEL, "input", NOTIFICATION_WM_UNFOCUS_REQUEST);
} break;
@@ -613,18 +578,17 @@ void SceneTree::_notification(int p_notification) {
};
};
-
void SceneTree::set_auto_accept_quit(bool p_enable) {
- accept_quit=p_enable;
+ accept_quit = p_enable;
}
void SceneTree::set_editor_hint(bool p_enabled) {
- editor_hint=p_enabled;
+ editor_hint = p_enabled;
}
-bool SceneTree::is_node_being_edited(const Node* p_node) const {
+bool SceneTree::is_node_being_edited(const Node *p_node) const {
#ifdef TOOLS_ENABLED
return editor_hint && edited_scene_root && edited_scene_root->is_a_parent_of(p_node);
#else
@@ -639,7 +603,7 @@ bool SceneTree::is_editor_hint() const {
void SceneTree::set_debug_collisions_hint(bool p_enabled) {
- debug_collisions_hint=p_enabled;
+ debug_collisions_hint = p_enabled;
}
bool SceneTree::is_debugging_collisions_hint() const {
@@ -649,7 +613,7 @@ bool SceneTree::is_debugging_collisions_hint() const {
void SceneTree::set_debug_navigation_hint(bool p_enabled) {
- debug_navigation_hint=p_enabled;
+ debug_navigation_hint = p_enabled;
}
bool SceneTree::is_debugging_navigation_hint() const {
@@ -657,9 +621,9 @@ bool SceneTree::is_debugging_navigation_hint() const {
return debug_navigation_hint;
}
-void SceneTree::set_debug_collisions_color(const Color& p_color) {
+void SceneTree::set_debug_collisions_color(const Color &p_color) {
- debug_collisions_color=p_color;
+ debug_collisions_color = p_color;
}
Color SceneTree::get_debug_collisions_color() const {
@@ -667,9 +631,9 @@ Color SceneTree::get_debug_collisions_color() const {
return debug_collisions_color;
}
-void SceneTree::set_debug_collision_contact_color(const Color& p_color) {
+void SceneTree::set_debug_collision_contact_color(const Color &p_color) {
- debug_collision_contact_color=p_color;
+ debug_collision_contact_color = p_color;
}
Color SceneTree::get_debug_collision_contact_color() const {
@@ -677,9 +641,9 @@ Color SceneTree::get_debug_collision_contact_color() const {
return debug_collision_contact_color;
}
-void SceneTree::set_debug_navigation_color(const Color& p_color) {
+void SceneTree::set_debug_navigation_color(const Color &p_color) {
- debug_navigation_color=p_color;
+ debug_navigation_color = p_color;
}
Color SceneTree::get_debug_navigation_color() const {
@@ -687,9 +651,9 @@ Color SceneTree::get_debug_navigation_color() const {
return debug_navigation_color;
}
-void SceneTree::set_debug_navigation_disabled_color(const Color& p_color) {
+void SceneTree::set_debug_navigation_disabled_color(const Color &p_color) {
- debug_navigation_disabled_color=p_color;
+ debug_navigation_disabled_color = p_color;
}
Color SceneTree::get_debug_navigation_disabled_color() const {
@@ -702,50 +666,47 @@ Ref<Material> SceneTree::get_debug_navigation_material() {
if (navigation_material.is_valid())
return navigation_material;
- Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
+ Ref<FixedMaterial> line_material = Ref<FixedMaterial>(memnew(FixedMaterial));
line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_color());
+ line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE, get_debug_navigation_color());
- navigation_material=line_material;
+ navigation_material = line_material;
return navigation_material;
-
}
-Ref<Material> SceneTree::get_debug_navigation_disabled_material(){
+Ref<Material> SceneTree::get_debug_navigation_disabled_material() {
if (navigation_disabled_material.is_valid())
return navigation_disabled_material;
- Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
+ Ref<FixedMaterial> line_material = Ref<FixedMaterial>(memnew(FixedMaterial));
line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_disabled_color());
+ line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE, get_debug_navigation_disabled_color());
- navigation_disabled_material=line_material;
+ navigation_disabled_material = line_material;
return navigation_disabled_material;
-
}
Ref<Material> SceneTree::get_debug_collision_material() {
if (collision_material.is_valid())
return collision_material;
-
- Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
+ Ref<FixedMaterial> line_material = Ref<FixedMaterial>(memnew(FixedMaterial));
line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collisions_color());
+ line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE, get_debug_collisions_color());
- collision_material=line_material;
+ collision_material = line_material;
return collision_material;
}
@@ -755,62 +716,58 @@ Ref<Mesh> SceneTree::get_debug_contact_mesh() {
if (debug_contact_mesh.is_valid())
return debug_contact_mesh;
- debug_contact_mesh = Ref<Mesh>( memnew( Mesh ) );
+ debug_contact_mesh = Ref<Mesh>(memnew(Mesh));
- Ref<FixedMaterial> mat = memnew( FixedMaterial );
- mat->set_flag(Material::FLAG_UNSHADED,true);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
- mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());
+ Ref<FixedMaterial> mat = memnew(FixedMaterial);
+ mat->set_flag(Material::FLAG_UNSHADED, true);
+ mat->set_flag(Material::FLAG_DOUBLE_SIDED, true);
+ mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
+ mat->set_parameter(FixedMaterial::PARAM_DIFFUSE, get_debug_collision_contact_color());
- Vector3 diamond[6]={
+ Vector3 diamond[6] = {
Vector3(-1, 0, 0),
- Vector3( 1, 0, 0),
- Vector3( 0, -1, 0),
- Vector3( 0, 1, 0),
- Vector3( 0, 0, -1),
- Vector3( 0, 0, 1)
+ Vector3(1, 0, 0),
+ Vector3(0, -1, 0),
+ Vector3(0, 1, 0),
+ Vector3(0, 0, -1),
+ Vector3(0, 0, 1)
};
- int diamond_faces[8*3]={
- 0,2,4,
- 0,3,4,
- 1,2,4,
- 1,3,4,
- 0,2,5,
- 0,3,5,
- 1,2,5,
- 1,3,5,
+ int diamond_faces[8 * 3] = {
+ 0, 2, 4,
+ 0, 3, 4,
+ 1, 2, 4,
+ 1, 3, 4,
+ 0, 2, 5,
+ 0, 3, 5,
+ 1, 2, 5,
+ 1, 3, 5,
};
DVector<int> indices;
- for(int i=0;i<8*3;i++)
+ for (int i = 0; i < 8 * 3; i++)
indices.push_back(diamond_faces[i]);
DVector<Vector3> vertices;
- for(int i=0;i<6;i++)
- vertices.push_back(diamond[i]*0.1);
+ for (int i = 0; i < 6; i++)
+ vertices.push_back(diamond[i] * 0.1);
Array arr;
arr.resize(Mesh::ARRAY_MAX);
- arr[Mesh::ARRAY_VERTEX]=vertices;
- arr[Mesh::ARRAY_INDEX]=indices;
+ arr[Mesh::ARRAY_VERTEX] = vertices;
+ arr[Mesh::ARRAY_INDEX] = indices;
-
- debug_contact_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr);
- debug_contact_mesh->surface_set_material(0,mat);
+ debug_contact_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, arr);
+ debug_contact_mesh->surface_set_material(0, mat);
return debug_contact_mesh;
-
}
-
-
void SceneTree::set_pause(bool p_enabled) {
- if (p_enabled==pause)
+ if (p_enabled == pause)
return;
- pause=p_enabled;
+ pause = p_enabled;
PhysicsServer::get_singleton()->set_active(!p_enabled);
Physics2DServer::get_singleton()->set_active(!p_enabled);
if (get_root())
@@ -822,12 +779,12 @@ bool SceneTree::is_paused() const {
return pause;
}
-void SceneTree::_call_input_pause(const StringName& p_group,const StringName& p_method,const InputEvent& p_input) {
+void SceneTree::_call_input_pause(const StringName &p_group, const StringName &p_method, const InputEvent &p_input) {
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
return;
- Group &g=E->get();
+ Group &g = E->get();
if (g.nodes.empty())
return;
@@ -835,17 +792,17 @@ void SceneTree::_call_input_pause(const StringName& p_group,const StringName& p_
//copy, so copy on write happens in case something is removed from process while being called
//performance is not lost because only if something is added/removed the vector is copied.
- Vector<Node*> nodes_copy = g.nodes;
+ Vector<Node *> nodes_copy = g.nodes;
- int node_count=nodes_copy.size();
+ int node_count = nodes_copy.size();
Node **nodes = &nodes_copy[0];
- Variant arg=p_input;
- const Variant *v[1]={&arg};
+ Variant arg = p_input;
+ const Variant *v[1] = { &arg };
call_lock++;
- for(int i=node_count-1;i>=0;i--) {
+ for (int i = node_count - 1; i >= 0; i--) {
if (input_handled)
break;
@@ -858,37 +815,36 @@ void SceneTree::_call_input_pause(const StringName& p_group,const StringName& p_
continue;
Variant::CallError ce;
- n->call_multilevel(p_method,(const Variant**)v,1);
+ n->call_multilevel(p_method, (const Variant **)v, 1);
//ERR_FAIL_COND(node_count != g.nodes.size());
}
call_lock--;
- if (call_lock==0)
+ if (call_lock == 0)
call_skip.clear();
}
-void SceneTree::_notify_group_pause(const StringName& p_group,int p_notification) {
+void SceneTree::_notify_group_pause(const StringName &p_group, int p_notification) {
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
return;
- Group &g=E->get();
+ Group &g = E->get();
if (g.nodes.empty())
return;
-
_update_group_order(g);
//copy, so copy on write happens in case something is removed from process while being called
//performance is not lost because only if something is added/removed the vector is copied.
- Vector<Node*> nodes_copy = g.nodes;
+ Vector<Node *> nodes_copy = g.nodes;
- int node_count=nodes_copy.size();
+ int node_count = nodes_copy.size();
Node **nodes = &nodes_copy[0];
call_lock++;
- for(int i=0;i<node_count;i++) {
+ for (int i = 0; i < node_count; i++) {
Node *n = nodes[i];
if (call_lock && call_skip.has(n))
@@ -902,7 +858,7 @@ void SceneTree::_notify_group_pause(const StringName& p_group,int p_notification
}
call_lock--;
- if (call_lock==0)
+ if (call_lock == 0)
call_skip.clear();
}
@@ -922,93 +878,87 @@ uint32_t SceneTree::get_last_event_id() const {
return last_id;
}
+Variant SceneTree::_call_group(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
-Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) {
-
-
- r_error.error=Variant::CallError::CALL_OK;
+ r_error.error = Variant::CallError::CALL_OK;
- ERR_FAIL_COND_V(p_argcount<3,Variant());
- ERR_FAIL_COND_V(!p_args[0]->is_num(),Variant());
- ERR_FAIL_COND_V(p_args[1]->get_type()!=Variant::STRING,Variant());
- ERR_FAIL_COND_V(p_args[2]->get_type()!=Variant::STRING,Variant());
+ ERR_FAIL_COND_V(p_argcount < 3, Variant());
+ ERR_FAIL_COND_V(!p_args[0]->is_num(), Variant());
+ ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING, Variant());
+ ERR_FAIL_COND_V(p_args[2]->get_type() != Variant::STRING, Variant());
int flags = *p_args[0];
StringName group = *p_args[1];
StringName method = *p_args[2];
Variant v[VARIANT_ARG_MAX];
- for(int i=0;i<MIN(p_argcount-3,5);i++) {
+ for (int i = 0; i < MIN(p_argcount - 3, 5); i++) {
- v[i]=*p_args[i+3];
+ v[i] = *p_args[i + 3];
}
- call_group(flags,group,method,v[0],v[1],v[2],v[3],v[4]);
+ call_group(flags, group, method, v[0], v[1], v[2], v[3], v[4]);
return Variant();
}
-
int64_t SceneTree::get_frame() const {
return current_frame;
}
-
-Array SceneTree::_get_nodes_in_group(const StringName& p_group) {
+Array SceneTree::_get_nodes_in_group(const StringName &p_group) {
Array ret;
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
return ret;
_update_group_order(E->get()); //update order just in case
int nc = E->get().nodes.size();
- if (nc==0)
+ if (nc == 0)
return ret;
ret.resize(nc);
Node **ptr = E->get().nodes.ptr();
- for(int i=0;i<nc;i++) {
+ for (int i = 0; i < nc; i++) {
- ret[i]=ptr[i];
+ ret[i] = ptr[i];
}
return ret;
}
-bool SceneTree::has_group(const StringName& p_identifier) const {
+bool SceneTree::has_group(const StringName &p_identifier) const {
return group_map.has(p_identifier);
}
-void SceneTree::get_nodes_in_group(const StringName& p_group,List<Node*> *p_list) {
-
+void SceneTree::get_nodes_in_group(const StringName &p_group, List<Node *> *p_list) {
- Map<StringName,Group>::Element *E=group_map.find(p_group);
+ Map<StringName, Group>::Element *E = group_map.find(p_group);
if (!E)
return;
_update_group_order(E->get()); //update order just in case
int nc = E->get().nodes.size();
- if (nc==0)
+ if (nc == 0)
return;
Node **ptr = E->get().nodes.ptr();
- for(int i=0;i<nc;i++) {
+ for (int i = 0; i < nc; i++) {
p_list->push_back(ptr[i]);
}
}
-
-static void _fill_array(Node *p_node, Array& array, int p_level) {
+static void _fill_array(Node *p_node, Array &array, int p_level) {
array.push_back(p_level);
array.push_back(p_node->get_name());
array.push_back(p_node->get_type());
array.push_back(p_node->get_instance_ID());
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- _fill_array(p_node->get_child(i),array,p_level+1);
+ _fill_array(p_node->get_child(i), array, p_level + 1);
}
}
@@ -1017,20 +967,19 @@ void SceneTree::_debugger_request_tree(void *self) {
SceneTree *sml = (SceneTree *)self;
Array arr;
- _fill_array(sml->root,arr,0);
- ScriptDebugger::get_singleton()->send_message("scene_tree",arr);
+ _fill_array(sml->root, arr, 0);
+ ScriptDebugger::get_singleton()->send_message("scene_tree", arr);
}
-
void SceneTree::_flush_delete_queue() {
_THREAD_SAFE_METHOD_
- while( delete_queue.size() ) {
+ while (delete_queue.size()) {
- Object *obj = ObjectDB::get_instance( delete_queue.front()->get() );
+ Object *obj = ObjectDB::get_instance(delete_queue.front()->get());
if (obj) {
- memdelete( obj );
+ memdelete(obj);
}
delete_queue.pop_front();
}
@@ -1044,23 +993,20 @@ void SceneTree::queue_delete(Object *p_object) {
delete_queue.push_back(p_object->get_instance_ID());
}
-
int SceneTree::get_node_count() const {
return node_count;
}
-
void SceneTree::_update_root_rect() {
-
- if (stretch_mode==STRETCH_MODE_DISABLED) {
- root->set_rect(Rect2(Point2(),last_screen_size));
+ if (stretch_mode == STRETCH_MODE_DISABLED) {
+ root->set_rect(Rect2(Point2(), last_screen_size));
return; //user will take care
}
//actual screen video mode
- Size2 video_mode = Size2(OS::get_singleton()->get_video_mode().width,OS::get_singleton()->get_video_mode().height);
+ Size2 video_mode = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height);
Size2 desired_res = stretch_min;
Size2 viewport_size;
@@ -1069,42 +1015,41 @@ void SceneTree::_update_root_rect() {
float viewport_aspect = desired_res.get_aspect();
float video_mode_aspect = video_mode.get_aspect();
- if (stretch_aspect==STRETCH_ASPECT_IGNORE || ABS(viewport_aspect - video_mode_aspect)<CMP_EPSILON) {
+ if (stretch_aspect == STRETCH_ASPECT_IGNORE || ABS(viewport_aspect - video_mode_aspect) < CMP_EPSILON) {
//same aspect or ignore aspect
- viewport_size=desired_res;
- screen_size=video_mode;
+ viewport_size = desired_res;
+ screen_size = video_mode;
} else if (viewport_aspect < video_mode_aspect) {
// screen ratio is smaller vertically
- if (stretch_aspect==STRETCH_ASPECT_KEEP_HEIGHT) {
+ if (stretch_aspect == STRETCH_ASPECT_KEEP_HEIGHT) {
//will stretch horizontally
- viewport_size.x=desired_res.y*video_mode_aspect;
- viewport_size.y=desired_res.y;
- screen_size=video_mode;
+ viewport_size.x = desired_res.y * video_mode_aspect;
+ viewport_size.y = desired_res.y;
+ screen_size = video_mode;
} else {
//will need black bars
- viewport_size=desired_res;
+ viewport_size = desired_res;
screen_size.x = video_mode.y * viewport_aspect;
- screen_size.y=video_mode.y;
+ screen_size.y = video_mode.y;
}
} else {
//screen ratio is smaller horizontally
- if (stretch_aspect==STRETCH_ASPECT_KEEP_WIDTH) {
+ if (stretch_aspect == STRETCH_ASPECT_KEEP_WIDTH) {
//will stretch horizontally
- viewport_size.x=desired_res.x;
- viewport_size.y=desired_res.x / video_mode_aspect;
- screen_size=video_mode;
+ viewport_size.x = desired_res.x;
+ viewport_size.y = desired_res.x / video_mode_aspect;
+ screen_size = video_mode;
} else {
//will need black bars
- viewport_size=desired_res;
- screen_size.x=video_mode.x;
+ viewport_size = desired_res;
+ screen_size.x = video_mode.x;
screen_size.y = video_mode.x / viewport_aspect;
}
-
}
screen_size = screen_size.floor();
@@ -1114,58 +1059,54 @@ void SceneTree::_update_root_rect() {
Size2 offset;
//black bars and margin
if (screen_size.x < video_mode.x) {
- margin.x = Math::round((video_mode.x - screen_size.x)/2.0);
- VisualServer::get_singleton()->black_bars_set_margins(margin.x,0,margin.x,0);
+ margin.x = Math::round((video_mode.x - screen_size.x) / 2.0);
+ VisualServer::get_singleton()->black_bars_set_margins(margin.x, 0, margin.x, 0);
offset.x = Math::round(margin.x * viewport_size.y / screen_size.y);
} else if (screen_size.y < video_mode.y) {
- margin.y = Math::round((video_mode.y - screen_size.y)/2.0);
- VisualServer::get_singleton()->black_bars_set_margins(0,margin.y,0,margin.y);
+ margin.y = Math::round((video_mode.y - screen_size.y) / 2.0);
+ VisualServer::get_singleton()->black_bars_set_margins(0, margin.y, 0, margin.y);
offset.y = Math::round(margin.y * viewport_size.x / screen_size.x);
} else {
- VisualServer::get_singleton()->black_bars_set_margins(0,0,0,0);
+ VisualServer::get_singleton()->black_bars_set_margins(0, 0, 0, 0);
}
-// print_line("VP SIZE: "+viewport_size+" OFFSET: "+offset+" = "+(offset*2+viewport_size));
-// print_line("SS: "+video_mode);
+ // print_line("VP SIZE: "+viewport_size+" OFFSET: "+offset+" = "+(offset*2+viewport_size));
+ // print_line("SS: "+video_mode);
switch (stretch_mode) {
case STRETCH_MODE_2D: {
-// root->set_rect(Rect2(Point2(),video_mode));
+ // root->set_rect(Rect2(Point2(),video_mode));
root->set_as_render_target(false);
- root->set_rect(Rect2(margin,screen_size));
+ root->set_rect(Rect2(margin, screen_size));
root->set_size_override_stretch(true);
- root->set_size_override(true,viewport_size);
+ root->set_size_override(true, viewport_size);
} break;
case STRETCH_MODE_VIEWPORT: {
- root->set_rect(Rect2(Point2(),viewport_size));
+ root->set_rect(Rect2(Point2(), viewport_size));
root->set_size_override_stretch(false);
- root->set_size_override(false,Size2());
+ root->set_size_override(false, Size2());
root->set_as_render_target(true);
root->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS);
- root->set_render_target_to_screen_rect(Rect2(margin,screen_size));
+ root->set_render_target_to_screen_rect(Rect2(margin, screen_size));
} break;
-
-
}
-
}
-void SceneTree::set_screen_stretch(StretchMode p_mode,StretchAspect p_aspect,const Size2 p_minsize) {
+void SceneTree::set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize) {
- stretch_mode=p_mode;
- stretch_aspect=p_aspect;
- stretch_min=p_minsize;
+ stretch_mode = p_mode;
+ stretch_aspect = p_aspect;
+ stretch_min = p_minsize;
_update_root_rect();
}
-
#ifdef TOOLS_ENABLED
void SceneTree::set_edited_scene_root(Node *p_node) {
- edited_scene_root=p_node;
+ edited_scene_root = p_node;
}
Node *SceneTree::get_edited_scene_root() const {
@@ -1174,76 +1115,74 @@ Node *SceneTree::get_edited_scene_root() const {
}
#endif
-void SceneTree::set_current_scene(Node* p_scene) {
+void SceneTree::set_current_scene(Node *p_scene) {
- ERR_FAIL_COND(p_scene && p_scene->get_parent()!=root);
- current_scene=p_scene;
+ ERR_FAIL_COND(p_scene && p_scene->get_parent() != root);
+ current_scene = p_scene;
}
-Node* SceneTree::get_current_scene() const{
+Node *SceneTree::get_current_scene() const {
return current_scene;
}
-void SceneTree::_change_scene(Node* p_to) {
+void SceneTree::_change_scene(Node *p_to) {
if (current_scene) {
- memdelete( current_scene );
- current_scene=NULL;
+ memdelete(current_scene);
+ current_scene = NULL;
}
if (p_to) {
- current_scene=p_to;
+ current_scene = p_to;
root->add_child(p_to);
}
}
-Error SceneTree::change_scene(const String& p_path){
+Error SceneTree::change_scene(const String &p_path) {
Ref<PackedScene> new_scene = ResourceLoader::load(p_path);
if (new_scene.is_null())
return ERR_CANT_OPEN;
return change_scene_to(new_scene);
-
}
-Error SceneTree::change_scene_to(const Ref<PackedScene>& p_scene){
+Error SceneTree::change_scene_to(const Ref<PackedScene> &p_scene) {
- Node *new_scene=NULL;
+ Node *new_scene = NULL;
if (p_scene.is_valid()) {
new_scene = p_scene->instance();
- ERR_FAIL_COND_V(!new_scene,ERR_CANT_CREATE);
+ ERR_FAIL_COND_V(!new_scene, ERR_CANT_CREATE);
}
- call_deferred("_change_scene",new_scene);
+ call_deferred("_change_scene", new_scene);
return OK;
-
}
Error SceneTree::reload_current_scene() {
- ERR_FAIL_COND_V(!current_scene,ERR_UNCONFIGURED);
+ ERR_FAIL_COND_V(!current_scene, ERR_UNCONFIGURED);
String fname = current_scene->get_filename();
return change_scene(fname);
}
-void SceneTree::add_current_scene(Node * p_current) {
+void SceneTree::add_current_scene(Node *p_current) {
- current_scene=p_current;
+ current_scene = p_current;
root->add_child(p_current);
}
#ifdef DEBUG_ENABLED
-void SceneTree::_live_edit_node_path_func(const NodePath &p_path,int p_id) {
+void SceneTree::_live_edit_node_path_func(const NodePath &p_path, int p_id) {
- live_edit_node_path_cache[p_id]=p_path;
+ live_edit_node_path_cache[p_id] = p_path;
}
-void SceneTree::_live_edit_res_path_func(const String &p_path,int p_id) {
+void SceneTree::_live_edit_res_path_func(const String &p_path, int p_id) {
- live_edit_resource_cache[p_id]=p_path;
+ live_edit_resource_cache[p_id] = p_path;
}
-void SceneTree::_live_edit_node_set_func(int p_id,const StringName& p_prop,const Variant& p_value) {
+void SceneTree::_live_edit_node_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
if (!live_edit_node_path_cache.has(p_id))
return;
@@ -1253,13 +1192,13 @@ void SceneTree::_live_edit_node_set_func(int p_id,const StringName& p_prop,const
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
- for(Set<Node*>::Element *F=E->get().front();F;F=F->next()) {
+ for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1268,20 +1207,18 @@ void SceneTree::_live_edit_node_set_func(int p_id,const StringName& p_prop,const
continue;
Node *n2 = n->get_node(np);
- n2->set(p_prop,p_value);
+ n2->set(p_prop, p_value);
}
-
}
-void SceneTree::_live_edit_node_set_res_func(int p_id,const StringName& p_prop,const String& p_value) {
+void SceneTree::_live_edit_node_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
RES r = ResourceLoader::load(p_value);
if (!r.is_valid())
return;
- _live_edit_node_set_func(p_id,p_prop,r);
-
+ _live_edit_node_set_func(p_id, p_prop, r);
}
-void SceneTree::_live_edit_node_call_func(int p_id,const StringName& p_method,VARIANT_ARG_DECLARE) {
+void SceneTree::_live_edit_node_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
if (!live_edit_node_path_cache.has(p_id))
return;
@@ -1291,13 +1228,13 @@ void SceneTree::_live_edit_node_call_func(int p_id,const StringName& p_method,VA
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
- for(Set<Node*>::Element *F=E->get().front();F;F=F->next()) {
+ for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1306,10 +1243,10 @@ void SceneTree::_live_edit_node_call_func(int p_id,const StringName& p_method,VA
continue;
Node *n2 = n->get_node(np);
- n2->call(p_method,VARIANT_ARG_PASS);
+ n2->call(p_method, VARIANT_ARG_PASS);
}
}
-void SceneTree::_live_edit_res_set_func(int p_id,const StringName& p_prop,const Variant& p_value) {
+void SceneTree::_live_edit_res_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
if (!live_edit_resource_cache.has(p_id))
return;
@@ -1323,17 +1260,16 @@ void SceneTree::_live_edit_res_set_func(int p_id,const StringName& p_prop,const
if (!r.is_valid())
return;
- r->set(p_prop,p_value);
+ r->set(p_prop, p_value);
}
-void SceneTree::_live_edit_res_set_res_func(int p_id,const StringName& p_prop,const String& p_value) {
+void SceneTree::_live_edit_res_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
RES r = ResourceLoader::load(p_value);
if (!r.is_valid())
return;
- _live_edit_res_set_func(p_id,p_prop,r);
-
+ _live_edit_res_set_func(p_id, p_prop, r);
}
-void SceneTree::_live_edit_res_call_func(int p_id,const StringName& p_method,VARIANT_ARG_DECLARE) {
+void SceneTree::_live_edit_res_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
if (!live_edit_resource_cache.has(p_id))
return;
@@ -1347,29 +1283,28 @@ void SceneTree::_live_edit_res_call_func(int p_id,const StringName& p_method,VAR
if (!r.is_valid())
return;
- r->call(p_method,VARIANT_ARG_PASS);
+ r->call(p_method, VARIANT_ARG_PASS);
}
-void SceneTree::_live_edit_root_func(const NodePath& p_scene_path,const String& p_scene_from) {
+void SceneTree::_live_edit_root_func(const NodePath &p_scene_path, const String &p_scene_from) {
- live_edit_root=p_scene_path;
- live_edit_scene=p_scene_from;
+ live_edit_root = p_scene_path;
+ live_edit_scene = p_scene_from;
}
-void SceneTree::_live_edit_create_node_func(const NodePath& p_parent,const String& p_type,const String& p_name) {
-
+void SceneTree::_live_edit_create_node_func(const NodePath &p_parent, const String &p_type, const String &p_name) {
Node *base = NULL;
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
- for(Set<Node*>::Element *F=E->get().front();F;F=F->next()) {
+ for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1381,13 +1316,13 @@ void SceneTree::_live_edit_create_node_func(const NodePath& p_parent,const Strin
Object *o = ObjectTypeDB::instance(p_type);
if (!o)
continue;
- Node *no=o->cast_to<Node>();
+ Node *no = o->cast_to<Node>();
no->set_name(p_name);
n2->add_child(no);
}
}
-void SceneTree::_live_edit_instance_node_func(const NodePath& p_parent,const String& p_path,const String& p_name){
+void SceneTree::_live_edit_instance_node_func(const NodePath &p_parent, const String &p_path, const String &p_name) {
Ref<PackedScene> ps = ResourceLoader::load(p_path);
@@ -1398,13 +1333,13 @@ void SceneTree::_live_edit_instance_node_func(const NodePath& p_parent,const Str
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
- for(Set<Node*>::Element *F=E->get().front();F;F=F->next()) {
+ for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1413,29 +1348,27 @@ void SceneTree::_live_edit_instance_node_func(const NodePath& p_parent,const Str
continue;
Node *n2 = n->get_node(p_parent);
-
-
- Node *no=ps->instance();
+ Node *no = ps->instance();
no->set_name(p_name);
n2->add_child(no);
}
}
-void SceneTree::_live_edit_remove_node_func(const NodePath& p_at){
+void SceneTree::_live_edit_remove_node_func(const NodePath &p_at) {
Node *base = NULL;
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
- for(Set<Node*>::Element *F=E->get().front();F;) {
+ for (Set<Node *>::Element *F = E->get().front(); F;) {
- Set<Node*>::Element *N=F->next();
+ Set<Node *>::Element *N = F->next();
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1446,26 +1379,24 @@ void SceneTree::_live_edit_remove_node_func(const NodePath& p_at){
memdelete(n2);
- F=N;
-
+ F = N;
}
}
-void SceneTree::_live_edit_remove_and_keep_node_func(const NodePath& p_at,ObjectID p_keep_id){
+void SceneTree::_live_edit_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_keep_id) {
Node *base = NULL;
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
+ for (Set<Node *>::Element *F = E->get().front(); F;) {
- for(Set<Node*>::Element *F=E->get().front();F;) {
-
- Set<Node*>::Element *N=F->next();
+ Set<Node *>::Element *N = F->next();
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1477,28 +1408,26 @@ void SceneTree::_live_edit_remove_and_keep_node_func(const NodePath& p_at,Object
n2->get_parent()->remove_child(n2);
- live_edit_remove_list[n][p_keep_id]=n2;
-
- F=N;
+ live_edit_remove_list[n][p_keep_id] = n2;
+ F = N;
}
}
-void SceneTree::_live_edit_restore_node_func(ObjectID p_id,const NodePath& p_at,int p_at_pos){
-
+void SceneTree::_live_edit_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
Node *base = NULL;
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
- for(Set<Node*>::Element *F=E->get().front();F;) {
+ for (Set<Node *>::Element *F = E->get().front(); F;) {
- Set<Node*>::Element *N=F->next();
+ Set<Node *>::Element *N = F->next();
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1507,12 +1436,12 @@ void SceneTree::_live_edit_restore_node_func(ObjectID p_id,const NodePath& p_at,
continue;
Node *n2 = n->get_node(p_at);
- Map<Node*,Map<ObjectID,Node*> >::Element *EN=live_edit_remove_list.find(n);
+ Map<Node *, Map<ObjectID, Node *> >::Element *EN = live_edit_remove_list.find(n);
if (!EN)
continue;
- Map<ObjectID,Node*>::Element *FN=EN->get().find(p_id);
+ Map<ObjectID, Node *>::Element *FN = EN->get().find(p_id);
if (!FN)
continue;
@@ -1520,27 +1449,26 @@ void SceneTree::_live_edit_restore_node_func(ObjectID p_id,const NodePath& p_at,
EN->get().erase(FN);
- if (EN->get().size()==0) {
+ if (EN->get().size() == 0) {
live_edit_remove_list.erase(EN);
}
- F=N;
-
+ F = N;
}
}
-void SceneTree::_live_edit_duplicate_node_func(const NodePath& p_at,const String& p_new_name){
+void SceneTree::_live_edit_duplicate_node_func(const NodePath &p_at, const String &p_new_name) {
Node *base = NULL;
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
- for(Set<Node*>::Element *F=E->get().front();F;F=F->next()) {
+ for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1556,22 +1484,21 @@ void SceneTree::_live_edit_duplicate_node_func(const NodePath& p_at,const String
dup->set_name(p_new_name);
n2->get_parent()->add_child(dup);
-
}
}
-void SceneTree::_live_edit_reparent_node_func(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos){
+void SceneTree::_live_edit_reparent_node_func(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
Node *base = NULL;
if (root->has_node(live_edit_root))
base = root->get_node(live_edit_root);
- Map<String,Set<Node*> >::Element *E=live_scene_edit_cache.find(live_edit_scene);
+ Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
if (!E)
return; //scene not editable
- for(Set<Node*>::Element *F=E->get().front();F;F=F->next()) {
+ for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
- Node *n=F->get();
+ Node *n = F->get();
if (base && !base->is_a_parent_of(n))
continue;
@@ -1588,203 +1515,187 @@ void SceneTree::_live_edit_reparent_node_func(const NodePath& p_at,const NodePat
nfrom->set_name(p_new_name);
nto->add_child(nfrom);
- if (p_at_pos>=0)
- nto->move_child(nfrom,p_at_pos);
-
+ if (p_at_pos >= 0)
+ nto->move_child(nfrom, p_at_pos);
}
}
-
#endif
+void SceneTree::drop_files(const Vector<String> &p_files, int p_from_screen) {
-void SceneTree::drop_files(const Vector<String>& p_files,int p_from_screen) {
-
- emit_signal("files_dropped",p_files,p_from_screen);
- MainLoop::drop_files(p_files,p_from_screen);
+ emit_signal("files_dropped", p_files, p_from_screen);
+ MainLoop::drop_files(p_files, p_from_screen);
}
void SceneTree::_bind_methods() {
-
//ObjectTypeDB::bind_method(_MD("call_group","call_flags","group","method","arg1","arg2"),&SceneMainLoop::_call_group,DEFVAL(Variant()),DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("notify_group","call_flags","group","notification"),&SceneTree::notify_group);
- ObjectTypeDB::bind_method(_MD("set_group","call_flags","group","property","value"),&SceneTree::set_group);
+ ObjectTypeDB::bind_method(_MD("notify_group", "call_flags", "group", "notification"), &SceneTree::notify_group);
+ ObjectTypeDB::bind_method(_MD("set_group", "call_flags", "group", "property", "value"), &SceneTree::set_group);
- ObjectTypeDB::bind_method(_MD("get_nodes_in_group","group"),&SceneTree::_get_nodes_in_group);
+ ObjectTypeDB::bind_method(_MD("get_nodes_in_group", "group"), &SceneTree::_get_nodes_in_group);
- ObjectTypeDB::bind_method(_MD("get_root:Viewport"),&SceneTree::get_root);
- ObjectTypeDB::bind_method(_MD("has_group","name"),&SceneTree::has_group);
+ ObjectTypeDB::bind_method(_MD("get_root:Viewport"), &SceneTree::get_root);
+ ObjectTypeDB::bind_method(_MD("has_group", "name"), &SceneTree::has_group);
- ObjectTypeDB::bind_method(_MD("set_auto_accept_quit","enabled"),&SceneTree::set_auto_accept_quit);
+ ObjectTypeDB::bind_method(_MD("set_auto_accept_quit", "enabled"), &SceneTree::set_auto_accept_quit);
- ObjectTypeDB::bind_method(_MD("set_editor_hint","enable"),&SceneTree::set_editor_hint);
- ObjectTypeDB::bind_method(_MD("is_editor_hint"),&SceneTree::is_editor_hint);
- ObjectTypeDB::bind_method(_MD("set_debug_collisions_hint","enable"),&SceneTree::set_debug_collisions_hint);
- ObjectTypeDB::bind_method(_MD("is_debugging_collisions_hint"),&SceneTree::is_debugging_collisions_hint);
- ObjectTypeDB::bind_method(_MD("set_debug_navigation_hint","enable"),&SceneTree::set_debug_navigation_hint);
- ObjectTypeDB::bind_method(_MD("is_debugging_navigation_hint"),&SceneTree::is_debugging_navigation_hint);
+ ObjectTypeDB::bind_method(_MD("set_editor_hint", "enable"), &SceneTree::set_editor_hint);
+ ObjectTypeDB::bind_method(_MD("is_editor_hint"), &SceneTree::is_editor_hint);
+ ObjectTypeDB::bind_method(_MD("set_debug_collisions_hint", "enable"), &SceneTree::set_debug_collisions_hint);
+ ObjectTypeDB::bind_method(_MD("is_debugging_collisions_hint"), &SceneTree::is_debugging_collisions_hint);
+ ObjectTypeDB::bind_method(_MD("set_debug_navigation_hint", "enable"), &SceneTree::set_debug_navigation_hint);
+ ObjectTypeDB::bind_method(_MD("is_debugging_navigation_hint"), &SceneTree::is_debugging_navigation_hint);
#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method(_MD("set_edited_scene_root","scene"),&SceneTree::set_edited_scene_root);
- ObjectTypeDB::bind_method(_MD("get_edited_scene_root"),&SceneTree::get_edited_scene_root);
+ ObjectTypeDB::bind_method(_MD("set_edited_scene_root", "scene"), &SceneTree::set_edited_scene_root);
+ ObjectTypeDB::bind_method(_MD("get_edited_scene_root"), &SceneTree::get_edited_scene_root);
#endif
- ObjectTypeDB::bind_method(_MD("set_pause","enable"),&SceneTree::set_pause);
- ObjectTypeDB::bind_method(_MD("is_paused"),&SceneTree::is_paused);
- ObjectTypeDB::bind_method(_MD("set_input_as_handled"),&SceneTree::set_input_as_handled);
-
-
- ObjectTypeDB::bind_method(_MD("get_node_count"),&SceneTree::get_node_count);
- ObjectTypeDB::bind_method(_MD("get_frame"),&SceneTree::get_frame);
- ObjectTypeDB::bind_method(_MD("quit"),&SceneTree::quit);
-
- ObjectTypeDB::bind_method(_MD("set_screen_stretch","mode","aspect","minsize"),&SceneTree::set_screen_stretch);
-
- ObjectTypeDB::bind_method(_MD("queue_delete","obj"),&SceneTree::queue_delete);
+ ObjectTypeDB::bind_method(_MD("set_pause", "enable"), &SceneTree::set_pause);
+ ObjectTypeDB::bind_method(_MD("is_paused"), &SceneTree::is_paused);
+ ObjectTypeDB::bind_method(_MD("set_input_as_handled"), &SceneTree::set_input_as_handled);
+ ObjectTypeDB::bind_method(_MD("get_node_count"), &SceneTree::get_node_count);
+ ObjectTypeDB::bind_method(_MD("get_frame"), &SceneTree::get_frame);
+ ObjectTypeDB::bind_method(_MD("quit"), &SceneTree::quit);
+ ObjectTypeDB::bind_method(_MD("set_screen_stretch", "mode", "aspect", "minsize"), &SceneTree::set_screen_stretch);
+ ObjectTypeDB::bind_method(_MD("queue_delete", "obj"), &SceneTree::queue_delete);
MethodInfo mi;
- mi.name="call_group";
- mi.arguments.push_back( PropertyInfo( Variant::INT, "flags"));
- mi.arguments.push_back( PropertyInfo( Variant::STRING, "group"));
- mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
+ mi.name = "call_group";
+ mi.arguments.push_back(PropertyInfo(Variant::INT, "flags"));
+ mi.arguments.push_back(PropertyInfo(Variant::STRING, "group"));
+ mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
Vector<Variant> defargs;
- for(int i=0;i<VARIANT_ARG_MAX;i++) {
- mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
+ for (int i = 0; i < VARIANT_ARG_MAX; i++) {
+ mi.arguments.push_back(PropertyInfo(Variant::NIL, "arg" + itos(i)));
defargs.push_back(Variant());
}
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call_group",&SceneTree::_call_group,mi,defargs);
-
- ObjectTypeDB::bind_method(_MD("set_current_scene","child_node:Node"),&SceneTree::set_current_scene);
- ObjectTypeDB::bind_method(_MD("get_current_scene:Node"),&SceneTree::get_current_scene);
+ ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT, "call_group", &SceneTree::_call_group, mi, defargs);
- ObjectTypeDB::bind_method(_MD("change_scene","path"),&SceneTree::change_scene);
- ObjectTypeDB::bind_method(_MD("change_scene_to","packed_scene:PackedScene"),&SceneTree::change_scene_to);
+ ObjectTypeDB::bind_method(_MD("set_current_scene", "child_node:Node"), &SceneTree::set_current_scene);
+ ObjectTypeDB::bind_method(_MD("get_current_scene:Node"), &SceneTree::get_current_scene);
- ObjectTypeDB::bind_method(_MD("reload_current_scene"),&SceneTree::reload_current_scene);
+ ObjectTypeDB::bind_method(_MD("change_scene", "path"), &SceneTree::change_scene);
+ ObjectTypeDB::bind_method(_MD("change_scene_to", "packed_scene:PackedScene"), &SceneTree::change_scene_to);
- ObjectTypeDB::bind_method(_MD("_change_scene"),&SceneTree::_change_scene);
+ ObjectTypeDB::bind_method(_MD("reload_current_scene"), &SceneTree::reload_current_scene);
- ADD_SIGNAL( MethodInfo("tree_changed") );
- ADD_SIGNAL( MethodInfo("node_removed",PropertyInfo( Variant::OBJECT, "node") ) );
- ADD_SIGNAL( MethodInfo("screen_resized") );
- ADD_SIGNAL( MethodInfo("node_configuration_warning_changed",PropertyInfo( Variant::OBJECT, "node")) );
+ ObjectTypeDB::bind_method(_MD("_change_scene"), &SceneTree::_change_scene);
- ADD_SIGNAL( MethodInfo("idle_frame"));
- ADD_SIGNAL( MethodInfo("fixed_frame"));
+ ADD_SIGNAL(MethodInfo("tree_changed"));
+ ADD_SIGNAL(MethodInfo("node_removed", PropertyInfo(Variant::OBJECT, "node")));
+ ADD_SIGNAL(MethodInfo("screen_resized"));
+ ADD_SIGNAL(MethodInfo("node_configuration_warning_changed", PropertyInfo(Variant::OBJECT, "node")));
- ADD_SIGNAL( MethodInfo("files_dropped",PropertyInfo(Variant::STRING_ARRAY,"files"),PropertyInfo(Variant::INT,"screen")) );
+ ADD_SIGNAL(MethodInfo("idle_frame"));
+ ADD_SIGNAL(MethodInfo("fixed_frame"));
- BIND_CONSTANT( GROUP_CALL_DEFAULT );
- BIND_CONSTANT( GROUP_CALL_REVERSE );
- BIND_CONSTANT( GROUP_CALL_REALTIME );
- BIND_CONSTANT( GROUP_CALL_UNIQUE );
+ ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
- BIND_CONSTANT( STRETCH_MODE_DISABLED );
- BIND_CONSTANT( STRETCH_MODE_2D );
- BIND_CONSTANT( STRETCH_MODE_VIEWPORT );
- BIND_CONSTANT( STRETCH_ASPECT_IGNORE );
- BIND_CONSTANT( STRETCH_ASPECT_KEEP );
- BIND_CONSTANT( STRETCH_ASPECT_KEEP_WIDTH );
- BIND_CONSTANT( STRETCH_ASPECT_KEEP_HEIGHT );
+ BIND_CONSTANT(GROUP_CALL_DEFAULT);
+ BIND_CONSTANT(GROUP_CALL_REVERSE);
+ BIND_CONSTANT(GROUP_CALL_REALTIME);
+ BIND_CONSTANT(GROUP_CALL_UNIQUE);
+ BIND_CONSTANT(STRETCH_MODE_DISABLED);
+ BIND_CONSTANT(STRETCH_MODE_2D);
+ BIND_CONSTANT(STRETCH_MODE_VIEWPORT);
+ BIND_CONSTANT(STRETCH_ASPECT_IGNORE);
+ BIND_CONSTANT(STRETCH_ASPECT_KEEP);
+ BIND_CONSTANT(STRETCH_ASPECT_KEEP_WIDTH);
+ BIND_CONSTANT(STRETCH_ASPECT_KEEP_HEIGHT);
}
-SceneTree *SceneTree::singleton=NULL;
+SceneTree *SceneTree::singleton = NULL;
SceneTree::SceneTree() {
- singleton=this;
- _quit=false;
- initialized=false;
- editor_hint=false;
- debug_collisions_hint=false;
- debug_navigation_hint=false;
- debug_collisions_color=GLOBAL_DEF("debug/collision_shape_color",Color(0.0,0.6,0.7,0.5));
- debug_collision_contact_color=GLOBAL_DEF("debug/collision_contact_color",Color(1.0,0.2,0.1,0.8));
- debug_navigation_color=GLOBAL_DEF("debug/navigation_geometry_color",Color(0.1,1.0,0.7,0.4));
- debug_navigation_disabled_color=GLOBAL_DEF("debug/navigation_disabled_geometry_color",Color(1.0,0.7,0.1,0.4));
- collision_debug_contacts=GLOBAL_DEF("debug/collision_max_contacts_displayed",10000);
-
+ singleton = this;
+ _quit = false;
+ initialized = false;
+ editor_hint = false;
+ debug_collisions_hint = false;
+ debug_navigation_hint = false;
+ debug_collisions_color = GLOBAL_DEF("debug/collision_shape_color", Color(0.0, 0.6, 0.7, 0.5));
+ debug_collision_contact_color = GLOBAL_DEF("debug/collision_contact_color", Color(1.0, 0.2, 0.1, 0.8));
+ debug_navigation_color = GLOBAL_DEF("debug/navigation_geometry_color", Color(0.1, 1.0, 0.7, 0.4));
+ debug_navigation_disabled_color = GLOBAL_DEF("debug/navigation_disabled_geometry_color", Color(1.0, 0.7, 0.1, 0.4));
+ collision_debug_contacts = GLOBAL_DEF("debug/collision_max_contacts_displayed", 10000);
- tree_version=1;
- fixed_process_time=1;
- idle_process_time=1;
- last_id=1;
- root=NULL;
- current_frame=0;
- tree_changed_name="tree_changed";
- node_removed_name="node_removed";
- ugc_locked=false;
- call_lock=0;
- root_lock=0;
- node_count=0;
+ tree_version = 1;
+ fixed_process_time = 1;
+ idle_process_time = 1;
+ last_id = 1;
+ root = NULL;
+ current_frame = 0;
+ tree_changed_name = "tree_changed";
+ node_removed_name = "node_removed";
+ ugc_locked = false;
+ call_lock = 0;
+ root_lock = 0;
+ node_count = 0;
//create with mainloop
- root = memnew( Viewport );
+ root = memnew(Viewport);
root->set_name("root");
- root->set_world( Ref<World>( memnew( World )));
+ root->set_world(Ref<World>(memnew(World)));
//root->set_world_2d( Ref<World2D>( memnew( World2D )));
root->set_as_audio_listener(true);
root->set_as_audio_listener_2d(true);
- current_scene=NULL;
+ current_scene = NULL;
- stretch_mode=STRETCH_MODE_DISABLED;
- stretch_aspect=STRETCH_ASPECT_IGNORE;
+ stretch_mode = STRETCH_MODE_DISABLED;
+ stretch_aspect = STRETCH_ASPECT_IGNORE;
- last_screen_size=Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height );
- root->set_rect(Rect2(Point2(),last_screen_size));
+ last_screen_size = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height);
+ root->set_rect(Rect2(Point2(), last_screen_size));
if (ScriptDebugger::get_singleton()) {
- ScriptDebugger::get_singleton()->set_request_scene_tree_message_func(_debugger_request_tree,this);
+ ScriptDebugger::get_singleton()->set_request_scene_tree_message_func(_debugger_request_tree, this);
}
- root->set_physics_object_picking(GLOBAL_DEF("physics/enable_object_picking",true));
+ root->set_physics_object_picking(GLOBAL_DEF("physics/enable_object_picking", true));
#ifdef TOOLS_ENABLED
- edited_scene_root=NULL;
+ edited_scene_root = NULL;
#endif
#ifdef DEBUG_ENABLED
+ live_edit_funcs.udata = this;
+ live_edit_funcs.node_path_func = _live_edit_node_path_funcs;
+ live_edit_funcs.res_path_func = _live_edit_res_path_funcs;
+ live_edit_funcs.node_set_func = _live_edit_node_set_funcs;
+ live_edit_funcs.node_set_res_func = _live_edit_node_set_res_funcs;
+ live_edit_funcs.node_call_func = _live_edit_node_call_funcs;
+ live_edit_funcs.res_set_func = _live_edit_res_set_funcs;
+ live_edit_funcs.res_set_res_func = _live_edit_res_set_res_funcs;
+ live_edit_funcs.res_call_func = _live_edit_res_call_funcs;
+ live_edit_funcs.root_func = _live_edit_root_funcs;
- live_edit_funcs.udata=this;
- live_edit_funcs.node_path_func=_live_edit_node_path_funcs;
- live_edit_funcs.res_path_func=_live_edit_res_path_funcs;
- live_edit_funcs.node_set_func=_live_edit_node_set_funcs;
- live_edit_funcs.node_set_res_func=_live_edit_node_set_res_funcs;
- live_edit_funcs.node_call_func=_live_edit_node_call_funcs;
- live_edit_funcs.res_set_func=_live_edit_res_set_funcs;
- live_edit_funcs.res_set_res_func=_live_edit_res_set_res_funcs;
- live_edit_funcs.res_call_func=_live_edit_res_call_funcs;
- live_edit_funcs.root_func=_live_edit_root_funcs;
-
- live_edit_funcs.tree_create_node_func=_live_edit_create_node_funcs;
- live_edit_funcs.tree_instance_node_func=_live_edit_instance_node_funcs;
- live_edit_funcs.tree_remove_node_func=_live_edit_remove_node_funcs;
- live_edit_funcs.tree_remove_and_keep_node_func=_live_edit_remove_and_keep_node_funcs;
- live_edit_funcs.tree_restore_node_func=_live_edit_restore_node_funcs;
- live_edit_funcs.tree_duplicate_node_func=_live_edit_duplicate_node_funcs;
- live_edit_funcs.tree_reparent_node_func=_live_edit_reparent_node_funcs;
+ live_edit_funcs.tree_create_node_func = _live_edit_create_node_funcs;
+ live_edit_funcs.tree_instance_node_func = _live_edit_instance_node_funcs;
+ live_edit_funcs.tree_remove_node_func = _live_edit_remove_node_funcs;
+ live_edit_funcs.tree_remove_and_keep_node_func = _live_edit_remove_and_keep_node_funcs;
+ live_edit_funcs.tree_restore_node_func = _live_edit_restore_node_funcs;
+ live_edit_funcs.tree_duplicate_node_func = _live_edit_duplicate_node_funcs;
+ live_edit_funcs.tree_reparent_node_func = _live_edit_reparent_node_funcs;
if (ScriptDebugger::get_singleton()) {
ScriptDebugger::get_singleton()->set_live_edit_funcs(&live_edit_funcs);
}
- live_edit_root=NodePath("/root");
+ live_edit_root = NodePath("/root");
#endif
-
-
}
-
SceneTree::~SceneTree() {
-
-
}
diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h
index 4d89cd5ec..8b20c8dbf 100644
--- a/scene/main/scene_main_loop.h
+++ b/scene/main/scene_main_loop.h
@@ -29,17 +29,15 @@
#ifndef SCENE_MAIN_LOOP_H
#define SCENE_MAIN_LOOP_H
-
#include "os/main_loop.h"
+#include "os/thread_safe.h"
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
-#include "os/thread_safe.h"
#include "self_list.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
class SceneTree;
class PackedScene;
class Node;
@@ -51,10 +49,9 @@ class SceneTree : public MainLoop {
_THREAD_SAFE_CLASS_
- OBJ_TYPE( SceneTree, MainLoop );
-public:
-
+ OBJ_TYPE(SceneTree, MainLoop);
+public:
enum StretchMode {
STRETCH_MODE_DISABLED,
@@ -69,15 +66,14 @@ public:
STRETCH_ASPECT_KEEP_WIDTH,
STRETCH_ASPECT_KEEP_HEIGHT,
};
-private:
-
+private:
struct Group {
- Vector<Node*> nodes;
+ Vector<Node *> nodes;
//uint64_t last_tree_version;
bool changed;
- Group() { changed=false; };
+ Group() { changed = false; };
};
Viewport *root;
@@ -94,7 +90,7 @@ private:
bool pause;
int root_lock;
- Map<StringName,Group> group_map;
+ Map<StringName, Group> group_map;
bool _quit;
bool initialized;
bool input_handled;
@@ -102,7 +98,6 @@ private:
StringName tree_changed_name;
StringName node_removed_name;
-
int64_t current_frame;
int node_count;
@@ -114,13 +109,12 @@ private:
StringName group;
StringName call;
- bool operator<(const UGCall& p_with) const { return group==p_with.group?call<p_with.call:group<p_with.group; }
+ bool operator<(const UGCall &p_with) const { return group == p_with.group ? call < p_with.call : group < p_with.group; }
};
//safety for when a node is deleted while a group is being called
int call_lock;
- Set<Node*> call_skip; //skip erased nodes
-
+ Set<Node *> call_skip; //skip erased nodes
StretchMode stretch_mode;
StretchAspect stretch_aspect;
@@ -130,15 +124,15 @@ private:
List<ObjectID> delete_queue;
- Map<UGCall,Vector<Variant> > unique_group_calls;
+ Map<UGCall, Vector<Variant> > unique_group_calls;
bool ugc_locked;
void _flush_ugc();
void _flush_transform_notifications();
- _FORCE_INLINE_ void _update_group_order(Group& g);
+ _FORCE_INLINE_ void _update_group_order(Group &g);
void _update_listener();
- Array _get_nodes_in_group(const StringName& p_group);
+ Array _get_nodes_in_group(const StringName &p_group);
Node *current_scene;
@@ -152,115 +146,110 @@ private:
Ref<Material> collision_material;
int collision_debug_contacts;
- void _change_scene(Node* p_to);
+ void _change_scene(Node *p_to);
//void _call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,const Variant& p_arg1,const Variant& p_arg2);
static SceneTree *singleton;
-friend class Node;
+ friend class Node;
void tree_changed();
void node_removed(Node *p_node);
+ Group *add_to_group(const StringName &p_group, Node *p_node);
+ void remove_from_group(const StringName &p_group, Node *p_node);
- Group* add_to_group(const StringName& p_group, Node *p_node);
- void remove_from_group(const StringName& p_group, Node *p_node);
-
- void _notify_group_pause(const StringName& p_group,int p_notification);
- void _call_input_pause(const StringName& p_group,const StringName& p_method,const InputEvent& p_input);
- Variant _call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
-
+ void _notify_group_pause(const StringName &p_group, int p_notification);
+ void _call_input_pause(const StringName &p_group, const StringName &p_method, const InputEvent &p_input);
+ Variant _call_group(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
static void _debugger_request_tree(void *self);
void _flush_delete_queue();
-//optimization
-friend class CanvasItem;
-friend class Spatial;
-friend class Viewport;
+ //optimization
+ friend class CanvasItem;
+ friend class Spatial;
+ friend class Viewport;
SelfList<Node>::List xform_change_list;
#ifdef DEBUG_ENABLED
- Map<int,NodePath> live_edit_node_path_cache;
- Map<int,String> live_edit_resource_cache;
+ Map<int, NodePath> live_edit_node_path_cache;
+ Map<int, String> live_edit_resource_cache;
NodePath live_edit_root;
String live_edit_scene;
- Map<String,Set<Node*> > live_scene_edit_cache;
- Map<Node*,Map<ObjectID,Node*> > live_edit_remove_list;
+ Map<String, Set<Node *> > live_scene_edit_cache;
+ Map<Node *, Map<ObjectID, Node *> > live_edit_remove_list;
ScriptDebugger::LiveEditFuncs live_edit_funcs;
- void _live_edit_node_path_func(const NodePath &p_path,int p_id) ;
- void _live_edit_res_path_func(const String &p_path,int p_id) ;
+ void _live_edit_node_path_func(const NodePath &p_path, int p_id);
+ void _live_edit_res_path_func(const String &p_path, int p_id);
- void _live_edit_node_set_func(int p_id,const StringName& p_prop,const Variant& p_value) ;
- void _live_edit_node_set_res_func(int p_id,const StringName& p_prop,const String& p_value) ;
- void _live_edit_node_call_func(int p_id,const StringName& p_method,VARIANT_ARG_DECLARE) ;
- void _live_edit_res_set_func(int p_id,const StringName& p_prop,const Variant& p_value) ;
- void _live_edit_res_set_res_func(int p_id,const StringName& p_prop,const String& p_value) ;
- void _live_edit_res_call_func(int p_id,const StringName& p_method,VARIANT_ARG_DECLARE) ;
- void _live_edit_root_func(const NodePath& p_scene_path,const String& p_scene_from) ;
+ void _live_edit_node_set_func(int p_id, const StringName &p_prop, const Variant &p_value);
+ void _live_edit_node_set_res_func(int p_id, const StringName &p_prop, const String &p_value);
+ void _live_edit_node_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE);
+ void _live_edit_res_set_func(int p_id, const StringName &p_prop, const Variant &p_value);
+ void _live_edit_res_set_res_func(int p_id, const StringName &p_prop, const String &p_value);
+ void _live_edit_res_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE);
+ void _live_edit_root_func(const NodePath &p_scene_path, const String &p_scene_from);
- void _live_edit_create_node_func(const NodePath& p_parent,const String& p_type,const String& p_name);
- void _live_edit_instance_node_func(const NodePath& p_parent,const String& p_path,const String& p_name);
- void _live_edit_remove_node_func(const NodePath& p_at);
- void _live_edit_remove_and_keep_node_func(const NodePath& p_at,ObjectID p_keep_id);
- void _live_edit_restore_node_func(ObjectID p_id,const NodePath& p_at,int p_at_pos);
- void _live_edit_duplicate_node_func(const NodePath& p_at,const String& p_new_name);
- void _live_edit_reparent_node_func(const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos);
+ void _live_edit_create_node_func(const NodePath &p_parent, const String &p_type, const String &p_name);
+ void _live_edit_instance_node_func(const NodePath &p_parent, const String &p_path, const String &p_name);
+ void _live_edit_remove_node_func(const NodePath &p_at);
+ void _live_edit_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_keep_id);
+ void _live_edit_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_at_pos);
+ void _live_edit_duplicate_node_func(const NodePath &p_at, const String &p_new_name);
+ void _live_edit_reparent_node_func(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos);
- static void _live_edit_node_path_funcs(void *self,const NodePath &p_path,int p_id) { reinterpret_cast<SceneTree*>(self)->_live_edit_node_path_func(p_path,p_id); }
- static void _live_edit_res_path_funcs(void *self,const String &p_path,int p_id) { reinterpret_cast<SceneTree*>(self)->_live_edit_res_path_func(p_path,p_id); }
+ static void _live_edit_node_path_funcs(void *self, const NodePath &p_path, int p_id) { reinterpret_cast<SceneTree *>(self)->_live_edit_node_path_func(p_path, p_id); }
+ static void _live_edit_res_path_funcs(void *self, const String &p_path, int p_id) { reinterpret_cast<SceneTree *>(self)->_live_edit_res_path_func(p_path, p_id); }
- static void _live_edit_node_set_funcs(void *self,int p_id,const StringName& p_prop,const Variant& p_value) { reinterpret_cast<SceneTree*>(self)->_live_edit_node_set_func(p_id,p_prop,p_value); }
- static void _live_edit_node_set_res_funcs(void *self,int p_id,const StringName& p_prop,const String& p_value) { reinterpret_cast<SceneTree*>(self)->_live_edit_node_set_res_func(p_id,p_prop,p_value); }
- static void _live_edit_node_call_funcs(void *self,int p_id,const StringName& p_method,VARIANT_ARG_DECLARE) { reinterpret_cast<SceneTree*>(self)->_live_edit_node_call_func(p_id,p_method,VARIANT_ARG_PASS); }
- static void _live_edit_res_set_funcs(void *self,int p_id,const StringName& p_prop,const Variant& p_value) { reinterpret_cast<SceneTree*>(self)->_live_edit_res_set_func(p_id,p_prop,p_value); }
- static void _live_edit_res_set_res_funcs(void *self,int p_id,const StringName& p_prop,const String& p_value) { reinterpret_cast<SceneTree*>(self)->_live_edit_res_set_res_func(p_id,p_prop,p_value); }
- static void _live_edit_res_call_funcs(void *self,int p_id,const StringName& p_method,VARIANT_ARG_DECLARE) { reinterpret_cast<SceneTree*>(self)->_live_edit_res_call_func(p_id,p_method,VARIANT_ARG_PASS); }
- static void _live_edit_root_funcs(void *self, const NodePath& p_scene_path,const String& p_scene_from) { reinterpret_cast<SceneTree*>(self)->_live_edit_root_func(p_scene_path,p_scene_from); }
+ static void _live_edit_node_set_funcs(void *self, int p_id, const StringName &p_prop, const Variant &p_value) { reinterpret_cast<SceneTree *>(self)->_live_edit_node_set_func(p_id, p_prop, p_value); }
+ static void _live_edit_node_set_res_funcs(void *self, int p_id, const StringName &p_prop, const String &p_value) { reinterpret_cast<SceneTree *>(self)->_live_edit_node_set_res_func(p_id, p_prop, p_value); }
+ static void _live_edit_node_call_funcs(void *self, int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) { reinterpret_cast<SceneTree *>(self)->_live_edit_node_call_func(p_id, p_method, VARIANT_ARG_PASS); }
+ static void _live_edit_res_set_funcs(void *self, int p_id, const StringName &p_prop, const Variant &p_value) { reinterpret_cast<SceneTree *>(self)->_live_edit_res_set_func(p_id, p_prop, p_value); }
+ static void _live_edit_res_set_res_funcs(void *self, int p_id, const StringName &p_prop, const String &p_value) { reinterpret_cast<SceneTree *>(self)->_live_edit_res_set_res_func(p_id, p_prop, p_value); }
+ static void _live_edit_res_call_funcs(void *self, int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) { reinterpret_cast<SceneTree *>(self)->_live_edit_res_call_func(p_id, p_method, VARIANT_ARG_PASS); }
+ static void _live_edit_root_funcs(void *self, const NodePath &p_scene_path, const String &p_scene_from) { reinterpret_cast<SceneTree *>(self)->_live_edit_root_func(p_scene_path, p_scene_from); }
- static void _live_edit_create_node_funcs(void* self,const NodePath& p_parent,const String& p_type,const String& p_name) { reinterpret_cast<SceneTree*>(self)->_live_edit_create_node_func(p_parent,p_type,p_name); }
- static void _live_edit_instance_node_funcs(void* self,const NodePath& p_parent,const String& p_path,const String& p_name) { reinterpret_cast<SceneTree*>(self)->_live_edit_instance_node_func(p_parent,p_path,p_name); }
- static void _live_edit_remove_node_funcs(void* self,const NodePath& p_at) { reinterpret_cast<SceneTree*>(self)->_live_edit_remove_node_func(p_at); }
- static void _live_edit_remove_and_keep_node_funcs(void* self,const NodePath& p_at,ObjectID p_keep_id) { reinterpret_cast<SceneTree*>(self)->_live_edit_remove_and_keep_node_func(p_at,p_keep_id); }
- static void _live_edit_restore_node_funcs(void* self,ObjectID p_id,const NodePath& p_at,int p_at_pos) { reinterpret_cast<SceneTree*>(self)->_live_edit_restore_node_func(p_id,p_at,p_at_pos); }
- static void _live_edit_duplicate_node_funcs(void* self,const NodePath& p_at,const String& p_new_name) { reinterpret_cast<SceneTree*>(self)->_live_edit_duplicate_node_func(p_at,p_new_name); }
- static void _live_edit_reparent_node_funcs(void* self,const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name,int p_at_pos) { reinterpret_cast<SceneTree*>(self)->_live_edit_reparent_node_func(p_at,p_new_place,p_new_name,p_at_pos); }
+ static void _live_edit_create_node_funcs(void *self, const NodePath &p_parent, const String &p_type, const String &p_name) { reinterpret_cast<SceneTree *>(self)->_live_edit_create_node_func(p_parent, p_type, p_name); }
+ static void _live_edit_instance_node_funcs(void *self, const NodePath &p_parent, const String &p_path, const String &p_name) { reinterpret_cast<SceneTree *>(self)->_live_edit_instance_node_func(p_parent, p_path, p_name); }
+ static void _live_edit_remove_node_funcs(void *self, const NodePath &p_at) { reinterpret_cast<SceneTree *>(self)->_live_edit_remove_node_func(p_at); }
+ static void _live_edit_remove_and_keep_node_funcs(void *self, const NodePath &p_at, ObjectID p_keep_id) { reinterpret_cast<SceneTree *>(self)->_live_edit_remove_and_keep_node_func(p_at, p_keep_id); }
+ static void _live_edit_restore_node_funcs(void *self, ObjectID p_id, const NodePath &p_at, int p_at_pos) { reinterpret_cast<SceneTree *>(self)->_live_edit_restore_node_func(p_id, p_at, p_at_pos); }
+ static void _live_edit_duplicate_node_funcs(void *self, const NodePath &p_at, const String &p_new_name) { reinterpret_cast<SceneTree *>(self)->_live_edit_duplicate_node_func(p_at, p_new_name); }
+ static void _live_edit_reparent_node_funcs(void *self, const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) { reinterpret_cast<SceneTree *>(self)->_live_edit_reparent_node_func(p_at, p_new_place, p_new_name, p_at_pos); }
#endif
protected:
-
void _notification(int p_notification);
static void _bind_methods();
public:
-
enum {
- NOTIFICATION_TRANSFORM_CHANGED=29
+ NOTIFICATION_TRANSFORM_CHANGED = 29
};
enum CallGroupFlags {
- GROUP_CALL_DEFAULT=0,
- GROUP_CALL_REVERSE=1,
- GROUP_CALL_REALTIME=2,
- GROUP_CALL_UNIQUE=4,
- GROUP_CALL_MULIILEVEL=8,
+ GROUP_CALL_DEFAULT = 0,
+ GROUP_CALL_REVERSE = 1,
+ GROUP_CALL_REALTIME = 2,
+ GROUP_CALL_UNIQUE = 4,
+ GROUP_CALL_MULIILEVEL = 8,
};
_FORCE_INLINE_ Viewport *get_root() const { return root; }
uint32_t get_last_event_id() const;
- void call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_LIST);
- void notify_group(uint32_t p_call_flags,const StringName& p_group,int p_notification);
- void set_group(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value);
-
+ void call_group(uint32_t p_call_flags, const StringName &p_group, const StringName &p_function, VARIANT_ARG_LIST);
+ void notify_group(uint32_t p_call_flags, const StringName &p_group, int p_notification);
+ void set_group(uint32_t p_call_flags, const StringName &p_group, const String &p_name, const Variant &p_value);
- virtual void input_text( const String& p_text );
- virtual void input_event( const InputEvent& p_event );
+ virtual void input_text(const String &p_text);
+ virtual void input_event(const InputEvent &p_event);
virtual void init();
virtual bool iteration(float p_time);
@@ -279,12 +268,12 @@ public:
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;
- bool is_node_being_edited(const Node* p_node) const;
+ bool is_node_being_edited(const Node *p_node) const;
void set_pause(bool p_enabled);
bool is_paused() const;
- void set_camera(const RID& p_camera);
+ void set_camera(const RID &p_camera);
RID get_camera() const;
void set_debug_collisions_hint(bool p_enabled);
@@ -293,19 +282,18 @@ public:
void set_debug_navigation_hint(bool p_enabled);
bool is_debugging_navigation_hint() const;
- void set_debug_collisions_color(const Color& p_color);
+ void set_debug_collisions_color(const Color &p_color);
Color get_debug_collisions_color() const;
- void set_debug_collision_contact_color(const Color& p_color);
+ void set_debug_collision_contact_color(const Color &p_color);
Color get_debug_collision_contact_color() const;
- void set_debug_navigation_color(const Color& p_color);
+ void set_debug_navigation_color(const Color &p_color);
Color get_debug_navigation_color() const;
- void set_debug_navigation_disabled_color(const Color& p_color);
+ void set_debug_navigation_disabled_color(const Color &p_color);
Color get_debug_navigation_disabled_color() const;
-
Ref<Material> get_debug_navigation_material();
Ref<Material> get_debug_navigation_disabled_material();
Ref<Material> get_debug_collision_material();
@@ -319,42 +307,37 @@ public:
void queue_delete(Object *p_object);
- void get_nodes_in_group(const StringName& p_group,List<Node*> *p_list);
- bool has_group(const StringName& p_identifier) const;
+ void get_nodes_in_group(const StringName &p_group, List<Node *> *p_list);
+ bool has_group(const StringName &p_identifier) const;
+ void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize);
- void set_screen_stretch(StretchMode p_mode,StretchAspect p_aspect,const Size2 p_minsize);
-
- //void change_scene(const String& p_path);
- //Node *get_loaded_scene();
+//void change_scene(const String& p_path);
+//Node *get_loaded_scene();
#ifdef TOOLS_ENABLED
void set_edited_scene_root(Node *p_node);
Node *get_edited_scene_root() const;
#endif
- void set_current_scene(Node* p_scene);
- Node* get_current_scene() const;
- Error change_scene(const String& p_path);
- Error change_scene_to(const Ref<PackedScene>& p_scene);
+ void set_current_scene(Node *p_scene);
+ Node *get_current_scene() const;
+ Error change_scene(const String &p_path);
+ Error change_scene_to(const Ref<PackedScene> &p_scene);
Error reload_current_scene();
//used by Main::start, don't use otherwise
- void add_current_scene(Node * p_current);
+ void add_current_scene(Node *p_current);
- static SceneTree* get_singleton() { return singleton; }
+ static SceneTree *get_singleton() { return singleton; }
- void drop_files(const Vector<String>& p_files,int p_from_screen=0);
+ void drop_files(const Vector<String> &p_files, int p_from_screen = 0);
SceneTree();
~SceneTree();
-
};
-
-VARIANT_ENUM_CAST( SceneTree::StretchMode );
-VARIANT_ENUM_CAST( SceneTree::StretchAspect );
-
-
+VARIANT_ENUM_CAST(SceneTree::StretchMode);
+VARIANT_ENUM_CAST(SceneTree::StretchAspect);
#endif
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 721e9a56c..1010e76ba 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -28,21 +28,19 @@
/*************************************************************************/
#include "timer.h"
-
void Timer::_notification(int p_what) {
- switch(p_what) {
-
+ switch (p_what) {
case NOTIFICATION_READY: {
if (autostart) {
#ifdef TOOLS_ENABLED
- if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root()==this || get_tree()->get_edited_scene_root()->is_a_parent_of(this)))
+ if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this)))
break;
#endif
start();
- autostart=false;
+ autostart = false;
}
} break;
case NOTIFICATION_PROCESS: {
@@ -50,7 +48,7 @@ void Timer::_notification(int p_what) {
return;
time_left -= get_process_delta_time();
- if (time_left<0) {
+ if (time_left < 0) {
if (!one_shot)
//time_left=wait_time+time_left;
time_left = wait_time;
@@ -66,7 +64,7 @@ void Timer::_notification(int p_what) {
return;
time_left -= get_fixed_process_delta_time();
- if (time_left<0) {
+ if (time_left < 0) {
if (!one_shot)
//time_left = wait_time + time_left;
time_left = wait_time;
@@ -79,13 +77,10 @@ void Timer::_notification(int p_what) {
}
}
-
-
void Timer::set_wait_time(float p_time) {
ERR_EXPLAIN("time should be greater than zero.");
- ERR_FAIL_COND(p_time<=0);
- wait_time=p_time;
-
+ ERR_FAIL_COND(p_time <= 0);
+ wait_time = p_time;
}
float Timer::get_wait_time() const {
@@ -94,7 +89,7 @@ float Timer::get_wait_time() const {
void Timer::set_one_shot(bool p_one_shot) {
- one_shot=p_one_shot;
+ one_shot = p_one_shot;
}
bool Timer::is_one_shot() const {
@@ -103,7 +98,7 @@ bool Timer::is_one_shot() const {
void Timer::set_autostart(bool p_start) {
- autostart=p_start;
+ autostart = p_start;
}
bool Timer::has_autostart() const {
@@ -111,24 +106,22 @@ bool Timer::has_autostart() const {
}
void Timer::start() {
- time_left=wait_time;
+ time_left = wait_time;
_set_process(true);
}
void Timer::stop() {
- time_left=-1;
+ time_left = -1;
_set_process(false);
- autostart=false;
+ autostart = false;
}
-
void Timer::set_active(bool p_active) {
if (active == p_active)
return;
active = p_active;
_set_process(processing);
-
}
bool Timer::is_active() const {
@@ -137,7 +130,7 @@ bool Timer::is_active() const {
float Timer::get_time_left() const {
- return time_left >0 ? time_left : 0;
+ return time_left > 0 ? time_left : 0;
}
void Timer::set_timer_process_mode(TimerProcessMode p_mode) {
@@ -151,25 +144,23 @@ void Timer::set_timer_process_mode(TimerProcessMode p_mode) {
set_fixed_process(false);
set_process(true);
}
- break;
+ break;
case TIMER_PROCESS_IDLE:
if (is_processing()) {
set_process(false);
set_fixed_process(true);
}
- break;
+ break;
}
timer_process_mode = p_mode;
}
-Timer::TimerProcessMode Timer::get_timer_process_mode() const{
+Timer::TimerProcessMode Timer::get_timer_process_mode() const {
return timer_process_mode;
}
-
-void Timer::_set_process(bool p_process, bool p_force)
-{
+void Timer::_set_process(bool p_process, bool p_force) {
switch (timer_process_mode) {
case TIMER_PROCESS_FIXED: set_fixed_process(p_process && active); break;
case TIMER_PROCESS_IDLE: set_process(p_process && active); break;
@@ -179,43 +170,42 @@ void Timer::_set_process(bool p_process, bool p_force)
void Timer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_wait_time","time_sec"),&Timer::set_wait_time);
- ObjectTypeDB::bind_method(_MD("get_wait_time"),&Timer::get_wait_time);
+ ObjectTypeDB::bind_method(_MD("set_wait_time", "time_sec"), &Timer::set_wait_time);
+ ObjectTypeDB::bind_method(_MD("get_wait_time"), &Timer::get_wait_time);
- ObjectTypeDB::bind_method(_MD("set_one_shot","enable"),&Timer::set_one_shot);
- ObjectTypeDB::bind_method(_MD("is_one_shot"),&Timer::is_one_shot);
+ ObjectTypeDB::bind_method(_MD("set_one_shot", "enable"), &Timer::set_one_shot);
+ ObjectTypeDB::bind_method(_MD("is_one_shot"), &Timer::is_one_shot);
- ObjectTypeDB::bind_method(_MD("set_autostart","enable"),&Timer::set_autostart);
- ObjectTypeDB::bind_method(_MD("has_autostart"),&Timer::has_autostart);
+ ObjectTypeDB::bind_method(_MD("set_autostart", "enable"), &Timer::set_autostart);
+ ObjectTypeDB::bind_method(_MD("has_autostart"), &Timer::has_autostart);
- ObjectTypeDB::bind_method(_MD("start"),&Timer::start);
- ObjectTypeDB::bind_method(_MD("stop"),&Timer::stop);
+ ObjectTypeDB::bind_method(_MD("start"), &Timer::start);
+ ObjectTypeDB::bind_method(_MD("stop"), &Timer::stop);
ObjectTypeDB::bind_method(_MD("set_active", "active"), &Timer::set_active);
ObjectTypeDB::bind_method(_MD("is_active"), &Timer::is_active);
- ObjectTypeDB::bind_method(_MD("get_time_left"),&Timer::get_time_left);
+ ObjectTypeDB::bind_method(_MD("get_time_left"), &Timer::get_time_left);
ObjectTypeDB::bind_method(_MD("set_timer_process_mode", "mode"), &Timer::set_timer_process_mode);
ObjectTypeDB::bind_method(_MD("get_timer_process_mode"), &Timer::get_timer_process_mode);
- ADD_SIGNAL( MethodInfo("timeout") );
-
- ADD_PROPERTY( PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_timer_process_mode"), _SCS("get_timer_process_mode") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.01,4096,0.01" ), _SCS("set_wait_time"), _SCS("get_wait_time") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "one_shot" ), _SCS("set_one_shot"), _SCS("is_one_shot") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autostart" ), _SCS("set_autostart"), _SCS("has_autostart") );
+ ADD_SIGNAL(MethodInfo("timeout"));
- BIND_CONSTANT( TIMER_PROCESS_FIXED );
- BIND_CONSTANT( TIMER_PROCESS_IDLE );
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), _SCS("set_timer_process_mode"), _SCS("get_timer_process_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.01,4096,0.01"), _SCS("set_wait_time"), _SCS("get_wait_time"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), _SCS("set_one_shot"), _SCS("is_one_shot"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autostart"), _SCS("set_autostart"), _SCS("has_autostart"));
+ BIND_CONSTANT(TIMER_PROCESS_FIXED);
+ BIND_CONSTANT(TIMER_PROCESS_IDLE);
}
Timer::Timer() {
timer_process_mode = TIMER_PROCESS_IDLE;
- autostart=false;
- wait_time=1;
- one_shot=false;
+ autostart = false;
+ wait_time = 1;
+ one_shot = false;
time_left = -1;
processing = false;
active = true;
diff --git a/scene/main/timer.h b/scene/main/timer.h
index ea8d24b3a..024dbfd1c 100644
--- a/scene/main/timer.h
+++ b/scene/main/timer.h
@@ -33,7 +33,7 @@
class Timer : public Node {
- OBJ_TYPE( Timer, Node );
+ OBJ_TYPE(Timer, Node);
float wait_time;
bool one_shot;
@@ -42,12 +42,12 @@ class Timer : public Node {
bool active;
double time_left;
-protected:
+protected:
void _notification(int p_what);
static void _bind_methods();
-public:
+public:
enum TimerProcessMode {
TIMER_PROCESS_FIXED,
TIMER_PROCESS_IDLE,
@@ -76,7 +76,6 @@ public:
private:
TimerProcessMode timer_process_mode;
void _set_process(bool p_process, bool p_force = false);
-
};
VARIANT_ENUM_CAST(Timer::TimerProcessMode);
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 0068ac57f..d37f95641 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -27,25 +27,25 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "viewport.h"
+#include "os/input.h"
#include "os/os.h"
#include "scene/3d/spatial.h"
-#include "os/input.h"
#include "servers/physics_2d_server.h"
//#include "scene/3d/camera.h"
-#include "servers/spatial_sound_server.h"
-#include "servers/spatial_sound_2d_server.h"
-#include "scene/gui/control.h"
#include "scene/3d/camera.h"
+#include "scene/3d/collision_object.h"
#include "scene/3d/listener.h"
-#include "scene/resources/mesh.h"
#include "scene/3d/spatial_indexer.h"
-#include "scene/3d/collision_object.h"
+#include "scene/gui/control.h"
+#include "scene/resources/mesh.h"
+#include "servers/spatial_sound_2d_server.h"
+#include "servers/spatial_sound_server.h"
#include "scene/2d/collision_object_2d.h"
-#include "scene/gui/panel.h"
#include "scene/gui/label.h"
+#include "scene/gui/panel.h"
#include "scene/main/timer.h"
#include "scene/scene_string_names.h"
@@ -53,88 +53,82 @@
int RenderTargetTexture::get_width() const {
- ERR_FAIL_COND_V(!vp,0);
+ ERR_FAIL_COND_V(!vp, 0);
return vp->rect.size.width;
}
-int RenderTargetTexture::get_height() const{
+int RenderTargetTexture::get_height() const {
- ERR_FAIL_COND_V(!vp,0);
+ ERR_FAIL_COND_V(!vp, 0);
return vp->rect.size.height;
}
-Size2 RenderTargetTexture::get_size() const{
+Size2 RenderTargetTexture::get_size() const {
- ERR_FAIL_COND_V(!vp,Size2());
+ ERR_FAIL_COND_V(!vp, Size2());
return vp->rect.size;
}
-RID RenderTargetTexture::get_rid() const{
+RID RenderTargetTexture::get_rid() const {
- ERR_FAIL_COND_V(!vp,RID());
+ ERR_FAIL_COND_V(!vp, RID());
return vp->render_target_texture_rid;
}
-bool RenderTargetTexture::has_alpha() const{
+bool RenderTargetTexture::has_alpha() const {
return false;
}
-void RenderTargetTexture::set_flags(uint32_t p_flags){
+void RenderTargetTexture::set_flags(uint32_t p_flags) {
ERR_FAIL_COND(!vp);
- if (p_flags&FLAG_FILTER)
- flags=FLAG_FILTER;
+ if (p_flags & FLAG_FILTER)
+ flags = FLAG_FILTER;
else
- flags=0;
-
- VS::get_singleton()->texture_set_flags(vp->render_target_texture_rid,flags);
+ flags = 0;
+ VS::get_singleton()->texture_set_flags(vp->render_target_texture_rid, flags);
}
-uint32_t RenderTargetTexture::get_flags() const{
+uint32_t RenderTargetTexture::get_flags() const {
return flags;
}
-RenderTargetTexture::RenderTargetTexture(Viewport *p_vp){
+RenderTargetTexture::RenderTargetTexture(Viewport *p_vp) {
- vp=p_vp;
- flags=0;
+ vp = p_vp;
+ flags = 0;
}
/////////////////////////////////////
class TooltipPanel : public Panel {
- OBJ_TYPE(TooltipPanel,Panel)
+ OBJ_TYPE(TooltipPanel, Panel)
public:
- TooltipPanel() {};
-
+ TooltipPanel(){};
};
class TooltipLabel : public Label {
- OBJ_TYPE(TooltipLabel,Label)
+ OBJ_TYPE(TooltipLabel, Label)
public:
- TooltipLabel() {};
-
+ TooltipLabel(){};
};
-
Viewport::GUI::GUI() {
+ mouse_focus = NULL;
+ mouse_focus_button = -1;
+ key_focus = NULL;
+ mouse_over = NULL;
- mouse_focus=NULL;
- mouse_focus_button=-1;
- key_focus=NULL;
- mouse_over=NULL;
-
- cancelled_input_ID=0;
- tooltip=NULL;
- tooltip_popup=NULL;
- tooltip_label=NULL;
- subwindow_order_dirty=false;
+ cancelled_input_ID = 0;
+ tooltip = NULL;
+ tooltip_popup = NULL;
+ tooltip_label = NULL;
+ subwindow_order_dirty = false;
}
-
/////////////////////////////////////
void Viewport::_update_stretch_transform() {
@@ -142,20 +136,17 @@ void Viewport::_update_stretch_transform() {
//print_line("sive override size "+size_override_size);
//print_line("rect size "+rect.size);
- stretch_transform=Matrix32();
- Size2 scale = rect.size/(size_override_size+size_override_margin*2);
+ stretch_transform = Matrix32();
+ Size2 scale = rect.size / (size_override_size + size_override_margin * 2);
stretch_transform.scale(scale);
- stretch_transform.elements[2]=size_override_margin*scale;
-
+ stretch_transform.elements[2] = size_override_margin * scale;
} else {
-
- stretch_transform=Matrix32();
+ stretch_transform = Matrix32();
}
_update_global_transform();
-
}
void Viewport::_update_rect() {
@@ -163,37 +154,34 @@ void Viewport::_update_rect() {
if (!is_inside_tree())
return;
-
if (!render_target && parent_control) {
Control *c = parent_control;
- rect.pos=Point2();
- rect.size=c->get_size();
+ rect.pos = Point2();
+ rect.size = c->get_size();
}
VisualServer::ViewportRect vr;
- vr.x=rect.pos.x;
- vr.y=rect.pos.y;
+ vr.x = rect.pos.x;
+ vr.y = rect.pos.y;
if (render_target) {
- vr.x=0;
- vr.y=0;
+ vr.x = 0;
+ vr.y = 0;
}
- vr.width=rect.size.width;
- vr.height=rect.size.height;
+ vr.width = rect.size.width;
+ vr.height = rect.size.height;
- VisualServer::get_singleton()->viewport_set_rect(viewport,vr);
- last_vp_rect=rect;
+ VisualServer::get_singleton()->viewport_set_rect(viewport, vr);
+ last_vp_rect = rect;
if (canvas_item.is_valid()) {
- VisualServer::get_singleton()->canvas_item_set_custom_rect(canvas_item,true,rect);
+ VisualServer::get_singleton()->canvas_item_set_custom_rect(canvas_item, true, rect);
}
emit_signal("size_changed");
render_target_texture->emit_changed();
-
-
}
void Viewport::_parent_resized() {
@@ -202,92 +190,79 @@ void Viewport::_parent_resized() {
}
void Viewport::_parent_draw() {
-
}
void Viewport::_parent_visibility_changed() {
-
if (parent_control) {
Control *c = parent_control;
- VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,c->is_visible());
+ VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, c->is_visible());
_update_listener();
_update_listener_2d();
}
-
-
}
-
void Viewport::_vp_enter_tree() {
if (parent_control) {
- Control *cparent=parent_control;
+ Control *cparent = parent_control;
RID parent_ci = cparent->get_canvas_item();
ERR_FAIL_COND(!parent_ci.is_valid());
canvas_item = VisualServer::get_singleton()->canvas_item_create();
- VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent_ci);
- VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false);
- VisualServer::get_singleton()->canvas_item_attach_viewport(canvas_item,viewport);
- parent_control->connect("resized",this,"_parent_resized");
- parent_control->connect("visibility_changed",this,"_parent_visibility_changed");
- } else if (!parent){
-
- VisualServer::get_singleton()->viewport_attach_to_screen(viewport,0);
+ VisualServer::get_singleton()->canvas_item_set_parent(canvas_item, parent_ci);
+ VisualServer::get_singleton()->canvas_item_set_visible(canvas_item, false);
+ VisualServer::get_singleton()->canvas_item_attach_viewport(canvas_item, viewport);
+ parent_control->connect("resized", this, "_parent_resized");
+ parent_control->connect("visibility_changed", this, "_parent_visibility_changed");
+ } else if (!parent) {
+ VisualServer::get_singleton()->viewport_attach_to_screen(viewport, 0);
}
-
-
}
void Viewport::_vp_exit_tree() {
if (parent_control) {
- parent_control->disconnect("resized",this,"_parent_resized");
+ parent_control->disconnect("resized", this, "_parent_resized");
}
if (parent_control) {
- parent_control->disconnect("visibility_changed",this,"_parent_visibility_changed");
+ parent_control->disconnect("visibility_changed", this, "_parent_visibility_changed");
}
if (canvas_item.is_valid()) {
VisualServer::get_singleton()->free(canvas_item);
- canvas_item=RID();
-
+ canvas_item = RID();
}
if (!parent) {
VisualServer::get_singleton()->viewport_detach(viewport);
-
}
-
}
-
void Viewport::update_worlds() {
if (!is_inside_tree())
return;
Rect2 xformed_rect = (global_canvas_transform * canvas_transform).affine_inverse().xform(get_visible_rect());
- find_world_2d()->_update_viewport(this,xformed_rect);
+ find_world_2d()->_update_viewport(this, xformed_rect);
find_world_2d()->_update();
find_world()->_update(get_tree()->get_frame());
}
-
void Viewport::_test_new_mouseover(ObjectID new_collider) {
#ifndef _3D_DISABLED
- if (new_collider!=physics_object_over) {
+ if (new_collider != physics_object_over) {
if (physics_object_over) {
Object *obj = ObjectDB::get_instance(physics_object_over);
@@ -305,90 +280,80 @@ void Viewport::_test_new_mouseover(ObjectID new_collider) {
CollisionObject *co = obj->cast_to<CollisionObject>();
if (co) {
co->_mouse_enter();
-
}
}
-
}
- physics_object_over=new_collider;
-
+ physics_object_over = new_collider;
}
#endif
-
}
void Viewport::_notification(int p_what) {
-
- switch( p_what ) {
+ switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
if (get_parent()) {
- Node *parent=get_parent();
+ Node *parent = get_parent();
if (parent) {
- parent_control=parent->cast_to<Control>();
+ parent_control = parent->cast_to<Control>();
}
}
+ parent = NULL;
+ Node *parent_node = get_parent();
- parent=NULL;
- Node *parent_node=get_parent();
-
-
- while(parent_node) {
+ while (parent_node) {
parent = parent_node->cast_to<Viewport>();
if (parent)
break;
- parent_node=parent_node->get_parent();
+ parent_node = parent_node->get_parent();
}
-
if (!render_target)
_vp_enter_tree();
-
- current_canvas=find_world_2d()->get_canvas();
- VisualServer::get_singleton()->viewport_set_scenario(viewport,find_world()->get_scenario());
- VisualServer::get_singleton()->viewport_attach_canvas(viewport,current_canvas);
+ current_canvas = find_world_2d()->get_canvas();
+ VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
+ VisualServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas);
_update_listener();
_update_listener_2d();
_update_rect();
- find_world_2d()->_register_viewport(this,Rect2());
+ find_world_2d()->_register_viewport(this, Rect2());
add_to_group("_viewports");
if (get_tree()->is_debugging_collisions_hint()) {
//2D
- Physics2DServer::get_singleton()->space_set_debug_contacts(find_world_2d()->get_space(),get_tree()->get_collision_debug_contact_count());
- contact_2d_debug=VisualServer::get_singleton()->canvas_item_create();
- VisualServer::get_singleton()->canvas_item_set_parent(contact_2d_debug,find_world_2d()->get_canvas());
+ Physics2DServer::get_singleton()->space_set_debug_contacts(find_world_2d()->get_space(), get_tree()->get_collision_debug_contact_count());
+ contact_2d_debug = VisualServer::get_singleton()->canvas_item_create();
+ VisualServer::get_singleton()->canvas_item_set_parent(contact_2d_debug, find_world_2d()->get_canvas());
//3D
- PhysicsServer::get_singleton()->space_set_debug_contacts(find_world()->get_space(),get_tree()->get_collision_debug_contact_count());
- contact_3d_debug_multimesh=VisualServer::get_singleton()->multimesh_create();
- VisualServer::get_singleton()->multimesh_set_instance_count(contact_3d_debug_multimesh,get_tree()->get_collision_debug_contact_count());
- VisualServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh,0);
- VisualServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh,get_tree()->get_debug_contact_mesh()->get_rid());
- contact_3d_debug_instance=VisualServer::get_singleton()->instance_create();
- VisualServer::get_singleton()->instance_set_base(contact_3d_debug_instance,contact_3d_debug_multimesh);
- VisualServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance,find_world()->get_scenario());
- VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance,VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,true);
-
+ PhysicsServer::get_singleton()->space_set_debug_contacts(find_world()->get_space(), get_tree()->get_collision_debug_contact_count());
+ contact_3d_debug_multimesh = VisualServer::get_singleton()->multimesh_create();
+ VisualServer::get_singleton()->multimesh_set_instance_count(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count());
+ VisualServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, 0);
+ VisualServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh, get_tree()->get_debug_contact_mesh()->get_rid());
+ contact_3d_debug_instance = VisualServer::get_singleton()->instance_create();
+ VisualServer::get_singleton()->instance_set_base(contact_3d_debug_instance, contact_3d_debug_multimesh);
+ VisualServer::get_singleton()->instance_set_scenario(contact_3d_debug_instance, find_world()->get_scenario());
+ VisualServer::get_singleton()->instance_geometry_set_flag(contact_3d_debug_instance, VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS, true);
}
} break;
case NOTIFICATION_READY: {
#ifndef _3D_DISABLED
if (listeners.size() && !listener) {
- Listener *first=NULL;
- for(Set<Listener*>::Element *E=listeners.front();E;E=E->next()) {
+ Listener *first = NULL;
+ for (Set<Listener *>::Element *E = listeners.front(); E; E = E->next()) {
- if (first==NULL || first->is_greater_than(E->get())) {
- first=E->get();
+ if (first == NULL || first->is_greater_than(E->get())) {
+ first = E->get();
}
}
@@ -398,11 +363,11 @@ void Viewport::_notification(int p_what) {
if (cameras.size() && !camera) {
//there are cameras but no current camera, pick first in tree and make it current
- Camera *first=NULL;
- for(Set<Camera*>::Element *E=cameras.front();E;E=E->next()) {
+ Camera *first = NULL;
+ for (Set<Camera *>::Element *E = cameras.front(); E; E = E->next()) {
- if (first==NULL || first->is_greater_than(E->get())) {
- first=E->get();
+ if (first == NULL || first->is_greater_than(E->get())) {
+ first = E->get();
}
}
@@ -413,7 +378,6 @@ void Viewport::_notification(int p_what) {
} break;
case NOTIFICATION_EXIT_TREE: {
-
_gui_cancel_tooltip();
if (world_2d.is_valid())
world_2d->_remove_viewport(this);
@@ -421,30 +385,30 @@ void Viewport::_notification(int p_what) {
if (!render_target)
_vp_exit_tree();
- VisualServer::get_singleton()->viewport_set_scenario(viewport,RID());
+ VisualServer::get_singleton()->viewport_set_scenario(viewport, RID());
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
- VisualServer::get_singleton()->viewport_remove_canvas(viewport,current_canvas);
+ VisualServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
if (contact_2d_debug.is_valid()) {
VisualServer::get_singleton()->free(contact_2d_debug);
- contact_2d_debug=RID();
+ contact_2d_debug = RID();
}
if (contact_3d_debug_multimesh.is_valid()) {
VisualServer::get_singleton()->free(contact_3d_debug_multimesh);
VisualServer::get_singleton()->free(contact_3d_debug_instance);
- contact_3d_debug_instance=RID();
- contact_3d_debug_multimesh=RID();
+ contact_3d_debug_instance = RID();
+ contact_3d_debug_multimesh = RID();
}
remove_from_group("_viewports");
- parent_control=NULL;
+ parent_control = NULL;
} break;
case NOTIFICATION_FIXED_PROCESS: {
- if (gui.tooltip_timer>=0) {
- gui.tooltip_timer-=get_fixed_process_delta_time();
- if (gui.tooltip_timer<0) {
+ if (gui.tooltip_timer >= 0) {
+ gui.tooltip_timer -= get_fixed_process_delta_time();
+ if (gui.tooltip_timer < 0) {
_gui_show_tooltip();
}
}
@@ -458,117 +422,110 @@ void Viewport::_notification(int p_what) {
int point_count = Physics2DServer::get_singleton()->space_get_contact_count(find_world_2d()->get_space());
Color ccol = get_tree()->get_debug_collision_contact_color();
+ for (int i = 0; i < point_count; i++) {
- for(int i=0;i<point_count;i++) {
-
- VisualServer::get_singleton()->canvas_item_add_rect(contact_2d_debug,Rect2(points[i]-Vector2(2,2),Vector2(5,5)),ccol);
+ VisualServer::get_singleton()->canvas_item_add_rect(contact_2d_debug, Rect2(points[i] - Vector2(2, 2), Vector2(5, 5)), ccol);
}
}
if (get_tree()->is_debugging_collisions_hint() && contact_3d_debug_multimesh.is_valid()) {
-
Vector<Vector3> points = PhysicsServer::get_singleton()->space_get_contacts(find_world()->get_space());
int point_count = PhysicsServer::get_singleton()->space_get_contact_count(find_world()->get_space());
+ VS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, point_count);
- VS::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh,point_count);
-
- if (point_count>0) {
+ if (point_count > 0) {
AABB aabb;
Transform t;
- for(int i=0;i<point_count;i++) {
+ for (int i = 0; i < point_count; i++) {
- if (i==0)
- aabb.pos=points[i];
+ if (i == 0)
+ aabb.pos = points[i];
else
aabb.expand_to(points[i]);
- t.origin=points[i];
- VisualServer::get_singleton()->multimesh_instance_set_transform(contact_3d_debug_multimesh,i,t);
+ t.origin = points[i];
+ VisualServer::get_singleton()->multimesh_instance_set_transform(contact_3d_debug_multimesh, i, t);
}
- aabb.grow(aabb.get_longest_axis_size()*0.01);
- VisualServer::get_singleton()->multimesh_set_aabb(contact_3d_debug_multimesh,aabb);
+ aabb.grow(aabb.get_longest_axis_size() * 0.01);
+ VisualServer::get_singleton()->multimesh_set_aabb(contact_3d_debug_multimesh, aabb);
}
}
+ if (physics_object_picking && (render_target || Input::get_singleton()->get_mouse_mode() != Input::MOUSE_MODE_CAPTURED)) {
-
- if (physics_object_picking && (render_target || Input::get_singleton()->get_mouse_mode()!=Input::MOUSE_MODE_CAPTURED)) {
-
- Vector2 last_pos(1e20,1e20);
+ Vector2 last_pos(1e20, 1e20);
CollisionObject *last_object;
- ObjectID last_id=0;
+ ObjectID last_id = 0;
PhysicsDirectSpaceState::RayResult result;
- Physics2DDirectSpaceState *ss2d=Physics2DServer::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
+ Physics2DDirectSpaceState *ss2d = Physics2DServer::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
- bool motion_tested=false;
+ bool motion_tested = false;
- while(physics_picking_events.size()) {
+ while (physics_picking_events.size()) {
InputEvent ev = physics_picking_events.front()->get();
physics_picking_events.pop_front();
Vector2 pos;
- switch(ev.type) {
+ switch (ev.type) {
case InputEvent::MOUSE_MOTION: {
- pos.x=ev.mouse_motion.x;
- pos.y=ev.mouse_motion.y;
- motion_tested=true;
- physics_last_mousepos=pos;
+ pos.x = ev.mouse_motion.x;
+ pos.y = ev.mouse_motion.y;
+ motion_tested = true;
+ physics_last_mousepos = pos;
} break;
case InputEvent::MOUSE_BUTTON: {
- pos.x=ev.mouse_button.x;
- pos.y=ev.mouse_button.y;
+ pos.x = ev.mouse_button.x;
+ pos.y = ev.mouse_button.y;
} break;
case InputEvent::SCREEN_DRAG: {
- pos.x=ev.screen_drag.x;
- pos.y=ev.screen_drag.y;
+ pos.x = ev.screen_drag.x;
+ pos.y = ev.screen_drag.y;
} break;
case InputEvent::SCREEN_TOUCH: {
- pos.x=ev.screen_touch.x;
- pos.y=ev.screen_touch.y;
+ pos.x = ev.screen_touch.x;
+ pos.y = ev.screen_touch.y;
} break;
-
}
if (ss2d) {
//send to 2D
-
uint64_t frame = get_tree()->get_frame();
Vector2 point = get_canvas_transform().affine_inverse().xform(pos);
Physics2DDirectSpaceState::ShapeResult res[64];
- int rc = ss2d->intersect_point(point,res,64,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF,true);
- for(int i=0;i<rc;i++) {
+ int rc = ss2d->intersect_point(point, res, 64, Set<RID>(), 0xFFFFFFFF, 0xFFFFFFFF, true);
+ for (int i = 0; i < rc; i++) {
if (res[i].collider_id && res[i].collider) {
- CollisionObject2D *co=res[i].collider->cast_to<CollisionObject2D>();
+ CollisionObject2D *co = res[i].collider->cast_to<CollisionObject2D>();
if (co) {
- Map<ObjectID,uint64_t>::Element *E=physics_2d_mouseover.find(res[i].collider_id);
+ Map<ObjectID, uint64_t>::Element *E = physics_2d_mouseover.find(res[i].collider_id);
if (!E) {
- E=physics_2d_mouseover.insert(res[i].collider_id,frame);
+ E = physics_2d_mouseover.insert(res[i].collider_id, frame);
co->_mouse_enter();
} else {
- E->get()=frame;
+ E->get() = frame;
}
- co->_input_event(this,ev,res[i].shape);
+ co->_input_event(this, ev, res[i].shape);
}
}
}
- List<Map<ObjectID,uint64_t>::Element*> to_erase;
+ List<Map<ObjectID, uint64_t>::Element *> to_erase;
- for (Map<ObjectID,uint64_t>::Element*E=physics_2d_mouseover.front();E;E=E->next()) {
- if (E->get()!=frame) {
- Object *o=ObjectDB::get_instance(E->key());
+ for (Map<ObjectID, uint64_t>::Element *E = physics_2d_mouseover.front(); E; E = E->next()) {
+ if (E->get() != frame) {
+ Object *o = ObjectDB::get_instance(E->key());
if (o) {
- CollisionObject2D *co=o->cast_to<CollisionObject2D>();
+ CollisionObject2D *co = o->cast_to<CollisionObject2D>();
if (co) {
co->_mouse_exit();
}
@@ -577,60 +534,50 @@ void Viewport::_notification(int p_what) {
}
}
- while(to_erase.size()) {
+ while (to_erase.size()) {
physics_2d_mouseover.erase(to_erase.front()->get());
to_erase.pop_front();
}
-
}
-
-
#ifndef _3D_DISABLED
- bool captured=false;
-
- if (physics_object_capture!=0) {
+ bool captured = false;
+ if (physics_object_capture != 0) {
Object *obj = ObjectDB::get_instance(physics_object_capture);
if (obj) {
CollisionObject *co = obj->cast_to<CollisionObject>();
if (co) {
- co->_input_event(camera,ev,Vector3(),Vector3(),0);
- captured=true;
- if (ev.type==InputEvent::MOUSE_BUTTON && ev.mouse_button.button_index==1 && !ev.mouse_button.pressed) {
- physics_object_capture=0;
+ co->_input_event(camera, ev, Vector3(), Vector3(), 0);
+ captured = true;
+ if (ev.type == InputEvent::MOUSE_BUTTON && ev.mouse_button.button_index == 1 && !ev.mouse_button.pressed) {
+ physics_object_capture = 0;
}
} else {
- physics_object_capture=0;
+ physics_object_capture = 0;
}
} else {
- physics_object_capture=0;
+ physics_object_capture = 0;
}
}
-
if (captured) {
//none
- } else if (pos==last_pos) {
+ } else if (pos == last_pos) {
if (last_id) {
if (ObjectDB::get_instance(last_id)) {
//good, exists
- last_object->_input_event(camera,ev,result.position,result.normal,result.shape);
- if (last_object->get_capture_input_on_drag() && ev.type==InputEvent::MOUSE_BUTTON && ev.mouse_button.button_index==1 && ev.mouse_button.pressed) {
- physics_object_capture=last_id;
+ last_object->_input_event(camera, ev, result.position, result.normal, result.shape);
+ if (last_object->get_capture_input_on_drag() && ev.type == InputEvent::MOUSE_BUTTON && ev.mouse_button.button_index == 1 && ev.mouse_button.pressed) {
+ physics_object_capture = last_id;
}
-
-
}
}
} else {
-
-
-
if (camera) {
Vector3 from = camera->project_ray_origin(pos);
@@ -639,8 +586,8 @@ void Viewport::_notification(int p_what) {
PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space());
if (space) {
- bool col = space->intersect_ray(from,from+dir*10000,result,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF,true);
- ObjectID new_collider=0;
+ bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, 0xFFFFFFFF, true);
+ ObjectID new_collider = 0;
if (col) {
if (result.collider) {
@@ -648,29 +595,28 @@ void Viewport::_notification(int p_what) {
CollisionObject *co = result.collider->cast_to<CollisionObject>();
if (co) {
- co->_input_event(camera,ev,result.position,result.normal,result.shape);
- last_object=co;
- last_id=result.collider_id;
- new_collider=last_id;
- if (co->get_capture_input_on_drag() && ev.type==InputEvent::MOUSE_BUTTON && ev.mouse_button.button_index==1 && ev.mouse_button.pressed) {
- physics_object_capture=last_id;
+ co->_input_event(camera, ev, result.position, result.normal, result.shape);
+ last_object = co;
+ last_id = result.collider_id;
+ new_collider = last_id;
+ if (co->get_capture_input_on_drag() && ev.type == InputEvent::MOUSE_BUTTON && ev.mouse_button.button_index == 1 && ev.mouse_button.pressed) {
+ physics_object_capture = last_id;
}
-
}
}
}
- if (ev.type==InputEvent::MOUSE_MOTION) {
+ if (ev.type == InputEvent::MOUSE_MOTION) {
_test_new_mouseover(new_collider);
}
}
- last_pos=pos;
+ last_pos = pos;
}
}
}
- if (!motion_tested && camera && physics_last_mousepos!=Vector2(1e20,1e20)) {
+ if (!motion_tested && camera && physics_last_mousepos != Vector2(1e20, 1e20)) {
//test anyway for mouseenter/exit because objects might move
Vector3 from = camera->project_ray_origin(physics_last_mousepos);
@@ -679,24 +625,21 @@ void Viewport::_notification(int p_what) {
PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space());
if (space) {
- bool col = space->intersect_ray(from,from+dir*10000,result,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF,true);
- ObjectID new_collider=0;
+ bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, 0xFFFFFFFF, true);
+ ObjectID new_collider = 0;
if (col) {
if (result.collider) {
CollisionObject *co = result.collider->cast_to<CollisionObject>();
if (co) {
- new_collider=result.collider_id;
-
+ new_collider = result.collider_id;
}
}
}
_test_new_mouseover(new_collider);
-
}
#endif
}
-
}
} break;
@@ -708,35 +651,32 @@ RID Viewport::get_viewport() const {
return viewport;
}
-void Viewport::set_rect(const Rect2& p_rect) {
+void Viewport::set_rect(const Rect2 &p_rect) {
- if (rect==p_rect)
+ if (rect == p_rect)
return;
- rect=p_rect;
+ rect = p_rect;
_update_rect();
_update_stretch_transform();
-
}
Rect2 Viewport::get_visible_rect() const {
-
Rect2 r;
- if (rect.pos==Vector2() && rect.size==Size2()) {
+ if (rect.pos == Vector2() && rect.size == Size2()) {
- r=Rect2( Point2(), Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height ) );
+ r = Rect2(Point2(), Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height));
} else {
- r=Rect2( rect.pos , rect.size );
+ r = Rect2(rect.pos, rect.size);
}
if (size_override) {
- r.size=size_override_size;
+ r.size = size_override_size;
}
-
return r;
}
@@ -745,16 +685,13 @@ Rect2 Viewport::get_rect() const {
return rect;
}
-
void Viewport::_update_listener() {
- if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible()))) {
+ if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible()))) {
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, find_world()->get_sound_space());
} else {
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
}
-
-
}
void Viewport::_update_listener_2d() {
@@ -763,93 +700,79 @@ void Viewport::_update_listener_2d() {
SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, find_world_2d()->get_sound_space());
else
SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, RID());
-
}
-
void Viewport::set_as_audio_listener(bool p_enable) {
- if (p_enable==audio_listener)
+ if (p_enable == audio_listener)
return;
- audio_listener=p_enable;
+ audio_listener = p_enable;
_update_listener();
-
}
bool Viewport::is_audio_listener() const {
- return audio_listener;
+ return audio_listener;
}
void Viewport::set_as_audio_listener_2d(bool p_enable) {
- if (p_enable==audio_listener_2d)
+ if (p_enable == audio_listener_2d)
return;
- audio_listener_2d=p_enable;
+ audio_listener_2d = p_enable;
_update_listener_2d();
-
-
}
bool Viewport::is_audio_listener_2d() const {
- return audio_listener_2d;
+ return audio_listener_2d;
}
-void Viewport::set_canvas_transform(const Matrix32& p_transform) {
+void Viewport::set_canvas_transform(const Matrix32 &p_transform) {
- canvas_transform=p_transform;
- VisualServer::get_singleton()->viewport_set_canvas_transform(viewport,find_world_2d()->get_canvas(),canvas_transform);
+ canvas_transform = p_transform;
+ VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, find_world_2d()->get_canvas(), canvas_transform);
Matrix32 xform = (global_canvas_transform * canvas_transform).affine_inverse();
Size2 ss = get_visible_rect().size;
- SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Matrix32(0, xform.xform(ss*0.5)));
- Vector2 ss2 = ss*xform.get_scale();
- float panrange = MAX(ss2.x,ss2.y);
+ SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Matrix32(0, xform.xform(ss * 0.5)));
+ Vector2 ss2 = ss * xform.get_scale();
+ float panrange = MAX(ss2.x, ss2.y);
SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange);
-
-
}
-Matrix32 Viewport::get_canvas_transform() const{
+Matrix32 Viewport::get_canvas_transform() const {
return canvas_transform;
}
-
-
void Viewport::_update_global_transform() {
-
Matrix32 sxform = stretch_transform * global_canvas_transform;
- VisualServer::get_singleton()->viewport_set_global_canvas_transform(viewport,sxform);
+ VisualServer::get_singleton()->viewport_set_global_canvas_transform(viewport, sxform);
Matrix32 xform = (sxform * canvas_transform).affine_inverse();
Size2 ss = get_visible_rect().size;
- SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Matrix32(0, xform.xform(ss*0.5)));
- Vector2 ss2 = ss*xform.get_scale();
- float panrange = MAX(ss2.x,ss2.y);
+ SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Matrix32(0, xform.xform(ss * 0.5)));
+ Vector2 ss2 = ss * xform.get_scale();
+ float panrange = MAX(ss2.x, ss2.y);
SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange);
-
}
+void Viewport::set_global_canvas_transform(const Matrix32 &p_transform) {
-void Viewport::set_global_canvas_transform(const Matrix32& p_transform) {
-
- global_canvas_transform=p_transform;
+ global_canvas_transform = p_transform;
_update_global_transform();
-
-
}
-Matrix32 Viewport::get_global_canvas_transform() const{
+Matrix32 Viewport::get_global_canvas_transform() const {
return global_canvas_transform;
}
@@ -862,7 +785,7 @@ void Viewport::_listener_transform_changed_notify() {
#endif
}
-void Viewport::_listener_set(Listener* p_listener) {
+void Viewport::_listener_set(Listener *p_listener) {
#ifndef _3D_DISABLED
@@ -876,13 +799,13 @@ void Viewport::_listener_set(Listener* p_listener) {
#endif
}
-bool Viewport::_listener_add(Listener* p_listener) {
+bool Viewport::_listener_add(Listener *p_listener) {
listeners.insert(p_listener);
return listeners.size() == 1;
}
-void Viewport::_listener_remove(Listener* p_listener) {
+void Viewport::_listener_remove(Listener *p_listener) {
listeners.erase(p_listener);
if (listener == p_listener) {
@@ -891,10 +814,10 @@ void Viewport::_listener_remove(Listener* p_listener) {
}
#ifndef _3D_DISABLED
-void Viewport::_listener_make_next_current(Listener* p_exclude) {
+void Viewport::_listener_make_next_current(Listener *p_exclude) {
if (listeners.size() > 0) {
- for (Set<Listener*>::Element *E = listeners.front(); E; E = E->next()) {
+ for (Set<Listener *>::Element *E = listeners.front(); E; E = E->next()) {
if (p_exclude == E->get())
continue;
@@ -904,10 +827,8 @@ void Viewport::_listener_make_next_current(Listener* p_exclude) {
return;
E->get()->make_current();
-
}
- }
- else {
+ } else {
// Attempt to reset listener to the camera position
if (camera != NULL) {
_update_listener();
@@ -926,21 +847,21 @@ void Viewport::_camera_transform_changed_notify() {
#endif
}
-void Viewport::_camera_set(Camera* p_camera) {
+void Viewport::_camera_set(Camera *p_camera) {
#ifndef _3D_DISABLED
- if (camera==p_camera)
+ if (camera == p_camera)
return;
if (camera && find_world().is_valid()) {
camera->notification(Camera::NOTIFICATION_LOST_CURRENT);
}
- camera=p_camera;
+ camera = p_camera;
if (camera)
- VisualServer::get_singleton()->viewport_attach_camera(viewport,camera->get_camera());
+ VisualServer::get_singleton()->viewport_attach_camera(viewport, camera->get_camera());
else
- VisualServer::get_singleton()->viewport_attach_camera(viewport,RID());
+ VisualServer::get_singleton()->viewport_attach_camera(viewport, RID());
if (camera && find_world().is_valid()) {
camera->notification(Camera::NOTIFICATION_BECAME_CURRENT);
@@ -951,43 +872,41 @@ void Viewport::_camera_set(Camera* p_camera) {
#endif
}
-bool Viewport::_camera_add(Camera* p_camera) {
+bool Viewport::_camera_add(Camera *p_camera) {
cameras.insert(p_camera);
- return cameras.size()==1;
+ return cameras.size() == 1;
}
-void Viewport::_camera_remove(Camera* p_camera) {
+void Viewport::_camera_remove(Camera *p_camera) {
cameras.erase(p_camera);
- if (camera==p_camera) {
- camera=NULL;
+ if (camera == p_camera) {
+ camera = NULL;
}
}
#ifndef _3D_DISABLED
-void Viewport::_camera_make_next_current(Camera* p_exclude) {
+void Viewport::_camera_make_next_current(Camera *p_exclude) {
- for(Set<Camera*>::Element *E=cameras.front();E;E=E->next()) {
+ for (Set<Camera *>::Element *E = cameras.front(); E; E = E->next()) {
- if (p_exclude==E->get())
+ if (p_exclude == E->get())
continue;
if (!E->get()->is_inside_tree())
continue;
- if (camera!=NULL)
+ if (camera != NULL)
return;
E->get()->make_current();
-
}
}
#endif
void Viewport::set_transparent_background(bool p_enable) {
- transparent_bg=p_enable;
- VS::get_singleton()->viewport_set_transparent_background(viewport,p_enable);
-
+ transparent_bg = p_enable;
+ VS::get_singleton()->viewport_set_transparent_background(viewport, p_enable);
}
bool Viewport::has_transparent_background() const {
@@ -995,37 +914,37 @@ bool Viewport::has_transparent_background() const {
return transparent_bg;
}
-void Viewport::set_world_2d(const Ref<World2D>& p_world_2d) {
- if (world_2d==p_world_2d)
+void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
+ if (world_2d == p_world_2d)
return;
- if (parent && parent->find_world_2d()==p_world_2d) {
+ if (parent && parent->find_world_2d() == p_world_2d) {
WARN_PRINT("Unable to use parent world as world_2d");
return;
}
if (is_inside_tree()) {
find_world_2d()->_remove_viewport(this);
- VisualServer::get_singleton()->viewport_remove_canvas(viewport,current_canvas);
+ VisualServer::get_singleton()->viewport_remove_canvas(viewport, current_canvas);
}
if (p_world_2d.is_valid())
- world_2d=p_world_2d;
+ world_2d = p_world_2d;
else {
WARN_PRINT("Invalid world");
- world_2d=Ref<World2D>( memnew( World2D ));
+ world_2d = Ref<World2D>(memnew(World2D));
}
_update_listener_2d();
if (is_inside_tree()) {
- current_canvas=find_world_2d()->get_canvas();
- VisualServer::get_singleton()->viewport_attach_canvas(viewport,current_canvas);
- find_world_2d()->_register_viewport(this,Rect2());
+ current_canvas = find_world_2d()->get_canvas();
+ VisualServer::get_singleton()->viewport_attach_canvas(viewport, current_canvas);
+ find_world_2d()->_register_viewport(this, Rect2());
}
}
-Ref<World2D> Viewport::find_world_2d() const{
+Ref<World2D> Viewport::find_world_2d() const {
if (world_2d.is_valid())
return world_2d;
@@ -1037,8 +956,7 @@ Ref<World2D> Viewport::find_world_2d() const{
void Viewport::_propagate_enter_world(Node *p_node) {
-
- if (p_node!=this) {
+ if (p_node != this) {
if (!p_node->is_inside_tree()) //may not have entered scene yet
return;
@@ -1057,27 +975,26 @@ void Viewport::_propagate_enter_world(Node *p_node) {
}
}
-
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
_propagate_enter_world(p_node->get_child(i));
}
}
-void Viewport::_propagate_viewport_notification(Node* p_node,int p_what) {
+void Viewport::_propagate_viewport_notification(Node *p_node, int p_what) {
p_node->notification(p_what);
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
Node *c = p_node->get_child(i);
if (c->cast_to<Viewport>())
continue;
- _propagate_viewport_notification(c,p_what);
+ _propagate_viewport_notification(c, p_what);
}
}
void Viewport::_propagate_exit_world(Node *p_node) {
- if (p_node!=this) {
+ if (p_node != this) {
if (!p_node->is_inside_tree()) //may have exited scene already
return;
@@ -1096,18 +1013,15 @@ void Viewport::_propagate_exit_world(Node *p_node) {
}
}
-
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
_propagate_exit_world(p_node->get_child(i));
}
-
}
+void Viewport::set_world(const Ref<World> &p_world) {
-void Viewport::set_world(const Ref<World>& p_world) {
-
- if (world==p_world)
+ if (world == p_world)
return;
if (is_inside_tree())
@@ -1118,7 +1032,7 @@ void Viewport::set_world(const Ref<World>& p_world) {
camera->notification(Camera::NOTIFICATION_LOST_CURRENT);
#endif
- world=p_world;
+ world = p_world;
if (is_inside_tree())
_propagate_enter_world(this);
@@ -1131,24 +1045,23 @@ void Viewport::set_world(const Ref<World>& p_world) {
//propagate exit
if (is_inside_tree()) {
- VisualServer::get_singleton()->viewport_set_scenario(viewport,find_world()->get_scenario());
+ VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
}
_update_listener();
-
}
-Ref<World> Viewport::get_world() const{
+Ref<World> Viewport::get_world() const {
return world;
}
-Ref<World2D> Viewport::get_world_2d() const{
+Ref<World2D> Viewport::get_world_2d() const {
return world_2d;
}
-Ref<World> Viewport::find_world() const{
+Ref<World> Viewport::find_world() const {
if (own_world.is_valid())
return own_world;
@@ -1160,36 +1073,33 @@ Ref<World> Viewport::find_world() const{
return Ref<World>();
}
-Listener* Viewport::get_listener() const {
+Listener *Viewport::get_listener() const {
return listener;
}
-Camera* Viewport::get_camera() const {
+Camera *Viewport::get_camera() const {
return camera;
}
-
Matrix32 Viewport::get_final_transform() const {
return stretch_transform * global_canvas_transform;
}
-void Viewport::set_size_override(bool p_enable, const Size2& p_size, const Vector2 &p_margin) {
+void Viewport::set_size_override(bool p_enable, const Size2 &p_size, const Vector2 &p_margin) {
- if (size_override==p_enable && p_size==size_override_size)
+ if (size_override == p_enable && p_size == size_override_size)
return;
- size_override=p_enable;
- if (p_size.x>=0 || p_size.y>=0) {
- size_override_size=p_size;
+ size_override = p_enable;
+ if (p_size.x >= 0 || p_size.y >= 0) {
+ size_override_size = p_size;
}
- size_override_margin=p_margin;
+ size_override_margin = p_margin;
_update_rect();
_update_stretch_transform();
-
-
}
Size2 Viewport::get_size_override() const {
@@ -1202,32 +1112,30 @@ bool Viewport::is_size_override_enabled() const {
}
void Viewport::set_size_override_stretch(bool p_enable) {
- if (p_enable==size_override_stretch)
+ if (p_enable == size_override_stretch)
return;
- size_override_stretch=p_enable;
+ size_override_stretch = p_enable;
if (size_override) {
_update_rect();
}
-
_update_stretch_transform();
}
-
bool Viewport::is_size_override_stretch_enabled() const {
return size_override_stretch;
}
-void Viewport::set_as_render_target(bool p_enable){
+void Viewport::set_as_render_target(bool p_enable) {
- if (render_target==p_enable)
+ if (render_target == p_enable)
return;
- render_target=p_enable;
+ render_target = p_enable;
- VS::get_singleton()->viewport_set_as_render_target(viewport,p_enable);
+ VS::get_singleton()->viewport_set_as_render_target(viewport, p_enable);
if (is_inside_tree()) {
if (p_enable)
@@ -1241,7 +1149,7 @@ void Viewport::set_as_render_target(bool p_enable){
render_target_texture_rid = VS::get_singleton()->viewport_get_render_target_texture(viewport);
} else {
- render_target_texture_rid=RID();
+ render_target_texture_rid = RID();
}
render_target_texture->set_flags(render_target_texture->flags);
@@ -1250,23 +1158,22 @@ void Viewport::set_as_render_target(bool p_enable){
update_configuration_warning();
}
-bool Viewport::is_set_as_render_target() const{
+bool Viewport::is_set_as_render_target() const {
return render_target;
}
-void Viewport::set_render_target_update_mode(RenderTargetUpdateMode p_mode){
-
- render_target_update_mode=p_mode;
- VS::get_singleton()->viewport_set_render_target_update_mode(viewport,VS::RenderTargetUpdateMode(p_mode));
+void Viewport::set_render_target_update_mode(RenderTargetUpdateMode p_mode) {
+ render_target_update_mode = p_mode;
+ VS::get_singleton()->viewport_set_render_target_update_mode(viewport, VS::RenderTargetUpdateMode(p_mode));
}
-Viewport::RenderTargetUpdateMode Viewport::get_render_target_update_mode() const{
+Viewport::RenderTargetUpdateMode Viewport::get_render_target_update_mode() const {
return render_target_update_mode;
}
//RID get_render_target_texture() const;
-void Viewport::queue_screen_capture(){
+void Viewport::queue_screen_capture() {
VS::get_singleton()->viewport_queue_screen_capture(viewport);
}
@@ -1282,22 +1189,22 @@ Ref<RenderTargetTexture> Viewport::get_render_target_texture() const {
void Viewport::set_render_target_vflip(bool p_enable) {
- render_target_vflip=p_enable;
- VisualServer::get_singleton()->viewport_set_render_target_vflip(viewport,p_enable);
+ render_target_vflip = p_enable;
+ VisualServer::get_singleton()->viewport_set_render_target_vflip(viewport, p_enable);
}
-bool Viewport::get_render_target_vflip() const{
+bool Viewport::get_render_target_vflip() const {
return render_target_vflip;
}
void Viewport::set_render_target_clear_on_new_frame(bool p_enable) {
- render_target_clear_on_new_frame=p_enable;
- VisualServer::get_singleton()->viewport_set_render_target_clear_on_new_frame(viewport,p_enable);
+ render_target_clear_on_new_frame = p_enable;
+ VisualServer::get_singleton()->viewport_set_render_target_clear_on_new_frame(viewport, p_enable);
}
-bool Viewport::get_render_target_clear_on_new_frame() const{
+bool Viewport::get_render_target_clear_on_new_frame() const {
return render_target_clear_on_new_frame;
}
@@ -1310,45 +1217,42 @@ void Viewport::render_target_clear() {
void Viewport::set_render_target_filter(bool p_enable) {
- if(!render_target)
+ if (!render_target)
return;
- render_target_texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
-
+ render_target_texture->set_flags(p_enable ? int(Texture::FLAG_FILTER) : int(0));
}
-bool Viewport::get_render_target_filter() const{
+bool Viewport::get_render_target_filter() const {
- return (render_target_texture->get_flags()&Texture::FLAG_FILTER)!=0;
+ return (render_target_texture->get_flags() & Texture::FLAG_FILTER) != 0;
}
void Viewport::set_render_target_gen_mipmaps(bool p_enable) {
//render_target_texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
- render_target_gen_mipmaps=p_enable;
-
+ render_target_gen_mipmaps = p_enable;
}
-bool Viewport::get_render_target_gen_mipmaps() const{
+bool Viewport::get_render_target_gen_mipmaps() const {
//return (render_target_texture->get_flags()&Texture::FLAG_FILTER)!=0;
return render_target_gen_mipmaps;
}
-
Matrix32 Viewport::_get_input_pre_xform() const {
Matrix32 pre_xf;
if (render_target) {
- if (to_screen_rect!=Rect2()) {
+ if (to_screen_rect != Rect2()) {
- pre_xf.elements[2]=-to_screen_rect.pos;
- pre_xf.scale(rect.size/to_screen_rect.size);
+ pre_xf.elements[2] = -to_screen_rect.pos;
+ pre_xf.scale(rect.size / to_screen_rect.size);
}
} else {
- pre_xf.elements[2]=-rect.pos;
+ pre_xf.elements[2] = -rect.pos;
}
return pre_xf;
@@ -1363,24 +1267,22 @@ Vector2 Viewport::_get_window_offset() const {
return Vector2();
}
-void Viewport::_make_input_local(InputEvent& ev) {
-
+void Viewport::_make_input_local(InputEvent &ev) {
- switch(ev.type) {
+ switch (ev.type) {
case InputEvent::MOUSE_BUTTON: {
Vector2 vp_ofs = _get_window_offset();
Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
- Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
- Vector2 l = ai.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y)-vp_ofs);
+ Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x, ev.mouse_button.global_y));
+ Vector2 l = ai.xform(Vector2(ev.mouse_button.x, ev.mouse_button.y) - vp_ofs);
-
- ev.mouse_button.x=l.x;
- ev.mouse_button.y=l.y;
- ev.mouse_button.global_x=g.x;
- ev.mouse_button.global_y=g.y;
+ ev.mouse_button.x = l.x;
+ ev.mouse_button.y = l.y;
+ ev.mouse_button.global_x = g.x;
+ ev.mouse_button.global_y = g.y;
} break;
case InputEvent::MOUSE_MOTION: {
@@ -1388,20 +1290,19 @@ void Viewport::_make_input_local(InputEvent& ev) {
Vector2 vp_ofs = _get_window_offset();
Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
- Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
- Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y)-vp_ofs);
- Vector2 r = ai.basis_xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y));
- Vector2 s = ai.basis_xform(Vector2(ev.mouse_motion.speed_x,ev.mouse_motion.speed_y));
-
+ Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x, ev.mouse_motion.global_y));
+ Vector2 l = ai.xform(Vector2(ev.mouse_motion.x, ev.mouse_motion.y) - vp_ofs);
+ Vector2 r = ai.basis_xform(Vector2(ev.mouse_motion.relative_x, ev.mouse_motion.relative_y));
+ Vector2 s = ai.basis_xform(Vector2(ev.mouse_motion.speed_x, ev.mouse_motion.speed_y));
- ev.mouse_motion.x=l.x;
- ev.mouse_motion.y=l.y;
- ev.mouse_motion.global_x=g.x;
- ev.mouse_motion.global_y=g.y;
- ev.mouse_motion.relative_x=r.x;
- ev.mouse_motion.relative_y=r.y;
- ev.mouse_motion.speed_x=s.x;
- ev.mouse_motion.speed_y=s.y;
+ ev.mouse_motion.x = l.x;
+ ev.mouse_motion.y = l.y;
+ ev.mouse_motion.global_x = g.x;
+ ev.mouse_motion.global_y = g.y;
+ ev.mouse_motion.relative_x = r.x;
+ ev.mouse_motion.relative_y = r.y;
+ ev.mouse_motion.speed_x = s.x;
+ ev.mouse_motion.speed_y = s.y;
} break;
case InputEvent::SCREEN_TOUCH: {
@@ -1409,11 +1310,10 @@ void Viewport::_make_input_local(InputEvent& ev) {
Vector2 vp_ofs = _get_window_offset();
Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
- Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y)-vp_ofs);
-
+ Vector2 t = ai.xform(Vector2(ev.screen_touch.x, ev.screen_touch.y) - vp_ofs);
- ev.screen_touch.x=t.x;
- ev.screen_touch.y=t.y;
+ ev.screen_touch.x = t.x;
+ ev.screen_touch.y = t.y;
} break;
case InputEvent::SCREEN_DRAG: {
@@ -1421,29 +1321,27 @@ void Viewport::_make_input_local(InputEvent& ev) {
Vector2 vp_ofs = _get_window_offset();
Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
- Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y)-vp_ofs);
- Vector2 r = ai.basis_xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
- Vector2 s = ai.basis_xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
- ev.screen_drag.x=t.x;
- ev.screen_drag.y=t.y;
- ev.screen_drag.relative_x=r.x;
- ev.screen_drag.relative_y=r.y;
- ev.screen_drag.speed_x=s.x;
- ev.screen_drag.speed_y=s.y;
+ Vector2 t = ai.xform(Vector2(ev.screen_drag.x, ev.screen_drag.y) - vp_ofs);
+ Vector2 r = ai.basis_xform(Vector2(ev.screen_drag.relative_x, ev.screen_drag.relative_y));
+ Vector2 s = ai.basis_xform(Vector2(ev.screen_drag.speed_x, ev.screen_drag.speed_y));
+ ev.screen_drag.x = t.x;
+ ev.screen_drag.y = t.y;
+ ev.screen_drag.relative_x = r.x;
+ ev.screen_drag.relative_y = r.y;
+ ev.screen_drag.speed_x = s.x;
+ ev.screen_drag.speed_y = s.y;
} break;
}
-
-
}
-void Viewport::_vp_input_text(const String& p_text) {
+void Viewport::_vp_input_text(const String &p_text) {
if (gui.key_focus) {
- gui.key_focus->call("set_text",p_text);
+ gui.key_focus->call("set_text", p_text);
}
}
-void Viewport::_vp_input(const InputEvent& p_ev) {
+void Viewport::_vp_input(const InputEvent &p_ev) {
if (disable_input)
return;
@@ -1457,20 +1355,18 @@ void Viewport::_vp_input(const InputEvent& p_ev) {
if (parent_control && !parent_control->is_visible())
return;
- if (render_target && to_screen_rect==Rect2())
+ if (render_target && to_screen_rect == Rect2())
return; //if render target, can't get input events
//this one handles system input, p_ev are in system coordinates
//they are converted to viewport coordinates
-
InputEvent ev = p_ev;
_make_input_local(ev);
input(ev);
-
}
-void Viewport::_vp_unhandled_input(const InputEvent& p_ev) {
+void Viewport::_vp_unhandled_input(const InputEvent &p_ev) {
if (disable_input)
return;
@@ -1483,7 +1379,7 @@ void Viewport::_vp_unhandled_input(const InputEvent& p_ev) {
if (parent_control && !parent_control->is_visible())
return;
- if (render_target && to_screen_rect==Rect2())
+ if (render_target && to_screen_rect == Rect2())
return; //if render target, can't get input events
//this one handles system input, p_ev are in system coordinates
@@ -1492,7 +1388,6 @@ void Viewport::_vp_unhandled_input(const InputEvent& p_ev) {
InputEvent ev = p_ev;
_make_input_local(ev);
unhandled_input(ev);
-
}
Vector2 Viewport::get_mouse_pos() const {
@@ -1500,24 +1395,21 @@ Vector2 Viewport::get_mouse_pos() const {
return (get_final_transform().affine_inverse() * _get_input_pre_xform()).xform(Input::get_singleton()->get_mouse_pos() - _get_window_offset());
}
-void Viewport::warp_mouse(const Vector2& p_pos) {
+void Viewport::warp_mouse(const Vector2 &p_pos) {
Vector2 gpos = (get_final_transform().affine_inverse() * _get_input_pre_xform()).affine_inverse().xform(p_pos);
Input::get_singleton()->warp_mouse_pos(gpos);
}
-
-
void Viewport::_gui_sort_subwindows() {
if (!gui.subwindow_order_dirty)
return;
-
gui.modal_stack.sort_custom<Control::CComparator>();
gui.subwindows.sort_custom<Control::CComparator>();
- gui.subwindow_order_dirty=false;
+ gui.subwindow_order_dirty = false;
}
void Viewport::_gui_sort_modal_stack() {
@@ -1525,7 +1417,6 @@ void Viewport::_gui_sort_modal_stack() {
gui.modal_stack.sort_custom<Control::CComparator>();
}
-
void Viewport::_gui_sort_roots() {
if (!gui.roots_order_dirty)
@@ -1533,19 +1424,17 @@ void Viewport::_gui_sort_roots() {
gui.roots.sort_custom<Control::CComparator>();
- gui.roots_order_dirty=false;
+ gui.roots_order_dirty = false;
}
-
void Viewport::_gui_cancel_tooltip() {
- gui.tooltip=NULL;
- gui.tooltip_timer=-1;
+ gui.tooltip = NULL;
+ gui.tooltip_timer = -1;
if (gui.tooltip_popup) {
gui.tooltip_popup->queue_delete();
- gui.tooltip_popup=NULL;
+ gui.tooltip_popup = NULL;
}
-
}
void Viewport::_gui_show_tooltip() {
@@ -1554,47 +1443,46 @@ void Viewport::_gui_show_tooltip() {
return;
}
- String tooltip = gui.tooltip->get_tooltip( gui.tooltip->get_global_transform().xform_inv(gui.tooltip_pos) );
- if (tooltip.length()==0)
+ String tooltip = gui.tooltip->get_tooltip(gui.tooltip->get_global_transform().xform_inv(gui.tooltip_pos));
+ if (tooltip.length() == 0)
return; // bye
if (gui.tooltip_popup) {
memdelete(gui.tooltip_popup);
- gui.tooltip_popup=NULL;
+ gui.tooltip_popup = NULL;
}
Control *rp = gui.tooltip->get_root_parent_control();
if (!rp)
return;
-
- gui.tooltip_popup = memnew( TooltipPanel );
+ gui.tooltip_popup = memnew(TooltipPanel);
rp->add_child(gui.tooltip_popup);
gui.tooltip_popup->force_parent_owned();
- gui.tooltip_label = memnew( TooltipLabel );
+ gui.tooltip_label = memnew(TooltipLabel);
gui.tooltip_popup->add_child(gui.tooltip_label);
gui.tooltip_popup->set_as_toplevel(true);
gui.tooltip_popup->hide();
- Ref<StyleBox> ttp = gui.tooltip_label->get_stylebox("panel","TooltipPanel");
+ Ref<StyleBox> ttp = gui.tooltip_label->get_stylebox("panel", "TooltipPanel");
- gui.tooltip_label->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_BEGIN,ttp->get_margin(MARGIN_LEFT));
- gui.tooltip_label->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,ttp->get_margin(MARGIN_TOP));
- gui.tooltip_label->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,ttp->get_margin(MARGIN_RIGHT));
- gui.tooltip_label->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_END,ttp->get_margin(MARGIN_BOTTOM));
+ gui.tooltip_label->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, ttp->get_margin(MARGIN_LEFT));
+ gui.tooltip_label->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, ttp->get_margin(MARGIN_TOP));
+ gui.tooltip_label->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, ttp->get_margin(MARGIN_RIGHT));
+ gui.tooltip_label->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, ttp->get_margin(MARGIN_BOTTOM));
gui.tooltip_label->set_text(tooltip);
- Rect2 r(gui.tooltip_pos+Point2(10,10),gui.tooltip_label->get_combined_minimum_size()+ttp->get_minimum_size());
+ Rect2 r(gui.tooltip_pos + Point2(10, 10), gui.tooltip_label->get_combined_minimum_size() + ttp->get_minimum_size());
Rect2 vr = gui.tooltip_label->get_viewport_rect();
- if (r.size.x+r.pos.x>vr.size.x)
- r.pos.x=vr.size.x-r.size.x;
- else if (r.pos.x<0)
- r.pos.x=0;
+ if (r.size.x + r.pos.x > vr.size.x)
+ r.pos.x = vr.size.x - r.size.x;
+ else if (r.pos.x < 0)
+ r.pos.x = 0;
- if (r.size.y+r.pos.y>vr.size.y)
- r.pos.y=vr.size.y-r.size.y;
- else if (r.pos.y<0)
- r.pos.y=0;
+ if (r.size.y + r.pos.y > vr.size.y)
+ r.pos.y = vr.size.y - r.size.y;
+ else if (r.pos.y < 0)
+ r.pos.y = 0;
gui.tooltip_popup->set_global_pos(r.pos);
gui.tooltip_popup->set_size(r.size);
@@ -1603,56 +1491,53 @@ void Viewport::_gui_show_tooltip() {
gui.tooltip_popup->show();
}
+void Viewport::_gui_call_input(Control *p_control, const InputEvent &p_input) {
-void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) {
-
-// _block();
-
+ // _block();
InputEvent ev = p_input;
//mouse wheel events can't be stopped
- bool cant_stop_me_now = (ev.type==InputEvent::MOUSE_BUTTON &&
- (ev.mouse_button.button_index==BUTTON_WHEEL_DOWN ||
- ev.mouse_button.button_index==BUTTON_WHEEL_UP ||
- ev.mouse_button.button_index==BUTTON_WHEEL_LEFT ||
- ev.mouse_button.button_index==BUTTON_WHEEL_RIGHT ) );
+ bool cant_stop_me_now = (ev.type == InputEvent::MOUSE_BUTTON &&
+ (ev.mouse_button.button_index == BUTTON_WHEEL_DOWN ||
+ ev.mouse_button.button_index == BUTTON_WHEEL_UP ||
+ ev.mouse_button.button_index == BUTTON_WHEEL_LEFT ||
+ ev.mouse_button.button_index == BUTTON_WHEEL_RIGHT));
- CanvasItem *ci=p_control;
- while(ci) {
+ CanvasItem *ci = p_control;
+ while (ci) {
Control *control = ci->cast_to<Control>();
if (control) {
- control->call_multilevel(SceneStringNames::get_singleton()->_input_event,ev);
+ control->call_multilevel(SceneStringNames::get_singleton()->_input_event, ev);
if (gui.key_event_accepted)
break;
if (!control->is_inside_tree())
break;
- control->emit_signal(SceneStringNames::get_singleton()->input_event,ev);
+ control->emit_signal(SceneStringNames::get_singleton()->input_event, ev);
if (!control->is_inside_tree() || control->is_set_as_toplevel())
break;
if (gui.key_event_accepted)
break;
- if (!cant_stop_me_now && control->data.stop_mouse && (ev.type==InputEvent::MOUSE_BUTTON || ev.type==InputEvent::MOUSE_MOTION))
+ if (!cant_stop_me_now && control->data.stop_mouse && (ev.type == InputEvent::MOUSE_BUTTON || ev.type == InputEvent::MOUSE_MOTION))
break;
}
if (ci->is_set_as_toplevel())
break;
- ev=ev.xform_by(ci->get_transform()); //transform event upwards
- ci=ci->get_parent_item();
+ ev = ev.xform_by(ci->get_transform()); //transform event upwards
+ ci = ci->get_parent_item();
}
//_unblock();
-
}
-Control* Viewport::_gui_find_control(const Point2& p_global) {
+Control *Viewport::_gui_find_control(const Point2 &p_global) {
_gui_sort_subwindows();
- for (List<Control*>::Element *E=gui.subwindows.back();E;E=E->prev()) {
+ for (List<Control *>::Element *E = gui.subwindows.back(); E; E = E->prev()) {
Control *sw = E->get();
if (!sw->is_visible())
@@ -1661,18 +1546,18 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
Matrix32 xform;
CanvasItem *pci = sw->get_parent_item();
if (pci)
- xform=pci->get_global_transform_with_canvas();
+ xform = pci->get_global_transform_with_canvas();
else
- xform=sw->get_canvas_transform();
+ xform = sw->get_canvas_transform();
- Control *ret = _gui_find_control_at_pos(sw,p_global,xform,gui.focus_inv_xform);
+ Control *ret = _gui_find_control_at_pos(sw, p_global, xform, gui.focus_inv_xform);
if (ret)
return ret;
}
_gui_sort_roots();
- for (List<Control*>::Element *E=gui.roots.back();E;E=E->prev()) {
+ for (List<Control *>::Element *E = gui.roots.back(); E; E = E->prev()) {
Control *sw = E->get();
if (!sw->is_visible())
@@ -1681,30 +1566,27 @@ Control* Viewport::_gui_find_control(const Point2& p_global) {
Matrix32 xform;
CanvasItem *pci = sw->get_parent_item();
if (pci)
- xform=pci->get_global_transform_with_canvas();
+ xform = pci->get_global_transform_with_canvas();
else
- xform=sw->get_canvas_transform();
-
+ xform = sw->get_canvas_transform();
- Control *ret = _gui_find_control_at_pos(sw,p_global,xform,gui.focus_inv_xform);
+ Control *ret = _gui_find_control_at_pos(sw, p_global, xform, gui.focus_inv_xform);
if (ret)
return ret;
}
return NULL;
-
}
-
-Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_global,const Matrix32& p_xform,Matrix32& r_inv_xform) {
+Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Matrix32 &p_xform, Matrix32 &r_inv_xform) {
if (p_node->cast_to<Viewport>())
return NULL;
- Control *c=p_node->cast_to<Control>();
+ Control *c = p_node->cast_to<Control>();
if (c) {
- // print_line("at "+String(c->get_path())+" POS "+c->get_pos()+" bt "+p_xform);
+ // print_line("at "+String(c->get_path())+" POS "+c->get_pos()+" bt "+p_xform);
}
//subwindows first!!
@@ -1716,21 +1598,21 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
Matrix32 matrix = p_xform * p_node->get_transform();
// matrix.basis_determinant() == 0.0f implies that node does not exist on scene
- if(matrix.basis_determinant() == 0.0f)
+ if (matrix.basis_determinant() == 0.0f)
return NULL;
if (!c || !c->clips_input() || c->has_point(matrix.affine_inverse().xform(p_global))) {
- for(int i=p_node->get_child_count()-1;i>=0;i--) {
+ for (int i = p_node->get_child_count() - 1; i >= 0; i--) {
- if (p_node==gui.tooltip_popup)
+ if (p_node == gui.tooltip_popup)
continue;
CanvasItem *ci = p_node->get_child(i)->cast_to<CanvasItem>();
if (!ci || ci->is_set_as_toplevel())
continue;
- Control *ret=_gui_find_control_at_pos(ci,p_global,matrix,r_inv_xform);
+ Control *ret = _gui_find_control_at_pos(ci, p_global, matrix, r_inv_xform);
if (ret)
return ret;
}
@@ -1742,8 +1624,8 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
matrix.affine_invert();
//conditions for considering this as a valid control for return
- if (!c->data.ignore_mouse && c->has_point(matrix.xform(p_global)) && (!gui.drag_preview || (c!=gui.drag_preview && !gui.drag_preview->is_a_parent_of(c)))) {
- r_inv_xform=matrix;
+ if (!c->data.ignore_mouse && c->has_point(matrix.xform(p_global)) && (!gui.drag_preview || (c != gui.drag_preview && !gui.drag_preview->is_a_parent_of(c)))) {
+ r_inv_xform = matrix;
return c;
} else
return NULL;
@@ -1751,37 +1633,30 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
void Viewport::_gui_input_event(InputEvent p_event) {
-
-
- if (p_event.ID==gui.cancelled_input_ID) {
+ if (p_event.ID == gui.cancelled_input_ID) {
return;
}
//?
-// if (!is_visible()) {
-// return; //simple and plain
-// }
-
+ // if (!is_visible()) {
+ // return; //simple and plain
+ // }
- switch(p_event.type) {
+ switch (p_event.type) {
case InputEvent::MOUSE_BUTTON: {
+ gui.key_event_accepted = false;
- gui.key_event_accepted=false;
-
- Point2 mpos=Point2(p_event.mouse_button.x,p_event.mouse_button.y);
+ Point2 mpos = Point2(p_event.mouse_button.x, p_event.mouse_button.y);
if (p_event.mouse_button.pressed) {
-
-
Size2 pos = mpos;
- if (gui.mouse_focus && p_event.mouse_button.button_index!=gui.mouse_focus_button) {
+ if (gui.mouse_focus && p_event.mouse_button.button_index != gui.mouse_focus_button) {
//do not steal mouse focus and stuff
} else {
-
_gui_sort_modal_stack();
while (!gui.modal_stack.empty()) {
@@ -1789,7 +1664,7 @@ void Viewport::_gui_input_event(InputEvent p_event) {
Vector2 pos = top->get_global_transform_with_canvas().affine_inverse().xform(mpos);
if (!top->has_point(pos)) {
- if (top->data.modal_exclusive || top->data.modal_frame==OS::get_singleton()->get_frames_drawn()) {
+ if (top->data.modal_exclusive || top->data.modal_frame == OS::get_singleton()->get_frames_drawn()) {
//cancel event, sorry, modal exclusive EATS UP ALL
//alternative, you can't pop out a window the same frame it was made modal (fixes many issues)
get_tree()->set_input_as_handled();
@@ -1804,32 +1679,25 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}
}
-
-
//Matrix32 parent_xform;
//if (data.parent_canvas_item)
// parent_xform=data.parent_canvas_item->get_global_transform();
-
-
gui.mouse_focus = _gui_find_control(pos);
//print_line("has mf "+itos(gui.mouse_focus!=NULL));
- gui.mouse_focus_button=p_event.mouse_button.button_index;
+ gui.mouse_focus_button = p_event.mouse_button.button_index;
if (!gui.mouse_focus) {
break;
}
- if (p_event.mouse_button.button_index==BUTTON_LEFT) {
- gui.drag_accum=Vector2();
- gui.drag_attempted=false;
+ if (p_event.mouse_button.button_index == BUTTON_LEFT) {
+ gui.drag_accum = Vector2();
+ gui.drag_attempted = false;
}
-
-
}
-
p_event.mouse_button.global_x = pos.x;
p_event.mouse_button.global_y = pos.y;
@@ -1843,72 +1711,66 @@ void Viewport::_gui_input_event(InputEvent p_event) {
Array arr;
arr.push_back(gui.mouse_focus->get_path());
arr.push_back(gui.mouse_focus->get_type());
- ScriptDebugger::get_singleton()->send_message("click_ctrl",arr);
+ ScriptDebugger::get_singleton()->send_message("click_ctrl", arr);
}
- /*if (bool(GLOBAL_DEF("debug/print_clicked_control",false))) {
+/*if (bool(GLOBAL_DEF("debug/print_clicked_control",false))) {
print_line(String(gui.mouse_focus->get_path())+" - "+pos);
}*/
#endif
- if (gui.mouse_focus->get_focus_mode()!=Control::FOCUS_NONE && gui.mouse_focus!=gui.key_focus && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.mouse_focus->get_focus_mode() != Control::FOCUS_NONE && gui.mouse_focus != gui.key_focus && p_event.mouse_button.button_index == BUTTON_LEFT) {
// also get keyboard focus
gui.mouse_focus->grab_focus();
}
-
if (gui.mouse_focus->can_process()) {
- _gui_call_input(gui.mouse_focus,p_event);
+ _gui_call_input(gui.mouse_focus, p_event);
}
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
+ get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME, "windows", "_cancel_input_ID", p_event.ID);
get_tree()->set_input_as_handled();
-
- if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.drag_data.get_type() != Variant::NIL && p_event.mouse_button.button_index == BUTTON_LEFT) {
//alternate drop use (when using force_drag(), as proposed by #5342
- if (gui.mouse_focus && gui.mouse_focus->can_drop_data(pos,gui.drag_data)) {
- gui.mouse_focus->drop_data(pos,gui.drag_data);
+ if (gui.mouse_focus && gui.mouse_focus->can_drop_data(pos, gui.drag_data)) {
+ gui.mouse_focus->drop_data(pos, gui.drag_data);
}
- gui.drag_data=Variant();
+ gui.drag_data = Variant();
if (gui.drag_preview) {
- memdelete( gui.drag_preview );
- gui.drag_preview=NULL;
+ memdelete(gui.drag_preview);
+ gui.drag_preview = NULL;
}
- _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ _propagate_viewport_notification(this, NOTIFICATION_DRAG_END);
//change mouse accordingly
}
-
-
_gui_cancel_tooltip();
//gui.tooltip_popup->hide();
} else {
-
-
- if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.drag_data.get_type() != Variant::NIL && p_event.mouse_button.button_index == BUTTON_LEFT) {
if (gui.mouse_over) {
Size2 pos = mpos;
pos = gui.focus_inv_xform.xform(pos);
- if (gui.mouse_over->can_drop_data(pos,gui.drag_data)) {
- gui.mouse_over->drop_data(pos,gui.drag_data);
+ if (gui.mouse_over->can_drop_data(pos, gui.drag_data)) {
+ gui.mouse_over->drop_data(pos, gui.drag_data);
}
}
- if (gui.drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
- memdelete( gui.drag_preview );
- gui.drag_preview=NULL;
+ if (gui.drag_preview && p_event.mouse_button.button_index == BUTTON_LEFT) {
+ memdelete(gui.drag_preview);
+ gui.drag_preview = NULL;
}
- gui.drag_data=Variant();
- _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ gui.drag_data = Variant();
+ _propagate_viewport_notification(this, NOTIFICATION_DRAG_END);
//change mouse accordingly
}
@@ -1925,12 +1787,12 @@ void Viewport::_gui_input_event(InputEvent p_event) {
p_event.mouse_button.y = pos.y;
if (gui.mouse_focus->can_process()) {
- _gui_call_input(gui.mouse_focus,p_event);
+ _gui_call_input(gui.mouse_focus, p_event);
}
- if (p_event.mouse_button.button_index==gui.mouse_focus_button) {
- gui.mouse_focus=NULL;
- gui.mouse_focus_button=-1;
+ if (p_event.mouse_button.button_index == gui.mouse_focus_button) {
+ gui.mouse_focus = NULL;
+ gui.mouse_focus_button = -1;
}
/*if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
@@ -1938,44 +1800,40 @@ void Viewport::_gui_input_event(InputEvent p_event) {
gui.drag_data=Variant(); //always clear
}*/
-
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
+ get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME, "windows", "_cancel_input_ID", p_event.ID);
get_tree()->set_input_as_handled();
-
}
} break;
case InputEvent::MOUSE_MOTION: {
- gui.key_event_accepted=false;
- Point2 mpos=Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
+ gui.key_event_accepted = false;
+ Point2 mpos = Point2(p_event.mouse_motion.x, p_event.mouse_motion.y);
- gui.last_mouse_pos=mpos;
+ gui.last_mouse_pos = mpos;
Control *over = NULL;
-
// D&D
- if (!gui.drag_attempted && gui.mouse_focus && p_event.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
+ if (!gui.drag_attempted && gui.mouse_focus && p_event.mouse_motion.button_mask & BUTTON_MASK_LEFT) {
- gui.drag_accum+=Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y);
+ gui.drag_accum += Point2(p_event.mouse_motion.relative_x, p_event.mouse_motion.relative_y);
float len = gui.drag_accum.length();
- if (len>10) {
- gui.drag_data=gui.mouse_focus->get_drag_data(gui.focus_inv_xform.xform(mpos)-gui.drag_accum);
- if (gui.drag_data.get_type()!=Variant::NIL) {
+ if (len > 10) {
+ gui.drag_data = gui.mouse_focus->get_drag_data(gui.focus_inv_xform.xform(mpos) - gui.drag_accum);
+ if (gui.drag_data.get_type() != Variant::NIL) {
- gui.mouse_focus=NULL;
+ gui.mouse_focus = NULL;
}
- gui.drag_attempted=true;
- if (gui.drag_data.get_type()!=Variant::NIL) {
+ gui.drag_attempted = true;
+ if (gui.drag_data.get_type() != Variant::NIL) {
- _propagate_viewport_notification(this,NOTIFICATION_DRAG_BEGIN);
+ _propagate_viewport_notification(this, NOTIFICATION_DRAG_BEGIN);
}
}
}
-
if (gui.mouse_focus) {
- over=gui.mouse_focus;
+ over = gui.mouse_focus;
//recompute focus_inv_xform again here
} else {
@@ -1983,19 +1841,16 @@ void Viewport::_gui_input_event(InputEvent p_event) {
over = _gui_find_control(mpos);
}
-
-
- if (gui.drag_data.get_type()==Variant::NIL && over && !gui.modal_stack.empty()) {
+ if (gui.drag_data.get_type() == Variant::NIL && over && !gui.modal_stack.empty()) {
Control *top = gui.modal_stack.back()->get();
- if (over!=top && !top->is_a_parent_of(over)) {
+ if (over != top && !top->is_a_parent_of(over)) {
break; // don't send motion event to anything below modal stack top
}
}
-
- if (over!=gui.mouse_over) {
+ if (over != gui.mouse_over) {
if (gui.mouse_over)
gui.mouse_over->notification(Control::NOTIFICATION_MOUSE_EXIT);
@@ -2004,10 +1859,9 @@ void Viewport::_gui_input_event(InputEvent p_event) {
if (over)
over->notification(Control::NOTIFICATION_MOUSE_ENTER);
-
}
- gui.mouse_over=over;
+ gui.mouse_over = over;
if (gui.drag_preview) {
gui.drag_preview->set_pos(mpos);
@@ -2018,29 +1872,26 @@ void Viewport::_gui_input_event(InputEvent p_event) {
break;
}
-
Matrix32 localizer = over->get_global_transform_with_canvas().affine_inverse();
Size2 pos = localizer.xform(mpos);
- Vector2 speed = localizer.basis_xform(Point2(p_event.mouse_motion.speed_x,p_event.mouse_motion.speed_y));
- Vector2 rel = localizer.basis_xform(Point2(p_event.mouse_motion.relative_x,p_event.mouse_motion.relative_y));
-
+ Vector2 speed = localizer.basis_xform(Point2(p_event.mouse_motion.speed_x, p_event.mouse_motion.speed_y));
+ Vector2 rel = localizer.basis_xform(Point2(p_event.mouse_motion.relative_x, p_event.mouse_motion.relative_y));
p_event.mouse_motion.global_x = mpos.x;
p_event.mouse_motion.global_y = mpos.y;
- p_event.mouse_motion.speed_x=speed.x;
- p_event.mouse_motion.speed_y=speed.y;
- p_event.mouse_motion.relative_x=rel.x;
- p_event.mouse_motion.relative_y=rel.y;
+ p_event.mouse_motion.speed_x = speed.x;
+ p_event.mouse_motion.speed_y = speed.y;
+ p_event.mouse_motion.relative_x = rel.x;
+ p_event.mouse_motion.relative_y = rel.y;
- if (p_event.mouse_motion.button_mask==0) {
+ if (p_event.mouse_motion.button_mask == 0) {
//nothing pressed
- bool can_tooltip=true;
+ bool can_tooltip = true;
if (!gui.modal_stack.empty()) {
- if (gui.modal_stack.back()->get()!=over && !gui.modal_stack.back()->get()->is_a_parent_of(over))
- can_tooltip=false;
-
+ if (gui.modal_stack.back()->get() != over && !gui.modal_stack.back()->get()->is_a_parent_of(over))
+ can_tooltip = false;
}
bool is_tooltip_shown = false;
@@ -2053,51 +1904,40 @@ void Viewport::_gui_input_event(InputEvent p_event) {
_gui_cancel_tooltip();
else if (tooltip == gui.tooltip_label->get_text())
is_tooltip_shown = true;
- }
- else
+ } else
_gui_cancel_tooltip();
}
if (can_tooltip && !is_tooltip_shown) {
- gui.tooltip=over;
- gui.tooltip_pos=mpos;//(parent_xform * get_transform()).affine_inverse().xform(pos);
- gui.tooltip_timer=gui.tooltip_delay;
-
+ gui.tooltip = over;
+ gui.tooltip_pos = mpos; //(parent_xform * get_transform()).affine_inverse().xform(pos);
+ gui.tooltip_timer = gui.tooltip_delay;
}
}
-
//pos = gui.focus_inv_xform.xform(pos);
-
p_event.mouse_motion.x = pos.x;
p_event.mouse_motion.y = pos.y;
-
Control::CursorShape cursor_shape = over->get_cursor_shape(pos);
- OS::get_singleton()->set_cursor_shape( (OS::CursorShape)cursor_shape );
-
+ OS::get_singleton()->set_cursor_shape((OS::CursorShape)cursor_shape);
if (over->can_process()) {
- _gui_call_input(over,p_event);
+ _gui_call_input(over, p_event);
}
-
-
get_tree()->set_input_as_handled();
+ if (gui.drag_data.get_type() != Variant::NIL && p_event.mouse_motion.button_mask & BUTTON_MASK_LEFT) {
- if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
-
-
- bool can_drop = over->can_drop_data(pos,gui.drag_data);
+ bool can_drop = over->can_drop_data(pos, gui.drag_data);
if (!can_drop) {
- OS::get_singleton()->set_cursor_shape( OS::CURSOR_FORBIDDEN );
+ OS::get_singleton()->set_cursor_shape(OS::CURSOR_FORBIDDEN);
} else {
- OS::get_singleton()->set_cursor_shape( OS::CURSOR_CAN_DROP );
-
+ OS::get_singleton()->set_cursor_shape(OS::CURSOR_CAN_DROP);
}
//change mouse accordingly i guess
}
@@ -2108,21 +1948,19 @@ void Viewport::_gui_input_event(InputEvent p_event) {
case InputEvent::JOYSTICK_MOTION:
case InputEvent::KEY: {
-
if (gui.key_focus && !gui.key_focus->is_visible()) {
gui.key_focus->release_focus();
}
- if (gui.key_focus) {
+ if (gui.key_focus) {
- gui.key_event_accepted=false;
+ gui.key_event_accepted = false;
if (gui.key_focus->can_process()) {
- gui.key_focus->call_multilevel("_input_event",p_event);
+ gui.key_focus->call_multilevel("_input_event", p_event);
if (gui.key_focus) //maybe lost it
- gui.key_focus->emit_signal(SceneStringNames::get_singleton()->input_event,p_event);
+ gui.key_focus->emit_signal(SceneStringNames::get_singleton()->input_event, p_event);
}
-
if (gui.key_event_accepted) {
get_tree()->set_input_as_handled();
@@ -2130,7 +1968,6 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}
}
-
if (p_event.is_pressed() && p_event.is_action("ui_cancel") && !gui.modal_stack.empty()) {
_gui_sort_modal_stack();
@@ -2143,14 +1980,13 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}
}
-
- Control * from = gui.key_focus ? gui.key_focus : NULL; //hmm
+ Control *from = gui.key_focus ? gui.key_focus : NULL; //hmm
//keyboard focus
//if (from && p_event.key.pressed && !p_event.key.mod.alt && !p_event.key.mod.meta && !p_event.key.mod.command) {
if (from && p_event.is_pressed()) {
- Control * next=NULL;
+ Control *next = NULL;
if (p_event.is_action("ui_focus_next")) {
@@ -2182,7 +2018,6 @@ void Viewport::_gui_input_event(InputEvent p_event) {
next = from->_get_focus_neighbour(MARGIN_BOTTOM);
}
-
if (next) {
next->grab_focus();
get_tree()->set_input_as_handled();
@@ -2193,41 +2028,39 @@ void Viewport::_gui_input_event(InputEvent p_event) {
}
}
+List<Control *>::Element *Viewport::_gui_add_root_control(Control *p_control) {
-List<Control*>::Element* Viewport::_gui_add_root_control(Control* p_control) {
-
- gui.roots_order_dirty=true;
+ gui.roots_order_dirty = true;
return gui.roots.push_back(p_control);
}
-List<Control*>::Element* Viewport::_gui_add_subwindow_control(Control* p_control) {
+List<Control *>::Element *Viewport::_gui_add_subwindow_control(Control *p_control) {
- gui.subwindow_order_dirty=true;
+ gui.subwindow_order_dirty = true;
return gui.subwindows.push_back(p_control);
-
}
void Viewport::_gui_set_subwindow_order_dirty() {
- gui.subwindow_order_dirty=true;
+ gui.subwindow_order_dirty = true;
}
void Viewport::_gui_set_root_order_dirty() {
- gui.roots_order_dirty=true;
+ gui.roots_order_dirty = true;
}
-void Viewport::_gui_remove_modal_control(List<Control*>::Element *MI) {
+void Viewport::_gui_remove_modal_control(List<Control *>::Element *MI) {
gui.modal_stack.erase(MI);
}
-void Viewport::_gui_remove_from_modal_stack(List<Control*>::Element *MI,ObjectID p_prev_focus_owner) {
+void Viewport::_gui_remove_from_modal_stack(List<Control *>::Element *MI, ObjectID p_prev_focus_owner) {
//transfer the focus stack to the next
- List<Control*>::Element *next = MI->next();
+ List<Control *>::Element *next = MI->next();
gui.modal_stack.erase(MI);
- MI=NULL;
+ MI = NULL;
if (p_prev_focus_owner) {
@@ -2251,25 +2084,25 @@ void Viewport::_gui_remove_from_modal_stack(List<Control*>::Element *MI,ObjectID
}
}
-void Viewport::_gui_force_drag(Control *p_base, const Variant& p_data, Control *p_control) {
+void Viewport::_gui_force_drag(Control *p_base, const Variant &p_data, Control *p_control) {
ERR_EXPLAIN("Drag data must be a value");
- ERR_FAIL_COND(p_data.get_type()==Variant::NIL);
+ ERR_FAIL_COND(p_data.get_type() == Variant::NIL);
- gui.drag_data=p_data;
- gui.mouse_focus=NULL;
+ gui.drag_data = p_data;
+ gui.mouse_focus = NULL;
if (p_control) {
- _gui_set_drag_preview(p_base,p_control);
+ _gui_set_drag_preview(p_base, p_control);
}
}
void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) {
ERR_FAIL_NULL(p_control);
- ERR_FAIL_COND( !((Object*)p_control)->cast_to<Control>());
+ ERR_FAIL_COND(!((Object *)p_control)->cast_to<Control>());
ERR_FAIL_COND(p_control->is_inside_tree());
- ERR_FAIL_COND(p_control->get_parent()!=NULL);
+ ERR_FAIL_COND(p_control->get_parent() != NULL);
if (gui.drag_preview) {
memdelete(gui.drag_preview);
@@ -2279,25 +2112,24 @@ void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) {
p_base->get_root_parent_control()->add_child(p_control); //add as child of viewport
p_control->raise();
if (gui.drag_preview) {
- memdelete( gui.drag_preview );
+ memdelete(gui.drag_preview);
}
- gui.drag_preview=p_control;
+ gui.drag_preview = p_control;
}
-
-void Viewport::_gui_remove_root_control(List<Control*>::Element *RI) {
+void Viewport::_gui_remove_root_control(List<Control *>::Element *RI) {
gui.roots.erase(RI);
}
-void Viewport::_gui_remove_subwindow_control(List<Control*>::Element* SI){
+void Viewport::_gui_remove_subwindow_control(List<Control *>::Element *SI) {
gui.subwindows.erase(SI);
}
void Viewport::_gui_unfocus_control(Control *p_control) {
- if (gui.key_focus==p_control) {
+ if (gui.key_focus == p_control) {
gui.key_focus->release_focus();
}
}
@@ -2305,7 +2137,7 @@ void Viewport::_gui_unfocus_control(Control *p_control) {
void Viewport::_gui_hid_control(Control *p_control) {
if (gui.mouse_focus == p_control) {
- gui.mouse_focus=NULL;
+ gui.mouse_focus = NULL;
}
/* ???
@@ -2319,81 +2151,71 @@ void Viewport::_gui_hid_control(Control *p_control) {
*/
if (gui.key_focus == p_control)
- gui.key_focus=NULL;
+ gui.key_focus = NULL;
if (gui.mouse_over == p_control)
- gui.mouse_over=NULL;
+ gui.mouse_over = NULL;
if (gui.tooltip == p_control)
- gui.tooltip=NULL;
+ gui.tooltip = NULL;
if (gui.tooltip == p_control) {
- gui.tooltip=NULL;
+ gui.tooltip = NULL;
_gui_cancel_tooltip();
}
-
}
void Viewport::_gui_remove_control(Control *p_control) {
-
if (gui.mouse_focus == p_control)
- gui.mouse_focus=NULL;
+ gui.mouse_focus = NULL;
if (gui.key_focus == p_control)
- gui.key_focus=NULL;
+ gui.key_focus = NULL;
if (gui.mouse_over == p_control)
- gui.mouse_over=NULL;
+ gui.mouse_over = NULL;
if (gui.tooltip == p_control)
- gui.tooltip=NULL;
+ gui.tooltip = NULL;
if (gui.tooltip_popup == p_control) {
_gui_cancel_tooltip();
}
-
-
}
void Viewport::_gui_remove_focus() {
if (gui.key_focus) {
- Node *f=gui.key_focus;
- gui.key_focus=NULL;
- f->notification( Control::NOTIFICATION_FOCUS_EXIT,true );
-
-
+ Node *f = gui.key_focus;
+ gui.key_focus = NULL;
+ f->notification(Control::NOTIFICATION_FOCUS_EXIT, true);
}
}
-bool Viewport::_gui_is_modal_on_top(const Control* p_control) {
-
- return (gui.modal_stack.size() && gui.modal_stack.back()->get()==p_control);
+bool Viewport::_gui_is_modal_on_top(const Control *p_control) {
+ return (gui.modal_stack.size() && gui.modal_stack.back()->get() == p_control);
}
-bool Viewport::_gui_control_has_focus(const Control* p_control) {
+bool Viewport::_gui_control_has_focus(const Control *p_control) {
- return gui.key_focus==p_control;
+ return gui.key_focus == p_control;
}
-void Viewport::_gui_control_grab_focus(Control* p_control) {
-
+void Viewport::_gui_control_grab_focus(Control *p_control) {
//no need for change
- if (gui.key_focus && gui.key_focus==p_control)
+ if (gui.key_focus && gui.key_focus == p_control)
return;
- get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"_viewports","_gui_remove_focus");
- gui.key_focus=p_control;
+ get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME, "_viewports", "_gui_remove_focus");
+ gui.key_focus = p_control;
p_control->notification(Control::NOTIFICATION_FOCUS_ENTER);
p_control->update();
-
}
void Viewport::_gui_accept_event() {
- gui.key_event_accepted=true;
+ gui.key_event_accepted = true;
if (is_inside_tree())
get_tree()->set_input_as_handled();
}
-
-List<Control*>::Element* Viewport::_gui_show_modal(Control* p_control) {
+List<Control *>::Element *Viewport::_gui_show_modal(Control *p_control) {
gui.modal_stack.push_back(p_control);
if (gui.key_focus)
@@ -2413,77 +2235,67 @@ void Viewport::_gui_grab_click_focus(Control *p_control) {
if (gui.mouse_focus) {
-
- if (gui.mouse_focus==p_control)
+ if (gui.mouse_focus == p_control)
return;
InputEvent ie;
- ie.type=InputEvent::MOUSE_BUTTON;
- InputEventMouseButton &mb=ie.mouse_button;
+ ie.type = InputEvent::MOUSE_BUTTON;
+ InputEventMouseButton &mb = ie.mouse_button;
//send unclic
- Point2 click =gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
- mb.x=click.x;
- mb.y=click.y;
- mb.button_index=gui.mouse_focus_button;
- mb.pressed=false;
- gui.mouse_focus->call_deferred("_input_event",ie);
-
-
- gui.mouse_focus=p_control;
- gui.focus_inv_xform=gui.mouse_focus->get_global_transform_with_canvas().affine_inverse();
- click =gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
- mb.x=click.x;
- mb.y=click.y;
- mb.button_index=gui.mouse_focus_button;
- mb.pressed=true;
- gui.mouse_focus->call_deferred("_input_event",ie);
+ Point2 click = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
+ mb.x = click.x;
+ mb.y = click.y;
+ mb.button_index = gui.mouse_focus_button;
+ mb.pressed = false;
+ gui.mouse_focus->call_deferred("_input_event", ie);
+ gui.mouse_focus = p_control;
+ gui.focus_inv_xform = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse();
+ click = gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos);
+ mb.x = click.x;
+ mb.y = click.y;
+ mb.button_index = gui.mouse_focus_button;
+ mb.pressed = true;
+ gui.mouse_focus->call_deferred("_input_event", ie);
}
}
-
///////////////////////////////
-
-void Viewport::input(const InputEvent& p_event) {
+void Viewport::input(const InputEvent &p_event) {
ERR_FAIL_COND(!is_inside_tree());
-
- get_tree()->_call_input_pause(input_group,"_input",p_event); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
+ get_tree()->_call_input_pause(input_group, "_input", p_event); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
_gui_input_event(p_event);
//get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",p_event); //special one for GUI, as controls use their own process check
}
-void Viewport::unhandled_input(const InputEvent& p_event) {
+void Viewport::unhandled_input(const InputEvent &p_event) {
ERR_FAIL_COND(!is_inside_tree());
-
- get_tree()->_call_input_pause(unhandled_input_group,"_unhandled_input",p_event);
+ get_tree()->_call_input_pause(unhandled_input_group, "_unhandled_input", p_event);
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev);
- if (!get_tree()->input_handled && p_event.type==InputEvent::KEY) {
- get_tree()->_call_input_pause(unhandled_key_input_group,"_unhandled_key_input",p_event);
+ if (!get_tree()->input_handled && p_event.type == InputEvent::KEY) {
+ get_tree()->_call_input_pause(unhandled_key_input_group, "_unhandled_key_input", p_event);
//call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev);
}
-
if (physics_object_picking && !get_tree()->input_handled) {
- if (p_event.type==InputEvent::MOUSE_BUTTON || p_event.type==InputEvent::MOUSE_MOTION || p_event.type==InputEvent::SCREEN_DRAG || p_event.type==InputEvent::SCREEN_TOUCH) {
+ if (p_event.type == InputEvent::MOUSE_BUTTON || p_event.type == InputEvent::MOUSE_MOTION || p_event.type == InputEvent::SCREEN_DRAG || p_event.type == InputEvent::SCREEN_TOUCH) {
physics_picking_events.push_back(p_event);
}
}
-
}
void Viewport::set_use_own_world(bool p_world) {
- if (p_world==own_world.is_valid())
+ if (p_world == own_world.is_valid())
return;
-
if (is_inside_tree())
_propagate_exit_world(this);
@@ -2493,9 +2305,9 @@ void Viewport::set_use_own_world(bool p_world) {
#endif
if (!p_world)
- own_world=Ref<World>();
+ own_world = Ref<World>();
else
- own_world=Ref<World>( memnew( World ));
+ own_world = Ref<World>(memnew(World));
if (is_inside_tree())
_propagate_enter_world(this);
@@ -2508,12 +2320,10 @@ void Viewport::set_use_own_world(bool p_world) {
//propagate exit
if (is_inside_tree()) {
- VisualServer::get_singleton()->viewport_set_scenario(viewport,find_world()->get_scenario());
+ VisualServer::get_singleton()->viewport_set_scenario(viewport, find_world()->get_scenario());
}
_update_listener();
-
-
}
bool Viewport::is_using_own_world() const {
@@ -2521,34 +2331,29 @@ bool Viewport::is_using_own_world() const {
return own_world.is_valid();
}
-void Viewport::set_render_target_to_screen_rect(const Rect2& p_rect) {
+void Viewport::set_render_target_to_screen_rect(const Rect2 &p_rect) {
- to_screen_rect=p_rect;
- VisualServer::get_singleton()->viewport_set_render_target_to_screen_rect(viewport,to_screen_rect);
+ to_screen_rect = p_rect;
+ VisualServer::get_singleton()->viewport_set_render_target_to_screen_rect(viewport, to_screen_rect);
}
-Rect2 Viewport::get_render_target_to_screen_rect() const{
+Rect2 Viewport::get_render_target_to_screen_rect() const {
return to_screen_rect;
}
void Viewport::set_physics_object_picking(bool p_enable) {
- physics_object_picking=p_enable;
+ physics_object_picking = p_enable;
set_fixed_process(physics_object_picking);
if (!physics_object_picking)
physics_picking_events.clear();
-
-
}
-
Vector2 Viewport::get_camera_coords(const Vector2 &p_viewport_coords) const {
Matrix32 xf = get_final_transform();
return xf.xform(p_viewport_coords);
-
-
}
Vector2 Viewport::get_camera_rect_size() const {
@@ -2556,10 +2361,8 @@ Vector2 Viewport::get_camera_rect_size() const {
return last_vp_rect.size;
}
-
bool Viewport::get_physics_object_picking() {
-
return physics_object_picking;
}
@@ -2569,7 +2372,7 @@ bool Viewport::gui_has_modal_stack() const {
}
void Viewport::set_disable_input(bool p_disable) {
- disable_input=p_disable;
+ disable_input = p_disable;
}
bool Viewport::is_input_disabled() const {
@@ -2582,7 +2385,7 @@ Variant Viewport::gui_get_drag_data() const {
}
Control *Viewport::get_modal_stack_top() const {
- return gui.modal_stack.size()?gui.modal_stack.back()->get():NULL;
+ return gui.modal_stack.size() ? gui.modal_stack.back()->get() : NULL;
}
String Viewport::get_configuration_warning() const {
@@ -2597,190 +2400,176 @@ String Viewport::get_configuration_warning() const {
void Viewport::_bind_methods() {
-
- ObjectTypeDB::bind_method(_MD("set_rect","rect"), &Viewport::set_rect);
+ ObjectTypeDB::bind_method(_MD("set_rect", "rect"), &Viewport::set_rect);
ObjectTypeDB::bind_method(_MD("get_rect"), &Viewport::get_rect);
- ObjectTypeDB::bind_method(_MD("set_world_2d","world_2d:World2D"), &Viewport::set_world_2d);
+ ObjectTypeDB::bind_method(_MD("set_world_2d", "world_2d:World2D"), &Viewport::set_world_2d);
ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"), &Viewport::get_world_2d);
ObjectTypeDB::bind_method(_MD("find_world_2d:World2D"), &Viewport::find_world_2d);
- ObjectTypeDB::bind_method(_MD("set_world","world:World"), &Viewport::set_world);
+ ObjectTypeDB::bind_method(_MD("set_world", "world:World"), &Viewport::set_world);
ObjectTypeDB::bind_method(_MD("get_world:World"), &Viewport::get_world);
ObjectTypeDB::bind_method(_MD("find_world:World"), &Viewport::find_world);
- ObjectTypeDB::bind_method(_MD("set_canvas_transform","xform"), &Viewport::set_canvas_transform);
+ ObjectTypeDB::bind_method(_MD("set_canvas_transform", "xform"), &Viewport::set_canvas_transform);
ObjectTypeDB::bind_method(_MD("get_canvas_transform"), &Viewport::get_canvas_transform);
- ObjectTypeDB::bind_method(_MD("set_global_canvas_transform","xform"), &Viewport::set_global_canvas_transform);
+ ObjectTypeDB::bind_method(_MD("set_global_canvas_transform", "xform"), &Viewport::set_global_canvas_transform);
ObjectTypeDB::bind_method(_MD("get_global_canvas_transform"), &Viewport::get_global_canvas_transform);
ObjectTypeDB::bind_method(_MD("get_final_transform"), &Viewport::get_final_transform);
ObjectTypeDB::bind_method(_MD("get_visible_rect"), &Viewport::get_visible_rect);
- ObjectTypeDB::bind_method(_MD("set_transparent_background","enable"), &Viewport::set_transparent_background);
+ ObjectTypeDB::bind_method(_MD("set_transparent_background", "enable"), &Viewport::set_transparent_background);
ObjectTypeDB::bind_method(_MD("has_transparent_background"), &Viewport::has_transparent_background);
ObjectTypeDB::bind_method(_MD("_parent_visibility_changed"), &Viewport::_parent_visibility_changed);
ObjectTypeDB::bind_method(_MD("_parent_resized"), &Viewport::_parent_resized);
ObjectTypeDB::bind_method(_MD("_vp_input"), &Viewport::_vp_input);
- ObjectTypeDB::bind_method(_MD("_vp_input_text","text"), &Viewport::_vp_input_text);
+ ObjectTypeDB::bind_method(_MD("_vp_input_text", "text"), &Viewport::_vp_input_text);
ObjectTypeDB::bind_method(_MD("_vp_unhandled_input"), &Viewport::_vp_unhandled_input);
- ObjectTypeDB::bind_method(_MD("set_size_override","enable","size","margin"), &Viewport::set_size_override,DEFVAL(Size2(-1,-1)),DEFVAL(Size2(0,0)));
+ ObjectTypeDB::bind_method(_MD("set_size_override", "enable", "size", "margin"), &Viewport::set_size_override, DEFVAL(Size2(-1, -1)), DEFVAL(Size2(0, 0)));
ObjectTypeDB::bind_method(_MD("get_size_override"), &Viewport::get_size_override);
ObjectTypeDB::bind_method(_MD("is_size_override_enabled"), &Viewport::is_size_override_enabled);
- ObjectTypeDB::bind_method(_MD("set_size_override_stretch","enabled"), &Viewport::set_size_override_stretch);
+ ObjectTypeDB::bind_method(_MD("set_size_override_stretch", "enabled"), &Viewport::set_size_override_stretch);
ObjectTypeDB::bind_method(_MD("is_size_override_stretch_enabled"), &Viewport::is_size_override_stretch_enabled);
ObjectTypeDB::bind_method(_MD("queue_screen_capture"), &Viewport::queue_screen_capture);
ObjectTypeDB::bind_method(_MD("get_screen_capture"), &Viewport::get_screen_capture);
- ObjectTypeDB::bind_method(_MD("set_as_render_target","enable"), &Viewport::set_as_render_target);
+ ObjectTypeDB::bind_method(_MD("set_as_render_target", "enable"), &Viewport::set_as_render_target);
ObjectTypeDB::bind_method(_MD("is_set_as_render_target"), &Viewport::is_set_as_render_target);
- ObjectTypeDB::bind_method(_MD("set_render_target_vflip","enable"), &Viewport::set_render_target_vflip);
+ ObjectTypeDB::bind_method(_MD("set_render_target_vflip", "enable"), &Viewport::set_render_target_vflip);
ObjectTypeDB::bind_method(_MD("get_render_target_vflip"), &Viewport::get_render_target_vflip);
- ObjectTypeDB::bind_method(_MD("set_render_target_clear_on_new_frame","enable"), &Viewport::set_render_target_clear_on_new_frame);
+ ObjectTypeDB::bind_method(_MD("set_render_target_clear_on_new_frame", "enable"), &Viewport::set_render_target_clear_on_new_frame);
ObjectTypeDB::bind_method(_MD("get_render_target_clear_on_new_frame"), &Viewport::get_render_target_clear_on_new_frame);
ObjectTypeDB::bind_method(_MD("render_target_clear"), &Viewport::render_target_clear);
- ObjectTypeDB::bind_method(_MD("set_render_target_filter","enable"), &Viewport::set_render_target_filter);
+ ObjectTypeDB::bind_method(_MD("set_render_target_filter", "enable"), &Viewport::set_render_target_filter);
ObjectTypeDB::bind_method(_MD("get_render_target_filter"), &Viewport::get_render_target_filter);
- ObjectTypeDB::bind_method(_MD("set_render_target_gen_mipmaps","enable"), &Viewport::set_render_target_gen_mipmaps);
+ ObjectTypeDB::bind_method(_MD("set_render_target_gen_mipmaps", "enable"), &Viewport::set_render_target_gen_mipmaps);
ObjectTypeDB::bind_method(_MD("get_render_target_gen_mipmaps"), &Viewport::get_render_target_gen_mipmaps);
- ObjectTypeDB::bind_method(_MD("set_render_target_update_mode","mode"), &Viewport::set_render_target_update_mode);
+ ObjectTypeDB::bind_method(_MD("set_render_target_update_mode", "mode"), &Viewport::set_render_target_update_mode);
ObjectTypeDB::bind_method(_MD("get_render_target_update_mode"), &Viewport::get_render_target_update_mode);
ObjectTypeDB::bind_method(_MD("get_render_target_texture:RenderTargetTexture"), &Viewport::get_render_target_texture);
- ObjectTypeDB::bind_method(_MD("set_physics_object_picking","enable"), &Viewport::set_physics_object_picking);
+ ObjectTypeDB::bind_method(_MD("set_physics_object_picking", "enable"), &Viewport::set_physics_object_picking);
ObjectTypeDB::bind_method(_MD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
ObjectTypeDB::bind_method(_MD("get_viewport"), &Viewport::get_viewport);
- ObjectTypeDB::bind_method(_MD("input","local_event"), &Viewport::input);
- ObjectTypeDB::bind_method(_MD("unhandled_input","local_event"), &Viewport::unhandled_input);
+ ObjectTypeDB::bind_method(_MD("input", "local_event"), &Viewport::input);
+ ObjectTypeDB::bind_method(_MD("unhandled_input", "local_event"), &Viewport::unhandled_input);
ObjectTypeDB::bind_method(_MD("update_worlds"), &Viewport::update_worlds);
- ObjectTypeDB::bind_method(_MD("set_use_own_world","enable"), &Viewport::set_use_own_world);
+ ObjectTypeDB::bind_method(_MD("set_use_own_world", "enable"), &Viewport::set_use_own_world);
ObjectTypeDB::bind_method(_MD("is_using_own_world"), &Viewport::is_using_own_world);
ObjectTypeDB::bind_method(_MD("get_camera:Camera"), &Viewport::get_camera);
- ObjectTypeDB::bind_method(_MD("set_as_audio_listener","enable"), &Viewport::set_as_audio_listener);
- ObjectTypeDB::bind_method(_MD("is_audio_listener","enable"), &Viewport::is_audio_listener);
+ ObjectTypeDB::bind_method(_MD("set_as_audio_listener", "enable"), &Viewport::set_as_audio_listener);
+ ObjectTypeDB::bind_method(_MD("is_audio_listener", "enable"), &Viewport::is_audio_listener);
- ObjectTypeDB::bind_method(_MD("set_as_audio_listener_2d","enable"), &Viewport::set_as_audio_listener_2d);
- ObjectTypeDB::bind_method(_MD("is_audio_listener_2d","enable"), &Viewport::is_audio_listener_2d);
- ObjectTypeDB::bind_method(_MD("set_render_target_to_screen_rect","rect"), &Viewport::set_render_target_to_screen_rect);
+ ObjectTypeDB::bind_method(_MD("set_as_audio_listener_2d", "enable"), &Viewport::set_as_audio_listener_2d);
+ ObjectTypeDB::bind_method(_MD("is_audio_listener_2d", "enable"), &Viewport::is_audio_listener_2d);
+ ObjectTypeDB::bind_method(_MD("set_render_target_to_screen_rect", "rect"), &Viewport::set_render_target_to_screen_rect);
ObjectTypeDB::bind_method(_MD("get_mouse_pos"), &Viewport::get_mouse_pos);
- ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"), &Viewport::warp_mouse);
+ ObjectTypeDB::bind_method(_MD("warp_mouse", "to_pos"), &Viewport::warp_mouse);
ObjectTypeDB::bind_method(_MD("gui_has_modal_stack"), &Viewport::gui_has_modal_stack);
ObjectTypeDB::bind_method(_MD("gui_get_drag_data:Variant"), &Viewport::gui_get_drag_data);
- ObjectTypeDB::bind_method(_MD("set_disable_input","disable"), &Viewport::set_disable_input);
+ ObjectTypeDB::bind_method(_MD("set_disable_input", "disable"), &Viewport::set_disable_input);
ObjectTypeDB::bind_method(_MD("is_input_disabled"), &Viewport::is_input_disabled);
ObjectTypeDB::bind_method(_MD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip);
ObjectTypeDB::bind_method(_MD("_gui_remove_focus"), &Viewport::_gui_remove_focus);
- ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"), _SCS("set_rect"), _SCS("get_rect") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"own_world"), _SCS("set_use_own_world"), _SCS("is_using_own_world") );
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world",PROPERTY_HINT_RESOURCE_TYPE,"World"), _SCS("set_world"), _SCS("get_world") );
-// ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world_2d",PROPERTY_HINT_RESOURCE_TYPE,"World2D"), _SCS("set_world_2d"), _SCS("get_world_2d") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transparent_bg"), _SCS("set_transparent_background"), _SCS("has_transparent_background") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/enabled"), _SCS("set_as_render_target"), _SCS("is_set_as_render_target") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/v_flip"), _SCS("set_render_target_vflip"), _SCS("get_render_target_vflip") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/clear_on_new_frame"), _SCS("set_render_target_clear_on_new_frame"), _SCS("get_render_target_clear_on_new_frame") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/filter"), _SCS("set_render_target_filter"), _SCS("get_render_target_filter") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/gen_mipmaps"), _SCS("set_render_target_gen_mipmaps"), _SCS("get_render_target_gen_mipmaps") );
- ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target/update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), _SCS("set_render_target_update_mode"), _SCS("get_render_target_update_mode") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener/enable_2d"), _SCS("set_as_audio_listener_2d"), _SCS("is_audio_listener_2d") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener/enable_3d"), _SCS("set_as_audio_listener"), _SCS("is_audio_listener") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"physics/object_picking"), _SCS("set_physics_object_picking"), _SCS("get_physics_object_picking") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gui/disable_input"), _SCS("set_disable_input"), _SCS("is_input_disabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::RECT2, "rect"), _SCS("set_rect"), _SCS("get_rect"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world"), _SCS("set_use_own_world"), _SCS("is_using_own_world"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world", PROPERTY_HINT_RESOURCE_TYPE, "World"), _SCS("set_world"), _SCS("get_world"));
+ // ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world_2d",PROPERTY_HINT_RESOURCE_TYPE,"World2D"), _SCS("set_world_2d"), _SCS("get_world_2d") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent_bg"), _SCS("set_transparent_background"), _SCS("has_transparent_background"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target/enabled"), _SCS("set_as_render_target"), _SCS("is_set_as_render_target"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target/v_flip"), _SCS("set_render_target_vflip"), _SCS("get_render_target_vflip"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target/clear_on_new_frame"), _SCS("set_render_target_clear_on_new_frame"), _SCS("get_render_target_clear_on_new_frame"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target/filter"), _SCS("set_render_target_filter"), _SCS("get_render_target_filter"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target/gen_mipmaps"), _SCS("set_render_target_gen_mipmaps"), _SCS("get_render_target_gen_mipmaps"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target/update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,Always"), _SCS("set_render_target_update_mode"), _SCS("get_render_target_update_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener/enable_2d"), _SCS("set_as_audio_listener_2d"), _SCS("is_audio_listener_2d"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener/enable_3d"), _SCS("set_as_audio_listener"), _SCS("is_audio_listener"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "physics/object_picking"), _SCS("set_physics_object_picking"), _SCS("get_physics_object_picking"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui/disable_input"), _SCS("set_disable_input"), _SCS("is_input_disabled"));
ADD_SIGNAL(MethodInfo("size_changed"));
- BIND_CONSTANT( RENDER_TARGET_UPDATE_DISABLED );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_ONCE );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_WHEN_VISIBLE );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_ALWAYS );
-
+ BIND_CONSTANT(RENDER_TARGET_UPDATE_DISABLED);
+ BIND_CONSTANT(RENDER_TARGET_UPDATE_ONCE);
+ BIND_CONSTANT(RENDER_TARGET_UPDATE_WHEN_VISIBLE);
+ BIND_CONSTANT(RENDER_TARGET_UPDATE_ALWAYS);
}
-
-
-
-
Viewport::Viewport() {
-
- world_2d = Ref<World2D>( memnew( World2D ));
+ world_2d = Ref<World2D>(memnew(World2D));
viewport = VisualServer::get_singleton()->viewport_create();
internal_listener = SpatialSoundServer::get_singleton()->listener_create();
- audio_listener=false;
+ audio_listener = false;
internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create();
- audio_listener_2d=false;
- transparent_bg=false;
- parent=NULL;
- listener=NULL;
- camera=NULL;
- size_override=false;
- size_override_stretch=false;
- size_override_size=Size2(1,1);
- render_target_gen_mipmaps=false;
- render_target=false;
- render_target_vflip=false;
- render_target_clear_on_new_frame=true;
+ audio_listener_2d = false;
+ transparent_bg = false;
+ parent = NULL;
+ listener = NULL;
+ camera = NULL;
+ size_override = false;
+ size_override_stretch = false;
+ size_override_size = Size2(1, 1);
+ render_target_gen_mipmaps = false;
+ render_target = false;
+ render_target_vflip = false;
+ render_target_clear_on_new_frame = true;
//render_target_clear=true;
- render_target_update_mode=RENDER_TARGET_UPDATE_WHEN_VISIBLE;
- render_target_texture = Ref<RenderTargetTexture>( memnew( RenderTargetTexture(this) ) );
+ render_target_update_mode = RENDER_TARGET_UPDATE_WHEN_VISIBLE;
+ render_target_texture = Ref<RenderTargetTexture>(memnew(RenderTargetTexture(this)));
- physics_object_picking=false;
- physics_object_capture=0;
- physics_object_over=0;
- physics_last_mousepos=Vector2(1e20,1e20);
+ physics_object_picking = false;
+ physics_object_capture = 0;
+ physics_object_over = 0;
+ physics_last_mousepos = Vector2(1e20, 1e20);
+ String id = itos(get_instance_ID());
+ input_group = "_vp_input" + id;
+ gui_input_group = "_vp_gui_input" + id;
+ unhandled_input_group = "_vp_unhandled_input" + id;
+ unhandled_key_input_group = "_vp_unhandled_key_input" + id;
- String id=itos(get_instance_ID());
- input_group = "_vp_input"+id;
- gui_input_group = "_vp_gui_input"+id;
- unhandled_input_group = "_vp_unhandled_input"+id;
- unhandled_key_input_group = "_vp_unhandled_key_input"+id;
-
- disable_input=false;
+ disable_input = false;
//window tooltip
gui.tooltip_timer = -1;
//gui.tooltip_timer->force_parent_owned();
- gui.tooltip_delay=GLOBAL_DEF("display/tooltip_delay",0.7);
-
- gui.tooltip=NULL;
- gui.tooltip_label=NULL;
- gui.drag_preview=NULL;
- gui.drag_attempted=false;
-
-
- parent_control=NULL;
+ gui.tooltip_delay = GLOBAL_DEF("display/tooltip_delay", 0.7);
+ gui.tooltip = NULL;
+ gui.tooltip_label = NULL;
+ gui.drag_preview = NULL;
+ gui.drag_attempted = false;
+ parent_control = NULL;
}
-
Viewport::~Viewport() {
- VisualServer::get_singleton()->free( viewport );
+ VisualServer::get_singleton()->free(viewport);
SpatialSoundServer::get_singleton()->free(internal_listener);
SpatialSound2DServer::get_singleton()->free(internal_listener_2d);
if (render_target_texture.is_valid())
- render_target_texture->vp=NULL; //so if used, will crash
+ render_target_texture->vp = NULL; //so if used, will crash
}
-
-
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 2a54aec96..b9103ac48 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -29,11 +29,11 @@
#ifndef VIEWPORT_H
#define VIEWPORT_H
-#include "scene/main/node.h"
-#include "servers/visual_server.h"
-#include "scene/resources/world_2d.h"
#include "math_2d.h"
+#include "scene/main/node.h"
#include "scene/resources/texture.h"
+#include "scene/resources/world_2d.h"
+#include "servers/visual_server.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -50,16 +50,13 @@ class Viewport;
class RenderTargetTexture : public Texture {
- OBJ_TYPE( RenderTargetTexture, Texture );
+ OBJ_TYPE(RenderTargetTexture, Texture);
int flags;
-friend class Viewport;
+ friend class Viewport;
Viewport *vp;
-
public:
-
-
virtual int get_width() const;
virtual int get_height() const;
virtual Size2 get_size() const;
@@ -70,15 +67,14 @@ public:
virtual void set_flags(uint32_t p_flags);
virtual uint32_t get_flags() const;
- RenderTargetTexture(Viewport *p_vp=NULL);
-
+ RenderTargetTexture(Viewport *p_vp = NULL);
};
class Viewport : public Node {
- OBJ_TYPE( Viewport, Node );
-public:
+ OBJ_TYPE(Viewport, Node);
+public:
enum RenderTargetUpdateMode {
RENDER_TARGET_UPDATE_DISABLED,
RENDER_TARGET_UPDATE_ONCE, //then goes to disabled
@@ -87,18 +83,16 @@ public:
};
private:
-
-friend class RenderTargetTexture;
-
+ friend class RenderTargetTexture;
Control *parent_control;
Viewport *parent;
Listener *listener;
- Set<Listener*> listeners;
+ Set<Listener *> listeners;
Camera *camera;
- Set<Camera*> cameras;
+ Set<Camera *> cameras;
RID viewport;
RID canvas_item;
@@ -121,8 +115,6 @@ friend class RenderTargetTexture;
RID contact_3d_debug_multimesh;
RID contact_3d_debug_instance;
-
-
bool size_override;
bool size_override_stretch;
Size2 size_override_size;
@@ -142,7 +134,7 @@ friend class RenderTargetTexture;
ObjectID physics_object_over;
Vector2 physics_last_mousepos;
void _test_new_mouseover(ObjectID new_collider);
- Map<ObjectID,uint64_t> physics_2d_mouseover;
+ Map<ObjectID, uint64_t> physics_2d_mouseover;
void _update_rect();
@@ -166,7 +158,6 @@ friend class RenderTargetTexture;
void _propagate_exit_world(Node *p_node);
void _propagate_viewport_notification(Node *p_node, int p_what);
-
void _update_stretch_transform();
void _update_global_transform();
@@ -175,7 +166,6 @@ friend class RenderTargetTexture;
RID render_target_texture_rid;
Ref<RenderTargetTexture> render_target_texture;
-
struct GUI {
// info used when this is a window
@@ -195,30 +185,28 @@ friend class RenderTargetTexture;
Control *drag_preview;
float tooltip_timer;
float tooltip_delay;
- List<Control*> modal_stack;
+ List<Control *> modal_stack;
unsigned int cancelled_input_ID;
Matrix32 focus_inv_xform;
bool subwindow_order_dirty;
- List<Control*> subwindows;
+ List<Control *> subwindows;
bool roots_order_dirty;
- List<Control*> roots;
-
+ List<Control *> roots;
GUI();
} gui;
bool disable_input;
- void _gui_call_input(Control *p_control,const InputEvent& p_input);
+ void _gui_call_input(Control *p_control, const InputEvent &p_input);
void _gui_sort_subwindows();
void _gui_sort_roots();
void _gui_sort_modal_stack();
- Control* _gui_find_control(const Point2& p_global);
- Control* _gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_global,const Matrix32& p_xform,Matrix32& r_inv_xform);
+ Control *_gui_find_control(const Point2 &p_global);
+ Control *_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Matrix32 &p_xform, Matrix32 &r_inv_xform);
void _gui_input_event(InputEvent p_event);
-
void update_worlds();
_FORCE_INLINE_ Matrix32 _get_input_pre_xform() const;
@@ -226,43 +214,40 @@ friend class RenderTargetTexture;
void _vp_enter_tree();
void _vp_exit_tree();
- void _vp_input(const InputEvent& p_ev);
- void _vp_input_text(const String& p_text);
- void _vp_unhandled_input(const InputEvent& p_ev);
- void _make_input_local(InputEvent& ev);
-
+ void _vp_input(const InputEvent &p_ev);
+ void _vp_input_text(const String &p_text);
+ void _vp_unhandled_input(const InputEvent &p_ev);
+ void _make_input_local(InputEvent &ev);
-friend class Control;
+ friend class Control;
- List<Control*>::Element* _gui_add_root_control(Control* p_control);
- List<Control*>::Element* _gui_add_subwindow_control(Control* p_control);
+ List<Control *>::Element *_gui_add_root_control(Control *p_control);
+ List<Control *>::Element *_gui_add_subwindow_control(Control *p_control);
void _gui_set_subwindow_order_dirty();
void _gui_set_root_order_dirty();
-
- void _gui_remove_modal_control(List<Control*>::Element *MI);
- void _gui_remove_from_modal_stack(List<Control*>::Element *MI,ObjectID p_prev_focus_owner);
- void _gui_remove_root_control(List<Control*>::Element *RI);
- void _gui_remove_subwindow_control(List<Control*>::Element* SI);
+ void _gui_remove_modal_control(List<Control *>::Element *MI);
+ void _gui_remove_from_modal_stack(List<Control *>::Element *MI, ObjectID p_prev_focus_owner);
+ void _gui_remove_root_control(List<Control *>::Element *RI);
+ void _gui_remove_subwindow_control(List<Control *>::Element *SI);
void _gui_cancel_tooltip();
void _gui_show_tooltip();
-
void _gui_remove_control(Control *p_control);
void _gui_hid_control(Control *p_control);
- void _gui_force_drag(Control *p_base,const Variant& p_data,Control *p_control);
- void _gui_set_drag_preview(Control *p_base,Control *p_control);
+ void _gui_force_drag(Control *p_base, const Variant &p_data, Control *p_control);
+ void _gui_set_drag_preview(Control *p_base, Control *p_control);
- bool _gui_is_modal_on_top(const Control* p_control);
- List<Control*>::Element* _gui_show_modal(Control* p_control);
+ bool _gui_is_modal_on_top(const Control *p_control);
+ List<Control *>::Element *_gui_show_modal(Control *p_control);
void _gui_remove_focus();
void _gui_unfocus_control(Control *p_control);
- bool _gui_control_has_focus(const Control* p_control);
- void _gui_control_grab_focus(Control* p_control);
+ bool _gui_control_has_focus(const Control *p_control);
+ void _gui_control_grab_focus(Control *p_control);
void _gui_grab_click_focus(Control *p_control);
void _gui_accept_event();
@@ -270,28 +255,27 @@ friend class Control;
Vector2 _get_window_offset() const;
-friend class Listener;
+ friend class Listener;
void _listener_transform_changed_notify();
- void _listener_set(Listener* p_listener);
- bool _listener_add(Listener* p_listener); //true if first
- void _listener_remove(Listener* p_listener);
- void _listener_make_next_current(Listener* p_exclude);
+ void _listener_set(Listener *p_listener);
+ bool _listener_add(Listener *p_listener); //true if first
+ void _listener_remove(Listener *p_listener);
+ void _listener_make_next_current(Listener *p_exclude);
-friend class Camera;
+ friend class Camera;
void _camera_transform_changed_notify();
- void _camera_set(Camera* p_camera);
- bool _camera_add(Camera* p_camera); //true if first
- void _camera_remove(Camera* p_camera);
- void _camera_make_next_current(Camera* p_exclude);
-
+ void _camera_set(Camera *p_camera);
+ bool _camera_add(Camera *p_camera); //true if first
+ void _camera_remove(Camera *p_camera);
+ void _camera_make_next_current(Camera *p_exclude);
protected:
void _notification(int p_what);
static void _bind_methods();
-public:
- Listener* get_listener() const;
- Camera* get_camera() const;
+public:
+ Listener *get_listener() const;
+ Camera *get_camera() const;
void set_as_audio_listener(bool p_enable);
bool is_audio_listener() const;
@@ -299,24 +283,23 @@ public:
void set_as_audio_listener_2d(bool p_enable);
bool is_audio_listener_2d() const;
- void set_rect(const Rect2& p_rect);
+ void set_rect(const Rect2 &p_rect);
Rect2 get_rect() const;
Rect2 get_visible_rect() const;
RID get_viewport() const;
- void set_world(const Ref<World>& p_world);
- void set_world_2d(const Ref<World2D>& p_world_2d);
+ void set_world(const Ref<World> &p_world);
+ void set_world_2d(const Ref<World2D> &p_world_2d);
Ref<World> get_world() const;
Ref<World> find_world() const;
Ref<World2D> get_world_2d() const;
Ref<World2D> find_world_2d() const;
-
- void set_canvas_transform(const Matrix32& p_transform);
+ void set_canvas_transform(const Matrix32 &p_transform);
Matrix32 get_canvas_transform() const;
- void set_global_canvas_transform(const Matrix32& p_transform);
+ void set_global_canvas_transform(const Matrix32 &p_transform);
Matrix32 get_global_canvas_transform() const;
Matrix32 get_final_transform() const;
@@ -324,8 +307,7 @@ public:
void set_transparent_background(bool p_enable);
bool has_transparent_background() const;
-
- void set_size_override(bool p_enable,const Size2& p_size=Size2(-1,-1),const Vector2& p_margin=Vector2());
+ void set_size_override(bool p_enable, const Size2 &p_size = Size2(-1, -1), const Vector2 &p_margin = Vector2());
Size2 get_size_override() const;
bool is_size_override_enabled() const;
void set_size_override_stretch(bool p_enable);
@@ -351,8 +333,7 @@ public:
RenderTargetUpdateMode get_render_target_update_mode() const;
Ref<RenderTargetTexture> get_render_target_texture() const;
-
- Vector2 get_camera_coords(const Vector2& p_viewport_coords) const;
+ Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
Vector2 get_camera_rect_size() const;
void queue_screen_capture();
@@ -361,17 +342,17 @@ public:
void set_use_own_world(bool p_world);
bool is_using_own_world() const;
- void input(const InputEvent& p_event);
- void unhandled_input(const InputEvent& p_event);
+ void input(const InputEvent &p_event);
+ void unhandled_input(const InputEvent &p_event);
void set_disable_input(bool p_disable);
bool is_input_disabled() const;
- void set_render_target_to_screen_rect(const Rect2& p_rect);
+ void set_render_target_to_screen_rect(const Rect2 &p_rect);
Rect2 get_render_target_to_screen_rect() const;
Vector2 get_mouse_pos() const;
- void warp_mouse(const Vector2& p_pos);
+ void warp_mouse(const Vector2 &p_pos);
void set_physics_object_picking(bool p_enable);
bool get_physics_object_picking();
@@ -385,7 +366,6 @@ public:
Viewport();
~Viewport();
-
};
VARIANT_ENUM_CAST(Viewport::RenderTargetUpdateMode);
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 2a525de2c..2c82d5c31 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -27,94 +27,93 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_scene_types.h"
-#include "os/os.h"
#include "globals.h"
+#include "os/os.h"
#include "scene/io/resource_format_image.h"
#include "scene/io/resource_format_wav.h"
//#include "scene/io/scene_format_script.h"
-#include "resources/default_theme/default_theme.h"
#include "object_type_db.h"
-#include "scene/main/canvas_layer.h"
-#include "scene/main/instance_placeholder.h"
-#include "scene/main/viewport.h"
-#include "scene/main/http_request.h"
-#include "scene/gui/control.h"
-#include "scene/gui/texture_progress.h"
+#include "resources/default_theme/default_theme.h"
+#include "scene/2d/light_2d.h"
+#include "scene/2d/light_occluder_2d.h"
+#include "scene/2d/particles_2d.h"
+#include "scene/2d/path_2d.h"
+#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
-#include "scene/gui/link_button.h"
#include "scene/gui/button_array.h"
#include "scene/gui/button_group.h"
+#include "scene/gui/center_container.h"
+#include "scene/gui/check_box.h"
+#include "scene/gui/check_button.h"
+#include "scene/gui/color_picker.h"
+#include "scene/gui/color_rect.h"
+#include "scene/gui/control.h"
+#include "scene/gui/dialogs.h"
+#include "scene/gui/file_dialog.h"
+#include "scene/gui/graph_edit.h"
+#include "scene/gui/graph_node.h"
+#include "scene/gui/grid_container.h"
+#include "scene/gui/item_list.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
-#include "scene/gui/scroll_bar.h"
+#include "scene/gui/link_button.h"
+#include "scene/gui/margin_container.h"
+#include "scene/gui/menu_button.h"
+#include "scene/gui/option_button.h"
+#include "scene/gui/panel.h"
+#include "scene/gui/panel_container.h"
+#include "scene/gui/patch_9_frame.h"
+#include "scene/gui/popup_menu.h"
#include "scene/gui/progress_bar.h"
+#include "scene/gui/reference_frame.h"
+#include "scene/gui/rich_text_label.h"
+#include "scene/gui/scroll_bar.h"
+#include "scene/gui/scroll_container.h"
+#include "scene/gui/separator.h"
#include "scene/gui/slider.h"
-#include "scene/gui/popup_menu.h"
#include "scene/gui/spin_box.h"
-#include "scene/gui/option_button.h"
-#include "scene/gui/color_picker.h"
-#include "scene/gui/texture_frame.h"
-#include "scene/gui/color_rect.h"
-#include "scene/gui/patch_9_frame.h"
-#include "scene/gui/menu_button.h"
-#include "scene/gui/check_box.h"
-#include "scene/gui/check_button.h"
+#include "scene/gui/spin_box.h"
+#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
-#include "scene/gui/panel_container.h"
#include "scene/gui/tabs.h"
-#include "scene/gui/center_container.h"
-#include "scene/gui/scroll_container.h"
-#include "scene/gui/margin_container.h"
-#include "scene/gui/panel.h"
-#include "scene/gui/spin_box.h"
-#include "scene/gui/file_dialog.h"
-#include "scene/gui/dialogs.h"
-#include "scene/gui/tree.h"
-#include "scene/gui/item_list.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/texture_button.h"
-#include "scene/gui/separator.h"
-#include "scene/gui/rich_text_label.h"
-#include "scene/gui/box_container.h"
-#include "scene/gui/grid_container.h"
-#include "scene/gui/split_container.h"
-#include "scene/gui/video_player.h"
-#include "scene/gui/reference_frame.h"
-#include "scene/gui/graph_node.h"
-#include "scene/gui/graph_edit.h"
+#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_progress.h"
#include "scene/gui/tool_button.h"
+#include "scene/gui/tree.h"
+#include "scene/gui/video_player.h"
+#include "scene/main/canvas_layer.h"
+#include "scene/main/http_request.h"
+#include "scene/main/instance_placeholder.h"
+#include "scene/main/viewport.h"
#include "scene/resources/video_stream.h"
-#include "scene/2d/particles_2d.h"
-#include "scene/2d/path_2d.h"
-#include "scene/2d/light_2d.h"
-#include "scene/2d/light_occluder_2d.h"
-#include "scene/2d/canvas_item.h"
-#include "scene/2d/sprite.h"
#include "scene/2d/animated_sprite.h"
-#include "scene/2d/polygon_2d.h"
#include "scene/2d/back_buffer_copy.h"
-
+#include "scene/2d/canvas_item.h"
+#include "scene/2d/polygon_2d.h"
+#include "scene/2d/sprite.h"
#include "scene/2d/visibility_notifier_2d.h"
-#include "scene/2d/physics_body_2d.h"
-#include "scene/2d/ray_cast_2d.h"
-#include "scene/2d/joints_2d.h"
#include "scene/2d/area_2d.h"
#include "scene/2d/camera_2d.h"
-#include "scene/2d/collision_shape_2d.h"
+#include "scene/2d/canvas_modulate.h"
#include "scene/2d/collision_polygon_2d.h"
+#include "scene/2d/collision_shape_2d.h"
+#include "scene/2d/joints_2d.h"
+#include "scene/2d/navigation2d.h"
#include "scene/2d/parallax_background.h"
#include "scene/2d/parallax_layer.h"
-#include "scene/2d/sound_player_2d.h"
+#include "scene/2d/physics_body_2d.h"
+#include "scene/2d/ray_cast_2d.h"
+#include "scene/2d/remote_transform_2d.h"
#include "scene/2d/sample_player_2d.h"
#include "scene/2d/screen_button.h"
-#include "scene/2d/remote_transform_2d.h"
+#include "scene/2d/sound_player_2d.h"
#include "scene/2d/y_sort.h"
-#include "scene/2d/navigation2d.h"
-#include "scene/2d/canvas_modulate.h"
#include "scene/2d/position_2d.h"
#include "scene/2d/tile_map.h"
@@ -124,70 +123,67 @@
#include "scene/animation/animation_player.h"
#include "scene/animation/animation_tree_player.h"
#include "scene/animation/tween.h"
-#include "scene/main/scene_main_loop.h"
#include "scene/main/resource_preloader.h"
-#include "scene/resources/packed_scene.h"
#include "scene/main/scene_main_loop.h"
+#include "scene/main/scene_main_loop.h"
+#include "scene/resources/packed_scene.h"
-
-#include "scene/resources/surface_tool.h"
-#include "scene/resources/mesh_data_tool.h"
-#include "scene/resources/scene_preloader.h"
#include "scene/resources/dynamic_font.h"
#include "scene/resources/dynamic_font_stb.h"
+#include "scene/resources/mesh_data_tool.h"
+#include "scene/resources/scene_preloader.h"
+#include "scene/resources/surface_tool.h"
#include "scene/main/timer.h"
-#include "scene/audio/stream_player.h"
#include "scene/audio/event_player.h"
#include "scene/audio/sound_room_params.h"
-#include "scene/resources/sphere_shape.h"
-#include "scene/resources/ray_shape.h"
+#include "scene/audio/stream_player.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/capsule_shape.h"
-#include "scene/resources/plane_shape.h"
-#include "scene/resources/convex_polygon_shape.h"
#include "scene/resources/concave_polygon_shape.h"
+#include "scene/resources/convex_polygon_shape.h"
+#include "scene/resources/plane_shape.h"
+#include "scene/resources/ray_shape.h"
+#include "scene/resources/sphere_shape.h"
-#include "scene/resources/shape_line_2d.h"
-#include "scene/resources/circle_shape_2d.h"
-#include "scene/resources/segment_shape_2d.h"
-#include "scene/resources/rectangle_shape_2d.h"
#include "scene/resources/capsule_shape_2d.h"
-#include "scene/resources/convex_polygon_shape_2d.h"
+#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
+#include "scene/resources/convex_polygon_shape_2d.h"
+#include "scene/resources/rectangle_shape_2d.h"
+#include "scene/resources/segment_shape_2d.h"
+#include "scene/resources/shape_line_2d.h"
#include "scene/resources/mesh_library.h"
-
#include "scene/resources/polygon_path_finder.h"
-#include "scene/resources/sample.h"
#include "scene/audio/sample_player.h"
-#include "scene/resources/texture.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/room.h"
+#include "scene/resources/sample.h"
+#include "scene/resources/texture.h"
#include "scene/resources/shader_graph.h"
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
-#include "scene/resources/sample_library.h"
#include "scene/resources/audio_stream.h"
-#include "scene/resources/gibberish_stream.h"
#include "scene/resources/bit_mask.h"
#include "scene/resources/color_ramp.h"
+#include "scene/resources/gibberish_stream.h"
+#include "scene/resources/sample_library.h"
#include "scene/scene_string_names.h"
-
-#include "scene/3d/spatial.h"
-#include "scene/3d/skeleton.h"
#include "scene/3d/bone_attachment.h"
-#include "scene/3d/room_instance.h"
#include "scene/3d/path.h"
+#include "scene/3d/room_instance.h"
#include "scene/3d/scenario_fx.h"
+#include "scene/3d/skeleton.h"
+#include "scene/3d/spatial.h"
#include "scene/3d/visibility_notifier.h"
@@ -196,50 +192,48 @@
#include "scene/3d/listener.h"
#include "scene/3d/interpolated_camera.h"
-#include "scene/3d/position_3d.h"
-#include "scene/3d/test_cube.h"
-#include "scene/3d/mesh_instance.h"
-#include "scene/3d/quad.h"
#include "scene/3d/light.h"
+#include "scene/3d/mesh_instance.h"
#include "scene/3d/particles.h"
+#include "scene/3d/physics_body.h"
#include "scene/3d/portal.h"
+#include "scene/3d/position_3d.h"
+#include "scene/3d/quad.h"
+#include "scene/3d/test_cube.h"
#include "scene/resources/environment.h"
-#include "scene/3d/physics_body.h"
-#include "scene/3d/vehicle_body.h"
-#include "scene/3d/body_shape.h"
#include "scene/3d/area.h"
-#include "scene/3d/physics_joint.h"
-#include "scene/3d/multimesh_instance.h"
#include "scene/3d/baked_light_instance.h"
-#include "scene/3d/ray_cast.h"
+#include "scene/3d/body_shape.h"
+#include "scene/3d/collision_polygon.h"
#include "scene/3d/immediate_geometry.h"
-#include "scene/3d/sprite_3d.h"
+#include "scene/3d/multimesh_instance.h"
+#include "scene/3d/navigation.h"
+#include "scene/3d/navigation_mesh.h"
+#include "scene/3d/physics_joint.h"
+#include "scene/3d/proximity_group.h"
+#include "scene/3d/ray_cast.h"
#include "scene/3d/spatial_sample_player.h"
#include "scene/3d/spatial_stream_player.h"
-#include "scene/3d/proximity_group.h"
-#include "scene/3d/navigation_mesh.h"
-#include "scene/3d/navigation.h"
-#include "scene/3d/collision_polygon.h"
+#include "scene/3d/sprite_3d.h"
+#include "scene/3d/vehicle_body.h"
#endif
#include "scene/resources/scene_format_text.h"
-static ResourceFormatLoaderImage *resource_loader_image=NULL;
-static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
-
+static ResourceFormatLoaderImage *resource_loader_image = NULL;
+static ResourceFormatLoaderWAV *resource_loader_wav = NULL;
#ifdef TOOLS_ENABLED
-
#endif
-static ResourceFormatLoaderTheme *resource_loader_theme=NULL;
-static ResourceFormatLoaderShader *resource_loader_shader=NULL;
+static ResourceFormatLoaderTheme *resource_loader_theme = NULL;
+static ResourceFormatLoaderShader *resource_loader_shader = NULL;
-static ResourceFormatSaverText *resource_saver_text=NULL;
-static ResourceFormatLoaderText *resource_loader_text=NULL;
+static ResourceFormatSaverText *resource_saver_text = NULL;
+static ResourceFormatLoaderText *resource_loader_text = NULL;
-static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font=NULL;
+static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font = NULL;
//static SceneStringNames *string_names;
@@ -251,35 +245,34 @@ void register_scene_types() {
Node::init_node_hrcr();
- resource_loader_image = memnew( ResourceFormatLoaderImage );
- ResourceLoader::add_resource_format_loader( resource_loader_image );
+ resource_loader_image = memnew(ResourceFormatLoaderImage);
+ ResourceLoader::add_resource_format_loader(resource_loader_image);
- resource_loader_wav = memnew( ResourceFormatLoaderWAV );
- ResourceLoader::add_resource_format_loader( resource_loader_wav );
- resource_loader_dynamic_font = memnew( ResourceFormatLoaderDynamicFont );
- ResourceLoader::add_resource_format_loader( resource_loader_dynamic_font );
+ resource_loader_wav = memnew(ResourceFormatLoaderWAV);
+ ResourceLoader::add_resource_format_loader(resource_loader_wav);
+ resource_loader_dynamic_font = memnew(ResourceFormatLoaderDynamicFont);
+ ResourceLoader::add_resource_format_loader(resource_loader_dynamic_font);
#ifdef TOOLS_ENABLED
- //scene first!
+//scene first!
#endif
- resource_loader_theme = memnew( ResourceFormatLoaderTheme );
- ResourceLoader::add_resource_format_loader( resource_loader_theme );
-
- resource_loader_shader = memnew( ResourceFormatLoaderShader );
- ResourceLoader::add_resource_format_loader( resource_loader_shader );
+ resource_loader_theme = memnew(ResourceFormatLoaderTheme);
+ ResourceLoader::add_resource_format_loader(resource_loader_theme);
- bool default_theme_hidpi=GLOBAL_DEF("display/use_hidpi_theme",false);
- Globals::get_singleton()->set_custom_property_info("display/use_hidpi_theme",PropertyInfo(Variant::BOOL,"display/use_hidpi_theme",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
- String theme_path = GLOBAL_DEF("display/custom_theme","");
- Globals::get_singleton()->set_custom_property_info("display/custom_theme",PropertyInfo(Variant::STRING,"display/custom_theme",PROPERTY_HINT_FILE,"*.tres,*.res",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
- String font_path = GLOBAL_DEF("display/custom_theme_font","");
- Globals::get_singleton()->set_custom_property_info("display/custom_theme_font",PropertyInfo(Variant::STRING,"display/custom_theme_font",PROPERTY_HINT_FILE,"*.tres,*.res,*.fnt",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
+ resource_loader_shader = memnew(ResourceFormatLoaderShader);
+ ResourceLoader::add_resource_format_loader(resource_loader_shader);
+ bool default_theme_hidpi = GLOBAL_DEF("display/use_hidpi_theme", false);
+ Globals::get_singleton()->set_custom_property_info("display/use_hidpi_theme", PropertyInfo(Variant::BOOL, "display/use_hidpi_theme", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ String theme_path = GLOBAL_DEF("display/custom_theme", "");
+ Globals::get_singleton()->set_custom_property_info("display/custom_theme", PropertyInfo(Variant::STRING, "display/custom_theme", PROPERTY_HINT_FILE, "*.tres,*.res", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
+ String font_path = GLOBAL_DEF("display/custom_theme_font", "");
+ Globals::get_singleton()->set_custom_property_info("display/custom_theme_font", PropertyInfo(Variant::STRING, "display/custom_theme_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.fnt", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED));
- if (theme_path!=String()) {
+ if (theme_path != String()) {
Ref<Theme> theme = ResourceLoader::load(theme_path);
if (theme.is_valid()) {
Theme::set_default(theme);
@@ -287,13 +280,12 @@ void register_scene_types() {
} else {
Ref<Font> font;
- if (font_path!=String()) {
- font=ResourceLoader::load(font_path);
+ if (font_path != String()) {
+ font = ResourceLoader::load(font_path);
}
- make_default_theme(default_theme_hidpi,font);
+ make_default_theme(default_theme_hidpi, font);
}
-
OS::get_singleton()->yield(); //may take time to init
ObjectTypeDB::register_type<Object>();
@@ -317,8 +309,8 @@ void register_scene_types() {
ObjectTypeDB::register_type<ShortCut>();
ObjectTypeDB::register_type<Control>();
-// ObjectTypeDB::register_type<EmptyControl>();
- ObjectTypeDB::add_compatibility_type("EmptyControl","Control");
+ // ObjectTypeDB::register_type<EmptyControl>();
+ ObjectTypeDB::add_compatibility_type("EmptyControl", "Control");
ObjectTypeDB::register_type<Button>();
ObjectTypeDB::register_type<Label>();
ObjectTypeDB::register_type<HScrollBar>();
@@ -363,14 +355,13 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
-
ObjectTypeDB::register_virtual_type<ButtonArray>();
ObjectTypeDB::register_type<HButtonArray>();
ObjectTypeDB::register_type<VButtonArray>();
ObjectTypeDB::register_type<TextureProgress>();
ObjectTypeDB::register_type<ItemList>();
-#ifndef ADVANCED_GUI_DISABLED
+#ifndef ADVANCED_GUI_DISABLED
ObjectTypeDB::register_type<FileDialog>();
ObjectTypeDB::register_type<LineEdit>();
@@ -438,7 +429,6 @@ void register_scene_types() {
ObjectTypeDB::register_type<RigidBody>();
ObjectTypeDB::register_type<KinematicBody>();
-
ObjectTypeDB::register_type<VehicleBody>();
ObjectTypeDB::register_type<VehicleWheel>();
ObjectTypeDB::register_type<Area>();
@@ -472,16 +462,14 @@ void register_scene_types() {
ObjectTypeDB::register_type<SpatialStreamPlayer>();
ObjectTypeDB::register_type<SoundRoomParams>();
-
#endif
ObjectTypeDB::register_type<MeshLibrary>();
- AcceptDialog::set_swap_ok_cancel( GLOBAL_DEF("display/swap_ok_cancel",bool(OS::get_singleton()->get_swap_ok_cancel())) );
+ AcceptDialog::set_swap_ok_cancel(GLOBAL_DEF("display/swap_ok_cancel", bool(OS::get_singleton()->get_swap_ok_cancel())));
ObjectTypeDB::register_type<SamplePlayer>();
ObjectTypeDB::register_type<StreamPlayer>();
ObjectTypeDB::register_type<EventPlayer>();
-
ObjectTypeDB::register_type<CanvasItemMaterial>();
ObjectTypeDB::register_virtual_type<CanvasItem>();
ObjectTypeDB::register_type<Node2D>();
@@ -497,7 +485,7 @@ void register_scene_types() {
ObjectTypeDB::register_type<StaticBody2D>();
ObjectTypeDB::register_type<RigidBody2D>();
ObjectTypeDB::register_type<KinematicBody2D>();
- KinematicBody2D::motion_fix_enabled=bool(GLOBAL_DEF("physics_2d/motion_fix_enabled",false));
+ KinematicBody2D::motion_fix_enabled = bool(GLOBAL_DEF("physics_2d/motion_fix_enabled", false));
ObjectTypeDB::register_type<Area2D>();
ObjectTypeDB::register_type<CollisionShape2D>();
ObjectTypeDB::register_type<CollisionPolygon2D>();
@@ -510,11 +498,11 @@ void register_scene_types() {
ObjectTypeDB::register_type<OccluderPolygon2D>();
ObjectTypeDB::register_type<YSort>();
ObjectTypeDB::register_type<BackBufferCopy>();
- if (bool(GLOBAL_DEF("physics/remove_collision_helpers_at_runtime",false))) {
- ObjectTypeDB::set_type_enabled("CollisionShape2D",false);
- ObjectTypeDB::set_type_enabled("CollisionPolygon2D",false);
- ObjectTypeDB::set_type_enabled("CollisionShape",false);
- ObjectTypeDB::set_type_enabled("CollisionPolygon",false);
+ if (bool(GLOBAL_DEF("physics/remove_collision_helpers_at_runtime", false))) {
+ ObjectTypeDB::set_type_enabled("CollisionShape2D", false);
+ ObjectTypeDB::set_type_enabled("CollisionPolygon2D", false);
+ ObjectTypeDB::set_type_enabled("CollisionShape", false);
+ ObjectTypeDB::set_type_enabled("CollisionPolygon", false);
}
OS::get_singleton()->yield(); //may take time to init
@@ -550,9 +538,9 @@ void register_scene_types() {
ObjectTypeDB::register_type<RoomBounds>();
ObjectTypeDB::register_type<MaterialShaderGraph>();
ObjectTypeDB::register_type<MaterialShader>();
- ObjectTypeDB::add_compatibility_type("Shader","MaterialShader");
- ObjectTypeDB::add_compatibility_type("ParticleSystemMaterial","FixedMaterial");
- ObjectTypeDB::add_compatibility_type("UnshadedMaterial","FixedMaterial");
+ ObjectTypeDB::add_compatibility_type("Shader", "MaterialShader");
+ ObjectTypeDB::add_compatibility_type("ParticleSystemMaterial", "FixedMaterial");
+ ObjectTypeDB::add_compatibility_type("UnshadedMaterial", "FixedMaterial");
ObjectTypeDB::register_type<MultiMesh>();
ObjectTypeDB::register_type<MeshLibrary>();
@@ -594,8 +582,7 @@ void register_scene_types() {
ObjectTypeDB::register_type<StyleBoxImageMask>();
ObjectTypeDB::register_type<Theme>();
- ObjectTypeDB::add_compatibility_type("Font","BitmapFont");
-
+ ObjectTypeDB::add_compatibility_type("Font", "BitmapFont");
ObjectTypeDB::register_type<PolygonPathFinder>();
ObjectTypeDB::register_type<BitMap>();
@@ -607,8 +594,8 @@ void register_scene_types() {
ObjectTypeDB::register_type<SampleLibrary>();
ObjectTypeDB::register_virtual_type<AudioStream>();
ObjectTypeDB::register_virtual_type<AudioStreamPlayback>();
-//TODO: Adapt to the new AudioStream API or drop (GH-3307)
-// ObjectTypeDB::register_type<AudioStreamGibberish>();
+ //TODO: Adapt to the new AudioStream API or drop (GH-3307)
+ // ObjectTypeDB::register_type<AudioStreamGibberish>();
ObjectTypeDB::register_virtual_type<VideoStream>();
OS::get_singleton()->yield(); //may take time to init
@@ -639,31 +626,27 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
+ resource_saver_text = memnew(ResourceFormatSaverText);
+ ResourceSaver::add_resource_format_saver(resource_saver_text, true);
- resource_saver_text = memnew( ResourceFormatSaverText );
- ResourceSaver::add_resource_format_saver(resource_saver_text,true);
-
- resource_loader_text = memnew( ResourceFormatLoaderText );
- ResourceLoader::add_resource_format_loader(resource_loader_text,true);
-
+ resource_loader_text = memnew(ResourceFormatLoaderText);
+ ResourceLoader::add_resource_format_loader(resource_loader_text, true);
}
void unregister_scene_types() {
clear_default_theme();
- memdelete( resource_loader_image );
- memdelete( resource_loader_wav );
- memdelete( resource_loader_dynamic_font );
+ memdelete(resource_loader_image);
+ memdelete(resource_loader_wav);
+ memdelete(resource_loader_dynamic_font);
#ifdef TOOLS_ENABLED
-
#endif
-
- memdelete( resource_loader_theme );
- memdelete( resource_loader_shader );
+ memdelete(resource_loader_theme);
+ memdelete(resource_loader_shader);
if (resource_saver_text) {
memdelete(resource_saver_text);
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index d86c476ef..8ee68c729 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -29,33 +29,32 @@
#include "animation.h"
#include "geometry.h"
+bool Animation::_set(const StringName &p_name, const Variant &p_value) {
-bool Animation::_set(const StringName& p_name, const Variant& p_value) {
+ String name = p_name;
- String name=p_name;
-
- if (name=="length")
+ if (name == "length")
set_length(p_value);
- else if (name=="loop")
+ else if (name == "loop")
set_loop(p_value);
- else if (name=="step")
+ else if (name == "step")
set_step(p_value);
else if (name.begins_with("tracks/")) {
- int track=name.get_slicec('/',1).to_int();
- String what=name.get_slicec('/',2);
+ int track = name.get_slicec('/', 1).to_int();
+ String what = name.get_slicec('/', 2);
- if (tracks.size()==track && what=="type") {
+ if (tracks.size() == track && what == "type") {
- String type=p_value;
+ String type = p_value;
- if (type=="transform") {
+ if (type == "transform") {
add_track(TYPE_TRANSFORM);
- } else if (type=="value") {
+ } else if (type == "value") {
add_track(TYPE_VALUE);
- } else if (type=="method") {
+ } else if (type == "method") {
add_track(TYPE_METHOD);
} else {
@@ -66,21 +65,21 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
return true;
}
- ERR_FAIL_INDEX_V( track, tracks.size(),false );
+ ERR_FAIL_INDEX_V(track, tracks.size(), false);
- if (what=="path")
- track_set_path(track,p_value);
- else if (what=="interp")
- track_set_interpolation_type(track,InterpolationType(p_value.operator int()));
- else if (what=="imported")
- track_set_imported(track,p_value);
- else if (what == "keys" || what=="key_values") {
+ if (what == "path")
+ track_set_path(track, p_value);
+ else if (what == "interp")
+ track_set_interpolation_type(track, InterpolationType(p_value.operator int()));
+ else if (what == "imported")
+ track_set_imported(track, p_value);
+ else if (what == "keys" || what == "key_values") {
- if (track_get_type(track)==TYPE_TRANSFORM) {
+ if (track_get_type(track) == TYPE_TRANSFORM) {
- TransformTrack *tt = static_cast<TransformTrack*>(tracks[track]);
- DVector<float> values=p_value;
- int vcount=values.size();
+ TransformTrack *tt = static_cast<TransformTrack *>(tracks[track]);
+ DVector<float> values = p_value;
+ int vcount = values.size();
#if 0 // old compatibility hack
if ((vcount%11) == 0) {
@@ -119,137 +118,126 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
}
#endif
- ERR_FAIL_COND_V(vcount%12,false); // shuld be multiple of 11
+ ERR_FAIL_COND_V(vcount % 12, false); // shuld be multiple of 11
DVector<float>::Read r = values.read();
- tt->transforms.resize(vcount/12);
-
-
- for(int i=0;i<(vcount/12);i++) {
-
+ tt->transforms.resize(vcount / 12);
- TKey<TransformKey> &tk=tt->transforms[i];
- const float *ofs=&r[i*12];
- tk.time=ofs[0];
- tk.transition=ofs[1];
+ for (int i = 0; i < (vcount / 12); i++) {
- tk.value.loc.x=ofs[2];
- tk.value.loc.y=ofs[3];
- tk.value.loc.z=ofs[4];
+ TKey<TransformKey> &tk = tt->transforms[i];
+ const float *ofs = &r[i * 12];
+ tk.time = ofs[0];
+ tk.transition = ofs[1];
- tk.value.rot.x=ofs[5];
- tk.value.rot.y=ofs[6];
- tk.value.rot.z=ofs[7];
- tk.value.rot.w=ofs[8];
-
- tk.value.scale.x=ofs[9];
- tk.value.scale.y=ofs[10];
- tk.value.scale.z=ofs[11];
+ tk.value.loc.x = ofs[2];
+ tk.value.loc.y = ofs[3];
+ tk.value.loc.z = ofs[4];
+ tk.value.rot.x = ofs[5];
+ tk.value.rot.y = ofs[6];
+ tk.value.rot.z = ofs[7];
+ tk.value.rot.w = ofs[8];
+ tk.value.scale.x = ofs[9];
+ tk.value.scale.y = ofs[10];
+ tk.value.scale.z = ofs[11];
}
- } else if (track_get_type(track)==TYPE_VALUE) {
+ } else if (track_get_type(track) == TYPE_VALUE) {
- ValueTrack *vt = static_cast<ValueTrack*>(tracks[track]);
+ ValueTrack *vt = static_cast<ValueTrack *>(tracks[track]);
Dictionary d = p_value;
- ERR_FAIL_COND_V(!d.has("times"),false);
- ERR_FAIL_COND_V(!d.has("values"),false);
+ ERR_FAIL_COND_V(!d.has("times"), false);
+ ERR_FAIL_COND_V(!d.has("values"), false);
if (d.has("cont")) {
bool v = d["cont"];
- vt->update_mode=v?UPDATE_CONTINUOUS:UPDATE_DISCRETE;
+ vt->update_mode = v ? UPDATE_CONTINUOUS : UPDATE_DISCRETE;
}
if (d.has("update")) {
- int um =d["update"];
- if (um<0)
- um=0;
- else if (um>2)
- um=2;
- vt->update_mode=UpdateMode(um);
+ int um = d["update"];
+ if (um < 0)
+ um = 0;
+ else if (um > 2)
+ um = 2;
+ vt->update_mode = UpdateMode(um);
}
+ DVector<float> times = d["times"];
+ Array values = d["values"];
-
- DVector<float> times=d["times"];
- Array values=d["values"];
-
- ERR_FAIL_COND_V(times.size()!=values.size(),false);
+ ERR_FAIL_COND_V(times.size() != values.size(), false);
if (times.size()) {
- int valcount=times.size();
+ int valcount = times.size();
DVector<float>::Read rt = times.read();
vt->values.resize(valcount);
- for(int i=0;i<valcount;i++) {
+ for (int i = 0; i < valcount; i++) {
- vt->values[i].time=rt[i];
- vt->values[i].value=values[i];
+ vt->values[i].time = rt[i];
+ vt->values[i].value = values[i];
}
if (d.has("transitions")) {
DVector<float> transitions = d["transitions"];
- ERR_FAIL_COND_V(transitions.size()!=valcount,false);
+ ERR_FAIL_COND_V(transitions.size() != valcount, false);
DVector<float>::Read rtr = transitions.read();
+ for (int i = 0; i < valcount; i++) {
- for(int i=0;i<valcount;i++) {
-
- vt->values[i].transition=rtr[i];
+ vt->values[i].transition = rtr[i];
}
}
-
}
return true;
} else {
- while(track_get_key_count(track))
- track_remove_key(track,0); //well shouldn't be set anyway
+ while (track_get_key_count(track))
+ track_remove_key(track, 0); //well shouldn't be set anyway
Dictionary d = p_value;
- ERR_FAIL_COND_V(!d.has("times"),false);
- ERR_FAIL_COND_V(!d.has("values"),false);
+ ERR_FAIL_COND_V(!d.has("times"), false);
+ ERR_FAIL_COND_V(!d.has("values"), false);
- DVector<float> times=d["times"];
- Array values=d["values"];
+ DVector<float> times = d["times"];
+ Array values = d["values"];
- ERR_FAIL_COND_V(times.size()!=values.size(),false);
+ ERR_FAIL_COND_V(times.size() != values.size(), false);
if (times.size()) {
- int valcount=times.size();
+ int valcount = times.size();
DVector<float>::Read rt = times.read();
- for(int i=0;i<valcount;i++) {
+ for (int i = 0; i < valcount; i++) {
- track_insert_key(track,rt[i],values[i]);
+ track_insert_key(track, rt[i], values[i]);
}
if (d.has("transitions")) {
DVector<float> transitions = d["transitions"];
- ERR_FAIL_COND_V(transitions.size()!=valcount,false);
+ ERR_FAIL_COND_V(transitions.size() != valcount, false);
DVector<float>::Read rtr = transitions.read();
- for(int i=0;i<valcount;i++) {
+ for (int i = 0; i < valcount; i++) {
- track_set_key_transition(track,i,rtr[i]);
+ track_set_key_transition(track, i, rtr[i]);
}
}
-
}
-
-
}
} else
return false;
@@ -259,82 +247,79 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
return true;
}
+bool Animation::_get(const StringName &p_name, Variant &r_ret) const {
-bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
+ String name = p_name;
- String name=p_name;
-
- if (name=="length")
- r_ret= length;
- else if (name=="loop")
- r_ret= loop;
- else if (name=="step")
- r_ret= step;
+ if (name == "length")
+ r_ret = length;
+ else if (name == "loop")
+ r_ret = loop;
+ else if (name == "step")
+ r_ret = step;
else if (name.begins_with("tracks/")) {
- int track=name.get_slicec('/',1).to_int();
- String what=name.get_slicec('/',2);
- ERR_FAIL_INDEX_V( track, tracks.size(), false );
- if (what=="type") {
-
+ int track = name.get_slicec('/', 1).to_int();
+ String what = name.get_slicec('/', 2);
+ ERR_FAIL_INDEX_V(track, tracks.size(), false);
+ if (what == "type") {
switch (track_get_type(track)) {
- case TYPE_TRANSFORM: r_ret= "transform"; break;
- case TYPE_VALUE: r_ret= "value";break;
- case TYPE_METHOD: r_ret= "method";break;
+ case TYPE_TRANSFORM: r_ret = "transform"; break;
+ case TYPE_VALUE: r_ret = "value"; break;
+ case TYPE_METHOD: r_ret = "method"; break;
}
return true;
- } else if (what=="path")
- r_ret=track_get_path(track);
- else if (what=="interp")
+ } else if (what == "path")
+ r_ret = track_get_path(track);
+ else if (what == "interp")
r_ret = track_get_interpolation_type(track);
- else if (what=="imported")
+ else if (what == "imported")
r_ret = track_is_imported(track);
- else if (what=="keys") {
+ else if (what == "keys") {
- if (track_get_type(track)==TYPE_TRANSFORM) {
+ if (track_get_type(track) == TYPE_TRANSFORM) {
DVector<real_t> keys;
- int kk=track_get_key_count(track);
- keys.resize(kk*12);
+ int kk = track_get_key_count(track);
+ keys.resize(kk * 12);
DVector<real_t>::Write w = keys.write();
- int idx=0;
- for(int i=0;i<track_get_key_count(track);i++) {
+ int idx = 0;
+ for (int i = 0; i < track_get_key_count(track); i++) {
Vector3 loc;
Quat rot;
Vector3 scale;
- transform_track_get_key(track,i,&loc,&rot,&scale);
+ transform_track_get_key(track, i, &loc, &rot, &scale);
- w[idx++]=track_get_key_time(track,i);
- w[idx++]=track_get_key_transition(track,i);
- w[idx++]=loc.x;
- w[idx++]=loc.y;
- w[idx++]=loc.z;
+ w[idx++] = track_get_key_time(track, i);
+ w[idx++] = track_get_key_transition(track, i);
+ w[idx++] = loc.x;
+ w[idx++] = loc.y;
+ w[idx++] = loc.z;
- w[idx++]=rot.x;
- w[idx++]=rot.y;
- w[idx++]=rot.z;
- w[idx++]=rot.w;
+ w[idx++] = rot.x;
+ w[idx++] = rot.y;
+ w[idx++] = rot.z;
+ w[idx++] = rot.w;
- w[idx++]=scale.x;
- w[idx++]=scale.y;
- w[idx++]=scale.z;
+ w[idx++] = scale.x;
+ w[idx++] = scale.y;
+ w[idx++] = scale.z;
}
w = DVector<real_t>::Write();
- r_ret=keys;
+ r_ret = keys;
return true;
- } else if (track_get_type(track)==TYPE_VALUE) {
-
+ } else if (track_get_type(track) == TYPE_VALUE) {
- const ValueTrack *vt = static_cast<const ValueTrack*>(tracks[track]);
+ const ValueTrack *vt = static_cast<const ValueTrack *>(tracks[track]);
Dictionary d;
@@ -342,82 +327,80 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
DVector<float> key_transitions;
Array key_values;
- int kk=vt->values.size();
+ int kk = vt->values.size();
key_times.resize(kk);
key_transitions.resize(kk);
key_values.resize(kk);
- DVector<float>::Write wti=key_times.write();
- DVector<float>::Write wtr=key_transitions.write();
+ DVector<float>::Write wti = key_times.write();
+ DVector<float>::Write wtr = key_transitions.write();
- int idx=0;
+ int idx = 0;
const TKey<Variant> *vls = vt->values.ptr();
- for(int i=0;i<kk;i++) {
+ for (int i = 0; i < kk; i++) {
- wti[idx]=vls[i].time;
- wtr[idx]=vls[i].transition;
- key_values[idx]=vls[i].value;
+ wti[idx] = vls[i].time;
+ wtr[idx] = vls[i].transition;
+ key_values[idx] = vls[i].value;
idx++;
}
- wti=DVector<float>::Write();
- wtr=DVector<float>::Write();
+ wti = DVector<float>::Write();
+ wtr = DVector<float>::Write();
- d["times"]=key_times;
- d["transitions"]=key_transitions;
- d["values"]=key_values;
- if (track_get_type(track)==TYPE_VALUE) {
- d["update"]=value_track_get_update_mode(track);
+ d["times"] = key_times;
+ d["transitions"] = key_transitions;
+ d["values"] = key_values;
+ if (track_get_type(track) == TYPE_VALUE) {
+ d["update"] = value_track_get_update_mode(track);
}
- r_ret=d;
+ r_ret = d;
return true;
} else {
-
Dictionary d;
DVector<float> key_times;
DVector<float> key_transitions;
Array key_values;
- int kk=track_get_key_count(track);
+ int kk = track_get_key_count(track);
key_times.resize(kk);
key_transitions.resize(kk);
key_values.resize(kk);
- DVector<float>::Write wti=key_times.write();
- DVector<float>::Write wtr=key_transitions.write();
+ DVector<float>::Write wti = key_times.write();
+ DVector<float>::Write wtr = key_transitions.write();
- int idx=0;
- for(int i=0;i<track_get_key_count(track);i++) {
+ int idx = 0;
+ for (int i = 0; i < track_get_key_count(track); i++) {
- wti[idx]=track_get_key_time(track,i);
- wtr[idx]=track_get_key_transition(track,i);
- key_values[idx]=track_get_key_value(track,i);
+ wti[idx] = track_get_key_time(track, i);
+ wtr[idx] = track_get_key_transition(track, i);
+ key_values[idx] = track_get_key_value(track, i);
idx++;
}
- wti=DVector<float>::Write();
- wtr=DVector<float>::Write();
+ wti = DVector<float>::Write();
+ wtr = DVector<float>::Write();
- d["times"]=key_times;
- d["transitions"]=key_transitions;
- d["values"]=key_values;
- if (track_get_type(track)==TYPE_VALUE) {
- d["update"]=value_track_get_update_mode(track);
+ d["times"] = key_times;
+ d["transitions"] = key_transitions;
+ d["values"] = key_values;
+ if (track_get_type(track) == TYPE_VALUE) {
+ d["update"] = value_track_get_update_mode(track);
}
- r_ret=d;
+ r_ret = d;
return true;
-
}
} else
return false;
@@ -425,46 +408,44 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
return false;
return true;
-
}
+void Animation::_get_property_list(List<PropertyInfo> *p_list) const {
-void Animation::_get_property_list( List<PropertyInfo> *p_list) const {
-
- p_list->push_back( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_RANGE, "0.001,99999,0.001"));
- p_list->push_back( PropertyInfo( Variant::BOOL, "loop" ));
- p_list->push_back( PropertyInfo( Variant::REAL, "step", PROPERTY_HINT_RANGE, "0,4096,0.001" ));
+ p_list->push_back(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_RANGE, "0.001,99999,0.001"));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "loop"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "step", PROPERTY_HINT_RANGE, "0,4096,0.001"));
- for (int i=0;i<tracks.size();i++) {
+ for (int i = 0; i < tracks.size(); i++) {
- p_list->push_back( PropertyInfo( Variant::STRING, "tracks/"+itos(i)+"/type", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
- p_list->push_back( PropertyInfo( Variant::NODE_PATH, "tracks/"+itos(i)+"/path", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
- p_list->push_back( PropertyInfo( Variant::INT, "tracks/"+itos(i)+"/interp", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
- p_list->push_back( PropertyInfo( Variant::BOOL, "tracks/"+itos(i)+"/imported", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
- p_list->push_back( PropertyInfo( Variant::ARRAY, "tracks/"+itos(i)+"/keys", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR) );
+ p_list->push_back(PropertyInfo(Variant::STRING, "tracks/" + itos(i) + "/type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::NODE_PATH, "tracks/" + itos(i) + "/path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::INT, "tracks/" + itos(i) + "/interp", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::BOOL, "tracks/" + itos(i) + "/imported", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::ARRAY, "tracks/" + itos(i) + "/keys", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
}
}
-int Animation::add_track(TrackType p_type,int p_at_pos) {
+int Animation::add_track(TrackType p_type, int p_at_pos) {
- if (p_at_pos<0 || p_at_pos>=tracks.size())
- p_at_pos=tracks.size();
+ if (p_at_pos < 0 || p_at_pos >= tracks.size())
+ p_at_pos = tracks.size();
- switch( p_type ) {
+ switch (p_type) {
case TYPE_TRANSFORM: {
- TransformTrack *tt = memnew( TransformTrack );
- tracks.insert( p_at_pos,tt );
+ TransformTrack *tt = memnew(TransformTrack);
+ tracks.insert(p_at_pos, tt);
} break;
case TYPE_VALUE: {
- tracks.insert( p_at_pos,memnew( ValueTrack ) );
+ tracks.insert(p_at_pos, memnew(ValueTrack));
} break;
case TYPE_METHOD: {
- tracks.insert( p_at_pos,memnew( MethodTrack ) );
+ tracks.insert(p_at_pos, memnew(MethodTrack));
} break;
default: {
@@ -479,31 +460,31 @@ int Animation::add_track(TrackType p_type,int p_at_pos) {
void Animation::remove_track(int p_track) {
ERR_FAIL_INDEX(p_track, tracks.size());
- Track *t=tracks[p_track];
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
_clear(tt->transforms);
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
_clear(vt->values);
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
_clear(mt->methods);
} break;
}
- memdelete( t );
+ memdelete(t);
tracks.remove(p_track);
emit_changed();
}
@@ -515,27 +496,26 @@ int Animation::get_track_count() const {
Animation::TrackType Animation::track_get_type(int p_track) const {
- ERR_FAIL_INDEX_V(p_track, tracks.size(), TYPE_TRANSFORM );
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), TYPE_TRANSFORM);
return tracks[p_track]->type;
}
-void Animation::track_set_path(int p_track,const NodePath& p_path) {
+void Animation::track_set_path(int p_track, const NodePath &p_path) {
ERR_FAIL_INDEX(p_track, tracks.size());
- tracks[p_track]->path=p_path;
+ tracks[p_track]->path = p_path;
emit_changed();
-
}
NodePath Animation::track_get_path(int p_track) const {
- ERR_FAIL_INDEX_V(p_track, tracks.size(),NodePath());
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), NodePath());
return tracks[p_track]->path;
}
-int Animation::find_track(const NodePath& p_path) const {
+int Animation::find_track(const NodePath &p_path) const {
- for (int i=0; i<tracks.size(); i++) {
+ for (int i = 0; i < tracks.size(); i++) {
if (tracks[i]->path == p_path)
return i;
@@ -543,23 +523,20 @@ int Animation::find_track(const NodePath& p_path) const {
return -1;
};
-
-void Animation::track_set_interpolation_type(int p_track,InterpolationType p_interp) {
+void Animation::track_set_interpolation_type(int p_track, InterpolationType p_interp) {
ERR_FAIL_INDEX(p_track, tracks.size());
- ERR_FAIL_INDEX(p_interp,3);
- tracks[p_track]->interpolation=p_interp;
+ ERR_FAIL_INDEX(p_interp, 3);
+ tracks[p_track]->interpolation = p_interp;
emit_changed();
-
}
Animation::InterpolationType Animation::track_get_interpolation_type(int p_track) const {
- ERR_FAIL_INDEX_V(p_track, tracks.size(),INTERPOLATION_NEAREST);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), INTERPOLATION_NEAREST);
return tracks[p_track]->interpolation;
}
-
// transform
/*
template<class T>
@@ -587,23 +564,22 @@ int Animation::_insert_pos(float p_time, T& p_keys) {
}
*/
-template<class T, class V>
-int Animation::_insert(float p_time, T& p_keys, const V& p_value) {
-
- int idx=p_keys.size();
+template <class T, class V>
+int Animation::_insert(float p_time, T &p_keys, const V &p_value) {
- while(true) {
+ int idx = p_keys.size();
+ while (true) {
- if (idx==0 || p_keys[idx-1].time < p_time) {
+ if (idx == 0 || p_keys[idx - 1].time < p_time) {
//condition for insertion.
- p_keys.insert(idx,p_value);
+ p_keys.insert(idx, p_value);
return idx;
- } else if (p_keys[idx-1].time == p_time) {
+ } else if (p_keys[idx - 1].time == p_time) {
// condition for replacing.
- p_keys[idx-1]=p_value;
- return idx-1;
+ p_keys[idx - 1] = p_value;
+ return idx - 1;
}
idx--;
@@ -612,82 +588,81 @@ int Animation::_insert(float p_time, T& p_keys, const V& p_value) {
return -1;
}
-template<class T>
-void Animation::_clear(T& p_keys) {
-
+template <class T>
+void Animation::_clear(T &p_keys) {
p_keys.clear();
}
-Error Animation::transform_track_get_key(int p_track, int p_key, Vector3* r_loc, Quat* r_rot, Vector3* r_scale) const {
+Error Animation::transform_track_get_key(int p_track, int p_key, Vector3 *r_loc, Quat *r_rot, Vector3 *r_scale) const {
- ERR_FAIL_INDEX_V(p_track, tracks.size(),ERR_INVALID_PARAMETER);
- Track *t=tracks[p_track];
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
+ Track *t = tracks[p_track];
- TransformTrack * tt = static_cast<TransformTrack*>(t);
- ERR_FAIL_COND_V(t->type!=TYPE_TRANSFORM,ERR_INVALID_PARAMETER);
- ERR_FAIL_INDEX_V(p_key,tt->transforms.size(),ERR_INVALID_PARAMETER);
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
+ ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM, ERR_INVALID_PARAMETER);
+ ERR_FAIL_INDEX_V(p_key, tt->transforms.size(), ERR_INVALID_PARAMETER);
if (r_loc)
- *r_loc=tt->transforms[p_key].value.loc;
+ *r_loc = tt->transforms[p_key].value.loc;
if (r_rot)
- *r_rot=tt->transforms[p_key].value.rot;
+ *r_rot = tt->transforms[p_key].value.rot;
if (r_scale)
- *r_scale=tt->transforms[p_key].value.scale;
+ *r_scale = tt->transforms[p_key].value.scale;
return OK;
}
-int Animation::transform_track_insert_key(int p_track, float p_time, const Vector3 p_loc, const Quat& p_rot, const Vector3& p_scale) {
+int Animation::transform_track_insert_key(int p_track, float p_time, const Vector3 p_loc, const Quat &p_rot, const Vector3 &p_scale) {
- ERR_FAIL_INDEX_V(p_track, tracks.size(),-1);
- Track *t=tracks[p_track];
- ERR_FAIL_COND_V(t->type!=TYPE_TRANSFORM,-1);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM, -1);
- TransformTrack * tt = static_cast<TransformTrack*>(t);
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
TKey<TransformKey> tkey;
- tkey.time=p_time;
- tkey.value.loc=p_loc;
- tkey.value.rot=p_rot;
- tkey.value.scale=p_scale;
+ tkey.time = p_time;
+ tkey.value.loc = p_loc;
+ tkey.value.rot = p_rot;
+ tkey.value.scale = p_scale;
- int ret = _insert( p_time, tt->transforms, tkey );
+ int ret = _insert(p_time, tt->transforms, tkey);
emit_changed();
return ret;
}
void Animation::track_remove_key_at_pos(int p_track, float p_pos) {
- int idx = track_find_key(p_track,p_pos,true);
+ int idx = track_find_key(p_track, p_pos, true);
ERR_FAIL_COND(idx < 0);
- track_remove_key(p_track,idx);
+ track_remove_key(p_track, idx);
}
void Animation::track_remove_key(int p_track, int p_idx) {
- ERR_FAIL_INDEX(p_track,tracks.size());
- Track *t=tracks[p_track];
+ ERR_FAIL_INDEX(p_track, tracks.size());
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
- ERR_FAIL_INDEX(p_idx,tt->transforms.size());
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
+ ERR_FAIL_INDEX(p_idx, tt->transforms.size());
tt->transforms.remove(p_idx);
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
- ERR_FAIL_INDEX(p_idx,vt->values.size());
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
+ ERR_FAIL_INDEX(p_idx, vt->values.size());
vt->values.remove(p_idx);
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
- ERR_FAIL_INDEX(p_idx,mt->methods.size());
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
+ ERR_FAIL_INDEX(p_idx, mt->methods.size());
mt->methods.remove(p_idx);
} break;
@@ -698,39 +673,39 @@ void Animation::track_remove_key(int p_track, int p_idx) {
int Animation::track_find_key(int p_track, float p_time, bool p_exact) const {
- ERR_FAIL_INDEX_V(p_track,tracks.size(),-1);
- Track *t=tracks[p_track];
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
- int k = _find(tt->transforms,p_time);
- if (k<0 || k>=tt->transforms.size())
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
+ int k = _find(tt->transforms, p_time);
+ if (k < 0 || k >= tt->transforms.size())
return -1;
- if (tt->transforms[k].time!=p_time && p_exact)
+ if (tt->transforms[k].time != p_time && p_exact)
return -1;
return k;
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
- int k = _find(vt->values,p_time);
- if (k<0 || k>=vt->values.size())
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
+ int k = _find(vt->values, p_time);
+ if (k < 0 || k >= vt->values.size())
return -1;
- if (vt->values[k].time!=p_time && p_exact)
+ if (vt->values[k].time != p_time && p_exact)
return -1;
return k;
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
- int k = _find(mt->methods,p_time);
- if (k<0 || k>=mt->methods.size())
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
+ int k = _find(mt->methods, p_time);
+ if (k < 0 || k >= mt->methods.size())
return -1;
- if (mt->methods[k].time!=p_time && p_exact)
+ if (mt->methods[k].time != p_time && p_exact)
return -1;
return k;
@@ -740,65 +715,63 @@ int Animation::track_find_key(int p_track, float p_time, bool p_exact) const {
return -1;
}
-
-void Animation::track_insert_key(int p_track, float p_time, const Variant& p_value,float p_transition) {
+void Animation::track_insert_key(int p_track, float p_time, const Variant &p_value, float p_transition) {
ERR_FAIL_INDEX(p_track, tracks.size());
- Track *t=tracks[p_track];
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
Dictionary d = p_value;
Vector3 loc;
if (d.has("loc"))
- loc=d["loc"];
+ loc = d["loc"];
Quat rot;
if (d.has("rot"))
- rot=d["rot"];
+ rot = d["rot"];
Vector3 scale;
if (d.has("scale"))
- scale=d["scale"];
+ scale = d["scale"];
- int idx = transform_track_insert_key(p_track,p_time,loc,rot,scale);
- track_set_key_transition(p_track,idx,p_transition);
+ int idx = transform_track_insert_key(p_track, p_time, loc, rot, scale);
+ track_set_key_transition(p_track, idx, p_transition);
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
- TKey<Variant> k;
- k.time=p_time;
- k.transition=p_transition;
- k.value=p_value;
- _insert( p_time, vt->values, k );
+ TKey<Variant> k;
+ k.time = p_time;
+ k.transition = p_transition;
+ k.value = p_value;
+ _insert(p_time, vt->values, k);
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
- ERR_FAIL_COND( p_value.get_type() != Variant::DICTIONARY );
+ ERR_FAIL_COND(p_value.get_type() != Variant::DICTIONARY);
- Dictionary d=p_value;
- ERR_FAIL_COND(!d.has("method") || d["method"].get_type()!=Variant::STRING);
+ Dictionary d = p_value;
+ ERR_FAIL_COND(!d.has("method") || d["method"].get_type() != Variant::STRING);
ERR_FAIL_COND(!d.has("args") || !d["args"].is_array());
MethodKey k;
- k.time=p_time;
- k.transition=p_transition;
- k.method=d["method"];
- k.params=d["args"];
+ k.time = p_time;
+ k.transition = p_transition;
+ k.method = d["method"];
+ k.params = d["args"];
- _insert( p_time, mt->methods, k );
+ _insert(p_time, mt->methods, k);
} break;
-
}
emit_changed();
@@ -806,25 +779,25 @@ void Animation::track_insert_key(int p_track, float p_time, const Variant& p_val
int Animation::track_get_key_count(int p_track) const {
- ERR_FAIL_INDEX_V(p_track, tracks.size(),-1);
- Track *t=tracks[p_track];
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
return tt->transforms.size();
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
return vt->values.size();
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
return mt->methods.size();
} break;
}
@@ -835,40 +808,39 @@ int Animation::track_get_key_count(int p_track) const {
Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), Variant());
- Track *t=tracks[p_track];
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, tt->transforms.size(), Variant() );
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, tt->transforms.size(), Variant());
Dictionary d;
- d["loc"]=tt->transforms[p_key_idx].value.loc;
- d["rot"]=tt->transforms[p_key_idx].value.rot;
- d["scale"]=tt->transforms[p_key_idx].value.scale;
+ d["loc"] = tt->transforms[p_key_idx].value.loc;
+ d["rot"] = tt->transforms[p_key_idx].value.rot;
+ d["scale"] = tt->transforms[p_key_idx].value.scale;
return d;
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, vt->values.size(), Variant() );
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, vt->values.size(), Variant());
return vt->values[p_key_idx].value;
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, mt->methods.size(), Variant() );
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, mt->methods.size(), Variant());
Dictionary d;
- d["method"]=mt->methods[p_key_idx].method;
- d["args"]=mt->methods[p_key_idx].params;
+ d["method"] = mt->methods[p_key_idx].method;
+ d["args"] = mt->methods[p_key_idx].params;
return d;
} break;
-
}
ERR_FAIL_V(Variant());
@@ -877,452 +849,431 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
float Animation::track_get_key_time(int p_track, int p_key_idx) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
- Track *t=tracks[p_track];
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, tt->transforms.size(), -1 );
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, tt->transforms.size(), -1);
return tt->transforms[p_key_idx].time;
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, vt->values.size(), -1 );
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, vt->values.size(), -1);
return vt->values[p_key_idx].time;
-
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, mt->methods.size(), -1 );
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, mt->methods.size(), -1);
return mt->methods[p_key_idx].time;
-
} break;
}
ERR_FAIL_V(-1);
-
}
float Animation::track_get_key_transition(int p_track, int p_key_idx) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
- Track *t=tracks[p_track];
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, tt->transforms.size(), -1 );
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, tt->transforms.size(), -1);
return tt->transforms[p_key_idx].transition;
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, vt->values.size(), -1 );
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, vt->values.size(), -1);
return vt->values[p_key_idx].transition;
-
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
- ERR_FAIL_INDEX_V( p_key_idx, mt->methods.size(), -1 );
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
+ ERR_FAIL_INDEX_V(p_key_idx, mt->methods.size(), -1);
return mt->methods[p_key_idx].transition;
-
} break;
}
ERR_FAIL_V(0);
-
}
-void Animation::track_set_key_value(int p_track, int p_key_idx,const Variant& p_value) {
+void Animation::track_set_key_value(int p_track, int p_key_idx, const Variant &p_value) {
ERR_FAIL_INDEX(p_track, tracks.size());
- Track *t=tracks[p_track];
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
- ERR_FAIL_INDEX( p_key_idx, tt->transforms.size());
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
+ ERR_FAIL_INDEX(p_key_idx, tt->transforms.size());
Dictionary d = p_value;
if (d.has("loc"))
- tt->transforms[p_key_idx].value.loc=d["loc"];
+ tt->transforms[p_key_idx].value.loc = d["loc"];
if (d.has("rot"))
- tt->transforms[p_key_idx].value.rot=d["rot"];
+ tt->transforms[p_key_idx].value.rot = d["rot"];
if (d.has("scale"))
- tt->transforms[p_key_idx].value.scale=d["scale"];
+ tt->transforms[p_key_idx].value.scale = d["scale"];
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
- ERR_FAIL_INDEX( p_key_idx, vt->values.size());
- vt->values[p_key_idx].value=p_value;
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
+ ERR_FAIL_INDEX(p_key_idx, vt->values.size());
+ vt->values[p_key_idx].value = p_value;
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
- ERR_FAIL_INDEX( p_key_idx, mt->methods.size());
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
+ ERR_FAIL_INDEX(p_key_idx, mt->methods.size());
Dictionary d = p_value;
if (d.has("method"))
- mt->methods[p_key_idx].method=d["method"];
+ mt->methods[p_key_idx].method = d["method"];
if (d.has("args"))
- mt->methods[p_key_idx].params=d["args"];
+ mt->methods[p_key_idx].params = d["args"];
} break;
}
-
}
-void Animation::track_set_key_transition(int p_track, int p_key_idx,float p_transition) {
+void Animation::track_set_key_transition(int p_track, int p_key_idx, float p_transition) {
ERR_FAIL_INDEX(p_track, tracks.size());
- Track *t=tracks[p_track];
+ Track *t = tracks[p_track];
- switch(t->type) {
+ switch (t->type) {
case TYPE_TRANSFORM: {
- TransformTrack * tt = static_cast<TransformTrack*>(t);
- ERR_FAIL_INDEX( p_key_idx, tt->transforms.size());
- tt->transforms[p_key_idx].transition=p_transition;
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
+ ERR_FAIL_INDEX(p_key_idx, tt->transforms.size());
+ tt->transforms[p_key_idx].transition = p_transition;
} break;
case TYPE_VALUE: {
- ValueTrack * vt = static_cast<ValueTrack*>(t);
- ERR_FAIL_INDEX( p_key_idx, vt->values.size());
- vt->values[p_key_idx].transition=p_transition;
-
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
+ ERR_FAIL_INDEX(p_key_idx, vt->values.size());
+ vt->values[p_key_idx].transition = p_transition;
} break;
case TYPE_METHOD: {
- MethodTrack * mt = static_cast<MethodTrack*>(t);
- ERR_FAIL_INDEX( p_key_idx, mt->methods.size());
- mt->methods[p_key_idx].transition=p_transition;
-
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
+ ERR_FAIL_INDEX(p_key_idx, mt->methods.size());
+ mt->methods[p_key_idx].transition = p_transition;
} break;
}
-
}
+template <class K>
+int Animation::_find(const Vector<K> &p_keys, float p_time) const {
-
-template<class K>
-int Animation::_find( const Vector<K>& p_keys, float p_time) const {
-
- int len=p_keys.size();
- if (len==0)
+ int len = p_keys.size();
+ if (len == 0)
return -2;
int low = 0;
- int high = len -1;
+ int high = len - 1;
int middle;
- const K* keys =&p_keys[0];
+ const K *keys = &p_keys[0];
- while( low <= high ) {
+ while (low <= high) {
- middle = ( low + high ) / 2;
+ middle = (low + high) / 2;
- if( p_time == keys[ middle ].time ) { //match
+ if (p_time == keys[middle].time) { //match
return middle;
- } else if( p_time < keys[middle].time )
+ } else if (p_time < keys[middle].time)
high = middle - 1; //search low end of array
else
low = middle + 1; //search high end of array
}
- if (keys[middle].time>p_time)
+ if (keys[middle].time > p_time)
middle--;
return middle;
}
-Animation::TransformKey Animation::_interpolate( const Animation::TransformKey& p_a, const Animation::TransformKey& p_b, float p_c) const {
+Animation::TransformKey Animation::_interpolate(const Animation::TransformKey &p_a, const Animation::TransformKey &p_b, float p_c) const {
TransformKey ret;
- ret.loc=_interpolate(p_a.loc,p_b.loc,p_c);
- ret.rot=_interpolate(p_a.rot,p_b.rot,p_c);
- ret.scale=_interpolate(p_a.scale,p_b.scale,p_c);
+ ret.loc = _interpolate(p_a.loc, p_b.loc, p_c);
+ ret.rot = _interpolate(p_a.rot, p_b.rot, p_c);
+ ret.scale = _interpolate(p_a.scale, p_b.scale, p_c);
return ret;
}
-Vector3 Animation::_interpolate( const Vector3& p_a, const Vector3& p_b, float p_c) const {
+Vector3 Animation::_interpolate(const Vector3 &p_a, const Vector3 &p_b, float p_c) const {
- return p_a.linear_interpolate(p_b,p_c);
+ return p_a.linear_interpolate(p_b, p_c);
}
-Quat Animation::_interpolate( const Quat& p_a, const Quat& p_b, float p_c) const {
+Quat Animation::_interpolate(const Quat &p_a, const Quat &p_b, float p_c) const {
- return p_a.slerp(p_b,p_c);
+ return p_a.slerp(p_b, p_c);
}
-Variant Animation::_interpolate( const Variant& p_a, const Variant& p_b, float p_c) const {
+Variant Animation::_interpolate(const Variant &p_a, const Variant &p_b, float p_c) const {
Variant dst;
- Variant::interpolate(p_a,p_b,p_c,dst);
+ Variant::interpolate(p_a, p_b, p_c, dst);
return dst;
}
+float Animation::_interpolate(const float &p_a, const float &p_b, float p_c) const {
-float Animation::_interpolate( const float& p_a, const float& p_b, float p_c) const {
-
- return p_a*(1.0-p_c) + p_b*p_c;
+ return p_a * (1.0 - p_c) + p_b * p_c;
}
-Animation::TransformKey Animation::_cubic_interpolate( const Animation::TransformKey& p_pre_a, const Animation::TransformKey& p_a, const Animation::TransformKey& p_b, const Animation::TransformKey& p_post_b,float p_c) const {
-
+Animation::TransformKey Animation::_cubic_interpolate(const Animation::TransformKey &p_pre_a, const Animation::TransformKey &p_a, const Animation::TransformKey &p_b, const Animation::TransformKey &p_post_b, float p_c) const {
Animation::TransformKey tk;
- tk.loc = p_a.loc.cubic_interpolate(p_b.loc,p_pre_a.loc,p_post_b.loc,p_c);
- tk.scale = p_a.scale.cubic_interpolate(p_b.scale,p_pre_a.scale,p_post_b.scale,p_c);
- tk.rot = p_a.rot.cubic_slerp(p_b.rot,p_pre_a.rot,p_post_b.rot,p_c);
+ tk.loc = p_a.loc.cubic_interpolate(p_b.loc, p_pre_a.loc, p_post_b.loc, p_c);
+ tk.scale = p_a.scale.cubic_interpolate(p_b.scale, p_pre_a.scale, p_post_b.scale, p_c);
+ tk.rot = p_a.rot.cubic_slerp(p_b.rot, p_pre_a.rot, p_post_b.rot, p_c);
return tk;
-
}
-Vector3 Animation::_cubic_interpolate( const Vector3& p_pre_a,const Vector3& p_a, const Vector3& p_b,const Vector3& p_post_b, float p_c) const {
+Vector3 Animation::_cubic_interpolate(const Vector3 &p_pre_a, const Vector3 &p_a, const Vector3 &p_b, const Vector3 &p_post_b, float p_c) const {
- return p_a.cubic_interpolate(p_b,p_pre_a,p_post_b,p_c);
+ return p_a.cubic_interpolate(p_b, p_pre_a, p_post_b, p_c);
}
-Quat Animation::_cubic_interpolate( const Quat& p_pre_a,const Quat& p_a, const Quat& p_b,const Quat& p_post_b, float p_c) const {
+Quat Animation::_cubic_interpolate(const Quat &p_pre_a, const Quat &p_a, const Quat &p_b, const Quat &p_post_b, float p_c) const {
- return p_a.cubic_slerp(p_b,p_pre_a,p_post_b,p_c);
+ return p_a.cubic_slerp(p_b, p_pre_a, p_post_b, p_c);
}
-Variant Animation::_cubic_interpolate( const Variant& p_pre_a,const Variant& p_a, const Variant& p_b, const Variant& p_post_b,float p_c) const {
+Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, float p_c) const {
- Variant::Type type_a=p_a.get_type();
- Variant::Type type_b=p_b.get_type();
- Variant::Type type_pa=p_pre_a.get_type();
- Variant::Type type_pb=p_post_b.get_type();
+ Variant::Type type_a = p_a.get_type();
+ Variant::Type type_b = p_b.get_type();
+ Variant::Type type_pa = p_pre_a.get_type();
+ Variant::Type type_pb = p_post_b.get_type();
//make int and real play along
- uint32_t vformat=1<<type_a;
- vformat|=1<<type_b;
- vformat|=1<<type_pa;
- vformat|=1<<type_pb;
+ uint32_t vformat = 1 << type_a;
+ vformat |= 1 << type_b;
+ vformat |= 1 << type_pa;
+ vformat |= 1 << type_pb;
- if (vformat==((1<<Variant::INT)|(1<<Variant::REAL)) || vformat==(1<<Variant::REAL)) {
+ if (vformat == ((1 << Variant::INT) | (1 << Variant::REAL)) || vformat == (1 << Variant::REAL)) {
//mix of real and int
- real_t p0=p_pre_a;
- real_t p1=p_a;
- real_t p2=p_b;
- real_t p3=p_post_b;
+ real_t p0 = p_pre_a;
+ real_t p1 = p_a;
+ real_t p2 = p_b;
+ real_t p3 = p_post_b;
float t = p_c;
float t2 = t * t;
float t3 = t2 * t;
- return
- 0.5f * ( ( p1 * 2.0f) +
- ( -p0 + p2 ) * t +
- ( 2.0f * p0 - 5.0f * p1 + 4 * p2 - p3 ) * t2 +
- ( -p0 + 3.0f * p1 - 3.0f * p2 + p3 ) * t3 );
-
+ return 0.5f * ((p1 * 2.0f) +
+ (-p0 + p2) * t +
+ (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
+ (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
} else if ((vformat & (vformat - 1))) {
return p_a; //can't interpolate, mix of types
}
- switch(type_a) {
+ switch (type_a) {
case Variant::VECTOR2: {
- Vector2 a=p_a;
- Vector2 b=p_b;
- Vector2 pa=p_pre_a;
- Vector2 pb=p_post_b;
+ Vector2 a = p_a;
+ Vector2 b = p_b;
+ Vector2 pa = p_pre_a;
+ Vector2 pb = p_post_b;
- return a.cubic_interpolate(b,pa,pb,p_c);
+ return a.cubic_interpolate(b, pa, pb, p_c);
} break;
case Variant::RECT2: {
- Rect2 a=p_a;
- Rect2 b=p_b;
- Rect2 pa=p_pre_a;
- Rect2 pb=p_post_b;
+ Rect2 a = p_a;
+ Rect2 b = p_b;
+ Rect2 pa = p_pre_a;
+ Rect2 pb = p_post_b;
return Rect2(
- a.pos.cubic_interpolate(b.pos,pa.pos,pb.pos,p_c),
- a.size.cubic_interpolate(b.size,pa.size,pb.size,p_c)
- );
+ a.pos.cubic_interpolate(b.pos, pa.pos, pb.pos, p_c),
+ a.size.cubic_interpolate(b.size, pa.size, pb.size, p_c));
} break;
case Variant::VECTOR3: {
- Vector3 a=p_a;
- Vector3 b=p_b;
- Vector3 pa=p_pre_a;
- Vector3 pb=p_post_b;
+ Vector3 a = p_a;
+ Vector3 b = p_b;
+ Vector3 pa = p_pre_a;
+ Vector3 pb = p_post_b;
- return a.cubic_interpolate(b,pa,pb,p_c);
+ return a.cubic_interpolate(b, pa, pb, p_c);
} break;
case Variant::QUAT: {
- Quat a=p_a;
- Quat b=p_b;
- Quat pa=p_pre_a;
- Quat pb=p_post_b;
+ Quat a = p_a;
+ Quat b = p_b;
+ Quat pa = p_pre_a;
+ Quat pb = p_post_b;
- return a.cubic_slerp(b,pa,pb,p_c);
+ return a.cubic_slerp(b, pa, pb, p_c);
} break;
case Variant::_AABB: {
- AABB a=p_a;
- AABB b=p_b;
- AABB pa=p_pre_a;
- AABB pb=p_post_b;
+ AABB a = p_a;
+ AABB b = p_b;
+ AABB pa = p_pre_a;
+ AABB pb = p_post_b;
return AABB(
- a.pos.cubic_interpolate(b.pos,pa.pos,pb.pos,p_c),
- a.size.cubic_interpolate(b.size,pa.size,pb.size,p_c)
- );
+ a.pos.cubic_interpolate(b.pos, pa.pos, pb.pos, p_c),
+ a.size.cubic_interpolate(b.size, pa.size, pb.size, p_c));
} break;
default: {
- return _interpolate(p_a,p_b,p_c);
+ return _interpolate(p_a, p_b, p_c);
}
}
return Variant();
}
-float Animation::_cubic_interpolate( const float& p_pre_a,const float& p_a, const float& p_b, const float& p_post_b, float p_c) const {
+float Animation::_cubic_interpolate(const float &p_pre_a, const float &p_a, const float &p_b, const float &p_post_b, float p_c) const {
- return _interpolate(p_a,p_b,p_c);
+ return _interpolate(p_a, p_b, p_c);
}
-template<class T>
-T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, InterpolationType p_interp, bool *p_ok) const {
+template <class T>
+T Animation::_interpolate(const Vector<TKey<T> > &p_keys, float p_time, InterpolationType p_interp, bool *p_ok) const {
- int len=_find( p_keys, length )+1; // try to find last key (there may be more past the end)
+ int len = _find(p_keys, length) + 1; // try to find last key (there may be more past the end)
- if (len<=0) {
+ if (len <= 0) {
// (-1 or -2 returned originally) (plus one above)
// meaning no keys, or only key time is larger than length
if (p_ok)
- *p_ok=false;
+ *p_ok = false;
return T();
- } else if (len==1) { // one key found (0+1), return it
+ } else if (len == 1) { // one key found (0+1), return it
if (p_ok)
- *p_ok=true;
+ *p_ok = true;
return p_keys[0].value;
}
- int idx=_find(p_keys, p_time);
+ int idx = _find(p_keys, p_time);
- ERR_FAIL_COND_V( idx==-2, T());
+ ERR_FAIL_COND_V(idx == -2, T());
if (p_ok)
- *p_ok=true;
+ *p_ok = true;
- int next=0;
- float c=0;
+ int next = 0;
+ float c = 0;
// prepare for all cases of interpolation
if (loop) {
- // loop
- if (idx>=0) {
+ // loop
+ if (idx >= 0) {
- if ((idx+1) < len) {
+ if ((idx + 1) < len) {
- next=idx+1;
- float delta=p_keys[next].time - p_keys[idx].time;
- float from=p_time-p_keys[idx].time;
+ next = idx + 1;
+ float delta = p_keys[next].time - p_keys[idx].time;
+ float from = p_time - p_keys[idx].time;
- if (Math::absf(delta)>CMP_EPSILON)
- c=from/delta;
+ if (Math::absf(delta) > CMP_EPSILON)
+ c = from / delta;
else
- c=0;
+ c = 0;
} else {
- next=0;
- float delta=(length - p_keys[idx].time) + p_keys[next].time;
- float from=p_time-p_keys[idx].time;
+ next = 0;
+ float delta = (length - p_keys[idx].time) + p_keys[next].time;
+ float from = p_time - p_keys[idx].time;
- if (Math::absf(delta)>CMP_EPSILON)
- c=from/delta;
+ if (Math::absf(delta) > CMP_EPSILON)
+ c = from / delta;
else
- c=0;
-
+ c = 0;
}
} else {
// on loop, behind first key
- idx=len-1;
- next=0;
- float endtime=(length - p_keys[idx].time);
- if (endtime<0) // may be keys past the end
- endtime=0;
- float delta=endtime + p_keys[next].time;
- float from=endtime+p_time;
+ idx = len - 1;
+ next = 0;
+ float endtime = (length - p_keys[idx].time);
+ if (endtime < 0) // may be keys past the end
+ endtime = 0;
+ float delta = endtime + p_keys[next].time;
+ float from = endtime + p_time;
- if (Math::absf(delta)>CMP_EPSILON)
- c=from/delta;
+ if (Math::absf(delta) > CMP_EPSILON)
+ c = from / delta;
else
- c=0;
+ c = 0;
}
} else { // no loop
- if (idx>=0) {
+ if (idx >= 0) {
- if ((idx+1) < len) {
+ if ((idx + 1) < len) {
- next=idx+1;
- float delta=p_keys[next].time - p_keys[idx].time;
- float from=p_time - p_keys[idx].time;
+ next = idx + 1;
+ float delta = p_keys[next].time - p_keys[idx].time;
+ float from = p_time - p_keys[idx].time;
- if (Math::absf(delta)>CMP_EPSILON)
- c=from/delta;
+ if (Math::absf(delta) > CMP_EPSILON)
+ c = from / delta;
else
- c=0;
+ c = 0;
} else {
- next=idx;
+ next = idx;
}
- } else if (idx<0) {
+ } else if (idx < 0) {
- idx=next=0;
+ idx = next = 0;
}
-
}
float tr = p_keys[idx].transition;
- if (tr==0 || idx==next) {
+ if (tr == 0 || idx == next) {
// don't interpolate if not needed
return p_keys[idx].value;
}
- if (tr!=1.0) {
+ if (tr != 1.0) {
- c = Math::ease(c,tr);
+ c = Math::ease(c, tr);
}
- switch(p_interp) {
+ switch (p_interp) {
case INTERPOLATION_NEAREST: {
@@ -1333,66 +1284,59 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, Inter
return _interpolate(p_keys[idx].value, p_keys[next].value, c);
} break;
case INTERPOLATION_CUBIC: {
- int pre = idx-1;
- if (pre<0)
- pre=0;
- int post = next+1;
- if (post>=len)
- post=next;
+ int pre = idx - 1;
+ if (pre < 0)
+ pre = 0;
+ int post = next + 1;
+ if (post >= len)
+ post = next;
-
- return _cubic_interpolate(p_keys[pre].value,p_keys[idx].value, p_keys[next].value,p_keys[post].value, c);
+ return _cubic_interpolate(p_keys[pre].value, p_keys[idx].value, p_keys[next].value, p_keys[post].value, c);
} break;
default: return p_keys[idx].value;
}
// do a barrel roll
-
-
}
+Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3 *r_loc, Quat *r_rot, Vector3 *r_scale) const {
-Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3 * r_loc, Quat *r_rot, Vector3 *r_scale) const {
-
- ERR_FAIL_INDEX_V(p_track, tracks.size(),ERR_INVALID_PARAMETER);
- Track *t=tracks[p_track];
- ERR_FAIL_COND_V(t->type!=TYPE_TRANSFORM,ERR_INVALID_PARAMETER);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM, ERR_INVALID_PARAMETER);
- TransformTrack * tt = static_cast<TransformTrack*>(t);
+ TransformTrack *tt = static_cast<TransformTrack *>(t);
bool ok;
- TransformKey tk = _interpolate( tt->transforms, p_time, tt->interpolation, &ok );
+ TransformKey tk = _interpolate(tt->transforms, p_time, tt->interpolation, &ok);
if (!ok) // ??
return ERR_UNAVAILABLE;
if (r_loc)
- *r_loc=tk.loc;
+ *r_loc = tk.loc;
if (r_rot)
- *r_rot=tk.rot;
+ *r_rot = tk.rot;
if (r_scale)
- *r_scale=tk.scale;
+ *r_scale = tk.scale;
return OK;
-
}
Variant Animation::value_track_interpolate(int p_track, float p_time) const {
- ERR_FAIL_INDEX_V(p_track, tracks.size(),0);
- Track *t=tracks[p_track];
- ERR_FAIL_COND_V(t->type!=TYPE_VALUE, Variant());
- ValueTrack * vt = static_cast<ValueTrack*>(t);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), 0);
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND_V(t->type != TYPE_VALUE, Variant());
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
bool ok;
-
- Variant res = _interpolate( vt->values, p_time, vt->update_mode==UPDATE_CONTINUOUS?vt->interpolation:INTERPOLATION_NEAREST, &ok );
-
+ Variant res = _interpolate(vt->values, p_time, vt->update_mode == UPDATE_CONTINUOUS ? vt->interpolation : INTERPOLATION_NEAREST, &ok);
if (ok) {
@@ -1402,219 +1346,203 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const {
return Variant();
}
-void Animation::_value_track_get_key_indices_in_range(const ValueTrack * vt, float from_time, float to_time,List<int> *p_indices) const {
+void Animation::_value_track_get_key_indices_in_range(const ValueTrack *vt, float from_time, float to_time, List<int> *p_indices) const {
- if (from_time!=length && to_time==length)
- to_time=length*1.01; //include a little more if at the end
- int to=_find( vt->values, to_time);
+ if (from_time != length && to_time == length)
+ to_time = length * 1.01; //include a little more if at the end
+ int to = _find(vt->values, to_time);
// can't really send the events == time, will be sent in the next frame.
// if event>=len then it will probably never be requested by the anim player.
- if (to>=0 && vt->values[to].time>=to_time)
+ if (to >= 0 && vt->values[to].time >= to_time)
to--;
- if (to<0)
+ if (to < 0)
return; // not bother
- int from=_find( vt->values, from_time);
+ int from = _find(vt->values, from_time);
// position in the right first event.+
- if (from<0 || vt->values[from].time<from_time)
+ if (from < 0 || vt->values[from].time < from_time)
from++;
- int max=vt->values.size();
+ int max = vt->values.size();
- for (int i=from;i<=to;i++) {
+ for (int i = from; i <= to; i++) {
- ERR_CONTINUE( i<0 || i>=max); // shouldn't happen
+ ERR_CONTINUE(i < 0 || i >= max); // shouldn't happen
p_indices->push_back(i);
}
-
-
}
-void Animation::value_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const {
+void Animation::value_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const {
ERR_FAIL_INDEX(p_track, tracks.size());
- Track *t=tracks[p_track];
- ERR_FAIL_COND( t->type != TYPE_VALUE );
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND(t->type != TYPE_VALUE);
- ValueTrack * vt = static_cast<ValueTrack*>(t);
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
- float from_time=p_time-p_delta;
- float to_time=p_time;
+ float from_time = p_time - p_delta;
+ float to_time = p_time;
- if (from_time>to_time)
- SWAP(from_time,to_time);
+ if (from_time > to_time)
+ SWAP(from_time, to_time);
if (loop) {
- from_time=Math::fposmod(from_time,length);
- to_time=Math::fposmod(to_time,length);
+ from_time = Math::fposmod(from_time, length);
+ to_time = Math::fposmod(to_time, length);
- if (from_time>to_time) {
+ if (from_time > to_time) {
// handle loop by splitting
- _value_track_get_key_indices_in_range(vt,length-from_time,length,p_indices);
- _value_track_get_key_indices_in_range(vt,0,to_time,p_indices);
+ _value_track_get_key_indices_in_range(vt, length - from_time, length, p_indices);
+ _value_track_get_key_indices_in_range(vt, 0, to_time, p_indices);
return;
}
} else {
- if (from_time<0)
- from_time=0;
- if (from_time>length)
- from_time=length;
-
- if (to_time<0)
- to_time=0;
- if (to_time>length)
- to_time=length;
-
+ if (from_time < 0)
+ from_time = 0;
+ if (from_time > length)
+ from_time = length;
+ if (to_time < 0)
+ to_time = 0;
+ if (to_time > length)
+ to_time = length;
}
- _value_track_get_key_indices_in_range(vt,from_time,to_time,p_indices);
-
-
+ _value_track_get_key_indices_in_range(vt, from_time, to_time, p_indices);
}
void Animation::value_track_set_update_mode(int p_track, UpdateMode p_mode) {
ERR_FAIL_INDEX(p_track, tracks.size());
- Track *t=tracks[p_track];
- ERR_FAIL_COND( t->type != TYPE_VALUE );
- ERR_FAIL_INDEX(p_mode,3);
-
- ValueTrack * vt = static_cast<ValueTrack*>(t);
- vt->update_mode=p_mode;
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND(t->type != TYPE_VALUE);
+ ERR_FAIL_INDEX(p_mode, 3);
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
+ vt->update_mode = p_mode;
}
Animation::UpdateMode Animation::value_track_get_update_mode(int p_track) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), UPDATE_CONTINUOUS);
- Track *t=tracks[p_track];
- ERR_FAIL_COND_V( t->type != TYPE_VALUE, UPDATE_CONTINUOUS );
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND_V(t->type != TYPE_VALUE, UPDATE_CONTINUOUS);
- ValueTrack * vt = static_cast<ValueTrack*>(t);
+ ValueTrack *vt = static_cast<ValueTrack *>(t);
return vt->update_mode;
-
}
+void Animation::_method_track_get_key_indices_in_range(const MethodTrack *mt, float from_time, float to_time, List<int> *p_indices) const {
-void Animation::_method_track_get_key_indices_in_range(const MethodTrack * mt, float from_time, float to_time,List<int> *p_indices) const {
+ if (from_time != length && to_time == length)
+ to_time = length * 1.01; //include a little more if at the end
- if (from_time!=length && to_time==length)
- to_time=length*1.01; //include a little more if at the end
-
-
- int to=_find( mt->methods, to_time);
+ int to = _find(mt->methods, to_time);
// can't really send the events == time, will be sent in the next frame.
// if event>=len then it will probably never be requested by the anim player.
- if (to>=0 && mt->methods[to].time>=to_time)
+ if (to >= 0 && mt->methods[to].time >= to_time)
to--;
- if (to<0)
+ if (to < 0)
return; // not bother
- int from=_find( mt->methods, from_time);
+ int from = _find(mt->methods, from_time);
// position in the right first event.+
- if (from<0 || mt->methods[from].time<from_time)
+ if (from < 0 || mt->methods[from].time < from_time)
from++;
- int max=mt->methods.size();
+ int max = mt->methods.size();
- for (int i=from;i<=to;i++) {
+ for (int i = from; i <= to; i++) {
- ERR_CONTINUE( i<0 || i>=max); // shouldn't happen
+ ERR_CONTINUE(i < 0 || i >= max); // shouldn't happen
p_indices->push_back(i);
}
-
}
-void Animation::method_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const {
+void Animation::method_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const {
ERR_FAIL_INDEX(p_track, tracks.size());
- Track *t=tracks[p_track];
- ERR_FAIL_COND( t->type != TYPE_METHOD );
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND(t->type != TYPE_METHOD);
- MethodTrack * mt = static_cast<MethodTrack*>(t);
+ MethodTrack *mt = static_cast<MethodTrack *>(t);
- float from_time=p_time-p_delta;
- float to_time=p_time;
+ float from_time = p_time - p_delta;
+ float to_time = p_time;
- if (from_time>to_time)
- SWAP(from_time,to_time);
+ if (from_time > to_time)
+ SWAP(from_time, to_time);
if (loop) {
if (from_time > length || from_time < 0)
- from_time=Math::fposmod(from_time,length);
+ from_time = Math::fposmod(from_time, length);
if (to_time > length || to_time < 0)
- to_time=Math::fposmod(to_time,length);
+ to_time = Math::fposmod(to_time, length);
- if (from_time>to_time) {
+ if (from_time > to_time) {
// handle loop by splitting
- _method_track_get_key_indices_in_range(mt,from_time,length,p_indices);
- _method_track_get_key_indices_in_range(mt,0,to_time,p_indices);
+ _method_track_get_key_indices_in_range(mt, from_time, length, p_indices);
+ _method_track_get_key_indices_in_range(mt, 0, to_time, p_indices);
return;
}
} else {
- if (from_time<0)
- from_time=0;
- if (from_time>length)
- from_time=length;
-
- if (to_time<0)
- to_time=0;
- if (to_time>length)
- to_time=length;
+ if (from_time < 0)
+ from_time = 0;
+ if (from_time > length)
+ from_time = length;
+ if (to_time < 0)
+ to_time = 0;
+ if (to_time > length)
+ to_time = length;
}
- _method_track_get_key_indices_in_range(mt,from_time,to_time,p_indices);
-
-
+ _method_track_get_key_indices_in_range(mt, from_time, to_time, p_indices);
}
-Vector<Variant> Animation::method_track_get_params(int p_track,int p_key_idx) const {
+Vector<Variant> Animation::method_track_get_params(int p_track, int p_key_idx) const {
- ERR_FAIL_INDEX_V(p_track, tracks.size(),Vector<Variant>());
- Track *t=tracks[p_track];
- ERR_FAIL_COND_V( t->type != TYPE_METHOD, Vector<Variant>() );
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), Vector<Variant>());
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND_V(t->type != TYPE_METHOD, Vector<Variant>());
- MethodTrack * pm = static_cast<MethodTrack*>(t);
+ MethodTrack *pm = static_cast<MethodTrack *>(t);
- ERR_FAIL_INDEX_V( p_key_idx, pm->methods.size(), Vector<Variant>() );
+ ERR_FAIL_INDEX_V(p_key_idx, pm->methods.size(), Vector<Variant>());
- const MethodKey& mk=pm->methods[p_key_idx];
+ const MethodKey &mk = pm->methods[p_key_idx];
return mk.params;
}
-StringName Animation::method_track_get_name(int p_track,int p_key_idx) const {
-
- ERR_FAIL_INDEX_V(p_track, tracks.size(),StringName());
- Track *t=tracks[p_track];
- ERR_FAIL_COND_V( t->type != TYPE_METHOD, StringName() );
+StringName Animation::method_track_get_name(int p_track, int p_key_idx) const {
- MethodTrack * pm = static_cast<MethodTrack*>(t);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), StringName());
+ Track *t = tracks[p_track];
+ ERR_FAIL_COND_V(t->type != TYPE_METHOD, StringName());
- ERR_FAIL_INDEX_V( p_key_idx, pm->methods.size(), StringName() );
+ MethodTrack *pm = static_cast<MethodTrack *>(t);
- return pm->methods[ p_key_idx ].method;
+ ERR_FAIL_INDEX_V(p_key_idx, pm->methods.size(), StringName());
+ return pm->methods[p_key_idx].method;
}
-
void Animation::set_length(float p_length) {
- ERR_FAIL_COND( length<0 );
- length=p_length;
+ ERR_FAIL_COND(length < 0);
+ length = p_length;
emit_changed();
}
float Animation::get_length() const {
@@ -1624,7 +1552,7 @@ float Animation::get_length() const {
void Animation::set_loop(bool p_enabled) {
- loop=p_enabled;
+ loop = p_enabled;
emit_changed();
}
bool Animation::has_loop() const {
@@ -1634,284 +1562,268 @@ bool Animation::has_loop() const {
void Animation::track_move_up(int p_track) {
+ if (p_track >= 0 && p_track < (tracks.size() - 1)) {
- if (p_track>=0 && p_track<(tracks.size()-1)) {
-
- SWAP( tracks[p_track], tracks[p_track+1] );
+ SWAP(tracks[p_track], tracks[p_track + 1]);
}
emit_changed();
}
-void Animation::track_set_imported(int p_track,bool p_imported) {
+void Animation::track_set_imported(int p_track, bool p_imported) {
- ERR_FAIL_INDEX(p_track,tracks.size());
- tracks[p_track]->imported=p_imported;
+ ERR_FAIL_INDEX(p_track, tracks.size());
+ tracks[p_track]->imported = p_imported;
}
-bool Animation::track_is_imported(int p_track) const{
+bool Animation::track_is_imported(int p_track) const {
- ERR_FAIL_INDEX_V(p_track,tracks.size(),false);
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), false);
return tracks[p_track]->imported;
-
}
-
void Animation::track_move_down(int p_track) {
- if (p_track>0 && p_track<tracks.size()) {
+ if (p_track > 0 && p_track < tracks.size()) {
- SWAP( tracks[p_track], tracks[p_track-1] );
+ SWAP(tracks[p_track], tracks[p_track - 1]);
}
emit_changed();
}
void Animation::set_step(float p_step) {
- step=p_step;
+ step = p_step;
emit_changed();
}
-float Animation::get_step() const{
+float Animation::get_step() const {
return step;
}
-
void Animation::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_track","type","at_pos"),&Animation::add_track,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("remove_track","idx"),&Animation::remove_track);
- ObjectTypeDB::bind_method(_MD("get_track_count"),&Animation::get_track_count);
- ObjectTypeDB::bind_method(_MD("track_get_type","idx"),&Animation::track_get_type);
- ObjectTypeDB::bind_method(_MD("track_get_path","idx"),&Animation::track_get_path);
- ObjectTypeDB::bind_method(_MD("track_set_path","idx","path"),&Animation::track_set_path);
- ObjectTypeDB::bind_method(_MD("find_track","path"),&Animation::find_track);
-
- ObjectTypeDB::bind_method(_MD("track_move_up","idx"),&Animation::track_move_up);
- ObjectTypeDB::bind_method(_MD("track_move_down","idx"),&Animation::track_move_down);
+ ObjectTypeDB::bind_method(_MD("add_track", "type", "at_pos"), &Animation::add_track, DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("remove_track", "idx"), &Animation::remove_track);
+ ObjectTypeDB::bind_method(_MD("get_track_count"), &Animation::get_track_count);
+ ObjectTypeDB::bind_method(_MD("track_get_type", "idx"), &Animation::track_get_type);
+ ObjectTypeDB::bind_method(_MD("track_get_path", "idx"), &Animation::track_get_path);
+ ObjectTypeDB::bind_method(_MD("track_set_path", "idx", "path"), &Animation::track_set_path);
+ ObjectTypeDB::bind_method(_MD("find_track", "path"), &Animation::find_track);
- ObjectTypeDB::bind_method(_MD("track_set_imported","idx","imported"),&Animation::track_set_imported);
- ObjectTypeDB::bind_method(_MD("track_is_imported","idx"),&Animation::track_is_imported);
+ ObjectTypeDB::bind_method(_MD("track_move_up", "idx"), &Animation::track_move_up);
+ ObjectTypeDB::bind_method(_MD("track_move_down", "idx"), &Animation::track_move_down);
+ ObjectTypeDB::bind_method(_MD("track_set_imported", "idx", "imported"), &Animation::track_set_imported);
+ ObjectTypeDB::bind_method(_MD("track_is_imported", "idx"), &Animation::track_is_imported);
- ObjectTypeDB::bind_method(_MD("transform_track_insert_key","idx","time","loc","rot","scale"),&Animation::transform_track_insert_key);
- ObjectTypeDB::bind_method(_MD("track_insert_key","idx","time","key","transition"),&Animation::track_insert_key,DEFVAL(1));
- ObjectTypeDB::bind_method(_MD("track_remove_key","idx","key_idx"),&Animation::track_remove_key);
- ObjectTypeDB::bind_method(_MD("track_remove_key_at_pos","idx","pos"),&Animation::track_remove_key_at_pos);
- ObjectTypeDB::bind_method(_MD("track_set_key_value","idx","key","value"),&Animation::track_set_key_value);
- ObjectTypeDB::bind_method(_MD("track_set_key_transition","idx","key_idx","transition"),&Animation::track_set_key_transition);
- ObjectTypeDB::bind_method(_MD("track_get_key_transition","idx","key_idx"),&Animation::track_get_key_transition);
+ ObjectTypeDB::bind_method(_MD("transform_track_insert_key", "idx", "time", "loc", "rot", "scale"), &Animation::transform_track_insert_key);
+ ObjectTypeDB::bind_method(_MD("track_insert_key", "idx", "time", "key", "transition"), &Animation::track_insert_key, DEFVAL(1));
+ ObjectTypeDB::bind_method(_MD("track_remove_key", "idx", "key_idx"), &Animation::track_remove_key);
+ ObjectTypeDB::bind_method(_MD("track_remove_key_at_pos", "idx", "pos"), &Animation::track_remove_key_at_pos);
+ ObjectTypeDB::bind_method(_MD("track_set_key_value", "idx", "key", "value"), &Animation::track_set_key_value);
+ ObjectTypeDB::bind_method(_MD("track_set_key_transition", "idx", "key_idx", "transition"), &Animation::track_set_key_transition);
+ ObjectTypeDB::bind_method(_MD("track_get_key_transition", "idx", "key_idx"), &Animation::track_get_key_transition);
- ObjectTypeDB::bind_method(_MD("track_get_key_count","idx"),&Animation::track_get_key_count);
- ObjectTypeDB::bind_method(_MD("track_get_key_value","idx","key_idx"),&Animation::track_get_key_value);
- ObjectTypeDB::bind_method(_MD("track_get_key_time","idx","key_idx"),&Animation::track_get_key_time);
- ObjectTypeDB::bind_method(_MD("track_find_key","idx","time","exact"),&Animation::track_find_key,DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("track_get_key_count", "idx"), &Animation::track_get_key_count);
+ ObjectTypeDB::bind_method(_MD("track_get_key_value", "idx", "key_idx"), &Animation::track_get_key_value);
+ ObjectTypeDB::bind_method(_MD("track_get_key_time", "idx", "key_idx"), &Animation::track_get_key_time);
+ ObjectTypeDB::bind_method(_MD("track_find_key", "idx", "time", "exact"), &Animation::track_find_key, DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("track_set_interpolation_type","idx","interpolation"),&Animation::track_set_interpolation_type);
- ObjectTypeDB::bind_method(_MD("track_get_interpolation_type","idx"),&Animation::track_get_interpolation_type);
+ ObjectTypeDB::bind_method(_MD("track_set_interpolation_type", "idx", "interpolation"), &Animation::track_set_interpolation_type);
+ ObjectTypeDB::bind_method(_MD("track_get_interpolation_type", "idx"), &Animation::track_get_interpolation_type);
+ ObjectTypeDB::bind_method(_MD("transform_track_interpolate", "idx", "time_sec"), &Animation::_transform_track_interpolate);
+ ObjectTypeDB::bind_method(_MD("value_track_set_update_mode", "idx", "mode"), &Animation::value_track_set_update_mode);
+ ObjectTypeDB::bind_method(_MD("value_track_get_update_mode", "idx"), &Animation::value_track_get_update_mode);
+ ObjectTypeDB::bind_method(_MD("value_track_get_key_indices", "idx", "time_sec", "delta"), &Animation::_value_track_get_key_indices);
- ObjectTypeDB::bind_method(_MD("transform_track_interpolate","idx","time_sec"),&Animation::_transform_track_interpolate);
- ObjectTypeDB::bind_method(_MD("value_track_set_update_mode","idx","mode"),&Animation::value_track_set_update_mode);
- ObjectTypeDB::bind_method(_MD("value_track_get_update_mode","idx"),&Animation::value_track_get_update_mode);
+ ObjectTypeDB::bind_method(_MD("method_track_get_key_indices", "idx", "time_sec", "delta"), &Animation::_method_track_get_key_indices);
+ ObjectTypeDB::bind_method(_MD("method_track_get_name", "idx", "key_idx"), &Animation::method_track_get_name);
+ ObjectTypeDB::bind_method(_MD("method_track_get_params", "idx", "key_idx"), &Animation::method_track_get_params);
- ObjectTypeDB::bind_method(_MD("value_track_get_key_indices","idx","time_sec","delta"),&Animation::_value_track_get_key_indices);
+ ObjectTypeDB::bind_method(_MD("set_length", "time_sec"), &Animation::set_length);
+ ObjectTypeDB::bind_method(_MD("get_length"), &Animation::get_length);
- ObjectTypeDB::bind_method(_MD("method_track_get_key_indices","idx","time_sec","delta"),&Animation::_method_track_get_key_indices);
- ObjectTypeDB::bind_method(_MD("method_track_get_name","idx","key_idx"),&Animation::method_track_get_name);
- ObjectTypeDB::bind_method(_MD("method_track_get_params","idx","key_idx"),&Animation::method_track_get_params);
+ ObjectTypeDB::bind_method(_MD("set_loop", "enabled"), &Animation::set_loop);
+ ObjectTypeDB::bind_method(_MD("has_loop"), &Animation::has_loop);
- ObjectTypeDB::bind_method(_MD("set_length","time_sec"),&Animation::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&Animation::get_length);
+ ObjectTypeDB::bind_method(_MD("set_step", "size_sec"), &Animation::set_step);
+ ObjectTypeDB::bind_method(_MD("get_step"), &Animation::get_step);
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&Animation::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&Animation::has_loop);
+ ObjectTypeDB::bind_method(_MD("clear"), &Animation::clear);
- ObjectTypeDB::bind_method(_MD("set_step","size_sec"),&Animation::set_step);
- ObjectTypeDB::bind_method(_MD("get_step"),&Animation::get_step);
-
- ObjectTypeDB::bind_method(_MD("clear"),&Animation::clear);
-
- BIND_CONSTANT( TYPE_VALUE );
- BIND_CONSTANT( TYPE_TRANSFORM );
- BIND_CONSTANT( TYPE_METHOD );
-
- BIND_CONSTANT( INTERPOLATION_NEAREST );
- BIND_CONSTANT( INTERPOLATION_LINEAR );
- BIND_CONSTANT( INTERPOLATION_CUBIC );
-
- BIND_CONSTANT( UPDATE_CONTINUOUS );
- BIND_CONSTANT( UPDATE_DISCRETE );
- BIND_CONSTANT( UPDATE_TRIGGER );
+ BIND_CONSTANT(TYPE_VALUE);
+ BIND_CONSTANT(TYPE_TRANSFORM);
+ BIND_CONSTANT(TYPE_METHOD);
+ BIND_CONSTANT(INTERPOLATION_NEAREST);
+ BIND_CONSTANT(INTERPOLATION_LINEAR);
+ BIND_CONSTANT(INTERPOLATION_CUBIC);
+ BIND_CONSTANT(UPDATE_CONTINUOUS);
+ BIND_CONSTANT(UPDATE_DISCRETE);
+ BIND_CONSTANT(UPDATE_TRIGGER);
}
void Animation::clear() {
- for(int i=0;i<tracks.size();i++)
- memdelete( tracks[i] );
+ for (int i = 0; i < tracks.size(); i++)
+ memdelete(tracks[i]);
tracks.clear();
- loop=false;
- length=1;
-
+ loop = false;
+ length = 1;
}
+bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, const TKey<TransformKey> &t1, const TKey<TransformKey> &t2, float p_alowed_linear_err, float p_alowed_angular_err, float p_max_optimizable_angle, const Vector3 &p_norm) {
-
-bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0,const TKey<TransformKey> &t1, const TKey<TransformKey> &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle,const Vector3& p_norm) {
-
-
- real_t c = (t1.time-t0.time)/(t2.time-t0.time);
- real_t t[3]={-1,-1,-1};
+ real_t c = (t1.time - t0.time) / (t2.time - t0.time);
+ real_t t[3] = { -1, -1, -1 };
{ //translation
- const Vector3 &v0=t0.value.loc;
- const Vector3 &v1=t1.value.loc;
- const Vector3 &v2=t2.value.loc;
+ const Vector3 &v0 = t0.value.loc;
+ const Vector3 &v1 = t1.value.loc;
+ const Vector3 &v2 = t2.value.loc;
- if (v0.distance_to(v2)<CMP_EPSILON) {
+ if (v0.distance_to(v2) < CMP_EPSILON) {
//0 and 2 are close, let's see if 1 is close
- if (v0.distance_to(v1)>CMP_EPSILON) {
+ if (v0.distance_to(v1) > CMP_EPSILON) {
//not close, not optimizable
return false;
}
} else {
- Vector3 pd = (v2-v0);
+ Vector3 pd = (v2 - v0);
float d0 = pd.dot(v0);
float d1 = pd.dot(v1);
float d2 = pd.dot(v2);
- if (d1<d0 || d1>d2) {
+ if (d1 < d0 || d1 > d2) {
return false;
}
- Vector3 s[2]={ v0, v2 };
- real_t d =Geometry::get_closest_point_to_segment(v1,s).distance_to(v1);
+ Vector3 s[2] = { v0, v2 };
+ real_t d = Geometry::get_closest_point_to_segment(v1, s).distance_to(v1);
- if (d>pd.length()*p_alowed_linear_err) {
+ if (d > pd.length() * p_alowed_linear_err) {
return false; //beyond allowed error for colinearity
}
- if (p_norm!=Vector3() && Math::acos(pd.normalized().dot(p_norm))>p_alowed_angular_err)
+ if (p_norm != Vector3() && Math::acos(pd.normalized().dot(p_norm)) > p_alowed_angular_err)
return false;
- t[0] = (d1-d0)/(d2-d0);
+ t[0] = (d1 - d0) / (d2 - d0);
}
}
{ //rotation
- const Quat &q0=t0.value.rot;
- const Quat &q1=t1.value.rot;
- const Quat &q2=t2.value.rot;
+ const Quat &q0 = t0.value.rot;
+ const Quat &q1 = t1.value.rot;
+ const Quat &q2 = t2.value.rot;
//localize both to rotation from q0
- if ((q0-q2).length() < CMP_EPSILON) {
+ if ((q0 - q2).length() < CMP_EPSILON) {
- if ((q0-q1).length() > CMP_EPSILON)
+ if ((q0 - q1).length() > CMP_EPSILON)
return false;
} else {
-
Quat r02 = (q0.inverse() * q2).normalized();
Quat r01 = (q0.inverse() * q1).normalized();
- Vector3 v02,v01;
- real_t a02,a01;
+ Vector3 v02, v01;
+ real_t a02, a01;
- r02.get_axis_and_angle(v02,a02);
- r01.get_axis_and_angle(v01,a01);
+ r02.get_axis_and_angle(v02, a02);
+ r01.get_axis_and_angle(v01, a01);
- if (Math::abs(a02)>p_max_optimizable_angle)
+ if (Math::abs(a02) > p_max_optimizable_angle)
return false;
- if (v01.dot(v02)<0) {
+ if (v01.dot(v02) < 0) {
//make sure both rotations go the same way to compare
- v02=-v02;
- a02=-a02;
+ v02 = -v02;
+ a02 = -a02;
}
- real_t err_01 = Math::acos(v01.normalized().dot(v02.normalized()))/Math_PI;
- if (err_01>p_alowed_angular_err) {
+ real_t err_01 = Math::acos(v01.normalized().dot(v02.normalized())) / Math_PI;
+ if (err_01 > p_alowed_angular_err) {
//not rotating in the same axis
return false;
}
- if (a01*a02 < 0 ) {
+ if (a01 * a02 < 0) {
//not rotating in the same direction
return false;
}
- real_t tr = a01/a02;
- if (tr<0 || tr>1)
+ real_t tr = a01 / a02;
+ if (tr < 0 || tr > 1)
return false; //rotating too much or too less
- t[1]=tr;
-
+ t[1] = tr;
}
-
}
{ //scale
- const Vector3 &v0=t0.value.scale;
- const Vector3 &v1=t1.value.scale;
- const Vector3 &v2=t2.value.scale;
+ const Vector3 &v0 = t0.value.scale;
+ const Vector3 &v1 = t1.value.scale;
+ const Vector3 &v2 = t2.value.scale;
- if (v0.distance_to(v2)<CMP_EPSILON) {
+ if (v0.distance_to(v2) < CMP_EPSILON) {
//0 and 2 are close, let's see if 1 is close
- if (v0.distance_to(v1)>CMP_EPSILON) {
+ if (v0.distance_to(v1) > CMP_EPSILON) {
//not close, not optimizable
return false;
}
} else {
- Vector3 pd = (v2-v0);
+ Vector3 pd = (v2 - v0);
float d0 = pd.dot(v0);
float d1 = pd.dot(v1);
float d2 = pd.dot(v2);
- if (d1<d0 || d1>d2) {
+ if (d1 < d0 || d1 > d2) {
return false; //beyond segment range
}
- Vector3 s[2]={ v0, v2 };
- real_t d =Geometry::get_closest_point_to_segment(v1,s).distance_to(v1);
+ Vector3 s[2] = { v0, v2 };
+ real_t d = Geometry::get_closest_point_to_segment(v1, s).distance_to(v1);
- if (d>pd.length()*p_alowed_linear_err) {
+ if (d > pd.length() * p_alowed_linear_err) {
return false; //beyond allowed error for colinearity
}
- t[2] = (d1-d0)/(d2-d0);
+ t[2] = (d1 - d0) / (d2 - d0);
}
}
- bool erase=false;
- if (t[0]==-1 && t[1]==-1 && t[2]==-1) {
+ bool erase = false;
+ if (t[0] == -1 && t[1] == -1 && t[2] == -1) {
- erase=true;
+ erase = true;
} else {
- erase=true;
- real_t lt=-1;
- for(int j=0;j<3;j++) {
+ erase = true;
+ real_t lt = -1;
+ for (int j = 0; j < 3; j++) {
//search for t on first, one must be it
- if (t[j]!=-1) {
- lt=t[j]; //official t
+ if (t[j] != -1) {
+ lt = t[j]; //official t
//validate rest
- for(int k=j+1;k<3;k++) {
- if (t[k]==-1)
+ for (int k = j + 1; k < 3; k++) {
+ if (t[k] == -1)
continue;
- if (Math::abs(lt-t[k])>p_alowed_linear_err) {
- erase=false;
+ if (Math::abs(lt - t[k]) > p_alowed_linear_err) {
+ erase = false;
break;
}
}
@@ -1919,107 +1831,89 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0,const
}
}
- ERR_FAIL_COND_V( lt==-1,false );
+ ERR_FAIL_COND_V(lt == -1, false);
if (erase) {
- if (Math::abs(lt-c)>p_alowed_linear_err) {
+ if (Math::abs(lt - c) > p_alowed_linear_err) {
//todo, evaluate changing the transition if this fails?
//this could be done as a second pass and would be
//able to optimize more
- erase=false;
+ erase = false;
} else {
//print_line(itos(i)+"because of interp");
}
}
-
}
-
return erase;
-
-
}
+void Animation::_transform_track_optimize(int p_idx, float p_alowed_linear_err, float p_alowed_angular_err, float p_max_optimizable_angle) {
-void Animation::_transform_track_optimize(int p_idx,float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle) {
-
- ERR_FAIL_INDEX(p_idx,tracks.size());
- ERR_FAIL_COND(tracks[p_idx]->type!=TYPE_TRANSFORM);
- TransformTrack *tt= static_cast<TransformTrack*>(tracks[p_idx]);
- bool prev_erased=false;
+ ERR_FAIL_INDEX(p_idx, tracks.size());
+ ERR_FAIL_COND(tracks[p_idx]->type != TYPE_TRANSFORM);
+ TransformTrack *tt = static_cast<TransformTrack *>(tracks[p_idx]);
+ bool prev_erased = false;
TKey<TransformKey> first_erased;
Vector3 norm;
- for(int i=1;i<tt->transforms.size()-1;i++) {
+ for (int i = 1; i < tt->transforms.size() - 1; i++) {
- TKey<TransformKey> &t0 = tt->transforms[i-1];
+ TKey<TransformKey> &t0 = tt->transforms[i - 1];
TKey<TransformKey> &t1 = tt->transforms[i];
- TKey<TransformKey> &t2 = tt->transforms[i+1];
+ TKey<TransformKey> &t2 = tt->transforms[i + 1];
- bool erase = _transform_track_optimize_key(t0,t1,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle,norm);
+ bool erase = _transform_track_optimize_key(t0, t1, t2, p_alowed_linear_err, p_alowed_angular_err, p_max_optimizable_angle, norm);
if (erase && !prev_erased) {
- norm=(t2.value.loc-t1.value.loc).normalized();
+ norm = (t2.value.loc - t1.value.loc).normalized();
}
-
- if (prev_erased && !_transform_track_optimize_key(t0,first_erased,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle,norm)) {
- //avoid error to go beyond first erased key
- erase=false;
+ if (prev_erased && !_transform_track_optimize_key(t0, first_erased, t2, p_alowed_linear_err, p_alowed_angular_err, p_max_optimizable_angle, norm)) {
+ //avoid error to go beyond first erased key
+ erase = false;
}
-
if (erase) {
if (!prev_erased) {
- first_erased=t1;
- prev_erased=true;
+ first_erased = t1;
+ prev_erased = true;
}
tt->transforms.remove(i);
i--;
} else {
- prev_erased=false;
- norm=Vector3();
+ prev_erased = false;
+ norm = Vector3();
}
-
-
// print_line(itos(i)+" could be eliminated: "+rtos(tr));
//}
}
-
-
}
-void Animation::optimize(float p_allowed_linear_err,float p_allowed_angular_err,float p_angle_max) {
+void Animation::optimize(float p_allowed_linear_err, float p_allowed_angular_err, float p_angle_max) {
- for(int i=0;i<tracks.size();i++) {
-
- if (tracks[i]->type==TYPE_TRANSFORM)
- _transform_track_optimize(i,p_allowed_linear_err,p_allowed_angular_err,p_angle_max);
+ for (int i = 0; i < tracks.size(); i++) {
+ if (tracks[i]->type == TYPE_TRANSFORM)
+ _transform_track_optimize(i, p_allowed_linear_err, p_allowed_angular_err, p_angle_max);
}
-
}
-
Animation::Animation() {
- step=0.1;
- loop=false;
- length=1;
+ step = 0.1;
+ loop = false;
+ length = 1;
}
-
Animation::~Animation() {
- for(int i=0;i<tracks.size();i++)
- memdelete( tracks[i] );
-
+ for (int i = 0; i < tracks.size(); i++)
+ memdelete(tracks[i]);
}
-
-
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index 6f39d069f..7fb742f84 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -35,10 +35,10 @@
*/
class Animation : public Resource {
- OBJ_TYPE( Animation, Resource );
+ OBJ_TYPE(Animation, Resource);
RES_BASE_EXTENSION("anm");
-public:
+public:
enum LoopMode {
LOOP_NONE,
@@ -66,14 +66,16 @@ public:
};
private:
-
struct Track {
TrackType type;
InterpolationType interpolation;
NodePath path; // path to something
bool imported;
- Track() { interpolation=INTERPOLATION_LINEAR; imported=false;}
+ Track() {
+ interpolation = INTERPOLATION_LINEAR;
+ imported = false;
+ }
virtual ~Track() {}
};
@@ -81,18 +83,17 @@ private:
float transition;
float time; // time in secs
- Key() { transition=1; }
+ Key() { transition = 1; }
};
// transform key holds either Vector3 or Quaternion
- template<class T>
+ template <class T>
struct TKey : public Key {
float time;
T value;
};
-
struct TransformKey {
Vector3 loc;
@@ -104,9 +105,9 @@ private:
struct TransformTrack : public Track {
- Vector< TKey<TransformKey> > transforms;
+ Vector<TKey<TransformKey> > transforms;
- TransformTrack() { type=TYPE_TRANSFORM; }
+ TransformTrack() { type = TYPE_TRANSFORM; }
};
/* PROPERTY VALUE TRACK */
@@ -115,12 +116,14 @@ private:
UpdateMode update_mode;
bool update_on_seek;
- Vector< TKey<Variant> > values;
+ Vector<TKey<Variant> > values;
- ValueTrack() { type=TYPE_VALUE; update_mode=UPDATE_CONTINUOUS; }
+ ValueTrack() {
+ type = TYPE_VALUE;
+ update_mode = UPDATE_CONTINUOUS;
+ }
};
-
/* METHOD TRACK */
struct MethodKey : public Key {
@@ -131,56 +134,55 @@ private:
struct MethodTrack : public Track {
- Vector< MethodKey > methods;
- MethodTrack() { type=TYPE_METHOD; }
+ Vector<MethodKey> methods;
+ MethodTrack() { type = TYPE_METHOD; }
};
- Vector<Track*> tracks;
+ Vector<Track *> tracks;
/*
template<class T>
int _insert_pos(float p_time, T& p_keys);*/
- template<class T>
- void _clear(T& p_keys);
+ template <class T>
+ void _clear(T &p_keys);
- template<class T, class V>
- int _insert(float p_time, T& p_keys, const V& p_value);
+ template <class T, class V>
+ int _insert(float p_time, T &p_keys, const V &p_value);
- template<class K>
- inline int _find( const Vector<K>& p_keys, float p_time) const;
+ template <class K>
+ inline int _find(const Vector<K> &p_keys, float p_time) const;
- _FORCE_INLINE_ Animation::TransformKey _interpolate( const Animation::TransformKey& p_a, const Animation::TransformKey& p_b, float p_c) const;
+ _FORCE_INLINE_ Animation::TransformKey _interpolate(const Animation::TransformKey &p_a, const Animation::TransformKey &p_b, float p_c) const;
- _FORCE_INLINE_ Vector3 _interpolate( const Vector3& p_a, const Vector3& p_b, float p_c) const;
- _FORCE_INLINE_ Quat _interpolate( const Quat& p_a, const Quat& p_b, float p_c) const;
- _FORCE_INLINE_ Variant _interpolate( const Variant& p_a, const Variant& p_b, float p_c) const;
- _FORCE_INLINE_ float _interpolate( const float& p_a, const float& p_b, float p_c) const;
+ _FORCE_INLINE_ Vector3 _interpolate(const Vector3 &p_a, const Vector3 &p_b, float p_c) const;
+ _FORCE_INLINE_ Quat _interpolate(const Quat &p_a, const Quat &p_b, float p_c) const;
+ _FORCE_INLINE_ Variant _interpolate(const Variant &p_a, const Variant &p_b, float p_c) const;
+ _FORCE_INLINE_ float _interpolate(const float &p_a, const float &p_b, float p_c) const;
- _FORCE_INLINE_ Animation::TransformKey _cubic_interpolate( const Animation::TransformKey& p_pre_a, const Animation::TransformKey& p_a, const Animation::TransformKey& p_b, const Animation::TransformKey& p_post_b,float p_c) const;
- _FORCE_INLINE_ Vector3 _cubic_interpolate( const Vector3& p_pre_a,const Vector3& p_a, const Vector3& p_b,const Vector3& p_post_b, float p_c) const;
- _FORCE_INLINE_ Quat _cubic_interpolate( const Quat& p_pre_a,const Quat& p_a, const Quat& p_b,const Quat& p_post_b, float p_c) const;
- _FORCE_INLINE_ Variant _cubic_interpolate( const Variant& p_pre_a,const Variant& p_a, const Variant& p_b, const Variant& p_post_b,float p_c) const;
- _FORCE_INLINE_ float _cubic_interpolate( const float& p_pre_a,const float& p_a, const float& p_b, const float& p_post_b, float p_c) const;
+ _FORCE_INLINE_ Animation::TransformKey _cubic_interpolate(const Animation::TransformKey &p_pre_a, const Animation::TransformKey &p_a, const Animation::TransformKey &p_b, const Animation::TransformKey &p_post_b, float p_c) const;
+ _FORCE_INLINE_ Vector3 _cubic_interpolate(const Vector3 &p_pre_a, const Vector3 &p_a, const Vector3 &p_b, const Vector3 &p_post_b, float p_c) const;
+ _FORCE_INLINE_ Quat _cubic_interpolate(const Quat &p_pre_a, const Quat &p_a, const Quat &p_b, const Quat &p_post_b, float p_c) const;
+ _FORCE_INLINE_ Variant _cubic_interpolate(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, float p_c) const;
+ _FORCE_INLINE_ float _cubic_interpolate(const float &p_pre_a, const float &p_a, const float &p_b, const float &p_post_b, float p_c) const;
- template<class T>
- _FORCE_INLINE_ T _interpolate( const Vector< TKey<T> >& p_keys, float p_time, InterpolationType p_interp,bool *p_ok) const;
+ template <class T>
+ _FORCE_INLINE_ T _interpolate(const Vector<TKey<T> > &p_keys, float p_time, InterpolationType p_interp, bool *p_ok) const;
- _FORCE_INLINE_ void _value_track_get_key_indices_in_range(const ValueTrack * vt, float from_time, float to_time,List<int> *p_indices) const;
- _FORCE_INLINE_ void _method_track_get_key_indices_in_range(const MethodTrack * mt, float from_time, float to_time,List<int> *p_indices) const;
+ _FORCE_INLINE_ void _value_track_get_key_indices_in_range(const ValueTrack *vt, float from_time, float to_time, List<int> *p_indices) const;
+ _FORCE_INLINE_ void _method_track_get_key_indices_in_range(const MethodTrack *mt, float from_time, float to_time, List<int> *p_indices) const;
float length;
float step;
bool loop;
-// bind helpers
+ // bind helpers
private:
-
Array _transform_track_interpolate(int p_track, float p_time) const {
Vector3 loc;
Quat rot;
Vector3 scale;
- transform_track_interpolate(p_track,p_time,&loc,&rot,&scale);
+ transform_track_interpolate(p_track, p_time, &loc, &rot, &scale);
Array ret;
ret.push_back(loc);
ret.push_back(rot);
@@ -191,10 +193,10 @@ private:
DVector<int> _value_track_get_key_indices(int p_track, float p_time, float p_delta) const {
List<int> idxs;
- value_track_get_key_indices(p_track,p_time,p_delta,&idxs);
+ value_track_get_key_indices(p_track, p_time, p_delta, &idxs);
DVector<int> idxr;
- for (List<int>::Element *E=idxs.front();E;E=E->next()) {
+ for (List<int>::Element *E = idxs.front(); E; E = E->next()) {
idxr.push_back(E->get());
}
@@ -203,52 +205,49 @@ private:
DVector<int> _method_track_get_key_indices(int p_track, float p_time, float p_delta) const {
List<int> idxs;
- method_track_get_key_indices(p_track,p_time,p_delta,&idxs);
+ method_track_get_key_indices(p_track, p_time, p_delta, &idxs);
DVector<int> idxr;
- for (List<int>::Element *E=idxs.front();E;E=E->next()) {
+ for (List<int>::Element *E = idxs.front(); E; E = E->next()) {
idxr.push_back(E->get());
}
return idxr;
}
- bool _transform_track_optimize_key(const TKey<TransformKey> &t0,const TKey<TransformKey> &t1, const TKey<TransformKey> &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle,const Vector3& p_norm);
- void _transform_track_optimize(int p_idx, float p_allowed_err=0.05, float p_alowed_angular_err=0.01,float p_max_optimizable_angle=Math_PI*0.125);
+ bool _transform_track_optimize_key(const TKey<TransformKey> &t0, const TKey<TransformKey> &t1, const TKey<TransformKey> &t2, float p_alowed_linear_err, float p_alowed_angular_err, float p_max_optimizable_angle, const Vector3 &p_norm);
+ void _transform_track_optimize(int p_idx, float p_allowed_err = 0.05, float p_alowed_angular_err = 0.01, float p_max_optimizable_angle = Math_PI * 0.125);
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
- int add_track(TrackType p_type,int p_at_pos=-1);
+ int add_track(TrackType p_type, int p_at_pos = -1);
void remove_track(int p_track);
int get_track_count() const;
TrackType track_get_type(int p_track) const;
- void track_set_path(int p_track,const NodePath& p_path);
+ void track_set_path(int p_track, const NodePath &p_path);
NodePath track_get_path(int p_track) const;
- int find_track(const NodePath& p_path) const;
+ int find_track(const NodePath &p_path) const;
// transform
-
void track_move_up(int p_track);
void track_move_down(int p_track);
- void track_set_imported(int p_track,bool p_imported);
+ void track_set_imported(int p_track, bool p_imported);
bool track_is_imported(int p_track) const;
- int transform_track_insert_key(int p_track, float p_time, const Vector3 p_loc, const Quat& p_rot=Quat(), const Vector3& p_scale=Vector3());
- void track_insert_key(int p_track, float p_time, const Variant& p_key, float p_transition=1);
- void track_set_key_transition(int p_track, int p_key_idx,float p_transition);
- void track_set_key_value(int p_track, int p_key_idx,const Variant& p_value);
- int track_find_key(int p_track, float p_time, bool p_exact=false) const;
+ int transform_track_insert_key(int p_track, float p_time, const Vector3 p_loc, const Quat &p_rot = Quat(), const Vector3 &p_scale = Vector3());
+ void track_insert_key(int p_track, float p_time, const Variant &p_key, float p_transition = 1);
+ void track_set_key_transition(int p_track, int p_key_idx, float p_transition);
+ void track_set_key_value(int p_track, int p_key_idx, const Variant &p_value);
+ int track_find_key(int p_track, float p_time, bool p_exact = false) const;
void track_remove_key(int p_track, int p_idx);
void track_remove_key_at_pos(int p_track, float p_pos);
int track_get_key_count(int p_track) const;
@@ -256,23 +255,20 @@ public:
float track_get_key_time(int p_track, int p_key_idx) const;
float track_get_key_transition(int p_track, int p_key_idx) const;
- Error transform_track_get_key(int p_track, int p_key, Vector3* r_loc, Quat* r_rot, Vector3* r_scale) const;
- void track_set_interpolation_type(int p_track,InterpolationType p_interp);
+ Error transform_track_get_key(int p_track, int p_key, Vector3 *r_loc, Quat *r_rot, Vector3 *r_scale) const;
+ void track_set_interpolation_type(int p_track, InterpolationType p_interp);
InterpolationType track_get_interpolation_type(int p_track) const;
-
- Error transform_track_interpolate(int p_track, float p_time, Vector3 * r_loc, Quat *r_rot, Vector3 *r_scale) const;
+ Error transform_track_interpolate(int p_track, float p_time, Vector3 *r_loc, Quat *r_rot, Vector3 *r_scale) const;
Variant value_track_interpolate(int p_track, float p_time) const;
- void value_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const;
+ void value_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const;
void value_track_set_update_mode(int p_track, UpdateMode p_mode);
UpdateMode value_track_get_update_mode(int p_track) const;
-
- void method_track_get_key_indices(int p_track, float p_time, float p_delta,List<int> *p_indices) const;
- Vector<Variant> method_track_get_params(int p_track,int p_key_idx) const;
- StringName method_track_get_name(int p_track,int p_key_idx) const;
-
+ void method_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const;
+ Vector<Variant> method_track_get_params(int p_track, int p_key_idx) const;
+ StringName method_track_get_name(int p_track, int p_key_idx) const;
void set_length(float p_length);
float get_length() const;
@@ -285,17 +281,14 @@ public:
void clear();
- void optimize(float p_allowed_linear_err=0.05,float p_allowed_angular_err=0.01,float p_max_optimizable_angle=Math_PI*0.125);
+ void optimize(float p_allowed_linear_err = 0.05, float p_allowed_angular_err = 0.01, float p_max_optimizable_angle = Math_PI * 0.125);
Animation();
~Animation();
-
};
-VARIANT_ENUM_CAST( Animation::TrackType );
-VARIANT_ENUM_CAST( Animation::InterpolationType );
-VARIANT_ENUM_CAST( Animation::UpdateMode );
-
-
+VARIANT_ENUM_CAST(Animation::TrackType);
+VARIANT_ENUM_CAST(Animation::InterpolationType);
+VARIANT_ENUM_CAST(Animation::UpdateMode);
#endif
diff --git a/scene/resources/audio_stream.cpp b/scene/resources/audio_stream.cpp
index f6dc99b8a..5852dc3b2 100644
--- a/scene/resources/audio_stream.cpp
+++ b/scene/resources/audio_stream.cpp
@@ -30,32 +30,25 @@
//////////////////////////////
-
void AudioStreamPlayback::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("play","from_pos_sec"),&AudioStreamPlayback::play,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("stop"),&AudioStreamPlayback::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&AudioStreamPlayback::is_playing);
-
- ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&AudioStreamPlayback::set_loop);
- ObjectTypeDB::bind_method(_MD("has_loop"),&AudioStreamPlayback::has_loop);
+ ObjectTypeDB::bind_method(_MD("play", "from_pos_sec"), &AudioStreamPlayback::play, DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("stop"), &AudioStreamPlayback::stop);
+ ObjectTypeDB::bind_method(_MD("is_playing"), &AudioStreamPlayback::is_playing);
- ObjectTypeDB::bind_method(_MD("get_loop_count"),&AudioStreamPlayback::get_loop_count);
+ ObjectTypeDB::bind_method(_MD("set_loop", "enabled"), &AudioStreamPlayback::set_loop);
+ ObjectTypeDB::bind_method(_MD("has_loop"), &AudioStreamPlayback::has_loop);
- ObjectTypeDB::bind_method(_MD("seek_pos","pos"),&AudioStreamPlayback::seek_pos);
- ObjectTypeDB::bind_method(_MD("get_pos"),&AudioStreamPlayback::get_pos);
-
- ObjectTypeDB::bind_method(_MD("get_length"),&AudioStreamPlayback::get_length);
- ObjectTypeDB::bind_method(_MD("get_channels"),&AudioStreamPlayback::get_channels);
- ObjectTypeDB::bind_method(_MD("get_mix_rate"),&AudioStreamPlayback::get_mix_rate);
- ObjectTypeDB::bind_method(_MD("get_minimum_buffer_size"),&AudioStreamPlayback::get_minimum_buffer_size);
+ ObjectTypeDB::bind_method(_MD("get_loop_count"), &AudioStreamPlayback::get_loop_count);
+ ObjectTypeDB::bind_method(_MD("seek_pos", "pos"), &AudioStreamPlayback::seek_pos);
+ ObjectTypeDB::bind_method(_MD("get_pos"), &AudioStreamPlayback::get_pos);
+ ObjectTypeDB::bind_method(_MD("get_length"), &AudioStreamPlayback::get_length);
+ ObjectTypeDB::bind_method(_MD("get_channels"), &AudioStreamPlayback::get_channels);
+ ObjectTypeDB::bind_method(_MD("get_mix_rate"), &AudioStreamPlayback::get_mix_rate);
+ ObjectTypeDB::bind_method(_MD("get_minimum_buffer_size"), &AudioStreamPlayback::get_minimum_buffer_size);
}
-
void AudioStream::_bind_methods() {
-
-
}
-
diff --git a/scene/resources/audio_stream.h b/scene/resources/audio_stream.h
index 2039c4e90..963ec0d7e 100644
--- a/scene/resources/audio_stream.h
+++ b/scene/resources/audio_stream.h
@@ -34,50 +34,46 @@
class AudioStreamPlayback : public Reference {
- OBJ_TYPE( AudioStreamPlayback, Reference );
+ OBJ_TYPE(AudioStreamPlayback, Reference);
+
protected:
static void _bind_methods();
-public:
-
- virtual void play(float p_from_pos=0)=0;
- virtual void stop()=0;
- virtual bool is_playing() const=0;
-
- virtual void set_loop(bool p_enable)=0;
- virtual bool has_loop() const=0;
+public:
+ virtual void play(float p_from_pos = 0) = 0;
+ virtual void stop() = 0;
+ virtual bool is_playing() const = 0;
- virtual void set_loop_restart_time(float p_time)=0;
+ virtual void set_loop(bool p_enable) = 0;
+ virtual bool has_loop() const = 0;
- virtual int get_loop_count() const=0;
+ virtual void set_loop_restart_time(float p_time) = 0;
- virtual float get_pos() const=0;
- virtual void seek_pos(float p_time)=0;
+ virtual int get_loop_count() const = 0;
- virtual int mix(int16_t* p_bufer,int p_frames)=0;
+ virtual float get_pos() const = 0;
+ virtual void seek_pos(float p_time) = 0;
- virtual float get_length() const=0;
- virtual String get_stream_name() const=0;
+ virtual int mix(int16_t *p_bufer, int p_frames) = 0;
- virtual int get_channels() const=0;
- virtual int get_mix_rate() const=0;
- virtual int get_minimum_buffer_size() const=0;
+ virtual float get_length() const = 0;
+ virtual String get_stream_name() const = 0;
+ virtual int get_channels() const = 0;
+ virtual int get_mix_rate() const = 0;
+ virtual int get_minimum_buffer_size() const = 0;
};
class AudioStream : public Resource {
- OBJ_TYPE( AudioStream, Resource );
- OBJ_SAVE_TYPE( AudioStream ); //children are all saved as AudioStream, so they can be exchanged
+ OBJ_TYPE(AudioStream, Resource);
+ OBJ_SAVE_TYPE(AudioStream); //children are all saved as AudioStream, so they can be exchanged
protected:
static void _bind_methods();
-public:
-
- virtual Ref<AudioStreamPlayback> instance_playback()=0;
-
+public:
+ virtual Ref<AudioStreamPlayback> instance_playback() = 0;
};
-
#endif // AUDIO_STREAM_H
diff --git a/scene/resources/audio_stream_resampled.cpp b/scene/resources/audio_stream_resampled.cpp
index 7b49ec084..ba5f2429a 100644
--- a/scene/resources/audio_stream_resampled.cpp
+++ b/scene/resources/audio_stream_resampled.cpp
@@ -29,7 +29,6 @@
#include "audio_stream_resampled.h"
#include "globals.h"
-
#if 0
int AudioStreamResampled::get_channel_count() const {
diff --git a/scene/resources/baked_light.cpp b/scene/resources/baked_light.cpp
index bcfcbb217..b23e4636f 100644
--- a/scene/resources/baked_light.cpp
+++ b/scene/resources/baked_light.cpp
@@ -31,19 +31,18 @@
void BakedLight::set_mode(Mode p_mode) {
- mode=p_mode;
- VS::get_singleton()->baked_light_set_mode(baked_light,(VS::BakedLightMode(p_mode)));
-
+ mode = p_mode;
+ VS::get_singleton()->baked_light_set_mode(baked_light, (VS::BakedLightMode(p_mode)));
}
-BakedLight::Mode BakedLight::get_mode() const{
+BakedLight::Mode BakedLight::get_mode() const {
return mode;
}
-void BakedLight::set_octree(const DVector<uint8_t>& p_octree) {
+void BakedLight::set_octree(const DVector<uint8_t> &p_octree) {
- VS::get_singleton()->baked_light_set_octree(baked_light,p_octree);
+ VS::get_singleton()->baked_light_set_octree(baked_light, p_octree);
}
DVector<uint8_t> BakedLight::get_octree() const {
@@ -51,9 +50,9 @@ DVector<uint8_t> BakedLight::get_octree() const {
return VS::get_singleton()->baked_light_get_octree(baked_light);
}
-void BakedLight::set_light(const DVector<uint8_t>& p_light) {
+void BakedLight::set_light(const DVector<uint8_t> &p_light) {
- VS::get_singleton()->baked_light_set_light(baked_light,p_light);
+ VS::get_singleton()->baked_light_set_light(baked_light, p_light);
}
DVector<uint8_t> BakedLight::get_light() const {
@@ -61,10 +60,9 @@ DVector<uint8_t> BakedLight::get_light() const {
return VS::get_singleton()->baked_light_get_light(baked_light);
}
+void BakedLight::set_sampler_octree(const DVector<int> &p_sampler_octree) {
-void BakedLight::set_sampler_octree(const DVector<int>& p_sampler_octree) {
-
- VS::get_singleton()->baked_light_set_sampler_octree(baked_light,p_sampler_octree);
+ VS::get_singleton()->baked_light_set_sampler_octree(baked_light, p_sampler_octree);
}
DVector<int> BakedLight::get_sampler_octree() const {
@@ -72,80 +70,68 @@ DVector<int> BakedLight::get_sampler_octree() const {
return VS::get_singleton()->baked_light_get_sampler_octree(baked_light);
}
-
-
-
-
-void BakedLight::add_lightmap(const Ref<Texture> &p_texture,Size2 p_gen_size) {
+void BakedLight::add_lightmap(const Ref<Texture> &p_texture, Size2 p_gen_size) {
LightMap lm;
- lm.texture=p_texture;
- lm.gen_size=p_gen_size;
+ lm.texture = p_texture;
+ lm.gen_size = p_gen_size;
lightmaps.push_back(lm);
_update_lightmaps();
_change_notify();
}
-void BakedLight::set_lightmap_gen_size(int p_idx,const Size2& p_size){
+void BakedLight::set_lightmap_gen_size(int p_idx, const Size2 &p_size) {
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
- lightmaps[p_idx].gen_size=p_size;
+ ERR_FAIL_INDEX(p_idx, lightmaps.size());
+ lightmaps[p_idx].gen_size = p_size;
_update_lightmaps();
}
-Size2 BakedLight::get_lightmap_gen_size(int p_idx) const{
+Size2 BakedLight::get_lightmap_gen_size(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,lightmaps.size(),Size2());
+ ERR_FAIL_INDEX_V(p_idx, lightmaps.size(), Size2());
return lightmaps[p_idx].gen_size;
-
}
-void BakedLight::set_lightmap_texture(int p_idx,const Ref<Texture> &p_texture){
+void BakedLight::set_lightmap_texture(int p_idx, const Ref<Texture> &p_texture) {
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
- lightmaps[p_idx].texture=p_texture;
+ ERR_FAIL_INDEX(p_idx, lightmaps.size());
+ lightmaps[p_idx].texture = p_texture;
_update_lightmaps();
-
}
-Ref<Texture> BakedLight::get_lightmap_texture(int p_idx) const{
+Ref<Texture> BakedLight::get_lightmap_texture(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,lightmaps.size(),Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_idx, lightmaps.size(), Ref<Texture>());
return lightmaps[p_idx].texture;
-
}
-void BakedLight::erase_lightmap(int p_idx){
+void BakedLight::erase_lightmap(int p_idx) {
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
+ ERR_FAIL_INDEX(p_idx, lightmaps.size());
lightmaps.remove(p_idx);
_update_lightmaps();
_change_notify();
-
}
-int BakedLight::get_lightmaps_count() const{
+int BakedLight::get_lightmaps_count() const {
return lightmaps.size();
}
-void BakedLight::clear_lightmaps(){
+void BakedLight::clear_lightmaps() {
lightmaps.clear();
_update_lightmaps();
_change_notify();
}
-
-
void BakedLight::_update_lightmaps() {
VS::get_singleton()->baked_light_clear_lightmaps(baked_light);
- for(int i=0;i<lightmaps.size();i++) {
+ for (int i = 0; i < lightmaps.size(); i++) {
RID tid;
if (lightmaps[i].texture.is_valid())
- tid=lightmaps[i].texture->get_rid();
- VS::get_singleton()->baked_light_add_lightmap(baked_light,tid,i);
+ tid = lightmaps[i].texture->get_rid();
+ VS::get_singleton()->baked_light_add_lightmap(baked_light, tid, i);
}
}
-
-
RID BakedLight::get_rid() const {
return baked_light;
@@ -154,74 +140,72 @@ RID BakedLight::get_rid() const {
Array BakedLight::_get_lightmap_data() const {
Array ret;
- ret.resize(lightmaps.size()*2);
+ ret.resize(lightmaps.size() * 2);
- int idx=0;
- for(int i=0;i<lightmaps.size();i++) {
+ int idx = 0;
+ for (int i = 0; i < lightmaps.size(); i++) {
- ret[idx++]=Size2(lightmaps[i].gen_size);
- ret[idx++]=lightmaps[i].texture;
+ ret[idx++] = Size2(lightmaps[i].gen_size);
+ ret[idx++] = lightmaps[i].texture;
}
return ret;
-
}
-void BakedLight::_set_lightmap_data(Array p_array){
+void BakedLight::_set_lightmap_data(Array p_array) {
lightmaps.clear();
- for(int i=0;i<p_array.size();i+=2) {
+ for (int i = 0; i < p_array.size(); i += 2) {
Size2 size = p_array[i];
- Ref<Texture> tex = p_array[i+1];
-// ERR_CONTINUE(tex.is_null());
+ Ref<Texture> tex = p_array[i + 1];
+ // ERR_CONTINUE(tex.is_null());
LightMap lm;
- lm.gen_size=size;
- lm.texture=tex;
+ lm.gen_size = size;
+ lm.texture = tex;
lightmaps.push_back(lm);
}
_update_lightmaps();
}
-
void BakedLight::set_cell_subdivision(int p_subdiv) {
- cell_subdiv=p_subdiv;
+ cell_subdiv = p_subdiv;
}
-int BakedLight::get_cell_subdivision() const{
+int BakedLight::get_cell_subdivision() const {
return cell_subdiv;
}
-void BakedLight::set_initial_lattice_subdiv(int p_size){
+void BakedLight::set_initial_lattice_subdiv(int p_size) {
- lattice_subdiv=p_size;
+ lattice_subdiv = p_size;
}
-int BakedLight::get_initial_lattice_subdiv() const{
+int BakedLight::get_initial_lattice_subdiv() const {
return lattice_subdiv;
}
-void BakedLight::set_plot_size(float p_size){
+void BakedLight::set_plot_size(float p_size) {
- plot_size=p_size;
+ plot_size = p_size;
}
-float BakedLight::get_plot_size() const{
+float BakedLight::get_plot_size() const {
return plot_size;
}
-void BakedLight::set_bounces(int p_size){
+void BakedLight::set_bounces(int p_size) {
- bounces=p_size;
+ bounces = p_size;
}
-int BakedLight::get_bounces() const{
+int BakedLight::get_bounces() const {
return bounces;
}
void BakedLight::set_cell_extra_margin(float p_margin) {
- cell_extra_margin=p_margin;
+ cell_extra_margin = p_margin;
}
float BakedLight::get_cell_extra_margin() const {
@@ -230,7 +214,7 @@ float BakedLight::get_cell_extra_margin() const {
}
void BakedLight::set_edge_damp(float p_margin) {
- edge_damp=p_margin;
+ edge_damp = p_margin;
}
float BakedLight::get_edge_damp() const {
@@ -238,9 +222,8 @@ float BakedLight::get_edge_damp() const {
return edge_damp;
}
-
void BakedLight::set_normal_damp(float p_margin) {
- normal_damp=p_margin;
+ normal_damp = p_margin;
}
float BakedLight::get_normal_damp() const {
@@ -249,7 +232,7 @@ float BakedLight::get_normal_damp() const {
}
void BakedLight::set_tint(float p_margin) {
- tint=p_margin;
+ tint = p_margin;
}
float BakedLight::get_tint() const {
@@ -258,7 +241,7 @@ float BakedLight::get_tint() const {
}
void BakedLight::set_saturation(float p_margin) {
- saturation=p_margin;
+ saturation = p_margin;
}
float BakedLight::get_saturation() const {
@@ -267,7 +250,7 @@ float BakedLight::get_saturation() const {
}
void BakedLight::set_ao_radius(float p_ao_radius) {
- ao_radius=p_ao_radius;
+ ao_radius = p_ao_radius;
}
float BakedLight::get_ao_radius() const {
@@ -276,7 +259,7 @@ float BakedLight::get_ao_radius() const {
void BakedLight::set_ao_strength(float p_ao_strength) {
- ao_strength=p_ao_strength;
+ ao_strength = p_ao_strength;
}
float BakedLight::get_ao_strength() const {
@@ -294,7 +277,6 @@ bool BakedLight::get_realtime_color_enabled() const {
return VS::get_singleton()->baked_light_get_realtime_color_enabled(baked_light);
}
-
void BakedLight::set_realtime_color(const Color &p_realtime_color) {
VS::get_singleton()->baked_light_set_realtime_color(baked_light, p_realtime_color);
@@ -315,184 +297,175 @@ float BakedLight::get_realtime_energy() const {
return VS::get_singleton()->baked_light_get_realtime_energy(baked_light);
}
+void BakedLight::set_energy_multiplier(float p_multiplier) {
-
-void BakedLight::set_energy_multiplier(float p_multiplier){
-
- energy_multiply=p_multiplier;
+ energy_multiply = p_multiplier;
}
-float BakedLight::get_energy_multiplier() const{
+float BakedLight::get_energy_multiplier() const {
return energy_multiply;
}
-void BakedLight::set_gamma_adjust(float p_adjust){
+void BakedLight::set_gamma_adjust(float p_adjust) {
- gamma_adjust=p_adjust;
+ gamma_adjust = p_adjust;
}
-float BakedLight::get_gamma_adjust() const{
+float BakedLight::get_gamma_adjust() const {
return gamma_adjust;
}
-void BakedLight::set_bake_flag(BakeFlags p_flags,bool p_enable){
+void BakedLight::set_bake_flag(BakeFlags p_flags, bool p_enable) {
- flags[p_flags]=p_enable;
+ flags[p_flags] = p_enable;
}
-bool BakedLight::get_bake_flag(BakeFlags p_flags) const{
+bool BakedLight::get_bake_flag(BakeFlags p_flags) const {
return flags[p_flags];
}
void BakedLight::set_format(Format p_format) {
- format=p_format;
- VS::get_singleton()->baked_light_set_lightmap_multiplier(baked_light,format==FORMAT_HDR8?8.0:1.0);
+ format = p_format;
+ VS::get_singleton()->baked_light_set_lightmap_multiplier(baked_light, format == FORMAT_HDR8 ? 8.0 : 1.0);
}
-BakedLight::Format BakedLight::get_format() const{
+BakedLight::Format BakedLight::get_format() const {
return format;
}
void BakedLight::set_transfer_lightmaps_only_to_uv2(bool p_enable) {
- transfer_only_uv2=p_enable;
+ transfer_only_uv2 = p_enable;
}
-bool BakedLight::get_transfer_lightmaps_only_to_uv2() const{
+bool BakedLight::get_transfer_lightmaps_only_to_uv2() const {
return transfer_only_uv2;
}
-
-bool BakedLight::_set(const StringName& p_name, const Variant& p_value) {
+bool BakedLight::_set(const StringName &p_name, const Variant &p_value) {
String n = p_name;
if (!n.begins_with("lightmap"))
return false;
- int idx = n.get_slicec('/',1).to_int();
- ERR_FAIL_COND_V(idx<0,false);
- ERR_FAIL_COND_V(idx>lightmaps.size(),false);
+ int idx = n.get_slicec('/', 1).to_int();
+ ERR_FAIL_COND_V(idx < 0, false);
+ ERR_FAIL_COND_V(idx > lightmaps.size(), false);
- String what = n.get_slicec('/',2);
+ String what = n.get_slicec('/', 2);
Ref<Texture> tex;
Size2 gens;
- if (what=="texture")
- tex=p_value;
- else if (what=="gen_size")
- gens=p_value;
+ if (what == "texture")
+ tex = p_value;
+ else if (what == "gen_size")
+ gens = p_value;
- if (idx==lightmaps.size()) {
- if (tex.is_valid() || gens!=Size2())
- add_lightmap(tex,gens);
+ if (idx == lightmaps.size()) {
+ if (tex.is_valid() || gens != Size2())
+ add_lightmap(tex, gens);
} else {
if (tex.is_valid())
- set_lightmap_texture(idx,tex);
- else if (gens!=Size2())
- set_lightmap_gen_size(idx,gens);
+ set_lightmap_texture(idx, tex);
+ else if (gens != Size2())
+ set_lightmap_gen_size(idx, gens);
}
-
return true;
}
-bool BakedLight::_get(const StringName& p_name,Variant &r_ret) const{
+bool BakedLight::_get(const StringName &p_name, Variant &r_ret) const {
String n = p_name;
if (!n.begins_with("lightmap"))
return false;
- int idx = n.get_slicec('/',1).to_int();
- ERR_FAIL_COND_V(idx<0,false);
- ERR_FAIL_COND_V(idx>lightmaps.size(),false);
+ int idx = n.get_slicec('/', 1).to_int();
+ ERR_FAIL_COND_V(idx < 0, false);
+ ERR_FAIL_COND_V(idx > lightmaps.size(), false);
- String what = n.get_slicec('/',2);
+ String what = n.get_slicec('/', 2);
- if (what=="texture") {
- if (idx==lightmaps.size())
- r_ret=Ref<Texture>();
+ if (what == "texture") {
+ if (idx == lightmaps.size())
+ r_ret = Ref<Texture>();
else
- r_ret=lightmaps[idx].texture;
+ r_ret = lightmaps[idx].texture;
- } else if (what=="gen_size") {
+ } else if (what == "gen_size") {
- if (idx==lightmaps.size())
- r_ret=Size2();
+ if (idx == lightmaps.size())
+ r_ret = Size2();
else
- r_ret=Size2(lightmaps[idx].gen_size);
+ r_ret = Size2(lightmaps[idx].gen_size);
} else
return false;
return true;
-
-
}
-void BakedLight::_get_property_list( List<PropertyInfo> *p_list) const{
+void BakedLight::_get_property_list(List<PropertyInfo> *p_list) const {
- for(int i=0;i<=lightmaps.size();i++) {
+ for (int i = 0; i <= lightmaps.size(); i++) {
- p_list->push_back(PropertyInfo(Variant::VECTOR2,"lightmaps/"+itos(i)+"/gen_size",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR));
- p_list->push_back(PropertyInfo(Variant::OBJECT,"lightmaps/"+itos(i)+"/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture",PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, "lightmaps/" + itos(i) + "/gen_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "lightmaps/" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_EDITOR));
}
}
+void BakedLight::_bind_methods() {
-void BakedLight::_bind_methods(){
-
-
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&BakedLight::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&BakedLight::get_mode);
-
- ObjectTypeDB::bind_method(_MD("set_octree","octree"),&BakedLight::set_octree);
- ObjectTypeDB::bind_method(_MD("get_octree"),&BakedLight::get_octree);
+ ObjectTypeDB::bind_method(_MD("set_mode", "mode"), &BakedLight::set_mode);
+ ObjectTypeDB::bind_method(_MD("get_mode"), &BakedLight::get_mode);
- ObjectTypeDB::bind_method(_MD("set_light","light"),&BakedLight::set_light);
- ObjectTypeDB::bind_method(_MD("get_light"),&BakedLight::get_light);
+ ObjectTypeDB::bind_method(_MD("set_octree", "octree"), &BakedLight::set_octree);
+ ObjectTypeDB::bind_method(_MD("get_octree"), &BakedLight::get_octree);
- ObjectTypeDB::bind_method(_MD("set_sampler_octree","sampler_octree"),&BakedLight::set_sampler_octree);
- ObjectTypeDB::bind_method(_MD("get_sampler_octree"),&BakedLight::get_sampler_octree);
+ ObjectTypeDB::bind_method(_MD("set_light", "light"), &BakedLight::set_light);
+ ObjectTypeDB::bind_method(_MD("get_light"), &BakedLight::get_light);
+ ObjectTypeDB::bind_method(_MD("set_sampler_octree", "sampler_octree"), &BakedLight::set_sampler_octree);
+ ObjectTypeDB::bind_method(_MD("get_sampler_octree"), &BakedLight::get_sampler_octree);
- ObjectTypeDB::bind_method(_MD("add_lightmap","texture:Texture","gen_size"),&BakedLight::add_lightmap);
- ObjectTypeDB::bind_method(_MD("erase_lightmap","id"),&BakedLight::erase_lightmap);
- ObjectTypeDB::bind_method(_MD("clear_lightmaps"),&BakedLight::clear_lightmaps);
+ ObjectTypeDB::bind_method(_MD("add_lightmap", "texture:Texture", "gen_size"), &BakedLight::add_lightmap);
+ ObjectTypeDB::bind_method(_MD("erase_lightmap", "id"), &BakedLight::erase_lightmap);
+ ObjectTypeDB::bind_method(_MD("clear_lightmaps"), &BakedLight::clear_lightmaps);
- ObjectTypeDB::bind_method(_MD("_set_lightmap_data","lightmap_data"),&BakedLight::_set_lightmap_data);
- ObjectTypeDB::bind_method(_MD("_get_lightmap_data"),&BakedLight::_get_lightmap_data);
+ ObjectTypeDB::bind_method(_MD("_set_lightmap_data", "lightmap_data"), &BakedLight::_set_lightmap_data);
+ ObjectTypeDB::bind_method(_MD("_get_lightmap_data"), &BakedLight::_get_lightmap_data);
- ObjectTypeDB::bind_method(_MD("set_cell_subdivision","cell_subdivision"),&BakedLight::set_cell_subdivision);
- ObjectTypeDB::bind_method(_MD("get_cell_subdivision"),&BakedLight::get_cell_subdivision);
+ ObjectTypeDB::bind_method(_MD("set_cell_subdivision", "cell_subdivision"), &BakedLight::set_cell_subdivision);
+ ObjectTypeDB::bind_method(_MD("get_cell_subdivision"), &BakedLight::get_cell_subdivision);
- ObjectTypeDB::bind_method(_MD("set_initial_lattice_subdiv","cell_subdivision"),&BakedLight::set_initial_lattice_subdiv);
- ObjectTypeDB::bind_method(_MD("get_initial_lattice_subdiv","cell_subdivision"),&BakedLight::get_initial_lattice_subdiv);
+ ObjectTypeDB::bind_method(_MD("set_initial_lattice_subdiv", "cell_subdivision"), &BakedLight::set_initial_lattice_subdiv);
+ ObjectTypeDB::bind_method(_MD("get_initial_lattice_subdiv", "cell_subdivision"), &BakedLight::get_initial_lattice_subdiv);
- ObjectTypeDB::bind_method(_MD("set_plot_size","plot_size"),&BakedLight::set_plot_size);
- ObjectTypeDB::bind_method(_MD("get_plot_size"),&BakedLight::get_plot_size);
+ ObjectTypeDB::bind_method(_MD("set_plot_size", "plot_size"), &BakedLight::set_plot_size);
+ ObjectTypeDB::bind_method(_MD("get_plot_size"), &BakedLight::get_plot_size);
- ObjectTypeDB::bind_method(_MD("set_bounces","bounces"),&BakedLight::set_bounces);
- ObjectTypeDB::bind_method(_MD("get_bounces"),&BakedLight::get_bounces);
+ ObjectTypeDB::bind_method(_MD("set_bounces", "bounces"), &BakedLight::set_bounces);
+ ObjectTypeDB::bind_method(_MD("get_bounces"), &BakedLight::get_bounces);
- ObjectTypeDB::bind_method(_MD("set_cell_extra_margin","cell_extra_margin"),&BakedLight::set_cell_extra_margin);
- ObjectTypeDB::bind_method(_MD("get_cell_extra_margin"),&BakedLight::get_cell_extra_margin);
+ ObjectTypeDB::bind_method(_MD("set_cell_extra_margin", "cell_extra_margin"), &BakedLight::set_cell_extra_margin);
+ ObjectTypeDB::bind_method(_MD("get_cell_extra_margin"), &BakedLight::get_cell_extra_margin);
- ObjectTypeDB::bind_method(_MD("set_edge_damp","edge_damp"),&BakedLight::set_edge_damp);
- ObjectTypeDB::bind_method(_MD("get_edge_damp"),&BakedLight::get_edge_damp);
+ ObjectTypeDB::bind_method(_MD("set_edge_damp", "edge_damp"), &BakedLight::set_edge_damp);
+ ObjectTypeDB::bind_method(_MD("get_edge_damp"), &BakedLight::get_edge_damp);
- ObjectTypeDB::bind_method(_MD("set_normal_damp","normal_damp"),&BakedLight::set_normal_damp);
- ObjectTypeDB::bind_method(_MD("get_normal_damp"),&BakedLight::get_normal_damp);
+ ObjectTypeDB::bind_method(_MD("set_normal_damp", "normal_damp"), &BakedLight::set_normal_damp);
+ ObjectTypeDB::bind_method(_MD("get_normal_damp"), &BakedLight::get_normal_damp);
- ObjectTypeDB::bind_method(_MD("set_tint","tint"),&BakedLight::set_tint);
- ObjectTypeDB::bind_method(_MD("get_tint"),&BakedLight::get_tint);
+ ObjectTypeDB::bind_method(_MD("set_tint", "tint"), &BakedLight::set_tint);
+ ObjectTypeDB::bind_method(_MD("get_tint"), &BakedLight::get_tint);
- ObjectTypeDB::bind_method(_MD("set_saturation","saturation"),&BakedLight::set_saturation);
- ObjectTypeDB::bind_method(_MD("get_saturation"),&BakedLight::get_saturation);
+ ObjectTypeDB::bind_method(_MD("set_saturation", "saturation"), &BakedLight::set_saturation);
+ ObjectTypeDB::bind_method(_MD("get_saturation"), &BakedLight::get_saturation);
- ObjectTypeDB::bind_method(_MD("set_ao_radius","ao_radius"),&BakedLight::set_ao_radius);
- ObjectTypeDB::bind_method(_MD("get_ao_radius"),&BakedLight::get_ao_radius);
+ ObjectTypeDB::bind_method(_MD("set_ao_radius", "ao_radius"), &BakedLight::set_ao_radius);
+ ObjectTypeDB::bind_method(_MD("get_ao_radius"), &BakedLight::get_ao_radius);
- ObjectTypeDB::bind_method(_MD("set_ao_strength","ao_strength"),&BakedLight::set_ao_strength);
- ObjectTypeDB::bind_method(_MD("get_ao_strength"),&BakedLight::get_ao_strength);
+ ObjectTypeDB::bind_method(_MD("set_ao_strength", "ao_strength"), &BakedLight::set_ao_strength);
+ ObjectTypeDB::bind_method(_MD("get_ao_strength"), &BakedLight::get_ao_strength);
ObjectTypeDB::bind_method(_MD("set_realtime_color_enabled", "enabled"), &BakedLight::set_realtime_color_enabled);
ObjectTypeDB::bind_method(_MD("get_realtime_color_enabled"), &BakedLight::get_realtime_color_enabled);
@@ -503,97 +476,89 @@ void BakedLight::_bind_methods(){
ObjectTypeDB::bind_method(_MD("set_realtime_energy", "energy"), &BakedLight::set_realtime_energy);
ObjectTypeDB::bind_method(_MD("get_realtime_energy"), &BakedLight::get_realtime_energy);
- ObjectTypeDB::bind_method(_MD("set_format","format"),&BakedLight::set_format);
- ObjectTypeDB::bind_method(_MD("get_format"),&BakedLight::get_format);
+ ObjectTypeDB::bind_method(_MD("set_format", "format"), &BakedLight::set_format);
+ ObjectTypeDB::bind_method(_MD("get_format"), &BakedLight::get_format);
- ObjectTypeDB::bind_method(_MD("set_transfer_lightmaps_only_to_uv2","enable"),&BakedLight::set_transfer_lightmaps_only_to_uv2);
- ObjectTypeDB::bind_method(_MD("get_transfer_lightmaps_only_to_uv2"),&BakedLight::get_transfer_lightmaps_only_to_uv2);
+ ObjectTypeDB::bind_method(_MD("set_transfer_lightmaps_only_to_uv2", "enable"), &BakedLight::set_transfer_lightmaps_only_to_uv2);
+ ObjectTypeDB::bind_method(_MD("get_transfer_lightmaps_only_to_uv2"), &BakedLight::get_transfer_lightmaps_only_to_uv2);
+ ObjectTypeDB::bind_method(_MD("set_energy_multiplier", "energy_multiplier"), &BakedLight::set_energy_multiplier);
+ ObjectTypeDB::bind_method(_MD("get_energy_multiplier"), &BakedLight::get_energy_multiplier);
+ ObjectTypeDB::bind_method(_MD("set_gamma_adjust", "gamma_adjust"), &BakedLight::set_gamma_adjust);
+ ObjectTypeDB::bind_method(_MD("get_gamma_adjust"), &BakedLight::get_gamma_adjust);
+ ObjectTypeDB::bind_method(_MD("set_bake_flag", "flag", "enabled"), &BakedLight::set_bake_flag);
+ ObjectTypeDB::bind_method(_MD("get_bake_flag", "flag"), &BakedLight::get_bake_flag);
- ObjectTypeDB::bind_method(_MD("set_energy_multiplier","energy_multiplier"),&BakedLight::set_energy_multiplier);
- ObjectTypeDB::bind_method(_MD("get_energy_multiplier"),&BakedLight::get_energy_multiplier);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mode/mode", PROPERTY_HINT_ENUM, "Octree,Lightmaps"), _SCS("set_mode"), _SCS("get_mode"));
- ObjectTypeDB::bind_method(_MD("set_gamma_adjust","gamma_adjust"),&BakedLight::set_gamma_adjust);
- ObjectTypeDB::bind_method(_MD("get_gamma_adjust"),&BakedLight::get_gamma_adjust);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "baking/format", PROPERTY_HINT_ENUM, "RGB,HDR8,HDR16"), _SCS("set_format"), _SCS("get_format"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "baking/cell_subdiv", PROPERTY_HINT_RANGE, "4,14,1"), _SCS("set_cell_subdivision"), _SCS("get_cell_subdivision"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "baking/lattice_subdiv", PROPERTY_HINT_RANGE, "1,5,1"), _SCS("set_initial_lattice_subdiv"), _SCS("get_initial_lattice_subdiv"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "baking/light_bounces", PROPERTY_HINT_RANGE, "0,3,1"), _SCS("set_bounces"), _SCS("get_bounces"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "baking/plot_size", PROPERTY_HINT_RANGE, "1.0,16.0,0.01"), _SCS("set_plot_size"), _SCS("get_plot_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "baking/energy_mult", PROPERTY_HINT_RANGE, "0.01,4096.0,0.01"), _SCS("set_energy_multiplier"), _SCS("get_energy_multiplier"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "baking/gamma_adjust", PROPERTY_HINT_EXP_EASING), _SCS("set_gamma_adjust"), _SCS("get_gamma_adjust"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "baking/saturation", PROPERTY_HINT_RANGE, "0,8,0.01"), _SCS("set_saturation"), _SCS("get_saturation"));
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "baking_flags/diffuse"), _SCS("set_bake_flag"), _SCS("get_bake_flag"), BAKE_DIFFUSE);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "baking_flags/specular"), _SCS("set_bake_flag"), _SCS("get_bake_flag"), BAKE_SPECULAR);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "baking_flags/translucent"), _SCS("set_bake_flag"), _SCS("get_bake_flag"), BAKE_TRANSLUCENT);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "baking_flags/conserve_energy"), _SCS("set_bake_flag"), _SCS("get_bake_flag"), BAKE_CONSERVE_ENERGY);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "baking_flags/linear_color"), _SCS("set_bake_flag"), _SCS("get_bake_flag"), BAKE_LINEAR_COLOR);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "lightmap/use_only_uv2"), _SCS("set_transfer_lightmaps_only_to_uv2"), _SCS("get_transfer_lightmaps_only_to_uv2"));
- ObjectTypeDB::bind_method(_MD("set_bake_flag","flag","enabled"),&BakedLight::set_bake_flag);
- ObjectTypeDB::bind_method(_MD("get_bake_flag","flag"),&BakedLight::get_bake_flag);
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode/mode",PROPERTY_HINT_ENUM,"Octree,Lightmaps"),_SCS("set_mode"),_SCS("get_mode"));
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/format",PROPERTY_HINT_ENUM,"RGB,HDR8,HDR16"),_SCS("set_format"),_SCS("get_format"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/cell_subdiv",PROPERTY_HINT_RANGE,"4,14,1"),_SCS("set_cell_subdivision"),_SCS("get_cell_subdivision"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/lattice_subdiv",PROPERTY_HINT_RANGE,"1,5,1"),_SCS("set_initial_lattice_subdiv"),_SCS("get_initial_lattice_subdiv"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/light_bounces",PROPERTY_HINT_RANGE,"0,3,1"),_SCS("set_bounces"),_SCS("get_bounces"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/plot_size",PROPERTY_HINT_RANGE,"1.0,16.0,0.01"),_SCS("set_plot_size"),_SCS("get_plot_size"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/energy_mult",PROPERTY_HINT_RANGE,"0.01,4096.0,0.01"),_SCS("set_energy_multiplier"),_SCS("get_energy_multiplier"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/gamma_adjust",PROPERTY_HINT_EXP_EASING),_SCS("set_gamma_adjust"),_SCS("get_gamma_adjust"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/saturation",PROPERTY_HINT_RANGE,"0,8,0.01"),_SCS("set_saturation"),_SCS("get_saturation"));
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/diffuse"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/specular"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_SPECULAR);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/translucent"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_TRANSLUCENT);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/conserve_energy"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_CONSERVE_ENERGY);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/linear_color"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_LINEAR_COLOR);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"lightmap/use_only_uv2"),_SCS("set_transfer_lightmaps_only_to_uv2"),_SCS("get_transfer_lightmaps_only_to_uv2"));
-
- ADD_PROPERTY( PropertyInfo(Variant::RAW_ARRAY,"octree",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_octree"),_SCS("get_octree"));
- ADD_PROPERTY( PropertyInfo(Variant::RAW_ARRAY,"light",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_light"),_SCS("get_light"));
- ADD_PROPERTY( PropertyInfo(Variant::INT_ARRAY,"sampler_octree",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_sampler_octree"),_SCS("get_sampler_octree"));
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"lightmaps",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_lightmap_data"),_SCS("_get_lightmap_data"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/cell_margin",PROPERTY_HINT_RANGE,"0.01,0.8,0.01"),_SCS("set_cell_extra_margin"),_SCS("get_cell_extra_margin"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/edge_damp",PROPERTY_HINT_RANGE,"0.0,8.0,0.1"),_SCS("set_edge_damp"),_SCS("get_edge_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/normal_damp",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_normal_damp"),_SCS("get_normal_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/light_tint",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_tint"),_SCS("get_tint"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/ao_radius",PROPERTY_HINT_RANGE,"0.0,16.0,0.01"),_SCS("set_ao_radius"),_SCS("get_ao_radius"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/ao_strength",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_ao_strength"),_SCS("get_ao_strength"));
+ ADD_PROPERTY(PropertyInfo(Variant::RAW_ARRAY, "octree", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("set_octree"), _SCS("get_octree"));
+ ADD_PROPERTY(PropertyInfo(Variant::RAW_ARRAY, "light", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("set_light"), _SCS("get_light"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT_ARRAY, "sampler_octree", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("set_sampler_octree"), _SCS("get_sampler_octree"));
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "lightmaps", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_lightmap_data"), _SCS("_get_lightmap_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "advanced/cell_margin", PROPERTY_HINT_RANGE, "0.01,0.8,0.01"), _SCS("set_cell_extra_margin"), _SCS("get_cell_extra_margin"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "advanced/edge_damp", PROPERTY_HINT_RANGE, "0.0,8.0,0.1"), _SCS("set_edge_damp"), _SCS("get_edge_damp"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "advanced/normal_damp", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), _SCS("set_normal_damp"), _SCS("get_normal_damp"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "advanced/light_tint", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), _SCS("set_tint"), _SCS("get_tint"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "advanced/ao_radius", PROPERTY_HINT_RANGE, "0.0,16.0,0.01"), _SCS("set_ao_radius"), _SCS("get_ao_radius"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "advanced/ao_strength", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), _SCS("set_ao_strength"), _SCS("get_ao_strength"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "realtime/enabled"), _SCS("set_realtime_color_enabled"), _SCS("get_realtime_color_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "realtime/color", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_realtime_color"), _SCS("get_realtime_color"));
ADD_PROPERTY(PropertyInfo(Variant::REAL, "realtime/energy", PROPERTY_HINT_RANGE, "0.01,4096.0,0.01"), _SCS("set_realtime_energy"), _SCS("get_realtime_energy"));
+ BIND_CONSTANT(MODE_OCTREE);
+ BIND_CONSTANT(MODE_LIGHTMAPS);
- BIND_CONSTANT( MODE_OCTREE );
- BIND_CONSTANT( MODE_LIGHTMAPS );
-
- BIND_CONSTANT( BAKE_DIFFUSE );
- BIND_CONSTANT( BAKE_SPECULAR );
- BIND_CONSTANT( BAKE_TRANSLUCENT );
- BIND_CONSTANT( BAKE_CONSERVE_ENERGY );
- BIND_CONSTANT( BAKE_MAX );
-
-
+ BIND_CONSTANT(BAKE_DIFFUSE);
+ BIND_CONSTANT(BAKE_SPECULAR);
+ BIND_CONSTANT(BAKE_TRANSLUCENT);
+ BIND_CONSTANT(BAKE_CONSERVE_ENERGY);
+ BIND_CONSTANT(BAKE_MAX);
}
-
BakedLight::BakedLight() {
- cell_subdiv=8;
- lattice_subdiv=4;
- plot_size=2.5;
- bounces=1;
- energy_multiply=2.0;
- gamma_adjust=0.7;
- cell_extra_margin=0.05;
- edge_damp=0.0;
- normal_damp=0.0;
- saturation=1;
- tint=0.0;
- ao_radius=2.5;
- ao_strength=0.7;
- format=FORMAT_RGB;
- transfer_only_uv2=false;
-
+ cell_subdiv = 8;
+ lattice_subdiv = 4;
+ plot_size = 2.5;
+ bounces = 1;
+ energy_multiply = 2.0;
+ gamma_adjust = 0.7;
+ cell_extra_margin = 0.05;
+ edge_damp = 0.0;
+ normal_damp = 0.0;
+ saturation = 1;
+ tint = 0.0;
+ ao_radius = 2.5;
+ ao_strength = 0.7;
+ format = FORMAT_RGB;
+ transfer_only_uv2 = false;
- flags[BAKE_DIFFUSE]=true;
- flags[BAKE_SPECULAR]=false;
- flags[BAKE_TRANSLUCENT]=true;
- flags[BAKE_CONSERVE_ENERGY]=false;
- flags[BAKE_LINEAR_COLOR]=false;
+ flags[BAKE_DIFFUSE] = true;
+ flags[BAKE_SPECULAR] = false;
+ flags[BAKE_TRANSLUCENT] = true;
+ flags[BAKE_CONSERVE_ENERGY] = false;
+ flags[BAKE_LINEAR_COLOR] = false;
- mode=MODE_OCTREE;
- baked_light=VS::get_singleton()->baked_light_create();
+ mode = MODE_OCTREE;
+ baked_light = VS::get_singleton()->baked_light_create();
}
BakedLight::~BakedLight() {
diff --git a/scene/resources/baked_light.h b/scene/resources/baked_light.h
index adbe7ccca..8151bde42 100644
--- a/scene/resources/baked_light.h
+++ b/scene/resources/baked_light.h
@@ -34,7 +34,8 @@
class BakedLight : public Resource {
- OBJ_TYPE( BakedLight, Resource);
+ OBJ_TYPE(BakedLight, Resource);
+
public:
enum Mode {
@@ -59,7 +60,6 @@ public:
};
private:
-
RID baked_light;
Mode mode;
struct LightMap {
@@ -67,8 +67,7 @@ private:
Ref<Texture> texture;
};
-
- Vector< LightMap> lightmaps;
+ Vector<LightMap> lightmaps;
//bake vars
int cell_subdiv;
@@ -88,23 +87,19 @@ private:
Format format;
bool flags[BAKE_MAX];
-
-
void _update_lightmaps();
Array _get_lightmap_data() const;
void _set_lightmap_data(Array p_array);
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
void set_cell_subdivision(int p_subdiv);
int get_cell_subdivision() const;
@@ -147,13 +142,13 @@ public:
void set_realtime_color_enabled(const bool p_enabled);
bool get_realtime_color_enabled() const;
- void set_realtime_color(const Color& p_realtime_color);
+ void set_realtime_color(const Color &p_realtime_color);
Color get_realtime_color() const;
void set_realtime_energy(const float p_realtime_energy);
float get_realtime_energy() const;
- void set_bake_flag(BakeFlags p_flags,bool p_enable);
+ void set_bake_flag(BakeFlags p_flags, bool p_enable);
bool get_bake_flag(BakeFlags p_flags) const;
void set_format(Format p_margin);
@@ -165,24 +160,22 @@ public:
void set_mode(Mode p_mode);
Mode get_mode() const;
- void set_octree(const DVector<uint8_t>& p_octree);
+ void set_octree(const DVector<uint8_t> &p_octree);
DVector<uint8_t> get_octree() const;
- void set_light(const DVector<uint8_t>& p_light);
+ void set_light(const DVector<uint8_t> &p_light);
DVector<uint8_t> get_light() const;
- void set_sampler_octree(const DVector<int>& p_sampler_octree);
+ void set_sampler_octree(const DVector<int> &p_sampler_octree);
DVector<int> get_sampler_octree() const;
-
-
- void add_lightmap(const Ref<Texture> &p_texture,Size2 p_gen_size=Size2(256,256));
- void set_lightmap_gen_size(int p_idx,const Size2& p_size);
+ void add_lightmap(const Ref<Texture> &p_texture, Size2 p_gen_size = Size2(256, 256));
+ void set_lightmap_gen_size(int p_idx, const Size2 &p_size);
Size2 get_lightmap_gen_size(int p_idx) const;
- void set_lightmap_texture(int p_idx,const Ref<Texture> &p_texture);
+ void set_lightmap_texture(int p_idx, const Ref<Texture> &p_texture);
Ref<Texture> get_lightmap_texture(int p_idx) const;
void erase_lightmap(int p_idx);
- int get_lightmaps_count() const;
+ int get_lightmaps_count() const;
void clear_lightmaps();
virtual RID get_rid() const;
@@ -191,7 +184,6 @@ public:
~BakedLight();
};
-
VARIANT_ENUM_CAST(BakedLight::Format);
VARIANT_ENUM_CAST(BakedLight::Mode);
VARIANT_ENUM_CAST(BakedLight::BakeFlags);
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index b9b31ba32..f89f1831e 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -29,178 +29,166 @@
#include "bit_mask.h"
#include "io/image_loader.h"
-void BitMap::create(const Size2& p_size) {
+void BitMap::create(const Size2 &p_size) {
- ERR_FAIL_COND(p_size.width<1);
- ERR_FAIL_COND(p_size.height<1);
-
- width=p_size.width;
- height=p_size.height;
- bitmask.resize(((width*height)/8)+1);
- zeromem(bitmask.ptr(),bitmask.size());
+ ERR_FAIL_COND(p_size.width < 1);
+ ERR_FAIL_COND(p_size.height < 1);
+ width = p_size.width;
+ height = p_size.height;
+ bitmask.resize(((width * height) / 8) + 1);
+ zeromem(bitmask.ptr(), bitmask.size());
}
-void BitMap::create_from_image_alpha(const Image& p_image){
+void BitMap::create_from_image_alpha(const Image &p_image) {
ERR_FAIL_COND(p_image.empty());
- Image img=p_image;
+ Image img = p_image;
img.convert(Image::FORMAT_INTENSITY);
- ERR_FAIL_COND(img.get_format()!=Image::FORMAT_INTENSITY);
-
- create(Size2(img.get_width(),img.get_height()));
+ ERR_FAIL_COND(img.get_format() != Image::FORMAT_INTENSITY);
+ create(Size2(img.get_width(), img.get_height()));
DVector<uint8_t>::Read r = img.get_data().read();
uint8_t *w = bitmask.ptr();
- for(int i=0;i<width*height;i++) {
+ for (int i = 0; i < width * height; i++) {
- int bbyte = i/8;
+ int bbyte = i / 8;
int bbit = i % 8;
if (r[i])
- w[bbyte]|=(1<<bbit);
+ w[bbyte] |= (1 << bbit);
}
-
}
+void BitMap::set_bit_rect(const Rect2 &p_rect, bool p_value) {
-void BitMap::set_bit_rect(const Rect2& p_rect,bool p_value) {
-
- Rect2i current = Rect2i(0,0,width,height).clip(p_rect);
+ Rect2i current = Rect2i(0, 0, width, height).clip(p_rect);
uint8_t *data = bitmask.ptr();
- for(int i=current.pos.x;i<current.pos.x+current.size.x;i++) {
-
- for(int j=current.pos.y;j<current.pos.y+current.size.y;j++) {
+ for (int i = current.pos.x; i < current.pos.x + current.size.x; i++) {
+ for (int j = current.pos.y; j < current.pos.y + current.size.y; j++) {
int ofs = width * j + i;
- int bbyte = ofs/8;
+ int bbyte = ofs / 8;
int bbit = ofs % 8;
uint8_t b = data[bbyte];
if (p_value)
- b|=(1<<bbit);
+ b |= (1 << bbit);
else
- b&=!(1<<bbit);
-
- data[bbyte]=b;
+ b &= !(1 << bbit);
+ data[bbyte] = b;
}
}
-
}
int BitMap::get_true_bit_count() const {
int ds = bitmask.size();
const uint8_t *d = bitmask.ptr();
- int c=0;
+ int c = 0;
-//fast, almot branchless version
+ //fast, almot branchless version
- for(int i=0;i<ds;i++) {
+ for (int i = 0; i < ds; i++) {
- c+=(d[i]&(1<<7))>>7;
- c+=(d[i]&(1<<6))>>6;
- c+=(d[i]&(1<<5))>>5;
- c+=(d[i]&(1<<4))>>4;
- c+=(d[i]&(1<<3))>>3;
- c+=(d[i]&(1<<2))>>2;
- c+=d[i]&1;
+ c += (d[i] & (1 << 7)) >> 7;
+ c += (d[i] & (1 << 6)) >> 6;
+ c += (d[i] & (1 << 5)) >> 5;
+ c += (d[i] & (1 << 4)) >> 4;
+ c += (d[i] & (1 << 3)) >> 3;
+ c += (d[i] & (1 << 2)) >> 2;
+ c += d[i] & 1;
}
return c;
}
+void BitMap::set_bit(const Point2 &p_pos, bool p_value) {
-void BitMap::set_bit(const Point2& p_pos,bool p_value){
-
- int x=Math::fast_ftoi(p_pos.x);
- int y=Math::fast_ftoi(p_pos.y);
+ int x = Math::fast_ftoi(p_pos.x);
+ int y = Math::fast_ftoi(p_pos.y);
- ERR_FAIL_INDEX(x,width);
- ERR_FAIL_INDEX(y,height);
+ ERR_FAIL_INDEX(x, width);
+ ERR_FAIL_INDEX(y, height);
int ofs = width * y + x;
- int bbyte = ofs/8;
+ int bbyte = ofs / 8;
int bbit = ofs % 8;
uint8_t b = bitmask[bbyte];
if (p_value)
- b|=(1<<bbit);
+ b |= (1 << bbit);
else
- b&=!(1<<bbit);
+ b &= !(1 << bbit);
- bitmask[bbyte]=b;
+ bitmask[bbyte] = b;
}
-bool BitMap::get_bit(const Point2& p_pos) const{
+bool BitMap::get_bit(const Point2 &p_pos) const {
- int x=Math::fast_ftoi(p_pos.x);
- int y=Math::fast_ftoi(p_pos.y);
- ERR_FAIL_INDEX_V(x,width,false);
- ERR_FAIL_INDEX_V(y,height,false);
+ int x = Math::fast_ftoi(p_pos.x);
+ int y = Math::fast_ftoi(p_pos.y);
+ ERR_FAIL_INDEX_V(x, width, false);
+ ERR_FAIL_INDEX_V(y, height, false);
int ofs = width * y + x;
- int bbyte = ofs/8;
+ int bbyte = ofs / 8;
int bbit = ofs % 8;
- return (bitmask[bbyte]&(1<<bbit))!=0;
-
+ return (bitmask[bbyte] & (1 << bbit)) != 0;
}
Size2 BitMap::get_size() const {
- return Size2(width,height);
+ return Size2(width, height);
}
-void BitMap::_set_data(const Dictionary& p_d) {
+void BitMap::_set_data(const Dictionary &p_d) {
ERR_FAIL_COND(!p_d.has("size"));
ERR_FAIL_COND(!p_d.has("data"));
create(p_d["size"]);
- bitmask=p_d["data"];
+ bitmask = p_d["data"];
}
-Dictionary BitMap::_get_data() const{
+Dictionary BitMap::_get_data() const {
Dictionary d;
- d["size"]=get_size();
- d["data"]=bitmask;
+ d["size"] = get_size();
+ d["data"] = bitmask;
return d;
}
void BitMap::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create","size"),&BitMap::create);
- ObjectTypeDB::bind_method(_MD("create_from_image_alpha","image"),&BitMap::create_from_image_alpha);
+ ObjectTypeDB::bind_method(_MD("create", "size"), &BitMap::create);
+ ObjectTypeDB::bind_method(_MD("create_from_image_alpha", "image"), &BitMap::create_from_image_alpha);
- ObjectTypeDB::bind_method(_MD("set_bit","pos","bit"),&BitMap::set_bit);
- ObjectTypeDB::bind_method(_MD("get_bit","pos"),&BitMap::get_bit);
+ ObjectTypeDB::bind_method(_MD("set_bit", "pos", "bit"), &BitMap::set_bit);
+ ObjectTypeDB::bind_method(_MD("get_bit", "pos"), &BitMap::get_bit);
- ObjectTypeDB::bind_method(_MD("set_bit_rect","p_rect","bit"),&BitMap::set_bit_rect);
- ObjectTypeDB::bind_method(_MD("get_true_bit_count"),&BitMap::get_true_bit_count);
+ ObjectTypeDB::bind_method(_MD("set_bit_rect", "p_rect", "bit"), &BitMap::set_bit_rect);
+ ObjectTypeDB::bind_method(_MD("get_true_bit_count"), &BitMap::get_true_bit_count);
- ObjectTypeDB::bind_method(_MD("get_size"),&BitMap::get_size);
-
- ObjectTypeDB::bind_method(_MD("_set_data"),&BitMap::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&BitMap::_get_data);
-
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
+ ObjectTypeDB::bind_method(_MD("get_size"), &BitMap::get_size);
+ ObjectTypeDB::bind_method(_MD("_set_data"), &BitMap::_set_data);
+ ObjectTypeDB::bind_method(_MD("_get_data"), &BitMap::_get_data);
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data"));
}
BitMap::BitMap() {
- width=0;
- height=0;
+ width = 0;
+ height = 0;
}
//////////////////////////////////////
-
diff --git a/scene/resources/bit_mask.h b/scene/resources/bit_mask.h
index 1bc8688aa..7ffce6523 100644
--- a/scene/resources/bit_mask.h
+++ b/scene/resources/bit_mask.h
@@ -29,13 +29,12 @@
#ifndef BIT_MASK_H
#define BIT_MASK_H
-#include "resource.h"
#include "io/resource_loader.h"
-
+#include "resource.h"
class BitMap : public Resource {
- OBJ_TYPE(BitMap,Resource);
+ OBJ_TYPE(BitMap, Resource);
OBJ_SAVE_TYPE(BitMap);
RES_BASE_EXTENSION("pbm");
@@ -44,19 +43,18 @@ class BitMap : public Resource {
int height;
protected:
- void _set_data(const Dictionary& p_d);
+ void _set_data(const Dictionary &p_d);
Dictionary _get_data() const;
static void _bind_methods();
-public:
+public:
+ void create(const Size2 &p_size);
+ void create_from_image_alpha(const Image &p_image);
- void create(const Size2& p_size);
- void create_from_image_alpha(const Image& p_image);
-
- void set_bit(const Point2& p_pos,bool p_value);
- bool get_bit(const Point2& p_pos) const;
- void set_bit_rect(const Rect2& p_rect,bool p_value);
+ void set_bit(const Point2 &p_pos, bool p_value);
+ bool get_bit(const Point2 &p_pos) const;
+ void set_bit_rect(const Rect2 &p_rect, bool p_value);
int get_true_bit_count() const;
Size2 get_size() const;
@@ -64,5 +62,4 @@ public:
BitMap();
};
-
#endif // BIT_MASK_H
diff --git a/scene/resources/bounds.cpp b/scene/resources/bounds.cpp
index d8f8745ae..7514a70ef 100644
--- a/scene/resources/bounds.cpp
+++ b/scene/resources/bounds.cpp
@@ -28,19 +28,17 @@
/*************************************************************************/
#include "bounds.h"
-
void Bounds::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("set_bsp_tree","bsp_tree"),&Bounds::set_bsp_tree);
- ObjectTypeDB::bind_method( _MD("get_bsp_tree"),&Bounds::get_bsp_tree );
-
- ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "bsp_tree" ), _SCS("set_bsp_tree"), _SCS("get_bsp_tree"));
+ ObjectTypeDB::bind_method(_MD("set_bsp_tree", "bsp_tree"), &Bounds::set_bsp_tree);
+ ObjectTypeDB::bind_method(_MD("get_bsp_tree"), &Bounds::get_bsp_tree);
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "bsp_tree"), _SCS("set_bsp_tree"), _SCS("get_bsp_tree"));
}
-void Bounds::set_bsp_tree(const BSP_Tree& p_bsp_tree) {
+void Bounds::set_bsp_tree(const BSP_Tree &p_bsp_tree) {
- bsp_tree=p_bsp_tree;
+ bsp_tree = p_bsp_tree;
}
BSP_Tree Bounds::get_bsp_tree() const {
@@ -48,7 +46,5 @@ BSP_Tree Bounds::get_bsp_tree() const {
return bsp_tree;
}
-
-Bounds::Bounds()
-{
+Bounds::Bounds() {
}
diff --git a/scene/resources/bounds.h b/scene/resources/bounds.h
index aa7d248a0..97bc6fac6 100644
--- a/scene/resources/bounds.h
+++ b/scene/resources/bounds.h
@@ -29,21 +29,19 @@
#ifndef BOUNDS_H
#define BOUNDS_H
-#include "resource.h"
#include "bsp_tree.h"
+#include "resource.h"
class Bounds : public Resource {
- OBJ_TYPE(Bounds,Resource);
+ OBJ_TYPE(Bounds, Resource);
BSP_Tree bsp_tree;
protected:
-
static void _bind_methods();
public:
-
- void set_bsp_tree(const BSP_Tree& p_bsp_tree);
+ void set_bsp_tree(const BSP_Tree &p_bsp_tree);
BSP_Tree get_bsp_tree() const;
Bounds();
diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp
index 327102226..ae2695e45 100644
--- a/scene/resources/box_shape.cpp
+++ b/scene/resources/box_shape.cpp
@@ -29,34 +29,31 @@
#include "box_shape.h"
#include "servers/physics_server.h"
-
Vector<Vector3> BoxShape::_gen_debug_mesh_lines() {
-
Vector<Vector3> lines;
AABB aabb;
- aabb.pos=-get_extents();
- aabb.size=aabb.pos*-2;
+ aabb.pos = -get_extents();
+ aabb.size = aabb.pos * -2;
- for(int i=0;i<12;i++) {
- Vector3 a,b;
- aabb.get_edge(i,a,b);
+ for (int i = 0; i < 12; i++) {
+ Vector3 a, b;
+ aabb.get_edge(i, a, b);
lines.push_back(a);
lines.push_back(b);
}
-
return lines;
}
void BoxShape::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),extents);
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), extents);
}
-void BoxShape::set_extents(const Vector3& p_extents) {
+void BoxShape::set_extents(const Vector3 &p_extents) {
- extents=p_extents;
+ extents = p_extents;
_update_shape();
notify_change_to_owners();
_change_notify("extents");
@@ -67,17 +64,16 @@ Vector3 BoxShape::get_extents() const {
return extents;
}
-
void BoxShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_extents","extents"),&BoxShape::set_extents);
- ObjectTypeDB::bind_method(_MD("get_extents"),&BoxShape::get_extents);
-
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"extents"), _SCS("set_extents"), _SCS("get_extents") );
+ ObjectTypeDB::bind_method(_MD("set_extents", "extents"), &BoxShape::set_extents);
+ ObjectTypeDB::bind_method(_MD("get_extents"), &BoxShape::get_extents);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), _SCS("set_extents"), _SCS("get_extents"));
}
-BoxShape::BoxShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_BOX)) {
+BoxShape::BoxShape()
+ : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_BOX)) {
- set_extents(Vector3(1,1,1));
+ set_extents(Vector3(1, 1, 1));
}
diff --git a/scene/resources/box_shape.h b/scene/resources/box_shape.h
index 34918a978..180409909 100644
--- a/scene/resources/box_shape.h
+++ b/scene/resources/box_shape.h
@@ -33,19 +33,17 @@
class BoxShape : public Shape {
- OBJ_TYPE(BoxShape,Shape);
+ OBJ_TYPE(BoxShape, Shape);
Vector3 extents;
protected:
-
static void _bind_methods();
virtual void _update_shape();
virtual Vector<Vector3> _gen_debug_mesh_lines();
public:
-
- void set_extents(const Vector3& p_extents);
+ void set_extents(const Vector3 &p_extents);
Vector3 get_extents() const;
BoxShape();
diff --git a/scene/resources/canvas.cpp b/scene/resources/canvas.cpp
index bda97141c..dd0375b76 100644
--- a/scene/resources/canvas.cpp
+++ b/scene/resources/canvas.cpp
@@ -36,11 +36,9 @@ RID Canvas::get_rid() const {
Canvas::Canvas() {
- canvas=VisualServer::get_singleton()->canvas_create();
+ canvas = VisualServer::get_singleton()->canvas_create();
}
-
Canvas::~Canvas() {
VisualServer::get_singleton()->free(canvas);
}
-
diff --git a/scene/resources/canvas.h b/scene/resources/canvas.h
index 9ca840978..71714b5c8 100644
--- a/scene/resources/canvas.h
+++ b/scene/resources/canvas.h
@@ -29,17 +29,15 @@
#ifndef CANVAS_H
#define CANVAS_H
-
#include "resource.h"
class Canvas : public Resource {
- OBJ_TYPE(Canvas,Resource);
+ OBJ_TYPE(Canvas, Resource);
RID canvas;
public:
-
virtual RID get_rid() const;
Canvas();
~Canvas();
diff --git a/scene/resources/capsule_shape.cpp b/scene/resources/capsule_shape.cpp
index 5ed49c5b9..6c257bb2c 100644
--- a/scene/resources/capsule_shape.cpp
+++ b/scene/resources/capsule_shape.cpp
@@ -29,43 +29,39 @@
#include "capsule_shape.h"
#include "servers/physics_server.h"
-
Vector<Vector3> CapsuleShape::_gen_debug_mesh_lines() {
-
float radius = get_radius();
float height = get_height();
-
Vector<Vector3> points;
- Vector3 d(0,0,height*0.5);
- for(int i=0;i<360;i++) {
+ Vector3 d(0, 0, height * 0.5);
+ for (int i = 0; i < 360; i++) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*radius;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*radius;
+ float ra = Math::deg2rad(i);
+ float rb = Math::deg2rad(i + 1);
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius;
- points.push_back(Vector3(a.x,a.y,0)+d);
- points.push_back(Vector3(b.x,b.y,0)+d);
+ points.push_back(Vector3(a.x, a.y, 0) + d);
+ points.push_back(Vector3(b.x, b.y, 0) + d);
- points.push_back(Vector3(a.x,a.y,0)-d);
- points.push_back(Vector3(b.x,b.y,0)-d);
+ points.push_back(Vector3(a.x, a.y, 0) - d);
+ points.push_back(Vector3(b.x, b.y, 0) - d);
- if (i%90==0) {
+ if (i % 90 == 0) {
- points.push_back(Vector3(a.x,a.y,0)+d);
- points.push_back(Vector3(a.x,a.y,0)-d);
+ points.push_back(Vector3(a.x, a.y, 0) + d);
+ points.push_back(Vector3(a.x, a.y, 0) - d);
}
- Vector3 dud = i<180?d:-d;
-
- points.push_back(Vector3(0,a.y,a.x)+dud);
- points.push_back(Vector3(0,b.y,b.x)+dud);
- points.push_back(Vector3(a.y,0,a.x)+dud);
- points.push_back(Vector3(b.y,0,b.x)+dud);
+ Vector3 dud = i < 180 ? d : -d;
+ points.push_back(Vector3(0, a.y, a.x) + dud);
+ points.push_back(Vector3(0, b.y, b.x) + dud);
+ points.push_back(Vector3(a.y, 0, a.x) + dud);
+ points.push_back(Vector3(b.y, 0, b.x) + dud);
}
return points;
@@ -74,14 +70,14 @@ Vector<Vector3> CapsuleShape::_gen_debug_mesh_lines() {
void CapsuleShape::_update_shape() {
Dictionary d;
- d["radius"]=radius;
- d["height"]=height;
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),d);
+ d["radius"] = radius;
+ d["height"] = height;
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), d);
}
void CapsuleShape::set_radius(float p_radius) {
- radius=p_radius;
+ radius = p_radius;
_update_shape();
notify_change_to_owners();
_change_notify("radius");
@@ -94,7 +90,7 @@ float CapsuleShape::get_radius() const {
void CapsuleShape::set_height(float p_height) {
- height=p_height;
+ height = p_height;
_update_shape();
notify_change_to_owners();
_change_notify("height");
@@ -107,19 +103,19 @@ float CapsuleShape::get_height() const {
void CapsuleShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&CapsuleShape::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&CapsuleShape::get_radius);
- ObjectTypeDB::bind_method(_MD("set_height","height"),&CapsuleShape::set_height);
- ObjectTypeDB::bind_method(_MD("get_height"),&CapsuleShape::get_height);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,4096,0.01"), _SCS("set_radius"),_SCS("get_radius") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"height",PROPERTY_HINT_RANGE,"0.01,4096,0.01"), _SCS("set_height"),_SCS("get_height") );
+ ObjectTypeDB::bind_method(_MD("set_radius", "radius"), &CapsuleShape::set_radius);
+ ObjectTypeDB::bind_method(_MD("get_radius"), &CapsuleShape::get_radius);
+ ObjectTypeDB::bind_method(_MD("set_height", "height"), &CapsuleShape::set_height);
+ ObjectTypeDB::bind_method(_MD("get_height"), &CapsuleShape::get_height);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), _SCS("set_radius"), _SCS("get_radius"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), _SCS("set_height"), _SCS("get_height"));
}
-CapsuleShape::CapsuleShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CAPSULE)) {
+CapsuleShape::CapsuleShape()
+ : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CAPSULE)) {
- radius=1.0;
- height=1.0;
+ radius = 1.0;
+ height = 1.0;
_update_shape();
}
diff --git a/scene/resources/capsule_shape.h b/scene/resources/capsule_shape.h
index 8425d724f..364fb1f1c 100644
--- a/scene/resources/capsule_shape.h
+++ b/scene/resources/capsule_shape.h
@@ -33,25 +33,23 @@
class CapsuleShape : public Shape {
- OBJ_TYPE(CapsuleShape,Shape);
+ OBJ_TYPE(CapsuleShape, Shape);
float radius;
float height;
protected:
-
static void _bind_methods();
virtual void _update_shape();
virtual Vector<Vector3> _gen_debug_mesh_lines();
-public:
+public:
void set_radius(float p_radius);
float get_radius() const;
void set_height(float p_height);
float get_height() const;
-
CapsuleShape();
};
diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp
index 805666e7a..14dd6f0f1 100644
--- a/scene/resources/capsule_shape_2d.cpp
+++ b/scene/resources/capsule_shape_2d.cpp
@@ -33,14 +33,13 @@
void CapsuleShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),Vector2(radius,height));
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), Vector2(radius, height));
emit_changed();
}
-
void CapsuleShape2D::set_radius(real_t p_radius) {
- radius=p_radius;
+ radius = p_radius;
_update_shape();
}
@@ -51,7 +50,7 @@ real_t CapsuleShape2D::get_radius() const {
void CapsuleShape2D::set_height(real_t p_height) {
- height=p_height;
+ height = p_height;
_update_shape();
}
@@ -60,50 +59,47 @@ real_t CapsuleShape2D::get_height() const {
return height;
}
-
-void CapsuleShape2D::draw(const RID& p_to_rid,const Color& p_color) {
+void CapsuleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector<Vector2> points;
- for(int i=0;i<24;i++) {
- Vector2 ofs = Vector2(0,(i>6 && i<=18) ? -get_height()*0.5 : get_height()*0.5);
+ for (int i = 0; i < 24; i++) {
+ Vector2 ofs = Vector2(0, (i > 6 && i <= 18) ? -get_height() * 0.5 : get_height() * 0.5);
- points.push_back(Vector2(Math::sin(i*Math_PI*2/24.0),Math::cos(i*Math_PI*2/24.0))*get_radius() + ofs);
- if (i==6 || i==18)
- points.push_back(Vector2(Math::sin(i*Math_PI*2/24.0),Math::cos(i*Math_PI*2/24.0))*get_radius() - ofs);
+ points.push_back(Vector2(Math::sin(i * Math_PI * 2 / 24.0), Math::cos(i * Math_PI * 2 / 24.0)) * get_radius() + ofs);
+ if (i == 6 || i == 18)
+ points.push_back(Vector2(Math::sin(i * Math_PI * 2 / 24.0), Math::cos(i * Math_PI * 2 / 24.0)) * get_radius() - ofs);
}
Vector<Color> col;
col.push_back(p_color);
- VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid,points,col);
-
+ VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
}
Rect2 CapsuleShape2D::get_rect() const {
- Vector2 he=Point2(get_radius(),get_radius()+get_height()*0.5);
+ Vector2 he = Point2(get_radius(), get_radius() + get_height() * 0.5);
Rect2 rect;
- rect.pos=-he;
- rect.size=he*2.0;
+ rect.pos = -he;
+ rect.size = he * 2.0;
return rect;
}
void CapsuleShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&CapsuleShape2D::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&CapsuleShape2D::get_radius);
-
- ObjectTypeDB::bind_method(_MD("set_height","height"),&CapsuleShape2D::set_height);
- ObjectTypeDB::bind_method(_MD("get_height"),&CapsuleShape2D::get_height);
-
+ ObjectTypeDB::bind_method(_MD("set_radius", "radius"), &CapsuleShape2D::set_radius);
+ ObjectTypeDB::bind_method(_MD("get_radius"), &CapsuleShape2D::get_radius);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius"),_SCS("set_radius"),_SCS("get_radius") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"height"),_SCS("set_height"),_SCS("get_height") );
+ ObjectTypeDB::bind_method(_MD("set_height", "height"), &CapsuleShape2D::set_height);
+ ObjectTypeDB::bind_method(_MD("get_height"), &CapsuleShape2D::get_height);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), _SCS("set_radius"), _SCS("get_radius"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "height"), _SCS("set_height"), _SCS("get_height"));
}
-CapsuleShape2D::CapsuleShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CAPSULE)) {
+CapsuleShape2D::CapsuleShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CAPSULE)) {
- radius=10;
- height=20;
+ radius = 10;
+ height = 20;
_update_shape();
}
diff --git a/scene/resources/capsule_shape_2d.h b/scene/resources/capsule_shape_2d.h
index b17d3cec7..2cf77920d 100644
--- a/scene/resources/capsule_shape_2d.h
+++ b/scene/resources/capsule_shape_2d.h
@@ -32,25 +32,25 @@
#include "scene/resources/shape_2d.h"
class CapsuleShape2D : public Shape2D {
- OBJ_TYPE( CapsuleShape2D, Shape2D );
+ OBJ_TYPE(CapsuleShape2D, Shape2D);
real_t height;
real_t radius;
void _update_shape();
-protected:
+protected:
static void _bind_methods();
-public:
+public:
void set_height(real_t p_height);
real_t get_height() const;
void set_radius(real_t p_radius);
real_t get_radius() const;
- virtual void draw(const RID& p_to_rid,const Color& p_color);
- virtual Rect2 get_rect() const ;
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
+ virtual Rect2 get_rect() const;
CapsuleShape2D();
};
diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp
index 3aec7300d..5d4660b2e 100644
--- a/scene/resources/circle_shape_2d.cpp
+++ b/scene/resources/circle_shape_2d.cpp
@@ -32,14 +32,13 @@
#include "servers/visual_server.h"
void CircleShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),radius);
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), radius);
emit_changed();
}
-
void CircleShape2D::set_radius(real_t p_radius) {
- radius=p_radius;
+ radius = p_radius;
_update_shape();
}
@@ -48,39 +47,37 @@ real_t CircleShape2D::get_radius() const {
return radius;
}
-
void CircleShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&CircleShape2D::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&CircleShape2D::get_radius);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0.01,16384,0.5"),_SCS("set_radius"),_SCS("get_radius") );
+ ObjectTypeDB::bind_method(_MD("set_radius", "radius"), &CircleShape2D::set_radius);
+ ObjectTypeDB::bind_method(_MD("get_radius"), &CircleShape2D::get_radius);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.01,16384,0.5"), _SCS("set_radius"), _SCS("get_radius"));
}
Rect2 CircleShape2D::get_rect() const {
Rect2 rect;
- rect.pos=-Point2(get_radius(),get_radius());
- rect.size=Point2(get_radius(),get_radius())*2.0;
+ rect.pos = -Point2(get_radius(), get_radius());
+ rect.size = Point2(get_radius(), get_radius()) * 2.0;
return rect;
}
-void CircleShape2D::draw(const RID& p_to_rid,const Color& p_color) {
+void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector<Vector2> points;
- for(int i=0;i<24;i++) {
+ for (int i = 0; i < 24; i++) {
- points.push_back(Vector2(Math::cos(i*Math_PI*2/24.0),Math::sin(i*Math_PI*2/24.0))*get_radius());
+ points.push_back(Vector2(Math::cos(i * Math_PI * 2 / 24.0), Math::sin(i * Math_PI * 2 / 24.0)) * get_radius());
}
Vector<Color> col;
col.push_back(p_color);
- VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid,points,col);
-
+ VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
}
-CircleShape2D::CircleShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CIRCLE)) {
+CircleShape2D::CircleShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CIRCLE)) {
- radius=10;
+ radius = 10;
_update_shape();
}
diff --git a/scene/resources/circle_shape_2d.h b/scene/resources/circle_shape_2d.h
index 9c728a22a..1a5ccac1a 100644
--- a/scene/resources/circle_shape_2d.h
+++ b/scene/resources/circle_shape_2d.h
@@ -32,22 +32,21 @@
#include "scene/resources/shape_2d.h"
class CircleShape2D : public Shape2D {
- OBJ_TYPE( CircleShape2D, Shape2D );
+ OBJ_TYPE(CircleShape2D, Shape2D);
real_t radius;
void _update_shape();
-protected:
+protected:
static void _bind_methods();
-public:
+public:
void set_radius(real_t p_radius);
real_t get_radius() const;
- virtual void draw(const RID& p_to_rid,const Color& p_color);
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
virtual Rect2 get_rect() const;
-
CircleShape2D();
};
diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp
index cdef4346b..c7892ca13 100644
--- a/scene/resources/color_ramp.cpp
+++ b/scene/resources/color_ramp.cpp
@@ -37,51 +37,45 @@
ColorRamp::ColorRamp() {
//Set initial color ramp transition from black to white
points.resize(2);
- points[0].color = Color(0,0,0,1);
+ points[0].color = Color(0, 0, 0, 1);
points[0].offset = 0;
- points[1].color = Color(1,1,1,1);
+ points[1].color = Color(1, 1, 1, 1);
points[1].offset = 1;
is_sorted = true;
}
ColorRamp::~ColorRamp() {
-
}
void ColorRamp::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("add_point", "offset", "color"), &ColorRamp::add_point);
+ ObjectTypeDB::bind_method(_MD("remove_point", "offset", "color"), &ColorRamp::remove_point);
+ ObjectTypeDB::bind_method(_MD("set_offset", "point", "offset"), &ColorRamp::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset", "point"), &ColorRamp::get_offset);
+ ObjectTypeDB::bind_method(_MD("set_color", "point", "color"), &ColorRamp::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color", "point"), &ColorRamp::get_color);
+ ObjectTypeDB::bind_method(_MD("interpolate", "offset"), &ColorRamp::get_color_at_offset);
- ObjectTypeDB::bind_method(_MD("add_point","offset","color"),&ColorRamp::add_point);
- ObjectTypeDB::bind_method(_MD("remove_point","offset","color"),&ColorRamp::remove_point);
-
- ObjectTypeDB::bind_method(_MD("set_offset","point","offset"),&ColorRamp::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset","point"),&ColorRamp::get_offset);
-
- ObjectTypeDB::bind_method(_MD("set_color","point","color"),&ColorRamp::set_color);
- ObjectTypeDB::bind_method(_MD("get_color","point"),&ColorRamp::get_color);
-
- ObjectTypeDB::bind_method(_MD("interpolate","offset"),&ColorRamp::get_color_at_offset);
+ ObjectTypeDB::bind_method(_MD("get_point_count"), &ColorRamp::get_points_count);
- ObjectTypeDB::bind_method(_MD("get_point_count"),&ColorRamp::get_points_count);
+ ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS, "offsets"), &ColorRamp::set_offsets);
+ ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS), &ColorRamp::get_offsets);
- ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
- ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
+ ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_COLORS, "colors"), &ColorRamp::set_colors);
+ ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_COLORS), &ColorRamp::get_colors);
- ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_COLORS,"colors"),&ColorRamp::set_colors);
- ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_COLORS),&ColorRamp::get_colors);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"offsets"),_SCS(COLOR_RAMP_SET_OFFSETS),_SCS(COLOR_RAMP_GET_OFFSETS) );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"colors"),_SCS(COLOR_RAMP_SET_COLORS),_SCS(COLOR_RAMP_GET_COLORS) );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "offsets"), _SCS(COLOR_RAMP_SET_OFFSETS), _SCS(COLOR_RAMP_GET_OFFSETS));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "colors"), _SCS(COLOR_RAMP_SET_COLORS), _SCS(COLOR_RAMP_GET_COLORS));
}
Vector<float> ColorRamp::get_offsets() const {
Vector<float> offsets;
offsets.resize(points.size());
- for(int i = 0; i < points.size(); i++)
- {
+ for (int i = 0; i < points.size(); i++) {
offsets[i] = points[i].offset;
}
return offsets;
@@ -90,74 +84,69 @@ Vector<float> ColorRamp::get_offsets() const {
Vector<Color> ColorRamp::get_colors() const {
Vector<Color> colors;
colors.resize(points.size());
- for(int i = 0; i < points.size(); i++)
- {
+ for (int i = 0; i < points.size(); i++) {
colors[i] = points[i].color;
}
return colors;
}
-void ColorRamp::set_offsets(const Vector<float>& p_offsets) {
+void ColorRamp::set_offsets(const Vector<float> &p_offsets) {
points.resize(p_offsets.size());
- for(int i = 0; i < points.size(); i++)
- {
+ for (int i = 0; i < points.size(); i++) {
points[i].offset = p_offsets[i];
}
is_sorted = false;
}
-void ColorRamp::set_colors(const Vector<Color>& p_colors) {
- if(points.size()<p_colors.size())
+void ColorRamp::set_colors(const Vector<Color> &p_colors) {
+ if (points.size() < p_colors.size())
is_sorted = false;
points.resize(p_colors.size());
- for(int i = 0; i < points.size(); i++)
- {
+ for (int i = 0; i < points.size(); i++) {
points[i].color = p_colors[i];
}
}
-Vector<ColorRamp::Point>& ColorRamp::get_points() {
+Vector<ColorRamp::Point> &ColorRamp::get_points() {
return points;
}
-void ColorRamp::add_point(float p_offset, const Color& p_color) {
+void ColorRamp::add_point(float p_offset, const Color &p_color) {
Point p;
- p.offset=p_offset;
- p.color=p_color;
- is_sorted=false;
+ p.offset = p_offset;
+ p.color = p_color;
+ is_sorted = false;
points.push_back(p);
-
}
void ColorRamp::remove_point(int p_index) {
- ERR_FAIL_INDEX(p_index,points.size());
- ERR_FAIL_COND(points.size()<=2);
+ ERR_FAIL_INDEX(p_index, points.size());
+ ERR_FAIL_COND(points.size() <= 2);
points.remove(p_index);
}
-void ColorRamp::set_points(Vector<ColorRamp::Point>& p_points) {
+void ColorRamp::set_points(Vector<ColorRamp::Point> &p_points) {
points = p_points;
is_sorted = false;
}
void ColorRamp::set_offset(int pos, const float offset) {
- if(points.size() <= pos)
+ if (points.size() <= pos)
points.resize(pos + 1);
points[pos].offset = offset;
is_sorted = false;
}
float ColorRamp::get_offset(int pos) const {
- if(points.size() > pos)
+ if (points.size() > pos)
return points[pos].offset;
- return 0; //TODO: Maybe throw some error instead?
+ return 0; //TODO: Maybe throw some error instead?
}
-void ColorRamp::set_color(int pos, const Color& color) {
- if(points.size() <= pos)
- {
+void ColorRamp::set_color(int pos, const Color &color) {
+ if (points.size() <= pos) {
points.resize(pos + 1);
is_sorted = false;
}
@@ -165,9 +154,9 @@ void ColorRamp::set_color(int pos, const Color& color) {
}
Color ColorRamp::get_color(int pos) const {
- if(points.size() > pos)
+ if (points.size() > pos)
return points[pos].color;
- return Color(0,0,0,1); //TODO: Maybe throw some error instead?
+ return Color(0, 0, 0, 1); //TODO: Maybe throw some error instead?
}
int ColorRamp::get_points_count() const {
diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h
index 7908956ef..ec978ed7f 100644
--- a/scene/resources/color_ramp.h
+++ b/scene/resources/color_ramp.h
@@ -31,17 +31,17 @@
#include "resource.h"
-class ColorRamp: public Resource {
- OBJ_TYPE( ColorRamp, Resource );
- OBJ_SAVE_TYPE( ColorRamp );
+class ColorRamp : public Resource {
+ OBJ_TYPE(ColorRamp, Resource);
+ OBJ_SAVE_TYPE(ColorRamp);
public:
struct Point {
float offset;
Color color;
- bool operator<(const Point& p_ponit) const {
- return offset<p_ponit.offset;
+ bool operator<(const Point &p_ponit) const {
+ return offset < p_ponit.offset;
}
};
@@ -56,47 +56,45 @@ public:
ColorRamp();
virtual ~ColorRamp();
- void add_point(float p_offset, const Color& p_color);
+ void add_point(float p_offset, const Color &p_color);
void remove_point(int p_index);
- void set_points(Vector<Point>& points);
- Vector<Point>& get_points();
+ void set_points(Vector<Point> &points);
+ Vector<Point> &get_points();
void set_offset(int pos, const float offset);
float get_offset(int pos) const;
- void set_color(int pos, const Color& color);
+ void set_color(int pos, const Color &color);
Color get_color(int pos) const;
- void set_offsets(const Vector<float>& offsets);
+ void set_offsets(const Vector<float> &offsets);
Vector<float> get_offsets() const;
- void set_colors(const Vector<Color>& colors);
+ void set_colors(const Vector<Color> &colors);
Vector<Color> get_colors() const;
_FORCE_INLINE_ Color get_color_at_offset(float p_offset) {
if (points.empty())
- return Color(0,0,0,1);
+ return Color(0, 0, 0, 1);
- if(!is_sorted)
- {
+ if (!is_sorted) {
points.sort();
is_sorted = true;
}
//binary search
int low = 0;
- int high = points.size() -1;
+ int high = points.size() - 1;
int middle;
- while( low <= high )
- {
- middle = ( low + high ) / 2;
- Point& point = points[middle];
- if( point.offset > p_offset ) {
+ while (low <= high) {
+ middle = (low + high) / 2;
+ Point &point = points[middle];
+ if (point.offset > p_offset) {
high = middle - 1; //search low end of array
- } else if ( point.offset < p_offset) {
+ } else if (point.offset < p_offset) {
low = middle + 1; //search high end of array
} else {
return point.color;
@@ -104,19 +102,18 @@ public:
}
//return interpolated value
- if (points[middle].offset>p_offset)
- {
+ if (points[middle].offset > p_offset) {
middle--;
}
- int first=middle;
- int second=middle+1;
- if(second>=points.size())
- return points[points.size()-1].color;
- if(first<0)
+ int first = middle;
+ int second = middle + 1;
+ if (second >= points.size())
+ return points[points.size() - 1].color;
+ if (first < 0)
return points[0].color;
- Point& pointFirst = points[first];
- Point& pointSecond = points[second];
- return pointFirst.color.linear_interpolate(pointSecond.color, (p_offset-pointFirst.offset)/(pointSecond.offset - pointFirst.offset));
+ Point &pointFirst = points[first];
+ Point &pointSecond = points[second];
+ return pointFirst.color.linear_interpolate(pointSecond.color, (p_offset - pointFirst.offset) / (pointSecond.offset - pointFirst.offset));
}
int get_points_count() const;
diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape.cpp
index 0589a0928..da2ba54d0 100644
--- a/scene/resources/concave_polygon_shape.cpp
+++ b/scene/resources/concave_polygon_shape.cpp
@@ -34,87 +34,79 @@ Vector<Vector3> ConcavePolygonShape::_gen_debug_mesh_lines() {
Set<DrawEdge> edges;
- DVector<Vector3> data=get_faces();
- int datalen=data.size();
- ERR_FAIL_COND_V( (datalen%3)!=0,Vector<Vector3>() );
+ DVector<Vector3> data = get_faces();
+ int datalen = data.size();
+ ERR_FAIL_COND_V((datalen % 3) != 0, Vector<Vector3>());
- DVector<Vector3>::Read r=data.read();
+ DVector<Vector3>::Read r = data.read();
- for(int i=0;i<datalen;i+=3) {
+ for (int i = 0; i < datalen; i += 3) {
- for(int j=0;j<3;j++) {
+ for (int j = 0; j < 3; j++) {
- DrawEdge de(r[i+j],r[i+((j+1)%3)]);
+ DrawEdge de(r[i + j], r[i + ((j + 1) % 3)]);
edges.insert(de);
}
-
}
Vector<Vector3> points;
- points.resize(edges.size()*2);
- int idx=0;
- for (Set<DrawEdge>::Element*E=edges.front();E;E=E->next()) {
+ points.resize(edges.size() * 2);
+ int idx = 0;
+ for (Set<DrawEdge>::Element *E = edges.front(); E; E = E->next()) {
- points[idx+0]=E->get().a;
- points[idx+1]=E->get().b;
- idx+=2;
+ points[idx + 0] = E->get().a;
+ points[idx + 1] = E->get().b;
+ idx += 2;
}
return points;
-
}
-bool ConcavePolygonShape::_set(const StringName& p_name, const Variant& p_value) {
+bool ConcavePolygonShape::_set(const StringName &p_name, const Variant &p_value) {
- if (p_name=="data")
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),p_value);
+ if (p_name == "data")
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_value);
else
return false;
return true;
-
}
-bool ConcavePolygonShape::_get(const StringName& p_name,Variant &r_ret) const {
+bool ConcavePolygonShape::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name=="data")
- r_ret=PhysicsServer::get_singleton()->shape_get_data(get_shape());
+ if (p_name == "data")
+ r_ret = PhysicsServer::get_singleton()->shape_get_data(get_shape());
else
return false;
return true;
-
}
-void ConcavePolygonShape::_get_property_list( List<PropertyInfo> *p_list) const {
+void ConcavePolygonShape::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back( PropertyInfo(Variant::ARRAY,"data") );
+ p_list->push_back(PropertyInfo(Variant::ARRAY, "data"));
}
-
void ConcavePolygonShape::_update_shape() {
-
}
-void ConcavePolygonShape::set_faces(const DVector<Vector3>& p_faces) {
+void ConcavePolygonShape::set_faces(const DVector<Vector3> &p_faces) {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),p_faces);
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), p_faces);
notify_change_to_owners();
}
DVector<Vector3> ConcavePolygonShape::get_faces() const {
return PhysicsServer::get_singleton()->shape_get_data(get_shape());
-
}
-
-
void ConcavePolygonShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_faces","faces"),&ConcavePolygonShape::set_faces);
- ObjectTypeDB::bind_method(_MD("get_faces"),&ConcavePolygonShape::get_faces);
+ ObjectTypeDB::bind_method(_MD("set_faces", "faces"), &ConcavePolygonShape::set_faces);
+ ObjectTypeDB::bind_method(_MD("get_faces"), &ConcavePolygonShape::get_faces);
}
-ConcavePolygonShape::ConcavePolygonShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) {
+ConcavePolygonShape::ConcavePolygonShape()
+ : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) {
//set_planes(Vector3(1,1,1));
}
diff --git a/scene/resources/concave_polygon_shape.h b/scene/resources/concave_polygon_shape.h
index b4c07f189..74b86fa24 100644
--- a/scene/resources/concave_polygon_shape.h
+++ b/scene/resources/concave_polygon_shape.h
@@ -33,44 +33,41 @@
class ConcavePolygonShape : public Shape {
- OBJ_TYPE(ConcavePolygonShape,Shape);
+ OBJ_TYPE(ConcavePolygonShape, Shape);
struct DrawEdge {
Vector3 a;
Vector3 b;
- bool operator<(const DrawEdge& p_edge) const {
- if (a==p_edge.a)
- return b<p_edge.b;
+ bool operator<(const DrawEdge &p_edge) const {
+ if (a == p_edge.a)
+ return b < p_edge.b;
else
- return a<p_edge.a;
+ return a < p_edge.a;
}
- DrawEdge(const Vector3& p_a=Vector3(),const Vector3& p_b=Vector3()) {
- a=p_a;
- b=p_b;
- if (a<b) {
- SWAP(a,b);
+ DrawEdge(const Vector3 &p_a = Vector3(), const Vector3 &p_b = Vector3()) {
+ a = p_a;
+ b = p_b;
+ if (a < b) {
+ SWAP(a, b);
}
}
};
protected:
-
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
virtual void _update_shape();
virtual Vector<Vector3> _gen_debug_mesh_lines();
-public:
- void set_faces(const DVector<Vector3>& p_faces);
+public:
+ void set_faces(const DVector<Vector3> &p_faces);
DVector<Vector3> get_faces() const;
-
ConcavePolygonShape();
};
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index 4b16e924c..466cb6f30 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -31,9 +31,9 @@
#include "servers/physics_2d_server.h"
#include "servers/visual_server.h"
-void ConcavePolygonShape2D::set_segments(const DVector<Vector2>& p_segments) {
+void ConcavePolygonShape2D::set_segments(const DVector<Vector2> &p_segments) {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),p_segments);
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), p_segments);
emit_changed();
}
@@ -42,55 +42,47 @@ DVector<Vector2> ConcavePolygonShape2D::get_segments() const {
return Physics2DServer::get_singleton()->shape_get_data(get_rid());
}
-void ConcavePolygonShape2D::draw(const RID& p_to_rid,const Color& p_color) {
-
+void ConcavePolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
DVector<Vector2> s = get_segments();
- int len=s.size();
- if (len==0 || (len%2)==1)
+ int len = s.size();
+ if (len == 0 || (len % 2) == 1)
return;
DVector<Vector2>::Read r = s.read();
- for(int i=0;i<len;i+=2) {
- VisualServer::get_singleton()->canvas_item_add_line(p_to_rid,r[i],r[i+1],p_color,2);
+ for (int i = 0; i < len; i += 2) {
+ VisualServer::get_singleton()->canvas_item_add_line(p_to_rid, r[i], r[i + 1], p_color, 2);
}
-
}
Rect2 ConcavePolygonShape2D::get_rect() const {
-
DVector<Vector2> s = get_segments();
- int len=s.size();
- if (len==0)
+ int len = s.size();
+ if (len == 0)
return Rect2();
Rect2 rect;
DVector<Vector2>::Read r = s.read();
- for(int i=0;i<len;i++) {
- if (i==0)
- rect.pos=r[i];
+ for (int i = 0; i < len; i++) {
+ if (i == 0)
+ rect.pos = r[i];
else
rect.expand_to(r[i]);
}
return rect;
-
}
-
void ConcavePolygonShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_segments","segments"),&ConcavePolygonShape2D::set_segments);
- ObjectTypeDB::bind_method(_MD("get_segments"),&ConcavePolygonShape2D::get_segments);
-
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"segments"),_SCS("set_segments"),_SCS("get_segments") );
+ ObjectTypeDB::bind_method(_MD("set_segments", "segments"), &ConcavePolygonShape2D::set_segments);
+ ObjectTypeDB::bind_method(_MD("get_segments"), &ConcavePolygonShape2D::get_segments);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "segments"), _SCS("set_segments"), _SCS("get_segments"));
}
-ConcavePolygonShape2D::ConcavePolygonShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON)) {
-
+ConcavePolygonShape2D::ConcavePolygonShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON)) {
}
-
-
diff --git a/scene/resources/concave_polygon_shape_2d.h b/scene/resources/concave_polygon_shape_2d.h
index cda36a799..b94bff4cd 100644
--- a/scene/resources/concave_polygon_shape_2d.h
+++ b/scene/resources/concave_polygon_shape_2d.h
@@ -32,17 +32,17 @@
#include "scene/resources/shape_2d.h"
class ConcavePolygonShape2D : public Shape2D {
- OBJ_TYPE( ConcavePolygonShape2D, Shape2D );
-protected:
+ OBJ_TYPE(ConcavePolygonShape2D, Shape2D);
+protected:
static void _bind_methods();
-public:
- void set_segments(const DVector<Vector2>& p_segments);
+public:
+ void set_segments(const DVector<Vector2> &p_segments);
DVector<Vector2> get_segments() const;
- virtual void draw(const RID& p_to_rid,const Color& p_color);
- virtual Rect2 get_rect() const ;
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
+ virtual Rect2 get_rect() const;
ConcavePolygonShape2D();
};
diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp
index ed2557ac7..5a27c66e8 100644
--- a/scene/resources/convex_polygon_shape.cpp
+++ b/scene/resources/convex_polygon_shape.cpp
@@ -27,46 +27,42 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "convex_polygon_shape.h"
-#include "servers/physics_server.h"
#include "quick_hull.h"
+#include "servers/physics_server.h"
Vector<Vector3> ConvexPolygonShape::_gen_debug_mesh_lines() {
DVector<Vector3> points = get_points();
- if (points.size()>3) {
+ if (points.size() > 3) {
QuickHull qh;
Vector<Vector3> varr = Variant(points);
Geometry::MeshData md;
- Error err = qh.build(varr,md);
- if (err==OK) {
+ Error err = qh.build(varr, md);
+ if (err == OK) {
Vector<Vector3> lines;
- lines.resize(md.edges.size()*2);
- for(int i=0;i<md.edges.size();i++) {
- lines[i*2+0]=md.vertices[md.edges[i].a];
- lines[i*2+1]=md.vertices[md.edges[i].b];
+ lines.resize(md.edges.size() * 2);
+ for (int i = 0; i < md.edges.size(); i++) {
+ lines[i * 2 + 0] = md.vertices[md.edges[i].a];
+ lines[i * 2 + 1] = md.vertices[md.edges[i].b];
}
return lines;
-
-
}
-
}
return Vector<Vector3>();
}
-
void ConvexPolygonShape::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),points);
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), points);
emit_changed();
}
-void ConvexPolygonShape::set_points(const DVector<Vector3>& p_points) {
+void ConvexPolygonShape::set_points(const DVector<Vector3> &p_points) {
- points=p_points;
+ points = p_points;
_update_shape();
notify_change_to_owners();
}
@@ -76,17 +72,16 @@ DVector<Vector3> ConvexPolygonShape::get_points() const {
return points;
}
-
void ConvexPolygonShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_points","points"),&ConvexPolygonShape::set_points);
- ObjectTypeDB::bind_method(_MD("get_points"),&ConvexPolygonShape::get_points);
-
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"points"), _SCS("set_points"), _SCS("get_points") );
+ ObjectTypeDB::bind_method(_MD("set_points", "points"), &ConvexPolygonShape::set_points);
+ ObjectTypeDB::bind_method(_MD("get_points"), &ConvexPolygonShape::get_points);
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "points"), _SCS("set_points"), _SCS("get_points"));
}
-ConvexPolygonShape::ConvexPolygonShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON)) {
+ConvexPolygonShape::ConvexPolygonShape()
+ : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON)) {
//set_points(Vector3(1,1,1));
}
diff --git a/scene/resources/convex_polygon_shape.h b/scene/resources/convex_polygon_shape.h
index 33c60768a..bc7c0bbbb 100644
--- a/scene/resources/convex_polygon_shape.h
+++ b/scene/resources/convex_polygon_shape.h
@@ -33,19 +33,18 @@
class ConvexPolygonShape : public Shape {
- OBJ_TYPE(ConvexPolygonShape,Shape);
+ OBJ_TYPE(ConvexPolygonShape, Shape);
DVector<Vector3> points;
protected:
-
static void _bind_methods();
virtual void _update_shape();
virtual Vector<Vector3> _gen_debug_mesh_lines();
-public:
- void set_points(const DVector<Vector3>& p_points);
+public:
+ void set_points(const DVector<Vector3> &p_points);
DVector<Vector3> get_points() const;
ConvexPolygonShape();
diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp
index 4550ea331..9a7dbced2 100644
--- a/scene/resources/convex_polygon_shape_2d.cpp
+++ b/scene/resources/convex_polygon_shape_2d.cpp
@@ -28,28 +28,26 @@
/*************************************************************************/
#include "convex_polygon_shape_2d.h"
+#include "geometry.h"
#include "servers/physics_2d_server.h"
#include "servers/visual_server.h"
-#include "geometry.h"
void ConvexPolygonShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),points);
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), points);
emit_changed();
-
}
-void ConvexPolygonShape2D::set_point_cloud(const Vector<Vector2>& p_points) {
+void ConvexPolygonShape2D::set_point_cloud(const Vector<Vector2> &p_points) {
-
- Vector<Point2> hull=Geometry::convex_hull_2d(p_points);
- ERR_FAIL_COND(hull.size()<3);
+ Vector<Point2> hull = Geometry::convex_hull_2d(p_points);
+ ERR_FAIL_COND(hull.size() < 3);
set_points(hull);
}
-void ConvexPolygonShape2D::set_points(const Vector<Vector2>& p_points) {
+void ConvexPolygonShape2D::set_points(const Vector<Vector2> &p_points) {
- points=p_points;
+ points = p_points;
_update_shape();
}
@@ -58,48 +56,41 @@ Vector<Vector2> ConvexPolygonShape2D::get_points() const {
return points;
}
-
void ConvexPolygonShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_point_cloud","point_cloud"),&ConvexPolygonShape2D::set_point_cloud);
- ObjectTypeDB::bind_method(_MD("set_points","points"),&ConvexPolygonShape2D::set_points);
- ObjectTypeDB::bind_method(_MD("get_points"),&ConvexPolygonShape2D::get_points);
-
-
-
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2_ARRAY,"points"),_SCS("set_points"),_SCS("get_points") );
+ ObjectTypeDB::bind_method(_MD("set_point_cloud", "point_cloud"), &ConvexPolygonShape2D::set_point_cloud);
+ ObjectTypeDB::bind_method(_MD("set_points", "points"), &ConvexPolygonShape2D::set_points);
+ ObjectTypeDB::bind_method(_MD("get_points"), &ConvexPolygonShape2D::get_points);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2_ARRAY, "points"), _SCS("set_points"), _SCS("get_points"));
}
-void ConvexPolygonShape2D::draw(const RID& p_to_rid,const Color& p_color) {
-
+void ConvexPolygonShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector<Color> col;
col.push_back(p_color);
- VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid,points,col);
+ VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col);
}
-Rect2 ConvexPolygonShape2D::get_rect() const {
-
+Rect2 ConvexPolygonShape2D::get_rect() const {
Rect2 rect;
- for(int i=0;i<points.size();i++) {
- if (i==0)
- rect.pos=points[i];
+ for (int i = 0; i < points.size(); i++) {
+ if (i == 0)
+ rect.pos = points[i];
else
rect.expand_to(points[i]);
}
return rect;
-
}
-ConvexPolygonShape2D::ConvexPolygonShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON)) {
-
+ConvexPolygonShape2D::ConvexPolygonShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON)) {
- int pcount =3;
- for(int i=0;i<pcount;i++)
- points.push_back(Vector2(Math::sin(i*Math_PI*2/pcount),-Math::cos(i*Math_PI*2/pcount))*10);
+ int pcount = 3;
+ for (int i = 0; i < pcount; i++)
+ points.push_back(Vector2(Math::sin(i * Math_PI * 2 / pcount), -Math::cos(i * Math_PI * 2 / pcount)) * 10);
_update_shape();
}
diff --git a/scene/resources/convex_polygon_shape_2d.h b/scene/resources/convex_polygon_shape_2d.h
index 886f4eab7..bb55570cb 100644
--- a/scene/resources/convex_polygon_shape_2d.h
+++ b/scene/resources/convex_polygon_shape_2d.h
@@ -32,21 +32,21 @@
#include "scene/resources/shape_2d.h"
class ConvexPolygonShape2D : public Shape2D {
- OBJ_TYPE( ConvexPolygonShape2D, Shape2D );
+ OBJ_TYPE(ConvexPolygonShape2D, Shape2D);
Vector<Vector2> points;
void _update_shape();
-protected:
+protected:
static void _bind_methods();
-public:
- void set_point_cloud(const Vector<Vector2>& p_points);
- void set_points(const Vector<Vector2>& p_points);
+public:
+ void set_point_cloud(const Vector<Vector2> &p_points);
+ void set_points(const Vector<Vector2> &p_points);
Vector<Vector2> get_points() const;
- virtual void draw(const RID& p_to_rid,const Color& p_color);
- virtual Rect2 get_rect() const ;
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
+ virtual Rect2 get_rect() const;
ConvexPolygonShape2D();
};
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp
index 537f93c0f..87474af6a 100644
--- a/scene/resources/curve.cpp
+++ b/scene/resources/curve.cpp
@@ -29,19 +29,16 @@
#include "curve.h"
#include "core_string_names.h"
-template<class T>
+template <class T>
static _FORCE_INLINE_ T _bezier_interp(real_t t, T start, T control_1, T control_2, T end) {
- /* Formula from Wikipedia article on Bezier curves. */
+ /* Formula from Wikipedia article on Bezier curves. */
real_t omt = (1.0 - t);
- real_t omt2 = omt*omt;
- real_t omt3 = omt2*omt;
- real_t t2 = t*t;
- real_t t3 = t2*t;
+ real_t omt2 = omt * omt;
+ real_t omt3 = omt2 * omt;
+ real_t t2 = t * t;
+ real_t t3 = t2 * t;
- return start * omt3
- + control_1 * omt2 * t * 3.0
- + control_2 * omt * t2 * 3.0
- + end * t3;
+ return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3;
}
#if 0
@@ -382,92 +379,80 @@ Curve2D::Curve2D()
#endif
-
-
-
int Curve2D::get_point_count() const {
return points.size();
}
-void Curve2D::add_point(const Vector2& p_pos, const Vector2& p_in, const Vector2& p_out,int p_atpos) {
+void Curve2D::add_point(const Vector2 &p_pos, const Vector2 &p_in, const Vector2 &p_out, int p_atpos) {
Point n;
- n.pos=p_pos;
- n.in=p_in;
- n.out=p_out;
- if (p_atpos>=0 && p_atpos<points.size())
- points.insert(p_atpos,n);
+ n.pos = p_pos;
+ n.in = p_in;
+ n.out = p_out;
+ if (p_atpos >= 0 && p_atpos < points.size())
+ points.insert(p_atpos, n);
else
points.push_back(n);
-
- baked_cache_dirty=true;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-void Curve2D::set_point_pos(int p_index, const Vector2& p_pos) {
+void Curve2D::set_point_pos(int p_index, const Vector2 &p_pos) {
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
- points[p_index].pos=p_pos;
- baked_cache_dirty=true;
+ points[p_index].pos = p_pos;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
Vector2 Curve2D::get_point_pos(int p_index) const {
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector2());
+ ERR_FAIL_INDEX_V(p_index, points.size(), Vector2());
return points[p_index].pos;
-
}
+void Curve2D::set_point_in(int p_index, const Vector2 &p_in) {
-void Curve2D::set_point_in(int p_index, const Vector2& p_in) {
-
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
- points[p_index].in=p_in;
- baked_cache_dirty=true;
+ points[p_index].in = p_in;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
Vector2 Curve2D::get_point_in(int p_index) const {
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector2());
+ ERR_FAIL_INDEX_V(p_index, points.size(), Vector2());
return points[p_index].in;
-
}
-void Curve2D::set_point_out(int p_index, const Vector2& p_out) {
+void Curve2D::set_point_out(int p_index, const Vector2 &p_out) {
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
- points[p_index].out=p_out;
- baked_cache_dirty=true;
+ points[p_index].out = p_out;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
Vector2 Curve2D::get_point_out(int p_index) const {
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector2());
+ ERR_FAIL_INDEX_V(p_index, points.size(), Vector2());
return points[p_index].out;
-
}
-
void Curve2D::remove_point(int p_index) {
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
points.remove(p_index);
- baked_cache_dirty=true;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
void Curve2D::clear_points() {
if (!points.empty()) {
points.clear();
- baked_cache_dirty=true;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
}
@@ -475,151 +460,138 @@ void Curve2D::clear_points() {
Vector2 Curve2D::interpolate(int p_index, float p_offset) const {
int pc = points.size();
- ERR_FAIL_COND_V(pc==0,Vector2());
+ ERR_FAIL_COND_V(pc == 0, Vector2());
- if (p_index >= pc-1)
- return points[pc-1].pos;
- else if (p_index<0)
+ if (p_index >= pc - 1)
+ return points[pc - 1].pos;
+ else if (p_index < 0)
return points[0].pos;
Vector2 p0 = points[p_index].pos;
- Vector2 p1 = p0+points[p_index].out;
- Vector2 p3 = points[p_index+1].pos;
- Vector2 p2 = p3+points[p_index+1].in;
+ Vector2 p1 = p0 + points[p_index].out;
+ Vector2 p3 = points[p_index + 1].pos;
+ Vector2 p2 = p3 + points[p_index + 1].in;
- return _bezier_interp(p_offset,p0,p1,p2,p3);
+ return _bezier_interp(p_offset, p0, p1, p2, p3);
}
Vector2 Curve2D::interpolatef(real_t p_findex) const {
+ if (p_findex < 0)
+ p_findex = 0;
+ else if (p_findex >= points.size())
+ p_findex = points.size();
- if (p_findex<0)
- p_findex=0;
- else if (p_findex>=points.size())
- p_findex=points.size();
-
- return interpolate((int)p_findex,Math::fmod(p_findex,1.0));
-
+ return interpolate((int)p_findex, Math::fmod(p_findex, 1.0));
}
+void Curve2D::_bake_segment2d(Map<float, Vector2> &r_bake, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_max_depth, float p_tol) const {
-void Curve2D::_bake_segment2d(Map<float,Vector2>& r_bake, float p_begin, float p_end,const Vector2& p_a,const Vector2& p_out,const Vector2& p_b, const Vector2& p_in,int p_depth,int p_max_depth,float p_tol) const {
-
- float mp = p_begin+(p_end-p_begin)*0.5;
- Vector2 beg = _bezier_interp(p_begin,p_a,p_a+p_out,p_b+p_in,p_b);
- Vector2 mid = _bezier_interp(mp,p_a,p_a+p_out,p_b+p_in,p_b);
- Vector2 end = _bezier_interp(p_end,p_a,p_a+p_out,p_b+p_in,p_b);
+ float mp = p_begin + (p_end - p_begin) * 0.5;
+ Vector2 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b);
+ Vector2 mid = _bezier_interp(mp, p_a, p_a + p_out, p_b + p_in, p_b);
+ Vector2 end = _bezier_interp(p_end, p_a, p_a + p_out, p_b + p_in, p_b);
- Vector2 na = (mid-beg).normalized();
- Vector2 nb = (end-mid).normalized();
+ Vector2 na = (mid - beg).normalized();
+ Vector2 nb = (end - mid).normalized();
float dp = na.dot(nb);
- if (dp<Math::cos(Math::deg2rad(p_tol))) {
+ if (dp < Math::cos(Math::deg2rad(p_tol))) {
- r_bake[mp]=mid;
+ r_bake[mp] = mid;
}
- if (p_depth<p_max_depth) {
- _bake_segment2d(r_bake,p_begin,mp,p_a,p_out,p_b,p_in,p_depth+1,p_max_depth,p_tol);
- _bake_segment2d(r_bake,mp,p_end,p_a,p_out,p_b,p_in,p_depth+1,p_max_depth,p_tol);
+ if (p_depth < p_max_depth) {
+ _bake_segment2d(r_bake, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_max_depth, p_tol);
+ _bake_segment2d(r_bake, mp, p_end, p_a, p_out, p_b, p_in, p_depth + 1, p_max_depth, p_tol);
}
}
-
-
void Curve2D::_bake() const {
if (!baked_cache_dirty)
return;
- baked_max_ofs=0;
- baked_cache_dirty=false;
+ baked_max_ofs = 0;
+ baked_cache_dirty = false;
- if (points.size()==0) {
+ if (points.size() == 0) {
baked_point_cache.resize(0);
return;
}
- if (points.size()==1) {
+ if (points.size() == 1) {
baked_point_cache.resize(1);
- baked_point_cache.set(0,points[0].pos);
+ baked_point_cache.set(0, points[0].pos);
return;
}
-
- Vector2 pos=points[0].pos;
+ Vector2 pos = points[0].pos;
List<Vector2> pointlist;
pointlist.push_back(pos); //start always from origin
- for(int i=0;i<points.size()-1;i++) {
+ for (int i = 0; i < points.size() - 1; i++) {
float step = 0.1; // at least 10 substeps ought to be enough?
float p = 0;
- while(p<1.0) {
-
- float np=p+step;
- if (np>1.0)
- np=1.0;
+ while (p < 1.0) {
+ float np = p + step;
+ if (np > 1.0)
+ np = 1.0;
- Vector2 npp = _bezier_interp(np, points[i].pos,points[i].pos+points[i].out,points[i+1].pos+points[i+1].in,points[i+1].pos);
+ Vector2 npp = _bezier_interp(np, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos);
float d = pos.distance_to(npp);
- if (d>bake_interval) {
+ if (d > bake_interval) {
// OK! between P and NP there _has_ to be Something, let's go searching!
int iterations = 10; //lots of detail!
float low = p;
float hi = np;
- float mid = low+(hi-low)*0.5;
+ float mid = low + (hi - low) * 0.5;
- for(int j=0;j<iterations;j++) {
+ for (int j = 0; j < iterations; j++) {
-
- npp = _bezier_interp(mid, points[i].pos,points[i].pos+points[i].out,points[i+1].pos+points[i+1].in,points[i+1].pos);
+ npp = _bezier_interp(mid, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos);
d = pos.distance_to(npp);
if (bake_interval < d)
- hi=mid;
+ hi = mid;
else
- low=mid;
- mid = low+(hi-low)*0.5;
-
+ low = mid;
+ mid = low + (hi - low) * 0.5;
}
- pos=npp;
- p=mid;
+ pos = npp;
+ p = mid;
pointlist.push_back(pos);
} else {
- p=np;
+ p = np;
}
-
}
}
- Vector2 lastpos = points[points.size()-1].pos;
-
+ Vector2 lastpos = points[points.size() - 1].pos;
float rem = pos.distance_to(lastpos);
- baked_max_ofs=(pointlist.size()-1)*bake_interval+rem;
+ baked_max_ofs = (pointlist.size() - 1) * bake_interval + rem;
pointlist.push_back(lastpos);
baked_point_cache.resize(pointlist.size());
Vector2Array::Write w = baked_point_cache.write();
- int idx=0;
-
+ int idx = 0;
- for(List<Vector2>::Element *E=pointlist.front();E;E=E->next()) {
+ for (List<Vector2>::Element *E = pointlist.front(); E; E = E->next()) {
- w[idx]=E->get();
+ w[idx] = E->get();
idx++;
}
-
}
float Curve2D::get_baked_length() const {
@@ -629,51 +601,50 @@ float Curve2D::get_baked_length() const {
return baked_max_ofs;
}
-Vector2 Curve2D::interpolate_baked(float p_offset,bool p_cubic) const{
+Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const {
if (baked_cache_dirty)
_bake();
//validate//
int pc = baked_point_cache.size();
- if (pc==0) {
+ if (pc == 0) {
ERR_EXPLAIN("No points in Curve2D");
- ERR_FAIL_COND_V(pc==0,Vector2());
+ ERR_FAIL_COND_V(pc == 0, Vector2());
}
- if (pc==1)
+ if (pc == 1)
return baked_point_cache.get(0);
- int bpc=baked_point_cache.size();
+ int bpc = baked_point_cache.size();
Vector2Array::Read r = baked_point_cache.read();
- if (p_offset<0)
+ if (p_offset < 0)
return r[0];
- if (p_offset>=baked_max_ofs)
- return r[bpc-1];
+ if (p_offset >= baked_max_ofs)
+ return r[bpc - 1];
- int idx = Math::floor((double)p_offset/(double)bake_interval);
- float frac = Math::fmod(p_offset,bake_interval);
+ int idx = Math::floor((double)p_offset / (double)bake_interval);
+ float frac = Math::fmod(p_offset, bake_interval);
- if (idx>=bpc-1) {
- return r[bpc-1];
- } else if (idx==bpc-2) {
- frac/=Math::fmod(baked_max_ofs,bake_interval);
+ if (idx >= bpc - 1) {
+ return r[bpc - 1];
+ } else if (idx == bpc - 2) {
+ frac /= Math::fmod(baked_max_ofs, bake_interval);
} else {
- frac/=bake_interval;
+ frac /= bake_interval;
}
if (p_cubic) {
- Vector2 pre = idx>0? r[idx-1] : r[idx];
- Vector2 post = (idx<(bpc-2))? r[idx+2] : r[idx+1];
- return r[idx].cubic_interpolate(r[idx+1],pre,post,frac);
+ Vector2 pre = idx > 0 ? r[idx - 1] : r[idx];
+ Vector2 post = (idx < (bpc - 2)) ? r[idx + 2] : r[idx + 1];
+ return r[idx].cubic_interpolate(r[idx + 1], pre, post, frac);
} else {
- return r[idx].linear_interpolate(r[idx+1],frac);
+ return r[idx].linear_interpolate(r[idx + 1], frac);
}
}
-
Vector2Array Curve2D::get_baked_points() const {
if (baked_cache_dirty)
@@ -682,16 +653,14 @@ Vector2Array Curve2D::get_baked_points() const {
return baked_point_cache;
}
+void Curve2D::set_bake_interval(float p_tolerance) {
-void Curve2D::set_bake_interval(float p_tolerance){
-
- bake_interval=p_tolerance;
- baked_cache_dirty=true;
+ bake_interval = p_tolerance;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
-float Curve2D::get_bake_interval() const{
+float Curve2D::get_bake_interval() const {
return bake_interval;
}
@@ -701,143 +670,125 @@ Dictionary Curve2D::_get_data() const {
Dictionary dc;
Vector2Array d;
- d.resize(points.size()*3);
+ d.resize(points.size() * 3);
Vector2Array::Write w = d.write();
+ for (int i = 0; i < points.size(); i++) {
- for(int i=0;i<points.size();i++) {
-
- w[i*3+0]=points[i].in;
- w[i*3+1]=points[i].out;
- w[i*3+2]=points[i].pos;
-
+ w[i * 3 + 0] = points[i].in;
+ w[i * 3 + 1] = points[i].out;
+ w[i * 3 + 2] = points[i].pos;
}
- w=Vector2Array::Write();
+ w = Vector2Array::Write();
- dc["points"]=d;
+ dc["points"] = d;
return dc;
}
-void Curve2D::_set_data(const Dictionary& p_data){
-
+void Curve2D::_set_data(const Dictionary &p_data) {
ERR_FAIL_COND(!p_data.has("points"));
- Vector2Array rp=p_data["points"];
+ Vector2Array rp = p_data["points"];
int pc = rp.size();
- ERR_FAIL_COND(pc%3!=0);
- points.resize(pc/3);
+ ERR_FAIL_COND(pc % 3 != 0);
+ points.resize(pc / 3);
Vector2Array::Read r = rp.read();
- for(int i=0;i<points.size();i++) {
+ for (int i = 0; i < points.size(); i++) {
- points[i].in=r[i*3+0];
- points[i].out=r[i*3+1];
- points[i].pos=r[i*3+2];
+ points[i].in = r[i * 3 + 0];
+ points[i].out = r[i * 3 + 1];
+ points[i].pos = r[i * 3 + 2];
}
- baked_cache_dirty=true;
-
+ baked_cache_dirty = true;
}
-
-Vector2Array Curve2D::tesselate(int p_max_stages,float p_tolerance) const {
+Vector2Array Curve2D::tesselate(int p_max_stages, float p_tolerance) const {
Vector2Array tess;
-
- if (points.size()==0) {
+ if (points.size() == 0) {
return tess;
}
- Vector< Map<float,Vector2> > midpoints;
+ Vector<Map<float, Vector2> > midpoints;
- midpoints.resize(points.size()-1);
+ midpoints.resize(points.size() - 1);
- int pc=1;
- for(int i=0;i<points.size()-1;i++) {
+ int pc = 1;
+ for (int i = 0; i < points.size() - 1; i++) {
- _bake_segment2d(midpoints[i],0,1,points[i].pos,points[i].out,points[i+1].pos,points[i+1].in,0,p_max_stages,p_tolerance);
+ _bake_segment2d(midpoints[i], 0, 1, points[i].pos, points[i].out, points[i + 1].pos, points[i + 1].in, 0, p_max_stages, p_tolerance);
pc++;
- pc+=midpoints[i].size();
-
+ pc += midpoints[i].size();
}
tess.resize(pc);
- Vector2Array::Write bpw=tess.write();
- bpw[0]=points[0].pos;
- int pidx=0;
+ Vector2Array::Write bpw = tess.write();
+ bpw[0] = points[0].pos;
+ int pidx = 0;
- for(int i=0;i<points.size()-1;i++) {
+ for (int i = 0; i < points.size() - 1; i++) {
- for(Map<float,Vector2>::Element *E=midpoints[i].front();E;E=E->next()) {
+ for (Map<float, Vector2>::Element *E = midpoints[i].front(); E; E = E->next()) {
pidx++;
bpw[pidx] = E->get();
}
pidx++;
- bpw[pidx] = points[i+1].pos;
-
+ bpw[pidx] = points[i + 1].pos;
}
- bpw=Vector2Array::Write ();
+ bpw = Vector2Array::Write();
return tess;
-
}
void Curve2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_point_count"),&Curve2D::get_point_count);
- ObjectTypeDB::bind_method(_MD("add_point","pos","in","out","atpos"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2()),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve2D::set_point_pos);
- ObjectTypeDB::bind_method(_MD("get_point_pos","idx"),&Curve2D::get_point_pos);
- ObjectTypeDB::bind_method(_MD("set_point_in","idx","pos"),&Curve2D::set_point_in);
- ObjectTypeDB::bind_method(_MD("get_point_in","idx"),&Curve2D::get_point_in);
- ObjectTypeDB::bind_method(_MD("set_point_out","idx","pos"),&Curve2D::set_point_out);
- ObjectTypeDB::bind_method(_MD("get_point_out","idx"),&Curve2D::get_point_out);
- ObjectTypeDB::bind_method(_MD("remove_point","idx"),&Curve2D::remove_point);
- ObjectTypeDB::bind_method(_MD("clear_points"),&Curve2D::clear_points);
- ObjectTypeDB::bind_method(_MD("interpolate","idx","t"),&Curve2D::interpolate);
- ObjectTypeDB::bind_method(_MD("interpolatef","fofs"),&Curve2D::interpolatef);
+ ObjectTypeDB::bind_method(_MD("get_point_count"), &Curve2D::get_point_count);
+ ObjectTypeDB::bind_method(_MD("add_point", "pos", "in", "out", "atpos"), &Curve2D::add_point, DEFVAL(Vector2()), DEFVAL(Vector2()), DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("set_point_pos", "idx", "pos"), &Curve2D::set_point_pos);
+ ObjectTypeDB::bind_method(_MD("get_point_pos", "idx"), &Curve2D::get_point_pos);
+ ObjectTypeDB::bind_method(_MD("set_point_in", "idx", "pos"), &Curve2D::set_point_in);
+ ObjectTypeDB::bind_method(_MD("get_point_in", "idx"), &Curve2D::get_point_in);
+ ObjectTypeDB::bind_method(_MD("set_point_out", "idx", "pos"), &Curve2D::set_point_out);
+ ObjectTypeDB::bind_method(_MD("get_point_out", "idx"), &Curve2D::get_point_out);
+ ObjectTypeDB::bind_method(_MD("remove_point", "idx"), &Curve2D::remove_point);
+ ObjectTypeDB::bind_method(_MD("clear_points"), &Curve2D::clear_points);
+ ObjectTypeDB::bind_method(_MD("interpolate", "idx", "t"), &Curve2D::interpolate);
+ ObjectTypeDB::bind_method(_MD("interpolatef", "fofs"), &Curve2D::interpolatef);
//ObjectTypeDB::bind_method(_MD("bake","subdivs"),&Curve2D::bake,DEFVAL(10));
- ObjectTypeDB::bind_method(_MD("set_bake_interval","distance"),&Curve2D::set_bake_interval);
- ObjectTypeDB::bind_method(_MD("get_bake_interval"),&Curve2D::get_bake_interval);
-
- ObjectTypeDB::bind_method(_MD("get_baked_length"),&Curve2D::get_baked_length);
- ObjectTypeDB::bind_method(_MD("interpolate_baked","offset","cubic"),&Curve2D::interpolate_baked,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_baked_points"),&Curve2D::get_baked_points);
- ObjectTypeDB::bind_method(_MD("tesselate","max_stages","tolerance_degrees"),&Curve2D::tesselate,DEFVAL(5),DEFVAL(4));
+ ObjectTypeDB::bind_method(_MD("set_bake_interval", "distance"), &Curve2D::set_bake_interval);
+ ObjectTypeDB::bind_method(_MD("get_bake_interval"), &Curve2D::get_bake_interval);
- ObjectTypeDB::bind_method(_MD("_get_data"),&Curve2D::_get_data);
- ObjectTypeDB::bind_method(_MD("_set_data"),&Curve2D::_set_data);
+ ObjectTypeDB::bind_method(_MD("get_baked_length"), &Curve2D::get_baked_length);
+ ObjectTypeDB::bind_method(_MD("interpolate_baked", "offset", "cubic"), &Curve2D::interpolate_baked, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_baked_points"), &Curve2D::get_baked_points);
+ ObjectTypeDB::bind_method(_MD("tesselate", "max_stages", "tolerance_degrees"), &Curve2D::tesselate, DEFVAL(5), DEFVAL(4));
+ ObjectTypeDB::bind_method(_MD("_get_data"), &Curve2D::_get_data);
+ ObjectTypeDB::bind_method(_MD("_set_data"), &Curve2D::_set_data);
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bake_interval",PROPERTY_HINT_RANGE,"0.01,512,0.01"), _SCS("set_bake_interval"),_SCS("get_bake_interval"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_interval", PROPERTY_HINT_RANGE, "0.01,512,0.01"), _SCS("set_bake_interval"), _SCS("get_bake_interval"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data"));
/*ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_out"), _SCS("set_points_out"),_SCS("get_points_out"));
ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_pos"), _SCS("set_points_pos"),_SCS("get_points_pos"));
*/
}
-
-
-
-Curve2D::Curve2D()
-{
- baked_cache_dirty=false;
- baked_max_ofs=0;
-/* add_point(Vector2(-1,0,0));
+Curve2D::Curve2D() {
+ baked_cache_dirty = false;
+ baked_max_ofs = 0;
+ /* add_point(Vector2(-1,0,0));
add_point(Vector2(0,2,0));
add_point(Vector2(0,3,5));*/
- bake_interval=5;
-
+ bake_interval = 5;
}
-
-
-
/***********************************************************************************/
/***********************************************************************************/
/***********************************************************************************/
@@ -849,93 +800,82 @@ int Curve3D::get_point_count() const {
return points.size();
}
-void Curve3D::add_point(const Vector3& p_pos, const Vector3& p_in, const Vector3& p_out,int p_atpos) {
+void Curve3D::add_point(const Vector3 &p_pos, const Vector3 &p_in, const Vector3 &p_out, int p_atpos) {
Point n;
- n.pos=p_pos;
- n.in=p_in;
- n.out=p_out;
- if (p_atpos>=0 && p_atpos<points.size())
- points.insert(p_atpos,n);
+ n.pos = p_pos;
+ n.in = p_in;
+ n.out = p_out;
+ if (p_atpos >= 0 && p_atpos < points.size())
+ points.insert(p_atpos, n);
else
points.push_back(n);
-
- baked_cache_dirty=true;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
-void Curve3D::set_point_pos(int p_index, const Vector3& p_pos) {
+void Curve3D::set_point_pos(int p_index, const Vector3 &p_pos) {
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
- points[p_index].pos=p_pos;
- baked_cache_dirty=true;
+ points[p_index].pos = p_pos;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
Vector3 Curve3D::get_point_pos(int p_index) const {
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector3());
+ ERR_FAIL_INDEX_V(p_index, points.size(), Vector3());
return points[p_index].pos;
-
}
void Curve3D::set_point_tilt(int p_index, float p_tilt) {
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
- points[p_index].tilt=p_tilt;
- baked_cache_dirty=true;
+ points[p_index].tilt = p_tilt;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
float Curve3D::get_point_tilt(int p_index) const {
- ERR_FAIL_INDEX_V(p_index,points.size(),0);
+ ERR_FAIL_INDEX_V(p_index, points.size(), 0);
return points[p_index].tilt;
-
}
+void Curve3D::set_point_in(int p_index, const Vector3 &p_in) {
-void Curve3D::set_point_in(int p_index, const Vector3& p_in) {
-
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
- points[p_index].in=p_in;
- baked_cache_dirty=true;
+ points[p_index].in = p_in;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
Vector3 Curve3D::get_point_in(int p_index) const {
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector3());
+ ERR_FAIL_INDEX_V(p_index, points.size(), Vector3());
return points[p_index].in;
-
}
-void Curve3D::set_point_out(int p_index, const Vector3& p_out) {
+void Curve3D::set_point_out(int p_index, const Vector3 &p_out) {
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
- points[p_index].out=p_out;
- baked_cache_dirty=true;
+ points[p_index].out = p_out;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
Vector3 Curve3D::get_point_out(int p_index) const {
- ERR_FAIL_INDEX_V(p_index,points.size(),Vector3());
+ ERR_FAIL_INDEX_V(p_index, points.size(), Vector3());
return points[p_index].out;
-
}
-
void Curve3D::remove_point(int p_index) {
- ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_INDEX(p_index, points.size());
points.remove(p_index);
- baked_cache_dirty=true;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
@@ -943,7 +883,7 @@ void Curve3D::clear_points() {
if (!points.empty()) {
points.clear();
- baked_cache_dirty=true;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
}
}
@@ -951,158 +891,147 @@ void Curve3D::clear_points() {
Vector3 Curve3D::interpolate(int p_index, float p_offset) const {
int pc = points.size();
- ERR_FAIL_COND_V(pc==0,Vector3());
+ ERR_FAIL_COND_V(pc == 0, Vector3());
- if (p_index >= pc-1)
- return points[pc-1].pos;
- else if (p_index<0)
+ if (p_index >= pc - 1)
+ return points[pc - 1].pos;
+ else if (p_index < 0)
return points[0].pos;
Vector3 p0 = points[p_index].pos;
- Vector3 p1 = p0+points[p_index].out;
- Vector3 p3 = points[p_index+1].pos;
- Vector3 p2 = p3+points[p_index+1].in;
+ Vector3 p1 = p0 + points[p_index].out;
+ Vector3 p3 = points[p_index + 1].pos;
+ Vector3 p2 = p3 + points[p_index + 1].in;
- return _bezier_interp(p_offset,p0,p1,p2,p3);
+ return _bezier_interp(p_offset, p0, p1, p2, p3);
}
Vector3 Curve3D::interpolatef(real_t p_findex) const {
+ if (p_findex < 0)
+ p_findex = 0;
+ else if (p_findex >= points.size())
+ p_findex = points.size();
- if (p_findex<0)
- p_findex=0;
- else if (p_findex>=points.size())
- p_findex=points.size();
-
- return interpolate((int)p_findex,Math::fmod(p_findex,1.0));
-
+ return interpolate((int)p_findex, Math::fmod(p_findex, 1.0));
}
+void Curve3D::_bake_segment3d(Map<float, Vector3> &r_bake, float p_begin, float p_end, const Vector3 &p_a, const Vector3 &p_out, const Vector3 &p_b, const Vector3 &p_in, int p_depth, int p_max_depth, float p_tol) const {
-void Curve3D::_bake_segment3d(Map<float,Vector3>& r_bake, float p_begin, float p_end,const Vector3& p_a,const Vector3& p_out,const Vector3& p_b, const Vector3& p_in,int p_depth,int p_max_depth,float p_tol) const {
+ float mp = p_begin + (p_end - p_begin) * 0.5;
+ Vector3 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b);
+ Vector3 mid = _bezier_interp(mp, p_a, p_a + p_out, p_b + p_in, p_b);
+ Vector3 end = _bezier_interp(p_end, p_a, p_a + p_out, p_b + p_in, p_b);
- float mp = p_begin+(p_end-p_begin)*0.5;
- Vector3 beg = _bezier_interp(p_begin,p_a,p_a+p_out,p_b+p_in,p_b);
- Vector3 mid = _bezier_interp(mp,p_a,p_a+p_out,p_b+p_in,p_b);
- Vector3 end = _bezier_interp(p_end,p_a,p_a+p_out,p_b+p_in,p_b);
-
- Vector3 na = (mid-beg).normalized();
- Vector3 nb = (end-mid).normalized();
+ Vector3 na = (mid - beg).normalized();
+ Vector3 nb = (end - mid).normalized();
float dp = na.dot(nb);
- if (dp<Math::cos(Math::deg2rad(p_tol))) {
+ if (dp < Math::cos(Math::deg2rad(p_tol))) {
- r_bake[mp]=mid;
+ r_bake[mp] = mid;
}
- if (p_depth<p_max_depth) {
- _bake_segment3d(r_bake,p_begin,mp,p_a,p_out,p_b,p_in,p_depth+1,p_max_depth,p_tol);
- _bake_segment3d(r_bake,mp,p_end,p_a,p_out,p_b,p_in,p_depth+1,p_max_depth,p_tol);
+ if (p_depth < p_max_depth) {
+ _bake_segment3d(r_bake, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_max_depth, p_tol);
+ _bake_segment3d(r_bake, mp, p_end, p_a, p_out, p_b, p_in, p_depth + 1, p_max_depth, p_tol);
}
}
-
-
void Curve3D::_bake() const {
if (!baked_cache_dirty)
return;
- baked_max_ofs=0;
- baked_cache_dirty=false;
+ baked_max_ofs = 0;
+ baked_cache_dirty = false;
- if (points.size()==0) {
+ if (points.size() == 0) {
baked_point_cache.resize(0);
baked_tilt_cache.resize(0);
return;
}
- if (points.size()==1) {
+ if (points.size() == 1) {
baked_point_cache.resize(1);
- baked_point_cache.set(0,points[0].pos);
+ baked_point_cache.set(0, points[0].pos);
baked_tilt_cache.resize(1);
- baked_tilt_cache.set(0,points[0].tilt);
+ baked_tilt_cache.set(0, points[0].tilt);
return;
}
-
- Vector3 pos=points[0].pos;
+ Vector3 pos = points[0].pos;
List<Plane> pointlist;
- pointlist.push_back(Plane(pos,points[0].tilt));
+ pointlist.push_back(Plane(pos, points[0].tilt));
- for(int i=0;i<points.size()-1;i++) {
+ for (int i = 0; i < points.size() - 1; i++) {
float step = 0.1; // at least 10 substeps ought to be enough?
float p = 0;
- while(p<1.0) {
-
- float np=p+step;
- if (np>1.0)
- np=1.0;
+ while (p < 1.0) {
+ float np = p + step;
+ if (np > 1.0)
+ np = 1.0;
- Vector3 npp = _bezier_interp(np, points[i].pos,points[i].pos+points[i].out,points[i+1].pos+points[i+1].in,points[i+1].pos);
+ Vector3 npp = _bezier_interp(np, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos);
float d = pos.distance_to(npp);
- if (d>bake_interval) {
+ if (d > bake_interval) {
// OK! between P and NP there _has_ to be Something, let's go searching!
int iterations = 10; //lots of detail!
float low = p;
float hi = np;
- float mid = low+(hi-low)*0.5;
+ float mid = low + (hi - low) * 0.5;
- for(int j=0;j<iterations;j++) {
+ for (int j = 0; j < iterations; j++) {
-
- npp = _bezier_interp(mid, points[i].pos,points[i].pos+points[i].out,points[i+1].pos+points[i+1].in,points[i+1].pos);
+ npp = _bezier_interp(mid, points[i].pos, points[i].pos + points[i].out, points[i + 1].pos + points[i + 1].in, points[i + 1].pos);
d = pos.distance_to(npp);
if (bake_interval < d)
- hi=mid;
+ hi = mid;
else
- low=mid;
- mid = low+(hi-low)*0.5;
-
+ low = mid;
+ mid = low + (hi - low) * 0.5;
}
- pos=npp;
- p=mid;
+ pos = npp;
+ p = mid;
Plane post;
- post.normal=pos;
- post.d=Math::lerp(points[i].tilt,points[i+1].tilt,mid);
+ post.normal = pos;
+ post.d = Math::lerp(points[i].tilt, points[i + 1].tilt, mid);
pointlist.push_back(post);
} else {
- p=np;
+ p = np;
}
-
}
}
- Vector3 lastpos = points[points.size()-1].pos;
- float lastilt = points[points.size()-1].tilt;
+ Vector3 lastpos = points[points.size() - 1].pos;
+ float lastilt = points[points.size() - 1].tilt;
float rem = pos.distance_to(lastpos);
- baked_max_ofs=(pointlist.size()-1)*bake_interval+rem;
- pointlist.push_back(Plane(lastpos,lastilt));
+ baked_max_ofs = (pointlist.size() - 1) * bake_interval + rem;
+ pointlist.push_back(Plane(lastpos, lastilt));
baked_point_cache.resize(pointlist.size());
Vector3Array::Write w = baked_point_cache.write();
- int idx=0;
+ int idx = 0;
baked_tilt_cache.resize(pointlist.size());
RealArray::Write wt = baked_tilt_cache.write();
- for(List<Plane>::Element *E=pointlist.front();E;E=E->next()) {
+ for (List<Plane>::Element *E = pointlist.front(); E; E = E->next()) {
- w[idx]=E->get().normal;
- wt[idx]=E->get().d;
+ w[idx] = E->get().normal;
+ wt[idx] = E->get().d;
idx++;
}
-
}
float Curve3D::get_baked_length() const {
@@ -1112,90 +1041,87 @@ float Curve3D::get_baked_length() const {
return baked_max_ofs;
}
-Vector3 Curve3D::interpolate_baked(float p_offset,bool p_cubic) const{
+Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const {
if (baked_cache_dirty)
_bake();
//validate//
int pc = baked_point_cache.size();
- if (pc==0) {
+ if (pc == 0) {
ERR_EXPLAIN("No points in Curve3D");
- ERR_FAIL_COND_V(pc==0,Vector3());
+ ERR_FAIL_COND_V(pc == 0, Vector3());
}
- if (pc==1)
+ if (pc == 1)
return baked_point_cache.get(0);
- int bpc=baked_point_cache.size();
+ int bpc = baked_point_cache.size();
Vector3Array::Read r = baked_point_cache.read();
- if (p_offset<0)
+ if (p_offset < 0)
return r[0];
- if (p_offset>=baked_max_ofs)
- return r[bpc-1];
+ if (p_offset >= baked_max_ofs)
+ return r[bpc - 1];
- int idx = Math::floor((double)p_offset/(double)bake_interval);
- float frac = Math::fmod(p_offset,bake_interval);
+ int idx = Math::floor((double)p_offset / (double)bake_interval);
+ float frac = Math::fmod(p_offset, bake_interval);
- if (idx>=bpc-1) {
- return r[bpc-1];
- } else if (idx==bpc-2) {
- frac/=Math::fmod(baked_max_ofs,bake_interval);
+ if (idx >= bpc - 1) {
+ return r[bpc - 1];
+ } else if (idx == bpc - 2) {
+ frac /= Math::fmod(baked_max_ofs, bake_interval);
} else {
- frac/=bake_interval;
+ frac /= bake_interval;
}
if (p_cubic) {
- Vector3 pre = idx>0? r[idx-1] : r[idx];
- Vector3 post = (idx<(bpc-2))? r[idx+2] : r[idx+1];
- return r[idx].cubic_interpolate(r[idx+1],pre,post,frac);
+ Vector3 pre = idx > 0 ? r[idx - 1] : r[idx];
+ Vector3 post = (idx < (bpc - 2)) ? r[idx + 2] : r[idx + 1];
+ return r[idx].cubic_interpolate(r[idx + 1], pre, post, frac);
} else {
- return r[idx].linear_interpolate(r[idx+1],frac);
+ return r[idx].linear_interpolate(r[idx + 1], frac);
}
}
-float Curve3D::interpolate_baked_tilt(float p_offset) const{
+float Curve3D::interpolate_baked_tilt(float p_offset) const {
if (baked_cache_dirty)
_bake();
//validate//
int pc = baked_tilt_cache.size();
- if (pc==0) {
+ if (pc == 0) {
ERR_EXPLAIN("No tilts in Curve3D");
- ERR_FAIL_COND_V(pc==0,0);
+ ERR_FAIL_COND_V(pc == 0, 0);
}
- if (pc==1)
+ if (pc == 1)
return baked_tilt_cache.get(0);
- int bpc=baked_tilt_cache.size();
+ int bpc = baked_tilt_cache.size();
RealArray::Read r = baked_tilt_cache.read();
- if (p_offset<0)
+ if (p_offset < 0)
return r[0];
- if (p_offset>=baked_max_ofs)
- return r[bpc-1];
+ if (p_offset >= baked_max_ofs)
+ return r[bpc - 1];
- int idx = Math::floor((double)p_offset/(double)bake_interval);
- float frac = Math::fmod(p_offset,bake_interval);
+ int idx = Math::floor((double)p_offset / (double)bake_interval);
+ float frac = Math::fmod(p_offset, bake_interval);
- if (idx>=bpc-1) {
- return r[bpc-1];
- } else if (idx==bpc-2) {
- frac/=Math::fmod(baked_max_ofs,bake_interval);
+ if (idx >= bpc - 1) {
+ return r[bpc - 1];
+ } else if (idx == bpc - 2) {
+ frac /= Math::fmod(baked_max_ofs, bake_interval);
} else {
- frac/=bake_interval;
+ frac /= bake_interval;
}
- return Math::lerp(r[idx],r[idx+1],frac);
-
-
+ return Math::lerp(r[idx], r[idx + 1], frac);
}
-
Vector3Array Curve3D::get_baked_points() const {
if (baked_cache_dirty)
@@ -1204,7 +1130,6 @@ Vector3Array Curve3D::get_baked_points() const {
return baked_point_cache;
}
-
RealArray Curve3D::get_baked_tilts() const {
if (baked_cache_dirty)
@@ -1213,16 +1138,14 @@ RealArray Curve3D::get_baked_tilts() const {
return baked_tilt_cache;
}
+void Curve3D::set_bake_interval(float p_tolerance) {
-void Curve3D::set_bake_interval(float p_tolerance){
-
- bake_interval=p_tolerance;
- baked_cache_dirty=true;
+ bake_interval = p_tolerance;
+ baked_cache_dirty = true;
emit_signal(CoreStringNames::get_singleton()->changed);
-
}
-float Curve3D::get_bake_interval() const{
+float Curve3D::get_bake_interval() const {
return bake_interval;
}
@@ -1232,163 +1155,134 @@ Dictionary Curve3D::_get_data() const {
Dictionary dc;
Vector3Array d;
- d.resize(points.size()*3);
+ d.resize(points.size() * 3);
Vector3Array::Write w = d.write();
RealArray t;
t.resize(points.size());
RealArray::Write wt = t.write();
+ for (int i = 0; i < points.size(); i++) {
- for(int i=0;i<points.size();i++) {
-
- w[i*3+0]=points[i].in;
- w[i*3+1]=points[i].out;
- w[i*3+2]=points[i].pos;
- wt[i]=points[i].tilt;
+ w[i * 3 + 0] = points[i].in;
+ w[i * 3 + 1] = points[i].out;
+ w[i * 3 + 2] = points[i].pos;
+ wt[i] = points[i].tilt;
}
- w=Vector3Array::Write();
- wt=RealArray::Write();
+ w = Vector3Array::Write();
+ wt = RealArray::Write();
- dc["points"]=d;
- dc["tilts"]=t;
+ dc["points"] = d;
+ dc["tilts"] = t;
return dc;
}
-void Curve3D::_set_data(const Dictionary& p_data){
-
+void Curve3D::_set_data(const Dictionary &p_data) {
ERR_FAIL_COND(!p_data.has("points"));
ERR_FAIL_COND(!p_data.has("tilts"));
- Vector3Array rp=p_data["points"];
+ Vector3Array rp = p_data["points"];
int pc = rp.size();
- ERR_FAIL_COND(pc%3!=0);
- points.resize(pc/3);
+ ERR_FAIL_COND(pc % 3 != 0);
+ points.resize(pc / 3);
Vector3Array::Read r = rp.read();
- RealArray rtl=p_data["tilts"];
- RealArray::Read rt=rtl.read();
+ RealArray rtl = p_data["tilts"];
+ RealArray::Read rt = rtl.read();
- for(int i=0;i<points.size();i++) {
+ for (int i = 0; i < points.size(); i++) {
- points[i].in=r[i*3+0];
- points[i].out=r[i*3+1];
- points[i].pos=r[i*3+2];
- points[i].tilt=rt[i];
+ points[i].in = r[i * 3 + 0];
+ points[i].out = r[i * 3 + 1];
+ points[i].pos = r[i * 3 + 2];
+ points[i].tilt = rt[i];
}
- baked_cache_dirty=true;
-
+ baked_cache_dirty = true;
}
-
-Vector3Array Curve3D::tesselate(int p_max_stages,float p_tolerance) const {
+Vector3Array Curve3D::tesselate(int p_max_stages, float p_tolerance) const {
Vector3Array tess;
-
- if (points.size()==0) {
+ if (points.size() == 0) {
return tess;
}
- Vector< Map<float,Vector3> > midpoints;
+ Vector<Map<float, Vector3> > midpoints;
- midpoints.resize(points.size()-1);
+ midpoints.resize(points.size() - 1);
- int pc=1;
- for(int i=0;i<points.size()-1;i++) {
+ int pc = 1;
+ for (int i = 0; i < points.size() - 1; i++) {
- _bake_segment3d(midpoints[i],0,1,points[i].pos,points[i].out,points[i+1].pos,points[i+1].in,0,p_max_stages,p_tolerance);
+ _bake_segment3d(midpoints[i], 0, 1, points[i].pos, points[i].out, points[i + 1].pos, points[i + 1].in, 0, p_max_stages, p_tolerance);
pc++;
- pc+=midpoints[i].size();
-
+ pc += midpoints[i].size();
}
tess.resize(pc);
- Vector3Array::Write bpw=tess.write();
- bpw[0]=points[0].pos;
- int pidx=0;
+ Vector3Array::Write bpw = tess.write();
+ bpw[0] = points[0].pos;
+ int pidx = 0;
- for(int i=0;i<points.size()-1;i++) {
+ for (int i = 0; i < points.size() - 1; i++) {
- for(Map<float,Vector3>::Element *E=midpoints[i].front();E;E=E->next()) {
+ for (Map<float, Vector3>::Element *E = midpoints[i].front(); E; E = E->next()) {
pidx++;
bpw[pidx] = E->get();
}
pidx++;
- bpw[pidx] = points[i+1].pos;
-
+ bpw[pidx] = points[i + 1].pos;
}
- bpw=Vector3Array::Write ();
+ bpw = Vector3Array::Write();
return tess;
-
}
void Curve3D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_point_count"),&Curve3D::get_point_count);
- ObjectTypeDB::bind_method(_MD("add_point","pos","in","out","atpos"),&Curve3D::add_point,DEFVAL(Vector3()),DEFVAL(Vector3()),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("set_point_pos","idx","pos"),&Curve3D::set_point_pos);
- ObjectTypeDB::bind_method(_MD("get_point_pos","idx"),&Curve3D::get_point_pos);
- ObjectTypeDB::bind_method(_MD("set_point_tilt","idx","tilt"),&Curve3D::set_point_tilt);
- ObjectTypeDB::bind_method(_MD("get_point_tilt","idx"),&Curve3D::get_point_tilt);
- ObjectTypeDB::bind_method(_MD("set_point_in","idx","pos"),&Curve3D::set_point_in);
- ObjectTypeDB::bind_method(_MD("get_point_in","idx"),&Curve3D::get_point_in);
- ObjectTypeDB::bind_method(_MD("set_point_out","idx","pos"),&Curve3D::set_point_out);
- ObjectTypeDB::bind_method(_MD("get_point_out","idx"),&Curve3D::get_point_out);
- ObjectTypeDB::bind_method(_MD("remove_point","idx"),&Curve3D::remove_point);
- ObjectTypeDB::bind_method(_MD("clear_points"),&Curve3D::clear_points);
- ObjectTypeDB::bind_method(_MD("interpolate","idx","t"),&Curve3D::interpolate);
- ObjectTypeDB::bind_method(_MD("interpolatef","fofs"),&Curve3D::interpolatef);
+ ObjectTypeDB::bind_method(_MD("get_point_count"), &Curve3D::get_point_count);
+ ObjectTypeDB::bind_method(_MD("add_point", "pos", "in", "out", "atpos"), &Curve3D::add_point, DEFVAL(Vector3()), DEFVAL(Vector3()), DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("set_point_pos", "idx", "pos"), &Curve3D::set_point_pos);
+ ObjectTypeDB::bind_method(_MD("get_point_pos", "idx"), &Curve3D::get_point_pos);
+ ObjectTypeDB::bind_method(_MD("set_point_tilt", "idx", "tilt"), &Curve3D::set_point_tilt);
+ ObjectTypeDB::bind_method(_MD("get_point_tilt", "idx"), &Curve3D::get_point_tilt);
+ ObjectTypeDB::bind_method(_MD("set_point_in", "idx", "pos"), &Curve3D::set_point_in);
+ ObjectTypeDB::bind_method(_MD("get_point_in", "idx"), &Curve3D::get_point_in);
+ ObjectTypeDB::bind_method(_MD("set_point_out", "idx", "pos"), &Curve3D::set_point_out);
+ ObjectTypeDB::bind_method(_MD("get_point_out", "idx"), &Curve3D::get_point_out);
+ ObjectTypeDB::bind_method(_MD("remove_point", "idx"), &Curve3D::remove_point);
+ ObjectTypeDB::bind_method(_MD("clear_points"), &Curve3D::clear_points);
+ ObjectTypeDB::bind_method(_MD("interpolate", "idx", "t"), &Curve3D::interpolate);
+ ObjectTypeDB::bind_method(_MD("interpolatef", "fofs"), &Curve3D::interpolatef);
//ObjectTypeDB::bind_method(_MD("bake","subdivs"),&Curve3D::bake,DEFVAL(10));
- ObjectTypeDB::bind_method(_MD("set_bake_interval","distance"),&Curve3D::set_bake_interval);
- ObjectTypeDB::bind_method(_MD("get_bake_interval"),&Curve3D::get_bake_interval);
-
- ObjectTypeDB::bind_method(_MD("get_baked_length"),&Curve3D::get_baked_length);
- ObjectTypeDB::bind_method(_MD("interpolate_baked","offset","cubic"),&Curve3D::interpolate_baked,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_baked_points"),&Curve3D::get_baked_points);
- ObjectTypeDB::bind_method(_MD("get_baked_tilts"),&Curve3D::get_baked_tilts);
- ObjectTypeDB::bind_method(_MD("tesselate","max_stages","tolerance_degrees"),&Curve3D::tesselate,DEFVAL(5),DEFVAL(4));
+ ObjectTypeDB::bind_method(_MD("set_bake_interval", "distance"), &Curve3D::set_bake_interval);
+ ObjectTypeDB::bind_method(_MD("get_bake_interval"), &Curve3D::get_bake_interval);
- ObjectTypeDB::bind_method(_MD("_get_data"),&Curve3D::_get_data);
- ObjectTypeDB::bind_method(_MD("_set_data"),&Curve3D::_set_data);
+ ObjectTypeDB::bind_method(_MD("get_baked_length"), &Curve3D::get_baked_length);
+ ObjectTypeDB::bind_method(_MD("interpolate_baked", "offset", "cubic"), &Curve3D::interpolate_baked, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_baked_points"), &Curve3D::get_baked_points);
+ ObjectTypeDB::bind_method(_MD("get_baked_tilts"), &Curve3D::get_baked_tilts);
+ ObjectTypeDB::bind_method(_MD("tesselate", "max_stages", "tolerance_degrees"), &Curve3D::tesselate, DEFVAL(5), DEFVAL(4));
+ ObjectTypeDB::bind_method(_MD("_get_data"), &Curve3D::_get_data);
+ ObjectTypeDB::bind_method(_MD("_set_data"), &Curve3D::_set_data);
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bake_interval",PROPERTY_HINT_RANGE,"0.01,512,0.01"), _SCS("set_bake_interval"),_SCS("get_bake_interval"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bake_interval", PROPERTY_HINT_RANGE, "0.01,512,0.01"), _SCS("set_bake_interval"), _SCS("get_bake_interval"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data"));
/*ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_out"), _SCS("set_points_out"),_SCS("get_points_out"));
ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "points_pos"), _SCS("set_points_pos"),_SCS("get_points_pos"));
*/
}
-
-
-
-Curve3D::Curve3D()
-{
- baked_cache_dirty=false;
- baked_max_ofs=0;
-/* add_point(Vector3(-1,0,0));
+Curve3D::Curve3D() {
+ baked_cache_dirty = false;
+ baked_max_ofs = 0;
+ /* add_point(Vector3(-1,0,0));
add_point(Vector3(0,2,0));
add_point(Vector3(0,3,5));*/
- bake_interval=0.2;
-
+ bake_interval = 0.2;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/scene/resources/curve.h b/scene/resources/curve.h
index c842c03c0..e831bd17b 100644
--- a/scene/resources/curve.h
+++ b/scene/resources/curve.h
@@ -81,10 +81,9 @@ public:
#endif
-
class Curve2D : public Resource {
- OBJ_TYPE(Curve2D,Resource);
+ OBJ_TYPE(Curve2D, Resource);
struct Point {
@@ -93,7 +92,6 @@ class Curve2D : public Resource {
Vector2 pos;
};
-
Vector<Point> points;
struct BakedPoint {
@@ -106,31 +104,25 @@ class Curve2D : public Resource {
mutable Vector2Array baked_point_cache;
mutable float baked_max_ofs;
-
void _bake() const;
float bake_interval;
- void _bake_segment2d(Map<float,Vector2>& r_bake, float p_begin, float p_end,const Vector2& p_a,const Vector2& p_out,const Vector2& p_b, const Vector2& p_in,int p_depth,int p_max_depth,float p_tol) const;
+ void _bake_segment2d(Map<float, Vector2> &r_bake, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_max_depth, float p_tol) const;
Dictionary _get_data() const;
void _set_data(const Dictionary &p_data);
protected:
-
static void _bind_methods();
-
-
public:
-
-
int get_point_count() const;
- void add_point(const Vector2& p_pos, const Vector2& p_in=Vector2(), const Vector2& p_out=Vector2(),int p_atpos=-1);
- void set_point_pos(int p_index, const Vector2& p_pos);
+ void add_point(const Vector2 &p_pos, const Vector2 &p_in = Vector2(), const Vector2 &p_out = Vector2(), int p_atpos = -1);
+ void set_point_pos(int p_index, const Vector2 &p_pos);
Vector2 get_point_pos(int p_index) const;
- void set_point_in(int p_index, const Vector2& p_in);
+ void set_point_in(int p_index, const Vector2 &p_in);
Vector2 get_point_in(int p_index) const;
- void set_point_out(int p_index, const Vector2& p_out);
+ void set_point_out(int p_index, const Vector2 &p_out);
Vector2 get_point_out(int p_index) const;
void remove_point(int p_index);
void clear_points();
@@ -138,26 +130,21 @@ public:
Vector2 interpolate(int p_index, float p_offset) const;
Vector2 interpolatef(real_t p_findex) const;
-
void set_bake_interval(float p_distance);
float get_bake_interval() const;
-
float get_baked_length() const;
- Vector2 interpolate_baked(float p_offset,bool p_cubic=false) const;
+ Vector2 interpolate_baked(float p_offset, bool p_cubic = false) const;
Vector2Array get_baked_points() const; //useful for going thru
- Vector2Array tesselate(int p_max_stages=5,float p_tolerance=4) const; //useful for display
-
+ Vector2Array tesselate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display
Curve2D();
};
-
-
class Curve3D : public Resource {
- OBJ_TYPE(Curve3D,Resource);
+ OBJ_TYPE(Curve3D, Resource);
struct Point {
@@ -166,10 +153,9 @@ class Curve3D : public Resource {
Vector3 pos;
float tilt;
- Point() { tilt=0; }
+ Point() { tilt = 0; }
};
-
Vector<Point> points;
struct BakedPoint {
@@ -183,33 +169,27 @@ class Curve3D : public Resource {
mutable RealArray baked_tilt_cache;
mutable float baked_max_ofs;
-
void _bake() const;
float bake_interval;
- void _bake_segment3d(Map<float,Vector3>& r_bake, float p_begin, float p_end,const Vector3& p_a,const Vector3& p_out,const Vector3& p_b, const Vector3& p_in,int p_depth,int p_max_depth,float p_tol) const;
+ void _bake_segment3d(Map<float, Vector3> &r_bake, float p_begin, float p_end, const Vector3 &p_a, const Vector3 &p_out, const Vector3 &p_b, const Vector3 &p_in, int p_depth, int p_max_depth, float p_tol) const;
Dictionary _get_data() const;
void _set_data(const Dictionary &p_data);
protected:
-
static void _bind_methods();
-
-
public:
-
-
int get_point_count() const;
- void add_point(const Vector3& p_pos, const Vector3& p_in=Vector3(), const Vector3& p_out=Vector3(),int p_atpos=-1);
- void set_point_pos(int p_index, const Vector3& p_pos);
+ void add_point(const Vector3 &p_pos, const Vector3 &p_in = Vector3(), const Vector3 &p_out = Vector3(), int p_atpos = -1);
+ void set_point_pos(int p_index, const Vector3 &p_pos);
Vector3 get_point_pos(int p_index) const;
void set_point_tilt(int p_index, float p_tilt);
float get_point_tilt(int p_index) const;
- void set_point_in(int p_index, const Vector3& p_in);
+ void set_point_in(int p_index, const Vector3 &p_in);
Vector3 get_point_in(int p_index) const;
- void set_point_out(int p_index, const Vector3& p_out);
+ void set_point_out(int p_index, const Vector3 &p_out);
Vector3 get_point_out(int p_index) const;
void remove_point(int p_index);
void clear_points();
@@ -217,19 +197,16 @@ public:
Vector3 interpolate(int p_index, float p_offset) const;
Vector3 interpolatef(real_t p_findex) const;
-
void set_bake_interval(float p_distance);
float get_bake_interval() const;
-
float get_baked_length() const;
- Vector3 interpolate_baked(float p_offset,bool p_cubic=false) const;
+ Vector3 interpolate_baked(float p_offset, bool p_cubic = false) const;
float interpolate_baked_tilt(float p_offset) const;
Vector3Array get_baked_points() const; //useful for going thru
RealArray get_baked_tilts() const; //useful for going thru
- Vector3Array tesselate(int p_max_stages=5,float p_tolerance=4) const; //useful for display
-
+ Vector3Array tesselate(int p_max_stages = 5, float p_tolerance = 4) const; //useful for display
Curve3D();
};
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index ef91b730f..c525c107b 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -31,177 +31,165 @@
#include "scene/resources/theme.h"
-#include "theme_data.h"
#include "os/os.h"
+#include "theme_data.h"
-#include "font_lodpi.inc"
#include "font_hidpi.inc"
+#include "font_lodpi.inc"
-typedef Map<const void*,Ref<ImageTexture> > TexCacheMap;
+typedef Map<const void *, Ref<ImageTexture> > TexCacheMap;
-static TexCacheMap *tex_cache;
-static int scale=1;
+static TexCacheMap *tex_cache;
+static int scale = 1;
-template<class T>
-static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, float p_right, float p_botton,float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1, bool p_draw_center=true) {
+template <class T>
+static Ref<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, float p_right, float p_botton, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1, bool p_draw_center = true) {
Ref<ImageTexture> texture;
-
if (tex_cache->has(p_src)) {
- texture=(*tex_cache)[p_src];
+ texture = (*tex_cache)[p_src];
} else {
- texture = Ref<ImageTexture>( memnew( ImageTexture ) );
+ texture = Ref<ImageTexture>(memnew(ImageTexture));
Image img(p_src);
- if (scale>1) {
+ if (scale > 1) {
img.convert(Image::FORMAT_RGBA);
img.expand_x2_hq2x();
}
- texture->create_from_image( img,ImageTexture::FLAG_FILTER );
- (*tex_cache)[p_src]=texture;
+ texture->create_from_image(img, ImageTexture::FLAG_FILTER);
+ (*tex_cache)[p_src] = texture;
}
-
- Ref<StyleBoxTexture> style( memnew( StyleBoxTexture ) );
+ Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
style->set_texture(texture);
- style->set_margin_size( MARGIN_LEFT, p_left * scale);
- style->set_margin_size( MARGIN_RIGHT, p_right * scale);
- style->set_margin_size( MARGIN_BOTTOM, p_botton * scale);
- style->set_margin_size( MARGIN_TOP, p_top * scale);
- style->set_default_margin( MARGIN_LEFT, p_margin_left * scale);
- style->set_default_margin( MARGIN_RIGHT, p_margin_right * scale);
- style->set_default_margin( MARGIN_BOTTOM, p_margin_botton * scale);
- style->set_default_margin( MARGIN_TOP, p_margin_top * scale);
+ style->set_margin_size(MARGIN_LEFT, p_left * scale);
+ style->set_margin_size(MARGIN_RIGHT, p_right * scale);
+ style->set_margin_size(MARGIN_BOTTOM, p_botton * scale);
+ style->set_margin_size(MARGIN_TOP, p_top * scale);
+ style->set_default_margin(MARGIN_LEFT, p_margin_left * scale);
+ style->set_default_margin(MARGIN_RIGHT, p_margin_right * scale);
+ style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * scale);
+ style->set_default_margin(MARGIN_TOP, p_margin_top * scale);
style->set_draw_center(p_draw_center);
return style;
}
+static Ref<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> p_sbox, float p_left, float p_top, float p_right, float p_botton) {
-static Ref<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> p_sbox,float p_left, float p_top, float p_right, float p_botton) {
-
- p_sbox->set_expand_margin_size(MARGIN_LEFT,p_left * scale);
- p_sbox->set_expand_margin_size(MARGIN_TOP,p_top * scale);
- p_sbox->set_expand_margin_size(MARGIN_RIGHT,p_right * scale);
- p_sbox->set_expand_margin_size(MARGIN_BOTTOM,p_botton * scale);
+ p_sbox->set_expand_margin_size(MARGIN_LEFT, p_left * scale);
+ p_sbox->set_expand_margin_size(MARGIN_TOP, p_top * scale);
+ p_sbox->set_expand_margin_size(MARGIN_RIGHT, p_right * scale);
+ p_sbox->set_expand_margin_size(MARGIN_BOTTOM, p_botton * scale);
return p_sbox;
}
-template<class T>
+template <class T>
static Ref<Texture> make_icon(T p_src) {
-
- Ref<ImageTexture> texture( memnew( ImageTexture ) );
+ Ref<ImageTexture> texture(memnew(ImageTexture));
Image img = Image(p_src);
- if (scale>1) {
+ if (scale > 1) {
img.convert(Image::FORMAT_RGBA);
img.expand_x2_hq2x();
}
- texture->create_from_image( img,ImageTexture::FLAG_FILTER );
+ texture->create_from_image(img, ImageTexture::FLAG_FILTER);
return texture;
}
-static Ref<Shader> make_shader(const char*vertex_code,const char*fragment_code,const char*lighting_code) {
- Ref<Shader> shader = (memnew( Shader(Shader::MODE_CANVAS_ITEM) ));
+static Ref<Shader> make_shader(const char *vertex_code, const char *fragment_code, const char *lighting_code) {
+ Ref<Shader> shader = (memnew(Shader(Shader::MODE_CANVAS_ITEM)));
shader->set_code(vertex_code, fragment_code, lighting_code);
return shader;
}
-static Ref<BitmapFont> make_font(int p_height,int p_ascent, int p_valign, int p_charcount, const int *p_chars,const Ref<Texture> &p_texture) {
-
+static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p_charcount, const int *p_chars, const Ref<Texture> &p_texture) {
- Ref<BitmapFont> font( memnew( BitmapFont ) );
- font->add_texture( p_texture );
+ Ref<BitmapFont> font(memnew(BitmapFont));
+ font->add_texture(p_texture);
- for (int i=0;i<p_charcount;i++) {
+ for (int i = 0; i < p_charcount; i++) {
- const int *c = &p_chars[i*8];
+ const int *c = &p_chars[i * 8];
- int chr=c[0];
+ int chr = c[0];
Rect2 frect;
- frect.pos.x=c[1];
- frect.pos.y=c[2];
- frect.size.x=c[3];
- frect.size.y=c[4];
- Point2 align( c[5], c[6]+p_valign);
- int advance=c[7];
-
-
- font->add_char( chr, 0, frect, align,advance );
+ frect.pos.x = c[1];
+ frect.pos.y = c[2];
+ frect.size.x = c[3];
+ frect.size.y = c[4];
+ Point2 align(c[5], c[6] + p_valign);
+ int advance = c[7];
+ font->add_char(chr, 0, frect, align, advance);
}
- font->set_height( p_height );
- font->set_ascent( p_ascent );
+ font->set_height(p_height);
+ font->set_ascent(p_ascent);
return font;
}
+static Ref<BitmapFont> make_font2(int p_height, int p_ascent, int p_charcount, const int *p_char_rects, int p_kerning_count, const int *p_kernings, int p_w, int p_h, const unsigned char *p_img) {
-
-static Ref<BitmapFont> make_font2(int p_height,int p_ascent, int p_charcount, const int *p_char_rects,int p_kerning_count,const int *p_kernings,int p_w, int p_h, const unsigned char *p_img) {
-
-
- Ref<BitmapFont> font( memnew( BitmapFont ) );
+ Ref<BitmapFont> font(memnew(BitmapFont));
Image image(p_img);
- Ref<ImageTexture> tex = memnew( ImageTexture );
+ Ref<ImageTexture> tex = memnew(ImageTexture);
tex->create_from_image(image);
- font->add_texture( tex );
+ font->add_texture(tex);
- for (int i=0;i<p_charcount;i++) {
+ for (int i = 0; i < p_charcount; i++) {
- const int *c = &p_char_rects[i*8];
+ const int *c = &p_char_rects[i * 8];
- int chr=c[0];
+ int chr = c[0];
Rect2 frect;
- frect.pos.x=c[1];
- frect.pos.y=c[2];
- frect.size.x=c[3];
- frect.size.y=c[4];
- Point2 align( c[6], c[5]);
- int advance=c[7];
-
- font->add_char( chr, 0, frect, align,advance );
+ frect.pos.x = c[1];
+ frect.pos.y = c[2];
+ frect.size.x = c[3];
+ frect.size.y = c[4];
+ Point2 align(c[6], c[5]);
+ int advance = c[7];
+ font->add_char(chr, 0, frect, align, advance);
}
- for(int i=0;i<p_kerning_count;i++) {
+ for (int i = 0; i < p_kerning_count; i++) {
- font->add_kerning_pair(p_kernings[i*3+0],p_kernings[i*3+1],p_kernings[i*3+2]);
+ font->add_kerning_pair(p_kernings[i * 3 + 0], p_kernings[i * 3 + 1], p_kernings[i * 3 + 2]);
}
- font->set_height( p_height );
- font->set_ascent( p_ascent );
+ font->set_height(p_height);
+ font->set_ascent(p_ascent);
return font;
}
+static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_botton = -1) {
-static Ref<StyleBox> make_empty_stylebox(float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1) {
-
- Ref<StyleBox> style( memnew( StyleBoxEmpty) );
+ Ref<StyleBox> style(memnew(StyleBoxEmpty));
- style->set_default_margin( MARGIN_LEFT, p_margin_left * scale);
- style->set_default_margin( MARGIN_RIGHT, p_margin_right * scale);
- style->set_default_margin( MARGIN_BOTTOM, p_margin_botton * scale);
- style->set_default_margin( MARGIN_TOP, p_margin_top * scale);
+ style->set_default_margin(MARGIN_LEFT, p_margin_left * scale);
+ style->set_default_margin(MARGIN_RIGHT, p_margin_right * scale);
+ style->set_default_margin(MARGIN_BOTTOM, p_margin_botton * scale);
+ style->set_default_margin(MARGIN_TOP, p_margin_top * scale);
return style;
}
-void fill_default_theme(Ref<Theme>& t,const Ref<Font> & default_font,const Ref<Font> & large_font,Ref<Texture>& default_icon, Ref<StyleBox>& default_style,bool p_hidpi) {
+void fill_default_theme(Ref<Theme> &t, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, bool p_hidpi) {
if (p_hidpi)
- scale=2;
+ scale = 2;
else
- scale=1;
+ scale = 1;
- tex_cache = memnew( TexCacheMap );
+ tex_cache = memnew(TexCacheMap);
//Ref<BitmapFont> default_font = make_font(_bi_font_normal_height,_bi_font_normal_ascent,_bi_font_normal_valign,_bi_font_normal_charcount,_bi_font_normal_characters,make_icon(font_normal_png));
@@ -211,735 +199,670 @@ void fill_default_theme(Ref<Theme>& t,const Ref<Font> & default_font,const Ref<F
Color control_font_color_lower = Color::html("a0a0a0");
Color control_font_color_low = Color::html("b0b0b0");
Color control_font_color_hover = Color::html("f0f0f0");
- Color control_font_color_disabled = Color(0.9,0.9,0.9,0.2);
+ Color control_font_color_disabled = Color(0.9, 0.9, 0.9, 0.2);
Color control_font_color_pressed = Color::html("ffffff");
Color font_color_selection = Color::html("7d7d7d");
-
// Panel
- t->set_stylebox("panel","Panel", make_stylebox( panel_bg_png,0,0,0,0) );
-
-
+ t->set_stylebox("panel", "Panel", make_stylebox(panel_bg_png, 0, 0, 0, 0));
// Focus
- Ref<StyleBoxTexture> focus = make_stylebox( focus_png,5,5,5,5);
- for(int i=0;i<4;i++) {
- focus->set_expand_margin_size(Margin(i),1 *scale);
+ Ref<StyleBoxTexture> focus = make_stylebox(focus_png, 5, 5, 5, 5);
+ for (int i = 0; i < 4; i++) {
+ focus->set_expand_margin_size(Margin(i), 1 * scale);
}
-
-
// Button
- Ref<StyleBox> sb_button_normal = sb_expand( make_stylebox( button_normal_png,4,4,4,4,6,3,6,3),2,2,2,2);
- Ref<StyleBox> sb_button_pressed = sb_expand( make_stylebox( button_pressed_png,4,4,4,4,6,3,6,3),2,2,2,2);
- Ref<StyleBox> sb_button_hover = sb_expand( make_stylebox( button_hover_png,4,4,4,4,6,2,6,2),2,2,2,2);
- Ref<StyleBox> sb_button_disabled = sb_expand( make_stylebox( button_disabled_png,4,4,4,4,6,2,6,2),2,2,2,2);
- Ref<StyleBox> sb_button_focus = sb_expand( make_stylebox( button_focus_png,4,4,4,4,6,2,6,2),2,2,2,2);
+ Ref<StyleBox> sb_button_normal = sb_expand(make_stylebox(button_normal_png, 4, 4, 4, 4, 6, 3, 6, 3), 2, 2, 2, 2);
+ Ref<StyleBox> sb_button_pressed = sb_expand(make_stylebox(button_pressed_png, 4, 4, 4, 4, 6, 3, 6, 3), 2, 2, 2, 2);
+ Ref<StyleBox> sb_button_hover = sb_expand(make_stylebox(button_hover_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
+ Ref<StyleBox> sb_button_disabled = sb_expand(make_stylebox(button_disabled_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
+ Ref<StyleBox> sb_button_focus = sb_expand(make_stylebox(button_focus_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
- t->set_stylebox("normal","Button", sb_button_normal);
- t->set_stylebox("pressed","Button", sb_button_pressed);
- t->set_stylebox("hover","Button", sb_button_hover);
- t->set_stylebox("disabled","Button", sb_button_disabled);
- t->set_stylebox("focus","Button", sb_button_focus);
+ t->set_stylebox("normal", "Button", sb_button_normal);
+ t->set_stylebox("pressed", "Button", sb_button_pressed);
+ t->set_stylebox("hover", "Button", sb_button_hover);
+ t->set_stylebox("disabled", "Button", sb_button_disabled);
+ t->set_stylebox("focus", "Button", sb_button_focus);
- t->set_font("font","Button", default_font );
+ t->set_font("font", "Button", default_font);
- t->set_color("font_color","Button", control_font_color );
- t->set_color("font_color_pressed","Button", control_font_color_pressed );
- t->set_color("font_color_hover","Button", control_font_color_hover );
- t->set_color("font_color_disabled","Button", control_font_color_disabled );
+ t->set_color("font_color", "Button", control_font_color);
+ t->set_color("font_color_pressed", "Button", control_font_color_pressed);
+ t->set_color("font_color_hover", "Button", control_font_color_hover);
+ t->set_color("font_color_disabled", "Button", control_font_color_disabled);
- t->set_constant("hseparation","Button", 2 *scale);
+ t->set_constant("hseparation", "Button", 2 * scale);
// LinkButton
- t->set_font("font","LinkButton", default_font );
+ t->set_font("font", "LinkButton", default_font);
- t->set_color("font_color","LinkButton", control_font_color );
- t->set_color("font_color_pressed","LinkButton", control_font_color_pressed );
- t->set_color("font_color_hover","LinkButton", control_font_color_hover );
+ t->set_color("font_color", "LinkButton", control_font_color);
+ t->set_color("font_color_pressed", "LinkButton", control_font_color_pressed);
+ t->set_color("font_color_hover", "LinkButton", control_font_color_hover);
- t->set_constant("underline_spacing","LinkButton", 2 *scale);
+ t->set_constant("underline_spacing", "LinkButton", 2 * scale);
// ColorPickerButton
- t->set_stylebox("normal","ColorPickerButton", sb_button_normal);
- t->set_stylebox("pressed","ColorPickerButton", sb_button_pressed);
- t->set_stylebox("hover","ColorPickerButton", sb_button_hover);
- t->set_stylebox("disabled","ColorPickerButton", sb_button_disabled);
- t->set_stylebox("focus","ColorPickerButton", sb_button_focus);
+ t->set_stylebox("normal", "ColorPickerButton", sb_button_normal);
+ t->set_stylebox("pressed", "ColorPickerButton", sb_button_pressed);
+ t->set_stylebox("hover", "ColorPickerButton", sb_button_hover);
+ t->set_stylebox("disabled", "ColorPickerButton", sb_button_disabled);
+ t->set_stylebox("focus", "ColorPickerButton", sb_button_focus);
- t->set_font("font","ColorPickerButton", default_font );
+ t->set_font("font", "ColorPickerButton", default_font);
- t->set_color("font_color","ColorPickerButton", Color(1,1,1,1) );
- t->set_color("font_color_pressed","ColorPickerButton", Color(0.8,0.8,0.8,1) );
- t->set_color("font_color_hover","ColorPickerButton", Color(1,1,1,1) );
- t->set_color("font_color_disabled","ColorPickerButton", Color(0.9,0.9,0.9,0.3) );
-
- t->set_constant("hseparation","ColorPickerButton", 2 *scale);
+ t->set_color("font_color", "ColorPickerButton", Color(1, 1, 1, 1));
+ t->set_color("font_color_pressed", "ColorPickerButton", Color(0.8, 0.8, 0.8, 1));
+ t->set_color("font_color_hover", "ColorPickerButton", Color(1, 1, 1, 1));
+ t->set_color("font_color_disabled", "ColorPickerButton", Color(0.9, 0.9, 0.9, 0.3));
+ t->set_constant("hseparation", "ColorPickerButton", 2 * scale);
// ToolButton
- Ref<StyleBox> tb_empty = memnew( StyleBoxEmpty );
- tb_empty->set_default_margin(MARGIN_LEFT,6 *scale);
- tb_empty->set_default_margin(MARGIN_RIGHT,6 *scale);
- tb_empty->set_default_margin(MARGIN_TOP,4 *scale);
- tb_empty->set_default_margin(MARGIN_BOTTOM,4 *scale);
-
- t->set_stylebox("normal","ToolButton", tb_empty);
- t->set_stylebox("pressed","ToolButton", make_stylebox( button_pressed_png,4,4,4,4) );
- t->set_stylebox("hover","ToolButton", make_stylebox( button_normal_png,4,4,4,4) );
- t->set_stylebox("disabled","ToolButton", make_empty_stylebox(4,4,4,4) );
- t->set_stylebox("focus","ToolButton", focus );
- t->set_font("font","ToolButton", default_font );
-
- t->set_color("font_color","ToolButton", control_font_color );
- t->set_color("font_color_pressed","ToolButton", control_font_color_pressed );
- t->set_color("font_color_hover","ToolButton", control_font_color_hover );
- t->set_color("font_color_disabled","ToolButton", Color(0.9,0.95,1,0.3) );
+ Ref<StyleBox> tb_empty = memnew(StyleBoxEmpty);
+ tb_empty->set_default_margin(MARGIN_LEFT, 6 * scale);
+ tb_empty->set_default_margin(MARGIN_RIGHT, 6 * scale);
+ tb_empty->set_default_margin(MARGIN_TOP, 4 * scale);
+ tb_empty->set_default_margin(MARGIN_BOTTOM, 4 * scale);
- t->set_constant("hseparation","ToolButton", 3 );
+ t->set_stylebox("normal", "ToolButton", tb_empty);
+ t->set_stylebox("pressed", "ToolButton", make_stylebox(button_pressed_png, 4, 4, 4, 4));
+ t->set_stylebox("hover", "ToolButton", make_stylebox(button_normal_png, 4, 4, 4, 4));
+ t->set_stylebox("disabled", "ToolButton", make_empty_stylebox(4, 4, 4, 4));
+ t->set_stylebox("focus", "ToolButton", focus);
+ t->set_font("font", "ToolButton", default_font);
+ t->set_color("font_color", "ToolButton", control_font_color);
+ t->set_color("font_color_pressed", "ToolButton", control_font_color_pressed);
+ t->set_color("font_color_hover", "ToolButton", control_font_color_hover);
+ t->set_color("font_color_disabled", "ToolButton", Color(0.9, 0.95, 1, 0.3));
+ t->set_constant("hseparation", "ToolButton", 3);
// OptionButton
- Ref<StyleBox> sb_optbutton_normal = sb_expand( make_stylebox( option_button_normal_png,4,4,21,4,6,3,21,3),2,2,2,2);
- Ref<StyleBox> sb_optbutton_pressed = sb_expand( make_stylebox( option_button_pressed_png,4,4,21,4,6,3,21,3),2,2,2,2);
- Ref<StyleBox> sb_optbutton_hover = sb_expand( make_stylebox( option_button_hover_png,4,4,21,4,6,2,21,2),2,2,2,2);
- Ref<StyleBox> sb_optbutton_disabled = sb_expand( make_stylebox( option_button_disabled_png,4,4,21,4,6,2,21,2),2,2,2,2);
- Ref<StyleBox> sb_optbutton_focus = sb_expand( make_stylebox( button_focus_png,4,4,4,4,6,2,6,2),2,2,2,2);
+ Ref<StyleBox> sb_optbutton_normal = sb_expand(make_stylebox(option_button_normal_png, 4, 4, 21, 4, 6, 3, 21, 3), 2, 2, 2, 2);
+ Ref<StyleBox> sb_optbutton_pressed = sb_expand(make_stylebox(option_button_pressed_png, 4, 4, 21, 4, 6, 3, 21, 3), 2, 2, 2, 2);
+ Ref<StyleBox> sb_optbutton_hover = sb_expand(make_stylebox(option_button_hover_png, 4, 4, 21, 4, 6, 2, 21, 2), 2, 2, 2, 2);
+ Ref<StyleBox> sb_optbutton_disabled = sb_expand(make_stylebox(option_button_disabled_png, 4, 4, 21, 4, 6, 2, 21, 2), 2, 2, 2, 2);
+ Ref<StyleBox> sb_optbutton_focus = sb_expand(make_stylebox(button_focus_png, 4, 4, 4, 4, 6, 2, 6, 2), 2, 2, 2, 2);
- t->set_stylebox("normal","OptionButton", sb_optbutton_normal );
- t->set_stylebox("pressed","OptionButton", sb_optbutton_pressed );
- t->set_stylebox("hover","OptionButton", sb_optbutton_hover );
- t->set_stylebox("disabled","OptionButton", sb_optbutton_disabled );
- t->set_stylebox("focus","OptionButton", sb_button_focus );
+ t->set_stylebox("normal", "OptionButton", sb_optbutton_normal);
+ t->set_stylebox("pressed", "OptionButton", sb_optbutton_pressed);
+ t->set_stylebox("hover", "OptionButton", sb_optbutton_hover);
+ t->set_stylebox("disabled", "OptionButton", sb_optbutton_disabled);
+ t->set_stylebox("focus", "OptionButton", sb_button_focus);
- t->set_icon("arrow","OptionButton", make_icon( option_arrow_png ) );
+ t->set_icon("arrow", "OptionButton", make_icon(option_arrow_png));
- t->set_font("font","OptionButton", default_font );
-
- t->set_color("font_color","OptionButton", control_font_color );
- t->set_color("font_color_pressed","OptionButton", control_font_color_pressed );
- t->set_color("font_color_hover","OptionButton", control_font_color_hover );
- t->set_color("font_color_disabled","OptionButton", control_font_color_disabled );
-
- t->set_constant("hseparation","OptionButton", 2 *scale);
- t->set_constant("arrow_margin","OptionButton", 2 *scale);
+ t->set_font("font", "OptionButton", default_font);
+ t->set_color("font_color", "OptionButton", control_font_color);
+ t->set_color("font_color_pressed", "OptionButton", control_font_color_pressed);
+ t->set_color("font_color_hover", "OptionButton", control_font_color_hover);
+ t->set_color("font_color_disabled", "OptionButton", control_font_color_disabled);
+ t->set_constant("hseparation", "OptionButton", 2 * scale);
+ t->set_constant("arrow_margin", "OptionButton", 2 * scale);
// MenuButton
- t->set_stylebox("normal","MenuButton", sb_button_normal );
- t->set_stylebox("pressed","MenuButton", sb_button_pressed );
- t->set_stylebox("hover","MenuButton", sb_button_pressed );
- t->set_stylebox("disabled","MenuButton", make_empty_stylebox(0,0,0,0) );
- t->set_stylebox("focus","MenuButton", sb_button_focus );
+ t->set_stylebox("normal", "MenuButton", sb_button_normal);
+ t->set_stylebox("pressed", "MenuButton", sb_button_pressed);
+ t->set_stylebox("hover", "MenuButton", sb_button_pressed);
+ t->set_stylebox("disabled", "MenuButton", make_empty_stylebox(0, 0, 0, 0));
+ t->set_stylebox("focus", "MenuButton", sb_button_focus);
- t->set_font("font","MenuButton", default_font );
+ t->set_font("font", "MenuButton", default_font);
- t->set_color("font_color","MenuButton", control_font_color );
- t->set_color("font_color_pressed","MenuButton", control_font_color_pressed );
- t->set_color("font_color_hover","MenuButton", control_font_color_hover );
- t->set_color("font_color_disabled","MenuButton", Color(1,1,1,0.3) );
+ t->set_color("font_color", "MenuButton", control_font_color);
+ t->set_color("font_color_pressed", "MenuButton", control_font_color_pressed);
+ t->set_color("font_color_hover", "MenuButton", control_font_color_hover);
+ t->set_color("font_color_disabled", "MenuButton", Color(1, 1, 1, 0.3));
- t->set_constant("hseparation","MenuButton", 3 *scale);
+ t->set_constant("hseparation", "MenuButton", 3 * scale);
// ButtonGroup
- t->set_stylebox("panel","ButtonGroup", memnew( StyleBoxEmpty ));
+ t->set_stylebox("panel", "ButtonGroup", memnew(StyleBoxEmpty));
// CheckBox
- Ref<StyleBox> cbx_empty = memnew( StyleBoxEmpty );
- cbx_empty->set_default_margin(MARGIN_LEFT,22 *scale);
- cbx_empty->set_default_margin(MARGIN_RIGHT,4 *scale);
- cbx_empty->set_default_margin(MARGIN_TOP,4 *scale);
- cbx_empty->set_default_margin(MARGIN_BOTTOM,5 *scale);
+ Ref<StyleBox> cbx_empty = memnew(StyleBoxEmpty);
+ cbx_empty->set_default_margin(MARGIN_LEFT, 22 * scale);
+ cbx_empty->set_default_margin(MARGIN_RIGHT, 4 * scale);
+ cbx_empty->set_default_margin(MARGIN_TOP, 4 * scale);
+ cbx_empty->set_default_margin(MARGIN_BOTTOM, 5 * scale);
Ref<StyleBox> cbx_focus = focus;
- cbx_focus->set_default_margin(MARGIN_LEFT,4 *scale);
- cbx_focus->set_default_margin(MARGIN_RIGHT,22 *scale);
- cbx_focus->set_default_margin(MARGIN_TOP,4 *scale);
- cbx_focus->set_default_margin(MARGIN_BOTTOM,5 *scale);
+ cbx_focus->set_default_margin(MARGIN_LEFT, 4 * scale);
+ cbx_focus->set_default_margin(MARGIN_RIGHT, 22 * scale);
+ cbx_focus->set_default_margin(MARGIN_TOP, 4 * scale);
+ cbx_focus->set_default_margin(MARGIN_BOTTOM, 5 * scale);
- t->set_stylebox("normal","CheckBox", cbx_empty );
- t->set_stylebox("pressed","CheckBox", cbx_empty );
- t->set_stylebox("disabled","CheckBox", cbx_empty );
- t->set_stylebox("hover","CheckBox", cbx_empty );
- t->set_stylebox("focus","CheckBox", cbx_focus );
+ t->set_stylebox("normal", "CheckBox", cbx_empty);
+ t->set_stylebox("pressed", "CheckBox", cbx_empty);
+ t->set_stylebox("disabled", "CheckBox", cbx_empty);
+ t->set_stylebox("hover", "CheckBox", cbx_empty);
+ t->set_stylebox("focus", "CheckBox", cbx_focus);
t->set_icon("checked", "CheckBox", make_icon(checked_png));
t->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
t->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
t->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
- t->set_font("font","CheckBox", default_font );
-
- t->set_color("font_color","CheckBox", control_font_color );
- t->set_color("font_color_pressed","CheckBox", control_font_color_pressed );
- t->set_color("font_color_hover","CheckBox", control_font_color_hover );
- t->set_color("font_color_disabled","CheckBox", control_font_color_disabled );
-
- t->set_constant("hseparation","CheckBox",4 *scale);
- t->set_constant("check_vadjust","CheckBox",0 *scale);
+ t->set_font("font", "CheckBox", default_font);
+ t->set_color("font_color", "CheckBox", control_font_color);
+ t->set_color("font_color_pressed", "CheckBox", control_font_color_pressed);
+ t->set_color("font_color_hover", "CheckBox", control_font_color_hover);
+ t->set_color("font_color_disabled", "CheckBox", control_font_color_disabled);
+ t->set_constant("hseparation", "CheckBox", 4 * scale);
+ t->set_constant("check_vadjust", "CheckBox", 0 * scale);
// CheckButton
- Ref<StyleBox> cb_empty = memnew( StyleBoxEmpty );
- cb_empty->set_default_margin(MARGIN_LEFT,6 *scale);
- cb_empty->set_default_margin(MARGIN_RIGHT,70 *scale);
- cb_empty->set_default_margin(MARGIN_TOP,4 *scale);
- cb_empty->set_default_margin(MARGIN_BOTTOM,4 *scale);
-
- t->set_stylebox("normal","CheckButton", cb_empty );
- t->set_stylebox("pressed","CheckButton", cb_empty );
- t->set_stylebox("disabled","CheckButton", cb_empty );
- t->set_stylebox("hover","CheckButton", cb_empty );
- t->set_stylebox("focus","CheckButton", focus );
-
- t->set_icon("on","CheckButton", make_icon(toggle_on_png) );
- t->set_icon("off","CheckButton", make_icon(toggle_off_png));
+ Ref<StyleBox> cb_empty = memnew(StyleBoxEmpty);
+ cb_empty->set_default_margin(MARGIN_LEFT, 6 * scale);
+ cb_empty->set_default_margin(MARGIN_RIGHT, 70 * scale);
+ cb_empty->set_default_margin(MARGIN_TOP, 4 * scale);
+ cb_empty->set_default_margin(MARGIN_BOTTOM, 4 * scale);
- t->set_font("font","CheckButton", default_font );
+ t->set_stylebox("normal", "CheckButton", cb_empty);
+ t->set_stylebox("pressed", "CheckButton", cb_empty);
+ t->set_stylebox("disabled", "CheckButton", cb_empty);
+ t->set_stylebox("hover", "CheckButton", cb_empty);
+ t->set_stylebox("focus", "CheckButton", focus);
- t->set_color("font_color","CheckButton", control_font_color );
- t->set_color("font_color_pressed","CheckButton", control_font_color_pressed );
- t->set_color("font_color_hover","CheckButton", control_font_color_hover );
- t->set_color("font_color_disabled","CheckButton", control_font_color_disabled );
+ t->set_icon("on", "CheckButton", make_icon(toggle_on_png));
+ t->set_icon("off", "CheckButton", make_icon(toggle_off_png));
- t->set_constant("hseparation","CheckButton",4 *scale);
- t->set_constant("check_vadjust","CheckButton",0 *scale);
+ t->set_font("font", "CheckButton", default_font);
+ t->set_color("font_color", "CheckButton", control_font_color);
+ t->set_color("font_color_pressed", "CheckButton", control_font_color_pressed);
+ t->set_color("font_color_hover", "CheckButton", control_font_color_hover);
+ t->set_color("font_color_disabled", "CheckButton", control_font_color_disabled);
+ t->set_constant("hseparation", "CheckButton", 4 * scale);
+ t->set_constant("check_vadjust", "CheckButton", 0 * scale);
// Label
- t->set_font("font","Label", default_font );
-
- t->set_color("font_color","Label", Color(1,1,1) );
- t->set_color("font_color_shadow","Label", Color(0,0,0,0) );
-
- t->set_constant("shadow_offset_x","Label", 1 *scale);
- t->set_constant("shadow_offset_y","Label", 1 *scale);
- t->set_constant("shadow_as_outline","Label", 0 *scale);
- t->set_constant("line_spacing","Label", 3 *scale);
+ t->set_font("font", "Label", default_font);
+ t->set_color("font_color", "Label", Color(1, 1, 1));
+ t->set_color("font_color_shadow", "Label", Color(0, 0, 0, 0));
+ t->set_constant("shadow_offset_x", "Label", 1 * scale);
+ t->set_constant("shadow_offset_y", "Label", 1 * scale);
+ t->set_constant("shadow_as_outline", "Label", 0 * scale);
+ t->set_constant("line_spacing", "Label", 3 * scale);
// LineEdit
- t->set_stylebox("normal","LineEdit", make_stylebox( line_edit_png,5,5,5,5) );
- t->set_stylebox("focus","LineEdit", focus );
- t->set_stylebox("read_only","LineEdit", make_stylebox( line_edit_disabled_png,6,6,6,6) );
+ t->set_stylebox("normal", "LineEdit", make_stylebox(line_edit_png, 5, 5, 5, 5));
+ t->set_stylebox("focus", "LineEdit", focus);
+ t->set_stylebox("read_only", "LineEdit", make_stylebox(line_edit_disabled_png, 6, 6, 6, 6));
- t->set_font("font","LineEdit", default_font );
-
- t->set_color("font_color","LineEdit", control_font_color );
- t->set_color("font_color_selected","LineEdit", Color(0,0,0) );
- t->set_color("cursor_color","LineEdit", control_font_color_hover );
- t->set_color("selection_color","LineEdit", font_color_selection );
-
- t->set_constant("minimum_spaces","LineEdit", 12 *scale);
+ t->set_font("font", "LineEdit", default_font);
+ t->set_color("font_color", "LineEdit", control_font_color);
+ t->set_color("font_color_selected", "LineEdit", Color(0, 0, 0));
+ t->set_color("cursor_color", "LineEdit", control_font_color_hover);
+ t->set_color("selection_color", "LineEdit", font_color_selection);
+ t->set_constant("minimum_spaces", "LineEdit", 12 * scale);
// ProgressBar
- t->set_stylebox("bg","ProgressBar", make_stylebox( progress_bar_png,4,4,4,4,0,0,0,0) );
- t->set_stylebox("fg","ProgressBar", make_stylebox( progress_fill_png,6,6,6,6,2,1,2,1) );
-
- t->set_font("font","ProgressBar", default_font );
-
- t->set_color("font_color","ProgressBar", control_font_color_hover );
- t->set_color("font_color_shadow","ProgressBar", Color(0,0,0) );
+ t->set_stylebox("bg", "ProgressBar", make_stylebox(progress_bar_png, 4, 4, 4, 4, 0, 0, 0, 0));
+ t->set_stylebox("fg", "ProgressBar", make_stylebox(progress_fill_png, 6, 6, 6, 6, 2, 1, 2, 1));
+ t->set_font("font", "ProgressBar", default_font);
+ t->set_color("font_color", "ProgressBar", control_font_color_hover);
+ t->set_color("font_color_shadow", "ProgressBar", Color(0, 0, 0));
// TextEdit
- t->set_stylebox("normal","TextEdit", make_stylebox( tree_bg_png,3,3,3,3) );
- t->set_stylebox("focus","TextEdit", focus );
- t->set_stylebox("completion","TextEdit", make_stylebox( tree_bg_png,3,3,3,3) );
+ t->set_stylebox("normal", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3));
+ t->set_stylebox("focus", "TextEdit", focus);
+ t->set_stylebox("completion", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3));
- t->set_icon("tab","TextEdit", make_icon( tab_png) );
+ t->set_icon("tab", "TextEdit", make_icon(tab_png));
- t->set_font("font","TextEdit", default_font );
+ t->set_font("font", "TextEdit", default_font);
- t->set_color("completion_background_color", "TextEdit",Color::html("2C2A32"));
- t->set_color("completion_selected_color", "TextEdit",Color::html("434244"));
- t->set_color("completion_existing_color", "TextEdit",Color::html("21dfdfdf"));
- t->set_color("completion_scroll_color","TextEdit", control_font_color_pressed );
- t->set_color("completion_font_color","TextEdit", Color::html("aaaaaa"));
- t->set_color("font_color","TextEdit", control_font_color );
- t->set_color("font_color_selected","TextEdit", Color(0,0,0) );
- t->set_color("selection_color","TextEdit", font_color_selection );
- t->set_color("mark_color","TextEdit", Color(1.0,0.4,0.4,0.4) );
- t->set_color("breakpoint_color","TextEdit", Color(0.8,0.8,0.4,0.2) );
- t->set_color("current_line_color","TextEdit", Color(0.25,0.25,0.26,0.8) );
- t->set_color("caret_color","TextEdit", control_font_color );
+ t->set_color("completion_background_color", "TextEdit", Color::html("2C2A32"));
+ t->set_color("completion_selected_color", "TextEdit", Color::html("434244"));
+ t->set_color("completion_existing_color", "TextEdit", Color::html("21dfdfdf"));
+ t->set_color("completion_scroll_color", "TextEdit", control_font_color_pressed);
+ t->set_color("completion_font_color", "TextEdit", Color::html("aaaaaa"));
+ t->set_color("font_color", "TextEdit", control_font_color);
+ t->set_color("font_color_selected", "TextEdit", Color(0, 0, 0));
+ t->set_color("selection_color", "TextEdit", font_color_selection);
+ t->set_color("mark_color", "TextEdit", Color(1.0, 0.4, 0.4, 0.4));
+ t->set_color("breakpoint_color", "TextEdit", Color(0.8, 0.8, 0.4, 0.2));
+ t->set_color("current_line_color", "TextEdit", Color(0.25, 0.25, 0.26, 0.8));
+ t->set_color("caret_color", "TextEdit", control_font_color);
t->set_color("caret_background_color", "TextEdit", Color::html("000000"));
- t->set_color("symbol_color","TextEdit", control_font_color_hover );
- t->set_color("brace_mismatch_color","TextEdit", Color(1,0.2,0.2) );
- t->set_color("line_number_color","TextEdit",Color::html("66aaaaaa"));
- t->set_color("function_color","TextEdit",Color::html("66a2ce"));
- t->set_color("member_variable_color","TextEdit",Color::html("e64e59"));
- t->set_color("number_color","TextEdit",Color::html("EB9532"));
- t->set_color("word_highlighted_color","TextEdit",Color(0.8,0.9,0.9,0.15));
-
- t->set_constant("completion_lines","TextEdit", 7 );
- t->set_constant("completion_max_width","TextEdit", 50 );
- t->set_constant("completion_scroll_width","TextEdit", 3 );
- t->set_constant("line_spacing","TextEdit",4 *scale);
+ t->set_color("symbol_color", "TextEdit", control_font_color_hover);
+ t->set_color("brace_mismatch_color", "TextEdit", Color(1, 0.2, 0.2));
+ t->set_color("line_number_color", "TextEdit", Color::html("66aaaaaa"));
+ t->set_color("function_color", "TextEdit", Color::html("66a2ce"));
+ t->set_color("member_variable_color", "TextEdit", Color::html("e64e59"));
+ t->set_color("number_color", "TextEdit", Color::html("EB9532"));
+ t->set_color("word_highlighted_color", "TextEdit", Color(0.8, 0.9, 0.9, 0.15));
+ t->set_constant("completion_lines", "TextEdit", 7);
+ t->set_constant("completion_max_width", "TextEdit", 50);
+ t->set_constant("completion_scroll_width", "TextEdit", 3);
+ t->set_constant("line_spacing", "TextEdit", 4 * scale);
- Ref<Texture> empty_icon = memnew( ImageTexture );
+ Ref<Texture> empty_icon = memnew(ImageTexture);
// HScrollBar
- t->set_stylebox("scroll","HScrollBar", make_stylebox( scroll_bg_png,5,5,5,5,0,0,0,0) );
- t->set_stylebox("scroll_focus","HScrollBar", make_stylebox( scroll_bg_png,5,5,5,5,0,0,0,0) );
- t->set_stylebox("grabber","HScrollBar", make_stylebox( scroll_grabber_png,5,5,5,5,2,2,2,2) );
- t->set_stylebox("grabber_hilite","HScrollBar", make_stylebox( scroll_grabber_hl_png,5,5,5,5,2,2,2,2) );
-
- t->set_icon("increment","HScrollBar",empty_icon);
- t->set_icon("increment_hilite","HScrollBar",empty_icon);
- t->set_icon("decrement","HScrollBar",empty_icon);
- t->set_icon("decrement_hilite","HScrollBar",empty_icon);
-
+ t->set_stylebox("scroll", "HScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
+ t->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
+ t->set_stylebox("grabber", "HScrollBar", make_stylebox(scroll_grabber_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ t->set_stylebox("grabber_hilite", "HScrollBar", make_stylebox(scroll_grabber_hl_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ t->set_icon("increment", "HScrollBar", empty_icon);
+ t->set_icon("increment_hilite", "HScrollBar", empty_icon);
+ t->set_icon("decrement", "HScrollBar", empty_icon);
+ t->set_icon("decrement_hilite", "HScrollBar", empty_icon);
// VScrollBar
- t->set_stylebox("scroll","VScrollBar", make_stylebox( scroll_bg_png,5,5,5,5,0,0,0,0) );
- t->set_stylebox("scroll_focus","VScrollBar", make_stylebox( scroll_bg_png,5,5,5,5,0,0,0,0) );
- t->set_stylebox("grabber","VScrollBar", make_stylebox( scroll_grabber_png,5,5,5,5,2,2,2,2) );
- t->set_stylebox("grabber_hilite","VScrollBar", make_stylebox( scroll_grabber_hl_png,5,5,5,5,2,2,2,2) );
-
- t->set_icon("increment","VScrollBar",empty_icon);
- t->set_icon("increment_hilite","VScrollBar",empty_icon);
- t->set_icon("decrement","VScrollBar",empty_icon);
- t->set_icon("decrement_hilite","VScrollBar",empty_icon);
-
+ t->set_stylebox("scroll", "VScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
+ t->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(scroll_bg_png, 5, 5, 5, 5, 0, 0, 0, 0));
+ t->set_stylebox("grabber", "VScrollBar", make_stylebox(scroll_grabber_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ t->set_stylebox("grabber_hilite", "VScrollBar", make_stylebox(scroll_grabber_hl_png, 5, 5, 5, 5, 2, 2, 2, 2));
+ t->set_icon("increment", "VScrollBar", empty_icon);
+ t->set_icon("increment_hilite", "VScrollBar", empty_icon);
+ t->set_icon("decrement", "VScrollBar", empty_icon);
+ t->set_icon("decrement_hilite", "VScrollBar", empty_icon);
// HSlider
- t->set_stylebox("slider","HSlider", make_stylebox( hslider_bg_png,4,4,4,4) );
- t->set_stylebox("grabber_hilite","HSlider", make_stylebox( hslider_grabber_hl_png,6,6,6,6) );
- t->set_stylebox("focus","HSlider", focus );
-
- t->set_icon("grabber","HSlider", make_icon( hslider_grabber_png ) );
- t->set_icon("grabber_hilite","HSlider", make_icon( hslider_grabber_hl_png ) );
- t->set_icon("tick","HSlider", make_icon( hslider_tick_png ) );
-
-
+ t->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
+ t->set_stylebox("grabber_hilite", "HSlider", make_stylebox(hslider_grabber_hl_png, 6, 6, 6, 6));
+ t->set_stylebox("focus", "HSlider", focus);
+ t->set_icon("grabber", "HSlider", make_icon(hslider_grabber_png));
+ t->set_icon("grabber_hilite", "HSlider", make_icon(hslider_grabber_hl_png));
+ t->set_icon("tick", "HSlider", make_icon(hslider_tick_png));
// VSlider
- t->set_stylebox("slider","VSlider", make_stylebox( vslider_bg_png,4,4,4,4) );
- t->set_stylebox("grabber_hilite","VSlider", make_stylebox( vslider_grabber_hl_png,6,6,6,6) );
- t->set_stylebox("focus","HSlider", focus );
-
- t->set_icon("grabber","VSlider", make_icon( vslider_grabber_png) );
- t->set_icon("grabber_hilite","VSlider", make_icon( vslider_grabber_hl_png ) );
- t->set_icon("tick","VSlider", make_icon( vslider_tick_png ) );
-
+ t->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
+ t->set_stylebox("grabber_hilite", "VSlider", make_stylebox(vslider_grabber_hl_png, 6, 6, 6, 6));
+ t->set_stylebox("focus", "HSlider", focus);
+ t->set_icon("grabber", "VSlider", make_icon(vslider_grabber_png));
+ t->set_icon("grabber_hilite", "VSlider", make_icon(vslider_grabber_hl_png));
+ t->set_icon("tick", "VSlider", make_icon(vslider_tick_png));
// SpinBox
- t->set_icon("updown","SpinBox",make_icon(spinbox_updown_png));
-
-
+ t->set_icon("updown", "SpinBox", make_icon(spinbox_updown_png));
// WindowDialog
- Ref<StyleBoxTexture> style_pp_win = sb_expand(make_stylebox( popup_window_png,10,30,10,8),8,26,8,4);
+ Ref<StyleBoxTexture> style_pp_win = sb_expand(make_stylebox(popup_window_png, 10, 30, 10, 8), 8, 26, 8, 4);
/*for(int i=0;i<4;i++)
style_pp_win->set_expand_margin_size((Margin)i,3);
style_pp_win->set_expand_margin_size(MARGIN_TOP,26);*/
- t->set_stylebox("panel","WindowDialog", style_pp_win );
+ t->set_stylebox("panel", "WindowDialog", style_pp_win);
- t->set_icon("close","WindowDialog", make_icon( close_png ) );
- t->set_icon("close_hilite","WindowDialog", make_icon( close_hl_png ) );
+ t->set_icon("close", "WindowDialog", make_icon(close_png));
+ t->set_icon("close_hilite", "WindowDialog", make_icon(close_hl_png));
- t->set_font("title_font","WindowDialog", large_font );
+ t->set_font("title_font", "WindowDialog", large_font);
- t->set_color("title_color","WindowDialog", Color(0,0,0) );
-
- t->set_constant("close_h_ofs","WindowDialog", 22 *scale);
- t->set_constant("close_v_ofs","WindowDialog", 20 *scale);
- t->set_constant("titlebar_height","WindowDialog", 18 *scale);
- t->set_constant("title_height","WindowDialog", 20 *scale);
+ t->set_color("title_color", "WindowDialog", Color(0, 0, 0));
+ t->set_constant("close_h_ofs", "WindowDialog", 22 * scale);
+ t->set_constant("close_v_ofs", "WindowDialog", 20 * scale);
+ t->set_constant("titlebar_height", "WindowDialog", 18 * scale);
+ t->set_constant("title_height", "WindowDialog", 20 * scale);
// File Dialog
- t->set_icon("reload","FileDialog",make_icon( icon_reload_png ));
-
+ t->set_icon("reload", "FileDialog", make_icon(icon_reload_png));
// Popup
- Ref<StyleBoxTexture> style_pp = sb_expand( make_stylebox( popup_bg_png,5,5,5,5,4,4,4,4),2,2,2,2);
+ Ref<StyleBoxTexture> style_pp = sb_expand(make_stylebox(popup_bg_png, 5, 5, 5, 5, 4, 4, 4, 4), 2, 2, 2, 2);
- Ref<StyleBoxTexture> selected = make_stylebox( selection_png,6,6,6,6);
- for(int i=0;i<4;i++) {
- selected->set_expand_margin_size(Margin(i),2 *scale);
+ Ref<StyleBoxTexture> selected = make_stylebox(selection_png, 6, 6, 6, 6);
+ for (int i = 0; i < 4; i++) {
+ selected->set_expand_margin_size(Margin(i), 2 * scale);
}
- t->set_stylebox("panel","PopupPanel", style_pp );
-
-
-
+ t->set_stylebox("panel", "PopupPanel", style_pp);
// PopupMenu
- t->set_stylebox("panel","PopupMenu", make_stylebox( popup_bg_png,4,4,4,4,10,10,10,10) );
- t->set_stylebox("panel_disabled","PopupMenu", make_stylebox( popup_bg_disabled_png,4,4,4,4) );
- t->set_stylebox("hover","PopupMenu", selected );
- t->set_stylebox("separator","PopupMenu", make_stylebox( vseparator_png,3,3,3,3) );
+ t->set_stylebox("panel", "PopupMenu", make_stylebox(popup_bg_png, 4, 4, 4, 4, 10, 10, 10, 10));
+ t->set_stylebox("panel_disabled", "PopupMenu", make_stylebox(popup_bg_disabled_png, 4, 4, 4, 4));
+ t->set_stylebox("hover", "PopupMenu", selected);
+ t->set_stylebox("separator", "PopupMenu", make_stylebox(vseparator_png, 3, 3, 3, 3));
- t->set_icon("checked","PopupMenu", make_icon(checked_png) );
- t->set_icon("unchecked","PopupMenu", make_icon(unchecked_png) );
- t->set_icon("submenu","PopupMenu", make_icon(submenu_png) );
+ t->set_icon("checked", "PopupMenu", make_icon(checked_png));
+ t->set_icon("unchecked", "PopupMenu", make_icon(unchecked_png));
+ t->set_icon("submenu", "PopupMenu", make_icon(submenu_png));
- t->set_font("font","PopupMenu", default_font );
+ t->set_font("font", "PopupMenu", default_font);
- t->set_color("font_color","PopupMenu", control_font_color );
- t->set_color("font_color_accel","PopupMenu", Color(0.7,0.7,0.7,0.8) );
- t->set_color("font_color_disabled","PopupMenu", Color(0.4,0.4,0.4,0.8) );
- t->set_color("font_color_hover","PopupMenu", control_font_color );
-
- t->set_constant("hseparation","PopupMenu",4 *scale);
- t->set_constant("vseparation","PopupMenu",4 *scale);
+ t->set_color("font_color", "PopupMenu", control_font_color);
+ t->set_color("font_color_accel", "PopupMenu", Color(0.7, 0.7, 0.7, 0.8));
+ t->set_color("font_color_disabled", "PopupMenu", Color(0.4, 0.4, 0.4, 0.8));
+ t->set_color("font_color_hover", "PopupMenu", control_font_color);
+ t->set_constant("hseparation", "PopupMenu", 4 * scale);
+ t->set_constant("vseparation", "PopupMenu", 4 * scale);
// GraphNode
- Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_png,6,24,6,5,3,24,16,5);
- Ref<StyleBoxTexture> graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,3,24,16,5);
- Ref<StyleBoxTexture> graphsbdefault = make_stylebox(graph_node_default_png,4,4,4,4,6,4,4,4);
- Ref<StyleBoxTexture> graphsbdeffocus = make_stylebox(graph_node_default_focus_png,4,4,4,4,6,4,4,4);
+ Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_png, 6, 24, 6, 5, 3, 24, 16, 5);
+ Ref<StyleBoxTexture> graphsbselected = make_stylebox(graph_node_selected_png, 6, 24, 6, 5, 3, 24, 16, 5);
+ Ref<StyleBoxTexture> graphsbdefault = make_stylebox(graph_node_default_png, 4, 4, 4, 4, 6, 4, 4, 4);
+ Ref<StyleBoxTexture> graphsbdeffocus = make_stylebox(graph_node_default_focus_png, 4, 4, 4, 4, 6, 4, 4, 4);
//graphsb->set_expand_margin_size(MARGIN_LEFT,10);
//graphsb->set_expand_margin_size(MARGIN_RIGHT,10);
- t->set_stylebox("frame","GraphNode", graphsb );
- t->set_stylebox("selectedframe","GraphNode", graphsbselected );
- t->set_stylebox("defaultframe", "GraphNode", graphsbdefault );
- t->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus );
- t->set_constant("separation","GraphNode", 1 *scale);
- t->set_icon("port","GraphNode", make_icon( graph_port_png ) );
- t->set_icon("close","GraphNode", make_icon( graph_node_close_png ) );
- t->set_font("title_font","GraphNode", default_font );
- t->set_color("title_color","GraphNode", Color(0,0,0,1));
- t->set_constant("title_offset","GraphNode", 18 *scale);
- t->set_constant("close_offset","GraphNode", 18 *scale);
- t->set_constant("port_offset","GraphNode", 3 *scale);
-
+ t->set_stylebox("frame", "GraphNode", graphsb);
+ t->set_stylebox("selectedframe", "GraphNode", graphsbselected);
+ t->set_stylebox("defaultframe", "GraphNode", graphsbdefault);
+ t->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus);
+ t->set_constant("separation", "GraphNode", 1 * scale);
+ t->set_icon("port", "GraphNode", make_icon(graph_port_png));
+ t->set_icon("close", "GraphNode", make_icon(graph_node_close_png));
+ t->set_font("title_font", "GraphNode", default_font);
+ t->set_color("title_color", "GraphNode", Color(0, 0, 0, 1));
+ t->set_constant("title_offset", "GraphNode", 18 * scale);
+ t->set_constant("close_offset", "GraphNode", 18 * scale);
+ t->set_constant("port_offset", "GraphNode", 3 * scale);
// Tree
- Ref<StyleBoxTexture> tree_selected = make_stylebox( selection_png,4,4,4,4,8,0,8,0);
- Ref<StyleBoxTexture> tree_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,0,8,0);
+ Ref<StyleBoxTexture> tree_selected = make_stylebox(selection_png, 4, 4, 4, 4, 8, 0, 8, 0);
+ Ref<StyleBoxTexture> tree_selected_oof = make_stylebox(selection_oof_png, 4, 4, 4, 4, 8, 0, 8, 0);
- t->set_stylebox("bg","Tree", make_stylebox( tree_bg_png,4,4,4,5) );
- t->set_stylebox("bg_focus","Tree", focus );
- t->set_stylebox("selected","Tree", tree_selected_oof );
- t->set_stylebox("selected_focus","Tree", tree_selected );
- t->set_stylebox("cursor","Tree", focus );
- t->set_stylebox("cursor_unfocused","Tree", focus );
- t->set_stylebox("button_pressed","Tree",make_stylebox( button_pressed_png,4,4,4,4));
- t->set_stylebox("title_button_normal","Tree", make_stylebox( tree_title_png,4,4,4,4) );
- t->set_stylebox("title_button_pressed","Tree", make_stylebox( tree_title_pressed_png,4,4,4,4) );
- t->set_stylebox("title_button_hover","Tree", make_stylebox( tree_title_png,4,4,4,4) );
+ t->set_stylebox("bg", "Tree", make_stylebox(tree_bg_png, 4, 4, 4, 5));
+ t->set_stylebox("bg_focus", "Tree", focus);
+ t->set_stylebox("selected", "Tree", tree_selected_oof);
+ t->set_stylebox("selected_focus", "Tree", tree_selected);
+ t->set_stylebox("cursor", "Tree", focus);
+ t->set_stylebox("cursor_unfocused", "Tree", focus);
+ t->set_stylebox("button_pressed", "Tree", make_stylebox(button_pressed_png, 4, 4, 4, 4));
+ t->set_stylebox("title_button_normal", "Tree", make_stylebox(tree_title_png, 4, 4, 4, 4));
+ t->set_stylebox("title_button_pressed", "Tree", make_stylebox(tree_title_pressed_png, 4, 4, 4, 4));
+ t->set_stylebox("title_button_hover", "Tree", make_stylebox(tree_title_png, 4, 4, 4, 4));
- t->set_icon("checked","Tree",make_icon(checked_png));
- t->set_icon("unchecked","Tree",make_icon(unchecked_png));
- t->set_icon("updown","Tree",make_icon(updown_png));
- t->set_icon("select_arrow","Tree",make_icon(dropdown_png));
- t->set_icon("arrow","Tree",make_icon(arrow_down_png));
- t->set_icon("arrow_collapsed","Tree",make_icon(arrow_right_png));
+ t->set_icon("checked", "Tree", make_icon(checked_png));
+ t->set_icon("unchecked", "Tree", make_icon(unchecked_png));
+ t->set_icon("updown", "Tree", make_icon(updown_png));
+ t->set_icon("select_arrow", "Tree", make_icon(dropdown_png));
+ t->set_icon("arrow", "Tree", make_icon(arrow_down_png));
+ t->set_icon("arrow_collapsed", "Tree", make_icon(arrow_right_png));
- t->set_font("title_button_font","Tree", default_font );
- t->set_font("font","Tree", default_font );
+ t->set_font("title_button_font", "Tree", default_font);
+ t->set_font("font", "Tree", default_font);
- t->set_color("title_button_color","Tree", control_font_color );
- t->set_color("font_color","Tree", control_font_color_low );
- t->set_color("font_color_selected","Tree", control_font_color_pressed );
- t->set_color("selection_color","Tree", Color(0.1,0.1,1,0.8) );
- t->set_color("cursor_color","Tree", Color(0,0,0) );
- t->set_color("guide_color","Tree", Color(0,0,0,0.1) );
- t->set_color("drop_position_color","Tree", Color(1,0.3,0.2) );
- t->set_color("relationship_line_color", "Tree", Color::html("464646") );
+ t->set_color("title_button_color", "Tree", control_font_color);
+ t->set_color("font_color", "Tree", control_font_color_low);
+ t->set_color("font_color_selected", "Tree", control_font_color_pressed);
+ t->set_color("selection_color", "Tree", Color(0.1, 0.1, 1, 0.8));
+ t->set_color("cursor_color", "Tree", Color(0, 0, 0));
+ t->set_color("guide_color", "Tree", Color(0, 0, 0, 0.1));
+ t->set_color("drop_position_color", "Tree", Color(1, 0.3, 0.2));
+ t->set_color("relationship_line_color", "Tree", Color::html("464646"));
- t->set_constant("hseparation","Tree",4 *scale);
- t->set_constant("vseparation","Tree",4 *scale);
- t->set_constant("guide_width","Tree",2 *scale);
- t->set_constant("item_margin","Tree",12 *scale);
- t->set_constant("button_margin","Tree",4 *scale);
+ t->set_constant("hseparation", "Tree", 4 * scale);
+ t->set_constant("vseparation", "Tree", 4 * scale);
+ t->set_constant("guide_width", "Tree", 2 * scale);
+ t->set_constant("item_margin", "Tree", 12 * scale);
+ t->set_constant("button_margin", "Tree", 4 * scale);
t->set_constant("draw_relationship_lines", "Tree", 0);
t->set_constant("scroll_border", "Tree", 4);
t->set_constant("scroll_speed", "Tree", 12);
-
// ItemList
- Ref<StyleBoxTexture> item_selected = make_stylebox( selection_png,4,4,4,4,8,2,8,2);
- Ref<StyleBoxTexture> item_selected_oof = make_stylebox( selection_oof_png,4,4,4,4,8,2,8,2);
-
- t->set_stylebox("bg","ItemList", make_stylebox( tree_bg_png,4,4,4,5) );
- t->set_stylebox("bg_focus","ItemList", focus );
- t->set_constant("hseparation","ItemList",4);
- t->set_constant("vseparation","ItemList",2);
- t->set_constant("icon_margin","ItemList",4);
- t->set_constant("line_separation","ItemList",2 *scale);
- t->set_font("font","ItemList", default_font );
- t->set_color("font_color","ItemList", control_font_color_lower );
- t->set_color("font_color_selected","ItemList", control_font_color_pressed );
- t->set_color("guide_color","ItemList", Color(0,0,0,0.1) );
- t->set_stylebox("selected","ItemList", item_selected_oof );
- t->set_stylebox("selected_focus","ItemList", item_selected );
- t->set_stylebox("cursor","ItemList", focus );
- t->set_stylebox("cursor_unfocused","ItemList", focus );
+ Ref<StyleBoxTexture> item_selected = make_stylebox(selection_png, 4, 4, 4, 4, 8, 2, 8, 2);
+ Ref<StyleBoxTexture> item_selected_oof = make_stylebox(selection_oof_png, 4, 4, 4, 4, 8, 2, 8, 2);
+ t->set_stylebox("bg", "ItemList", make_stylebox(tree_bg_png, 4, 4, 4, 5));
+ t->set_stylebox("bg_focus", "ItemList", focus);
+ t->set_constant("hseparation", "ItemList", 4);
+ t->set_constant("vseparation", "ItemList", 2);
+ t->set_constant("icon_margin", "ItemList", 4);
+ t->set_constant("line_separation", "ItemList", 2 * scale);
+ t->set_font("font", "ItemList", default_font);
+ t->set_color("font_color", "ItemList", control_font_color_lower);
+ t->set_color("font_color_selected", "ItemList", control_font_color_pressed);
+ t->set_color("guide_color", "ItemList", Color(0, 0, 0, 0.1));
+ t->set_stylebox("selected", "ItemList", item_selected_oof);
+ t->set_stylebox("selected_focus", "ItemList", item_selected);
+ t->set_stylebox("cursor", "ItemList", focus);
+ t->set_stylebox("cursor_unfocused", "ItemList", focus);
// TabContainer
- Ref<StyleBoxTexture> tc_sb = sb_expand( make_stylebox( tab_container_bg_png,4,4,4,4,4,4,4,4),3,3,3,3);
-
- tc_sb->set_expand_margin_size(MARGIN_TOP,2 *scale);
- tc_sb->set_default_margin(MARGIN_TOP,8 *scale);
+ Ref<StyleBoxTexture> tc_sb = sb_expand(make_stylebox(tab_container_bg_png, 4, 4, 4, 4, 4, 4, 4, 4), 3, 3, 3, 3);
- t->set_stylebox("tab_fg","TabContainer", sb_expand( make_stylebox( tab_current_png,4,4,4,1,16,4,16,4),2,2,2,2) );
- t->set_stylebox("tab_bg","TabContainer", sb_expand( make_stylebox( tab_behind_png,5,5,5,1,16,6,16,4),3,0,3,3) );
- t->set_stylebox("panel","TabContainer", tc_sb );
+ tc_sb->set_expand_margin_size(MARGIN_TOP, 2 * scale);
+ tc_sb->set_default_margin(MARGIN_TOP, 8 * scale);
- t->set_icon("increment","TabContainer",make_icon( scroll_button_right_png));
- t->set_icon("increment_hilite","TabContainer",make_icon( scroll_button_right_hl_png));
- t->set_icon("decrement","TabContainer",make_icon( scroll_button_left_png));
- t->set_icon("decrement_hilite","TabContainer",make_icon( scroll_button_left_hl_png));
- t->set_icon("menu","TabContainer",make_icon( tab_menu_png));
- t->set_icon("menu_hilite","TabContainer",make_icon( tab_menu_hl_png));
+ t->set_stylebox("tab_fg", "TabContainer", sb_expand(make_stylebox(tab_current_png, 4, 4, 4, 1, 16, 4, 16, 4), 2, 2, 2, 2));
+ t->set_stylebox("tab_bg", "TabContainer", sb_expand(make_stylebox(tab_behind_png, 5, 5, 5, 1, 16, 6, 16, 4), 3, 0, 3, 3));
+ t->set_stylebox("panel", "TabContainer", tc_sb);
- t->set_font("font","TabContainer", default_font );
+ t->set_icon("increment", "TabContainer", make_icon(scroll_button_right_png));
+ t->set_icon("increment_hilite", "TabContainer", make_icon(scroll_button_right_hl_png));
+ t->set_icon("decrement", "TabContainer", make_icon(scroll_button_left_png));
+ t->set_icon("decrement_hilite", "TabContainer", make_icon(scroll_button_left_hl_png));
+ t->set_icon("menu", "TabContainer", make_icon(tab_menu_png));
+ t->set_icon("menu_hilite", "TabContainer", make_icon(tab_menu_hl_png));
- t->set_color("font_color_fg","TabContainer", control_font_color_hover );
- t->set_color("font_color_bg","TabContainer", control_font_color_low );
-
- t->set_constant("side_margin","TabContainer", 8 *scale);
- t->set_constant("top_margin","TabContainer", 24 *scale);
- t->set_constant("label_valign_fg","TabContainer", 0 *scale);
- t->set_constant("label_valign_bg","TabContainer", 2 *scale);
- t->set_constant("hseparation","TabContainer", 4 *scale);
+ t->set_font("font", "TabContainer", default_font);
+ t->set_color("font_color_fg", "TabContainer", control_font_color_hover);
+ t->set_color("font_color_bg", "TabContainer", control_font_color_low);
+ t->set_constant("side_margin", "TabContainer", 8 * scale);
+ t->set_constant("top_margin", "TabContainer", 24 * scale);
+ t->set_constant("label_valign_fg", "TabContainer", 0 * scale);
+ t->set_constant("label_valign_bg", "TabContainer", 2 * scale);
+ t->set_constant("hseparation", "TabContainer", 4 * scale);
// Tabs
- t->set_stylebox("tab_fg","Tabs", sb_expand( make_stylebox( tab_current_png,4,3,4,1,16,3,16,2),2,2,2,2) );
- t->set_stylebox("tab_bg","Tabs", sb_expand( make_stylebox( tab_behind_png,5,4,5,1,16,5,16,2),3,3,3,3) );
- t->set_stylebox("panel","Tabs",tc_sb );
- t->set_stylebox("button_pressed","Tabs", make_stylebox( button_pressed_png,4,4,4,4) );
- t->set_stylebox("button","Tabs", make_stylebox( button_normal_png,4,4,4,4) );
-
- t->set_icon("increment","Tabs",make_icon( scroll_button_right_png));
- t->set_icon("increment_hilite","Tabs",make_icon( scroll_button_right_hl_png));
- t->set_icon("decrement","Tabs",make_icon( scroll_button_left_png));
- t->set_icon("decrement_hilite","Tabs",make_icon( scroll_button_left_hl_png));
- t->set_icon("close","Tabs",make_icon( tab_close_png));
-
- t->set_font("font","Tabs", default_font );
+ t->set_stylebox("tab_fg", "Tabs", sb_expand(make_stylebox(tab_current_png, 4, 3, 4, 1, 16, 3, 16, 2), 2, 2, 2, 2));
+ t->set_stylebox("tab_bg", "Tabs", sb_expand(make_stylebox(tab_behind_png, 5, 4, 5, 1, 16, 5, 16, 2), 3, 3, 3, 3));
+ t->set_stylebox("panel", "Tabs", tc_sb);
+ t->set_stylebox("button_pressed", "Tabs", make_stylebox(button_pressed_png, 4, 4, 4, 4));
+ t->set_stylebox("button", "Tabs", make_stylebox(button_normal_png, 4, 4, 4, 4));
- t->set_color("font_color_fg","Tabs", control_font_color_hover );
- t->set_color("font_color_bg","Tabs", control_font_color_low );
+ t->set_icon("increment", "Tabs", make_icon(scroll_button_right_png));
+ t->set_icon("increment_hilite", "Tabs", make_icon(scroll_button_right_hl_png));
+ t->set_icon("decrement", "Tabs", make_icon(scroll_button_left_png));
+ t->set_icon("decrement_hilite", "Tabs", make_icon(scroll_button_left_hl_png));
+ t->set_icon("close", "Tabs", make_icon(tab_close_png));
- t->set_constant("top_margin","Tabs", 24 *scale);
- t->set_constant("label_valign_fg","Tabs", 0 *scale);
- t->set_constant("label_valign_bg","Tabs", 2 *scale);
- t->set_constant("hseparation","Tabs", 4 *scale);
+ t->set_font("font", "Tabs", default_font);
+ t->set_color("font_color_fg", "Tabs", control_font_color_hover);
+ t->set_color("font_color_bg", "Tabs", control_font_color_low);
+ t->set_constant("top_margin", "Tabs", 24 * scale);
+ t->set_constant("label_valign_fg", "Tabs", 0 * scale);
+ t->set_constant("label_valign_bg", "Tabs", 2 * scale);
+ t->set_constant("hseparation", "Tabs", 4 * scale);
// Separators
- t->set_stylebox("separator","HSeparator", make_stylebox( vseparator_png,3,3,3,3) );
- t->set_stylebox("separator","VSeparator", make_stylebox( hseparator_png,3,3,3,3) );
+ t->set_stylebox("separator", "HSeparator", make_stylebox(vseparator_png, 3, 3, 3, 3));
+ t->set_stylebox("separator", "VSeparator", make_stylebox(hseparator_png, 3, 3, 3, 3));
- t->set_icon("close","Icons", make_icon(icon_close_png));
- t->set_font("normal","Fonts", default_font );
- t->set_font("large","Fonts", large_font );
-
- t->set_constant("separation","HSeparator", 4 *scale);
- t->set_constant("separation","VSeparator", 4 *scale);
+ t->set_icon("close", "Icons", make_icon(icon_close_png));
+ t->set_font("normal", "Fonts", default_font);
+ t->set_font("large", "Fonts", large_font);
+ t->set_constant("separation", "HSeparator", 4 * scale);
+ t->set_constant("separation", "VSeparator", 4 * scale);
// Dialogs
- t->set_constant("margin","Dialogs",8 *scale);
- t->set_constant("button_margin","Dialogs",32 *scale);
-
-
+ t->set_constant("margin", "Dialogs", 8 * scale);
+ t->set_constant("button_margin", "Dialogs", 32 * scale);
// FileDialog
- t->set_icon("folder","FileDialog",make_icon(icon_folder_png));
- t->set_color("files_disabled","FileDialog",Color(0,0,0,0.7));
-
-
+ t->set_icon("folder", "FileDialog", make_icon(icon_folder_png));
+ t->set_color("files_disabled", "FileDialog", Color(0, 0, 0, 0.7));
// colorPicker
- t->set_constant("value_height","ColorPicker", 23 *scale);
- t->set_constant("value_width","ColorPicker", 50 *scale);
- t->set_constant("color_width","ColorPicker", 100 *scale);
- t->set_constant("label_width","ColorPicker", 20 *scale);
- t->set_constant("hseparator","ColorPicker", 4 *scale);
+ t->set_constant("value_height", "ColorPicker", 23 * scale);
+ t->set_constant("value_width", "ColorPicker", 50 * scale);
+ t->set_constant("color_width", "ColorPicker", 100 * scale);
+ t->set_constant("label_width", "ColorPicker", 20 * scale);
+ t->set_constant("hseparator", "ColorPicker", 4 * scale);
- t->set_icon("screen_picker","ColorPicker", make_icon( icon_color_pick_png ) );
- t->set_icon("add_preset","ColorPicker", make_icon( icon_add_png ) );
+ t->set_icon("screen_picker", "ColorPicker", make_icon(icon_color_pick_png));
+ t->set_icon("add_preset", "ColorPicker", make_icon(icon_add_png));
t->set_shader("uv_editor", "ColorPicker", make_shader("", uv_editor_shader_code, ""));
t->set_shader("w_editor", "ColorPicker", make_shader("", w_editor_shader_code, ""));
// TooltipPanel
- Ref<StyleBoxTexture> style_tt = make_stylebox( tooltip_bg_png,4,4,4,4);
- for(int i=0;i<4;i++)
- style_tt->set_expand_margin_size((Margin)i,4 *scale);
+ Ref<StyleBoxTexture> style_tt = make_stylebox(tooltip_bg_png, 4, 4, 4, 4);
+ for (int i = 0; i < 4; i++)
+ style_tt->set_expand_margin_size((Margin)i, 4 * scale);
- t->set_stylebox("panel","TooltipPanel", style_tt );
+ t->set_stylebox("panel", "TooltipPanel", style_tt);
- t->set_font("font","TooltipLabel", default_font );
-
- t->set_color("font_color","TooltipLabel", Color(0,0,0) );
- t->set_color("font_color_shadow","TooltipLabel", Color(0,0,0,0.1) );
-
- t->set_constant("shadow_offset_x","TooltipLabel", 1 );
- t->set_constant("shadow_offset_y","TooltipLabel", 1 );
+ t->set_font("font", "TooltipLabel", default_font);
+ t->set_color("font_color", "TooltipLabel", Color(0, 0, 0));
+ t->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0.1));
+ t->set_constant("shadow_offset_x", "TooltipLabel", 1);
+ t->set_constant("shadow_offset_y", "TooltipLabel", 1);
// RichTextLabel
- t->set_stylebox("focus","RichTextLabel", focus );
-
- t->set_font("normal_font","RichTextLabel", default_font );
- t->set_font("bold_font","RichTextLabel", default_font );
- t->set_font("italics_font","RichTextLabel", default_font );
- t->set_font("bold_italics_font","RichTextLabel", default_font );
- t->set_font("mono_font","RichTextLabel", default_font );
+ t->set_stylebox("focus", "RichTextLabel", focus);
- t->set_color("default_color","RichTextLabel", control_font_color );
- t->set_color("font_color_selected","RichTextLabel", font_color_selection );
- t->set_color("selection_color","RichTextLabel", Color(0.1,0.1,1,0.8) );
-
- t->set_constant("line_separation","RichTextLabel", 1 *scale);
- t->set_constant("table_hseparation","RichTextLabel", 3 *scale);
- t->set_constant("table_vseparation","RichTextLabel", 3 *scale);
+ t->set_font("normal_font", "RichTextLabel", default_font);
+ t->set_font("bold_font", "RichTextLabel", default_font);
+ t->set_font("italics_font", "RichTextLabel", default_font);
+ t->set_font("bold_italics_font", "RichTextLabel", default_font);
+ t->set_font("mono_font", "RichTextLabel", default_font);
+ t->set_color("default_color", "RichTextLabel", control_font_color);
+ t->set_color("font_color_selected", "RichTextLabel", font_color_selection);
+ t->set_color("selection_color", "RichTextLabel", Color(0.1, 0.1, 1, 0.8));
+ t->set_constant("line_separation", "RichTextLabel", 1 * scale);
+ t->set_constant("table_hseparation", "RichTextLabel", 3 * scale);
+ t->set_constant("table_vseparation", "RichTextLabel", 3 * scale);
// Containers
- t->set_stylebox("bg","VSplitContainer", make_stylebox( vsplit_bg_png,1,1,1,1) );
- t->set_stylebox("bg","HSplitContainer", make_stylebox( hsplit_bg_png,1,1,1,1) );
-
- t->set_icon("grabber","VSplitContainer",make_icon(vsplitter_png));
- t->set_icon("grabber","HSplitContainer",make_icon(hsplitter_png));
-
- t->set_constant("separation","HBoxContainer",4 *scale);
- t->set_constant("separation","VBoxContainer",4 *scale);
- t->set_constant("margin_left","MarginContainer",8 *scale);
- t->set_constant("margin_top","MarginContainer",0 *scale);
- t->set_constant("margin_right","MarginContainer",0 *scale);
- t->set_constant("margin_bottom","MarginContainer",0 *scale);
- t->set_constant("hseparation","GridContainer",4 *scale);
- t->set_constant("vseparation","GridContainer",4 *scale);
- t->set_constant("separation","HSplitContainer",12 *scale);
- t->set_constant("separation","VSplitContainer",12 *scale);
- t->set_constant("autohide","HSplitContainer",1 *scale);
- t->set_constant("autohide","VSplitContainer",1 *scale);
+ t->set_stylebox("bg", "VSplitContainer", make_stylebox(vsplit_bg_png, 1, 1, 1, 1));
+ t->set_stylebox("bg", "HSplitContainer", make_stylebox(hsplit_bg_png, 1, 1, 1, 1));
+ t->set_icon("grabber", "VSplitContainer", make_icon(vsplitter_png));
+ t->set_icon("grabber", "HSplitContainer", make_icon(hsplitter_png));
+ t->set_constant("separation", "HBoxContainer", 4 * scale);
+ t->set_constant("separation", "VBoxContainer", 4 * scale);
+ t->set_constant("margin_left", "MarginContainer", 8 * scale);
+ t->set_constant("margin_top", "MarginContainer", 0 * scale);
+ t->set_constant("margin_right", "MarginContainer", 0 * scale);
+ t->set_constant("margin_bottom", "MarginContainer", 0 * scale);
+ t->set_constant("hseparation", "GridContainer", 4 * scale);
+ t->set_constant("vseparation", "GridContainer", 4 * scale);
+ t->set_constant("separation", "HSplitContainer", 12 * scale);
+ t->set_constant("separation", "VSplitContainer", 12 * scale);
+ t->set_constant("autohide", "HSplitContainer", 1 * scale);
+ t->set_constant("autohide", "VSplitContainer", 1 * scale);
// HButtonArray
- t->set_stylebox("normal","HButtonArray", sb_button_normal);
- t->set_stylebox("selected","HButtonArray", sb_button_pressed);
- t->set_stylebox("hover","HButtonArray", sb_button_hover);
+ t->set_stylebox("normal", "HButtonArray", sb_button_normal);
+ t->set_stylebox("selected", "HButtonArray", sb_button_pressed);
+ t->set_stylebox("hover", "HButtonArray", sb_button_hover);
- t->set_font("font","HButtonArray", default_font);
- t->set_font("font_selected","HButtonArray", default_font);
+ t->set_font("font", "HButtonArray", default_font);
+ t->set_font("font_selected", "HButtonArray", default_font);
- t->set_color("font_color","HButtonArray", control_font_color_low );
- t->set_color("font_color_selected","HButtonArray", control_font_color_hover );
+ t->set_color("font_color", "HButtonArray", control_font_color_low);
+ t->set_color("font_color_selected", "HButtonArray", control_font_color_hover);
- t->set_constant("icon_separator","HButtonArray", 2 *scale );
- t->set_constant("button_separator","HButtonArray", 4 *scale );
-
- t->set_stylebox("focus","HButtonArray", focus );
+ t->set_constant("icon_separator", "HButtonArray", 2 * scale);
+ t->set_constant("button_separator", "HButtonArray", 4 * scale);
+ t->set_stylebox("focus", "HButtonArray", focus);
// VButtonArray
- t->set_stylebox("normal","VButtonArray", sb_button_normal);
- t->set_stylebox("selected","VButtonArray", sb_button_pressed);
- t->set_stylebox("hover","VButtonArray", sb_button_hover);
-
- t->set_font("font","VButtonArray", default_font);
- t->set_font("font_selected","VButtonArray", default_font);
+ t->set_stylebox("normal", "VButtonArray", sb_button_normal);
+ t->set_stylebox("selected", "VButtonArray", sb_button_pressed);
+ t->set_stylebox("hover", "VButtonArray", sb_button_hover);
- t->set_color("font_color","VButtonArray", control_font_color_low );
- t->set_color("font_color_selected","VButtonArray", control_font_color_hover );
+ t->set_font("font", "VButtonArray", default_font);
+ t->set_font("font_selected", "VButtonArray", default_font);
- t->set_constant("icon_separator","VButtonArray", 2 *scale);
- t->set_constant("button_separator","VButtonArray", 4 *scale);
+ t->set_color("font_color", "VButtonArray", control_font_color_low);
+ t->set_color("font_color_selected", "VButtonArray", control_font_color_hover);
- t->set_stylebox("focus","VButtonArray", focus );
+ t->set_constant("icon_separator", "VButtonArray", 2 * scale);
+ t->set_constant("button_separator", "VButtonArray", 4 * scale);
+ t->set_stylebox("focus", "VButtonArray", focus);
// ReferenceFrame
- Ref<StyleBoxTexture> ttnc = make_stylebox( full_panel_bg_png,8,8,8,8);
+ Ref<StyleBoxTexture> ttnc = make_stylebox(full_panel_bg_png, 8, 8, 8, 8);
ttnc->set_draw_center(false);
- t->set_stylebox("border","ReferenceFrame", make_stylebox( reference_border_png,4,4,4,4) );
- t->set_stylebox("panelnc","Panel", ttnc );
- t->set_stylebox("panelf","Panel", tc_sb );
+ t->set_stylebox("border", "ReferenceFrame", make_stylebox(reference_border_png, 4, 4, 4, 4));
+ t->set_stylebox("panelnc", "Panel", ttnc);
+ t->set_stylebox("panelf", "Panel", tc_sb);
- Ref<StyleBoxTexture> sb_pc = make_stylebox( tab_container_bg_png,4,4,4,4,7,7,7,7);
- t->set_stylebox("panel","PanelContainer", sb_pc );
-
-
-
- t->set_icon("minus","GraphEdit", make_icon(icon_zoom_less_png) );
- t->set_icon("reset","GraphEdit", make_icon(icon_zoom_reset_png) );
- t->set_icon("more","GraphEdit", make_icon(icon_zoom_more_png) );
- t->set_stylebox("bg","GraphEdit", make_stylebox( tree_bg_png,4,4,4,5) );
-
-
-
- t->set_icon( "logo","Icons", make_icon(logo_png) );
+ Ref<StyleBoxTexture> sb_pc = make_stylebox(tab_container_bg_png, 4, 4, 4, 4, 7, 7, 7, 7);
+ t->set_stylebox("panel", "PanelContainer", sb_pc);
+ t->set_icon("minus", "GraphEdit", make_icon(icon_zoom_less_png));
+ t->set_icon("reset", "GraphEdit", make_icon(icon_zoom_reset_png));
+ t->set_icon("more", "GraphEdit", make_icon(icon_zoom_more_png));
+ t->set_stylebox("bg", "GraphEdit", make_stylebox(tree_bg_png, 4, 4, 4, 5));
+ t->set_icon("logo", "Icons", make_icon(logo_png));
// Theme
- default_icon= make_icon(error_icon_png) ;
- default_style = make_stylebox( error_icon_png,2,2,2,2) ;
-
- memdelete( tex_cache );
+ default_icon = make_icon(error_icon_png);
+ default_style = make_stylebox(error_icon_png, 2, 2, 2, 2);
+ memdelete(tex_cache);
}
-void make_default_theme(bool p_hidpi,Ref<Font> p_font) {
+void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
Ref<Theme> t;
t.instance();
@@ -948,27 +871,26 @@ void make_default_theme(bool p_hidpi,Ref<Font> p_font) {
Ref<Texture> default_icon;
Ref<BitmapFont> default_font;
if (p_font.is_valid()) {
- default_font=p_font;
- } if (p_hidpi) {
- default_font=make_font2(_hidpi_font_height,_hidpi_font_ascent,_hidpi_font_charcount,&_hidpi_font_charrects[0][0],_hidpi_font_kerning_pair_count,&_hidpi_font_kerning_pairs[0][0],_hidpi_font_img_width,_hidpi_font_img_height,_hidpi_font_img_data);
+ default_font = p_font;
+ }
+ if (p_hidpi) {
+ default_font = make_font2(_hidpi_font_height, _hidpi_font_ascent, _hidpi_font_charcount, &_hidpi_font_charrects[0][0], _hidpi_font_kerning_pair_count, &_hidpi_font_kerning_pairs[0][0], _hidpi_font_img_width, _hidpi_font_img_height, _hidpi_font_img_data);
} else {
- default_font=make_font2(_lodpi_font_height,_lodpi_font_ascent,_lodpi_font_charcount,&_lodpi_font_charrects[0][0],_lodpi_font_kerning_pair_count,&_lodpi_font_kerning_pairs[0][0],_lodpi_font_img_width,_lodpi_font_img_height,_lodpi_font_img_data);
+ default_font = make_font2(_lodpi_font_height, _lodpi_font_ascent, _lodpi_font_charcount, &_lodpi_font_charrects[0][0], _lodpi_font_kerning_pair_count, &_lodpi_font_kerning_pairs[0][0], _lodpi_font_img_width, _lodpi_font_img_height, _lodpi_font_img_data);
}
- Ref<BitmapFont> large_font=default_font;
- fill_default_theme(t,default_font,large_font,default_icon,default_style,p_hidpi);
-
- Theme::set_default( t );
- Theme::set_default_icon( default_icon );
- Theme::set_default_style( default_style );
- Theme::set_default_font( default_font );
+ Ref<BitmapFont> large_font = default_font;
+ fill_default_theme(t, default_font, large_font, default_icon, default_style, p_hidpi);
+ Theme::set_default(t);
+ Theme::set_default_icon(default_icon);
+ Theme::set_default_style(default_style);
+ Theme::set_default_font(default_font);
}
void clear_default_theme() {
- Theme::set_default( Ref<Theme>() );
- Theme::set_default_icon( Ref< Texture >() );
- Theme::set_default_style( Ref< StyleBox >() );
- Theme::set_default_font( Ref< Font >() );
-
+ Theme::set_default(Ref<Theme>());
+ Theme::set_default_icon(Ref<Texture>());
+ Theme::set_default_style(Ref<StyleBox>());
+ Theme::set_default_font(Ref<Font>());
}
diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h
index 4af4cc543..4177cbb27 100644
--- a/scene/resources/default_theme/default_theme.h
+++ b/scene/resources/default_theme/default_theme.h
@@ -35,7 +35,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
-void fill_default_theme(Ref<Theme>& theme,const Ref<Font> & default_font,const Ref<Font> & large_font,Ref<Texture>& default_icon, Ref<StyleBox>& default_style,bool p_hidpi);
+void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, bool p_hidpi);
void make_default_theme(bool p_hidpi, Ref<Font> p_font);
void clear_default_theme();
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index ab758f72b..5f58417fc 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -1,570 +1,455 @@
// THIS FILE HAS BEEN AUTOGENERATED, DONT EDIT!!
-
-
-
-
-static const unsigned char arrow_down_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x8,0x4,0x0,0x0,0x0,0xfc,0x7c,0x94,0x6c,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x4a,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0xa0,0x1a,0x60,0x64,0x60,0x60,0x60,0x78,0xf0,0x1f,0x55,0x50,0x81,0x91,0x81,0x81,0x9,0x97,0xe,0xfc,0x12,0x8c,0xf1,0xc,0x5f,0xe1,0x22,0xdf,0x19,0xd3,0x91,0xe4,0xef,0x6b,0xdc,0xbf,0xf4,0xe0,0xff,0x83,0xff,0xf,0xae,0x3f,0xd6,0x45,0xb2,0x9c,0x81,0x81,0x81,0xe1,0x5,0xf7,0xcf,0x29,0xc,0xc,0xec,0x39,0x12,0x5f,0x19,0xa8,0xd,0x0,0x99,0x85,0x11,0xfa,0x28,0xbe,0xff,0xef,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char arrow_down_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x4, 0x0, 0x0, 0x0, 0xfc, 0x7c, 0x94, 0x6c, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x4a, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0xa0, 0x1a, 0x60, 0x64, 0x60, 0x60, 0x60, 0x78, 0xf0, 0x1f, 0x55, 0x50, 0x81, 0x91, 0x81, 0x81, 0x9, 0x97, 0xe, 0xfc, 0x12, 0x8c, 0xf1, 0xc, 0x5f, 0xe1, 0x22, 0xdf, 0x19, 0xd3, 0x91, 0xe4, 0xef, 0x6b, 0xdc, 0xbf, 0xf4, 0xe0, 0xff, 0x83, 0xff, 0xf, 0xae, 0x3f, 0xd6, 0x45, 0xb2, 0x9c, 0x81, 0x81, 0x81, 0xe1, 0x5, 0xf7, 0xcf, 0x29, 0xc, 0xc, 0xec, 0x39, 0x12, 0x5f, 0x19, 0xa8, 0xd, 0x0, 0x99, 0x85, 0x11, 0xfa, 0x28, 0xbe, 0xff, 0xef, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char arrow_right_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x8,0x4,0x0,0x0,0x0,0xfc,0x7c,0x94,0x6c,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x4e,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0x20,0x13,0x3c,0xf8,0xff,0xe0,0xff,0x83,0xff,0xf7,0x13,0x10,0x22,0x8c,0x30,0x9,0x6,0x6,0x6,0x6,0x86,0xaf,0x8c,0xe6,0xf2,0x57,0x21,0x22,0x4c,0x28,0x1a,0xb9,0xff,0xaf,0x7a,0xc1,0x8d,0x4d,0x82,0x81,0x41,0xeb,0xe7,0x14,0xec,0x12,0x70,0x80,0x2e,0x71,0x8d,0x3d,0x7,0x9b,0xc4,0x57,0xc6,0x30,0x89,0xaf,0x58,0x24,0xfe,0xe7,0xc0,0xdc,0x44,0xe,0x0,0x0,0xa0,0xe1,0x15,0x49,0x2,0x9f,0xab,0x0,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char arrow_right_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x4, 0x0, 0x0, 0x0, 0xfc, 0x7c, 0x94, 0x6c, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x4e, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0x20, 0x13, 0x3c, 0xf8, 0xff, 0xe0, 0xff, 0x83, 0xff, 0xf7, 0x13, 0x10, 0x22, 0x8c, 0x30, 0x9, 0x6, 0x6, 0x6, 0x6, 0x86, 0xaf, 0x8c, 0xe6, 0xf2, 0x57, 0x21, 0x22, 0x4c, 0x28, 0x1a, 0xb9, 0xff, 0xaf, 0x7a, 0xc1, 0x8d, 0x4d, 0x82, 0x81, 0x41, 0xeb, 0xe7, 0x14, 0xec, 0x12, 0x70, 0x80, 0x2e, 0x71, 0x8d, 0x3d, 0x7, 0x9b, 0xc4, 0x57, 0xc6, 0x30, 0x89, 0xaf, 0x58, 0x24, 0xfe, 0xe7, 0xc0, 0xdc, 0x44, 0xe, 0x0, 0x0, 0xa0, 0xe1, 0x15, 0x49, 0x2, 0x9f, 0xab, 0x0, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char background_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x3,0x0,0x0,0x0,0x44,0xa4,0x8a,0xc6,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x11,0x50,0x4c,0x54,0x45,0x91,0xc9,0xab,0x90,0xc9,0xab,0x90,0xc9,0xaa,0x90,0xc8,0xab,0x91,0xc9,0xaa,0x91,0xc8,0xab,0x90,0xc8,0xaa,0x8f,0xc8,0xab,0x8f,0xc9,0xab,0x8f,0xc8,0xaa,0x90,0xc7,0xaa,0x90,0xc7,0xab,0x8f,0xc7,0xaa,0x8f,0xc7,0xab,0x8e,0xc7,0xab,0x8e,0xc6,0xab,0x8f,0xc6,0xab,0x8e,0xc6,0xaa,0x8f,0xc6,0xaa,0x8e,0xc7,0xaa,0x8e,0xc5,0xaa,0x8e,0xc5,0xab,0x8d,0xc5,0xaa,0x8d,0xc5,0xab,0x8d,0xc6,0xaa,0x8d,0xc6,0xab,0x8d,0xc4,0xaa,0x8e,0xc4,0xab,0x8d,0xc4,0xab,0x8e,0xc4,0xaa,0x8c,0xc4,0xaa,0x8c,0xc5,0xaa,0x8d,0xc3,0xab,0x8d,0xc3,0xaa,0x8c,0xc3,0xaa,0x8c,0xc4,0xab,0x8c,0xc3,0xab,0x8c,0xc2,0xab,0x8b,0xc2,0xaa,0x8b,0xc3,0xaa,0x8b,0xc3,0xab,0x8c,0xc2,0xaa,0x8b,0xc2,0xab,0x8b,0xc1,0xaa,0x8b,0xc1,0xab,0x8a,0xc2,0xaa,0x8a,0xc1,0xaa,0x8a,0xc0,0xaa,0x8b,0xc0,0xaa,0x8a,0xc1,0xa9,0x8a,0xc0,0xa9,0x89,0xc0,0xaa,0x8a,0xbf,0xaa,0x89,0xbf,0xaa,0x89,0xbf,0xa9,0x8a,0xbf,0xa9,0x88,0xbf,0xaa,0x89,0xbe,0xaa,0x89,0xbe,0xa9,0x88,0xbf,0xa9,0x88,0xbe,0xa9,0x88,0xbe,0xaa,0x88,0xbd,0xaa,0x88,0xbd,0xa9,0x89,0xbd,0xaa,0x89,0xbd,0xa9,0x87,0xbe,0xa9,0x87,0xbd,0xaa,0x87,0xbe,0xaa,0x87,0xbd,0xa9,0x87,0xbc,0xaa,0x88,0xbc,0xa9,0x88,0xbc,0xaa,0x87,0xbc,0xa9,0x86,0xbc,0xa9,0x87,0xbb,0xaa,0x87,0xbb,0xa9,0x86,0xbb,0xa9,0x86,0xbc,0xaa,0x86,0xbb,0xaa,0x86,0xba,0xaa,0x86,0xba,0xa9,0x85,0xba,0xa9,0x85,0xbb,0xaa,0x85,0xbb,0xa9,0x85,0xba,0xaa,0x85,0xb9,0xa9,0x86,0xb9,0xa9,0x86,0xb9,0xaa,0x85,0xb9,0xaa,0xff,0xff,0xff,0x25,0xe,0xc5,0xe1,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x5a,0x3,0xbb,0xa5,0xa2,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x2,0xaa,0x49,0x44,0x41,0x54,0x38,0xcb,0x45,0x4b,0xd,0x63,0x9a,0x56,0x14,0xbd,0x86,0x2d,0x24,0x2b,0xf8,0x8a,0x1,0xcc,0x18,0x23,0xcd,0x8b,0xc5,0x2a,0xa9,0x6e,0x51,0x98,0x58,0x3e,0xda,0x52,0x69,0x9e,0x4a,0x10,0xba,0xb8,0xec,0xff,0xff,0x91,0x9d,0x47,0xd2,0xf5,0xbc,0xcb,0x3d,0x1f,0xf7,0x40,0xd4,0x23,0x4c,0x4f,0x2,0x9b,0xa8,0x93,0x27,0x9d,0xa3,0xe7,0x50,0xe9,0xc9,0x79,0x69,0x74,0xf7,0x9f,0x7a,0x8a,0xd2,0xfb,0xf9,0xf4,0x25,0x53,0xd5,0x33,0xf4,0xcf,0xce,0x90,0x9d,0xa8,0xa,0x80,0x75,0xaa,0xc8,0xca,0xa9,0xa2,0x9c,0xf4,0x54,0x52,0x91,0x9c,0xab,0x2a,0x46,0x42,0xf9,0xe5,0xb4,0x2b,0xa9,0xe7,0xca,0xab,0x57,0xc8,0x15,0x8d,0x74,0x4d,0xd5,0x25,0x40,0x8a,0xae,0xea,0xda,0xb9,0xd6,0x59,0x55,0x12,0xfe,0xd0,0x49,0xef,0xb3,0xbe,0xfe,0x5a,0x37,0x34,0x66,0x30,0x5d,0xd3,0xfb,0xfa,0x80,0x69,0x3,0x7d,0x70,0xd1,0xd5,0xfa,0x9a,0x4e,0x3,0xe3,0x62,0xd0,0xd7,0xd,0xd6,0x37,0x98,0xd1,0xef,0xf,0xc0,0x9a,0xc1,0x2e,0xc,0xc6,0x2e,0xd8,0xeb,0x1,0x86,0x98,0x61,0x32,0x13,0x7f,0x33,0x66,0x49,0x36,0xba,0x41,0x68,0x18,0xdd,0x66,0x64,0x5b,0x96,0x69,0x59,0x90,0xd6,0xf0,0x72,0x68,0x9a,0x43,0xd3,0xfa,0xd5,0x32,0x2f,0x6d,0xe3,0xd2,0xb2,0x98,0x65,0x30,0x93,0x1c,0x7b,0x88,0x67,0xdb,0xa6,0xd,0x72,0x7e,0x1b,0xba,0xa8,0xc0,0xda,0xbf,0xf,0x91,0xba,0xb6,0x4b,0x8e,0xe7,0x78,0xee,0xd0,0x75,0x87,0x1e,0xac,0xe3,0x60,0x5f,0x39,0x57,0xe,0x84,0xe7,0xd8,0xb6,0x63,0x5f,0xd1,0x1b,0xe7,0x9a,0xcb,0x92,0xe7,0xba,0xae,0xe7,0xf0,0x1b,0xc7,0xb9,0x76,0x3c,0x8e,0xb3,0x87,0x16,0xbf,0xf1,0x88,0x73,0xee,0x8c,0x46,0xd8,0xd7,0x7c,0xe4,0xf1,0xef,0x18,0x79,0x37,0x9c,0x7b,0x6f,0xbc,0x11,0x27,0xfe,0xd6,0xf7,0xf9,0x98,0xf3,0x77,0x13,0xfe,0x96,0x8f,0xb8,0x3f,0x96,0x65,0x9f,0x4f,0x38,0x1f,0x4f,0xf8,0x68,0xc2,0xc9,0x7f,0xc6,0x74,0xea,0x73,0x49,0x13,0xcc,0x78,0xe2,0xfb,0x13,0x59,0xf2,0xdf,0xf9,0x63,0xa,0xa6,0xfe,0x34,0xf0,0xf1,0xba,0xe9,0x20,0x39,0xf0,0x6f,0x83,0xdb,0x69,0x10,0x4c,0x29,0x78,0x3f,0xb,0x50,0x91,0xe7,0xc0,0x9f,0x61,0xdd,0x6,0xb3,0xd9,0xcc,0xf7,0xdf,0x83,0xe0,0x2,0x9a,0xcd,0x67,0xcf,0x98,0x77,0xea,0xf,0x29,0xe4,0xfc,0x9,0x13,0x40,0xd0,0x1c,0x87,0x1f,0xb8,0x93,0xab,0xb,0xee,0x5e,0x62,0x5a,0x2c,0xe7,0x21,0x78,0xb9,0x58,0x2e,0xb1,0xd1,0xb8,0x5b,0x84,0x4b,0xd8,0xf9,0x7c,0x81,0xef,0x2e,0xa4,0xc5,0x22,0xc,0x97,0x61,0x18,0x85,0x12,0x51,0x4,0x5e,0x46,0x61,0xf4,0x97,0x74,0xb,0xb9,0xa8,0x3b,0xad,0xe2,0x38,0xa,0xd7,0xab,0x28,0x4,0x85,0x1f,0xe2,0x10,0x1c,0xc5,0xe1,0x2a,0x5c,0x25,0x2b,0x4a,0xe3,0x38,0x49,0x93,0x24,0x4d,0xe3,0x34,0x4e,0xe2,0x68,0xd,0x1f,0xad,0x93,0x24,0x59,0x23,0xfa,0xb0,0x4e,0x53,0xca,0xf2,0x2c,0xfb,0xf8,0xf1,0x13,0x6c,0x92,0x42,0xa7,0x49,0x9e,0xe6,0x69,0x92,0x49,0xd3,0x65,0x94,0x7d,0xce,0xb2,0x2c,0xc9,0xd2,0xa2,0xf8,0x92,0xe7,0x59,0x51,0xc0,0x7d,0xce,0xb,0xc8,0x1c,0xc8,0x36,0x5,0x95,0x5f,0xb3,0x72,0x53,0x66,0xf7,0x5f,0x37,0x70,0xf7,0x79,0x51,0x88,0xfb,0x12,0x3d,0x91,0xdd,0x8b,0x4d,0x99,0x8b,0x92,0x44,0x59,0xa,0x51,0x8a,0x72,0xb,0x2e,0x37,0x2,0x1a,0xa2,0x0,0x8b,0xd,0x62,0x21,0x48,0xec,0x76,0x7b,0x21,0xaa,0x52,0xec,0xb6,0xa2,0xaa,0xb6,0xf,0xfb,0x7d,0x2d,0xc4,0xf6,0xa1,0x7a,0x10,0xdb,0x9d,0x28,0x77,0x15,0x55,0xbb,0xba,0x92,0xd8,0x57,0xbb,0xaa,0xaa,0xeb,0x7d,0x2d,0xed,0xff,0xdf,0xbe,0xa6,0x43,0xd5,0x34,0x75,0xd3,0x54,0xcd,0xa1,0xaa,0xf,0x75,0x83,0xbc,0xae,0x5a,0xb4,0x64,0xf6,0xd,0x1d,0x6a,0x25,0x9a,0xa6,0x6d,0xab,0x43,0x3,0xfc,0x2d,0x57,0x8b,0xf7,0xf8,0xd8,0xb4,0x87,0xb6,0x6e,0xe9,0xb1,0x6d,0x8e,0x6d,0x7b,0x6c,0xff,0x39,0x3e,0x1d,0x9f,0x20,0x8f,0xd2,0x1d,0xff,0x45,0xa,0xdd,0xb6,0x4f,0xff,0x1,0xbe,0xd3,0xa6,0xf7,0x55,0x9e,0xe1,0xf0,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char background_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x20, 0x8, 0x3, 0x0, 0x0, 0x0, 0x44, 0xa4, 0x8a, 0xc6, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x11, 0x50, 0x4c, 0x54, 0x45, 0x91, 0xc9, 0xab, 0x90, 0xc9, 0xab, 0x90, 0xc9, 0xaa, 0x90, 0xc8, 0xab, 0x91, 0xc9, 0xaa, 0x91, 0xc8, 0xab, 0x90, 0xc8, 0xaa, 0x8f, 0xc8, 0xab, 0x8f, 0xc9, 0xab, 0x8f, 0xc8, 0xaa, 0x90, 0xc7, 0xaa, 0x90, 0xc7, 0xab, 0x8f, 0xc7, 0xaa, 0x8f, 0xc7, 0xab, 0x8e, 0xc7, 0xab, 0x8e, 0xc6, 0xab, 0x8f, 0xc6, 0xab, 0x8e, 0xc6, 0xaa, 0x8f, 0xc6, 0xaa, 0x8e, 0xc7, 0xaa, 0x8e, 0xc5, 0xaa, 0x8e, 0xc5, 0xab, 0x8d, 0xc5, 0xaa, 0x8d, 0xc5, 0xab, 0x8d, 0xc6, 0xaa, 0x8d, 0xc6, 0xab, 0x8d, 0xc4, 0xaa, 0x8e, 0xc4, 0xab, 0x8d, 0xc4, 0xab, 0x8e, 0xc4, 0xaa, 0x8c, 0xc4, 0xaa, 0x8c, 0xc5, 0xaa, 0x8d, 0xc3, 0xab, 0x8d, 0xc3, 0xaa, 0x8c, 0xc3, 0xaa, 0x8c, 0xc4, 0xab, 0x8c, 0xc3, 0xab, 0x8c, 0xc2, 0xab, 0x8b, 0xc2, 0xaa, 0x8b, 0xc3, 0xaa, 0x8b, 0xc3, 0xab, 0x8c, 0xc2, 0xaa, 0x8b, 0xc2, 0xab, 0x8b, 0xc1, 0xaa, 0x8b, 0xc1, 0xab, 0x8a, 0xc2, 0xaa, 0x8a, 0xc1, 0xaa, 0x8a, 0xc0, 0xaa, 0x8b, 0xc0, 0xaa, 0x8a, 0xc1, 0xa9, 0x8a, 0xc0, 0xa9, 0x89, 0xc0, 0xaa, 0x8a, 0xbf, 0xaa, 0x89, 0xbf, 0xaa, 0x89, 0xbf, 0xa9, 0x8a, 0xbf, 0xa9, 0x88, 0xbf, 0xaa, 0x89, 0xbe, 0xaa, 0x89, 0xbe, 0xa9, 0x88, 0xbf, 0xa9, 0x88, 0xbe, 0xa9, 0x88, 0xbe, 0xaa, 0x88, 0xbd, 0xaa, 0x88, 0xbd, 0xa9, 0x89, 0xbd, 0xaa, 0x89, 0xbd, 0xa9, 0x87, 0xbe, 0xa9, 0x87, 0xbd, 0xaa, 0x87, 0xbe, 0xaa, 0x87, 0xbd, 0xa9, 0x87, 0xbc, 0xaa, 0x88, 0xbc, 0xa9, 0x88, 0xbc, 0xaa, 0x87, 0xbc, 0xa9, 0x86, 0xbc, 0xa9, 0x87, 0xbb, 0xaa, 0x87, 0xbb, 0xa9, 0x86, 0xbb, 0xa9, 0x86, 0xbc, 0xaa, 0x86, 0xbb, 0xaa, 0x86, 0xba, 0xaa, 0x86, 0xba, 0xa9, 0x85, 0xba, 0xa9, 0x85, 0xbb, 0xaa, 0x85, 0xbb, 0xa9, 0x85, 0xba, 0xaa, 0x85, 0xb9, 0xa9, 0x86, 0xb9, 0xa9, 0x86, 0xb9, 0xaa, 0x85, 0xb9, 0xaa, 0xff, 0xff, 0xff, 0x25, 0xe, 0xc5, 0xe1, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x5a, 0x3, 0xbb, 0xa5, 0xa2, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x2, 0xaa, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0x45, 0x4b, 0xd, 0x63, 0x9a, 0x56, 0x14, 0xbd, 0x86, 0x2d, 0x24, 0x2b, 0xf8, 0x8a, 0x1, 0xcc, 0x18, 0x23, 0xcd, 0x8b, 0xc5, 0x2a, 0xa9, 0x6e, 0x51, 0x98, 0x58, 0x3e, 0xda, 0x52, 0x69, 0x9e, 0x4a, 0x10, 0xba, 0xb8, 0xec, 0xff, 0xff, 0x91, 0x9d, 0x47, 0xd2, 0xf5, 0xbc, 0xcb, 0x3d, 0x1f, 0xf7, 0x40, 0xd4, 0x23, 0x4c, 0x4f, 0x2, 0x9b, 0xa8, 0x93, 0x27, 0x9d, 0xa3, 0xe7, 0x50, 0xe9, 0xc9, 0x79, 0x69, 0x74, 0xf7, 0x9f, 0x7a, 0x8a, 0xd2, 0xfb, 0xf9, 0xf4, 0x25, 0x53, 0xd5, 0x33, 0xf4, 0xcf, 0xce, 0x90, 0x9d, 0xa8, 0xa, 0x80, 0x75, 0xaa, 0xc8, 0xca, 0xa9, 0xa2, 0x9c, 0xf4, 0x54, 0x52, 0x91, 0x9c, 0xab, 0x2a, 0x46, 0x42, 0xf9, 0xe5, 0xb4, 0x2b, 0xa9, 0xe7, 0xca, 0xab, 0x57, 0xc8, 0x15, 0x8d, 0x74, 0x4d, 0xd5, 0x25, 0x40, 0x8a, 0xae, 0xea, 0xda, 0xb9, 0xd6, 0x59, 0x55, 0x12, 0xfe, 0xd0, 0x49, 0xef, 0xb3, 0xbe, 0xfe, 0x5a, 0x37, 0x34, 0x66, 0x30, 0x5d, 0xd3, 0xfb, 0xfa, 0x80, 0x69, 0x3, 0x7d, 0x70, 0xd1, 0xd5, 0xfa, 0x9a, 0x4e, 0x3, 0xe3, 0x62, 0xd0, 0xd7, 0xd, 0xd6, 0x37, 0x98, 0xd1, 0xef, 0xf, 0xc0, 0x9a, 0xc1, 0x2e, 0xc, 0xc6, 0x2e, 0xd8, 0xeb, 0x1, 0x86, 0x98, 0x61, 0x32, 0x13, 0x7f, 0x33, 0x66, 0x49, 0x36, 0xba, 0x41, 0x68, 0x18, 0xdd, 0x66, 0x64, 0x5b, 0x96, 0x69, 0x59, 0x90, 0xd6, 0xf0, 0x72, 0x68, 0x9a, 0x43, 0xd3, 0xfa, 0xd5, 0x32, 0x2f, 0x6d, 0xe3, 0xd2, 0xb2, 0x98, 0x65, 0x30, 0x93, 0x1c, 0x7b, 0x88, 0x67, 0xdb, 0xa6, 0xd, 0x72, 0x7e, 0x1b, 0xba, 0xa8, 0xc0, 0xda, 0xbf, 0xf, 0x91, 0xba, 0xb6, 0x4b, 0x8e, 0xe7, 0x78, 0xee, 0xd0, 0x75, 0x87, 0x1e, 0xac, 0xe3, 0x60, 0x5f, 0x39, 0x57, 0xe, 0x84, 0xe7, 0xd8, 0xb6, 0x63, 0x5f, 0xd1, 0x1b, 0xe7, 0x9a, 0xcb, 0x92, 0xe7, 0xba, 0xae, 0xe7, 0xf0, 0x1b, 0xc7, 0xb9, 0x76, 0x3c, 0x8e, 0xb3, 0x87, 0x16, 0xbf, 0xf1, 0x88, 0x73, 0xee, 0x8c, 0x46, 0xd8, 0xd7, 0x7c, 0xe4, 0xf1, 0xef, 0x18, 0x79, 0x37, 0x9c, 0x7b, 0x6f, 0xbc, 0x11, 0x27, 0xfe, 0xd6, 0xf7, 0xf9, 0x98, 0xf3, 0x77, 0x13, 0xfe, 0x96, 0x8f, 0xb8, 0x3f, 0x96, 0x65, 0x9f, 0x4f, 0x38, 0x1f, 0x4f, 0xf8, 0x68, 0xc2, 0xc9, 0x7f, 0xc6, 0x74, 0xea, 0x73, 0x49, 0x13, 0xcc, 0x78, 0xe2, 0xfb, 0x13, 0x59, 0xf2, 0xdf, 0xf9, 0x63, 0xa, 0xa6, 0xfe, 0x34, 0xf0, 0xf1, 0xba, 0xe9, 0x20, 0x39, 0xf0, 0x6f, 0x83, 0xdb, 0x69, 0x10, 0x4c, 0x29, 0x78, 0x3f, 0xb, 0x50, 0x91, 0xe7, 0xc0, 0x9f, 0x61, 0xdd, 0x6, 0xb3, 0xd9, 0xcc, 0xf7, 0xdf, 0x83, 0xe0, 0x2, 0x9a, 0xcd, 0x67, 0xcf, 0x98, 0x77, 0xea, 0xf, 0x29, 0xe4, 0xfc, 0x9, 0x13, 0x40, 0xd0, 0x1c, 0x87, 0x1f, 0xb8, 0x93, 0xab, 0xb, 0xee, 0x5e, 0x62, 0x5a, 0x2c, 0xe7, 0x21, 0x78, 0xb9, 0x58, 0x2e, 0xb1, 0xd1, 0xb8, 0x5b, 0x84, 0x4b, 0xd8, 0xf9, 0x7c, 0x81, 0xef, 0x2e, 0xa4, 0xc5, 0x22, 0xc, 0x97, 0x61, 0x18, 0x85, 0x12, 0x51, 0x4, 0x5e, 0x46, 0x61, 0xf4, 0x97, 0x74, 0xb, 0xb9, 0xa8, 0x3b, 0xad, 0xe2, 0x38, 0xa, 0xd7, 0xab, 0x28, 0x4, 0x85, 0x1f, 0xe2, 0x10, 0x1c, 0xc5, 0xe1, 0x2a, 0x5c, 0x25, 0x2b, 0x4a, 0xe3, 0x38, 0x49, 0x93, 0x24, 0x4d, 0xe3, 0x34, 0x4e, 0xe2, 0x68, 0xd, 0x1f, 0xad, 0x93, 0x24, 0x59, 0x23, 0xfa, 0xb0, 0x4e, 0x53, 0xca, 0xf2, 0x2c, 0xfb, 0xf8, 0xf1, 0x13, 0x6c, 0x92, 0x42, 0xa7, 0x49, 0x9e, 0xe6, 0x69, 0x92, 0x49, 0xd3, 0x65, 0x94, 0x7d, 0xce, 0xb2, 0x2c, 0xc9, 0xd2, 0xa2, 0xf8, 0x92, 0xe7, 0x59, 0x51, 0xc0, 0x7d, 0xce, 0xb, 0xc8, 0x1c, 0xc8, 0x36, 0x5, 0x95, 0x5f, 0xb3, 0x72, 0x53, 0x66, 0xf7, 0x5f, 0x37, 0x70, 0xf7, 0x79, 0x51, 0x88, 0xfb, 0x12, 0x3d, 0x91, 0xdd, 0x8b, 0x4d, 0x99, 0x8b, 0x92, 0x44, 0x59, 0xa, 0x51, 0x8a, 0x72, 0xb, 0x2e, 0x37, 0x2, 0x1a, 0xa2, 0x0, 0x8b, 0xd, 0x62, 0x21, 0x48, 0xec, 0x76, 0x7b, 0x21, 0xaa, 0x52, 0xec, 0xb6, 0xa2, 0xaa, 0xb6, 0xf, 0xfb, 0x7d, 0x2d, 0xc4, 0xf6, 0xa1, 0x7a, 0x10, 0xdb, 0x9d, 0x28, 0x77, 0x15, 0x55, 0xbb, 0xba, 0x92, 0xd8, 0x57, 0xbb, 0xaa, 0xaa, 0xeb, 0x7d, 0x2d, 0xed, 0xff, 0xdf, 0xbe, 0xa6, 0x43, 0xd5, 0x34, 0x75, 0xd3, 0x54, 0xcd, 0xa1, 0xaa, 0xf, 0x75, 0x83, 0xbc, 0xae, 0x5a, 0xb4, 0x64, 0xf6, 0xd, 0x1d, 0x6a, 0x25, 0x9a, 0xa6, 0x6d, 0xab, 0x43, 0x3, 0xfc, 0x2d, 0x57, 0x8b, 0xf7, 0xf8, 0xd8, 0xb4, 0x87, 0xb6, 0x6e, 0xe9, 0xb1, 0x6d, 0x8e, 0x6d, 0x7b, 0x6c, 0xff, 0x39, 0x3e, 0x1d, 0x9f, 0x20, 0x8f, 0xd2, 0x1d, 0xff, 0x45, 0xa, 0xdd, 0xb6, 0x4f, 0xff, 0x1, 0xbe, 0xd3, 0xa6, 0xf7, 0x55, 0x9e, 0xe1, 0xf0, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char base_green_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x1,0x3,0x0,0x0,0x0,0x49,0xb4,0xe8,0xb7,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x90,0xc9,0xab,0xff,0xff,0xff,0xc6,0xd0,0x9d,0x30,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1,0xff,0x2,0x2d,0xde,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xc,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x18,0xdc,0x0,0x0,0x0,0xa0,0x0,0x1,0x61,0x25,0x7d,0x47,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char base_green_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x20, 0x1, 0x3, 0x0, 0x0, 0x0, 0x49, 0xb4, 0xe8, 0xb7, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x50, 0x4c, 0x54, 0x45, 0x90, 0xc9, 0xab, 0xff, 0xff, 0xff, 0xc6, 0xd0, 0x9d, 0x30, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1, 0xff, 0x2, 0x2d, 0xde, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xc, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x18, 0xdc, 0x0, 0x0, 0x0, 0xa0, 0x0, 0x1, 0x61, 0x25, 0x7d, 0x47, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char button_disabled_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xd9,0x49,0x44,0x41,0x54,0x28,0xcf,0x7d,0x91,0x41,0x4e,0xc3,0x30,0x14,0x44,0x9f,0xed,0x8f,0x6d,0x35,0x8b,0x9a,0x6d,0xb9,0x6,0xfb,0xde,0x81,0xd3,0xe4,0x8,0xf4,0x32,0xbd,0x1,0xb,0x6e,0xc0,0x25,0x60,0x83,0xa8,0x2,0x6a,0xa4,0xc6,0x49,0xfc,0xbb,0x88,0x54,0x11,0x94,0x30,0xb3,0xf9,0xd2,0x9f,0x19,0x8d,0x34,0x6,0xc1,0x13,0x88,0x78,0x1c,0x96,0x9,0x85,0x91,0xcc,0x85,0x8e,0x2c,0x78,0x2a,0x12,0x5b,0x2a,0x2,0x6,0x3,0x28,0x4a,0x47,0xcb,0x37,0xd,0x8,0x81,0xb4,0x7f,0x7a,0xa8,0x87,0xc4,0xc,0xd2,0xbc,0x3f,0xbf,0x1e,0x19,0x84,0xc8,0x76,0x57,0x9f,0xd2,0x80,0xfe,0x7a,0x1b,0x24,0xed,0x6a,0x5e,0x38,0xb,0x9e,0xaa,0x4f,0xfd,0xdc,0x8e,0xd2,0xd3,0x27,0x2a,0xbc,0xe0,0x8,0x65,0xe6,0xe6,0xd6,0x94,0x80,0x13,0x2c,0x46,0x29,0xb,0x2,0x5,0x83,0x15,0xc0,0xac,0x26,0x18,0x90,0xe9,0x5c,0x11,0x30,0x9,0x54,0x17,0x5,0xa,0xa,0x42,0x41,0xcb,0x62,0x87,0x2,0x4a,0x11,0x46,0xba,0xd5,0x84,0x8e,0xd1,0x92,0x69,0x6d,0xe3,0xd0,0x3f,0x74,0xd8,0x86,0x96,0xec,0xb8,0xc3,0xa5,0xaf,0xfb,0x47,0x1f,0x3d,0xe1,0xc6,0x48,0x3c,0x7d,0x1e,0x3e,0xde,0xf8,0x31,0x6c,0xfe,0x1d,0xab,0x15,0x32,0x30,0x70,0x5e,0x9b,0xfb,0xa,0xbb,0x7c,0x61,0xa2,0x50,0x44,0x45,0xca,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char button_disabled_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xd9, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x7d, 0x91, 0x41, 0x4e, 0xc3, 0x30, 0x14, 0x44, 0x9f, 0xed, 0x8f, 0x6d, 0x35, 0x8b, 0x9a, 0x6d, 0xb9, 0x6, 0xfb, 0xde, 0x81, 0xd3, 0xe4, 0x8, 0xf4, 0x32, 0xbd, 0x1, 0xb, 0x6e, 0xc0, 0x25, 0x60, 0x83, 0xa8, 0x2, 0x6a, 0xa4, 0xc6, 0x49, 0xfc, 0xbb, 0x88, 0x54, 0x11, 0x94, 0x30, 0xb3, 0xf9, 0xd2, 0x9f, 0x19, 0x8d, 0x34, 0x6, 0xc1, 0x13, 0x88, 0x78, 0x1c, 0x96, 0x9, 0x85, 0x91, 0xcc, 0x85, 0x8e, 0x2c, 0x78, 0x2a, 0x12, 0x5b, 0x2a, 0x2, 0x6, 0x3, 0x28, 0x4a, 0x47, 0xcb, 0x37, 0xd, 0x8, 0x81, 0xb4, 0x7f, 0x7a, 0xa8, 0x87, 0xc4, 0xc, 0xd2, 0xbc, 0x3f, 0xbf, 0x1e, 0x19, 0x84, 0xc8, 0x76, 0x57, 0x9f, 0xd2, 0x80, 0xfe, 0x7a, 0x1b, 0x24, 0xed, 0x6a, 0x5e, 0x38, 0xb, 0x9e, 0xaa, 0x4f, 0xfd, 0xdc, 0x8e, 0xd2, 0xd3, 0x27, 0x2a, 0xbc, 0xe0, 0x8, 0x65, 0xe6, 0xe6, 0xd6, 0x94, 0x80, 0x13, 0x2c, 0x46, 0x29, 0xb, 0x2, 0x5, 0x83, 0x15, 0xc0, 0xac, 0x26, 0x18, 0x90, 0xe9, 0x5c, 0x11, 0x30, 0x9, 0x54, 0x17, 0x5, 0xa, 0xa, 0x42, 0x41, 0xcb, 0x62, 0x87, 0x2, 0x4a, 0x11, 0x46, 0xba, 0xd5, 0x84, 0x8e, 0xd1, 0x92, 0x69, 0x6d, 0xe3, 0xd0, 0x3f, 0x74, 0xd8, 0x86, 0x96, 0xec, 0xb8, 0xc3, 0xa5, 0xaf, 0xfb, 0x47, 0x1f, 0x3d, 0xe1, 0xc6, 0x48, 0x3c, 0x7d, 0x1e, 0x3e, 0xde, 0xf8, 0x31, 0x6c, 0xfe, 0x1d, 0xab, 0x15, 0x32, 0x30, 0x70, 0x5e, 0x9b, 0xfb, 0xa, 0xbb, 0x7c, 0x61, 0xa2, 0x50, 0x44, 0x45, 0xca, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char button_focus_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x30,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0xff,0xff,0xff,0xb9,0xa2,0x9b,0xc9,0x0,0x0,0x0,0xf,0x74,0x52,0x4e,0x53,0x0,0xe,0x39,0x68,0x7a,0x7b,0x3a,0x74,0x10,0x8,0x69,0xf,0x6,0x75,0x11,0xb8,0x16,0x0,0x1,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xf,0x18,0xba,0x0,0xd9,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x3f,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc0,0x4,0x42,0x26,0xa1,0xa1,0xce,0x8a,0x40,0x46,0x7a,0xe7,0xcc,0x99,0x33,0xca,0x80,0x8c,0xd5,0x20,0xe1,0x5d,0x40,0x1c,0x3,0x62,0x1c,0x5,0xe2,0x48,0x10,0x63,0x2a,0x7e,0x6,0x5c,0x31,0x58,0xbb,0x14,0x10,0xe7,0xee,0x9c,0x39,0x73,0x1e,0xc8,0x40,0x31,0x98,0x15,0xe8,0x0,0x0,0xec,0xe0,0x11,0x6d,0x2c,0x6f,0x45,0x2b,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char button_focus_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x30, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0xff, 0xff, 0xff, 0xb9, 0xa2, 0x9b, 0xc9, 0x0, 0x0, 0x0, 0xf, 0x74, 0x52, 0x4e, 0x53, 0x0, 0xe, 0x39, 0x68, 0x7a, 0x7b, 0x3a, 0x74, 0x10, 0x8, 0x69, 0xf, 0x6, 0x75, 0x11, 0xb8, 0x16, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xf, 0x18, 0xba, 0x0, 0xd9, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x3f, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc0, 0x4, 0x42, 0x26, 0xa1, 0xa1, 0xce, 0x8a, 0x40, 0x46, 0x7a, 0xe7, 0xcc, 0x99, 0x33, 0xca, 0x80, 0x8c, 0xd5, 0x20, 0xe1, 0x5d, 0x40, 0x1c, 0x3, 0x62, 0x1c, 0x5, 0xe2, 0x48, 0x10, 0x63, 0x2a, 0x7e, 0x6, 0x5c, 0x31, 0x58, 0xbb, 0x14, 0x10, 0xe7, 0xee, 0x9c, 0x39, 0x73, 0x1e, 0xc8, 0x40, 0x31, 0x98, 0x15, 0xe8, 0x0, 0x0, 0xec, 0xe0, 0x11, 0x6d, 0x2c, 0x6f, 0x45, 0x2b, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char button_hover_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x8d,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x42,0x40,0x4b,0x5f,0x5a,0x6c,0x5f,0x5a,0x6b,0x56,0x53,0x64,0x57,0x53,0x64,0x3e,0x3b,0x46,0x57,0x53,0x63,0x57,0x53,0x63,0x5b,0x57,0x68,0x5a,0x56,0x67,0x4d,0x4a,0x57,0x49,0x46,0x52,0x48,0x45,0x51,0x5b,0x57,0x66,0x59,0x55,0x64,0x47,0x44,0x50,0x58,0x54,0x64,0x46,0x43,0x50,0x56,0x53,0x63,0x45,0x42,0x4f,0x56,0x53,0x62,0x45,0x42,0x4e,0x55,0x51,0x62,0x44,0x41,0x4e,0x55,0x51,0x60,0x44,0x41,0x4d,0x43,0x40,0x4c,0x47,0x43,0x51,0x43,0x3f,0x4d,0x42,0x3f,0x4c,0x53,0x50,0x5f,0x53,0x4f,0x5e,0xff,0xff,0xff,0x99,0x8b,0x2e,0x55,0x0,0x0,0x0,0x16,0x74,0x52,0x4e,0x53,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x77,0xef,0xef,0xef,0xef,0x77,0xef,0xed,0x6b,0x28,0x52,0x7a,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x2e,0x54,0xd3,0x10,0x87,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x97,0x49,0x44,0x41,0x54,0x18,0xd3,0x65,0xcf,0x49,0x12,0x82,0x30,0x10,0x5,0xd0,0xce,0x48,0x46,0x40,0x51,0x4,0x41,0x45,0xc4,0x20,0x88,0xf7,0xbf,0x9e,0x21,0x45,0x65,0xa1,0x6f,0xd7,0xbf,0xaa,0x27,0x0,0x84,0x9,0x65,0xdc,0x63,0x94,0x60,0x4,0x80,0x12,0x21,0x95,0x36,0xd6,0x1a,0xad,0xa4,0x48,0x10,0x60,0x91,0x66,0xe5,0x29,0x28,0xb3,0x54,0x60,0x20,0x32,0xaf,0xea,0x73,0x50,0x57,0xb9,0x24,0x40,0x55,0xb3,0xd5,0x3e,0x69,0x14,0x5,0xa6,0xdb,0x4b,0xd4,0x6a,0x6,0xdc,0x5c,0x6f,0xd1,0xd5,0x70,0xe0,0xb6,0xbb,0x47,0x9d,0x5d,0x83,0xfe,0x11,0xf5,0x6b,0x60,0x86,0x67,0x34,0xf8,0x16,0xa6,0xdd,0x18,0x39,0x3f,0x94,0x2a,0x37,0xbe,0x36,0xa3,0xf3,0x6b,0x89,0xdc,0x4d,0xf3,0x3b,0x98,0xa7,0xbd,0x3f,0xc,0x8b,0xe2,0xb0,0x7c,0x82,0xe5,0x58,0xf8,0xd3,0xff,0x9e,0xfb,0x7d,0xff,0xb,0x74,0xeb,0x15,0x11,0xe1,0xa7,0x60,0xfc,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char button_hover_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x8d, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x42, 0x40, 0x4b, 0x5f, 0x5a, 0x6c, 0x5f, 0x5a, 0x6b, 0x56, 0x53, 0x64, 0x57, 0x53, 0x64, 0x3e, 0x3b, 0x46, 0x57, 0x53, 0x63, 0x57, 0x53, 0x63, 0x5b, 0x57, 0x68, 0x5a, 0x56, 0x67, 0x4d, 0x4a, 0x57, 0x49, 0x46, 0x52, 0x48, 0x45, 0x51, 0x5b, 0x57, 0x66, 0x59, 0x55, 0x64, 0x47, 0x44, 0x50, 0x58, 0x54, 0x64, 0x46, 0x43, 0x50, 0x56, 0x53, 0x63, 0x45, 0x42, 0x4f, 0x56, 0x53, 0x62, 0x45, 0x42, 0x4e, 0x55, 0x51, 0x62, 0x44, 0x41, 0x4e, 0x55, 0x51, 0x60, 0x44, 0x41, 0x4d, 0x43, 0x40, 0x4c, 0x47, 0x43, 0x51, 0x43, 0x3f, 0x4d, 0x42, 0x3f, 0x4c, 0x53, 0x50, 0x5f, 0x53, 0x4f, 0x5e, 0xff, 0xff, 0xff, 0x99, 0x8b, 0x2e, 0x55, 0x0, 0x0, 0x0, 0x16, 0x74, 0x52, 0x4e, 0x53, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x77, 0xef, 0xef, 0xef, 0xef, 0x77, 0xef, 0xed, 0x6b, 0x28, 0x52, 0x7a, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x2e, 0x54, 0xd3, 0x10, 0x87, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x97, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x65, 0xcf, 0x49, 0x12, 0x82, 0x30, 0x10, 0x5, 0xd0, 0xce, 0x48, 0x46, 0x40, 0x51, 0x4, 0x41, 0x45, 0xc4, 0x20, 0x88, 0xf7, 0xbf, 0x9e, 0x21, 0x45, 0x65, 0xa1, 0x6f, 0xd7, 0xbf, 0xaa, 0x27, 0x0, 0x84, 0x9, 0x65, 0xdc, 0x63, 0x94, 0x60, 0x4, 0x80, 0x12, 0x21, 0x95, 0x36, 0xd6, 0x1a, 0xad, 0xa4, 0x48, 0x10, 0x60, 0x91, 0x66, 0xe5, 0x29, 0x28, 0xb3, 0x54, 0x60, 0x20, 0x32, 0xaf, 0xea, 0x73, 0x50, 0x57, 0xb9, 0x24, 0x40, 0x55, 0xb3, 0xd5, 0x3e, 0x69, 0x14, 0x5, 0xa6, 0xdb, 0x4b, 0xd4, 0x6a, 0x6, 0xdc, 0x5c, 0x6f, 0xd1, 0xd5, 0x70, 0xe0, 0xb6, 0xbb, 0x47, 0x9d, 0x5d, 0x83, 0xfe, 0x11, 0xf5, 0x6b, 0x60, 0x86, 0x67, 0x34, 0xf8, 0x16, 0xa6, 0xdd, 0x18, 0x39, 0x3f, 0x94, 0x2a, 0x37, 0xbe, 0x36, 0xa3, 0xf3, 0x6b, 0x89, 0xdc, 0x4d, 0xf3, 0x3b, 0x98, 0xa7, 0xbd, 0x3f, 0xc, 0x8b, 0xe2, 0xb0, 0x7c, 0x82, 0xe5, 0x58, 0xf8, 0xd3, 0xff, 0x9e, 0xfb, 0x7d, 0xff, 0xb, 0x74, 0xeb, 0x15, 0x11, 0xe1, 0xa7, 0x60, 0xfc, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char button_normal_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x8a,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x3a,0x44,0x56,0x53,0x61,0x56,0x52,0x60,0x47,0x44,0x52,0x33,0x31,0x39,0x47,0x44,0x50,0x47,0x44,0x51,0x52,0x50,0x5d,0x51,0x4f,0x5d,0x46,0x42,0x4e,0x42,0x3e,0x4a,0x41,0x3e,0x49,0x51,0x4e,0x5b,0x40,0x3e,0x48,0x4f,0x4c,0x59,0x3f,0x3d,0x47,0x4e,0x4a,0x58,0x3e,0x3b,0x46,0x4b,0x49,0x55,0x3c,0x3a,0x44,0x4a,0x47,0x54,0x3b,0x39,0x43,0x49,0x46,0x53,0x3a,0x38,0x42,0x47,0x45,0x50,0x39,0x37,0x40,0x47,0x43,0x50,0x38,0x35,0x3f,0x36,0x34,0x3e,0x44,0x42,0x4d,0x44,0x41,0x4c,0xff,0xff,0xff,0xe5,0x37,0x10,0x78,0x0,0x0,0x0,0x15,0x74,0x52,0x4e,0x53,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x77,0xef,0xef,0xef,0x77,0xef,0xed,0xe8,0xff,0x76,0xed,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x2d,0xcd,0xda,0x41,0x3d,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x93,0x49,0x44,0x41,0x54,0x18,0xd3,0x65,0xcf,0x47,0x12,0x82,0x40,0x10,0x5,0xd0,0x9e,0xc8,0x44,0x92,0x22,0x41,0x54,0x44,0x40,0x14,0xef,0x7f,0x3e,0x7,0x8a,0xea,0x85,0xbe,0xe5,0xaf,0xea,0xf0,0x1,0x8,0x65,0x5c,0xc8,0x40,0x70,0x46,0x9,0x0,0x89,0x94,0x36,0xd6,0x79,0xef,0xac,0xd1,0x2a,0x22,0x40,0x55,0x9c,0x14,0xa7,0x4d,0x91,0xc4,0x8a,0x2,0xd3,0x69,0x59,0xd5,0x9b,0xaa,0x4c,0x35,0x3,0x6e,0x9a,0xfa,0xbc,0xab,0x1b,0xc3,0x41,0xd8,0xf6,0x82,0x5a,0x2b,0x40,0xba,0xeb,0xd,0x5d,0x9d,0x4,0xe9,0xbb,0x3b,0xea,0xfc,0x1a,0xf4,0xf,0xd4,0xaf,0x81,0x1b,0x46,0x34,0x84,0x11,0x61,0xa7,0x27,0x9a,0xc2,0x52,0x6e,0xe6,0x17,0x9a,0xc3,0x59,0xa6,0xb3,0xf1,0xbd,0x1b,0xb3,0xf0,0x18,0x55,0xf9,0x61,0xf9,0x6c,0x96,0x63,0x1e,0x5e,0xff,0x2b,0xf7,0x5b,0xff,0xb,0x69,0x5a,0x14,0xfa,0x84,0xf6,0xc2,0x8,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char button_normal_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x8a, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3c, 0x3a, 0x44, 0x56, 0x53, 0x61, 0x56, 0x52, 0x60, 0x47, 0x44, 0x52, 0x33, 0x31, 0x39, 0x47, 0x44, 0x50, 0x47, 0x44, 0x51, 0x52, 0x50, 0x5d, 0x51, 0x4f, 0x5d, 0x46, 0x42, 0x4e, 0x42, 0x3e, 0x4a, 0x41, 0x3e, 0x49, 0x51, 0x4e, 0x5b, 0x40, 0x3e, 0x48, 0x4f, 0x4c, 0x59, 0x3f, 0x3d, 0x47, 0x4e, 0x4a, 0x58, 0x3e, 0x3b, 0x46, 0x4b, 0x49, 0x55, 0x3c, 0x3a, 0x44, 0x4a, 0x47, 0x54, 0x3b, 0x39, 0x43, 0x49, 0x46, 0x53, 0x3a, 0x38, 0x42, 0x47, 0x45, 0x50, 0x39, 0x37, 0x40, 0x47, 0x43, 0x50, 0x38, 0x35, 0x3f, 0x36, 0x34, 0x3e, 0x44, 0x42, 0x4d, 0x44, 0x41, 0x4c, 0xff, 0xff, 0xff, 0xe5, 0x37, 0x10, 0x78, 0x0, 0x0, 0x0, 0x15, 0x74, 0x52, 0x4e, 0x53, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x77, 0xef, 0xef, 0xef, 0x77, 0xef, 0xed, 0xe8, 0xff, 0x76, 0xed, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x2d, 0xcd, 0xda, 0x41, 0x3d, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x93, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x65, 0xcf, 0x47, 0x12, 0x82, 0x40, 0x10, 0x5, 0xd0, 0x9e, 0xc8, 0x44, 0x92, 0x22, 0x41, 0x54, 0x44, 0x40, 0x14, 0xef, 0x7f, 0x3e, 0x7, 0x8a, 0xea, 0x85, 0xbe, 0xe5, 0xaf, 0xea, 0xf0, 0x1, 0x8, 0x65, 0x5c, 0xc8, 0x40, 0x70, 0x46, 0x9, 0x0, 0x89, 0x94, 0x36, 0xd6, 0x79, 0xef, 0xac, 0xd1, 0x2a, 0x22, 0x40, 0x55, 0x9c, 0x14, 0xa7, 0x4d, 0x91, 0xc4, 0x8a, 0x2, 0xd3, 0x69, 0x59, 0xd5, 0x9b, 0xaa, 0x4c, 0x35, 0x3, 0x6e, 0x9a, 0xfa, 0xbc, 0xab, 0x1b, 0xc3, 0x41, 0xd8, 0xf6, 0x82, 0x5a, 0x2b, 0x40, 0xba, 0xeb, 0xd, 0x5d, 0x9d, 0x4, 0xe9, 0xbb, 0x3b, 0xea, 0xfc, 0x1a, 0xf4, 0xf, 0xd4, 0xaf, 0x81, 0x1b, 0x46, 0x34, 0x84, 0x11, 0x61, 0xa7, 0x27, 0x9a, 0xc2, 0x52, 0x6e, 0xe6, 0x17, 0x9a, 0xc3, 0x59, 0xa6, 0xb3, 0xf1, 0xbd, 0x1b, 0xb3, 0xf0, 0x18, 0x55, 0xf9, 0x61, 0xf9, 0x6c, 0x96, 0x63, 0x1e, 0x5e, 0xff, 0x2b, 0xf7, 0x5b, 0xff, 0xb, 0x69, 0x5a, 0x14, 0xfa, 0x84, 0xf6, 0xc2, 0x8, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char button_pressed_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x93,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x2f,0x37,0x46,0x43,0x4f,0x47,0x44,0x50,0x55,0x52,0x5f,0x55,0x52,0x60,0x3d,0x3a,0x45,0x56,0x52,0x60,0x56,0x52,0x60,0x43,0x40,0x4c,0x42,0x40,0x4b,0x3a,0x38,0x41,0x36,0x34,0x3d,0x44,0x42,0x4e,0x36,0x34,0x3e,0x46,0x42,0x4f,0x38,0x35,0x3f,0x47,0x45,0x50,0x39,0x37,0x40,0x49,0x46,0x53,0x3a,0x38,0x42,0x4a,0x47,0x54,0x3b,0x39,0x43,0x4b,0x49,0x55,0x3c,0x3a,0x44,0x4e,0x4a,0x58,0x3e,0x3b,0x46,0x50,0x4d,0x5a,0x3f,0x3d,0x48,0x3f,0x3d,0x47,0x45,0x42,0x4d,0x41,0x3e,0x49,0x40,0x3e,0x48,0x52,0x4e,0x5c,0x51,0x4e,0x5b,0xff,0xff,0xff,0x32,0xd2,0xb4,0xc,0x0,0x0,0x0,0x16,0x74,0x52,0x4e,0x53,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x77,0xef,0xef,0xef,0xef,0x77,0xef,0xed,0x6b,0x28,0x52,0x7a,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x30,0xae,0xdc,0x2d,0xe4,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x95,0x49,0x44,0x41,0x54,0x18,0xd3,0x65,0xcf,0xdb,0x12,0x42,0x50,0x14,0x6,0xe0,0xb5,0x8f,0xf6,0x11,0xa5,0x24,0x9,0x49,0x22,0xd2,0xfb,0xbf,0x5d,0x9b,0x31,0xfb,0xa2,0xbe,0xcb,0x7f,0x66,0x1d,0x7e,0x0,0x84,0x9,0x65,0xdc,0x61,0x94,0x60,0x4,0x80,0x2,0x21,0x95,0x36,0xd6,0x1a,0xad,0xa4,0x8,0x10,0x60,0x11,0x46,0xe9,0x69,0x95,0x46,0xa1,0xc0,0x40,0x64,0x9c,0x9d,0x37,0x59,0x2c,0x9,0x50,0x95,0x5f,0xbc,0x5c,0x51,0x60,0xba,0xb8,0x7a,0x85,0x66,0xc0,0x4d,0x59,0x79,0xa5,0xe1,0xc0,0x6d,0x7d,0xf3,0x6a,0xbb,0x4,0xcd,0xdd,0x6b,0x96,0xc0,0xb4,0xf,0xaf,0x75,0x23,0x4c,0x77,0x4f,0xaf,0x73,0x4b,0xa9,0xea,0x87,0xd7,0x66,0xe8,0xdd,0x59,0x22,0x77,0xe3,0xf4,0x5e,0x4d,0xe3,0xde,0x3d,0x86,0x45,0x72,0x98,0x3f,0xab,0xf9,0x98,0xb8,0xd7,0xff,0xca,0xfd,0xd6,0xff,0x2,0x86,0xd,0x15,0x51,0x39,0x7d,0xa8,0x8e,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char button_pressed_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x93, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x31, 0x2f, 0x37, 0x46, 0x43, 0x4f, 0x47, 0x44, 0x50, 0x55, 0x52, 0x5f, 0x55, 0x52, 0x60, 0x3d, 0x3a, 0x45, 0x56, 0x52, 0x60, 0x56, 0x52, 0x60, 0x43, 0x40, 0x4c, 0x42, 0x40, 0x4b, 0x3a, 0x38, 0x41, 0x36, 0x34, 0x3d, 0x44, 0x42, 0x4e, 0x36, 0x34, 0x3e, 0x46, 0x42, 0x4f, 0x38, 0x35, 0x3f, 0x47, 0x45, 0x50, 0x39, 0x37, 0x40, 0x49, 0x46, 0x53, 0x3a, 0x38, 0x42, 0x4a, 0x47, 0x54, 0x3b, 0x39, 0x43, 0x4b, 0x49, 0x55, 0x3c, 0x3a, 0x44, 0x4e, 0x4a, 0x58, 0x3e, 0x3b, 0x46, 0x50, 0x4d, 0x5a, 0x3f, 0x3d, 0x48, 0x3f, 0x3d, 0x47, 0x45, 0x42, 0x4d, 0x41, 0x3e, 0x49, 0x40, 0x3e, 0x48, 0x52, 0x4e, 0x5c, 0x51, 0x4e, 0x5b, 0xff, 0xff, 0xff, 0x32, 0xd2, 0xb4, 0xc, 0x0, 0x0, 0x0, 0x16, 0x74, 0x52, 0x4e, 0x53, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x77, 0xef, 0xef, 0xef, 0xef, 0x77, 0xef, 0xed, 0x6b, 0x28, 0x52, 0x7a, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x30, 0xae, 0xdc, 0x2d, 0xe4, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x95, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x65, 0xcf, 0xdb, 0x12, 0x42, 0x50, 0x14, 0x6, 0xe0, 0xb5, 0x8f, 0xf6, 0x11, 0xa5, 0x24, 0x9, 0x49, 0x22, 0xd2, 0xfb, 0xbf, 0x5d, 0x9b, 0x31, 0xfb, 0xa2, 0xbe, 0xcb, 0x7f, 0x66, 0x1d, 0x7e, 0x0, 0x84, 0x9, 0x65, 0xdc, 0x61, 0x94, 0x60, 0x4, 0x80, 0x2, 0x21, 0x95, 0x36, 0xd6, 0x1a, 0xad, 0xa4, 0x8, 0x10, 0x60, 0x11, 0x46, 0xe9, 0x69, 0x95, 0x46, 0xa1, 0xc0, 0x40, 0x64, 0x9c, 0x9d, 0x37, 0x59, 0x2c, 0x9, 0x50, 0x95, 0x5f, 0xbc, 0x5c, 0x51, 0x60, 0xba, 0xb8, 0x7a, 0x85, 0x66, 0xc0, 0x4d, 0x59, 0x79, 0xa5, 0xe1, 0xc0, 0x6d, 0x7d, 0xf3, 0x6a, 0xbb, 0x4, 0xcd, 0xdd, 0x6b, 0x96, 0xc0, 0xb4, 0xf, 0xaf, 0x75, 0x23, 0x4c, 0x77, 0x4f, 0xaf, 0x73, 0x4b, 0xa9, 0xea, 0x87, 0xd7, 0x66, 0xe8, 0xdd, 0x59, 0x22, 0x77, 0xe3, 0xf4, 0x5e, 0x4d, 0xe3, 0xde, 0x3d, 0x86, 0x45, 0x72, 0x98, 0x3f, 0xab, 0xf9, 0x98, 0xb8, 0xd7, 0xff, 0xca, 0xfd, 0xd6, 0xff, 0x2, 0x86, 0xd, 0x15, 0x51, 0x39, 0x7d, 0xa8, 0x8e, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char checked_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x8d,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x58,0x56,0x63,0xb0,0xaf,0xb5,0x38,0x37,0x40,0x20,0x20,0x24,0xb6,0xb6,0xb9,0x57,0x57,0x5a,0x20,0x20,0x24,0x38,0x36,0x40,0x20,0x20,0x25,0x1e,0x1e,0x22,0x1f,0x1f,0x23,0x8b,0x8b,0x8d,0xff,0xff,0xff,0x20,0x20,0x24,0x22,0x22,0x27,0x23,0x23,0x28,0x42,0x42,0x47,0xf8,0xf8,0xf8,0xfe,0xfe,0xfe,0x25,0x25,0x2a,0x4e,0x4e,0x52,0x26,0x26,0x2b,0xc5,0xc5,0xc7,0xaa,0xaa,0xab,0xb8,0xb8,0xba,0x5f,0x5f,0x63,0x74,0x74,0x77,0xed,0xed,0xed,0x33,0x33,0x38,0x8d,0x8d,0x8f,0xb8,0xb8,0xb9,0x35,0x35,0x39,0x3a,0x3a,0x3e,0xfb,0xfb,0xfb,0xfa,0xfa,0xfa,0xb2,0xb2,0xb4,0x45,0x45,0x49,0x61,0x61,0x65,0x8f,0x8f,0x92,0x63,0x63,0x66,0x2a,0x2a,0x2f,0x40,0x82,0xb,0xf6,0x0,0x0,0x0,0xf,0x74,0x52,0x4e,0x53,0x0,0x7,0x27,0x50,0x66,0x68,0x6a,0x81,0xb4,0xfa,0xdd,0xfb,0xfb,0xb4,0xfa,0xb8,0xf0,0x7f,0x59,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x12,0x7b,0xbc,0x6c,0x0,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x8e,0x49,0x44,0x41,0x54,0x18,0xd3,0x65,0xcf,0x5b,0x12,0x82,0x30,0xc,0x40,0x51,0x48,0x5b,0x15,0x5,0x5b,0x42,0x2b,0x4,0x50,0x40,0xc5,0xb7,0xee,0x7f,0x79,0x96,0x8a,0x88,0x7a,0x3f,0xcf,0x4c,0x26,0x89,0xe7,0xfd,0xe5,0x3,0xe3,0xc2,0x35,0x99,0x82,0x6f,0x1,0x66,0x81,0x54,0xae,0x18,0xe7,0x60,0x81,0x5,0x89,0x36,0x5d,0xab,0x34,0x5b,0x30,0xb,0x5c,0x6a,0xa2,0xbc,0x20,0x2a,0x71,0x2d,0xb9,0x5,0xa1,0xc,0x6d,0xb0,0xa2,0x1a,0x9b,0xad,0x12,0x3d,0xec,0x70,0xdf,0x36,0x58,0x9b,0x1,0xe,0xc7,0xd3,0x19,0x4b,0xfa,0x80,0x9d,0xc9,0xd2,0xcb,0x18,0xae,0x88,0x37,0x1a,0x43,0x91,0xdf,0x1f,0x6f,0x70,0x6b,0x5f,0x69,0xb7,0x76,0x38,0xcc,0xe8,0x24,0xec,0xe,0x83,0x28,0xec,0x4f,0x97,0xcb,0x8,0xbe,0x9e,0xe3,0xcc,0x3d,0xf7,0xd3,0x13,0x10,0x58,0xd,0x44,0xd4,0xa5,0x38,0x3e,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char checked_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x8d, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x58, 0x56, 0x63, 0xb0, 0xaf, 0xb5, 0x38, 0x37, 0x40, 0x20, 0x20, 0x24, 0xb6, 0xb6, 0xb9, 0x57, 0x57, 0x5a, 0x20, 0x20, 0x24, 0x38, 0x36, 0x40, 0x20, 0x20, 0x25, 0x1e, 0x1e, 0x22, 0x1f, 0x1f, 0x23, 0x8b, 0x8b, 0x8d, 0xff, 0xff, 0xff, 0x20, 0x20, 0x24, 0x22, 0x22, 0x27, 0x23, 0x23, 0x28, 0x42, 0x42, 0x47, 0xf8, 0xf8, 0xf8, 0xfe, 0xfe, 0xfe, 0x25, 0x25, 0x2a, 0x4e, 0x4e, 0x52, 0x26, 0x26, 0x2b, 0xc5, 0xc5, 0xc7, 0xaa, 0xaa, 0xab, 0xb8, 0xb8, 0xba, 0x5f, 0x5f, 0x63, 0x74, 0x74, 0x77, 0xed, 0xed, 0xed, 0x33, 0x33, 0x38, 0x8d, 0x8d, 0x8f, 0xb8, 0xb8, 0xb9, 0x35, 0x35, 0x39, 0x3a, 0x3a, 0x3e, 0xfb, 0xfb, 0xfb, 0xfa, 0xfa, 0xfa, 0xb2, 0xb2, 0xb4, 0x45, 0x45, 0x49, 0x61, 0x61, 0x65, 0x8f, 0x8f, 0x92, 0x63, 0x63, 0x66, 0x2a, 0x2a, 0x2f, 0x40, 0x82, 0xb, 0xf6, 0x0, 0x0, 0x0, 0xf, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x7, 0x27, 0x50, 0x66, 0x68, 0x6a, 0x81, 0xb4, 0xfa, 0xdd, 0xfb, 0xfb, 0xb4, 0xfa, 0xb8, 0xf0, 0x7f, 0x59, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x12, 0x7b, 0xbc, 0x6c, 0x0, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x8e, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x65, 0xcf, 0x5b, 0x12, 0x82, 0x30, 0xc, 0x40, 0x51, 0x48, 0x5b, 0x15, 0x5, 0x5b, 0x42, 0x2b, 0x4, 0x50, 0x40, 0xc5, 0xb7, 0xee, 0x7f, 0x79, 0x96, 0x8a, 0x88, 0x7a, 0x3f, 0xcf, 0x4c, 0x26, 0x89, 0xe7, 0xfd, 0xe5, 0x3, 0xe3, 0xc2, 0x35, 0x99, 0x82, 0x6f, 0x1, 0x66, 0x81, 0x54, 0xae, 0x18, 0xe7, 0x60, 0x81, 0x5, 0x89, 0x36, 0x5d, 0xab, 0x34, 0x5b, 0x30, 0xb, 0x5c, 0x6a, 0xa2, 0xbc, 0x20, 0x2a, 0x71, 0x2d, 0xb9, 0x5, 0xa1, 0xc, 0x6d, 0xb0, 0xa2, 0x1a, 0x9b, 0xad, 0x12, 0x3d, 0xec, 0x70, 0xdf, 0x36, 0x58, 0x9b, 0x1, 0xe, 0xc7, 0xd3, 0x19, 0x4b, 0xfa, 0x80, 0x9d, 0xc9, 0xd2, 0xcb, 0x18, 0xae, 0x88, 0x37, 0x1a, 0x43, 0x91, 0xdf, 0x1f, 0x6f, 0x70, 0x6b, 0x5f, 0x69, 0xb7, 0x76, 0x38, 0xcc, 0xe8, 0x24, 0xec, 0xe, 0x83, 0x28, 0xec, 0x4f, 0x97, 0xcb, 0x8, 0xbe, 0x9e, 0xe3, 0xcc, 0x3d, 0xf7, 0xd3, 0x13, 0x10, 0x58, 0xd, 0x44, 0xd4, 0xa5, 0x38, 0x3e, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char checker_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x8,0x0,0x0,0x0,0x0,0xe1,0x64,0xe1,0x57,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xe,0xc4,0x0,0x0,0xe,0xc4,0x1,0x95,0x2b,0xe,0x1b,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x1a,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0xfc,0xcf,0xc0,0xc0,0xd0,0xc0,0xc0,0xc0,0xc0,0xc4,0x0,0x5,0x98,0xc,0xc6,0x7a,0xc2,0x6a,0x0,0x8b,0x7a,0x2,0x8d,0x68,0x67,0xe3,0xa,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char checker_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0xe1, 0x64, 0xe1, 0x57, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xe, 0xc4, 0x0, 0x0, 0xe, 0xc4, 0x1, 0x95, 0x2b, 0xe, 0x1b, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x1a, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0xfc, 0xcf, 0xc0, 0xc0, 0xd0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc4, 0x0, 0x5, 0x98, 0xc, 0xc6, 0x7a, 0xc2, 0x6a, 0x0, 0x8b, 0x7a, 0x2, 0x8d, 0x68, 0x67, 0xe3, 0xa, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char close_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x6c,0x49,0x44,0x41,0x54,0x28,0xcf,0xad,0x90,0xd1,0xa,0x80,0x20,0xc,0x45,0xad,0xa7,0x6b,0xee,0x35,0xb1,0x3f,0xf3,0xbb,0x13,0xc,0xea,0x5f,0x5c,0xf,0x42,0x4d,0x1c,0x14,0xd4,0xde,0xc6,0x39,0xd3,0xdd,0x19,0xf3,0x53,0xd9,0x48,0x5e,0xf6,0xe4,0x6d,0x6c,0x30,0xa,0xd2,0xad,0x90,0x47,0x42,0x11,0xa,0xcd,0x76,0x5,0x63,0x9b,0x16,0xd9,0xb9,0x20,0x9f,0xbc,0x14,0x15,0xb,0x65,0x47,0x56,0x71,0x55,0x90,0xc1,0x60,0x1c,0x12,0x8f,0x5a,0x26,0x1e,0xd4,0x79,0xf9,0x45,0x5d,0x57,0x59,0xd2,0x85,0x36,0x51,0x87,0xfb,0xd0,0xef,0xe,0xf5,0x78,0xea,0x4f,0x75,0x2,0x30,0x98,0x34,0x72,0xa,0x11,0xfb,0xc2,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char close_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x6c, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0xad, 0x90, 0xd1, 0xa, 0x80, 0x20, 0xc, 0x45, 0xad, 0xa7, 0x6b, 0xee, 0x35, 0xb1, 0x3f, 0xf3, 0xbb, 0x13, 0xc, 0xea, 0x5f, 0x5c, 0xf, 0x42, 0x4d, 0x1c, 0x14, 0xd4, 0xde, 0xc6, 0x39, 0xd3, 0xdd, 0x19, 0xf3, 0x53, 0xd9, 0x48, 0x5e, 0xf6, 0xe4, 0x6d, 0x6c, 0x30, 0xa, 0xd2, 0xad, 0x90, 0x47, 0x42, 0x11, 0xa, 0xcd, 0x76, 0x5, 0x63, 0x9b, 0x16, 0xd9, 0xb9, 0x20, 0x9f, 0xbc, 0x14, 0x15, 0xb, 0x65, 0x47, 0x56, 0x71, 0x55, 0x90, 0xc1, 0x60, 0x1c, 0x12, 0x8f, 0x5a, 0x26, 0x1e, 0xd4, 0x79, 0xf9, 0x45, 0x5d, 0x57, 0x59, 0xd2, 0x85, 0x36, 0x51, 0x87, 0xfb, 0xd0, 0xef, 0xe, 0xf5, 0x78, 0xea, 0x4f, 0x75, 0x2, 0x30, 0x98, 0x34, 0x72, 0xa, 0x11, 0xfb, 0xc2, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char close_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x6c,0x49,0x44,0x41,0x54,0x28,0xcf,0xad,0x90,0xd1,0xa,0x80,0x20,0xc,0x45,0xad,0xa7,0x6b,0xee,0x35,0xb1,0x3f,0xf3,0xbb,0x13,0xc,0xea,0x5f,0x5c,0xf,0x42,0x4d,0x1c,0x14,0xd4,0xde,0xc6,0x39,0xd3,0xdd,0x19,0xf3,0x53,0xd9,0x48,0x5e,0xf6,0xe4,0x6d,0x6c,0x30,0xa,0xd2,0xad,0x90,0x47,0x42,0x11,0xa,0xcd,0x76,0x5,0x63,0x9b,0x16,0xd9,0xb9,0x20,0x9f,0xbc,0x14,0x15,0xb,0x65,0x47,0x56,0x71,0x55,0x90,0xc1,0x60,0x1c,0x12,0x8f,0x5a,0x26,0x1e,0xd4,0x79,0xf9,0x45,0x5d,0x57,0x59,0xd2,0x85,0x36,0x51,0x87,0xfb,0xd0,0xef,0xe,0xf5,0x78,0xea,0x4f,0x75,0x2,0x30,0x98,0x34,0x72,0xa,0x11,0xfb,0xc2,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char close_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x6c, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0xad, 0x90, 0xd1, 0xa, 0x80, 0x20, 0xc, 0x45, 0xad, 0xa7, 0x6b, 0xee, 0x35, 0xb1, 0x3f, 0xf3, 0xbb, 0x13, 0xc, 0xea, 0x5f, 0x5c, 0xf, 0x42, 0x4d, 0x1c, 0x14, 0xd4, 0xde, 0xc6, 0x39, 0xd3, 0xdd, 0x19, 0xf3, 0x53, 0xd9, 0x48, 0x5e, 0xf6, 0xe4, 0x6d, 0x6c, 0x30, 0xa, 0xd2, 0xad, 0x90, 0x47, 0x42, 0x11, 0xa, 0xcd, 0x76, 0x5, 0x63, 0x9b, 0x16, 0xd9, 0xb9, 0x20, 0x9f, 0xbc, 0x14, 0x15, 0xb, 0x65, 0x47, 0x56, 0x71, 0x55, 0x90, 0xc1, 0x60, 0x1c, 0x12, 0x8f, 0x5a, 0x26, 0x1e, 0xd4, 0x79, 0xf9, 0x45, 0x5d, 0x57, 0x59, 0xd2, 0x85, 0x36, 0x51, 0x87, 0xfb, 0xd0, 0xef, 0xe, 0xf5, 0x78, 0xea, 0x4f, 0x75, 0x2, 0x30, 0x98, 0x34, 0x72, 0xa, 0x11, 0xfb, 0xc2, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char dosfont_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x80,0x0,0x0,0x0,0x80,0x1,0x0,0x0,0x0,0x0,0xeb,0x45,0x5c,0x66,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0x1,0xdd,0x8a,0x13,0xa4,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x89,0x0,0x0,0xb,0x89,0x1,0x37,0xc9,0xcb,0xad,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x2,0x83,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0xd4,0xb1,0x6e,0xdb,0x30,0x10,0x0,0x50,0x22,0x3,0x27,0x22,0xc8,0x78,0x83,0x91,0xa9,0x1f,0xc0,0xa9,0x10,0xa,0x7e,0xc,0x11,0x14,0x87,0xc,0x1c,0x32,0x9,0x1a,0xe,0x46,0xa6,0xfc,0x43,0xff,0x86,0xb5,0x80,0x9b,0x88,0x8e,0x5d,0x64,0x18,0x9e,0xdc,0xd5,0x53,0x91,0xc1,0xa0,0x7a,0xa4,0xe4,0xd4,0x31,0xd2,0x25,0x70,0x97,0xa2,0x37,0x48,0xe6,0x33,0x45,0xdd,0x51,0x24,0x95,0x7a,0x23,0xe0,0x75,0x13,0xb,0xd8,0x93,0xbf,0x51,0x51,0xa3,0xac,0x99,0xc9,0x29,0x87,0x81,0x83,0xb2,0x0,0xc7,0xfe,0xee,0x43,0x58,0x85,0x95,0xb7,0xa6,0xb6,0xaf,0x7a,0xe9,0x93,0x63,0xc3,0xf2,0xc,0x96,0x3e,0xba,0x97,0x11,0x3,0xb5,0x46,0xc0,0x15,0x30,0x43,0x1,0xbd,0x6,0x81,0x71,0xa9,0xb2,0x82,0x9,0x92,0x3d,0xf6,0xb0,0xbd,0x5c,0xf2,0x53,0xf2,0x75,0xc,0x11,0x5f,0xc7,0xe0,0xc4,0xaa,0xb4,0x40,0x41,0xc4,0x69,0xd0,0x27,0x55,0x12,0x13,0x78,0x74,0xa7,0xb5,0xd8,0x3f,0x14,0x77,0x81,0x0,0x22,0x93,0x9b,0x4c,0x54,0x5b,0x72,0x6d,0x98,0x17,0xd1,0x33,0xb3,0x94,0xaa,0x3c,0x93,0xea,0xb4,0x76,0x31,0x6a,0x66,0x0,0xa9,0x59,0x1c,0x8c,0xe,0x33,0xc0,0x12,0x4c,0x29,0xc2,0xa5,0xc3,0xc1,0xd0,0xb2,0x64,0x6a,0x60,0xa3,0xc0,0xea,0xac,0x19,0x58,0x4b,0xa9,0x4a,0x17,0xf0,0xda,0x68,0xb6,0x5,0xec,0xb2,0xf6,0x88,0x33,0xc8,0x18,0x52,0xd5,0x5a,0x1,0xb3,0x61,0x1,0x53,0xdf,0x2,0x51,0x2d,0x33,0xdd,0x12,0x59,0xea,0x94,0x95,0x3c,0x80,0x2e,0x5e,0xf9,0xdb,0x71,0x73,0x70,0xcf,0x39,0x3b,0x76,0xb7,0xbb,0x7d,0xcf,0x74,0x50,0xd,0x62,0x40,0x44,0x6,0x83,0xfe,0xc7,0x8e,0x51,0x5,0x5c,0xe1,0xdd,0xdd,0xaa,0xc2,0xf8,0x53,0x80,0x31,0xe2,0xfd,0x7d,0x14,0x8,0x7e,0xcc,0x5,0x28,0x62,0xd7,0xc5,0xc,0xa6,0xf3,0xc3,0x46,0xa6,0x30,0xd7,0x1e,0x1b,0x2e,0xd0,0x7f,0x63,0x5f,0x1f,0xf1,0x32,0xc9,0x90,0x82,0xef,0xb9,0x82,0xc,0x5a,0x1,0xef,0x66,0x90,0xd7,0x7a,0x2c,0x80,0x13,0x94,0xc4,0xf6,0x9f,0xd8,0x75,0xbb,0x2c,0x89,0xed,0xff,0x42,0xe9,0xa7,0xfb,0xa4,0x84,0xec,0x13,0x45,0x7,0x1a,0xb9,0x97,0x18,0x65,0xab,0x4,0xf9,0x54,0x8c,0x3c,0x54,0xe8,0xed,0xa3,0x7c,0x7b,0x55,0xe0,0x8b,0x0,0xf6,0x4f,0x36,0xd6,0x3d,0xc3,0xe8,0x41,0xc0,0xa1,0xb1,0xdb,0x9,0xa8,0x29,0x0,0xe,0xec,0xc3,0x4,0xc1,0x8,0xc,0x0,0xd6,0x36,0xf3,0x23,0xba,0x80,0x3,0x6f,0x17,0x15,0xbe,0x4b,0xe5,0x8c,0x23,0xc2,0x57,0x7b,0x5d,0x61,0x53,0xc0,0x61,0xf,0xbd,0xd5,0x15,0x68,0x47,0x8e,0x0,0x7b,0x37,0xba,0xab,0xba,0x59,0xcc,0x79,0x3d,0xd7,0xaf,0x5a,0xe3,0x85,0x66,0x69,0xab,0x16,0x32,0x31,0x5b,0xd0,0xdb,0x66,0x2,0x2f,0x6f,0xe,0xb2,0x42,0xb5,0x87,0xdf,0xf0,0x59,0xae,0x6a,0x86,0xae,0x93,0x4c,0x7d,0x1b,0x9a,0x6b,0x84,0xdd,0x9a,0xd6,0xca,0xc8,0x89,0xc3,0xfb,0xd4,0x82,0xe,0x30,0xa2,0x2c,0x18,0xc2,0x98,0xb2,0x4f,0x8,0xba,0x83,0xa1,0x40,0x12,0x88,0x6f,0x43,0x38,0x82,0x1c,0x1f,0x15,0x70,0x82,0x96,0xa8,0xa5,0x3d,0xed,0x9c,0xde,0xb9,0x1,0xe9,0xb8,0x5f,0x4c,0x39,0xd2,0xa6,0xac,0xa6,0x48,0xe7,0xd0,0x95,0x53,0xb0,0xc4,0x7b,0x97,0xd4,0xcd,0x3c,0xdd,0xf0,0xd0,0x4e,0xbf,0xe6,0x65,0x24,0x5b,0x7b,0x7d,0xe,0xe5,0xd6,0xae,0xe9,0x90,0x64,0xfd,0x70,0x9e,0x21,0xb5,0x6c,0x5,0xa4,0xa2,0x87,0xe9,0xa3,0x25,0xf4,0x5,0x5c,0x39,0x61,0xa6,0x1e,0xbe,0x11,0x18,0x80,0xed,0xb,0x18,0x9b,0x70,0x70,0xec,0x5f,0x80,0x3f,0x26,0x27,0xb3,0xc9,0x33,0xc8,0x5c,0x2c,0x5a,0x59,0x1f,0xcb,0x2c,0x89,0x9d,0xae,0xf,0x7d,0xcc,0xdb,0x9c,0xdd,0xd5,0xed,0x7c,0x7f,0xbe,0xd0,0x52,0xf9,0x1f,0xff,0x76,0xfc,0x2,0x24,0x3a,0x65,0x42,0xf6,0x41,0x91,0x95,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char dosfont_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x80, 0x1, 0x0, 0x0, 0x0, 0x0, 0xeb, 0x45, 0x5c, 0x66, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x76, 0x93, 0xcd, 0x38, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x1, 0xdd, 0x8a, 0x13, 0xa4, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x89, 0x0, 0x0, 0xb, 0x89, 0x1, 0x37, 0xc9, 0xcb, 0xad, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x2, 0x83, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xed, 0xd4, 0xb1, 0x6e, 0xdb, 0x30, 0x10, 0x0, 0x50, 0x22, 0x3, 0x27, 0x22, 0xc8, 0x78, 0x83, 0x91, 0xa9, 0x1f, 0xc0, 0xa9, 0x10, 0xa, 0x7e, 0xc, 0x11, 0x14, 0x87, 0xc, 0x1c, 0x32, 0x9, 0x1a, 0xe, 0x46, 0xa6, 0xfc, 0x43, 0xff, 0x86, 0xb5, 0x80, 0x9b, 0x88, 0x8e, 0x5d, 0x64, 0x18, 0x9e, 0xdc, 0xd5, 0x53, 0x91, 0xc1, 0xa0, 0x7a, 0xa4, 0xe4, 0xd4, 0x31, 0xd2, 0x25, 0x70, 0x97, 0xa2, 0x37, 0x48, 0xe6, 0x33, 0x45, 0xdd, 0x51, 0x24, 0x95, 0x7a, 0x23, 0xe0, 0x75, 0x13, 0xb, 0xd8, 0x93, 0xbf, 0x51, 0x51, 0xa3, 0xac, 0x99, 0xc9, 0x29, 0x87, 0x81, 0x83, 0xb2, 0x0, 0xc7, 0xfe, 0xee, 0x43, 0x58, 0x85, 0x95, 0xb7, 0xa6, 0xb6, 0xaf, 0x7a, 0xe9, 0x93, 0x63, 0xc3, 0xf2, 0xc, 0x96, 0x3e, 0xba, 0x97, 0x11, 0x3, 0xb5, 0x46, 0xc0, 0x15, 0x30, 0x43, 0x1, 0xbd, 0x6, 0x81, 0x71, 0xa9, 0xb2, 0x82, 0x9, 0x92, 0x3d, 0xf6, 0xb0, 0xbd, 0x5c, 0xf2, 0x53, 0xf2, 0x75, 0xc, 0x11, 0x5f, 0xc7, 0xe0, 0xc4, 0xaa, 0xb4, 0x40, 0x41, 0xc4, 0x69, 0xd0, 0x27, 0x55, 0x12, 0x13, 0x78, 0x74, 0xa7, 0xb5, 0xd8, 0x3f, 0x14, 0x77, 0x81, 0x0, 0x22, 0x93, 0x9b, 0x4c, 0x54, 0x5b, 0x72, 0x6d, 0x98, 0x17, 0xd1, 0x33, 0xb3, 0x94, 0xaa, 0x3c, 0x93, 0xea, 0xb4, 0x76, 0x31, 0x6a, 0x66, 0x0, 0xa9, 0x59, 0x1c, 0x8c, 0xe, 0x33, 0xc0, 0x12, 0x4c, 0x29, 0xc2, 0xa5, 0xc3, 0xc1, 0xd0, 0xb2, 0x64, 0x6a, 0x60, 0xa3, 0xc0, 0xea, 0xac, 0x19, 0x58, 0x4b, 0xa9, 0x4a, 0x17, 0xf0, 0xda, 0x68, 0xb6, 0x5, 0xec, 0xb2, 0xf6, 0x88, 0x33, 0xc8, 0x18, 0x52, 0xd5, 0x5a, 0x1, 0xb3, 0x61, 0x1, 0x53, 0xdf, 0x2, 0x51, 0x2d, 0x33, 0xdd, 0x12, 0x59, 0xea, 0x94, 0x95, 0x3c, 0x80, 0x2e, 0x5e, 0xf9, 0xdb, 0x71, 0x73, 0x70, 0xcf, 0x39, 0x3b, 0x76, 0xb7, 0xbb, 0x7d, 0xcf, 0x74, 0x50, 0xd, 0x62, 0x40, 0x44, 0x6, 0x83, 0xfe, 0xc7, 0x8e, 0x51, 0x5, 0x5c, 0xe1, 0xdd, 0xdd, 0xaa, 0xc2, 0xf8, 0x53, 0x80, 0x31, 0xe2, 0xfd, 0x7d, 0x14, 0x8, 0x7e, 0xcc, 0x5, 0x28, 0x62, 0xd7, 0xc5, 0xc, 0xa6, 0xf3, 0xc3, 0x46, 0xa6, 0x30, 0xd7, 0x1e, 0x1b, 0x2e, 0xd0, 0x7f, 0x63, 0x5f, 0x1f, 0xf1, 0x32, 0xc9, 0x90, 0x82, 0xef, 0xb9, 0x82, 0xc, 0x5a, 0x1, 0xef, 0x66, 0x90, 0xd7, 0x7a, 0x2c, 0x80, 0x13, 0x94, 0xc4, 0xf6, 0x9f, 0xd8, 0x75, 0xbb, 0x2c, 0x89, 0xed, 0xff, 0x42, 0xe9, 0xa7, 0xfb, 0xa4, 0x84, 0xec, 0x13, 0x45, 0x7, 0x1a, 0xb9, 0x97, 0x18, 0x65, 0xab, 0x4, 0xf9, 0x54, 0x8c, 0x3c, 0x54, 0xe8, 0xed, 0xa3, 0x7c, 0x7b, 0x55, 0xe0, 0x8b, 0x0, 0xf6, 0x4f, 0x36, 0xd6, 0x3d, 0xc3, 0xe8, 0x41, 0xc0, 0xa1, 0xb1, 0xdb, 0x9, 0xa8, 0x29, 0x0, 0xe, 0xec, 0xc3, 0x4, 0xc1, 0x8, 0xc, 0x0, 0xd6, 0x36, 0xf3, 0x23, 0xba, 0x80, 0x3, 0x6f, 0x17, 0x15, 0xbe, 0x4b, 0xe5, 0x8c, 0x23, 0xc2, 0x57, 0x7b, 0x5d, 0x61, 0x53, 0xc0, 0x61, 0xf, 0xbd, 0xd5, 0x15, 0x68, 0x47, 0x8e, 0x0, 0x7b, 0x37, 0xba, 0xab, 0xba, 0x59, 0xcc, 0x79, 0x3d, 0xd7, 0xaf, 0x5a, 0xe3, 0x85, 0x66, 0x69, 0xab, 0x16, 0x32, 0x31, 0x5b, 0xd0, 0xdb, 0x66, 0x2, 0x2f, 0x6f, 0xe, 0xb2, 0x42, 0xb5, 0x87, 0xdf, 0xf0, 0x59, 0xae, 0x6a, 0x86, 0xae, 0x93, 0x4c, 0x7d, 0x1b, 0x9a, 0x6b, 0x84, 0xdd, 0x9a, 0xd6, 0xca, 0xc8, 0x89, 0xc3, 0xfb, 0xd4, 0x82, 0xe, 0x30, 0xa2, 0x2c, 0x18, 0xc2, 0x98, 0xb2, 0x4f, 0x8, 0xba, 0x83, 0xa1, 0x40, 0x12, 0x88, 0x6f, 0x43, 0x38, 0x82, 0x1c, 0x1f, 0x15, 0x70, 0x82, 0x96, 0xa8, 0xa5, 0x3d, 0xed, 0x9c, 0xde, 0xb9, 0x1, 0xe9, 0xb8, 0x5f, 0x4c, 0x39, 0xd2, 0xa6, 0xac, 0xa6, 0x48, 0xe7, 0xd0, 0x95, 0x53, 0xb0, 0xc4, 0x7b, 0x97, 0xd4, 0xcd, 0x3c, 0xdd, 0xf0, 0xd0, 0x4e, 0xbf, 0xe6, 0x65, 0x24, 0x5b, 0x7b, 0x7d, 0xe, 0xe5, 0xd6, 0xae, 0xe9, 0x90, 0x64, 0xfd, 0x70, 0x9e, 0x21, 0xb5, 0x6c, 0x5, 0xa4, 0xa2, 0x87, 0xe9, 0xa3, 0x25, 0xf4, 0x5, 0x5c, 0x39, 0x61, 0xa6, 0x1e, 0xbe, 0x11, 0x18, 0x80, 0xed, 0xb, 0x18, 0x9b, 0x70, 0x70, 0xec, 0x5f, 0x80, 0x3f, 0x26, 0x27, 0xb3, 0xc9, 0x33, 0xc8, 0x5c, 0x2c, 0x5a, 0x59, 0x1f, 0xcb, 0x2c, 0x89, 0x9d, 0xae, 0xf, 0x7d, 0xcc, 0xdb, 0x9c, 0xdd, 0xd5, 0xed, 0x7c, 0x7f, 0xbe, 0xd0, 0x52, 0xf9, 0x1f, 0xff, 0x76, 0xfc, 0x2, 0x24, 0x3a, 0x65, 0x42, 0xf6, 0x41, 0x91, 0x95, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char dropdown_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x8,0x4,0x0,0x0,0x0,0x6e,0x6,0x76,0x0,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x64,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x60,0xf8,0xc0,0xcc,0x0,0x5,0x1f,0x98,0x19,0x18,0x18,0x3f,0x30,0xff,0xd3,0x83,0x70,0xff,0x33,0x33,0x30,0x8,0x9f,0x61,0xf9,0x6b,0xff,0x65,0x2f,0x3,0x1c,0xbc,0xea,0x66,0x62,0xbc,0xcf,0xc0,0xc0,0xf0,0x7,0x26,0xc0,0x74,0x89,0x89,0xe9,0x29,0x9f,0x14,0x3,0xb,0xc3,0x5f,0x6,0x6,0x6,0x6,0xee,0x38,0x91,0x25,0xc,0xc,0xc,0x1f,0xd8,0xde,0x4b,0x3e,0xfc,0xff,0xf0,0xff,0x9b,0x58,0xb8,0xce,0xf,0x6c,0xef,0xe4,0xde,0xa4,0x32,0x20,0x83,0xf,0x4c,0x30,0x16,0x0,0x75,0xad,0x1b,0x7f,0x65,0xec,0x78,0x4c,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char dropdown_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x8, 0x4, 0x0, 0x0, 0x0, 0x6e, 0x6, 0x76, 0x0, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x64, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x60, 0xf8, 0xc0, 0xcc, 0x0, 0x5, 0x1f, 0x98, 0x19, 0x18, 0x18, 0x3f, 0x30, 0xff, 0xd3, 0x83, 0x70, 0xff, 0x33, 0x33, 0x30, 0x8, 0x9f, 0x61, 0xf9, 0x6b, 0xff, 0x65, 0x2f, 0x3, 0x1c, 0xbc, 0xea, 0x66, 0x62, 0xbc, 0xcf, 0xc0, 0xc0, 0xf0, 0x7, 0x26, 0xc0, 0x74, 0x89, 0x89, 0xe9, 0x29, 0x9f, 0x14, 0x3, 0xb, 0xc3, 0x5f, 0x6, 0x6, 0x6, 0x6, 0xee, 0x38, 0x91, 0x25, 0xc, 0xc, 0xc, 0x1f, 0xd8, 0xde, 0x4b, 0x3e, 0xfc, 0xff, 0xf0, 0xff, 0x9b, 0x58, 0xb8, 0xce, 0xf, 0x6c, 0xef, 0xe4, 0xde, 0xa4, 0x32, 0x20, 0x83, 0xf, 0x4c, 0x30, 0x16, 0x0, 0x75, 0xad, 0x1b, 0x7f, 0x65, 0xec, 0x78, 0x4c, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char error_icon_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x4,0x0,0x0,0x0,0xd9,0x73,0xb2,0x7f,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x5d,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0x94,0xc1,0xe,0x80,0x20,0xc,0x43,0x5b,0xe3,0xff,0xff,0x72,0x3d,0xcc,0x85,0xa1,0xbb,0x18,0xf4,0x62,0xca,0xa9,0x74,0xe3,0x65,0xd,0x1,0xa,0x6b,0x6b,0x5b,0x3c,0x6f,0x80,0x1,0x7f,0x1,0xec,0x29,0x78,0xbe,0x2a,0x31,0x94,0x98,0x9e,0x98,0xf5,0xab,0x37,0x1,0xaa,0x19,0x8d,0xe2,0x50,0xb1,0x9b,0xbd,0xb7,0x23,0x8c,0x21,0x7b,0xd5,0xf5,0x3d,0x88,0x50,0x1,0xdf,0x46,0xb8,0xf,0x5c,0xef,0xa6,0xab,0xd1,0x7f,0xa2,0x1,0x6,0x0,0x0,0xe,0x62,0x6,0x31,0x47,0xb6,0x7f,0xdd,0x14,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char error_icon_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x20, 0x8, 0x4, 0x0, 0x0, 0x0, 0xd9, 0x73, 0xb2, 0x7f, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x5d, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xed, 0x94, 0xc1, 0xe, 0x80, 0x20, 0xc, 0x43, 0x5b, 0xe3, 0xff, 0xff, 0x72, 0x3d, 0xcc, 0x85, 0xa1, 0xbb, 0x18, 0xf4, 0x62, 0xca, 0xa9, 0x74, 0xe3, 0x65, 0xd, 0x1, 0xa, 0x6b, 0x6b, 0x5b, 0x3c, 0x6f, 0x80, 0x1, 0x7f, 0x1, 0xec, 0x29, 0x78, 0xbe, 0x2a, 0x31, 0x94, 0x98, 0x9e, 0x98, 0xf5, 0xab, 0x37, 0x1, 0xaa, 0x19, 0x8d, 0xe2, 0x50, 0xb1, 0x9b, 0xbd, 0xb7, 0x23, 0x8c, 0x21, 0x7b, 0xd5, 0xf5, 0x3d, 0x88, 0x50, 0x1, 0xdf, 0x46, 0xb8, 0xf, 0x5c, 0xef, 0xa6, 0xab, 0xd1, 0x7f, 0xa2, 0x1, 0x6, 0x0, 0x0, 0xe, 0x62, 0x6, 0x31, 0x47, 0xb6, 0x7f, 0xdd, 0x14, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char focus_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x4,0x3,0x0,0x0,0x0,0xa4,0x5b,0x41,0xd4,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x30,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0xff,0xff,0xff,0xb9,0xa2,0x9b,0xc9,0x0,0x0,0x0,0xf,0x74,0x52,0x4e,0x53,0x0,0xe,0x39,0x68,0x7a,0x7b,0x3a,0x74,0x10,0x8,0x69,0xf,0x6,0x75,0x11,0xb8,0x16,0x0,0x1,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xf,0x18,0xba,0x0,0xd9,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x38,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x10,0x32,0x9,0xd,0x75,0x56,0x64,0x48,0xef,0x9c,0x39,0x73,0x46,0x19,0xc3,0x6a,0x6,0x20,0xd8,0xc5,0x10,0x3,0xa2,0x8e,0x32,0x44,0x82,0xa8,0xa9,0xd8,0x29,0xa8,0x12,0xb0,0x6,0x29,0x86,0xdc,0x9d,0x33,0x67,0xce,0x2b,0x63,0x10,0x3,0x1b,0x6,0x0,0xdf,0xc6,0x11,0x6d,0xb8,0xf4,0x9c,0xac,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char focus_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x4, 0x3, 0x0, 0x0, 0x0, 0xa4, 0x5b, 0x41, 0xd4, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x30, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0xff, 0xff, 0xff, 0xb9, 0xa2, 0x9b, 0xc9, 0x0, 0x0, 0x0, 0xf, 0x74, 0x52, 0x4e, 0x53, 0x0, 0xe, 0x39, 0x68, 0x7a, 0x7b, 0x3a, 0x74, 0x10, 0x8, 0x69, 0xf, 0x6, 0x75, 0x11, 0xb8, 0x16, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xf, 0x18, 0xba, 0x0, 0xd9, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x38, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x10, 0x32, 0x9, 0xd, 0x75, 0x56, 0x64, 0x48, 0xef, 0x9c, 0x39, 0x73, 0x46, 0x19, 0xc3, 0x6a, 0x6, 0x20, 0xd8, 0xc5, 0x10, 0x3, 0xa2, 0x8e, 0x32, 0x44, 0x82, 0xa8, 0xa9, 0xd8, 0x29, 0xa8, 0x12, 0xb0, 0x6, 0x29, 0x86, 0xdc, 0x9d, 0x33, 0x67, 0xce, 0x2b, 0x63, 0x10, 0x3, 0x1b, 0x6, 0x0, 0xdf, 0xc6, 0x11, 0x6d, 0xb8, 0xf4, 0x9c, 0xac, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char frame_focus_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x4,0x3,0x0,0x0,0x0,0xa4,0x5b,0x41,0xd4,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x30,0x50,0x4c,0x54,0x45,0xff,0xff,0xff,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0x47,0x8c,0xbf,0xff,0xff,0xff,0xcc,0x40,0x27,0xb9,0x0,0x0,0x0,0xf,0x74,0x52,0x4e,0x53,0x0,0xe,0x39,0x68,0x7a,0x7b,0x3a,0x74,0x10,0x8,0x69,0xf,0x6,0x75,0x11,0xb8,0x16,0x0,0x1,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x0,0x88,0x5,0x1d,0x48,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x38,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x10,0x32,0x9,0xd,0x75,0x56,0x64,0x48,0xef,0x9c,0x39,0x73,0x46,0x19,0xc3,0x6a,0x6,0x20,0xd8,0xc5,0x10,0x3,0xa2,0x8e,0x32,0x44,0x82,0xa8,0xa9,0xd8,0x29,0xa8,0x12,0xb0,0x6,0x29,0x86,0xdc,0x9d,0x33,0x67,0xce,0x2b,0x63,0x10,0x3,0x1b,0x6,0x0,0xdf,0xc6,0x11,0x6d,0xb8,0xf4,0x9c,0xac,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char frame_focus_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x4, 0x3, 0x0, 0x0, 0x0, 0xa4, 0x5b, 0x41, 0xd4, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0xff, 0xff, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0x47, 0x8c, 0xbf, 0xff, 0xff, 0xff, 0xcc, 0x40, 0x27, 0xb9, 0x0, 0x0, 0x0, 0xf, 0x74, 0x52, 0x4e, 0x53, 0x0, 0xe, 0x39, 0x68, 0x7a, 0x7b, 0x3a, 0x74, 0x10, 0x8, 0x69, 0xf, 0x6, 0x75, 0x11, 0xb8, 0x16, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x88, 0x5, 0x1d, 0x48, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x38, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x10, 0x32, 0x9, 0xd, 0x75, 0x56, 0x64, 0x48, 0xef, 0x9c, 0x39, 0x73, 0x46, 0x19, 0xc3, 0x6a, 0x6, 0x20, 0xd8, 0xc5, 0x10, 0x3, 0xa2, 0x8e, 0x32, 0x44, 0x82, 0xa8, 0xa9, 0xd8, 0x29, 0xa8, 0x12, 0xb0, 0x6, 0x29, 0x86, 0xdc, 0x9d, 0x33, 0x67, 0xce, 0x2b, 0x63, 0x10, 0x3, 0x1b, 0x6, 0x0, 0xdf, 0xc6, 0x11, 0x6d, 0xb8, 0xf4, 0x9c, 0xac, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char full_panel_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x3,0x0,0x0,0x0,0x44,0xa4,0x8a,0xc6,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x33,0x50,0x4c,0x54,0x45,0x27,0x27,0x29,0x26,0x26,0x28,0x25,0x25,0x27,0x24,0x24,0x26,0x23,0x23,0x25,0x22,0x22,0x24,0x21,0x21,0x23,0x1e,0x1e,0x20,0x1d,0x1d,0x1f,0x1c,0x1c,0x1e,0x31,0x30,0x32,0x50,0x4e,0x54,0x4e,0x4c,0x50,0x4c,0x4a,0x4e,0x3d,0x3b,0x3f,0x38,0x36,0x3a,0xff,0xff,0xff,0x4,0xb3,0x69,0x9b,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x10,0x95,0xb2,0xd,0x2c,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x63,0x49,0x44,0x41,0x54,0x38,0xcb,0xed,0x93,0x29,0x12,0xc0,0x30,0xc,0xc4,0x7c,0x3b,0x67,0xf3,0xff,0xdf,0xb6,0xe1,0xce,0x98,0x15,0x45,0x58,0xb3,0x68,0x5,0x0,0x80,0x48,0x21,0x88,0xb0,0x41,0x62,0x51,0xb,0x50,0x61,0xda,0xa,0xb1,0x79,0xa9,0x1,0xc5,0x8d,0xe9,0x1b,0x60,0x6b,0x7d,0xcc,0x80,0xd1,0x9b,0x31,0x2,0x8a,0xf7,0x67,0x85,0x3c,0xdd,0x5,0x81,0xb4,0x8c,0x75,0x60,0x14,0x25,0x20,0xab,0xf3,0x24,0xcc,0x6a,0x57,0xb8,0xc2,0xff,0x42,0x76,0xda,0xf4,0xf6,0x69,0x38,0x69,0x7a,0x79,0xbc,0x49,0xfe,0x2f,0x65,0xd3,0x2d,0x45,0xb,0x5e,0xbc,0x3b,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char full_panel_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x20, 0x8, 0x3, 0x0, 0x0, 0x0, 0x44, 0xa4, 0x8a, 0xc6, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x33, 0x50, 0x4c, 0x54, 0x45, 0x27, 0x27, 0x29, 0x26, 0x26, 0x28, 0x25, 0x25, 0x27, 0x24, 0x24, 0x26, 0x23, 0x23, 0x25, 0x22, 0x22, 0x24, 0x21, 0x21, 0x23, 0x1e, 0x1e, 0x20, 0x1d, 0x1d, 0x1f, 0x1c, 0x1c, 0x1e, 0x31, 0x30, 0x32, 0x50, 0x4e, 0x54, 0x4e, 0x4c, 0x50, 0x4c, 0x4a, 0x4e, 0x3d, 0x3b, 0x3f, 0x38, 0x36, 0x3a, 0xff, 0xff, 0xff, 0x4, 0xb3, 0x69, 0x9b, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x10, 0x95, 0xb2, 0xd, 0x2c, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x63, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0xed, 0x93, 0x29, 0x12, 0xc0, 0x30, 0xc, 0xc4, 0x7c, 0x3b, 0x67, 0xf3, 0xff, 0xdf, 0xb6, 0xe1, 0xce, 0x98, 0x15, 0x45, 0x58, 0xb3, 0x68, 0x5, 0x0, 0x80, 0x48, 0x21, 0x88, 0xb0, 0x41, 0x62, 0x51, 0xb, 0x50, 0x61, 0xda, 0xa, 0xb1, 0x79, 0xa9, 0x1, 0xc5, 0x8d, 0xe9, 0x1b, 0x60, 0x6b, 0x7d, 0xcc, 0x80, 0xd1, 0x9b, 0x31, 0x2, 0x8a, 0xf7, 0x67, 0x85, 0x3c, 0xdd, 0x5, 0x81, 0xb4, 0x8c, 0x75, 0x60, 0x14, 0x25, 0x20, 0xab, 0xf3, 0x24, 0xcc, 0x6a, 0x57, 0xb8, 0xc2, 0xff, 0x42, 0x76, 0xda, 0xf4, 0xf6, 0x69, 0x38, 0x69, 0x7a, 0x79, 0xbc, 0x49, 0xfe, 0x2f, 0x65, 0xd3, 0x2d, 0x45, 0xb, 0x5e, 0xbc, 0x3b, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char graph_node_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x40,0x8,0x3,0x0,0x0,0x0,0x24,0xa3,0x7,0xa4,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x4d,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0xd,0x10,0x17,0x14,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0x12,0x10,0x13,0x0,0x0,0x0,0x19,0x17,0x1b,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x16,0x12,0x19,0x0,0x0,0x0,0xe,0xb,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0xb,0x10,0x16,0x12,0x19,0x0,0x0,0x0,0x1d,0x1a,0x1f,0x35,0x2f,0x38,0xba,0xa9,0xc3,0xc3,0xb7,0xcb,0xbd,0xad,0xc5,0xb9,0xa9,0xc3,0xb5,0xa3,0xbf,0xb4,0xa1,0xbe,0xb4,0xa2,0xbd,0xb4,0xa2,0xbe,0xb3,0xa2,0xbe,0xb1,0xa0,0xbc,0xb2,0xa0,0xbc,0xb2,0x9f,0xbc,0xb0,0x9e,0xba,0xb0,0x9d,0xbb,0xb1,0x9e,0xbb,0xb0,0x9e,0xbb,0xb1,0x9e,0xba,0xaf,0x9c,0xb9,0xae,0x9c,0xb9,0xae,0x9c,0xb8,0xaf,0x9d,0xb9,0xad,0x9b,0xb7,0xad,0x9a,0xb7,0xad,0x9a,0xb8,0xac,0x99,0xb6,0xab,0x99,0xb6,0xac,0x98,0xb6,0xab,0x98,0xb6,0xab,0x99,0xb5,0xa9,0x97,0xb4,0xa9,0x97,0xb5,0xaa,0x97,0xb4,0xa8,0x95,0xb3,0xa8,0x95,0xb2,0xa7,0x95,0xb3,0xa7,0x93,0xb1,0xa6,0x93,0xb1,0xa5,0x91,0xaf,0xa5,0x91,0xb0,0xa4,0x91,0xaf,0xa5,0x92,0xb0,0xa4,0x91,0xb0,0xa5,0x92,0xaf,0xa3,0x90,0xae,0xa3,0x90,0xad,0xa3,0x8f,0xae,0xa2,0x90,0xae,0xa1,0x8e,0xac,0xa1,0x8e,0xad,0xa2,0x8e,0xac,0x9f,0x8d,0xab,0xa0,0x8d,0xab,0xa0,0x8c,0xab,0xa0,0x8d,0xaa,0x9f,0x8c,0xaa,0x9f,0x8c,0xab,0x9e,0x8a,0xaa,0x9e,0x8b,0xa9,0x9e,0x8b,0xaa,0x9e,0x8a,0xa9,0x9d,0x8a,0xa9,0x9c,0x88,0xa7,0x9c,0x88,0xa8,0x9c,0x89,0xa7,0x9c,0x89,0xa8,0x9a,0x87,0xa6,0x9b,0x87,0xa6,0x9b,0x86,0xa6,0x9b,0x87,0xa7,0x19,0x15,0x1c,0x4a,0x42,0x4f,0x3b,0x34,0x3f,0x39,0x30,0x3f,0x24,0x1e,0x27,0xff,0xff,0xff,0x8f,0x6b,0x6d,0x0,0x0,0x0,0x0,0x22,0x74,0x52,0x4e,0x53,0x0,0x1,0x3,0x6,0x8,0x9,0x2,0xc,0x1e,0x33,0x41,0x46,0xd,0x31,0x9a,0xe3,0x5,0x24,0xb4,0x39,0xf4,0x44,0xa,0x47,0x45,0x3d,0xf8,0x2a,0xcd,0x11,0x3f,0xd3,0xfd,0x2b,0x85,0xa8,0x7,0x57,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x6e,0x22,0xf,0x51,0x17,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x1,0x53,0x49,0x44,0x41,0x54,0x38,0xcb,0xed,0xd4,0x69,0x57,0x1,0x51,0x18,0xc0,0xf1,0x8b,0x99,0xb1,0x8c,0x65,0x6c,0x63,0x9d,0xc1,0x10,0xd1,0xc4,0x44,0x23,0x6b,0xb2,0x55,0xa8,0x24,0x92,0xb2,0x15,0x45,0x8a,0xef,0xff,0xb6,0x6b,0xba,0x39,0x4e,0xbd,0xe8,0xb,0xf8,0x9f,0xe7,0xdc,0x73,0x9e,0xdf,0xfb,0xe7,0x2,0x0,0x64,0x72,0x5,0x86,0xc3,0x30,0x85,0x5c,0x6,0x60,0x84,0x52,0xa5,0xd6,0x90,0x30,0x8d,0x5a,0xa5,0x24,0xe0,0xae,0xd5,0xe9,0xd,0x9c,0x94,0x41,0xaf,0xd3,0x12,0x80,0x32,0x9a,0xfc,0x81,0x3d,0xa9,0x80,0xdf,0x64,0xa4,0x0,0x66,0xb6,0x4,0x43,0xfb,0x52,0xa1,0xa0,0xc5,0x8c,0x1,0xdc,0xca,0x85,0x23,0x7,0x61,0x9e,0xe7,0x23,0x3c,0xcf,0x59,0x71,0x40,0xdb,0xb8,0xc3,0x68,0x34,0x1a,0x83,0x13,0x8b,0x71,0x36,0x1a,0xe0,0x24,0x27,0x1c,0x9,0x71,0x21,0x9e,0x48,0x8,0xc7,0x8,0xc4,0xe4,0x49,0x4a,0x4c,0x8a,0x29,0x51,0x44,0x90,0xce,0x64,0xd2,0xe9,0x2c,0x9c,0x2c,0x82,0x5c,0x3e,0x97,0x3b,0xcd,0x17,0xf2,0x67,0x5,0x4,0x45,0x58,0xa9,0x5c,0x2a,0x96,0xcb,0x8,0x2a,0xd5,0x6a,0x65,0xdd,0x79,0x5,0xc1,0xc5,0xe5,0xba,0xf5,0x8b,0xa0,0x56,0x6f,0xd4,0xae,0x1a,0x8d,0xfa,0xf5,0xd,0x82,0xe6,0x6d,0xb3,0xd9,0x6a,0xc1,0xb9,0x43,0xd0,0x6e,0x77,0xee,0xdb,0xb0,0x4e,0x1b,0x41,0xf7,0xa1,0xf7,0xf8,0xd4,0xef,0xf6,0x7b,0x7d,0x4,0x83,0xe1,0x68,0x38,0x1c,0xd,0xc6,0xe3,0x67,0x4,0x2f,0x93,0xe9,0x74,0x3a,0x81,0xbd,0x22,0x78,0x9b,0xc1,0xe6,0xf3,0xd9,0xec,0x1d,0xc1,0x56,0x12,0x2c,0x3e,0x36,0x2d,0xbe,0xe1,0x73,0xd3,0xe,0x76,0xf0,0x1f,0xd0,0xb6,0xdf,0x60,0xdf,0x6,0x3b,0xd,0x30,0x87,0x73,0xf9,0xb3,0x2f,0x9d,0xe,0xc,0x50,0x2e,0xf7,0xa,0xc9,0x72,0xe5,0x76,0x51,0x80,0x60,0x58,0x8f,0x77,0x21,0xe5,0xf5,0xb0,0xc,0xbc,0x75,0x39,0xe3,0x63,0x49,0x1b,0x8c,0x64,0x7d,0x8c,0x5c,0xfa,0xd,0x14,0x38,0x2d,0x85,0x2b,0x8,0xf0,0xb7,0x2f,0x56,0x15,0x7,0x92,0x8b,0x88,0xb4,0x10,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char graph_node_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x40, 0x8, 0x3, 0x0, 0x0, 0x0, 0x24, 0xa3, 0x7, 0xa4, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x4d, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xd, 0x10, 0x17, 0x14, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x12, 0x10, 0x13, 0x0, 0x0, 0x0, 0x19, 0x17, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16, 0x12, 0x19, 0x0, 0x0, 0x0, 0xe, 0xb, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0xb, 0x10, 0x16, 0x12, 0x19, 0x0, 0x0, 0x0, 0x1d, 0x1a, 0x1f, 0x35, 0x2f, 0x38, 0xba, 0xa9, 0xc3, 0xc3, 0xb7, 0xcb, 0xbd, 0xad, 0xc5, 0xb9, 0xa9, 0xc3, 0xb5, 0xa3, 0xbf, 0xb4, 0xa1, 0xbe, 0xb4, 0xa2, 0xbd, 0xb4, 0xa2, 0xbe, 0xb3, 0xa2, 0xbe, 0xb1, 0xa0, 0xbc, 0xb2, 0xa0, 0xbc, 0xb2, 0x9f, 0xbc, 0xb0, 0x9e, 0xba, 0xb0, 0x9d, 0xbb, 0xb1, 0x9e, 0xbb, 0xb0, 0x9e, 0xbb, 0xb1, 0x9e, 0xba, 0xaf, 0x9c, 0xb9, 0xae, 0x9c, 0xb9, 0xae, 0x9c, 0xb8, 0xaf, 0x9d, 0xb9, 0xad, 0x9b, 0xb7, 0xad, 0x9a, 0xb7, 0xad, 0x9a, 0xb8, 0xac, 0x99, 0xb6, 0xab, 0x99, 0xb6, 0xac, 0x98, 0xb6, 0xab, 0x98, 0xb6, 0xab, 0x99, 0xb5, 0xa9, 0x97, 0xb4, 0xa9, 0x97, 0xb5, 0xaa, 0x97, 0xb4, 0xa8, 0x95, 0xb3, 0xa8, 0x95, 0xb2, 0xa7, 0x95, 0xb3, 0xa7, 0x93, 0xb1, 0xa6, 0x93, 0xb1, 0xa5, 0x91, 0xaf, 0xa5, 0x91, 0xb0, 0xa4, 0x91, 0xaf, 0xa5, 0x92, 0xb0, 0xa4, 0x91, 0xb0, 0xa5, 0x92, 0xaf, 0xa3, 0x90, 0xae, 0xa3, 0x90, 0xad, 0xa3, 0x8f, 0xae, 0xa2, 0x90, 0xae, 0xa1, 0x8e, 0xac, 0xa1, 0x8e, 0xad, 0xa2, 0x8e, 0xac, 0x9f, 0x8d, 0xab, 0xa0, 0x8d, 0xab, 0xa0, 0x8c, 0xab, 0xa0, 0x8d, 0xaa, 0x9f, 0x8c, 0xaa, 0x9f, 0x8c, 0xab, 0x9e, 0x8a, 0xaa, 0x9e, 0x8b, 0xa9, 0x9e, 0x8b, 0xaa, 0x9e, 0x8a, 0xa9, 0x9d, 0x8a, 0xa9, 0x9c, 0x88, 0xa7, 0x9c, 0x88, 0xa8, 0x9c, 0x89, 0xa7, 0x9c, 0x89, 0xa8, 0x9a, 0x87, 0xa6, 0x9b, 0x87, 0xa6, 0x9b, 0x86, 0xa6, 0x9b, 0x87, 0xa7, 0x19, 0x15, 0x1c, 0x4a, 0x42, 0x4f, 0x3b, 0x34, 0x3f, 0x39, 0x30, 0x3f, 0x24, 0x1e, 0x27, 0xff, 0xff, 0xff, 0x8f, 0x6b, 0x6d, 0x0, 0x0, 0x0, 0x0, 0x22, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x1, 0x3, 0x6, 0x8, 0x9, 0x2, 0xc, 0x1e, 0x33, 0x41, 0x46, 0xd, 0x31, 0x9a, 0xe3, 0x5, 0x24, 0xb4, 0x39, 0xf4, 0x44, 0xa, 0x47, 0x45, 0x3d, 0xf8, 0x2a, 0xcd, 0x11, 0x3f, 0xd3, 0xfd, 0x2b, 0x85, 0xa8, 0x7, 0x57, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x6e, 0x22, 0xf, 0x51, 0x17, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x1, 0x53, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0xed, 0xd4, 0x69, 0x57, 0x1, 0x51, 0x18, 0xc0, 0xf1, 0x8b, 0x99, 0xb1, 0x8c, 0x65, 0x6c, 0x63, 0x9d, 0xc1, 0x10, 0xd1, 0xc4, 0x44, 0x23, 0x6b, 0xb2, 0x55, 0xa8, 0x24, 0x92, 0xb2, 0x15, 0x45, 0x8a, 0xef, 0xff, 0xb6, 0x6b, 0xba, 0x39, 0x4e, 0xbd, 0xe8, 0xb, 0xf8, 0x9f, 0xe7, 0xdc, 0x73, 0x9e, 0xdf, 0xfb, 0xe7, 0x2, 0x0, 0x64, 0x72, 0x5, 0x86, 0xc3, 0x30, 0x85, 0x5c, 0x6, 0x60, 0x84, 0x52, 0xa5, 0xd6, 0x90, 0x30, 0x8d, 0x5a, 0xa5, 0x24, 0xe0, 0xae, 0xd5, 0xe9, 0xd, 0x9c, 0x94, 0x41, 0xaf, 0xd3, 0x12, 0x80, 0x32, 0x9a, 0xfc, 0x81, 0x3d, 0xa9, 0x80, 0xdf, 0x64, 0xa4, 0x0, 0x66, 0xb6, 0x4, 0x43, 0xfb, 0x52, 0xa1, 0xa0, 0xc5, 0x8c, 0x1, 0xdc, 0xca, 0x85, 0x23, 0x7, 0x61, 0x9e, 0xe7, 0x23, 0x3c, 0xcf, 0x59, 0x71, 0x40, 0xdb, 0xb8, 0xc3, 0x68, 0x34, 0x1a, 0x83, 0x13, 0x8b, 0x71, 0x36, 0x1a, 0xe0, 0x24, 0x27, 0x1c, 0x9, 0x71, 0x21, 0x9e, 0x48, 0x8, 0xc7, 0x8, 0xc4, 0xe4, 0x49, 0x4a, 0x4c, 0x8a, 0x29, 0x51, 0x44, 0x90, 0xce, 0x64, 0xd2, 0xe9, 0x2c, 0x9c, 0x2c, 0x82, 0x5c, 0x3e, 0x97, 0x3b, 0xcd, 0x17, 0xf2, 0x67, 0x5, 0x4, 0x45, 0x58, 0xa9, 0x5c, 0x2a, 0x96, 0xcb, 0x8, 0x2a, 0xd5, 0x6a, 0x65, 0xdd, 0x79, 0x5, 0xc1, 0xc5, 0xe5, 0xba, 0xf5, 0x8b, 0xa0, 0x56, 0x6f, 0xd4, 0xae, 0x1a, 0x8d, 0xfa, 0xf5, 0xd, 0x82, 0xe6, 0x6d, 0xb3, 0xd9, 0x6a, 0xc1, 0xb9, 0x43, 0xd0, 0x6e, 0x77, 0xee, 0xdb, 0xb0, 0x4e, 0x1b, 0x41, 0xf7, 0xa1, 0xf7, 0xf8, 0xd4, 0xef, 0xf6, 0x7b, 0x7d, 0x4, 0x83, 0xe1, 0x68, 0x38, 0x1c, 0xd, 0xc6, 0xe3, 0x67, 0x4, 0x2f, 0x93, 0xe9, 0x74, 0x3a, 0x81, 0xbd, 0x22, 0x78, 0x9b, 0xc1, 0xe6, 0xf3, 0xd9, 0xec, 0x1d, 0xc1, 0x56, 0x12, 0x2c, 0x3e, 0x36, 0x2d, 0xbe, 0xe1, 0x73, 0xd3, 0xe, 0x76, 0xf0, 0x1f, 0xd0, 0xb6, 0xdf, 0x60, 0xdf, 0x6, 0x3b, 0xd, 0x30, 0x87, 0x73, 0xf9, 0xb3, 0x2f, 0x9d, 0xe, 0xc, 0x50, 0x2e, 0xf7, 0xa, 0xc9, 0x72, 0xe5, 0x76, 0x51, 0x80, 0x60, 0x58, 0x8f, 0x77, 0x21, 0xe5, 0xf5, 0xb0, 0xc, 0xbc, 0x75, 0x39, 0xe3, 0x63, 0x49, 0x1b, 0x8c, 0x64, 0x7d, 0x8c, 0x5c, 0xfa, 0xd, 0x14, 0x38, 0x2d, 0x85, 0x2b, 0x8, 0xf0, 0xb7, 0x2f, 0x56, 0x15, 0x7, 0x92, 0x8b, 0x88, 0xb4, 0x10, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char graph_node_close_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x8,0x4,0x0,0x0,0x0,0xfc,0x7c,0x94,0x6c,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x65,0x49,0x44,0x41,0x54,0x18,0xd3,0x75,0x90,0x4b,0xe,0x80,0x20,0xc,0x44,0x47,0x57,0x53,0x64,0x2b,0x91,0x9b,0x71,0x6e,0x49,0x30,0xd1,0xbb,0x80,0xb,0xa2,0xb6,0x26,0x74,0x37,0x9f,0x34,0xaf,0x5,0x20,0xc9,0x7,0xa8,0xf1,0x41,0x12,0x0,0x49,0xac,0xcc,0x5f,0xe4,0x3,0x33,0xab,0x24,0xf8,0x55,0x76,0x36,0x1e,0x2e,0x2,0x78,0xd5,0xb2,0x29,0xe1,0xa2,0xb1,0x55,0xef,0x64,0x31,0x76,0x8f,0x58,0xd8,0xd8,0x78,0x3d,0xf6,0x8c,0xdf,0xb4,0xc9,0xf4,0xf5,0xaa,0x8e,0x61,0x48,0xc,0xa1,0x25,0x51,0xd1,0xf0,0xc0,0xd1,0x4b,0x6e,0xc7,0xae,0x34,0x72,0x3,0xf5,0x60,0xdd,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char graph_node_close_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x4, 0x0, 0x0, 0x0, 0xfc, 0x7c, 0x94, 0x6c, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x65, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x75, 0x90, 0x4b, 0xe, 0x80, 0x20, 0xc, 0x44, 0x47, 0x57, 0x53, 0x64, 0x2b, 0x91, 0x9b, 0x71, 0x6e, 0x49, 0x30, 0xd1, 0xbb, 0x80, 0xb, 0xa2, 0xb6, 0x26, 0x74, 0x37, 0x9f, 0x34, 0xaf, 0x5, 0x20, 0xc9, 0x7, 0xa8, 0xf1, 0x41, 0x12, 0x0, 0x49, 0xac, 0xcc, 0x5f, 0xe4, 0x3, 0x33, 0xab, 0x24, 0xf8, 0x55, 0x76, 0x36, 0x1e, 0x2e, 0x2, 0x78, 0xd5, 0xb2, 0x29, 0xe1, 0xa2, 0xb1, 0x55, 0xef, 0x64, 0x31, 0x76, 0x8f, 0x58, 0xd8, 0xd8, 0x78, 0x3d, 0xf6, 0x8c, 0xdf, 0xb4, 0xc9, 0xf4, 0xf5, 0xaa, 0x8e, 0x61, 0x48, 0xc, 0xa1, 0x25, 0x51, 0xd1, 0xf0, 0xc0, 0xd1, 0x4b, 0x6e, 0xc7, 0xae, 0x34, 0x72, 0x3, 0xf5, 0x60, 0xdd, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char graph_node_default_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x39,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x16,0x12,0x19,0xe,0xb,0x10,0xe,0xb,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x16,0x12,0x19,0x0,0x0,0x0,0x19,0x15,0x1c,0x24,0x1e,0x27,0x16,0x12,0x19,0xff,0xff,0xff,0x2b,0x4d,0xfd,0x66,0x0,0x0,0x0,0xf,0x74,0x52,0x4e,0x53,0x0,0x46,0x47,0x3f,0x2b,0x11,0x3,0xfd,0xd3,0xcd,0x2a,0x73,0x45,0xf8,0x3d,0x3f,0x57,0xda,0x84,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x12,0x7b,0xbc,0x6c,0x0,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x38,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0x64,0x2,0x2,0x46,0x8,0xc9,0xcc,0xc2,0xca,0xc6,0xc0,0x8f,0x4,0xd8,0x39,0x98,0x59,0x19,0x50,0x80,0x0,0x27,0x17,0xaa,0x0,0x83,0x20,0x37,0x9a,0x0,0x3f,0xd3,0xc0,0x8,0xf0,0xa0,0x9,0xf0,0xf2,0x61,0x3a,0x1d,0xc3,0x73,0xe8,0xde,0x7,0x0,0x89,0x4d,0x2,0xf2,0x16,0xd3,0x74,0x45,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char graph_node_default_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x39, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16, 0x12, 0x19, 0xe, 0xb, 0x10, 0xe, 0xb, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16, 0x12, 0x19, 0x0, 0x0, 0x0, 0x19, 0x15, 0x1c, 0x24, 0x1e, 0x27, 0x16, 0x12, 0x19, 0xff, 0xff, 0xff, 0x2b, 0x4d, 0xfd, 0x66, 0x0, 0x0, 0x0, 0xf, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x46, 0x47, 0x3f, 0x2b, 0x11, 0x3, 0xfd, 0xd3, 0xcd, 0x2a, 0x73, 0x45, 0xf8, 0x3d, 0x3f, 0x57, 0xda, 0x84, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x12, 0x7b, 0xbc, 0x6c, 0x0, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x38, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0x64, 0x2, 0x2, 0x46, 0x8, 0xc9, 0xcc, 0xc2, 0xca, 0xc6, 0xc0, 0x8f, 0x4, 0xd8, 0x39, 0x98, 0x59, 0x19, 0x50, 0x80, 0x0, 0x27, 0x17, 0xaa, 0x0, 0x83, 0x20, 0x37, 0x9a, 0x0, 0x3f, 0xd3, 0xc0, 0x8, 0xf0, 0xa0, 0x9, 0xf0, 0xf2, 0x61, 0x3a, 0x1d, 0xc3, 0x73, 0xe8, 0xde, 0x7, 0x0, 0x89, 0x4d, 0x2, 0xf2, 0x16, 0xd3, 0x74, 0x45, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char graph_node_default_focus_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xb7,0x49,0x44,0x41,0x54,0x28,0xcf,0x9d,0x91,0x3d,0x6a,0x42,0x61,0x10,0x45,0xcf,0x8c,0x4f,0x22,0x7c,0x58,0x84,0x14,0x2e,0xc0,0xf5,0x64,0x17,0xba,0x3,0x2d,0x4,0x41,0x17,0x96,0x2a,0x65,0x5c,0x43,0x7a,0xb,0x53,0xfa,0xc3,0x63,0x9c,0x6b,0xf1,0x4,0xf9,0x24,0x31,0x21,0xb7,0x1b,0xe6,0x14,0x33,0xe7,0x1a,0x80,0xc,0xc7,0x1,0xa7,0x4b,0x2,0x49,0x9a,0xc0,0x34,0xc2,0xbb,0x11,0xae,0x58,0x92,0x4,0x2d,0x2d,0x61,0xb2,0x99,0xf8,0x26,0xfd,0xaf,0xe1,0xdb,0x62,0xca,0x89,0x40,0x88,0x35,0x13,0xb6,0x15,0xb0,0x7d,0x99,0x68,0xfd,0xae,0xa2,0x1e,0x42,0xcc,0x9,0x4a,0x5,0x94,0x71,0xd8,0xfc,0xa8,0x67,0xf5,0x1d,0x40,0x34,0xec,0x2b,0x60,0xff,0xd9,0x48,0x3,0x1a,0xdc,0x79,0x14,0xbf,0x3d,0xf6,0x4f,0x80,0xdf,0x80,0xfc,0x2b,0x60,0x77,0x16,0x3a,0x13,0x76,0x24,0x48,0x7,0x28,0x2c,0x89,0x6a,0x1d,0xc3,0xe5,0xae,0x7c,0xd0,0x92,0x3f,0xa8,0xb6,0x53,0xd9,0xac,0x5e,0x39,0x10,0x8f,0xcb,0x4a,0x3b,0x5b,0x67,0x12,0x80,0xa7,0xea,0xbc,0x6b,0xdd,0x17,0xbe,0x3f,0x4f,0x23,0x27,0x82,0x63,0x73,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char graph_node_default_focus_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xb7, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x9d, 0x91, 0x3d, 0x6a, 0x42, 0x61, 0x10, 0x45, 0xcf, 0x8c, 0x4f, 0x22, 0x7c, 0x58, 0x84, 0x14, 0x2e, 0xc0, 0xf5, 0x64, 0x17, 0xba, 0x3, 0x2d, 0x4, 0x41, 0x17, 0x96, 0x2a, 0x65, 0x5c, 0x43, 0x7a, 0xb, 0x53, 0xfa, 0xc3, 0x63, 0x9c, 0x6b, 0xf1, 0x4, 0xf9, 0x24, 0x31, 0x21, 0xb7, 0x1b, 0xe6, 0x14, 0x33, 0xe7, 0x1a, 0x80, 0xc, 0xc7, 0x1, 0xa7, 0x4b, 0x2, 0x49, 0x9a, 0xc0, 0x34, 0xc2, 0xbb, 0x11, 0xae, 0x58, 0x92, 0x4, 0x2d, 0x2d, 0x61, 0xb2, 0x99, 0xf8, 0x26, 0xfd, 0xaf, 0xe1, 0xdb, 0x62, 0xca, 0x89, 0x40, 0x88, 0x35, 0x13, 0xb6, 0x15, 0xb0, 0x7d, 0x99, 0x68, 0xfd, 0xae, 0xa2, 0x1e, 0x42, 0xcc, 0x9, 0x4a, 0x5, 0x94, 0x71, 0xd8, 0xfc, 0xa8, 0x67, 0xf5, 0x1d, 0x40, 0x34, 0xec, 0x2b, 0x60, 0xff, 0xd9, 0x48, 0x3, 0x1a, 0xdc, 0x79, 0x14, 0xbf, 0x3d, 0xf6, 0x4f, 0x80, 0xdf, 0x80, 0xfc, 0x2b, 0x60, 0x77, 0x16, 0x3a, 0x13, 0x76, 0x24, 0x48, 0x7, 0x28, 0x2c, 0x89, 0x6a, 0x1d, 0xc3, 0xe5, 0xae, 0x7c, 0xd0, 0x92, 0x3f, 0xa8, 0xb6, 0x53, 0xd9, 0xac, 0x5e, 0x39, 0x10, 0x8f, 0xcb, 0x4a, 0x3b, 0x5b, 0x67, 0x12, 0x80, 0xa7, 0xea, 0xbc, 0x6b, 0xdd, 0x17, 0xbe, 0x3f, 0x4f, 0x23, 0x27, 0x82, 0x63, 0x73, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char graph_node_selected_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x40,0x8,0x3,0x0,0x0,0x0,0x24,0xa3,0x7,0xa4,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xd8,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf,0xd,0x10,0x17,0x14,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0x12,0x10,0x13,0x0,0x0,0x0,0x19,0x17,0x1b,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x16,0x12,0x19,0x0,0x0,0x0,0xe,0xb,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0xb,0x10,0x16,0x12,0x19,0x0,0x0,0x0,0x1d,0x1a,0x1f,0x35,0x2f,0x38,0x94,0xd6,0x84,0xa4,0xdc,0x95,0x99,0xd8,0x8a,0x8c,0xd3,0x7b,0x8b,0xd2,0x79,0x88,0xd1,0x76,0x87,0xd1,0x74,0x86,0xd0,0x73,0x85,0xd0,0x71,0x83,0xcf,0x70,0x82,0xcf,0x6f,0x81,0xce,0x6d,0x7f,0xce,0x6c,0x7b,0xcc,0x67,0x7d,0xcd,0x68,0x7a,0xcc,0x65,0x79,0xcb,0x64,0x76,0xca,0x61,0x75,0xca,0x60,0x78,0xcb,0x62,0x74,0xc9,0x5e,0x72,0xc9,0x5c,0x70,0xc8,0x59,0x71,0xc8,0x5b,0x6d,0xc7,0x57,0x6f,0xc7,0x58,0x6c,0xc6,0x55,0x68,0xc4,0x51,0x67,0xc4,0x4f,0x69,0xc5,0x52,0x19,0x15,0x1c,0x4a,0x42,0x4f,0x3b,0x34,0x3f,0x39,0x30,0x3f,0x24,0x1e,0x27,0xff,0xff,0xff,0x23,0xbb,0x3,0x70,0x0,0x0,0x0,0x22,0x74,0x52,0x4e,0x53,0x0,0x1,0x3,0x6,0x8,0x9,0x2,0xc,0x1e,0x33,0x41,0x46,0xd,0x31,0x9a,0xe3,0x5,0x24,0xb4,0x39,0xf4,0x44,0xa,0x47,0x45,0x3d,0xf8,0x2a,0xcd,0x11,0x3f,0xd3,0xfd,0x2b,0x85,0xa8,0x7,0x57,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x47,0x60,0xbd,0xc9,0x7b,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x1,0x7,0x49,0x44,0x41,0x54,0x38,0xcb,0xed,0xd4,0xd9,0x5a,0x82,0x40,0x14,0xc0,0xf1,0x23,0x9b,0xb,0x2e,0xb8,0x81,0x1b,0xa8,0x23,0x59,0xb1,0xa4,0x51,0x60,0x81,0x85,0x52,0xf8,0xfe,0x8f,0xd4,0x71,0x3a,0xcd,0xe7,0x57,0x17,0xbd,0x80,0xbf,0x99,0x73,0x71,0xfe,0xf7,0x33,0x0,0x50,0x91,0x64,0x45,0x45,0x8a,0x2c,0x55,0x0,0x69,0xd5,0x5a,0xbd,0xa1,0xa3,0x46,0xbd,0x56,0xd5,0x70,0x6f,0xb6,0xda,0x1d,0xc6,0x75,0xda,0xad,0xa6,0x6,0x46,0xb7,0xb7,0x72,0x6f,0x38,0x77,0xd5,0xeb,0x1a,0xa0,0xf4,0x7,0x6b,0xf7,0x96,0x73,0xd7,0x83,0xbe,0x2,0xea,0x90,0xdd,0x9,0x6c,0xa8,0x82,0x69,0xb1,0x7b,0xe4,0xe1,0xf5,0x3c,0x66,0x99,0xa0,0xea,0xcc,0xf3,0x3d,0x42,0x21,0x8,0x43,0x3f,0x8,0x3,0x3f,0x8,0x28,0x3c,0x8,0x14,0x36,0x68,0x8b,0x67,0xb3,0xa5,0xf0,0x88,0xa2,0x28,0xc2,0xa1,0xf0,0x24,0x50,0x78,0x16,0x28,0xc4,0x71,0x12,0xef,0x92,0x24,0x4e,0x76,0x14,0x5e,0x4,0xa,0xaf,0x2,0x85,0x34,0xcb,0xb2,0x14,0x65,0x29,0x85,0xfd,0xdb,0xd9,0x1e,0x51,0x78,0x17,0x28,0xe4,0x67,0x87,0x43,0x9e,0x1f,0x29,0x5c,0xe0,0xa1,0xf8,0x10,0x8a,0xef,0xf0,0x29,0x5c,0xc3,0x35,0xfc,0x17,0x4c,0xeb,0x77,0x18,0x5d,0x86,0x91,0x9,0xca,0x78,0x52,0xfe,0xec,0xe5,0x64,0xac,0x80,0x31,0x9d,0x9d,0xa8,0x94,0xa7,0xd9,0xd4,0x0,0xcd,0x76,0xe6,0x8b,0x82,0x5b,0xcc,0x1d,0x1b,0xdf,0xba,0x64,0x2f,0x1d,0xdd,0x42,0xba,0xb3,0xb4,0x25,0xfe,0x1b,0xc8,0xaa,0xc9,0xa9,0xb2,0x6,0x7f,0x7d,0x1,0x5d,0xdd,0xb5,0x61,0x26,0xcd,0x71,0x81,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char graph_node_selected_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x40, 0x8, 0x3, 0x0, 0x0, 0x0, 0x24, 0xa3, 0x7, 0xa4, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xd8, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xd, 0x10, 0x17, 0x14, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x12, 0x10, 0x13, 0x0, 0x0, 0x0, 0x19, 0x17, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16, 0x12, 0x19, 0x0, 0x0, 0x0, 0xe, 0xb, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0xb, 0x10, 0x16, 0x12, 0x19, 0x0, 0x0, 0x0, 0x1d, 0x1a, 0x1f, 0x35, 0x2f, 0x38, 0x94, 0xd6, 0x84, 0xa4, 0xdc, 0x95, 0x99, 0xd8, 0x8a, 0x8c, 0xd3, 0x7b, 0x8b, 0xd2, 0x79, 0x88, 0xd1, 0x76, 0x87, 0xd1, 0x74, 0x86, 0xd0, 0x73, 0x85, 0xd0, 0x71, 0x83, 0xcf, 0x70, 0x82, 0xcf, 0x6f, 0x81, 0xce, 0x6d, 0x7f, 0xce, 0x6c, 0x7b, 0xcc, 0x67, 0x7d, 0xcd, 0x68, 0x7a, 0xcc, 0x65, 0x79, 0xcb, 0x64, 0x76, 0xca, 0x61, 0x75, 0xca, 0x60, 0x78, 0xcb, 0x62, 0x74, 0xc9, 0x5e, 0x72, 0xc9, 0x5c, 0x70, 0xc8, 0x59, 0x71, 0xc8, 0x5b, 0x6d, 0xc7, 0x57, 0x6f, 0xc7, 0x58, 0x6c, 0xc6, 0x55, 0x68, 0xc4, 0x51, 0x67, 0xc4, 0x4f, 0x69, 0xc5, 0x52, 0x19, 0x15, 0x1c, 0x4a, 0x42, 0x4f, 0x3b, 0x34, 0x3f, 0x39, 0x30, 0x3f, 0x24, 0x1e, 0x27, 0xff, 0xff, 0xff, 0x23, 0xbb, 0x3, 0x70, 0x0, 0x0, 0x0, 0x22, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x1, 0x3, 0x6, 0x8, 0x9, 0x2, 0xc, 0x1e, 0x33, 0x41, 0x46, 0xd, 0x31, 0x9a, 0xe3, 0x5, 0x24, 0xb4, 0x39, 0xf4, 0x44, 0xa, 0x47, 0x45, 0x3d, 0xf8, 0x2a, 0xcd, 0x11, 0x3f, 0xd3, 0xfd, 0x2b, 0x85, 0xa8, 0x7, 0x57, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x47, 0x60, 0xbd, 0xc9, 0x7b, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x1, 0x7, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0xed, 0xd4, 0xd9, 0x5a, 0x82, 0x40, 0x14, 0xc0, 0xf1, 0x23, 0x9b, 0xb, 0x2e, 0xb8, 0x81, 0x1b, 0xa8, 0x23, 0x59, 0xb1, 0xa4, 0x51, 0x60, 0x81, 0x85, 0x52, 0xf8, 0xfe, 0x8f, 0xd4, 0x71, 0x3a, 0xcd, 0xe7, 0x57, 0x17, 0xbd, 0x80, 0xbf, 0x99, 0x73, 0x71, 0xfe, 0xf7, 0x33, 0x0, 0x50, 0x91, 0x64, 0x45, 0x45, 0x8a, 0x2c, 0x55, 0x0, 0x69, 0xd5, 0x5a, 0xbd, 0xa1, 0xa3, 0x46, 0xbd, 0x56, 0xd5, 0x70, 0x6f, 0xb6, 0xda, 0x1d, 0xc6, 0x75, 0xda, 0xad, 0xa6, 0x6, 0x46, 0xb7, 0xb7, 0x72, 0x6f, 0x38, 0x77, 0xd5, 0xeb, 0x1a, 0xa0, 0xf4, 0x7, 0x6b, 0xf7, 0x96, 0x73, 0xd7, 0x83, 0xbe, 0x2, 0xea, 0x90, 0xdd, 0x9, 0x6c, 0xa8, 0x82, 0x69, 0xb1, 0x7b, 0xe4, 0xe1, 0xf5, 0x3c, 0x66, 0x99, 0xa0, 0xea, 0xcc, 0xf3, 0x3d, 0x42, 0x21, 0x8, 0x43, 0x3f, 0x8, 0x3, 0x3f, 0x8, 0x28, 0x3c, 0x8, 0x14, 0x36, 0x68, 0x8b, 0x67, 0xb3, 0xa5, 0xf0, 0x88, 0xa2, 0x28, 0xc2, 0xa1, 0xf0, 0x24, 0x50, 0x78, 0x16, 0x28, 0xc4, 0x71, 0x12, 0xef, 0x92, 0x24, 0x4e, 0x76, 0x14, 0x5e, 0x4, 0xa, 0xaf, 0x2, 0x85, 0x34, 0xcb, 0xb2, 0x14, 0x65, 0x29, 0x85, 0xfd, 0xdb, 0xd9, 0x1e, 0x51, 0x78, 0x17, 0x28, 0xe4, 0x67, 0x87, 0x43, 0x9e, 0x1f, 0x29, 0x5c, 0xe0, 0xa1, 0xf8, 0x10, 0x8a, 0xef, 0xf0, 0x29, 0x5c, 0xc3, 0x35, 0xfc, 0x17, 0x4c, 0xeb, 0x77, 0x18, 0x5d, 0x86, 0x91, 0x9, 0xca, 0x78, 0x52, 0xfe, 0xec, 0xe5, 0x64, 0xac, 0x80, 0x31, 0x9d, 0x9d, 0xa8, 0x94, 0xa7, 0xd9, 0xd4, 0x0, 0xcd, 0x76, 0xe6, 0x8b, 0x82, 0x5b, 0xcc, 0x1d, 0x1b, 0xdf, 0xba, 0x64, 0x2f, 0x1d, 0xdd, 0x42, 0xba, 0xb3, 0xb4, 0x25, 0xfe, 0x1b, 0xc8, 0xaa, 0xc9, 0xa9, 0xb2, 0x6, 0x7f, 0x7d, 0x1, 0x5d, 0xdd, 0xb5, 0x61, 0x26, 0xcd, 0x71, 0x81, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char graph_port_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xa,0x0,0x0,0x0,0xa,0x8,0x3,0x0,0x0,0x0,0xba,0xec,0x3f,0x8f,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xc0,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xff,0xff,0x6a,0x6a,0x6a,0x52,0x52,0x52,0x61,0x61,0x61,0x48,0x48,0x48,0x94,0x94,0x93,0xca,0xca,0xca,0x94,0x94,0x94,0x92,0x92,0x92,0xbf,0xbf,0xbe,0xbe,0xbf,0xbe,0x92,0x91,0x91,0x50,0x50,0x50,0xc2,0xc1,0xc2,0xc1,0xc1,0xc1,0xc1,0xc1,0xc0,0xc1,0xc2,0xc2,0x50,0x50,0x4f,0x5c,0x5c,0x5c,0x5b,0x5b,0x5b,0x5b,0x5a,0x5a,0x4f,0x4f,0x4f,0xb5,0xb5,0xb5,0xd7,0xd7,0xd7,0x4f,0x4f,0x4e,0x88,0x88,0x88,0xda,0xdb,0xdb,0xda,0xda,0xda,0x45,0x45,0x45,0x86,0x86,0x86,0xac,0xac,0xac,0x4c,0x4d,0x4c,0x55,0x55,0x55,0x56,0x55,0x55,0x4d,0x4e,0x4c,0xda,0xda,0xda,0xd9,0xda,0xda,0xcf,0xd0,0xd0,0xb6,0xb6,0xb6,0xd0,0xd0,0xd0,0xc4,0xc4,0xc4,0xc8,0xc8,0xc8,0xca,0xcb,0xcb,0xc7,0xc7,0xc7,0xcf,0xcf,0xd0,0xd2,0xd2,0xd2,0xd0,0xcf,0xcf,0xca,0xcb,0xca,0xc6,0xc6,0xc5,0xd5,0xd6,0xd5,0xd8,0xd8,0xd8,0xd7,0xd8,0xd8,0xd6,0xd6,0xd6,0xc6,0xc6,0xc6,0xde,0xde,0xde,0xdf,0xdf,0xde,0xdf,0xde,0xdf,0xbc,0xbc,0xbc,0xe8,0xe8,0xe9,0xe8,0xe8,0xe8,0xb7,0xb7,0xb7,0xb6,0xb7,0xb6,0x0,0x0,0x0,0xf5,0xba,0x5d,0x7a,0x0,0x0,0x0,0x24,0x74,0x52,0x4e,0x53,0x0,0x1,0x8,0x5e,0x8c,0x15,0xe2,0xfe,0xe2,0xe2,0xfe,0xfe,0xe2,0x5e,0xfe,0xfe,0xfe,0xfe,0x5e,0x8c,0x8c,0x8c,0x5d,0xfd,0xfe,0x5d,0xe2,0xfe,0xfe,0x16,0xe2,0xfd,0x5d,0x8c,0x8c,0x5d,0xce,0x80,0x8b,0x8f,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x0,0x88,0x5,0x1d,0x48,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x70,0x49,0x44,0x41,0x54,0x8,0xd7,0x15,0xcd,0xb,0x2,0x81,0x50,0x14,0x5,0xc0,0x73,0x6f,0x25,0x84,0x90,0x94,0xa8,0xa4,0x48,0x1f,0xa9,0x1e,0xa2,0x62,0xff,0xcb,0xc2,0x6,0x66,0x0,0x62,0x49,0x96,0x25,0x26,0x80,0x94,0x81,0x1a,0x1d,0xd5,0xa1,0x42,0xe0,0xd1,0x69,0x1c,0xc7,0xda,0x79,0xc2,0x98,0xce,0xf4,0x24,0x4d,0x93,0xf9,0x62,0x9,0x23,0xcb,0x2f,0x45,0x71,0xcd,0x4b,0x3,0xab,0xaa,0x16,0x42,0xdc,0xee,0xf,0x13,0x6b,0xcb,0x6e,0x9e,0xaf,0xc6,0xb6,0x36,0x60,0xa7,0xdd,0x76,0xfd,0xae,0x75,0x18,0xe4,0x7a,0xfe,0xfb,0xe3,0x7b,0xee,0x1f,0xe6,0x7d,0x70,0x8,0x7f,0xc5,0x17,0xe3,0x97,0xa,0x2b,0xff,0x1e,0x73,0x38,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char graph_port_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0xa, 0x8, 0x3, 0x0, 0x0, 0x0, 0xba, 0xec, 0x3f, 0x8f, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xc0, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x6a, 0x6a, 0x6a, 0x52, 0x52, 0x52, 0x61, 0x61, 0x61, 0x48, 0x48, 0x48, 0x94, 0x94, 0x93, 0xca, 0xca, 0xca, 0x94, 0x94, 0x94, 0x92, 0x92, 0x92, 0xbf, 0xbf, 0xbe, 0xbe, 0xbf, 0xbe, 0x92, 0x91, 0x91, 0x50, 0x50, 0x50, 0xc2, 0xc1, 0xc2, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 0xc2, 0xc2, 0x50, 0x50, 0x4f, 0x5c, 0x5c, 0x5c, 0x5b, 0x5b, 0x5b, 0x5b, 0x5a, 0x5a, 0x4f, 0x4f, 0x4f, 0xb5, 0xb5, 0xb5, 0xd7, 0xd7, 0xd7, 0x4f, 0x4f, 0x4e, 0x88, 0x88, 0x88, 0xda, 0xdb, 0xdb, 0xda, 0xda, 0xda, 0x45, 0x45, 0x45, 0x86, 0x86, 0x86, 0xac, 0xac, 0xac, 0x4c, 0x4d, 0x4c, 0x55, 0x55, 0x55, 0x56, 0x55, 0x55, 0x4d, 0x4e, 0x4c, 0xda, 0xda, 0xda, 0xd9, 0xda, 0xda, 0xcf, 0xd0, 0xd0, 0xb6, 0xb6, 0xb6, 0xd0, 0xd0, 0xd0, 0xc4, 0xc4, 0xc4, 0xc8, 0xc8, 0xc8, 0xca, 0xcb, 0xcb, 0xc7, 0xc7, 0xc7, 0xcf, 0xcf, 0xd0, 0xd2, 0xd2, 0xd2, 0xd0, 0xcf, 0xcf, 0xca, 0xcb, 0xca, 0xc6, 0xc6, 0xc5, 0xd5, 0xd6, 0xd5, 0xd8, 0xd8, 0xd8, 0xd7, 0xd8, 0xd8, 0xd6, 0xd6, 0xd6, 0xc6, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdf, 0xdf, 0xde, 0xdf, 0xde, 0xdf, 0xbc, 0xbc, 0xbc, 0xe8, 0xe8, 0xe9, 0xe8, 0xe8, 0xe8, 0xb7, 0xb7, 0xb7, 0xb6, 0xb7, 0xb6, 0x0, 0x0, 0x0, 0xf5, 0xba, 0x5d, 0x7a, 0x0, 0x0, 0x0, 0x24, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x1, 0x8, 0x5e, 0x8c, 0x15, 0xe2, 0xfe, 0xe2, 0xe2, 0xfe, 0xfe, 0xe2, 0x5e, 0xfe, 0xfe, 0xfe, 0xfe, 0x5e, 0x8c, 0x8c, 0x8c, 0x5d, 0xfd, 0xfe, 0x5d, 0xe2, 0xfe, 0xfe, 0x16, 0xe2, 0xfd, 0x5d, 0x8c, 0x8c, 0x5d, 0xce, 0x80, 0x8b, 0x8f, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x88, 0x5, 0x1d, 0x48, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x70, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x15, 0xcd, 0xb, 0x2, 0x81, 0x50, 0x14, 0x5, 0xc0, 0x73, 0x6f, 0x25, 0x84, 0x90, 0x94, 0xa8, 0xa4, 0x48, 0x1f, 0xa9, 0x1e, 0xa2, 0x62, 0xff, 0xcb, 0xc2, 0x6, 0x66, 0x0, 0x62, 0x49, 0x96, 0x25, 0x26, 0x80, 0x94, 0x81, 0x1a, 0x1d, 0xd5, 0xa1, 0x42, 0xe0, 0xd1, 0x69, 0x1c, 0xc7, 0xda, 0x79, 0xc2, 0x98, 0xce, 0xf4, 0x24, 0x4d, 0x93, 0xf9, 0x62, 0x9, 0x23, 0xcb, 0x2f, 0x45, 0x71, 0xcd, 0x4b, 0x3, 0xab, 0xaa, 0x16, 0x42, 0xdc, 0xee, 0xf, 0x13, 0x6b, 0xcb, 0x6e, 0x9e, 0xaf, 0xc6, 0xb6, 0x36, 0x60, 0xa7, 0xdd, 0x76, 0xfd, 0xae, 0x75, 0x18, 0xe4, 0x7a, 0xfe, 0xfb, 0xe3, 0x7b, 0xee, 0x1f, 0xe6, 0x7d, 0x70, 0x8, 0x7f, 0xc5, 0x17, 0xe3, 0x97, 0xa, 0x2b, 0xff, 0x1e, 0x73, 0x38, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char hseparator_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x2,0x3,0x0,0x0,0x0,0xb9,0x61,0x56,0x18,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xc,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x73,0x9b,0xaa,0xce,0xdc,0xe1,0xff,0xff,0xff,0x64,0x6c,0x1,0xd2,0x0,0x0,0x0,0x3,0x74,0x52,0x4e,0x53,0x0,0xb3,0xb3,0x67,0xf6,0xdb,0x93,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x3,0x11,0xc,0x4c,0xf2,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x10,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x64,0x60,0x60,0xc2,0x40,0x8c,0xc,0x0,0x0,0xc7,0x0,0xf,0xf5,0x92,0x2f,0xa7,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char hseparator_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x2, 0x3, 0x0, 0x0, 0x0, 0xb9, 0x61, 0x56, 0x18, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xc, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x73, 0x9b, 0xaa, 0xce, 0xdc, 0xe1, 0xff, 0xff, 0xff, 0x64, 0x6c, 0x1, 0xd2, 0x0, 0x0, 0x0, 0x3, 0x74, 0x52, 0x4e, 0x53, 0x0, 0xb3, 0xb3, 0x67, 0xf6, 0xdb, 0x93, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x3, 0x11, 0xc, 0x4c, 0xf2, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x10, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x64, 0x60, 0x60, 0xc2, 0x40, 0x8c, 0xc, 0x0, 0x0, 0xc7, 0x0, 0xf, 0xf5, 0x92, 0x2f, 0xa7, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char hslider_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x4e,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x40,0x3e,0x4a,0x2a,0x29,0x2f,0x20,0x20,0x24,0x3f,0x3e,0x49,0x1f,0x1f,0x24,0x20,0x20,0x24,0x4d,0x4b,0x59,0x3f,0x3e,0x49,0x3f,0x3e,0x49,0x1e,0x1e,0x23,0x1f,0x1f,0x23,0x20,0x20,0x25,0x22,0x22,0x27,0x23,0x23,0x27,0x23,0x23,0x28,0x25,0x25,0x2a,0xff,0xff,0xff,0x5f,0xd6,0x94,0x4d,0x0,0x0,0x0,0x12,0x74,0x52,0x4e,0x53,0x0,0x0,0x4,0x19,0x40,0x5d,0x66,0x68,0x28,0x93,0xf0,0xfc,0x94,0xfc,0xfd,0x1a,0x96,0x95,0x6b,0xe2,0xd5,0x49,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x19,0xec,0x6e,0xb5,0x88,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x65,0x49,0x44,0x41,0x54,0x18,0xd3,0x85,0xce,0xdd,0xe,0x80,0x20,0x8,0x5,0x60,0x54,0xb4,0x22,0xb5,0x34,0x7f,0x7a,0xff,0x27,0x8d,0xad,0xd6,0x6a,0x5c,0xf8,0xdd,0xc1,0x6,0xe7,0x0,0x8c,0xa9,0x1f,0x9e,0xb5,0x41,0xeb,0x26,0xe6,0x2c,0x1a,0xad,0x40,0xcf,0xb,0xad,0xf9,0x60,0x79,0xa5,0x65,0xd6,0x60,0x7c,0x28,0xb5,0x75,0xd6,0x6a,0x9,0xde,0x0,0x52,0xe9,0xe7,0xa3,0x17,0x42,0xb0,0xb1,0x9e,0xaf,0x1a,0xad,0x5c,0x88,0x93,0x6d,0xff,0x3e,0xdd,0x37,0x8e,0x4d,0x14,0xef,0xd8,0x48,0x89,0x63,0x45,0x31,0x51,0x7d,0xe8,0x2,0xf5,0xf,0x9,0x67,0xd9,0x88,0x8f,0x5b,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char hslider_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x4e, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x40, 0x3e, 0x4a, 0x2a, 0x29, 0x2f, 0x20, 0x20, 0x24, 0x3f, 0x3e, 0x49, 0x1f, 0x1f, 0x24, 0x20, 0x20, 0x24, 0x4d, 0x4b, 0x59, 0x3f, 0x3e, 0x49, 0x3f, 0x3e, 0x49, 0x1e, 0x1e, 0x23, 0x1f, 0x1f, 0x23, 0x20, 0x20, 0x25, 0x22, 0x22, 0x27, 0x23, 0x23, 0x27, 0x23, 0x23, 0x28, 0x25, 0x25, 0x2a, 0xff, 0xff, 0xff, 0x5f, 0xd6, 0x94, 0x4d, 0x0, 0x0, 0x0, 0x12, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x4, 0x19, 0x40, 0x5d, 0x66, 0x68, 0x28, 0x93, 0xf0, 0xfc, 0x94, 0xfc, 0xfd, 0x1a, 0x96, 0x95, 0x6b, 0xe2, 0xd5, 0x49, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x19, 0xec, 0x6e, 0xb5, 0x88, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x65, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x85, 0xce, 0xdd, 0xe, 0x80, 0x20, 0x8, 0x5, 0x60, 0x54, 0xb4, 0x22, 0xb5, 0x34, 0x7f, 0x7a, 0xff, 0x27, 0x8d, 0xad, 0xd6, 0x6a, 0x5c, 0xf8, 0xdd, 0xc1, 0x6, 0xe7, 0x0, 0x8c, 0xa9, 0x1f, 0x9e, 0xb5, 0x41, 0xeb, 0x26, 0xe6, 0x2c, 0x1a, 0xad, 0x40, 0xcf, 0xb, 0xad, 0xf9, 0x60, 0x79, 0xa5, 0x65, 0xd6, 0x60, 0x7c, 0x28, 0xb5, 0x75, 0xd6, 0x6a, 0x9, 0xde, 0x0, 0x52, 0xe9, 0xe7, 0xa3, 0x17, 0x42, 0xb0, 0xb1, 0x9e, 0xaf, 0x1a, 0xad, 0x5c, 0x88, 0x93, 0x6d, 0xff, 0x3e, 0xdd, 0x37, 0x8e, 0x4d, 0x14, 0xef, 0xd8, 0x48, 0x89, 0x63, 0x45, 0x31, 0x51, 0x7d, 0xe8, 0x2, 0xf5, 0xf, 0x9, 0x67, 0xd9, 0x88, 0x8f, 0x5b, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char hslider_grabber_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x1,0x1d,0x49,0x44,0x41,0x54,0x28,0xcf,0x85,0xd1,0x3f,0x4b,0xc3,0x40,0x18,0xc7,0xf1,0xef,0x25,0xad,0x89,0xa9,0x70,0x83,0x43,0x5d,0xc4,0x21,0x6e,0x4a,0x7,0x47,0xdf,0x83,0x53,0x16,0x17,0xd7,0x4e,0xbe,0x2,0x5f,0x85,0x83,0xa0,0xb8,0x38,0xb8,0x88,0xd0,0x51,0x5d,0x1c,0x1c,0x1c,0x1c,0x2a,0xa2,0xe8,0x22,0x2d,0x82,0x2d,0x88,0x54,0xed,0x3f,0x1b,0x9a,0x78,0x49,0x1c,0x9a,0x54,0x4f,0x5,0x6f,0x3a,0xee,0xf9,0xf0,0x3c,0x3f,0x9e,0x83,0x7f,0x8e,0x18,0xdf,0x4c,0x1c,0x24,0x5,0x60,0x40,0x17,0x9f,0x48,0x7,0x26,0xd3,0xe5,0x55,0xd7,0x93,0x25,0xe8,0xde,0xd4,0x2b,0xbb,0x7,0xbc,0x8e,0x88,0x99,0x82,0xa9,0xf2,0xda,0xe2,0x86,0x58,0x78,0xb7,0x87,0xf6,0xc4,0xdc,0xcc,0xd2,0x6c,0xfb,0xf2,0x8e,0x10,0xc0,0x48,0x81,0x74,0x3d,0x55,0xf4,0x51,0x28,0x7c,0x54,0xd1,0xf5,0x90,0xa3,0x42,0x6,0xa,0xb2,0x14,0x90,0x0,0x90,0x10,0x20,0x4b,0x14,0x74,0x20,0x62,0xf1,0x3d,0x7b,0x24,0xb2,0x74,0x19,0x8,0x83,0x96,0x39,0x2e,0xb,0x82,0x37,0x94,0xe,0x6,0xbd,0xdb,0xfc,0x18,0xe4,0x49,0x9e,0xf0,0x75,0xd0,0xbf,0x3e,0xb6,0x22,0x23,0x7d,0x9a,0x4c,0xce,0xf6,0xe8,0xe9,0x20,0xb8,0xaa,0x6,0xcd,0x1c,0x0,0x39,0x3e,0x1e,0x4f,0xce,0x7f,0x76,0x88,0x1f,0x1a,0xcf,0xa7,0xe,0x6,0x6,0xe,0x8d,0x23,0xd5,0x22,0xd6,0x41,0x42,0x77,0x6b,0x33,0xaa,0x59,0x58,0xc4,0xf5,0x9d,0xed,0x6c,0xc0,0xd7,0x26,0x21,0xe,0x7,0x9d,0xda,0xf2,0x8a,0x1d,0x1f,0xae,0xdf,0x57,0x19,0xfe,0x6,0xa0,0x9a,0x2f,0xf3,0xed,0xfe,0xc5,0x7e,0x85,0xce,0x5f,0xbf,0x39,0xca,0x67,0x21,0x18,0x66,0x3b,0x0,0xf8,0x4,0x7e,0x5c,0x62,0x33,0x51,0xf0,0xbb,0xff,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char hslider_grabber_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x1, 0x1d, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x85, 0xd1, 0x3f, 0x4b, 0xc3, 0x40, 0x18, 0xc7, 0xf1, 0xef, 0x25, 0xad, 0x89, 0xa9, 0x70, 0x83, 0x43, 0x5d, 0xc4, 0x21, 0x6e, 0x4a, 0x7, 0x47, 0xdf, 0x83, 0x53, 0x16, 0x17, 0xd7, 0x4e, 0xbe, 0x2, 0x5f, 0x85, 0x83, 0xa0, 0xb8, 0x38, 0xb8, 0x88, 0xd0, 0x51, 0x5d, 0x1c, 0x1c, 0x1c, 0x1c, 0x2a, 0xa2, 0xe8, 0x22, 0x2d, 0x82, 0x2d, 0x88, 0x54, 0xed, 0x3f, 0x1b, 0x9a, 0x78, 0x49, 0x1c, 0x9a, 0x54, 0x4f, 0x5, 0x6f, 0x3a, 0xee, 0xf9, 0xf0, 0x3c, 0x3f, 0x9e, 0x83, 0x7f, 0x8e, 0x18, 0xdf, 0x4c, 0x1c, 0x24, 0x5, 0x60, 0x40, 0x17, 0x9f, 0x48, 0x7, 0x26, 0xd3, 0xe5, 0x55, 0xd7, 0x93, 0x25, 0xe8, 0xde, 0xd4, 0x2b, 0xbb, 0x7, 0xbc, 0x8e, 0x88, 0x99, 0x82, 0xa9, 0xf2, 0xda, 0xe2, 0x86, 0x58, 0x78, 0xb7, 0x87, 0xf6, 0xc4, 0xdc, 0xcc, 0xd2, 0x6c, 0xfb, 0xf2, 0x8e, 0x10, 0xc0, 0x48, 0x81, 0x74, 0x3d, 0x55, 0xf4, 0x51, 0x28, 0x7c, 0x54, 0xd1, 0xf5, 0x90, 0xa3, 0x42, 0x6, 0xa, 0xb2, 0x14, 0x90, 0x0, 0x90, 0x10, 0x20, 0x4b, 0x14, 0x74, 0x20, 0x62, 0xf1, 0x3d, 0x7b, 0x24, 0xb2, 0x74, 0x19, 0x8, 0x83, 0x96, 0x39, 0x2e, 0xb, 0x82, 0x37, 0x94, 0xe, 0x6, 0xbd, 0xdb, 0xfc, 0x18, 0xe4, 0x49, 0x9e, 0xf0, 0x75, 0xd0, 0xbf, 0x3e, 0xb6, 0x22, 0x23, 0x7d, 0x9a, 0x4c, 0xce, 0xf6, 0xe8, 0xe9, 0x20, 0xb8, 0xaa, 0x6, 0xcd, 0x1c, 0x0, 0x39, 0x3e, 0x1e, 0x4f, 0xce, 0x7f, 0x76, 0x88, 0x1f, 0x1a, 0xcf, 0xa7, 0xe, 0x6, 0x6, 0xe, 0x8d, 0x23, 0xd5, 0x22, 0xd6, 0x41, 0x42, 0x77, 0x6b, 0x33, 0xaa, 0x59, 0x58, 0xc4, 0xf5, 0x9d, 0xed, 0x6c, 0xc0, 0xd7, 0x26, 0x21, 0xe, 0x7, 0x9d, 0xda, 0xf2, 0x8a, 0x1d, 0x1f, 0xae, 0xdf, 0x57, 0x19, 0xfe, 0x6, 0xa0, 0x9a, 0x2f, 0xf3, 0xed, 0xfe, 0xc5, 0x7e, 0x85, 0xce, 0x5f, 0xbf, 0x39, 0xca, 0x67, 0x21, 0x18, 0x66, 0x3b, 0x0, 0xf8, 0x4, 0x7e, 0x5c, 0x62, 0x33, 0x51, 0xf0, 0xbb, 0xff, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char hslider_grabber_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xc6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x48,0x83,0x83,0x60,0xaf,0xb1,0x65,0xbb,0xca,0x61,0xb3,0xc2,0x0,0x0,0x0,0x63,0xb7,0xc8,0x63,0xb7,0xc7,0x0,0x0,0x0,0x61,0xb3,0xbc,0x60,0xb1,0xbc,0x0,0x0,0x0,0x0,0x0,0x0,0x5b,0xa6,0xa5,0x63,0xb4,0xb6,0x0,0x0,0x0,0x0,0x0,0x0,0x3a,0x69,0x69,0x5e,0xb1,0xcd,0x5e,0xb0,0xcd,0x36,0x63,0x63,0x0,0x0,0x0,0x17,0x2a,0x29,0x60,0xb2,0xbd,0x62,0xb3,0xbf,0x3,0x5,0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x55,0x9b,0x9a,0x52,0x96,0x95,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0xf,0xf,0x62,0xb4,0xbd,0x63,0xb7,0xbf,0x0,0x0,0x0,0x27,0x48,0x47,0x68,0xc0,0xcf,0x68,0xc1,0xcf,0x2d,0x52,0x52,0x51,0x93,0x92,0x56,0x9d,0x9c,0x0,0x0,0x0,0x54,0xa2,0xc8,0x4c,0x94,0xc2,0x48,0x8e,0xc0,0x47,0x8c,0xbf,0x4b,0x93,0xc2,0x4b,0x92,0xc2,0x4f,0x98,0xc4,0x4d,0x96,0xc3,0x55,0xa3,0xc8,0x53,0x9f,0xc7,0x49,0x8f,0xc0,0x4e,0x97,0xc4,0x5a,0xab,0xcb,0x5a,0xac,0xcc,0x52,0x9e,0xc6,0x51,0x9d,0xc6,0xff,0xff,0xff,0x6b,0x1e,0xb5,0x61,0x0,0x0,0x0,0x31,0x74,0x52,0x4e,0x53,0x0,0x3,0xd,0x1c,0x27,0x16,0x6e,0xc1,0xef,0xe8,0x28,0xf0,0xf0,0x22,0xdb,0xde,0x24,0x17,0xaf,0xc5,0x1a,0xa,0x65,0xfc,0xfe,0x64,0xc,0x31,0xe0,0xe0,0x28,0x2,0x1,0x14,0x9c,0x95,0x13,0x5,0x2c,0xdb,0xdc,0xb,0x4f,0xf4,0xf7,0x55,0x73,0x7d,0x4,0x28,0xf1,0xfd,0xa1,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x41,0x89,0xde,0x6c,0x4e,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x9e,0x49,0x44,0x41,0x54,0x18,0xd3,0x6d,0xcf,0xd7,0x12,0x82,0x30,0x10,0x5,0x50,0x48,0x42,0x12,0xb0,0x77,0x8d,0xd,0xb,0x28,0x56,0x12,0x62,0xd,0x96,0xff,0xff,0x2a,0x61,0xc,0xe0,0x83,0xfb,0xb4,0xf7,0xcc,0xec,0xcc,0x5d,0xc3,0xf8,0x37,0x26,0x80,0x8,0x41,0x60,0xe6,0xd9,0xc2,0x84,0x52,0x82,0xad,0x4c,0x0,0xb6,0xb9,0x10,0xdc,0xc6,0x40,0x3,0x24,0x3c,0x92,0x32,0xe2,0x4,0x6a,0x40,0x54,0xc8,0x64,0x4,0x45,0x1a,0x9c,0xd2,0x29,0x85,0x73,0xd9,0xd1,0x50,0xa9,0x5e,0x52,0xb8,0xd6,0xea,0x1a,0x1a,0xcd,0x5b,0xa,0xf7,0x56,0x5b,0x43,0xa7,0xdb,0x53,0x52,0xaa,0xfe,0x80,0x65,0x3d,0x86,0xa3,0x58,0xca,0x78,0x3c,0x99,0x6a,0x70,0x67,0xf3,0x87,0x52,0xcf,0xc5,0x32,0xaf,0xee,0xf9,0xab,0xd7,0x7b,0xed,0x7b,0xc5,0x33,0xc1,0x66,0xbb,0xdb,0xb3,0x22,0x27,0x47,0x87,0xa3,0xe5,0xfe,0xfe,0x1b,0x6,0x2c,0xfc,0x6e,0x1f,0x93,0x2a,0x10,0x62,0x3,0x21,0x32,0x75,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char hslider_grabber_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xc6, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x48, 0x83, 0x83, 0x60, 0xaf, 0xb1, 0x65, 0xbb, 0xca, 0x61, 0xb3, 0xc2, 0x0, 0x0, 0x0, 0x63, 0xb7, 0xc8, 0x63, 0xb7, 0xc7, 0x0, 0x0, 0x0, 0x61, 0xb3, 0xbc, 0x60, 0xb1, 0xbc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5b, 0xa6, 0xa5, 0x63, 0xb4, 0xb6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3a, 0x69, 0x69, 0x5e, 0xb1, 0xcd, 0x5e, 0xb0, 0xcd, 0x36, 0x63, 0x63, 0x0, 0x0, 0x0, 0x17, 0x2a, 0x29, 0x60, 0xb2, 0xbd, 0x62, 0xb3, 0xbf, 0x3, 0x5, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x55, 0x9b, 0x9a, 0x52, 0x96, 0x95, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0xf, 0xf, 0x62, 0xb4, 0xbd, 0x63, 0xb7, 0xbf, 0x0, 0x0, 0x0, 0x27, 0x48, 0x47, 0x68, 0xc0, 0xcf, 0x68, 0xc1, 0xcf, 0x2d, 0x52, 0x52, 0x51, 0x93, 0x92, 0x56, 0x9d, 0x9c, 0x0, 0x0, 0x0, 0x54, 0xa2, 0xc8, 0x4c, 0x94, 0xc2, 0x48, 0x8e, 0xc0, 0x47, 0x8c, 0xbf, 0x4b, 0x93, 0xc2, 0x4b, 0x92, 0xc2, 0x4f, 0x98, 0xc4, 0x4d, 0x96, 0xc3, 0x55, 0xa3, 0xc8, 0x53, 0x9f, 0xc7, 0x49, 0x8f, 0xc0, 0x4e, 0x97, 0xc4, 0x5a, 0xab, 0xcb, 0x5a, 0xac, 0xcc, 0x52, 0x9e, 0xc6, 0x51, 0x9d, 0xc6, 0xff, 0xff, 0xff, 0x6b, 0x1e, 0xb5, 0x61, 0x0, 0x0, 0x0, 0x31, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x3, 0xd, 0x1c, 0x27, 0x16, 0x6e, 0xc1, 0xef, 0xe8, 0x28, 0xf0, 0xf0, 0x22, 0xdb, 0xde, 0x24, 0x17, 0xaf, 0xc5, 0x1a, 0xa, 0x65, 0xfc, 0xfe, 0x64, 0xc, 0x31, 0xe0, 0xe0, 0x28, 0x2, 0x1, 0x14, 0x9c, 0x95, 0x13, 0x5, 0x2c, 0xdb, 0xdc, 0xb, 0x4f, 0xf4, 0xf7, 0x55, 0x73, 0x7d, 0x4, 0x28, 0xf1, 0xfd, 0xa1, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x41, 0x89, 0xde, 0x6c, 0x4e, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x9e, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x6d, 0xcf, 0xd7, 0x12, 0x82, 0x30, 0x10, 0x5, 0x50, 0x48, 0x42, 0x12, 0xb0, 0x77, 0x8d, 0xd, 0xb, 0x28, 0x56, 0x12, 0x62, 0xd, 0x96, 0xff, 0xff, 0x2a, 0x61, 0xc, 0xe0, 0x83, 0xfb, 0xb4, 0xf7, 0xcc, 0xec, 0xcc, 0x5d, 0xc3, 0xf8, 0x37, 0x26, 0x80, 0x8, 0x41, 0x60, 0xe6, 0xd9, 0xc2, 0x84, 0x52, 0x82, 0xad, 0x4c, 0x0, 0xb6, 0xb9, 0x10, 0xdc, 0xc6, 0x40, 0x3, 0x24, 0x3c, 0x92, 0x32, 0xe2, 0x4, 0x6a, 0x40, 0x54, 0xc8, 0x64, 0x4, 0x45, 0x1a, 0x9c, 0xd2, 0x29, 0x85, 0x73, 0xd9, 0xd1, 0x50, 0xa9, 0x5e, 0x52, 0xb8, 0xd6, 0xea, 0x1a, 0x1a, 0xcd, 0x5b, 0xa, 0xf7, 0x56, 0x5b, 0x43, 0xa7, 0xdb, 0x53, 0x52, 0xaa, 0xfe, 0x80, 0x65, 0x3d, 0x86, 0xa3, 0x58, 0xca, 0x78, 0x3c, 0x99, 0x6a, 0x70, 0x67, 0xf3, 0x87, 0x52, 0xcf, 0xc5, 0x32, 0xaf, 0xee, 0xf9, 0xab, 0xd7, 0x7b, 0xed, 0x7b, 0xc5, 0x33, 0xc1, 0x66, 0xbb, 0xdb, 0xb3, 0x22, 0x27, 0x47, 0x87, 0xa3, 0xe5, 0xfe, 0xfe, 0x1b, 0x6, 0x2c, 0xfc, 0x6e, 0x1f, 0x93, 0x2a, 0x10, 0x62, 0x3, 0x21, 0x32, 0x75, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char hslider_tick_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xc3,0x98,0xc3,0xc0,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x1e,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x38,0x55,0x5f,0x8c,0xac,0xb8,0x81,0xa2,0xad,0x98,0x98,0x98,0x4e,0x4e,0x4e,0x8d,0x8d,0x8d,0x82,0x82,0x82,0x4e,0x4e,0x4e,0xff,0xff,0xff,0xc1,0xc9,0xb1,0x80,0x0,0x0,0x0,0x9,0x74,0x52,0x4e,0x53,0x0,0x0,0x0,0x0,0x79,0x31,0x79,0x79,0x1c,0x7e,0xed,0x4b,0xf4,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x9,0xf1,0xd9,0xa5,0xec,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x21,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x9,0x60,0x60,0xb,0x60,0x60,0xf,0x60,0x60,0x6d,0x60,0x60,0x14,0x60,0xc0,0x4,0x4c,0x2,0xc,0xcc,0x2,0xc,0x30,0x65,0x0,0x46,0x9d,0x2,0xbe,0x9f,0x3a,0x6c,0xab,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char hslider_tick_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xc3, 0x98, 0xc3, 0xc0, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x1e, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x38, 0x55, 0x5f, 0x8c, 0xac, 0xb8, 0x81, 0xa2, 0xad, 0x98, 0x98, 0x98, 0x4e, 0x4e, 0x4e, 0x8d, 0x8d, 0x8d, 0x82, 0x82, 0x82, 0x4e, 0x4e, 0x4e, 0xff, 0xff, 0xff, 0xc1, 0xc9, 0xb1, 0x80, 0x0, 0x0, 0x0, 0x9, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x0, 0x0, 0x79, 0x31, 0x79, 0x79, 0x1c, 0x7e, 0xed, 0x4b, 0xf4, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x9, 0xf1, 0xd9, 0xa5, 0xec, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x21, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x9, 0x60, 0x60, 0xb, 0x60, 0x60, 0xf, 0x60, 0x60, 0x6d, 0x60, 0x60, 0x14, 0x60, 0xc0, 0x4, 0x4c, 0x2, 0xc, 0xcc, 0x2, 0xc, 0x30, 0x65, 0x0, 0x46, 0x9d, 0x2, 0xbe, 0x9f, 0x3a, 0x6c, 0xab, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char hsplit_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x1,0x3,0x0,0x0,0x0,0xfe,0xc1,0x2c,0xc8,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x27,0x27,0x29,0xff,0xff,0xff,0x11,0xab,0xb9,0xf3,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1,0xff,0x2,0x2d,0xde,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xb,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x40,0x5,0x0,0x0,0x10,0x0,0x1,0xa1,0xc5,0x21,0xc1,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char hsplit_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x1, 0x3, 0x0, 0x0, 0x0, 0xfe, 0xc1, 0x2c, 0xc8, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x50, 0x4c, 0x54, 0x45, 0x27, 0x27, 0x29, 0xff, 0xff, 0xff, 0x11, 0xab, 0xb9, 0xf3, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1, 0xff, 0x2, 0x2d, 0xde, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xb, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x40, 0x5, 0x0, 0x0, 0x10, 0x0, 0x1, 0xa1, 0xc5, 0x21, 0xc1, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char hsplitter_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x40,0x8,0x0,0x0,0x0,0x0,0x2,0x6f,0x69,0x56,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x27,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0x80,0x2,0x66,0x86,0x5,0xa2,0xe7,0x18,0x16,0x88,0x9e,0x63,0x66,0x10,0xbd,0xf6,0x98,0x41,0xf4,0xda,0x63,0x6,0xc,0x30,0xaa,0x66,0x54,0xd,0x9a,0x1a,0x0,0x5c,0x29,0x6a,0x81,0x90,0x8f,0x52,0x12,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char hsplitter_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x40, 0x8, 0x0, 0x0, 0x0, 0x0, 0x2, 0x6f, 0x69, 0x56, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x76, 0x93, 0xcd, 0x38, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x27, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x80, 0x2, 0x66, 0x86, 0x5, 0xa2, 0xe7, 0x18, 0x16, 0x88, 0x9e, 0x63, 0x66, 0x10, 0xbd, 0xf6, 0x98, 0x41, 0xf4, 0xda, 0x63, 0x6, 0xc, 0x30, 0xaa, 0x66, 0x54, 0xd, 0x9a, 0x1a, 0x0, 0x5c, 0x29, 0x6a, 0x81, 0x90, 0x8f, 0x52, 0x12, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_add_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x0,0x0,0x0,0x0,0x3a,0x98,0xa0,0xbd,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x21,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0xc0,0x1,0x1e,0x3c,0x80,0x32,0x98,0xd0,0x65,0xa8,0x21,0xc0,0xc8,0xf0,0x0,0x85,0xaf,0x80,0xa1,0x82,0x3e,0xee,0xc0,0x0,0x0,0x13,0x86,0x4,0x98,0x60,0x93,0x6c,0x5a,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_add_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x0, 0x0, 0x0, 0x0, 0x3a, 0x98, 0xa0, 0xbd, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x76, 0x93, 0xcd, 0x38, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x21, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0xc0, 0x1, 0x1e, 0x3c, 0x80, 0x32, 0x98, 0xd0, 0x65, 0xa8, 0x21, 0xc0, 0xc8, 0xf0, 0x0, 0x85, 0xaf, 0x80, 0xa1, 0x82, 0x3e, 0xee, 0xc0, 0x0, 0x0, 0x13, 0x86, 0x4, 0x98, 0x60, 0x93, 0x6c, 0x5a, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_close_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x6c,0x49,0x44,0x41,0x54,0x28,0xcf,0xad,0x90,0xd1,0xa,0x80,0x20,0xc,0x45,0xad,0xa7,0x6b,0xee,0x35,0xb1,0x3f,0xf3,0xbb,0x13,0xc,0xea,0x5f,0x5c,0xf,0x42,0x4d,0x1c,0x14,0xd4,0xde,0xc6,0x39,0xd3,0xdd,0x19,0xf3,0x53,0xd9,0x48,0x5e,0xf6,0xe4,0x6d,0x6c,0x30,0xa,0xd2,0xad,0x90,0x47,0x42,0x11,0xa,0xcd,0x76,0x5,0x63,0x9b,0x16,0xd9,0xb9,0x20,0x9f,0xbc,0x14,0x15,0xb,0x65,0x47,0x56,0x71,0x55,0x90,0xc1,0x60,0x1c,0x12,0x8f,0x5a,0x26,0x1e,0xd4,0x79,0xf9,0x45,0x5d,0x57,0x59,0xd2,0x85,0x36,0x51,0x87,0xfb,0xd0,0xef,0xe,0xf5,0x78,0xea,0x4f,0x75,0x2,0x30,0x98,0x34,0x72,0xa,0x11,0xfb,0xc2,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_close_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x6c, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0xad, 0x90, 0xd1, 0xa, 0x80, 0x20, 0xc, 0x45, 0xad, 0xa7, 0x6b, 0xee, 0x35, 0xb1, 0x3f, 0xf3, 0xbb, 0x13, 0xc, 0xea, 0x5f, 0x5c, 0xf, 0x42, 0x4d, 0x1c, 0x14, 0xd4, 0xde, 0xc6, 0x39, 0xd3, 0xdd, 0x19, 0xf3, 0x53, 0xd9, 0x48, 0x5e, 0xf6, 0xe4, 0x6d, 0x6c, 0x30, 0xa, 0xd2, 0xad, 0x90, 0x47, 0x42, 0x11, 0xa, 0xcd, 0x76, 0x5, 0x63, 0x9b, 0x16, 0xd9, 0xb9, 0x20, 0x9f, 0xbc, 0x14, 0x15, 0xb, 0x65, 0x47, 0x56, 0x71, 0x55, 0x90, 0xc1, 0x60, 0x1c, 0x12, 0x8f, 0x5a, 0x26, 0x1e, 0xd4, 0x79, 0xf9, 0x45, 0x5d, 0x57, 0x59, 0xd2, 0x85, 0x36, 0x51, 0x87, 0xfb, 0xd0, 0xef, 0xe, 0xf5, 0x78, 0xea, 0x4f, 0x75, 0x2, 0x30, 0x98, 0x34, 0x72, 0xa, 0x11, 0xfb, 0xc2, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_color_pick_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xe0,0x49,0x44,0x41,0x54,0x28,0xcf,0x95,0x91,0xbf,0x6a,0xc2,0x60,0x14,0xc5,0xcf,0x17,0x82,0xcf,0xd0,0xad,0x75,0x13,0x12,0xa1,0x5b,0xc0,0xdd,0x35,0xe0,0x50,0xfc,0x43,0xfb,0x8,0x6e,0x8e,0x3e,0x44,0x1f,0xa0,0xf,0xd0,0xa9,0x88,0x53,0x85,0x3a,0x38,0x74,0x12,0xc1,0x45,0x1c,0x8c,0xf9,0xce,0x27,0x89,0xa0,0x19,0x3a,0x17,0xe2,0x17,0x87,0xb4,0x60,0x9a,0x48,0xc9,0x99,0xee,0xe5,0x7,0xe7,0x5e,0xce,0x1,0xca,0x4a,0x59,0xab,0xa,0xc0,0x16,0xf7,0x3c,0xb0,0x5,0x88,0x2c,0x96,0x8e,0x78,0x17,0xb3,0xd3,0x9b,0x78,0x11,0x26,0x80,0xe3,0xdd,0x8d,0xf9,0xc7,0xe0,0x1b,0x71,0xe2,0x1a,0xee,0xcf,0x16,0x3,0x46,0x96,0x57,0x97,0x78,0xfe,0x9d,0x93,0x18,0xfd,0xdc,0x7,0xb2,0xc3,0x90,0x3d,0x46,0xd4,0xd4,0xfe,0x53,0x21,0xf6,0x6c,0x40,0x76,0xa9,0xa9,0xd5,0x68,0x55,0x29,0xc4,0xca,0x62,0xe0,0xf,0x19,0xf1,0x4b,0x59,0x57,0xb0,0xec,0x0,0xf2,0x5e,0x3a,0x17,0xd8,0x7f,0x60,0xb0,0xad,0x3,0xb2,0xa6,0x76,0xfe,0x63,0xee,0xf6,0x3f,0x98,0x8d,0xd4,0xdc,0xb3,0x53,0xf3,0xac,0xc,0x40,0x34,0xb1,0x4e,0x36,0x9e,0x6d,0x4e,0x92,0x41,0xf5,0xb5,0x28,0xfd,0x31,0x35,0x3f,0x18,0xca,0x76,0x51,0x37,0x2,0xe0,0x5c,0xec,0xb1,0xc0,0xf4,0xf6,0xb3,0x74,0xb3,0x0,0x70,0x6,0x95,0x2,0x6f,0xae,0x29,0xa4,0x96,0x25,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x34,0x39,0x2b,0x30,0x32,0x3a,0x30,0x30,0xe3,0xb6,0x51,0xb2,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x34,0x39,0x2b,0x30,0x32,0x3a,0x30,0x30,0x92,0xeb,0xe9,0xe,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_color_pick_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xe0, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x95, 0x91, 0xbf, 0x6a, 0xc2, 0x60, 0x14, 0xc5, 0xcf, 0x17, 0x82, 0xcf, 0xd0, 0xad, 0x75, 0x13, 0x12, 0xa1, 0x5b, 0xc0, 0xdd, 0x35, 0xe0, 0x50, 0xfc, 0x43, 0xfb, 0x8, 0x6e, 0x8e, 0x3e, 0x44, 0x1f, 0xa0, 0xf, 0xd0, 0xa9, 0x88, 0x53, 0x85, 0x3a, 0x38, 0x74, 0x12, 0xc1, 0x45, 0x1c, 0x8c, 0xf9, 0xce, 0x27, 0x89, 0xa0, 0x19, 0x3a, 0x17, 0xe2, 0x17, 0x87, 0xb4, 0x60, 0x9a, 0x48, 0xc9, 0x99, 0xee, 0xe5, 0x7, 0xe7, 0x5e, 0xce, 0x1, 0xca, 0x4a, 0x59, 0xab, 0xa, 0xc0, 0x16, 0xf7, 0x3c, 0xb0, 0x5, 0x88, 0x2c, 0x96, 0x8e, 0x78, 0x17, 0xb3, 0xd3, 0x9b, 0x78, 0x11, 0x26, 0x80, 0xe3, 0xdd, 0x8d, 0xf9, 0xc7, 0xe0, 0x1b, 0x71, 0xe2, 0x1a, 0xee, 0xcf, 0x16, 0x3, 0x46, 0x96, 0x57, 0x97, 0x78, 0xfe, 0x9d, 0x93, 0x18, 0xfd, 0xdc, 0x7, 0xb2, 0xc3, 0x90, 0x3d, 0x46, 0xd4, 0xd4, 0xfe, 0x53, 0x21, 0xf6, 0x6c, 0x40, 0x76, 0xa9, 0xa9, 0xd5, 0x68, 0x55, 0x29, 0xc4, 0xca, 0x62, 0xe0, 0xf, 0x19, 0xf1, 0x4b, 0x59, 0x57, 0xb0, 0xec, 0x0, 0xf2, 0x5e, 0x3a, 0x17, 0xd8, 0x7f, 0x60, 0xb0, 0xad, 0x3, 0xb2, 0xa6, 0x76, 0xfe, 0x63, 0xee, 0xf6, 0x3f, 0x98, 0x8d, 0xd4, 0xdc, 0xb3, 0x53, 0xf3, 0xac, 0xc, 0x40, 0x34, 0xb1, 0x4e, 0x36, 0x9e, 0x6d, 0x4e, 0x92, 0x41, 0xf5, 0xb5, 0x28, 0xfd, 0x31, 0x35, 0x3f, 0x18, 0xca, 0x76, 0x51, 0x37, 0x2, 0xe0, 0x5c, 0xec, 0xb1, 0xc0, 0xf4, 0xf6, 0xb3, 0x74, 0xb3, 0x0, 0x70, 0x6, 0x95, 0x2, 0x6f, 0xae, 0x29, 0xa4, 0x96, 0x25, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x34, 0x39, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xe3, 0xb6, 0x51, 0xb2, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x34, 0x39, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0x92, 0xeb, 0xe9, 0xe, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_folder_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x40,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0xa0,0x14,0x30,0x32,0x30,0x3c,0x38,0xca,0x60,0x85,0x24,0x72,0x44,0xc1,0x16,0x5d,0xc1,0x7f,0x54,0x3d,0xa,0x8c,0xc8,0x3c,0x26,0x4c,0x43,0x1f,0xda,0x10,0x30,0x1,0xd5,0x3a,0x26,0x6,0x7c,0xc0,0x6,0xab,0x15,0xa8,0x60,0xc8,0x28,0x38,0x82,0x4b,0xf2,0xff,0x61,0x42,0xda,0x89,0x1,0x0,0x7c,0x5,0xb,0xf5,0x5d,0xb6,0xe9,0xbb,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x34,0x39,0x2b,0x30,0x32,0x3a,0x30,0x30,0xe3,0xb6,0x51,0xb2,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x34,0x39,0x2b,0x30,0x32,0x3a,0x30,0x30,0x92,0xeb,0xe9,0xe,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_folder_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x40, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0xa0, 0x14, 0x30, 0x32, 0x30, 0x3c, 0x38, 0xca, 0x60, 0x85, 0x24, 0x72, 0x44, 0xc1, 0x16, 0x5d, 0xc1, 0x7f, 0x54, 0x3d, 0xa, 0x8c, 0xc8, 0x3c, 0x26, 0x4c, 0x43, 0x1f, 0xda, 0x10, 0x30, 0x1, 0xd5, 0x3a, 0x26, 0x6, 0x7c, 0xc0, 0x6, 0xab, 0x15, 0xa8, 0x60, 0xc8, 0x28, 0x38, 0x82, 0x4b, 0xf2, 0xff, 0x61, 0x42, 0xda, 0x89, 0x1, 0x0, 0x7c, 0x5, 0xb, 0xf5, 0x5d, 0xb6, 0xe9, 0xbb, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x34, 0x39, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xe3, 0xb6, 0x51, 0xb2, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x34, 0x39, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0x92, 0xeb, 0xe9, 0xe, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_play_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x6b,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0xa0,0x17,0x78,0x70,0xf8,0xc1,0xb5,0x7,0xde,0xf8,0x14,0xfc,0x7f,0xf0,0xff,0xc1,0xff,0x87,0x3b,0x1e,0x6a,0xa1,0xcb,0x30,0x21,0x73,0xfe,0xbb,0xff,0xbf,0xf8,0x60,0xca,0x13,0x61,0x64,0x31,0x46,0x98,0x9,0x48,0x62,0x1f,0x18,0x3b,0x7e,0x4d,0x50,0xfd,0x89,0x5b,0x1,0x3,0x3,0x3,0xc3,0x11,0x5,0x5b,0x2c,0x56,0x60,0x3,0xd8,0x14,0xbc,0x67,0xac,0xf8,0xed,0x2,0xe3,0xb0,0xa0,0x49,0xfe,0x61,0x98,0xc9,0x52,0x2f,0xf3,0x16,0x21,0x80,0xa2,0x80,0x71,0x27,0x43,0x91,0xfc,0x35,0xf2,0x2,0x8a,0x96,0x0,0x0,0xbc,0x2d,0x27,0xc4,0x79,0x12,0x82,0x82,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_play_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x6b, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0xa0, 0x17, 0x78, 0x70, 0xf8, 0xc1, 0xb5, 0x7, 0xde, 0xf8, 0x14, 0xfc, 0x7f, 0xf0, 0xff, 0xc1, 0xff, 0x87, 0x3b, 0x1e, 0x6a, 0xa1, 0xcb, 0x30, 0x21, 0x73, 0xfe, 0xbb, 0xff, 0xbf, 0xf8, 0x60, 0xca, 0x13, 0x61, 0x64, 0x31, 0x46, 0x98, 0x9, 0x48, 0x62, 0x1f, 0x18, 0x3b, 0x7e, 0x4d, 0x50, 0xfd, 0x89, 0x5b, 0x1, 0x3, 0x3, 0x3, 0xc3, 0x11, 0x5, 0x5b, 0x2c, 0x56, 0x60, 0x3, 0xd8, 0x14, 0xbc, 0x67, 0xac, 0xf8, 0xed, 0x2, 0xe3, 0xb0, 0xa0, 0x49, 0xfe, 0x61, 0x98, 0xc9, 0x52, 0x2f, 0xf3, 0x16, 0x21, 0x80, 0xa2, 0x80, 0x71, 0x27, 0x43, 0x91, 0xfc, 0x35, 0xf2, 0x2, 0x8a, 0x96, 0x0, 0x0, 0xbc, 0x2d, 0x27, 0xc4, 0x79, 0x12, 0x82, 0x82, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_reload_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xe8,0x49,0x44,0x41,0x54,0x28,0xcf,0xa5,0x91,0x31,0x4e,0x2,0x51,0x10,0x86,0x3f,0x16,0x22,0x5b,0x10,0x88,0x5a,0x1a,0x4a,0x1b,0xd7,0x4,0x4a,0x6e,0x60,0x65,0xa3,0xc1,0xc4,0x8e,0x8e,0x46,0x38,0x90,0x5,0xa5,0x17,0x90,0x46,0xf,0x80,0x56,0x84,0x2,0x48,0xc,0xc9,0xee,0x3c,0x56,0xe,0x60,0xd0,0x64,0x2d,0xde,0x40,0xe3,0xbe,0xdd,0x4d,0xec,0x98,0x6a,0x26,0xf3,0x4d,0xe6,0x9f,0x7f,0xe0,0xd0,0x28,0x65,0xe9,0xaa,0x5a,0xe9,0x97,0xee,0xb9,0x4,0xe6,0xfa,0x64,0x1f,0xcf,0x7f,0xb,0x40,0x7c,0x66,0xc7,0xb4,0x72,0xa3,0xb3,0xf2,0x75,0x73,0x3,0x5e,0x3a,0x6d,0xc7,0xb4,0x88,0xe9,0x26,0x8d,0xa4,0xb1,0xbb,0xe1,0x83,0xb6,0x7d,0x5e,0x55,0x1d,0x1e,0xd,0x45,0xc5,0xc4,0x27,0x69,0x6d,0x8e,0xc5,0x88,0x86,0xf,0xe,0x90,0x77,0x51,0xb9,0xcd,0x8b,0xb,0xbb,0xa2,0x32,0x71,0x2b,0xb8,0x80,0xe4,0x35,0xf,0xd8,0x17,0x20,0x0,0xf,0x64,0x24,0x4a,0xd,0xfc,0x2f,0x19,0x65,0x80,0xf7,0x27,0xdf,0x3,0x7f,0xc0,0x12,0x80,0xa5,0x3f,0xc8,0xdd,0x7f,0x5,0x2c,0x52,0x49,0x81,0x6c,0x65,0x6b,0x82,0xac,0xfd,0x79,0x6a,0xd6,0x5,0x91,0x51,0x2f,0xea,0x39,0xc3,0xea,0xe1,0x9d,0x59,0x8b,0xca,0x74,0x71,0x54,0x70,0xd2,0x5d,0xa4,0xff,0x18,0x55,0x88,0x6f,0xde,0x74,0xf8,0xd3,0x69,0x6e,0xe,0x7e,0x24,0x0,0x7b,0x27,0x64,0x59,0x3b,0x41,0xb6,0x9a,0xe,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_reload_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xe8, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0xa5, 0x91, 0x31, 0x4e, 0x2, 0x51, 0x10, 0x86, 0x3f, 0x16, 0x22, 0x5b, 0x10, 0x88, 0x5a, 0x1a, 0x4a, 0x1b, 0xd7, 0x4, 0x4a, 0x6e, 0x60, 0x65, 0xa3, 0xc1, 0xc4, 0x8e, 0x8e, 0x46, 0x38, 0x90, 0x5, 0xa5, 0x17, 0x90, 0x46, 0xf, 0x80, 0x56, 0x84, 0x2, 0x48, 0xc, 0xc9, 0xee, 0x3c, 0x56, 0xe, 0x60, 0xd0, 0x64, 0x2d, 0xde, 0x40, 0xe3, 0xbe, 0xdd, 0x4d, 0xec, 0x98, 0x6a, 0x26, 0xf3, 0x4d, 0xe6, 0x9f, 0x7f, 0xe0, 0xd0, 0x28, 0x65, 0xe9, 0xaa, 0x5a, 0xe9, 0x97, 0xee, 0xb9, 0x4, 0xe6, 0xfa, 0x64, 0x1f, 0xcf, 0x7f, 0xb, 0x40, 0x7c, 0x66, 0xc7, 0xb4, 0x72, 0xa3, 0xb3, 0xf2, 0x75, 0x73, 0x3, 0x5e, 0x3a, 0x6d, 0xc7, 0xb4, 0x88, 0xe9, 0x26, 0x8d, 0xa4, 0xb1, 0xbb, 0xe1, 0x83, 0xb6, 0x7d, 0x5e, 0x55, 0x1d, 0x1e, 0xd, 0x45, 0xc5, 0xc4, 0x27, 0x69, 0x6d, 0x8e, 0xc5, 0x88, 0x86, 0xf, 0xe, 0x90, 0x77, 0x51, 0xb9, 0xcd, 0x8b, 0xb, 0xbb, 0xa2, 0x32, 0x71, 0x2b, 0xb8, 0x80, 0xe4, 0x35, 0xf, 0xd8, 0x17, 0x20, 0x0, 0xf, 0x64, 0x24, 0x4a, 0xd, 0xfc, 0x2f, 0x19, 0x65, 0x80, 0xf7, 0x27, 0xdf, 0x3, 0x7f, 0xc0, 0x12, 0x80, 0xa5, 0x3f, 0xc8, 0xdd, 0x7f, 0x5, 0x2c, 0x52, 0x49, 0x81, 0x6c, 0x65, 0x6b, 0x82, 0xac, 0xfd, 0x79, 0x6a, 0xd6, 0x5, 0x91, 0x51, 0x2f, 0xea, 0x39, 0xc3, 0xea, 0xe1, 0x9d, 0x59, 0x8b, 0xca, 0x74, 0x71, 0x54, 0x70, 0xd2, 0x5d, 0xa4, 0xff, 0x18, 0x55, 0x88, 0x6f, 0xde, 0x74, 0xf8, 0xd3, 0x69, 0x6e, 0xe, 0x7e, 0x24, 0x0, 0x7b, 0x27, 0x64, 0x59, 0x3b, 0x41, 0xb6, 0x9a, 0xe, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_stop_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x2b,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0x20,0xc,0x3e,0x30,0xe3,0x93,0x61,0x64,0x60,0x60,0x60,0x78,0xf8,0x1f,0xbb,0x2,0x79,0x46,0x6,0x6,0x26,0x42,0xe6,0x8f,0x2a,0xa0,0x96,0x2,0x6,0x42,0x91,0x45,0x10,0x0,0x0,0x95,0x31,0x5,0xe4,0xe,0x1,0x8e,0x3,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_stop_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x2b, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x20, 0xc, 0x3e, 0x30, 0xe3, 0x93, 0x61, 0x64, 0x60, 0x60, 0x60, 0x78, 0xf8, 0x1f, 0xbb, 0x2, 0x79, 0x46, 0x6, 0x6, 0x26, 0x42, 0xe6, 0x8f, 0x2a, 0xa0, 0x96, 0x2, 0x6, 0x42, 0x91, 0x45, 0x10, 0x0, 0x0, 0x95, 0x31, 0x5, 0xe4, 0xe, 0x1, 0x8e, 0x3, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_zoom_less_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x0,0x0,0x0,0x0,0x3a,0x98,0xa0,0xbd,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x17,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0x18,0x10,0xc0,0xc8,0xf0,0x0,0x85,0xaf,0xc0,0x34,0x30,0xee,0xc0,0x0,0x0,0x97,0xf9,0x1,0x4,0xea,0x8f,0x4a,0x96,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x34,0x39,0x2b,0x30,0x32,0x3a,0x30,0x30,0xe3,0xb6,0x51,0xb2,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x34,0x39,0x2b,0x30,0x32,0x3a,0x30,0x30,0x92,0xeb,0xe9,0xe,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_zoom_less_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x0, 0x0, 0x0, 0x0, 0x3a, 0x98, 0xa0, 0xbd, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x76, 0x93, 0xcd, 0x38, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x17, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0x18, 0x10, 0xc0, 0xc8, 0xf0, 0x0, 0x85, 0xaf, 0xc0, 0x34, 0x30, 0xee, 0xc0, 0x0, 0x0, 0x97, 0xf9, 0x1, 0x4, 0xea, 0x8f, 0x4a, 0x96, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x34, 0x39, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xe3, 0xb6, 0x51, 0xb2, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x34, 0x39, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0x92, 0xeb, 0xe9, 0xe, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_zoom_more_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x0,0x0,0x0,0x0,0x3a,0x98,0xa0,0xbd,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x21,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0xc0,0x1,0x1e,0x3c,0x80,0x32,0x98,0xd0,0x65,0xa8,0x21,0xc0,0xc8,0xf0,0x0,0x85,0xaf,0x80,0xa1,0x82,0x3e,0xee,0xc0,0x0,0x0,0x13,0x86,0x4,0x98,0x60,0x93,0x6c,0x5a,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_zoom_more_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x0, 0x0, 0x0, 0x0, 0x3a, 0x98, 0xa0, 0xbd, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x76, 0x93, 0xcd, 0x38, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x21, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0xc0, 0x1, 0x1e, 0x3c, 0x80, 0x32, 0x98, 0xd0, 0x65, 0xa8, 0x21, 0xc0, 0xc8, 0xf0, 0x0, 0x85, 0xaf, 0x80, 0xa1, 0x82, 0x3e, 0xee, 0xc0, 0x0, 0x0, 0x13, 0x86, 0x4, 0x98, 0x60, 0x93, 0x6c, 0x5a, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char icon_zoom_reset_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x4e,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0x20,0x6,0x3c,0xc,0x7b,0xf0,0xff,0xc1,0x7f,0xec,0x22,0x8c,0xc,0xc,0xcf,0x44,0x7e,0x5d,0x65,0x10,0x63,0x60,0x50,0x60,0x84,0x49,0x23,0x8b,0x30,0x31,0x30,0xfc,0x9a,0xc6,0x20,0x86,0x6a,0x22,0xa6,0x8,0x3,0xcc,0x40,0x84,0x55,0x30,0x16,0x13,0x21,0xf7,0xb1,0xa0,0x72,0x11,0xee,0x80,0x1,0x82,0x26,0x50,0x5d,0x1,0x7a,0x80,0xd,0xe,0x5f,0x10,0x4,0x0,0xfc,0xc5,0x22,0x8c,0x12,0xab,0xcb,0x61,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char icon_zoom_reset_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x4e, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x20, 0x6, 0x3c, 0xc, 0x7b, 0xf0, 0xff, 0xc1, 0x7f, 0xec, 0x22, 0x8c, 0xc, 0xc, 0xcf, 0x44, 0x7e, 0x5d, 0x65, 0x10, 0x63, 0x60, 0x50, 0x60, 0x84, 0x49, 0x23, 0x8b, 0x30, 0x31, 0x30, 0xfc, 0x9a, 0xc6, 0x20, 0x86, 0x6a, 0x22, 0xa6, 0x8, 0x3, 0xcc, 0x40, 0x84, 0x55, 0x30, 0x16, 0x13, 0x21, 0xf7, 0xb1, 0xa0, 0x72, 0x11, 0xee, 0x80, 0x1, 0x82, 0x26, 0x50, 0x5d, 0x1, 0x7a, 0x80, 0xd, 0xe, 0x5f, 0x10, 0x4, 0x0, 0xfc, 0xc5, 0x22, 0x8c, 0x12, 0xab, 0xcb, 0x61, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char line_edit_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xa,0x0,0x0,0x0,0xa,0x4,0x3,0x0,0x0,0x0,0x7f,0x1c,0xd2,0x8e,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2a,0x50,0x4c,0x54,0x45,0x17,0x16,0x1a,0x1d,0x1c,0x21,0x20,0x1e,0x24,0x21,0x1f,0x25,0x1d,0x1c,0x21,0x20,0x1e,0x24,0x1d,0x1c,0x21,0x1d,0x1c,0x21,0x24,0x22,0x29,0x28,0x26,0x2d,0x28,0x26,0x2e,0x2b,0x2a,0x31,0x2c,0x2a,0x32,0xff,0xff,0xff,0xb9,0x11,0x56,0x3e,0x0,0x0,0x0,0x8,0x74,0x52,0x4e,0x53,0x6f,0xef,0xf7,0xf7,0xf0,0xf9,0xf1,0xee,0xcf,0x21,0xd2,0xdf,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xd,0xf6,0xb4,0x61,0xf5,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x2d,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x54,0x36,0x36,0x12,0x60,0xf0,0x98,0xb5,0x6a,0x65,0xb,0x43,0xe4,0x9e,0x33,0xa7,0xa7,0x32,0x58,0x9d,0x39,0x73,0x66,0x31,0x16,0x12,0x22,0xb,0x52,0xd9,0xc6,0xc0,0x2,0xd4,0x55,0x0,0x0,0xc,0x14,0x1a,0x90,0x55,0x1a,0xec,0xdb,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char line_edit_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0xa, 0x4, 0x3, 0x0, 0x0, 0x0, 0x7f, 0x1c, 0xd2, 0x8e, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2a, 0x50, 0x4c, 0x54, 0x45, 0x17, 0x16, 0x1a, 0x1d, 0x1c, 0x21, 0x20, 0x1e, 0x24, 0x21, 0x1f, 0x25, 0x1d, 0x1c, 0x21, 0x20, 0x1e, 0x24, 0x1d, 0x1c, 0x21, 0x1d, 0x1c, 0x21, 0x24, 0x22, 0x29, 0x28, 0x26, 0x2d, 0x28, 0x26, 0x2e, 0x2b, 0x2a, 0x31, 0x2c, 0x2a, 0x32, 0xff, 0xff, 0xff, 0xb9, 0x11, 0x56, 0x3e, 0x0, 0x0, 0x0, 0x8, 0x74, 0x52, 0x4e, 0x53, 0x6f, 0xef, 0xf7, 0xf7, 0xf0, 0xf9, 0xf1, 0xee, 0xcf, 0x21, 0xd2, 0xdf, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xd, 0xf6, 0xb4, 0x61, 0xf5, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x2d, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x54, 0x36, 0x36, 0x12, 0x60, 0xf0, 0x98, 0xb5, 0x6a, 0x65, 0xb, 0x43, 0xe4, 0x9e, 0x33, 0xa7, 0xa7, 0x32, 0x58, 0x9d, 0x39, 0x73, 0x66, 0x31, 0x16, 0x12, 0x22, 0xb, 0x52, 0xd9, 0xc6, 0xc0, 0x2, 0xd4, 0x55, 0x0, 0x0, 0xc, 0x14, 0x1a, 0x90, 0x55, 0x1a, 0xec, 0xdb, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char line_edit_disabled_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xa,0x0,0x0,0x0,0xa,0x8,0x4,0x0,0x0,0x0,0x27,0x3b,0x7,0x36,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x64,0x49,0x44,0x41,0x54,0x8,0xd7,0x95,0xce,0x31,0x12,0x2,0x21,0x10,0x44,0xd1,0x3f,0x40,0xa1,0x44,0xa6,0x46,0xde,0x63,0x4f,0xe5,0x15,0x38,0xb2,0xd6,0x6,0xb0,0xc8,0x30,0x6,0x96,0xac,0x56,0x99,0xf8,0xb3,0x7e,0x51,0xcb,0xf9,0x1a,0xb3,0x3f,0xa,0xaf,0xc,0xad,0x2d,0xcb,0xe5,0x76,0x38,0x5,0x76,0xec,0x6c,0xf7,0xe0,0x53,0xe0,0x13,0xa1,0x27,0x27,0x43,0x26,0x81,0x20,0xc8,0x70,0xfc,0xe8,0xf,0x34,0x67,0xd8,0x9c,0x86,0x61,0x2e,0x68,0xe9,0x91,0xaf,0x4b,0x5a,0x7d,0x2a,0x2c,0x3,0xed,0xef,0x1e,0x6b,0xcb,0x4f,0xa6,0x66,0x2b,0x25,0x6,0x1,0x37,0x40,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char line_edit_disabled_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0xa, 0x8, 0x4, 0x0, 0x0, 0x0, 0x27, 0x3b, 0x7, 0x36, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x64, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x95, 0xce, 0x31, 0x12, 0x2, 0x21, 0x10, 0x44, 0xd1, 0x3f, 0x40, 0xa1, 0x44, 0xa6, 0x46, 0xde, 0x63, 0x4f, 0xe5, 0x15, 0x38, 0xb2, 0xd6, 0x6, 0xb0, 0xc8, 0x30, 0x6, 0x96, 0xac, 0x56, 0x99, 0xf8, 0xb3, 0x7e, 0x51, 0xcb, 0xf9, 0x1a, 0xb3, 0x3f, 0xa, 0xaf, 0xc, 0xad, 0x2d, 0xcb, 0xe5, 0x76, 0x38, 0x5, 0x76, 0xec, 0x6c, 0xf7, 0xe0, 0x53, 0xe0, 0x13, 0xa1, 0x27, 0x27, 0x43, 0x26, 0x81, 0x20, 0xc8, 0x70, 0xfc, 0xe8, 0xf, 0x34, 0x67, 0xd8, 0x9c, 0x86, 0x61, 0x2e, 0x68, 0xe9, 0x91, 0xaf, 0x4b, 0x5a, 0x7d, 0x2a, 0x2c, 0x3, 0xed, 0xef, 0x1e, 0x6b, 0xcb, 0x4f, 0xa6, 0x66, 0x2b, 0x25, 0x6, 0x1, 0x37, 0x40, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char line_edit_focus_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xab,0x50,0x4c,0x54,0x45,0x1b,0x17,0x18,0x1b,0x17,0x18,0x1b,0x17,0x18,0xc8,0x68,0x12,0xef,0xed,0xe7,0xef,0xed,0xe8,0xf0,0xed,0xe8,0xf0,0xee,0xe8,0xf0,0xed,0xe7,0xed,0xeb,0xe5,0xee,0xeb,0xe5,0xee,0xeb,0xe6,0xec,0xe9,0xe3,0xeb,0xe9,0xe3,0xeb,0xe9,0xe2,0xec,0xe9,0xe2,0xe9,0xe6,0xe0,0xea,0xe7,0xe0,0xea,0xe7,0xe1,0xe8,0xe4,0xdd,0xe8,0xe5,0xde,0xe8,0xe5,0xdd,0xe8,0xe4,0xde,0xe6,0xe2,0xdb,0xe6,0xe3,0xdb,0xe6,0xe3,0xdc,0xe7,0xe2,0xdb,0xe7,0xe3,0xdb,0xe4,0xe0,0xd8,0xe5,0xe0,0xd8,0xe5,0xe1,0xd9,0xe5,0xe0,0xd9,0xe4,0xe1,0xd9,0xe5,0xe1,0xd8,0xe4,0xe0,0xd9,0xe2,0xdf,0xd6,0xe3,0xdf,0xd6,0xe3,0xde,0xd6,0xe2,0xde,0xd6,0xe1,0xdc,0xd4,0xe1,0xdc,0xd3,0xe0,0xdc,0xd3,0xe1,0xdd,0xd3,0xe1,0xdd,0xd4,0xdf,0xda,0xd0,0xdf,0xda,0xd1,0xdf,0xdb,0xd1,0xe0,0xda,0xd1,0xdd,0xd8,0xcf,0xdd,0xd8,0xce,0xde,0xd9,0xce,0xde,0xd8,0xce,0xdd,0xd9,0xce,0xdc,0xd6,0xcc,0xdb,0xd6,0xcc,0xdc,0xd6,0xcb,0xff,0xff,0xff,0x73,0x72,0x65,0x6f,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x36,0x61,0xc5,0x3a,0xd,0x83,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x38,0xa0,0x7,0xa5,0xd6,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x9e,0x49,0x44,0x41,0x54,0x18,0xd3,0x5d,0xcf,0xdb,0x16,0x82,0x20,0x10,0x85,0x61,0xb4,0xb4,0x13,0x1d,0x28,0x14,0xcb,0x4a,0x33,0xf,0x59,0x52,0x98,0x62,0xef,0xff,0x66,0xd1,0xf6,0xca,0xfe,0x19,0xd6,0x62,0x7d,0x77,0x43,0x88,0x3d,0x88,0x10,0x7b,0x34,0xc8,0x36,0x30,0x76,0x1c,0x77,0xe2,0x3a,0xee,0xd4,0x7c,0x0,0xb3,0x79,0x3f,0xa6,0x5,0x80,0xa2,0x25,0xa5,0xab,0x35,0x5,0x6c,0x18,0x63,0x5b,0xd6,0x7,0xd8,0x71,0xcf,0xe3,0x9c,0xfb,0x9c,0x7b,0x3e,0x40,0x4,0xfb,0xe0,0x10,0x84,0xa1,0x8,0x85,0x0,0x1c,0x4f,0xe7,0x28,0xbe,0x44,0x71,0x9c,0x24,0x67,0xc0,0x35,0x4d,0xb3,0x2c,0xcb,0xcd,0x4b,0x73,0x40,0x71,0x33,0x15,0xe5,0xfd,0x51,0x16,0x25,0xa0,0x92,0xf2,0xf9,0x92,0xbf,0x2a,0x9,0x50,0xaa,0x56,0xef,0x46,0xb5,0x4d,0x5b,0x37,0x0,0xdd,0x7d,0xb4,0x36,0xdb,0x69,0xad,0x1,0x7f,0xc7,0x59,0xc3,0xf3,0xad,0x2f,0x30,0x4f,0x11,0x50,0x3e,0x12,0x48,0xdb,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char line_edit_focus_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xab, 0x50, 0x4c, 0x54, 0x45, 0x1b, 0x17, 0x18, 0x1b, 0x17, 0x18, 0x1b, 0x17, 0x18, 0xc8, 0x68, 0x12, 0xef, 0xed, 0xe7, 0xef, 0xed, 0xe8, 0xf0, 0xed, 0xe8, 0xf0, 0xee, 0xe8, 0xf0, 0xed, 0xe7, 0xed, 0xeb, 0xe5, 0xee, 0xeb, 0xe5, 0xee, 0xeb, 0xe6, 0xec, 0xe9, 0xe3, 0xeb, 0xe9, 0xe3, 0xeb, 0xe9, 0xe2, 0xec, 0xe9, 0xe2, 0xe9, 0xe6, 0xe0, 0xea, 0xe7, 0xe0, 0xea, 0xe7, 0xe1, 0xe8, 0xe4, 0xdd, 0xe8, 0xe5, 0xde, 0xe8, 0xe5, 0xdd, 0xe8, 0xe4, 0xde, 0xe6, 0xe2, 0xdb, 0xe6, 0xe3, 0xdb, 0xe6, 0xe3, 0xdc, 0xe7, 0xe2, 0xdb, 0xe7, 0xe3, 0xdb, 0xe4, 0xe0, 0xd8, 0xe5, 0xe0, 0xd8, 0xe5, 0xe1, 0xd9, 0xe5, 0xe0, 0xd9, 0xe4, 0xe1, 0xd9, 0xe5, 0xe1, 0xd8, 0xe4, 0xe0, 0xd9, 0xe2, 0xdf, 0xd6, 0xe3, 0xdf, 0xd6, 0xe3, 0xde, 0xd6, 0xe2, 0xde, 0xd6, 0xe1, 0xdc, 0xd4, 0xe1, 0xdc, 0xd3, 0xe0, 0xdc, 0xd3, 0xe1, 0xdd, 0xd3, 0xe1, 0xdd, 0xd4, 0xdf, 0xda, 0xd0, 0xdf, 0xda, 0xd1, 0xdf, 0xdb, 0xd1, 0xe0, 0xda, 0xd1, 0xdd, 0xd8, 0xcf, 0xdd, 0xd8, 0xce, 0xde, 0xd9, 0xce, 0xde, 0xd8, 0xce, 0xdd, 0xd9, 0xce, 0xdc, 0xd6, 0xcc, 0xdb, 0xd6, 0xcc, 0xdc, 0xd6, 0xcb, 0xff, 0xff, 0xff, 0x73, 0x72, 0x65, 0x6f, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x36, 0x61, 0xc5, 0x3a, 0xd, 0x83, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x38, 0xa0, 0x7, 0xa5, 0xd6, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x9e, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x5d, 0xcf, 0xdb, 0x16, 0x82, 0x20, 0x10, 0x85, 0x61, 0xb4, 0xb4, 0x13, 0x1d, 0x28, 0x14, 0xcb, 0x4a, 0x33, 0xf, 0x59, 0x52, 0x98, 0x62, 0xef, 0xff, 0x66, 0xd1, 0xf6, 0xca, 0xfe, 0x19, 0xd6, 0x62, 0x7d, 0x77, 0x43, 0x88, 0x3d, 0x88, 0x10, 0x7b, 0x34, 0xc8, 0x36, 0x30, 0x76, 0x1c, 0x77, 0xe2, 0x3a, 0xee, 0xd4, 0x7c, 0x0, 0xb3, 0x79, 0x3f, 0xa6, 0x5, 0x80, 0xa2, 0x25, 0xa5, 0xab, 0x35, 0x5, 0x6c, 0x18, 0x63, 0x5b, 0xd6, 0x7, 0xd8, 0x71, 0xcf, 0xe3, 0x9c, 0xfb, 0x9c, 0x7b, 0x3e, 0x40, 0x4, 0xfb, 0xe0, 0x10, 0x84, 0xa1, 0x8, 0x85, 0x0, 0x1c, 0x4f, 0xe7, 0x28, 0xbe, 0x44, 0x71, 0x9c, 0x24, 0x67, 0xc0, 0x35, 0x4d, 0xb3, 0x2c, 0xcb, 0xcd, 0x4b, 0x73, 0x40, 0x71, 0x33, 0x15, 0xe5, 0xfd, 0x51, 0x16, 0x25, 0xa0, 0x92, 0xf2, 0xf9, 0x92, 0xbf, 0x2a, 0x9, 0x50, 0xaa, 0x56, 0xef, 0x46, 0xb5, 0x4d, 0x5b, 0x37, 0x0, 0xdd, 0x7d, 0xb4, 0x36, 0xdb, 0x69, 0xad, 0x1, 0x7f, 0xc7, 0x59, 0xc3, 0xf3, 0xad, 0x2f, 0x30, 0x4f, 0x11, 0x50, 0x3e, 0x12, 0x48, 0xdb, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char logo_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x80,0x0,0x0,0x0,0x80,0x8,0x6,0x0,0x0,0x0,0xc3,0x3e,0x61,0xcb,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0x2e,0x23,0x0,0x0,0x2e,0x23,0x1,0x78,0xa5,0x3f,0x76,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdc,0x9,0x7,0x13,0x2,0x0,0x15,0xb9,0x53,0x97,0x0,0x0,0x21,0x58,0x49,0x44,0x41,0x54,0x78,0xda,0xed,0x7d,0x79,0x9c,0x1c,0x55,0xb5,0xff,0xf7,0x7b,0xab,0x7b,0x66,0x48,0x8,0x61,0xd1,0x90,0xb0,0x88,0x91,0x27,0x24,0x24,0x21,0x3b,0x8,0x4,0x42,0x58,0x54,0xe0,0x91,0x80,0x24,0x1,0x2,0x9,0x42,0x80,0x4,0x11,0x90,0x9f,0xf2,0xd3,0xa7,0xcf,0xe7,0xf3,0x3d,0x1f,0x1f,0x7f,0xea,0xd3,0x48,0x4c,0x8,0x61,0xd,0x49,0x64,0x89,0x82,0x40,0x58,0x4,0x64,0xb,0x44,0x25,0x9b,0xd9,0x51,0x14,0x41,0x3,0xc8,0x16,0x20,0xfb,0x4c,0x77,0xdd,0xef,0xef,0x8f,0xaa,0xea,0xae,0xee,0xa9,0xea,0x9e,0xee,0xae,0x99,0xe9,0xe0,0x9c,0xf9,0xd4,0x74,0xd5,0xad,0x5b,0x77,0x39,0xe7,0xdc,0x7b,0xcf,0x39,0xf7,0xdc,0x7b,0x81,0x2e,0xe8,0x82,0x2e,0xe8,0x82,0x2e,0xe8,0x82,0x2e,0xe8,0x82,0x2e,0xe8,0x82,0x2e,0xf8,0xe7,0x2,0x76,0x76,0x1,0xea,0x1,0xe,0xff,0xc2,0xcc,0xbd,0x60,0x5b,0x6e,0xb6,0xd6,0xf6,0x2,0xb8,0x8d,0xc6,0x6c,0x36,0x34,0x6f,0x81,0x7c,0x43,0x30,0x7f,0x27,0xcd,0xdf,0x8c,0xe3,0x6c,0xda,0x70,0xef,0xf4,0x37,0x3b,0xbb,0xac,0x49,0x43,0xaa,0xb3,0xb,0x50,0xf,0x20,0x9b,0xfd,0x96,0xcd,0xb6,0x4c,0x40,0xd0,0x20,0x2c,0xac,0x4b,0xb3,0x3,0xc0,0x36,0x80,0x5b,0x41,0x6c,0x75,0x5b,0xb8,0xed,0xb0,0x71,0xff,0xbb,0x83,0xc6,0x6c,0x26,0x9d,0x65,0x74,0xd2,0x4f,0x6e,0x5c,0x74,0xc5,0xba,0xce,0x2e,0x7b,0xad,0xf0,0x4f,0xdf,0x3,0xf4,0x9f,0x38,0xb7,0x5b,0x76,0xd7,0x7,0x2f,0xcb,0xda,0x3,0xc8,0x42,0x94,0x48,0x6a,0x15,0x9f,0x24,0x0,0xbe,0x43,0xe3,0xfc,0xc1,0x49,0x37,0x4d,0xdd,0xf8,0x8b,0x2b,0xff,0xde,0xd9,0x75,0xa8,0x5,0x76,0x2b,0x6,0xe8,0x37,0x7e,0xf6,0x18,0xeb,0xb6,0x9c,0x6,0x69,0xf,0x1a,0xf3,0xc1,0x1f,0xef,0xbb,0xe6,0xdb,0xb5,0xa4,0x37,0xf2,0x9a,0xa5,0xdc,0xb2,0x69,0xe5,0x69,0xca,0xec,0xf8,0xa5,0xa4,0x26,0x48,0xf2,0x29,0x8c,0x82,0x7b,0x40,0x3e,0xae,0xfc,0x5f,0x41,0x82,0x4d,0x37,0xf5,0x18,0xb7,0xd7,0xc1,0xc3,0x1f,0xfe,0xfd,0x4f,0x3e,0xa3,0x2a,0x8b,0xd0,0xe9,0x50,0xf7,0xc,0x70,0xf8,0x39,0xb3,0x3e,0x9,0xb9,0xa7,0x48,0xf6,0x70,0xb9,0xd9,0xd1,0x90,0x3b,0xd2,0x2b,0x39,0x9b,0x4d,0xaa,0x69,0xfa,0x1f,0xef,0xbb,0xfa,0x8e,0x5a,0xd2,0x3f,0x6c,0xdc,0x8f,0x9f,0x91,0xcd,0x8c,0x2,0xe9,0xe4,0x43,0x3,0x7a,0xc7,0x80,0x4,0x80,0xbb,0x9c,0x74,0xd3,0x77,0xdd,0xcc,0xce,0x1f,0xbc,0xfc,0xd0,0xd7,0x6d,0x67,0xe3,0xa9,0x5a,0xa8,0x5b,0x19,0xa0,0xdf,0xf8,0xd9,0x47,0x42,0xee,0x51,0x72,0x5b,0x3e,0x6b,0xdd,0xcc,0x69,0x0,0xf6,0xf4,0x8,0xe3,0x75,0xc3,0x92,0x1a,0x6d,0x66,0xd7,0x8f,0xfa,0x8d,0x9f,0xf5,0xe7,0x97,0x7e,0x71,0xe5,0xf3,0x55,0xe5,0x31,0xe1,0xc6,0x83,0xdc,0x5d,0x5b,0x46,0x3,0x7e,0xb3,0xce,0x51,0xbd,0x74,0xbb,0xf0,0x9b,0xbb,0x23,0xd9,0x23,0x59,0xf7,0x4d,0xa8,0x34,0xd4,0x1d,0x3,0xf4,0x3b,0x67,0xf6,0x20,0xc0,0x1d,0x65,0xb3,0xcd,0x67,0xc9,0xcd,0x9c,0xa,0x9f,0x1a,0xfe,0xd8,0x5b,0xd0,0x15,0xb,0xda,0xcf,0x66,0x9a,0x7f,0xd8,0x7f,0xc2,0x9c,0xb1,0x1b,0x17,0x4d,0x7f,0xa7,0x92,0x7c,0xe,0xff,0xc2,0xd,0x69,0x58,0x77,0x1c,0x40,0x17,0x84,0x3,0x54,0x48,0x4a,0xd2,0x91,0x75,0x7,0x38,0x4d,0x7b,0xef,0xd6,0x2c,0x50,0x37,0xc,0xd0,0x7f,0xc2,0x8d,0x7,0x3,0x1a,0x65,0x33,0xcd,0x97,0x58,0x9b,0x3d,0x5,0x0,0x40,0xe6,0x5a,0xa6,0x82,0x47,0xbf,0x13,0x0,0x21,0x82,0x90,0xdc,0xcf,0xc8,0x66,0xbe,0xd6,0x6f,0xfc,0xac,0xef,0xbc,0xf4,0x8b,0x2b,0x77,0xb5,0x35,0x3f,0x93,0x6a,0xb4,0x36,0xb3,0xe3,0x7c,0x1a,0xe3,0x8f,0xe9,0xe1,0x21,0x3f,0x4,0xe1,0xd1,0x40,0x80,0x24,0xd1,0x90,0x10,0x8c,0x64,0xf,0x31,0xa9,0xa6,0x2e,0x6,0x48,0x2,0x64,0xb3,0xdf,0xb0,0xd9,0xe6,0x2f,0x1,0x41,0x6b,0xf7,0x9,0x2f,0x91,0x1e,0x23,0x78,0x40,0x9f,0x8,0x34,0x41,0x90,0x75,0x33,0xbb,0xfe,0xaf,0xd3,0xd0,0x7d,0xd9,0x61,0xe3,0x7e,0x78,0xdf,0x9f,0x1e,0xb8,0x2e,0x72,0x3c,0x1e,0x30,0xe9,0xce,0x94,0xdb,0xb2,0x7d,0x1f,0xd2,0xf4,0x0,0x6c,0x1a,0xb2,0xbd,0x65,0xdd,0xcf,0x0,0x30,0x0,0x41,0x42,0x91,0xbd,0x0,0xb,0xef,0x49,0x52,0x9e,0x7a,0x40,0x48,0x7b,0xee,0x6,0x62,0x54,0x49,0xa8,0x1b,0x6,0xb0,0xd9,0xcc,0x39,0x7e,0x6b,0xb,0xda,0x5c,0xa8,0xeb,0x2f,0x4,0x7a,0x81,0x41,0x3c,0x3,0x10,0x36,0xbb,0xeb,0xc7,0x4e,0x43,0x8f,0xd7,0xfa,0x4f,0xb8,0x71,0x3,0x68,0xf6,0x7,0xb0,0x37,0x81,0x34,0x8,0xca,0xda,0x46,0xb7,0x65,0xeb,0x27,0x20,0x3b,0xd8,0x75,0xdd,0xbe,0x4,0xf6,0x83,0x74,0x30,0x80,0x40,0xf0,0x53,0x25,0x43,0x0,0xfd,0xff,0x22,0xad,0xcd,0xee,0xac,0x59,0x3,0xe8,0x7f,0xee,0x2d,0xdd,0x36,0xde,0x73,0xe9,0x8e,0xce,0xc0,0x7b,0xdd,0x30,0x0,0x8d,0xf3,0xb2,0xac,0x3e,0xe,0xc0,0x20,0x4e,0xc,0xf,0xc8,0x1e,0x3c,0xf9,0x8a,0x3a,0x49,0x40,0xf6,0x60,0xeb,0xb6,0xfc,0x1f,0xd2,0xac,0xb3,0xb6,0xf9,0x24,0x78,0xad,0xbb,0x9b,0x17,0xb5,0x90,0x46,0xca,0x25,0x46,0x85,0x52,0x8e,0xcb,0xa7,0x30,0xdc,0x4a,0xa0,0x21,0xe8,0x7d,0xed,0x36,0x6f,0xad,0x89,0x1,0x8e,0x38,0x77,0x6e,0x5f,0xeb,0xb6,0x9c,0xde,0x7f,0xc2,0x9c,0xe7,0x36,0x2e,0x9a,0xbe,0xb6,0xc3,0xf1,0xde,0xd1,0x19,0xc6,0x41,0xff,0x9,0xb3,0xbf,0x67,0x33,0xcd,0x5f,0x96,0x6c,0xcf,0x70,0xab,0x8f,0xa3,0x43,0x41,0xb8,0x4,0x90,0x16,0x80,0x41,0xd8,0x78,0x43,0x6,0xef,0x8a,0xf4,0x7a,0x9,0xf2,0xfa,0x7d,0xff,0xb1,0x40,0x0,0x60,0x51,0xde,0xc5,0xf9,0x11,0x39,0x23,0x51,0xd6,0x69,0xdc,0xf3,0x18,0xc9,0xbe,0x61,0x9c,0x86,0xad,0x1b,0xee,0x9e,0xba,0xb5,0xad,0xf5,0x3d,0xe2,0xbc,0x5b,0xbb,0xc1,0xba,0x9f,0xc8,0x66,0xb6,0x2f,0x86,0x74,0x28,0x80,0xb7,0x4d,0xba,0xdb,0xb9,0xc6,0x38,0x4b,0x37,0xdc,0x73,0x59,0x4b,0x47,0xe1,0xbd,0x6e,0x18,0xa0,0xdf,0x84,0x39,0xa7,0x2b,0xb3,0x73,0x2e,0xa0,0x3,0x81,0x60,0x9c,0x6f,0x73,0xb7,0x1c,0xc8,0xb,0x20,0xf3,0xad,0x3a,0xf4,0x9c,0x78,0x3d,0x95,0x37,0x13,0x92,0xc6,0xf9,0xb,0x9d,0xf4,0x22,0x63,0x52,0xb7,0x3,0x78,0x3d,0xdb,0xbc,0x6d,0xe7,0x9f,0x1e,0xf8,0x6a,0xac,0x6d,0xa0,0xff,0x84,0x39,0xfb,0x4b,0xee,0x14,0x9b,0x69,0xfe,0x41,0x90,0x9a,0x2f,0x5b,0xc0,0xa4,0x9b,0xfe,0xcd,0x18,0xe7,0x96,0xd,0xf7,0x4e,0x7f,0xb7,0x23,0xf0,0x5e,0x37,0xc,0xd0,0xff,0xdc,0x9b,0x3f,0x65,0x5b,0xb6,0x3f,0x21,0xd9,0x4f,0x41,0x8,0x24,0xed,0xb6,0x95,0x56,0x65,0xde,0x25,0x55,0x53,0x3f,0xad,0x9c,0x26,0xe0,0x3f,0x14,0xf4,0x1e,0x26,0x75,0x3f,0x9d,0x86,0x9f,0xd2,0x49,0xaf,0xec,0xd1,0xfb,0x88,0x6d,0xc5,0x56,0xc2,0xfe,0x13,0x6f,0x3a,0xcc,0x66,0x9b,0xe7,0x40,0xee,0x18,0x0,0x5e,0xaf,0x15,0x24,0x3,0x8,0x24,0x8d,0xd3,0x70,0x13,0x4c,0xea,0xfb,0x1b,0xef,0x9d,0xf6,0x6a,0x7b,0xe3,0xdd,0xb4,0x77,0x6,0x6d,0x85,0x8d,0xf7,0x5c,0xf6,0xa,0x69,0x9a,0x3d,0x51,0x3b,0xc0,0x26,0xfd,0xb,0xa5,0x9,0x58,0xaa,0xa3,0x28,0xf7,0x6d,0x25,0xe0,0xa7,0x95,0x27,0x3e,0x94,0xcf,0xc0,0xd3,0x26,0xad,0x9b,0x3d,0xdb,0x6d,0xd9,0xf1,0x8c,0x6d,0xd9,0xfe,0xdc,0x96,0xd7,0x57,0x9f,0x11,0xfe,0xfc,0x88,0x73,0xe7,0x9e,0xec,0xb6,0xec,0xd8,0x28,0xeb,0x8e,0xf1,0xbe,0xf5,0xf1,0x2f,0x88,0xa0,0xcf,0x48,0xb4,0xd6,0x6d,0x99,0x66,0xb3,0x2d,0xf3,0xfb,0x4f,0x9c,0x7b,0x5c,0x7b,0xe3,0xbd,0x6e,0x7a,0x0,0x0,0xe8,0x77,0xce,0xcf,0x9e,0xb3,0x6e,0xe6,0x78,0x20,0x5a,0xfa,0xaf,0x3f,0x8,0x86,0x81,0x7c,0x61,0xfd,0x91,0x41,0x64,0xa0,0x5a,0x38,0x2b,0x4c,0xba,0xf1,0x3b,0x4,0x7a,0x66,0x5b,0x76,0x2c,0xf4,0xf8,0xbb,0xd5,0xb0,0x54,0xd0,0x4f,0x5,0x6a,0x26,0x8d,0x79,0x8d,0x4e,0xd3,0xbf,0xbd,0xb4,0x68,0xda,0x5d,0xed,0x55,0x3,0xa7,0xf6,0x24,0x92,0x83,0x8f,0xf,0x1c,0x9b,0x2,0x34,0x9c,0x40,0x8f,0x78,0xcb,0x4c,0x3d,0x41,0xd0,0x45,0xf9,0xe0,0xcb,0x2d,0xbe,0xd5,0x92,0x14,0x24,0xa2,0xb7,0x6c,0x76,0x82,0xac,0x7b,0x16,0x29,0x27,0x50,0x21,0x1,0x85,0xba,0xba,0x5c,0x37,0xe2,0xdb,0xbb,0x72,0x36,0xb0,0xbd,0x61,0xdd,0x13,0xf7,0x3f,0xf2,0xec,0x96,0x77,0xd6,0x2f,0xfe,0x5d,0x7b,0xd4,0xa0,0x6e,0x86,0x0,0xaf,0x34,0xce,0x12,0x0,0xef,0x7b,0xf7,0x86,0xf9,0x21,0x60,0x37,0xb9,0x8c,0xf1,0x94,0xc3,0x80,0x71,0x69,0x40,0xd2,0x90,0x6c,0x0,0xd4,0x0,0x18,0x79,0x17,0x8,0x18,0x45,0xa4,0xe1,0x31,0x81,0x31,0xfe,0x7b,0x3,0x40,0xfb,0x65,0x33,0xbb,0xbe,0xde,0x6f,0xc2,0x9c,0xaf,0xb4,0x7,0xca,0xeb,0xa6,0x7,0xe8,0x3f,0x71,0xee,0x4,0x4f,0x38,0x52,0x3f,0xf8,0xb6,0x9e,0xd0,0xe8,0xba,0xfb,0x5c,0x44,0xae,0xfd,0xe7,0xee,0x1,0xbf,0x67,0x80,0x7f,0x11,0xa1,0x77,0x45,0xdf,0x93,0xa1,0x74,0x82,0x1e,0x61,0x4f,0xca,0xe,0xea,0x35,0xe8,0x2c,0xe7,0x9d,0xf5,0x8b,0x97,0x26,0x89,0xf7,0xba,0x30,0x4,0xf5,0x9f,0x78,0xd3,0x2c,0x9b,0xdd,0x75,0x36,0xa0,0x3e,0xde,0x18,0x69,0x24,0x28,0x6c,0x0,0xde,0x1d,0x81,0x31,0xf7,0x6d,0x6,0x6f,0x14,0xf4,0x70,0x21,0xb0,0x1b,0xc8,0xee,0x49,0x17,0xb2,0xd3,0x19,0xe0,0xf0,0x73,0x66,0x3d,0xad,0x6c,0xcb,0x48,0x0,0xdd,0xbd,0x39,0x1e,0xdf,0x74,0x53,0xef,0xc3,0x7f,0x87,0x40,0xce,0xe4,0xd,0x1a,0x67,0xb5,0x71,0xd2,0xd7,0x27,0x9d,0x43,0x62,0xc,0x70,0xc4,0xb9,0x73,0x7f,0x24,0x61,0x1b,0x8d,0xf3,0xd3,0xd,0x77,0x4f,0x7d,0xbf,0x5c,0xfc,0x81,0x93,0xee,0xd8,0x23,0xdb,0xb2,0xe3,0x31,0xd9,0xec,0x9,0x5e,0x3f,0x97,0x13,0x80,0xbb,0x88,0xef,0x83,0x6f,0xc0,0x24,0xe9,0xbc,0x63,0x9c,0xf4,0xe2,0x75,0x3f,0xbf,0x38,0x71,0xb,0x61,0x22,0x98,0x3e,0xe2,0xbc,0x5b,0x47,0xd8,0xcc,0xce,0x7,0x25,0x75,0xa3,0x71,0xd6,0x80,0xe6,0x75,0xd2,0xfc,0x99,0xc6,0x99,0xb7,0xe1,0xee,0xa9,0x7f,0x2e,0x8e,0xdf,0xff,0xdc,0x5b,0xe,0x95,0xdb,0x72,0x87,0x6c,0x76,0x14,0xe9,0xab,0xc2,0x5e,0x4d,0xe1,0x49,0xc7,0x51,0xc5,0x8c,0x33,0xb9,0x87,0xe7,0x85,0x54,0xe2,0x9b,0x62,0x3,0x6f,0xb9,0xb4,0x63,0xb5,0xb4,0x88,0xf0,0xa8,0xef,0x2a,0x29,0x6f,0xeb,0x6f,0x72,0xbe,0x67,0x0,0x41,0xe7,0x91,0x74,0xd3,0x9e,0xe3,0xd7,0x2e,0x98,0xb2,0xb3,0x1a,0xfa,0x94,0x82,0x9a,0x19,0xe0,0x88,0xf3,0xe7,0xf5,0x50,0x76,0xc7,0xc3,0xb2,0xee,0x71,0x80,0x42,0x5a,0x85,0xd9,0x42,0x63,0xd6,0x80,0xce,0x4a,0x1a,0xe7,0x77,0x26,0x95,0x7e,0x74,0xdd,0x82,0x29,0x1f,0x1c,0x71,0xfe,0x6d,0x43,0x6c,0x66,0xd7,0x4d,0x90,0x7b,0x54,0xa8,0x18,0xc2,0x6e,0x3e,0xe0,0x27,0xa,0xca,0xd9,0x1c,0x9,0x3a,0xaf,0x9a,0x54,0xc3,0xbf,0x6f,0xb8,0xfb,0xd2,0x85,0xed,0x91,0x55,0xcd,0x43,0x80,0xdc,0xe6,0x1f,0xcb,0xba,0xbe,0xf1,0xc6,0x84,0xed,0xf0,0x7b,0xc9,0xba,0xa3,0x0,0x77,0x94,0xac,0x73,0x86,0xac,0x3b,0xae,0xff,0xc4,0xb9,0x7f,0x57,0xb6,0x79,0x38,0x64,0x8f,0xf2,0x6c,0xf4,0xb9,0x7e,0xdf,0x17,0xf8,0xca,0xb5,0xe0,0xb6,0x98,0xf5,0x2b,0x69,0x95,0xc5,0x3e,0x9f,0xe1,0xfb,0x72,0x71,0xdb,0x52,0xd6,0xf0,0x77,0x71,0xe5,0x2c,0xec,0x11,0x3c,0xe9,0x97,0xb9,0xf9,0x26,0x1a,0xe7,0xa9,0xc6,0x6e,0x3d,0xef,0xa9,0x95,0x4e,0x71,0x50,0x53,0xab,0x1b,0x70,0xfe,0x6d,0x5f,0xb0,0x99,0x9d,0xbf,0x90,0x37,0x8b,0x9f,0xa3,0x62,0x48,0x82,0x97,0x82,0x3c,0xa,0x3c,0xee,0x68,0x25,0x85,0xad,0xfd,0x5d,0xad,0x3f,0x4,0x9e,0x25,0x90,0x34,0x4e,0xea,0x45,0x3a,0xd,0xd7,0xad,0xbf,0xeb,0xe2,0xe7,0xda,0x2b,0xaf,0xaa,0x7b,0x80,0x81,0x93,0xee,0x38,0xd8,0xcd,0xec,0xfc,0xbe,0x2,0xa3,0x95,0xef,0x58,0xc5,0x90,0xff,0x4e,0xce,0x98,0x27,0x8,0x26,0x4f,0x64,0x8f,0xf8,0x7e,0xb7,0x5f,0xcd,0x5c,0x5d,0x12,0xf3,0x7b,0xd5,0xb0,0x5e,0xa9,0x6f,0x8a,0x1c,0xc7,0x2b,0xae,0x47,0xe1,0x77,0xde,0x9d,0x71,0xee,0x69,0x4f,0xe2,0x3,0x55,0x5a,0x2,0x7,0x4c,0x9a,0xd7,0x60,0x6d,0xf6,0x5a,0x59,0xfb,0x69,0x7f,0xf2,0xc6,0x9b,0x5d,0x2f,0x12,0xdf,0x73,0xcf,0x45,0xe3,0xbb,0x37,0xe7,0x91,0x73,0xac,0xa9,0x1c,0x2a,0xfc,0x46,0x2a,0xe8,0x9f,0x15,0xfc,0x13,0x50,0xe0,0x3e,0x20,0x95,0x49,0xa8,0xd4,0xc4,0x12,0x8b,0x7e,0x2b,0xad,0x7,0x8b,0x5f,0x30,0x5e,0x8e,0x4c,0x10,0x2a,0x66,0x80,0x81,0x17,0xce,0x77,0x20,0x3b,0xda,0x66,0x5b,0xae,0xcd,0x9b,0xc1,0xc3,0x53,0x76,0x9d,0x7b,0x29,0x34,0x43,0xe7,0xdf,0xfb,0x73,0xed,0x1e,0x81,0x25,0xd0,0x37,0x34,0xe4,0xae,0xe0,0x1d,0xa3,0x6d,0x73,0xf2,0xd3,0xca,0xdd,0xb7,0xff,0xe5,0x33,0xa9,0xdc,0x2f,0xc,0x98,0x74,0xc7,0xf1,0xed,0xc9,0x0,0x15,0xb7,0xbf,0x41,0x17,0xce,0xef,0x93,0x6d,0xd9,0xf9,0x0,0xac,0x3b,0xd2,0xeb,0xc0,0xe3,0x54,0xb7,0x4a,0x8a,0x50,0x4a,0x65,0x2,0x4a,0xb,0x5c,0x39,0xc8,0x77,0xa2,0xa,0xd4,0xa7,0x82,0xb4,0x3e,0x0,0xf9,0x3e,0x80,0x6d,0x0,0x76,0x92,0xdc,0x5,0xd2,0x42,0x8,0xe4,0x91,0x14,0x80,0x26,0x9,0xdd,0x20,0xbb,0xf,0xa0,0x5e,0x90,0x6f,0x2a,0x67,0x4c,0x1e,0x35,0x6b,0x2e,0x11,0xf5,0x93,0xe7,0x13,0x0,0xc2,0x42,0x32,0x34,0xce,0x93,0x26,0xd5,0x78,0xd9,0xba,0x85,0x17,0xbd,0x5a,0x5b,0x5e,0xa5,0x4b,0xd0,0x26,0x18,0x7c,0xc5,0x33,0xcc,0x7e,0xf8,0xea,0x19,0x36,0xb3,0xf3,0x21,0x0,0x16,0x81,0x12,0x1f,0xae,0x8a,0xe2,0x13,0x2d,0x18,0xf2,0x22,0x4,0xe7,0x3c,0xef,0x7,0xe6,0xaf,0xfc,0x87,0xad,0xc8,0xee,0x8b,0x1d,0xa,0xd6,0x8a,0x84,0xe6,0x66,0xfd,0x98,0x2d,0x34,0xce,0x3f,0x24,0xbc,0x4d,0x9a,0x4d,0x30,0x66,0x1d,0xc0,0x97,0x48,0xfe,0x15,0xe0,0x3b,0x20,0xdf,0x23,0xd4,0xec,0x5a,0x65,0xd2,0xe9,0x86,0x46,0xeb,0x66,0xba,0x1,0xd8,0xd7,0x5a,0xdb,0x7,0xd2,0x0,0xc9,0x8e,0x24,0x74,0xb0,0xa4,0x8f,0x1,0x3a,0x0,0xb2,0xfb,0x86,0xab,0xc2,0x90,0xcf,0x7a,0x1,0x33,0xa8,0x75,0x7d,0xa,0xe4,0xfd,0x8,0x33,0x40,0x41,0x13,0xa,0x3b,0xc6,0x7a,0x35,0xb2,0x74,0x1a,0xe6,0x34,0xef,0xdc,0x7e,0xd5,0x5f,0x1e,0xb8,0x3a,0xf1,0x15,0x48,0x15,0x9,0x81,0xee,0x96,0xbf,0xd,0x92,0xdb,0xf2,0x7d,0x80,0xa0,0x6f,0xb0,0xf7,0xb0,0x9f,0x9b,0xb7,0x40,0xde,0x23,0xab,0x88,0x82,0xb9,0xa7,0xd0,0xff,0x1c,0xc5,0x43,0x2c,0xc3,0xa8,0xc6,0xdb,0x2a,0x2c,0xb0,0x93,0x4,0x62,0x86,0xfc,0x29,0x78,0x80,0x7c,0xf,0x30,0x9b,0x4,0xb3,0x96,0x4e,0x6a,0x71,0x3a,0xd5,0xf0,0xe0,0xea,0x3b,0x27,0x95,0x33,0xa0,0xb4,0x0,0xd8,0xa,0xe0,0x2d,0x0,0x1b,0x1,0x3c,0x15,0xbc,0x18,0x30,0xe9,0xce,0x7e,0xb2,0x99,0x89,0x80,0x8e,0x83,0xec,0xa1,0x92,0x3d,0x8,0x42,0x63,0xa0,0xc1,0x7a,0x79,0x2a,0x50,0x79,0x42,0x66,0xcc,0xbc,0xab,0x40,0x58,0xd,0xca,0xd7,0x3b,0xa8,0x17,0xfc,0x70,0xbf,0x4a,0xfe,0xa,0x88,0xc0,0x30,0x26,0xc1,0x48,0xee,0x99,0x4d,0xdd,0xf7,0x5a,0xe,0xe0,0xf6,0xa4,0x19,0xa0,0xa2,0x1e,0x60,0xe0,0x5,0x77,0x9e,0xea,0x66,0x76,0x3e,0x26,0xc9,0x84,0xb1,0xdf,0x91,0x10,0xb2,0x15,0xcb,0xd7,0x32,0x7c,0xe,0xe0,0xfb,0x24,0xdf,0xa2,0x49,0xdd,0x6c,0x1c,0x67,0xf6,0xda,0x5,0x53,0xda,0xbc,0x48,0xa4,0xad,0x30,0x60,0xd2,0xbc,0x43,0x21,0xf7,0xbb,0x92,0x1d,0x29,0xeb,0x7e,0x2,0x52,0x93,0xbf,0x4c,0x2d,0xd4,0x10,0x12,0xad,0x6b,0xde,0xa7,0x91,0xce,0x12,0xa6,0xf6,0x38,0x75,0xfd,0xc2,0xb,0x9a,0x93,0xcc,0xa3,0x32,0x6,0x98,0x7c,0x57,0xa3,0xcd,0x36,0x9f,0x23,0xb7,0xe5,0x4e,0x40,0x4e,0xe0,0x80,0xd9,0x51,0xf6,0xfb,0x80,0xf8,0x61,0x84,0x4b,0xd8,0x49,0x60,0x87,0x49,0x37,0x7e,0x7b,0xdd,0xc2,0x8b,0x6e,0x6c,0xf7,0x42,0x0,0x18,0x30,0xf9,0xee,0x94,0x32,0xdb,0xe7,0xca,0xba,0xa7,0x1,0xda,0x3f,0xb7,0x78,0x25,0xef,0x26,0x98,0x38,0x42,0x24,0xb9,0x34,0xa9,0x7b,0x36,0xdc,0x3d,0xf5,0x82,0x24,0xd3,0xad,0x5c,0x8,0x9c,0xbc,0x70,0xf,0xeb,0x66,0x2f,0xb3,0xd9,0xe6,0x19,0xf0,0xc7,0x5b,0x4f,0x14,0xc8,0x69,0x57,0x25,0xd2,0x2c,0x67,0x15,0xb,0xc7,0x29,0xf2,0xe5,0xf7,0xa7,0x46,0xe1,0x59,0x19,0xe1,0x79,0xd2,0x3a,0x5b,0x61,0x9c,0xdb,0x68,0x52,0x5f,0x5f,0xbf,0x70,0x72,0x87,0xb9,0x52,0x7,0x30,0x70,0xf2,0xcf,0xbb,0xb9,0x2d,0xdb,0x97,0x41,0xb6,0x2f,0xc0,0x3d,0x2,0xe7,0x64,0x32,0xf0,0x48,0xe,0x44,0xa4,0x52,0xe,0xe6,0xc5,0x78,0x88,0x14,0x72,0x25,0x89,0xa0,0x59,0xed,0xa4,0x1a,0x3f,0xb7,0x6e,0xe1,0x94,0xb7,0xc2,0x2f,0x47,0x5e,0xb3,0x94,0x3b,0xdf,0x7b,0xc5,0xd0,0x69,0xa0,0xcd,0x6c,0x27,0x4d,0x9a,0x0,0xdd,0x75,0xb,0x2e,0x70,0xcb,0xd5,0xa1,0x2a,0x2e,0x1d,0x34,0xf9,0xe7,0x7b,0x58,0xb7,0xe5,0xdb,0x36,0xdb,0xf2,0x75,0x2,0x26,0x34,0xf0,0x33,0x69,0x57,0xae,0x70,0x97,0xf,0x8f,0xf8,0x2,0x0,0x63,0xcc,0x66,0xa6,0x1a,0xc7,0xae,0x5b,0x30,0x39,0x51,0x7,0x89,0x6a,0x60,0xc0,0xa4,0x79,0xd7,0xd9,0x6c,0xf3,0x37,0x0,0xed,0xcb,0xb0,0x47,0x50,0x72,0x26,0xab,0x80,0xe9,0x41,0x93,0x7a,0x7e,0xc3,0xdd,0x53,0x8f,0x1f,0x34,0xe5,0xee,0x46,0x9b,0x6d,0xa6,0x71,0x1a,0x9a,0x24,0xb7,0x2f,0xa4,0x8f,0x9,0xea,0x49,0xa0,0x87,0xa4,0x3,0x69,0x9c,0x17,0x20,0xf7,0xf9,0x75,0xb,0x2f,0xca,0x94,0x4a,0xbc,0xea,0xc2,0xd,0xbc,0x70,0x61,0x83,0x6c,0xf6,0xdf,0xe5,0xb6,0x7c,0x13,0x64,0xb0,0x20,0x23,0xbf,0xd8,0x22,0x49,0x8,0x98,0x4a,0x82,0xa4,0xac,0x71,0x52,0xcf,0x3b,0xd,0xdd,0xce,0x5e,0x33,0xef,0xbc,0xf,0x92,0xcf,0xac,0x5a,0x7c,0x2c,0x18,0x63,0xb3,0xbb,0xe6,0xc9,0xda,0x83,0x3d,0x43,0x17,0x3,0x49,0xbe,0xf6,0x6,0x91,0x5f,0xdc,0x2,0x1,0xbb,0x48,0xf3,0x1a,0xa4,0xde,0x80,0x7a,0x2,0x28,0xd2,0x81,0x82,0x7b,0xae,0x34,0xa9,0xc6,0xeb,0xd6,0x2d,0x9c,0xfc,0x54,0xa9,0xa4,0xab,0xf6,0x9,0x5c,0xb7,0xe0,0x82,0x16,0xa7,0xb1,0xfb,0x7f,0x99,0x54,0xe3,0x75,0x4,0xb2,0x8,0x69,0x33,0x89,0x9b,0x45,0x7c,0x24,0x90,0xcc,0x1a,0x27,0xfd,0xf0,0xfa,0xbb,0x2e,0x19,0x53,0x4f,0xc4,0xf7,0xf0,0x71,0xe1,0xd3,0x26,0xd5,0x78,0xa,0xe9,0x6c,0x40,0x41,0xd9,0x6b,0x77,0x6d,0x43,0xe1,0x6f,0x23,0x64,0xf,0x3,0xb4,0x17,0x8a,0xde,0x15,0xde,0x6b,0x88,0xa0,0x7f,0x29,0x57,0xee,0x9a,0x9c,0x42,0xd7,0xdc,0x3e,0x3e,0xeb,0x34,0x74,0x9f,0x69,0x52,0x4d,0x53,0x4,0xbe,0xdf,0x76,0x8b,0x60,0x18,0x4a,0x85,0x31,0xc7,0xd6,0x5e,0xbf,0x9f,0x7a,0x72,0xfd,0x5d,0x17,0x9f,0x95,0x18,0xd5,0x12,0x86,0x75,0xb,0x26,0xff,0xc9,0x34,0x34,0x9d,0x49,0xe3,0x2c,0xf7,0x2d,0x8e,0xfe,0xf0,0x15,0x26,0x63,0x31,0x59,0x4b,0x85,0x79,0xcf,0x7e,0x7,0x2b,0xd2,0xc8,0xf3,0x31,0xd,0x2e,0x8a,0x34,0xc1,0xd4,0x51,0x51,0x47,0x6c,0xc,0x81,0x4f,0x7e,0xea,0xc2,0x87,0x4a,0xf6,0x3e,0x35,0x7b,0x5,0xaf,0xbe,0xfd,0x9c,0x2c,0x53,0xd,0xf7,0x93,0xdc,0x51,0x64,0xa,0x29,0x1,0x51,0xcc,0x50,0x18,0x26,0xbf,0x1f,0x83,0xe7,0x2b,0x0,0xe3,0xa4,0x9f,0x6c,0x49,0xf7,0x3a,0xbd,0xdd,0xa8,0x97,0x10,0xac,0x9b,0x7f,0xc1,0x2b,0x26,0xd5,0x38,0x85,0xc6,0x59,0x82,0xfc,0xec,0x28,0xa2,0x99,0x1c,0x65,0xc2,0xf2,0xcf,0xcc,0xdb,0xa9,0xc3,0xef,0x99,0x7f,0x95,0x8b,0x27,0x4f,0x39,0x12,0xac,0xcd,0x9e,0xd7,0x9d,0x1f,0x4e,0x2c,0x55,0xde,0x44,0xdc,0xc2,0x6d,0x36,0xd3,0xf,0x40,0xda,0xa3,0x17,0x13,0x71,0xe7,0x26,0xd,0x5,0x58,0x6f,0x4a,0x3c,0xfd,0xa8,0x93,0x6e,0x1a,0xff,0xf2,0xbc,0xd3,0x77,0x8b,0xcd,0x98,0xd6,0xce,0xbf,0x60,0x23,0x4c,0x6a,0x16,0xe9,0xbc,0xec,0x4d,0x31,0x18,0xc9,0x53,0x97,0x6a,0xc6,0x4b,0x1b,0x2e,0x6,0xb3,0x6d,0x90,0xfa,0xca,0xaa,0x7f,0xfb,0x33,0x80,0x9b,0x99,0x1,0x70,0xdf,0x9a,0x13,0x2a,0x4,0x1,0x34,0x34,0xce,0x5a,0x9a,0xf4,0xd,0x6b,0xe6,0x9d,0xf7,0x61,0x7b,0x11,0xac,0x3d,0x60,0xfd,0xc2,0xc9,0xf7,0xc0,0xa4,0x6e,0x7,0xb9,0xcd,0xb7,0x57,0x75,0x98,0xd1,0x2c,0xbc,0x48,0x56,0x50,0x8f,0x52,0x71,0x6b,0x66,0x80,0x23,0xa7,0xdc,0xb5,0x17,0x60,0x87,0x92,0x48,0xe5,0xf5,0xde,0x44,0xc4,0x1e,0x92,0xdc,0x42,0x93,0x5a,0xb0,0x76,0xfe,0xa4,0xc7,0x3a,0xa,0x79,0x49,0x82,0x31,0xce,0x2c,0x9a,0xd4,0xbd,0xbe,0x8d,0x3a,0x98,0x25,0x69,0xf7,0x19,0xc5,0x80,0xf8,0xbe,0xf6,0x7c,0xe4,0xc0,0xc9,0xb,0x87,0xc4,0x96,0xb1,0x96,0xa,0x1e,0x7d,0xed,0xef,0x8,0x72,0x38,0x80,0xb4,0x97,0xa1,0xd7,0xcd,0xd5,0xd2,0x83,0xf9,0x5,0xf7,0x2a,0xe0,0xa4,0x1e,0x0,0x4d,0xe2,0xf6,0xef,0x8e,0x82,0xb5,0xf3,0x27,0x6d,0x31,0x4e,0xfa,0x36,0x18,0x67,0x29,0xfc,0x3e,0xd9,0x9f,0xe9,0xab,0xc,0x27,0x11,0xf7,0x88,0x9,0xf7,0x47,0x1,0xff,0x3f,0x1,0x6b,0x4f,0x80,0x74,0x76,0x5c,0x19,0x6b,0x62,0x80,0x6d,0xff,0xd8,0x48,0xeb,0x66,0xcf,0x25,0x4d,0xca,0x2f,0x51,0xcd,0xeb,0x79,0x7c,0x75,0x9f,0xa0,0x79,0x15,0x30,0xf7,0xaf,0x9b,0x3f,0xa9,0xa2,0xdd,0xbf,0xea,0xd,0xd6,0xde,0x79,0xfe,0xb,0x34,0xa9,0xc5,0x0,0x0,0x1a,0x11,0xac,0x58,0x31,0x64,0xc4,0x3d,0x63,0xc2,0x8b,0xf0,0x28,0x92,0xd,0x24,0xfa,0xc6,0x95,0xaf,0x26,0x6,0x58,0x7f,0xd7,0xc5,0x56,0x6e,0x76,0x2c,0xa0,0x34,0x69,0xc2,0x5b,0xaf,0x54,0x7e,0x91,0x81,0xe4,0xef,0xf5,0x22,0xc6,0x59,0x44,0x63,0x1e,0xef,0x6c,0x2,0x26,0x1,0xa4,0x59,0x4c,0x93,0x7a,0x12,0xfe,0x7e,0x46,0x28,0x35,0xc,0xb0,0xb6,0x6,0x54,0x98,0x16,0x82,0x6e,0xb5,0xf1,0xd3,0xe3,0xe7,0x46,0xd2,0xba,0x26,0x6,0x18,0x74,0xd1,0x3d,0x7d,0x41,0xf4,0xf6,0xc4,0x76,0x28,0xa7,0xf2,0x56,0x39,0xec,0xfb,0x92,0x3f,0x49,0xf3,0x16,0x8d,0xf3,0xd4,0xda,0x3b,0xcf,0xdf,0xde,0xd9,0xc4,0x4b,0x2,0xd6,0xde,0x79,0xfe,0x5a,0x3a,0xa9,0xf9,0x5e,0x25,0x73,0xe,0x1f,0x25,0xc4,0x9f,0xda,0x2f,0xcf,0xaf,0xc4,0x50,0x9e,0xf5,0xb4,0x67,0x63,0xb7,0x1e,0x7,0x46,0x95,0xad,0x6a,0x6,0x18,0x7c,0xc9,0xfd,0x29,0x59,0x3b,0xa,0xa0,0x4d,0xa2,0xe4,0x81,0x1,0x3,0x20,0x68,0x9c,0xf9,0x34,0xce,0x8a,0xce,0x26,0x5c,0xa2,0x40,0xf3,0x57,0xd2,0xbc,0x8b,0x76,0x76,0x9f,0xb,0x5c,0xe2,0xfc,0x1d,0x67,0xe0,0x73,0xc3,0xc1,0x10,0x3e,0x1d,0x55,0xac,0xaa,0x19,0x60,0xf5,0x6d,0x67,0x67,0x9,0x7d,0x26,0x34,0xd3,0x55,0x93,0x9a,0xc3,0xdc,0x46,0x4e,0x0,0x4d,0x6a,0xd9,0x9a,0x3b,0x26,0xee,0xd6,0x63,0x7f,0x31,0x18,0x63,0xd6,0x9b,0x54,0xc3,0x6c,0xff,0x51,0x91,0x5b,0x91,0xd7,0x0,0x85,0x3e,0x9,0x9e,0x22,0xe8,0xd,0xa5,0xe6,0x15,0x3a,0xa9,0xfb,0x49,0xf3,0x46,0xd4,0x77,0x6d,0xf6,0x8,0x1a,0x74,0xd1,0xdd,0x4d,0xa4,0xb3,0xbf,0xac,0xed,0x2b,0xe8,0x40,0x2,0x7b,0x43,0xee,0x98,0xdc,0x86,0x8d,0xc9,0xa8,0xb9,0x24,0xb9,0x9,0xe0,0xa6,0x24,0x91,0x53,0xf,0xb0,0xfa,0xf6,0x9,0x9b,0x7,0x7f,0x71,0xd1,0x43,0x0,0xfe,0x3,0x0,0x61,0x12,0x30,0xc1,0x84,0x26,0x80,0x48,0x12,0xb2,0xca,0xeb,0x1,0x7c,0x97,0xc6,0x79,0x96,0x74,0x16,0x64,0x65,0x16,0x6f,0xb8,0x73,0x42,0x36,0x2a,0x89,0x58,0x6,0x18,0x74,0xd1,0xbd,0x3d,0x21,0x1d,0xe,0xe8,0x40,0x90,0x7b,0x41,0xea,0x25,0x65,0x8f,0x90,0x75,0x8f,0x83,0xf4,0xe9,0x60,0xe1,0x7a,0x68,0x51,0x67,0xad,0x1e,0x31,0x9e,0x3b,0x21,0x53,0x33,0x4,0xac,0x69,0x2f,0x42,0x74,0x26,0x8,0xb0,0xa0,0x79,0x1f,0xd2,0x3e,0x9,0x35,0x97,0xc0,0x21,0xc7,0x73,0x8e,0x1,0x29,0x70,0x33,0xc9,0x55,0x34,0xa9,0x87,0x8c,0x93,0x9a,0xbf,0xfa,0xf6,0xf1,0x9b,0x4b,0x25,0x11,0xc9,0x0,0x83,0xbf,0xb8,0x68,0x7f,0x2b,0xf7,0x7c,0x59,0x77,0x3a,0x64,0xf,0x2f,0xcc,0x33,0xa7,0xb0,0x7b,0x4e,0xa,0xf0,0xf9,0xad,0xb6,0x1e,0x20,0x67,0x2c,0x37,0x8e,0xf3,0xfc,0x9a,0x3b,0x26,0x6e,0x4b,0x8,0xe7,0x75,0x5,0x92,0xb6,0x3,0xf8,0x33,0x80,0x91,0x40,0xa2,0xdb,0xd7,0x51,0xe0,0x3f,0xe8,0x38,0xaf,0x11,0xe6,0x41,0x90,0x3f,0x5d,0x3b,0xef,0xdc,0x36,0x9,0xd0,0x31,0x3d,0x80,0xc6,0xcb,0x75,0xbf,0x5,0xe8,0x63,0x60,0xd8,0xf1,0xb3,0xc0,0x41,0x23,0x34,0x3f,0xd1,0x26,0xb7,0xed,0x92,0x15,0xc8,0xff,0x7c,0x74,0xd7,0x86,0x93,0x7c,0x1b,0x26,0xf5,0x88,0x6c,0x76,0x24,0x22,0x5d,0xca,0x83,0xa0,0x72,0x4b,0x90,0x82,0x77,0xca,0xe1,0x8d,0x4e,0xfa,0x47,0xae,0xab,0x19,0x1b,0x16,0x9c,0x57,0xd6,0xb,0x28,0xc,0x91,0x3,0x91,0x80,0x5e,0x0,0x1a,0xbc,0x42,0x7b,0x53,0x8f,0x79,0xe9,0xd2,0x14,0x49,0xb1,0x40,0xe9,0xe7,0x8a,0x6c,0x1,0xbb,0x4,0x54,0x54,0x81,0xdd,0x9,0xd6,0xdc,0x31,0xe1,0x7d,0x1a,0xe7,0x49,0x1f,0x47,0x11,0xb6,0x80,0x0,0x8a,0x9f,0x11,0xf3,0x2e,0xf7,0xed,0x7,0x80,0xb9,0xad,0x52,0xe2,0x3,0x31,0x3d,0x80,0x64,0xf,0x0,0xb0,0x97,0x37,0xbf,0xac,0xfc,0xc6,0x36,0xde,0x5b,0x54,0xd6,0x73,0xb5,0x69,0x95,0x6c,0xb0,0x2e,0xe7,0x1d,0x82,0x1d,0xee,0xdb,0xd7,0x91,0x40,0xf2,0x3d,0x1f,0xaf,0x3e,0x46,0x8b,0x5b,0x7d,0x2e,0x66,0x4c,0xa,0xa1,0xb5,0x29,0xc1,0xa2,0x8,0xc3,0xb4,0xe3,0x38,0x4d,0xd5,0x94,0x27,0x7a,0x8,0x10,0x7a,0xe6,0xed,0xcb,0xc5,0x63,0x55,0xa5,0x3d,0x74,0xb9,0xf8,0x61,0x2c,0xf0,0x75,0x10,0x89,0xbb,0x73,0xd7,0x15,0xd0,0x8,0x84,0x65,0x68,0x51,0x4d,0x8,0xf,0x6d,0x49,0x20,0x7f,0x97,0x1f,0x2d,0x53,0x81,0x3c,0x56,0x29,0x44,0x32,0x0,0x8d,0x69,0x90,0x6b,0xbd,0x1d,0x2c,0x3b,0x60,0x1a,0x33,0xe7,0xf2,0x47,0xf3,0x6,0xc0,0x8f,0x34,0x3,0x10,0x70,0x9,0xbe,0x2f,0x69,0xbf,0x4,0x51,0x9b,0xaa,0x56,0x9c,0x4c,0x68,0x9f,0xc0,0x72,0xe3,0x15,0x4b,0xbe,0xf3,0x1a,0x3,0x41,0xf2,0x4d,0x48,0x1f,0x69,0x6,0x10,0xe0,0xa,0xfc,0xb0,0xd0,0xc1,0x27,0x6a,0xfc,0x8f,0xc3,0x1d,0xc3,0x69,0xe5,0xce,0x2f,0xaa,0xd6,0x1b,0x37,0x46,0xb,0xc8,0xa9,0x7a,0x68,0xd5,0xfb,0xc7,0xa,0xf8,0x8c,0x7e,0x9f,0xb,0x63,0xc9,0xef,0xe5,0x2f,0xa2,0xfb,0xe8,0xea,0x0,0x7e,0x3d,0x73,0xf5,0x67,0xcc,0x6f,0x14,0xc4,0x31,0x41,0x58,0xbe,0xaa,0xe,0x71,0xd1,0x43,0x0,0x0,0x5,0xd4,0x8a,0xcc,0x3b,0x1c,0xa8,0x88,0xf7,0x25,0xca,0xcf,0xf0,0x4d,0x78,0x55,0x2c,0x1,0xe0,0x0,0xd0,0x54,0x25,0xcc,0xec,0x2e,0x40,0xd2,0x11,0xb0,0x77,0x69,0x7a,0x85,0x9,0x1c,0x77,0xf,0xd0,0x3f,0x5b,0x43,0x82,0x6b,0xad,0xad,0xca,0xb4,0x1c,0xad,0x5,0x0,0x2d,0x79,0xcb,0x5e,0x39,0x83,0x45,0x2d,0x4d,0xb6,0x90,0x91,0x8,0xf4,0x21,0xf9,0x91,0x67,0x0,0x92,0xfb,0xb4,0x6d,0xb9,0x0,0xdb,0x78,0xaf,0x6c,0xb5,0x64,0x88,0x1e,0x2,0xc8,0xf,0x19,0xd8,0xaa,0xb,0x8e,0xef,0x8,0xfa,0xe8,0xfc,0x26,0x56,0x5e,0x9c,0x10,0x8f,0x94,0xdd,0x46,0xa5,0x88,0x9f,0x7c,0x63,0xa6,0x9f,0xcf,0x81,0x0,0x1a,0x13,0xc1,0x74,0xdd,0x82,0xf2,0x7b,0xa9,0x28,0x68,0x5f,0xc5,0x50,0xac,0x71,0x17,0xf5,0x94,0x2c,0x5a,0x73,0xe,0x66,0x43,0x1b,0x74,0x55,0x4,0x91,0x42,0x20,0x61,0xde,0x20,0xb8,0x85,0xe1,0x15,0x27,0x40,0x91,0x5c,0x10,0xb2,0x7,0x15,0xcb,0x9,0xa5,0x64,0xc2,0xe2,0x97,0x21,0x9b,0xa2,0xa4,0x8f,0xeb,0x23,0xcf,0x0,0xec,0x5,0x20,0xd8,0x53,0x0,0x28,0x25,0xf4,0x15,0xc,0x97,0x21,0x9c,0x7,0x32,0x9a,0x2f,0x48,0x12,0xcc,0x0,0xa8,0xea,0xd0,0xa9,0x18,0x4b,0xa0,0xde,0x2,0xd9,0x82,0x60,0xc1,0x81,0xc7,0xb6,0x8,0x76,0x44,0x60,0x3b,0xfc,0xf9,0x5a,0x40,0x13,0xeb,0x68,0x3,0xeb,0xa4,0x61,0xf0,0xd4,0x5f,0xed,0x6b,0xad,0x7b,0x8a,0x8f,0x57,0x26,0x85,0x3b,0x49,0x7b,0x3,0xfa,0xe6,0xe0,0x8b,0x7f,0x51,0xb1,0x56,0x17,0xed,0x26,0xe4,0xa4,0x1e,0x4,0x9d,0x6f,0xd3,0x38,0xcf,0x6,0x3e,0x5a,0xde,0xaf,0xaf,0xaf,0x3,0x40,0xfe,0x8,0xc7,0x3c,0x37,0x16,0x34,0xee,0x98,0x6e,0x20,0x1c,0x3f,0xb0,0x68,0x41,0xa2,0x31,0x5,0x61,0x1f,0x45,0x20,0x4d,0x2f,0x40,0xa7,0xe5,0x10,0x17,0x65,0xd5,0xcd,0xbd,0x63,0x99,0x9e,0x34,0x7f,0x43,0x43,0xc8,0xba,0x97,0x3,0x7c,0x7a,0xf0,0x25,0xf7,0xfd,0xf7,0xe0,0xa9,0xf,0xec,0xdd,0xe6,0x32,0xc5,0xbd,0x18,0x3c,0xf5,0x57,0xdd,0x1,0xf6,0x85,0xec,0x41,0x20,0x7a,0x43,0x38,0x4,0xd0,0x27,0x25,0x7b,0x24,0x81,0x81,0xf0,0xe7,0xa,0x80,0xf0,0x36,0xaf,0x35,0x51,0xcf,0x3f,0xf,0x32,0xf5,0x75,0xe3,0xa4,0x6f,0x5c,0x75,0xf3,0xbf,0xb6,0xf9,0x4,0xae,0xdd,0x5,0x86,0x5c,0xfa,0xc0,0x30,0x9b,0x6d,0xf9,0xd,0x80,0xbd,0x93,0x30,0x2,0x85,0xf6,0xc7,0x9,0x6f,0xba,0xb9,0x85,0x34,0x2b,0x5,0x3e,0x44,0x63,0xee,0x5c,0x7d,0xeb,0x59,0x25,0xf,0x9f,0x6a,0x73,0x29,0x86,0x5d,0xfe,0x70,0xf,0x6b,0xdd,0x7d,0x65,0xed,0x1,0x34,0x66,0x7f,0x59,0xdb,0xb,0x72,0xaf,0x96,0x6c,0xff,0xd6,0x66,0xcd,0x1a,0x2a,0x44,0xbe,0xe9,0x38,0xd,0x13,0x56,0xdd,0x32,0xf6,0x85,0x24,0xd2,0xac,0x27,0x18,0x3c,0xf5,0x57,0x23,0xe5,0x66,0x5e,0xf4,0x77,0x15,0x49,0x62,0x15,0x7d,0xab,0xa3,0x66,0x82,0xd3,0xc7,0x4,0x6c,0x26,0xcd,0xb,0x34,0xce,0x42,0xc7,0x98,0xfb,0x56,0xde,0x3c,0x36,0x72,0x99,0x78,0x9b,0x3d,0x82,0x56,0xce,0x3d,0x63,0x2b,0xbc,0x7d,0x74,0x5e,0xb,0x55,0x68,0x20,0x2d,0xfa,0x79,0x25,0x49,0x64,0xd3,0x2c,0x1,0xe8,0x63,0xa5,0x83,0x6a,0xc5,0x4c,0xbd,0xc1,0xd0,0xcb,0x16,0xef,0x67,0x6d,0x76,0x9c,0x3f,0xcc,0x55,0x61,0x62,0x8f,0xd4,0xc6,0xb,0xf4,0xe8,0xd0,0xbe,0x8c,0x22,0xb0,0x2f,0xa0,0x33,0x61,0xdd,0xc1,0x2e,0x30,0x74,0xf0,0xd4,0x7,0x17,0xac,0xbe,0x75,0xec,0xba,0xe2,0x4,0xaa,0x6e,0xb9,0xc3,0xa6,0x3f,0x96,0x32,0x34,0xbf,0xf7,0x48,0xef,0x2f,0x45,0xaa,0x68,0xf6,0x37,0x34,0xce,0xf9,0xaa,0x65,0xde,0xb1,0x44,0x9f,0x19,0x7a,0xd9,0x83,0xfb,0x77,0x14,0x71,0x3a,0x6,0x34,0x0,0xd6,0x9d,0xee,0xf,0x94,0x2c,0xa8,0x7b,0x9b,0xfc,0x44,0x59,0x6,0x87,0x41,0xfb,0xcb,0x9d,0x5b,0x24,0x6f,0x22,0x4f,0x9f,0x80,0xec,0x38,0x52,0x7d,0xa2,0x4a,0x55,0x35,0x3,0xac,0x9c,0xf3,0xf9,0xac,0x80,0x17,0xe0,0x9f,0xa3,0x5a,0x9d,0xdc,0x9f,0x2f,0xb7,0xa7,0x6d,0x4,0x9a,0x86,0xbd,0x40,0xc2,0x88,0xce,0x26,0x59,0x92,0x20,0xd9,0x43,0x1,0xec,0x7,0x50,0x85,0xcb,0x3b,0xc2,0x78,0xa8,0x1c,0x87,0x28,0xfe,0xb6,0x50,0xbb,0xa0,0xdf,0xad,0xbe,0x4a,0xe3,0x6c,0x8c,0x2a,0x57,0x4d,0x63,0xf7,0x1f,0x6e,0x19,0xfb,0x2a,0x8d,0x79,0x33,0x98,0x32,0x8e,0x76,0x74,0x8d,0x9a,0xf4,0x88,0xb3,0x6d,0x53,0x0,0x5,0xe9,0xe3,0xb2,0xf6,0xe4,0x21,0x97,0x2d,0xee,0xd9,0xb9,0x64,0x4b,0x6,0x6,0x5f,0xfa,0xe0,0x60,0x59,0x4d,0xf6,0x55,0xdd,0xdc,0x36,0x37,0x49,0x40,0xac,0xd7,0x40,0xce,0x96,0xf,0x10,0xdc,0xd2,0xd0,0xfd,0x63,0xaf,0x47,0xc5,0xab,0x89,0x1,0x6,0x5f,0x72,0x9f,0x1,0xcc,0x3,0x2,0x32,0x2,0x90,0x53,0xe5,0xa,0x2e,0x14,0x75,0x61,0xc5,0x5d,0x5f,0x41,0x78,0x9e,0x71,0xa1,0xf1,0xb2,0xf6,0xd4,0xc4,0xa9,0xd1,0x9,0x40,0xe0,0xc,0xc0,0x8e,0xf1,0x1c,0xab,0x0,0x76,0xc0,0x89,0x68,0x34,0x39,0x5f,0x3e,0x90,0x66,0x57,0xf1,0x9,0xa6,0x1,0xd4,0xc4,0x0,0xd,0x3d,0x7a,0xb,0x34,0xf7,0x4a,0xc8,0xfa,0x54,0x8c,0x98,0x19,0x2a,0x35,0x25,0x5c,0x1c,0xb7,0x60,0x37,0xb0,0x83,0x49,0x9d,0x3d,0xe4,0xd2,0x87,0x7a,0x77,0x36,0x1,0x6b,0x81,0x21,0x97,0x3e,0x74,0x2,0x64,0xc7,0xe6,0x25,0xff,0xf0,0xa,0xea,0xb6,0xe0,0xaa,0x54,0x58,0xdc,0xb7,0x61,0x13,0x2d,0x77,0xd1,0x98,0x57,0xe2,0xca,0x57,0x13,0x3,0x2c,0xfb,0xe9,0xb1,0xa2,0x71,0x56,0x80,0x39,0x37,0x2e,0x86,0x57,0xf8,0xb4,0x86,0x52,0x52,0x8e,0xf7,0x3e,0xef,0x2e,0x45,0x48,0x1a,0x7,0xe0,0x92,0x76,0xa0,0x4b,0x87,0xc0,0xb0,0x69,0x8f,0xf4,0x4,0xf4,0x45,0x49,0x47,0x7b,0x92,0xbf,0x9,0x26,0x4f,0x22,0xf0,0x11,0x87,0xab,0x52,0x61,0xb1,0xd,0xcb,0x77,0x15,0x20,0x40,0x2e,0x91,0x70,0x7f,0x5c,0x19,0x6b,0xd6,0xdf,0x57,0xcd,0x3d,0x7d,0xab,0x31,0xce,0x8b,0x20,0x4b,0xc,0x3,0x95,0x76,0x5f,0x26,0x30,0x3e,0x76,0x87,0xec,0x85,0x43,0x2e,0x7d,0x68,0x6c,0x47,0x10,0x2c,0x69,0x90,0xb5,0x57,0x49,0xf6,0xdc,0xd0,0xce,0x1d,0x55,0xe2,0x4,0x95,0xc6,0xb,0xe5,0x65,0x56,0xff,0xe1,0x96,0x33,0x63,0xd7,0x59,0x24,0x62,0xc0,0x31,0x4e,0xea,0x1a,0x0,0x9b,0xdb,0xd2,0xc9,0xc7,0x89,0x7f,0x45,0xcf,0x7e,0x55,0x68,0x25,0xdb,0x1f,0xd0,0x15,0xc3,0xa7,0x3f,0xba,0x17,0x76,0x23,0x18,0x7a,0xf9,0xc3,0x17,0xc9,0xba,0x97,0x90,0xec,0xe6,0x1f,0x22,0xdb,0xca,0x15,0x24,0xa,0x3f,0xa5,0xde,0xb0,0x8d,0xf1,0x82,0x85,0x96,0xfe,0x53,0xc9,0x35,0x16,0xc9,0x30,0x80,0x49,0xfd,0x15,0x60,0x16,0x2c,0xa7,0xb4,0xb4,0x56,0x78,0xe2,0x9e,0x7d,0x7f,0x44,0x43,0x1a,0x40,0xfa,0xbc,0xeb,0x66,0xef,0x4e,0x88,0x36,0xed,0xe,0xc3,0xa6,0x3d,0x72,0x34,0x64,0xaf,0x4,0xd1,0x97,0x9e,0xda,0xc7,0xb0,0x7a,0x86,0x12,0xf8,0x29,0x3b,0x61,0x56,0x3e,0x9e,0x48,0xe3,0xef,0x4b,0x65,0x5e,0x26,0xcd,0xba,0x52,0x65,0xad,0x99,0x1,0x86,0x5f,0xf1,0x44,0xca,0x75,0x33,0x17,0x93,0xdc,0xb3,0x60,0x82,0xa3,0xc6,0x8b,0x86,0x14,0x4,0x1a,0x7a,0x9b,0x2b,0xc9,0x9e,0x36,0xf4,0xf2,0xc5,0x8b,0x3b,0x9b,0xb8,0xe5,0x60,0xd8,0xb4,0x47,0x87,0x59,0xd7,0x9d,0x2b,0xd9,0x91,0xb9,0x63,0x71,0x88,0xa,0x8d,0x64,0x85,0x97,0x2,0xa5,0x2e,0x3e,0x9d,0x70,0x78,0x4e,0x93,0x22,0x9d,0x7b,0xff,0x70,0xf3,0xbf,0xfe,0xb2,0x54,0x79,0x6b,0x62,0x80,0x61,0x57,0x3c,0x9e,0x92,0xcd,0x5c,0x27,0xeb,0xde,0x0,0xa0,0x67,0xc1,0x92,0xe4,0x4,0x2e,0x7f,0xdf,0x3b,0xfa,0x27,0x8c,0xc1,0xba,0xf6,0xb3,0x43,0x2e,0x5b,0x7c,0x7f,0x65,0xa5,0xec,0x38,0x18,0x7a,0xf9,0xa3,0x43,0x25,0xf7,0x2e,0x40,0x47,0xfa,0x36,0xd,0x86,0x7e,0x6b,0xc1,0x3,0xbd,0x65,0xfe,0x8,0x7e,0xc3,0x57,0xee,0x14,0x94,0xf0,0x5,0xc0,0xa5,0xe1,0xdf,0xca,0x95,0xb9,0x6a,0x6,0x18,0x7a,0xf9,0xa3,0xd,0x72,0x33,0xdf,0xb3,0xae,0xfb,0xdf,0x0,0xd3,0x5e,0x68,0xb4,0x64,0x5f,0x9d,0x2a,0xd3,0x3a,0xdc,0x18,0xa6,0x21,0x9d,0x39,0xe4,0xd2,0x87,0x7e,0x3b,0xf4,0xf2,0x47,0x92,0xde,0x95,0xac,0x26,0x18,0x36,0xed,0xb1,0x93,0xad,0xcd,0x3c,0x28,0xab,0xc3,0xa,0xd7,0x52,0x94,0xd2,0x7a,0xe2,0x70,0x81,0xd6,0x71,0xf3,0x9a,0xdd,0x2e,0x92,0x1b,0x40,0xf3,0xa6,0x84,0x5d,0xa,0xb6,0x53,0x4,0x43,0x62,0x86,0x27,0xfc,0x9,0x6c,0x75,0x68,0x67,0x31,0x54,0xc5,0x0,0xc3,0xaf,0x78,0xbc,0x1b,0xa0,0x1f,0x59,0x6b,0xaf,0x3,0xe1,0xd0,0x10,0xc1,0x21,0xc7,0x85,0x2b,0xc7,0xa2,0x18,0x9f,0x45,0xe1,0xcc,0x8b,0x2b,0x5,0x78,0x8,0xb8,0x9f,0xa1,0x74,0x9,0x10,0x46,0xd0,0xd1,0xd6,0xba,0x2f,0xf,0xb9,0xfc,0x91,0xe3,0x3a,0x8c,0xc2,0x25,0x60,0xc8,0x65,0xf,0xff,0xa7,0xb5,0xd9,0x45,0x24,0xf,0xa,0xd4,0x6f,0x1a,0xe3,0xf9,0x39,0x17,0x8a,0x3f,0x85,0xf5,0x46,0xc,0x2e,0xa,0xf1,0x26,0x3f,0x2e,0x7d,0x7c,0xac,0x5c,0x75,0xf3,0x99,0x3,0x8d,0x93,0xfe,0x94,0x49,0x35,0xee,0x63,0x52,0x4d,0x4d,0x26,0x95,0xee,0x63,0x9c,0xf4,0x20,0x3a,0xe9,0xd1,0x74,0xd2,0x67,0xd1,0x38,0x5f,0xa6,0x71,0xbe,0x44,0xf0,0xd9,0x72,0x65,0x2f,0x27,0xb8,0x47,0x10,0xff,0xd7,0x7b,0xca,0xda,0xaf,0x4a,0xf6,0x3b,0x8,0x56,0xa3,0xb0,0xd2,0x95,0xae,0x55,0x2d,0x8c,0xf5,0xd8,0x5b,0x62,0xc8,0xb9,0x70,0x2b,0x68,0x1e,0x4b,0x77,0xdb,0xe7,0xbc,0x17,0x67,0x1c,0xd3,0xe1,0x9b,0x48,0xe,0xbf,0xe2,0x89,0x46,0xeb,0x66,0xd6,0xca,0xba,0x7,0x91,0xdc,0x23,0x98,0x92,0x87,0xc4,0x44,0x71,0x12,0x78,0xe8,0x92,0xab,0x40,0xe7,0xe4,0x95,0x73,0x3e,0xf7,0x7e,0x71,0x94,0xa3,0xbe,0xf2,0x5b,0xb6,0x6c,0x7b,0x97,0x4e,0xba,0x81,0xb2,0xd6,0x48,0xd6,0x5d,0x35,0xf7,0x8c,0xb2,0x47,0xcc,0x54,0x44,0x85,0xa1,0xd3,0x1e,0xed,0xe,0x60,0x32,0xac,0x9d,0x5,0xf8,0x67,0xff,0xa1,0xe3,0xf,0x8c,0x40,0xe1,0x3c,0x78,0xb,0xc8,0xb7,0x4,0xde,0xea,0x66,0xb3,0xd7,0xaf,0xb9,0xf5,0xcc,0x4c,0xd,0x59,0xb4,0x9,0x86,0x5c,0xfe,0x48,0x9a,0xc0,0x22,0x12,0x47,0xc9,0xda,0xdc,0x2c,0x1b,0x2b,0x26,0x7a,0x25,0x55,0x46,0x56,0xe0,0x5d,0xab,0xe6,0x9e,0x3e,0x25,0xc9,0xba,0x54,0x54,0xd8,0x61,0xd3,0x1e,0x3b,0x49,0x72,0x7f,0xe3,0x89,0xb5,0x1e,0x9b,0xb7,0x4a,0x2d,0xee,0xec,0x87,0x70,0xcc,0xb8,0xc5,0x23,0x2c,0x8a,0xab,0xc8,0x38,0x91,0xa7,0x83,0x49,0xda,0x4a,0x9a,0xd7,0x40,0x2e,0x2,0xcc,0x4f,0x56,0xce,0xf9,0x6c,0xe2,0x1e,0x45,0xc3,0xaf,0x78,0x7c,0xa8,0xb5,0xee,0xb5,0xde,0xde,0x48,0x3a,0x88,0xa4,0xbf,0x3f,0x62,0x20,0xaa,0x7b,0xc7,0x27,0xb6,0xaa,0x53,0xb8,0x2e,0x51,0x38,0x2a,0xf6,0xa4,0x2e,0xc4,0x97,0xbf,0xf,0x3,0x9f,0x4d,0x35,0x34,0x7d,0x6e,0xd9,0xcf,0x4e,0x4a,0xf4,0xc8,0x98,0x8a,0xe,0x8d,0x12,0xf0,0x16,0xc0,0x55,0x20,0x86,0x12,0x85,0x47,0xb7,0x14,0x54,0xa8,0x18,0xca,0x59,0x7f,0xc2,0x61,0x2c,0xfb,0x5d,0x1e,0xb5,0xb9,0x19,0x70,0x89,0x64,0xf,0xc9,0xe,0x84,0x78,0x10,0xa9,0xb,0x87,0x4e,0x7b,0x74,0x29,0xc0,0xc5,0x0,0x9f,0x58,0x75,0xd3,0xe7,0x3e,0xac,0x16,0x41,0x43,0xa7,0x3d,0x76,0x24,0x81,0x33,0x41,0x9c,0x62,0xdd,0xec,0x27,0x1,0xf4,0x26,0xd1,0xe4,0x17,0x26,0xe7,0xa,0x17,0xb9,0x8c,0x92,0x6d,0xb8,0x8f,0x7f,0xe,0xed,0xba,0xc2,0xd7,0x68,0xcc,0x6d,0x49,0x13,0x3f,0x8e,0x14,0x25,0x61,0xd8,0xf4,0x5f,0x9f,0x2e,0xeb,0x3e,0xc,0x44,0xad,0x70,0xed,0x70,0x28,0x68,0x57,0xa1,0x1d,0x4b,0x20,0xa9,0x19,0xe4,0x3f,0x0,0xbc,0xb,0xe0,0x6d,0x80,0x7f,0x34,0xc6,0xbc,0x28,0x61,0x83,0x64,0x37,0x1b,0x63,0xb6,0x9,0xcc,0x2,0x70,0x8d,0x31,0x8e,0x9b,0xcd,0x34,0x2,0xec,0x66,0xc,0xf,0x4,0x74,0x8c,0xb5,0x3a,0xe,0xd0,0x1,0x0,0x7a,0xc8,0xda,0xde,0x24,0xf7,0xcb,0x21,0x2d,0x7c,0x42,0xa,0xa,0xfb,0xe9,0x44,0x2a,0x15,0x4a,0x4f,0x92,0x5,0xcd,0x8d,0x3d,0xf7,0xeb,0x73,0xd5,0x33,0xd7,0xf,0x4e,0x5c,0xce,0xa9,0xf8,0xec,0x60,0x9,0x2b,0x40,0xf3,0x2,0xa0,0xe3,0x2,0x4f,0x9e,0xf0,0x69,0xd1,0xed,0xf,0x5,0x63,0x49,0xee,0xc1,0x3b,0x69,0x3b,0x68,0x3a,0x10,0xd,0x1b,0x25,0x1c,0x2,0xe0,0x10,0x3f,0xc6,0x9,0x92,0x1d,0x27,0xe1,0x7d,0x48,0xcd,0x90,0xcd,0x10,0xb4,0x0,0xe4,0x66,0xb2,0x24,0xe9,0x0,0x4a,0x59,0xab,0xee,0x80,0xf6,0x7,0x90,0xf3,0x48,0xa,0x16,0xc9,0xf8,0xe,0xd1,0x2c,0x76,0xe7,0xab,0x9c,0xf8,0xc5,0xe3,0x40,0x1,0x7e,0x45,0x43,0x4a,0xb0,0x0,0xc,0x69,0x9e,0x14,0xf9,0x83,0xf6,0x20,0x3e,0x50,0x5,0x3,0x90,0x7c,0x17,0xe4,0x77,0x64,0xdd,0x27,0xdb,0xeb,0xb8,0xb4,0xa,0x4a,0x13,0x2a,0x57,0x48,0x81,0x24,0xc2,0x4e,0x97,0xc1,0x88,0xda,0x1d,0x40,0x5f,0x40,0x7d,0xc1,0x9c,0x4a,0x91,0x4b,0x26,0x70,0x79,0xf,0x8c,0x6e,0xc8,0x7f,0x9b,0xcb,0x28,0xbf,0x59,0x46,0xb2,0x65,0x2f,0xc4,0x6f,0xee,0x5c,0x24,0x43,0x72,0x9,0x8d,0xf3,0x5f,0x2b,0x67,0x9f,0x5a,0xd6,0xa0,0x53,0x2d,0x54,0xdc,0x85,0xaf,0x9c,0xf3,0x59,0x57,0x56,0xcf,0x1,0xe6,0x7,0xcc,0x4f,0x3b,0x29,0xce,0xae,0xf,0xc4,0xdb,0xb2,0x11,0x11,0x16,0xf5,0x1e,0x31,0xdf,0x44,0x7d,0xe7,0x3f,0x33,0x58,0x72,0xe,0x7f,0x5b,0x4e,0x7f,0x7e,0x1,0x86,0x6,0x86,0x26,0xbf,0xb6,0xda,0xf,0xf3,0xe6,0x1c,0x20,0xd2,0x0,0xfe,0x7d,0xb1,0x52,0x5e,0x6c,0xcf,0x47,0x4c,0x19,0x4b,0xc5,0x61,0x89,0xfa,0x86,0x5d,0xb9,0xe8,0x19,0x73,0x1e,0x58,0x31,0xfb,0xd4,0x76,0xf5,0x8e,0xae,0x6a,0xc,0x5f,0x75,0xd3,0xe7,0x32,0xc6,0x71,0x66,0xd0,0x98,0x3f,0x7a,0x1e,0x81,0xf0,0x14,0x83,0xbc,0xcd,0x1a,0xa0,0x77,0x94,0x27,0x3,0x79,0x3d,0xf8,0xf1,0xc3,0xe4,0x1b,0x11,0x7c,0xbb,0x49,0x7e,0x4d,0x8,0xb,0xc3,0xa,0xec,0x61,0x21,0x3b,0x49,0x2e,0x6e,0x48,0x78,0x6c,0x65,0x53,0x2a,0x8e,0x1b,0x32,0x52,0x79,0xc6,0x2b,0x22,0xbc,0xcd,0xa1,0x77,0xa,0x8b,0x1f,0x25,0x7c,0x5f,0x9c,0x6f,0x51,0x18,0x23,0xca,0x15,0x67,0xe3,0x29,0x28,0x77,0x44,0x1d,0xa,0x3b,0x6,0x56,0xdc,0x43,0x77,0x8,0x3,0x0,0xc0,0x8a,0xd9,0xa7,0xbc,0x9,0x98,0x6f,0x48,0xb0,0xc1,0x4a,0x97,0x90,0xcd,0x3a,0xa8,0x72,0x40,0x71,0xff,0x40,0x54,0x13,0xd8,0xaa,0x3d,0xd3,0x5e,0xb0,0xb5,0x1d,0x22,0x30,0x57,0x80,0xc5,0x8,0xec,0xc6,0xc5,0x47,0x1b,0xe2,0x17,0x7f,0xc7,0x32,0xf9,0x97,0xcb,0xaf,0x5c,0x1e,0x95,0x94,0xc5,0xbb,0xf7,0x27,0xc0,0x34,0x61,0xd8,0x15,0x4f,0x8c,0xa9,0x4b,0x6,0x0,0x80,0x15,0x37,0x9e,0xf2,0x2b,0x81,0x73,0xfd,0x59,0x89,0xe0,0xbc,0xdb,0x9c,0xdf,0xa3,0x1f,0x6,0x1,0xaf,0xd0,0x38,0xf3,0x40,0xf3,0x3d,0x90,0x8f,0xa3,0x50,0x4b,0x66,0x72,0x3e,0x92,0x9d,0x24,0x8a,0x24,0x8,0x61,0x1c,0x2,0x1a,0xe,0x60,0xca,0x51,0x57,0x3d,0x9d,0x6e,0xaf,0xfc,0x6a,0x56,0xe3,0x68,0x9c,0xaf,0xd2,0x38,0xbf,0x1,0xe8,0x2,0xc,0x66,0xa5,0x8,0xf0,0x3,0x81,0x4f,0x1,0x9c,0x4d,0x9a,0xff,0x30,0xc6,0x4c,0x5f,0x31,0xfb,0x94,0x6f,0x3,0xe6,0x6b,0xa0,0xf9,0x6d,0x28,0xae,0xef,0x27,0x17,0xb5,0x6d,0x5a,0xa5,0x17,0x6a,0xfc,0xbe,0xf3,0x2f,0x7f,0xd2,0x43,0x79,0xbc,0x68,0x8c,0x9b,0x75,0xcf,0x6b,0x2f,0x6,0x48,0xa4,0xc9,0x8c,0xb8,0xf2,0xa9,0x23,0x24,0xfb,0x6b,0x49,0x69,0x49,0x1b,0xc,0xb9,0x95,0xc6,0xac,0x0,0x78,0xf3,0xf2,0x59,0x27,0xbd,0x19,0x11,0xff,0x13,0xd6,0xba,0xf3,0x25,0x9d,0x60,0x72,0xaa,0x5b,0xe8,0xa0,0xe4,0x92,0xc5,0x6d,0x4b,0x6f,0xd1,0xd6,0x78,0x51,0x71,0xc3,0xcf,0x95,0xa4,0x53,0xd,0x4,0x55,0x8d,0xcd,0x43,0x5e,0x2f,0xca,0x47,0x68,0xcc,0xf8,0x95,0xb3,0x4f,0x2e,0x77,0xa,0x7a,0xd5,0x25,0xa8,0x19,0x46,0x5c,0xf9,0xd4,0xf5,0x92,0x5e,0x7,0x39,0x6f,0xc5,0xac,0x93,0xca,0x6e,0xf5,0x3a,0xfc,0x4b,0x4f,0x35,0x42,0xf6,0x69,0x41,0xc7,0x78,0x2,0x1e,0x73,0x15,0x66,0x58,0xa7,0x8b,0x41,0x51,0x78,0xc,0x29,0x45,0x22,0x96,0xf9,0xbe,0x38,0x4e,0x71,0xfc,0x28,0x4,0x29,0x26,0x8d,0xf6,0x60,0x15,0x7f,0x78,0x7c,0x97,0x34,0x3f,0x58,0x31,0xfb,0xe4,0x1f,0x26,0x9d,0x7e,0xa7,0xe,0x9a,0x23,0xaf,0x59,0x4a,0xb7,0x65,0xfb,0xe3,0x24,0x8e,0x6,0xd0,0xc3,0xdb,0x3c,0x23,0xd8,0x87,0x24,0x8a,0x5,0x18,0xf1,0x5c,0xe9,0xe4,0x43,0x5c,0xba,0xa5,0x58,0x24,0xa,0x65,0xc5,0xdf,0x95,0xcb,0x2f,0xae,0x4c,0x8c,0xf9,0x46,0xc1,0x7a,0x4b,0xff,0xe0,0x68,0x3e,0x63,0x85,0xcf,0xaf,0xba,0xf1,0x94,0x44,0xcd,0xc1,0x9d,0x6a,0xca,0x5d,0xf6,0xd3,0x63,0xb5,0xf2,0xc6,0x53,0x4f,0x25,0x53,0xb7,0x4a,0x7c,0xc3,0x57,0xd5,0x19,0xbd,0xce,0x90,0x31,0xcf,0x61,0x4d,0xa1,0x54,0xdc,0x8,0xbd,0x32,0x36,0x9d,0xb8,0x30,0x96,0xf8,0xae,0x5c,0x7e,0x71,0x71,0xe2,0xbe,0xf1,0xe4,0xe3,0x90,0x6e,0x3b,0x84,0xe4,0xb7,0x92,0xa6,0x41,0x67,0xdb,0xf2,0x1,0x0,0xcb,0x67,0x8d,0xb9,0x16,0x34,0xd7,0x4a,0x58,0xf,0xef,0x4,0x92,0x28,0x4a,0xed,0x56,0x57,0xb0,0xb7,0x72,0xb9,0xb0,0x52,0xdf,0x6,0x2e,0x71,0x7e,0xf8,0x36,0x0,0x1f,0x24,0x8d,0xfb,0xba,0xd2,0x9b,0x86,0x7f,0xe9,0xe9,0xde,0xa0,0x1e,0x25,0x30,0x24,0x5f,0xbc,0xb8,0x3d,0x74,0x6b,0x19,0x71,0x4b,0xa5,0xd1,0x16,0xa9,0x22,0x4e,0x7a,0xc8,0x7d,0x17,0xac,0x95,0xf4,0x67,0x2d,0x73,0x5d,0x9b,0xef,0xc9,0x62,0x5b,0x4f,0xa5,0x7,0xdd,0xbe,0xb7,0x4b,0x46,0xfe,0x5b,0x0,0x92,0x5e,0x27,0xf9,0xff,0x56,0xcc,0x3e,0x69,0x66,0xd2,0x38,0x6f,0x77,0x4b,0x53,0x25,0x60,0xc,0xcf,0x12,0xb0,0x7f,0xa1,0x46,0x10,0xc7,0xa3,0x49,0xf0,0x6e,0xb5,0x69,0xb3,0xd5,0x73,0x89,0x19,0x41,0x17,0x40,0xd6,0x6f,0xdc,0x8d,0x3e,0x81,0x63,0x36,0x88,0x28,0xdc,0x37,0xc0,0x8f,0xf3,0xf,0xc7,0x38,0xd7,0x2f,0xfb,0xd9,0x89,0xb3,0xd1,0xe,0x50,0x17,0x43,0x40,0x0,0x56,0x9a,0x2,0xb0,0x4f,0xcc,0xa0,0x19,0x46,0x54,0x95,0x57,0xf8,0xfb,0xa8,0xb4,0xa2,0xde,0x17,0x43,0x41,0x9a,0xf2,0xaf,0x90,0x15,0x34,0x6c,0x14,0x33,0x24,0xcd,0x12,0x63,0x9c,0x13,0x49,0x73,0xa9,0xf2,0x7b,0x39,0xd2,0x5b,0xff,0x58,0xd0,0xe5,0xe7,0xbc,0x87,0x83,0xd6,0xef,0xf9,0xf4,0xf3,0xb2,0xf6,0x22,0x3e,0x50,0x6f,0x3d,0x0,0xb9,0xb7,0x7f,0xab,0xe8,0xa6,0x5f,0x6b,0xab,0x2f,0x47,0xe4,0x36,0x30,0x41,0x99,0x11,0x42,0xc1,0xc6,0xf7,0xc4,0x12,0x49,0xff,0x43,0xf2,0xe9,0x65,0x33,0x47,0x67,0x0,0xfc,0x6e,0xe4,0x55,0xcf,0xbe,0x2d,0x6b,0x7f,0x9,0x61,0xcf,0x12,0xbe,0x23,0x16,0xa0,0x1,0xf9,0x24,0xc9,0x6f,0x2e,0x9b,0x39,0x7a,0x59,0x72,0x18,0x6e,0xd,0x75,0xd3,0x3,0xc,0xbf,0xf2,0x99,0x43,0xad,0xd4,0xd8,0x7a,0x7d,0x21,0x4a,0x48,0xe2,0x40,0xbc,0x74,0x8f,0x98,0x6f,0xa3,0x24,0x7d,0xc4,0xe4,0x17,0x91,0x6,0x10,0x78,0xfb,0x22,0x98,0xb4,0xb,0xc9,0x76,0xa4,0x31,0xf,0xd2,0x38,0xa3,0x40,0xf3,0x79,0x3a,0xd,0x4f,0x2c,0xff,0xd9,0x89,0x39,0x1f,0xc5,0x65,0x33,0x47,0x3f,0xe,0x9a,0xa1,0x2,0x7e,0xed,0x37,0x79,0x81,0x94,0x37,0xc9,0xc8,0x60,0x1,0x89,0x1,0x79,0x9b,0x80,0x69,0xed,0x4d,0x7c,0xa0,0x9e,0x7a,0x0,0xa2,0x1f,0xc1,0xc6,0xdc,0x53,0x4e,0xb2,0x2a,0xd7,0x52,0x5b,0x79,0xd0,0xf8,0xdd,0x27,0x83,0x77,0x88,0x77,0x57,0x60,0x44,0x7a,0xe5,0x7b,0x89,0xfc,0x9c,0x7d,0xe0,0xe,0x61,0xfe,0xa,0x70,0x11,0xa8,0x5b,0x1,0xbc,0xe,0x68,0xe7,0xf2,0x99,0xa3,0x23,0x3d,0x72,0x97,0xff,0x6c,0xf4,0x9f,0x47,0x5c,0xf5,0xec,0x64,0x8,0x93,0x24,0x3b,0x23,0xa8,0x82,0xef,0xdc,0x42,0x80,0x5f,0x3,0x79,0xc7,0x8a,0x99,0x27,0xbc,0xd7,0x11,0x68,0xaf,0x1f,0x6,0x0,0x8e,0x5,0xd8,0xc3,0xf7,0xc9,0xa8,0xc8,0xc9,0xc4,0x9f,0x7d,0xa,0x3c,0x68,0x2,0x46,0x0,0x80,0xd0,0x92,0x6c,0x0,0x21,0x71,0xbd,0x48,0x66,0xab,0xc6,0x9b,0x97,0x0,0xb2,0x20,0x7,0x81,0xdc,0x22,0x69,0xeb,0xf2,0x99,0xa3,0xdb,0xe4,0x88,0xba,0x7c,0xe6,0xe8,0x77,0x46,0x5e,0xbd,0x64,0x2e,0xc4,0xc5,0x90,0x9e,0x5,0x70,0xa0,0xa4,0x77,0x40,0x4e,0x4,0xf4,0xc2,0xa,0x6f,0xc8,0xe8,0x10,0xa8,0x1b,0x35,0x70,0xf8,0x97,0x9f,0x7d,0x9e,0xc4,0x31,0xbe,0x27,0x47,0x5b,0x9,0x92,0xd7,0xbb,0x3c,0xcf,0xd9,0xdb,0x1,0x2c,0x5,0x70,0x32,0xa0,0xb3,0x51,0x62,0xdb,0xd9,0x90,0xb7,0x50,0x45,0x6e,0xed,0x45,0xbd,0x4d,0x66,0xf9,0xcc,0xd1,0xd,0x6d,0xfa,0x30,0x6,0x46,0x5e,0xbd,0xe4,0x50,0x49,0xc3,0x0,0xac,0x5f,0x3e,0xf3,0x84,0xd,0xed,0x89,0xe3,0x48,0x3c,0x74,0x74,0x86,0x71,0x30,0xe2,0xaa,0xe7,0xde,0x2,0xd0,0x2b,0xbc,0xdf,0x50,0x29,0xa2,0x14,0xbf,0x97,0xf4,0x17,0x80,0x13,0x1,0xac,0xa1,0x77,0x9e,0x71,0x2f,0x0,0x7b,0x4a,0x6a,0x80,0x77,0xbc,0x7d,0xf,0x0,0x9f,0x2,0xd4,0x17,0xc0,0xbe,0x0,0x3e,0x9,0x78,0x1b,0x51,0x55,0xea,0xcf,0x1f,0xc,0x33,0x92,0x32,0xa4,0xe9,0xb6,0x7c,0xe6,0xf1,0xd9,0xb6,0x7e,0x1b,0x5,0x47,0x7f,0x65,0x69,0xea,0xf7,0x33,0x8e,0xad,0x29,0x8d,0x6a,0xa1,0x6e,0x86,0x0,0x82,0x3f,0x17,0xf4,0x15,0xf9,0xb,0xa1,0x3c,0xbf,0x48,0x8f,0x28,0x11,0x94,0xf1,0x37,0x44,0xf4,0x5,0x32,0x6f,0x14,0xb8,0xce,0xcd,0xba,0x7f,0x58,0x39,0xfb,0x44,0xb,0x60,0x93,0x7f,0xe5,0x60,0xc4,0xd5,0x2f,0x90,0xb0,0x3d,0x0,0xee,0x9,0x8f,0x21,0xfa,0xc8,0x6a,0x89,0x31,0x74,0x0,0x6f,0x71,0x65,0x5,0x83,0x8e,0x7f,0xca,0x6d,0x32,0xde,0x81,0x9d,0x45,0x7c,0xa0,0x8e,0x18,0x40,0xc0,0x8f,0x48,0xb3,0x44,0xb2,0x97,0x82,0x3c,0x2d,0x24,0x4,0x14,0xf4,0xba,0x7e,0x80,0xbf,0xf,0x1e,0x20,0x6b,0x9,0xe0,0xfb,0x12,0x1f,0xf5,0x89,0x1f,0x9,0xcb,0x6f,0x38,0x4e,0x0,0xb6,0xf8,0x17,0x46,0x5c,0xb5,0xe4,0x75,0x92,0xbf,0x15,0x70,0x1c,0x80,0x22,0x51,0xa1,0x75,0xe1,0x42,0x5c,0xa8,0xd0,0x9e,0x8c,0xdb,0xea,0xa8,0x13,0xad,0xa,0xea,0x46,0xd,0x5c,0x3e,0xf3,0xf8,0xd7,0x97,0xdd,0x30,0xea,0x3e,0x80,0xd7,0x1,0xbc,0x58,0xc2,0xaf,0x3,0xe7,0x92,0x22,0x87,0x11,0x92,0x46,0xa1,0x77,0xbf,0x7,0xf8,0xbf,0xcb,0x67,0x1e,0x5f,0xd1,0x59,0x43,0xc6,0x18,0xd2,0x98,0xbb,0x42,0xf6,0xf9,0x78,0x3b,0x7d,0xa1,0x4b,0x97,0x6f,0xac,0x81,0x5,0xf8,0x1a,0xda,0xd7,0x61,0xa0,0xdd,0xa1,0x6e,0xd9,0x77,0xc4,0x55,0x4b,0x8e,0x4,0x30,0x82,0xe4,0x89,0x0,0xc6,0x1,0x8,0x6f,0x11,0x13,0x8c,0xc1,0x9b,0x1,0x9c,0xb5,0x7c,0xe6,0xf1,0x4b,0xaa,0xc9,0x63,0xe4,0xd5,0x2f,0x1c,0x28,0xd9,0x4d,0xfe,0xb9,0x88,0xa5,0x5c,0x0,0xa,0xc0,0xd7,0x30,0x32,0x92,0x16,0x1,0x98,0xbc,0x7c,0xe6,0xf1,0x65,0x17,0x61,0xd6,0x2b,0xd4,0x2d,0x3,0x4,0x30,0xe2,0xea,0xe7,0xfb,0x0,0x38,0x3,0xc0,0xbf,0x10,0x3c,0xa,0xc0,0x18,0xdf,0x4a,0xb0,0x43,0xd0,0x95,0xcb,0x6f,0x18,0x75,0x47,0x8d,0xe9,0x3f,0x65,0x68,0x8e,0x87,0x77,0xf6,0x9e,0xe7,0x25,0x1c,0xc3,0xa,0xb2,0x5,0xea,0xc2,0x2e,0x2b,0xfb,0x9f,0x0,0x7e,0xb8,0xfc,0x86,0x51,0x5d,0xc,0xd0,0x11,0x70,0xd4,0x57,0x96,0xe,0x7,0x30,0x9,0x5e,0x6f,0xb0,0xe9,0xc5,0x19,0xc7,0x7e,0xb7,0x96,0xf4,0x46,0x5e,0xb3,0x94,0x92,0x3d,0x95,0xe4,0xaf,0x0,0xec,0x11,0xee,0x5,0x22,0xb4,0x90,0x9c,0xfc,0xe1,0x3f,0x5b,0x0,0x63,0x49,0xf3,0x48,0x67,0x2c,0x4d,0x4f,0xa,0x76,0x2b,0x6,0x68,0xf,0x18,0x79,0xcd,0xd2,0x3d,0x24,0xbd,0x4c,0xf2,0xc0,0x62,0xb5,0x33,0xce,0x5b,0x59,0xd2,0x26,0x92,0x2f,0x91,0xbc,0xf8,0xc5,0x19,0xc7,0x6c,0x6a,0x4b,0x3e,0xf5,0xa,0xff,0xf4,0xc,0x0,0x0,0x23,0xaf,0x7e,0xe1,0x7a,0x1a,0x5e,0x7,0x20,0xe5,0xfb,0x61,0x65,0x0,0xec,0x82,0xb0,0xb,0xc4,0xe,0x0,0x5b,0x24,0x6d,0x26,0xb9,0xd,0xc2,0x66,0x41,0x4b,0x8c,0x31,0xbf,0xfb,0xfd,0x4f,0x8e,0x59,0x57,0x63,0xd6,0x9d,0xe,0x75,0xa3,0x6,0x76,0x26,0xd0,0x98,0xff,0x91,0x74,0x8,0x80,0x1e,0x24,0xb7,0xc0,0xdb,0x5b,0x6f,0x33,0xd,0xdf,0x3,0xf0,0xb6,0xa4,0x57,0x1,0xbc,0xf4,0xe2,0x8c,0x63,0xdf,0xe9,0xec,0xb2,0x76,0x41,0x17,0x74,0x41,0x17,0x74,0x41,0x17,0x74,0x41,0x17,0x74,0x41,0x17,0x74,0x41,0x17,0xd4,0x6,0xff,0x1f,0x32,0x68,0x5,0x7e,0x99,0xd5,0x97,0x49,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char logo_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x80, 0x8, 0x6, 0x0, 0x0, 0x0, 0xc3, 0x3e, 0x61, 0xcb, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0x2e, 0x23, 0x0, 0x0, 0x2e, 0x23, 0x1, 0x78, 0xa5, 0x3f, 0x76, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xdc, 0x9, 0x7, 0x13, 0x2, 0x0, 0x15, 0xb9, 0x53, 0x97, 0x0, 0x0, 0x21, 0x58, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xed, 0x7d, 0x79, 0x9c, 0x1c, 0x55, 0xb5, 0xff, 0xf7, 0x7b, 0xab, 0x7b, 0x66, 0x48, 0x8, 0x61, 0xd1, 0x90, 0xb0, 0x88, 0x91, 0x27, 0x24, 0x24, 0x21, 0x3b, 0x8, 0x4, 0x42, 0x58, 0x54, 0xe0, 0x91, 0x80, 0x24, 0x1, 0x2, 0x9, 0x42, 0x80, 0x4, 0x11, 0x90, 0x9f, 0xf2, 0xd3, 0xa7, 0xcf, 0xe7, 0xf3, 0x3d, 0x1f, 0x1f, 0x7f, 0xea, 0xd3, 0x48, 0x4c, 0x8, 0x61, 0xd, 0x49, 0x64, 0x89, 0x82, 0x40, 0x58, 0x4, 0x64, 0xb, 0x44, 0x25, 0x9b, 0xd9, 0x51, 0x14, 0x41, 0x3, 0xc8, 0x16, 0x20, 0xfb, 0x4c, 0x77, 0xdd, 0xef, 0xef, 0x8f, 0xaa, 0xea, 0xae, 0xee, 0xa9, 0xea, 0x9e, 0xee, 0xae, 0x99, 0xe9, 0xe0, 0x9c, 0xf9, 0xd4, 0x74, 0xd5, 0xad, 0x5b, 0x77, 0x39, 0xe7, 0xdc, 0x7b, 0xcf, 0x39, 0xf7, 0xdc, 0x7b, 0x81, 0x2e, 0xe8, 0x82, 0x2e, 0xe8, 0x82, 0x2e, 0xe8, 0x82, 0x2e, 0xe8, 0x82, 0x2e, 0xe8, 0x82, 0x2e, 0xf8, 0xe7, 0x2, 0x76, 0x76, 0x1, 0xea, 0x1, 0xe, 0xff, 0xc2, 0xcc, 0xbd, 0x60, 0x5b, 0x6e, 0xb6, 0xd6, 0xf6, 0x2, 0xb8, 0x8d, 0xc6, 0x6c, 0x36, 0x34, 0x6f, 0x81, 0x7c, 0x43, 0x30, 0x7f, 0x27, 0xcd, 0xdf, 0x8c, 0xe3, 0x6c, 0xda, 0x70, 0xef, 0xf4, 0x37, 0x3b, 0xbb, 0xac, 0x49, 0x43, 0xaa, 0xb3, 0xb, 0x50, 0xf, 0x20, 0x9b, 0xfd, 0x96, 0xcd, 0xb6, 0x4c, 0x40, 0xd0, 0x20, 0x2c, 0xac, 0x4b, 0xb3, 0x3, 0xc0, 0x36, 0x80, 0x5b, 0x41, 0x6c, 0x75, 0x5b, 0xb8, 0xed, 0xb0, 0x71, 0xff, 0xbb, 0x83, 0xc6, 0x6c, 0x26, 0x9d, 0x65, 0x74, 0xd2, 0x4f, 0x6e, 0x5c, 0x74, 0xc5, 0xba, 0xce, 0x2e, 0x7b, 0xad, 0xf0, 0x4f, 0xdf, 0x3, 0xf4, 0x9f, 0x38, 0xb7, 0x5b, 0x76, 0xd7, 0x7, 0x2f, 0xcb, 0xda, 0x3, 0xc8, 0x42, 0x94, 0x48, 0x6a, 0x15, 0x9f, 0x24, 0x0, 0xbe, 0x43, 0xe3, 0xfc, 0xc1, 0x49, 0x37, 0x4d, 0xdd, 0xf8, 0x8b, 0x2b, 0xff, 0xde, 0xd9, 0x75, 0xa8, 0x5, 0x76, 0x2b, 0x6, 0xe8, 0x37, 0x7e, 0xf6, 0x18, 0xeb, 0xb6, 0x9c, 0x6, 0x69, 0xf, 0x1a, 0xf3, 0xc1, 0x1f, 0xef, 0xbb, 0xe6, 0xdb, 0xb5, 0xa4, 0x37, 0xf2, 0x9a, 0xa5, 0xdc, 0xb2, 0x69, 0xe5, 0x69, 0xca, 0xec, 0xf8, 0xa5, 0xa4, 0x26, 0x48, 0xf2, 0x29, 0x8c, 0x82, 0x7b, 0x40, 0x3e, 0xae, 0xfc, 0x5f, 0x41, 0x82, 0x4d, 0x37, 0xf5, 0x18, 0xb7, 0xd7, 0xc1, 0xc3, 0x1f, 0xfe, 0xfd, 0x4f, 0x3e, 0xa3, 0x2a, 0x8b, 0xd0, 0xe9, 0x50, 0xf7, 0xc, 0x70, 0xf8, 0x39, 0xb3, 0x3e, 0x9, 0xb9, 0xa7, 0x48, 0xf6, 0x70, 0xb9, 0xd9, 0xd1, 0x90, 0x3b, 0xd2, 0x2b, 0x39, 0x9b, 0x4d, 0xaa, 0x69, 0xfa, 0x1f, 0xef, 0xbb, 0xfa, 0x8e, 0x5a, 0xd2, 0x3f, 0x6c, 0xdc, 0x8f, 0x9f, 0x91, 0xcd, 0x8c, 0x2, 0xe9, 0xe4, 0x43, 0x3, 0x7a, 0xc7, 0x80, 0x4, 0x80, 0xbb, 0x9c, 0x74, 0xd3, 0x77, 0xdd, 0xcc, 0xce, 0x1f, 0xbc, 0xfc, 0xd0, 0xd7, 0x6d, 0x67, 0xe3, 0xa9, 0x5a, 0xa8, 0x5b, 0x19, 0xa0, 0xdf, 0xf8, 0xd9, 0x47, 0x42, 0xee, 0x51, 0x72, 0x5b, 0x3e, 0x6b, 0xdd, 0xcc, 0x69, 0x0, 0xf6, 0xf4, 0x8, 0xe3, 0x75, 0xc3, 0x92, 0x1a, 0x6d, 0x66, 0xd7, 0x8f, 0xfa, 0x8d, 0x9f, 0xf5, 0xe7, 0x97, 0x7e, 0x71, 0xe5, 0xf3, 0x55, 0xe5, 0x31, 0xe1, 0xc6, 0x83, 0xdc, 0x5d, 0x5b, 0x46, 0x3, 0x7e, 0xb3, 0xce, 0x51, 0xbd, 0x74, 0xbb, 0xf0, 0x9b, 0xbb, 0x23, 0xd9, 0x23, 0x59, 0xf7, 0x4d, 0xa8, 0x34, 0xd4, 0x1d, 0x3, 0xf4, 0x3b, 0x67, 0xf6, 0x20, 0xc0, 0x1d, 0x65, 0xb3, 0xcd, 0x67, 0xc9, 0xcd, 0x9c, 0xa, 0x9f, 0x1a, 0xfe, 0xd8, 0x5b, 0xd0, 0x15, 0xb, 0xda, 0xcf, 0x66, 0x9a, 0x7f, 0xd8, 0x7f, 0xc2, 0x9c, 0xb1, 0x1b, 0x17, 0x4d, 0x7f, 0xa7, 0x92, 0x7c, 0xe, 0xff, 0xc2, 0xd, 0x69, 0x58, 0x77, 0x1c, 0x40, 0x17, 0x84, 0x3, 0x54, 0x48, 0x4a, 0xd2, 0x91, 0x75, 0x7, 0x38, 0x4d, 0x7b, 0xef, 0xd6, 0x2c, 0x50, 0x37, 0xc, 0xd0, 0x7f, 0xc2, 0x8d, 0x7, 0x3, 0x1a, 0x65, 0x33, 0xcd, 0x97, 0x58, 0x9b, 0x3d, 0x5, 0x0, 0x40, 0xe6, 0x5a, 0xa6, 0x82, 0x47, 0xbf, 0x13, 0x0, 0x21, 0x82, 0x90, 0xdc, 0xcf, 0xc8, 0x66, 0xbe, 0xd6, 0x6f, 0xfc, 0xac, 0xef, 0xbc, 0xf4, 0x8b, 0x2b, 0x77, 0xb5, 0x35, 0x3f, 0x93, 0x6a, 0xb4, 0x36, 0xb3, 0xe3, 0x7c, 0x1a, 0xe3, 0x8f, 0xe9, 0xe1, 0x21, 0x3f, 0x4, 0xe1, 0xd1, 0x40, 0x80, 0x24, 0xd1, 0x90, 0x10, 0x8c, 0x64, 0xf, 0x31, 0xa9, 0xa6, 0x2e, 0x6, 0x48, 0x2, 0x64, 0xb3, 0xdf, 0xb0, 0xd9, 0xe6, 0x2f, 0x1, 0x41, 0x6b, 0xf7, 0x9, 0x2f, 0x91, 0x1e, 0x23, 0x78, 0x40, 0x9f, 0x8, 0x34, 0x41, 0x90, 0x75, 0x33, 0xbb, 0xfe, 0xaf, 0xd3, 0xd0, 0x7d, 0xd9, 0x61, 0xe3, 0x7e, 0x78, 0xdf, 0x9f, 0x1e, 0xb8, 0x2e, 0x72, 0x3c, 0x1e, 0x30, 0xe9, 0xce, 0x94, 0xdb, 0xb2, 0x7d, 0x1f, 0xd2, 0xf4, 0x0, 0x6c, 0x1a, 0xb2, 0xbd, 0x65, 0xdd, 0xcf, 0x0, 0x30, 0x0, 0x41, 0x42, 0x91, 0xbd, 0x0, 0xb, 0xef, 0x49, 0x52, 0x9e, 0x7a, 0x40, 0x48, 0x7b, 0xee, 0x6, 0x62, 0x54, 0x49, 0xa8, 0x1b, 0x6, 0xb0, 0xd9, 0xcc, 0x39, 0x7e, 0x6b, 0xb, 0xda, 0x5c, 0xa8, 0xeb, 0x2f, 0x4, 0x7a, 0x81, 0x41, 0x3c, 0x3, 0x10, 0x36, 0xbb, 0xeb, 0xc7, 0x4e, 0x43, 0x8f, 0xd7, 0xfa, 0x4f, 0xb8, 0x71, 0x3, 0x68, 0xf6, 0x7, 0xb0, 0x37, 0x81, 0x34, 0x8, 0xca, 0xda, 0x46, 0xb7, 0x65, 0xeb, 0x27, 0x20, 0x3b, 0xd8, 0x75, 0xdd, 0xbe, 0x4, 0xf6, 0x83, 0x74, 0x30, 0x80, 0x40, 0xf0, 0x53, 0x25, 0x43, 0x0, 0xfd, 0xff, 0x22, 0xad, 0xcd, 0xee, 0xac, 0x59, 0x3, 0xe8, 0x7f, 0xee, 0x2d, 0xdd, 0x36, 0xde, 0x73, 0xe9, 0x8e, 0xce, 0xc0, 0x7b, 0xdd, 0x30, 0x0, 0x8d, 0xf3, 0xb2, 0xac, 0x3e, 0xe, 0xc0, 0x20, 0x4e, 0xc, 0xf, 0xc8, 0x1e, 0x3c, 0xf9, 0x8a, 0x3a, 0x49, 0x40, 0xf6, 0x60, 0xeb, 0xb6, 0xfc, 0x1f, 0xd2, 0xac, 0xb3, 0xb6, 0xf9, 0x24, 0x78, 0xad, 0xbb, 0x9b, 0x17, 0xb5, 0x90, 0x46, 0xca, 0x25, 0x46, 0x85, 0x52, 0x8e, 0xcb, 0xa7, 0x30, 0xdc, 0x4a, 0xa0, 0x21, 0xe8, 0x7d, 0xed, 0x36, 0x6f, 0xad, 0x89, 0x1, 0x8e, 0x38, 0x77, 0x6e, 0x5f, 0xeb, 0xb6, 0x9c, 0xde, 0x7f, 0xc2, 0x9c, 0xe7, 0x36, 0x2e, 0x9a, 0xbe, 0xb6, 0xc3, 0xf1, 0xde, 0xd1, 0x19, 0xc6, 0x41, 0xff, 0x9, 0xb3, 0xbf, 0x67, 0x33, 0xcd, 0x5f, 0x96, 0x6c, 0xcf, 0x70, 0xab, 0x8f, 0xa3, 0x43, 0x41, 0xb8, 0x4, 0x90, 0x16, 0x80, 0x41, 0xd8, 0x78, 0x43, 0x6, 0xef, 0x8a, 0xf4, 0x7a, 0x9, 0xf2, 0xfa, 0x7d, 0xff, 0xb1, 0x40, 0x0, 0x60, 0x51, 0xde, 0xc5, 0xf9, 0x11, 0x39, 0x23, 0x51, 0xd6, 0x69, 0xdc, 0xf3, 0x18, 0xc9, 0xbe, 0x61, 0x9c, 0x86, 0xad, 0x1b, 0xee, 0x9e, 0xba, 0xb5, 0xad, 0xf5, 0x3d, 0xe2, 0xbc, 0x5b, 0xbb, 0xc1, 0xba, 0x9f, 0xc8, 0x66, 0xb6, 0x2f, 0x86, 0x74, 0x28, 0x80, 0xb7, 0x4d, 0xba, 0xdb, 0xb9, 0xc6, 0x38, 0x4b, 0x37, 0xdc, 0x73, 0x59, 0x4b, 0x47, 0xe1, 0xbd, 0x6e, 0x18, 0xa0, 0xdf, 0x84, 0x39, 0xa7, 0x2b, 0xb3, 0x73, 0x2e, 0xa0, 0x3, 0x81, 0x60, 0x9c, 0x6f, 0x73, 0xb7, 0x1c, 0xc8, 0xb, 0x20, 0xf3, 0xad, 0x3a, 0xf4, 0x9c, 0x78, 0x3d, 0x95, 0x37, 0x13, 0x92, 0xc6, 0xf9, 0xb, 0x9d, 0xf4, 0x22, 0x63, 0x52, 0xb7, 0x3, 0x78, 0x3d, 0xdb, 0xbc, 0x6d, 0xe7, 0x9f, 0x1e, 0xf8, 0x6a, 0xac, 0x6d, 0xa0, 0xff, 0x84, 0x39, 0xfb, 0x4b, 0xee, 0x14, 0x9b, 0x69, 0xfe, 0x41, 0x90, 0x9a, 0x2f, 0x5b, 0xc0, 0xa4, 0x9b, 0xfe, 0xcd, 0x18, 0xe7, 0x96, 0xd, 0xf7, 0x4e, 0x7f, 0xb7, 0x23, 0xf0, 0x5e, 0x37, 0xc, 0xd0, 0xff, 0xdc, 0x9b, 0x3f, 0x65, 0x5b, 0xb6, 0x3f, 0x21, 0xd9, 0x4f, 0x41, 0x8, 0x24, 0xed, 0xb6, 0x95, 0x56, 0x65, 0xde, 0x25, 0x55, 0x53, 0x3f, 0xad, 0x9c, 0x26, 0xe0, 0x3f, 0x14, 0xf4, 0x1e, 0x26, 0x75, 0x3f, 0x9d, 0x86, 0x9f, 0xd2, 0x49, 0xaf, 0xec, 0xd1, 0xfb, 0x88, 0x6d, 0xc5, 0x56, 0xc2, 0xfe, 0x13, 0x6f, 0x3a, 0xcc, 0x66, 0x9b, 0xe7, 0x40, 0xee, 0x18, 0x0, 0x5e, 0xaf, 0x15, 0x24, 0x3, 0x8, 0x24, 0x8d, 0xd3, 0x70, 0x13, 0x4c, 0xea, 0xfb, 0x1b, 0xef, 0x9d, 0xf6, 0x6a, 0x7b, 0xe3, 0xdd, 0xb4, 0x77, 0x6, 0x6d, 0x85, 0x8d, 0xf7, 0x5c, 0xf6, 0xa, 0x69, 0x9a, 0x3d, 0x51, 0x3b, 0xc0, 0x26, 0xfd, 0xb, 0xa5, 0x9, 0x58, 0xaa, 0xa3, 0x28, 0xf7, 0x6d, 0x25, 0xe0, 0xa7, 0x95, 0x27, 0x3e, 0x94, 0xcf, 0xc0, 0xd3, 0x26, 0xad, 0x9b, 0x3d, 0xdb, 0x6d, 0xd9, 0xf1, 0x8c, 0x6d, 0xd9, 0xfe, 0xdc, 0x96, 0xd7, 0x57, 0x9f, 0x11, 0xfe, 0xfc, 0x88, 0x73, 0xe7, 0x9e, 0xec, 0xb6, 0xec, 0xd8, 0x28, 0xeb, 0x8e, 0xf1, 0xbe, 0xf5, 0xf1, 0x2f, 0x88, 0xa0, 0xcf, 0x48, 0xb4, 0xd6, 0x6d, 0x99, 0x66, 0xb3, 0x2d, 0xf3, 0xfb, 0x4f, 0x9c, 0x7b, 0x5c, 0x7b, 0xe3, 0xbd, 0x6e, 0x7a, 0x0, 0x0, 0xe8, 0x77, 0xce, 0xcf, 0x9e, 0xb3, 0x6e, 0xe6, 0x78, 0x20, 0x5a, 0xfa, 0xaf, 0x3f, 0x8, 0x86, 0x81, 0x7c, 0x61, 0xfd, 0x91, 0x41, 0x64, 0xa0, 0x5a, 0x38, 0x2b, 0x4c, 0xba, 0xf1, 0x3b, 0x4, 0x7a, 0x66, 0x5b, 0x76, 0x2c, 0xf4, 0xf8, 0xbb, 0xd5, 0xb0, 0x54, 0xd0, 0x4f, 0x5, 0x6a, 0x26, 0x8d, 0x79, 0x8d, 0x4e, 0xd3, 0xbf, 0xbd, 0xb4, 0x68, 0xda, 0x5d, 0xed, 0x55, 0x3, 0xa7, 0xf6, 0x24, 0x92, 0x83, 0x8f, 0xf, 0x1c, 0x9b, 0x2, 0x34, 0x9c, 0x40, 0x8f, 0x78, 0xcb, 0x4c, 0x3d, 0x41, 0xd0, 0x45, 0xf9, 0xe0, 0xcb, 0x2d, 0xbe, 0xd5, 0x92, 0x14, 0x24, 0xa2, 0xb7, 0x6c, 0x76, 0x82, 0xac, 0x7b, 0x16, 0x29, 0x27, 0x50, 0x21, 0x1, 0x85, 0xba, 0xba, 0x5c, 0x37, 0xe2, 0xdb, 0xbb, 0x72, 0x36, 0xb0, 0xbd, 0x61, 0xdd, 0x13, 0xf7, 0x3f, 0xf2, 0xec, 0x96, 0x77, 0xd6, 0x2f, 0xfe, 0x5d, 0x7b, 0xd4, 0xa0, 0x6e, 0x86, 0x0, 0xaf, 0x34, 0xce, 0x12, 0x0, 0xef, 0x7b, 0xf7, 0x86, 0xf9, 0x21, 0x60, 0x37, 0xb9, 0x8c, 0xf1, 0x94, 0xc3, 0x80, 0x71, 0x69, 0x40, 0xd2, 0x90, 0x6c, 0x0, 0xd4, 0x0, 0x18, 0x79, 0x17, 0x8, 0x18, 0x45, 0xa4, 0xe1, 0x31, 0x81, 0x31, 0xfe, 0x7b, 0x3, 0x40, 0xfb, 0x65, 0x33, 0xbb, 0xbe, 0xde, 0x6f, 0xc2, 0x9c, 0xaf, 0xb4, 0x7, 0xca, 0xeb, 0xa6, 0x7, 0xe8, 0x3f, 0x71, 0xee, 0x4, 0x4f, 0x38, 0x52, 0x3f, 0xf8, 0xb6, 0x9e, 0xd0, 0xe8, 0xba, 0xfb, 0x5c, 0x44, 0xae, 0xfd, 0xe7, 0xee, 0x1, 0xbf, 0x67, 0x80, 0x7f, 0x11, 0xa1, 0x77, 0x45, 0xdf, 0x93, 0xa1, 0x74, 0x82, 0x1e, 0x61, 0x4f, 0xca, 0xe, 0xea, 0x35, 0xe8, 0x2c, 0xe7, 0x9d, 0xf5, 0x8b, 0x97, 0x26, 0x89, 0xf7, 0xba, 0x30, 0x4, 0xf5, 0x9f, 0x78, 0xd3, 0x2c, 0x9b, 0xdd, 0x75, 0x36, 0xa0, 0x3e, 0xde, 0x18, 0x69, 0x24, 0x28, 0x6c, 0x0, 0xde, 0x1d, 0x81, 0x31, 0xf7, 0x6d, 0x6, 0x6f, 0x14, 0xf4, 0x70, 0x21, 0xb0, 0x1b, 0xc8, 0xee, 0x49, 0x17, 0xb2, 0xd3, 0x19, 0xe0, 0xf0, 0x73, 0x66, 0x3d, 0xad, 0x6c, 0xcb, 0x48, 0x0, 0xdd, 0xbd, 0x39, 0x1e, 0xdf, 0x74, 0x53, 0xef, 0xc3, 0x7f, 0x87, 0x40, 0xce, 0xe4, 0xd, 0x1a, 0x67, 0xb5, 0x71, 0xd2, 0xd7, 0x27, 0x9d, 0x43, 0x62, 0xc, 0x70, 0xc4, 0xb9, 0x73, 0x7f, 0x24, 0x61, 0x1b, 0x8d, 0xf3, 0xd3, 0xd, 0x77, 0x4f, 0x7d, 0xbf, 0x5c, 0xfc, 0x81, 0x93, 0xee, 0xd8, 0x23, 0xdb, 0xb2, 0xe3, 0x31, 0xd9, 0xec, 0x9, 0x5e, 0x3f, 0x97, 0x13, 0x80, 0xbb, 0x88, 0xef, 0x83, 0x6f, 0xc0, 0x24, 0xe9, 0xbc, 0x63, 0x9c, 0xf4, 0xe2, 0x75, 0x3f, 0xbf, 0x38, 0x71, 0xb, 0x61, 0x22, 0x98, 0x3e, 0xe2, 0xbc, 0x5b, 0x47, 0xd8, 0xcc, 0xce, 0x7, 0x25, 0x75, 0xa3, 0x71, 0xd6, 0x80, 0xe6, 0x75, 0xd2, 0xfc, 0x99, 0xc6, 0x99, 0xb7, 0xe1, 0xee, 0xa9, 0x7f, 0x2e, 0x8e, 0xdf, 0xff, 0xdc, 0x5b, 0xe, 0x95, 0xdb, 0x72, 0x87, 0x6c, 0x76, 0x14, 0xe9, 0xab, 0xc2, 0x5e, 0x4d, 0xe1, 0x49, 0xc7, 0x51, 0xc5, 0x8c, 0x33, 0xb9, 0x87, 0xe7, 0x85, 0x54, 0xe2, 0x9b, 0x62, 0x3, 0x6f, 0xb9, 0xb4, 0x63, 0xb5, 0xb4, 0x88, 0xf0, 0xa8, 0xef, 0x2a, 0x29, 0x6f, 0xeb, 0x6f, 0x72, 0xbe, 0x67, 0x0, 0x41, 0xe7, 0x91, 0x74, 0xd3, 0x9e, 0xe3, 0xd7, 0x2e, 0x98, 0xb2, 0xb3, 0x1a, 0xfa, 0x94, 0x82, 0x9a, 0x19, 0xe0, 0x88, 0xf3, 0xe7, 0xf5, 0x50, 0x76, 0xc7, 0xc3, 0xb2, 0xee, 0x71, 0x80, 0x42, 0x5a, 0x85, 0xd9, 0x42, 0x63, 0xd6, 0x80, 0xce, 0x4a, 0x1a, 0xe7, 0x77, 0x26, 0x95, 0x7e, 0x74, 0xdd, 0x82, 0x29, 0x1f, 0x1c, 0x71, 0xfe, 0x6d, 0x43, 0x6c, 0x66, 0xd7, 0x4d, 0x90, 0x7b, 0x54, 0xa8, 0x18, 0xc2, 0x6e, 0x3e, 0xe0, 0x27, 0xa, 0xca, 0xd9, 0x1c, 0x9, 0x3a, 0xaf, 0x9a, 0x54, 0xc3, 0xbf, 0x6f, 0xb8, 0xfb, 0xd2, 0x85, 0xed, 0x91, 0x55, 0xcd, 0x43, 0x80, 0xdc, 0xe6, 0x1f, 0xcb, 0xba, 0xbe, 0xf1, 0xc6, 0x84, 0xed, 0xf0, 0x7b, 0xc9, 0xba, 0xa3, 0x0, 0x77, 0x94, 0xac, 0x73, 0x86, 0xac, 0x3b, 0xae, 0xff, 0xc4, 0xb9, 0x7f, 0x57, 0xb6, 0x79, 0x38, 0x64, 0x8f, 0xf2, 0x6c, 0xf4, 0xb9, 0x7e, 0xdf, 0x17, 0xf8, 0xca, 0xb5, 0xe0, 0xb6, 0x98, 0xf5, 0x2b, 0x69, 0x95, 0xc5, 0x3e, 0x9f, 0xe1, 0xfb, 0x72, 0x71, 0xdb, 0x52, 0xd6, 0xf0, 0x77, 0x71, 0xe5, 0x2c, 0xec, 0x11, 0x3c, 0xe9, 0x97, 0xb9, 0xf9, 0x26, 0x1a, 0xe7, 0xa9, 0xc6, 0x6e, 0x3d, 0xef, 0xa9, 0x95, 0x4e, 0x71, 0x50, 0x53, 0xab, 0x1b, 0x70, 0xfe, 0x6d, 0x5f, 0xb0, 0x99, 0x9d, 0xbf, 0x90, 0x37, 0x8b, 0x9f, 0xa3, 0x62, 0x48, 0x82, 0x97, 0x82, 0x3c, 0xa, 0x3c, 0xee, 0x68, 0x25, 0x85, 0xad, 0xfd, 0x5d, 0xad, 0x3f, 0x4, 0x9e, 0x25, 0x90, 0x34, 0x4e, 0xea, 0x45, 0x3a, 0xd, 0xd7, 0xad, 0xbf, 0xeb, 0xe2, 0xe7, 0xda, 0x2b, 0xaf, 0xaa, 0x7b, 0x80, 0x81, 0x93, 0xee, 0x38, 0xd8, 0xcd, 0xec, 0xfc, 0xbe, 0x2, 0xa3, 0x95, 0xef, 0x58, 0xc5, 0x90, 0xff, 0x4e, 0xce, 0x98, 0x27, 0x8, 0x26, 0x4f, 0x64, 0x8f, 0xf8, 0x7e, 0xb7, 0x5f, 0xcd, 0x5c, 0x5d, 0x12, 0xf3, 0x7b, 0xd5, 0xb0, 0x5e, 0xa9, 0x6f, 0x8a, 0x1c, 0xc7, 0x2b, 0xae, 0x47, 0xe1, 0x77, 0xde, 0x9d, 0x71, 0xee, 0x69, 0x4f, 0xe2, 0x3, 0x55, 0x5a, 0x2, 0x7, 0x4c, 0x9a, 0xd7, 0x60, 0x6d, 0xf6, 0x5a, 0x59, 0xfb, 0x69, 0x7f, 0xf2, 0xc6, 0x9b, 0x5d, 0x2f, 0x12, 0xdf, 0x73, 0xcf, 0x45, 0xe3, 0xbb, 0x37, 0xe7, 0x91, 0x73, 0xac, 0xa9, 0x1c, 0x2a, 0xfc, 0x46, 0x2a, 0xe8, 0x9f, 0x15, 0xfc, 0x13, 0x50, 0xe0, 0x3e, 0x20, 0x95, 0x49, 0xa8, 0xd4, 0xc4, 0x12, 0x8b, 0x7e, 0x2b, 0xad, 0x7, 0x8b, 0x5f, 0x30, 0x5e, 0x8e, 0x4c, 0x10, 0x2a, 0x66, 0x80, 0x81, 0x17, 0xce, 0x77, 0x20, 0x3b, 0xda, 0x66, 0x5b, 0xae, 0xcd, 0x9b, 0xc1, 0xc3, 0x53, 0x76, 0x9d, 0x7b, 0x29, 0x34, 0x43, 0xe7, 0xdf, 0xfb, 0x73, 0xed, 0x1e, 0x81, 0x25, 0xd0, 0x37, 0x34, 0xe4, 0xae, 0xe0, 0x1d, 0xa3, 0x6d, 0x73, 0xf2, 0xd3, 0xca, 0xdd, 0xb7, 0xff, 0xe5, 0x33, 0xa9, 0xdc, 0x2f, 0xc, 0x98, 0x74, 0xc7, 0xf1, 0xed, 0xc9, 0x0, 0x15, 0xb7, 0xbf, 0x41, 0x17, 0xce, 0xef, 0x93, 0x6d, 0xd9, 0xf9, 0x0, 0xac, 0x3b, 0xd2, 0xeb, 0xc0, 0xe3, 0x54, 0xb7, 0x4a, 0x8a, 0x50, 0x4a, 0x65, 0x2, 0x4a, 0xb, 0x5c, 0x39, 0xc8, 0x77, 0xa2, 0xa, 0xd4, 0xa7, 0x82, 0xb4, 0x3e, 0x0, 0xf9, 0x3e, 0x80, 0x6d, 0x0, 0x76, 0x92, 0xdc, 0x5, 0xd2, 0x42, 0x8, 0xe4, 0x91, 0x14, 0x80, 0x26, 0x9, 0xdd, 0x20, 0xbb, 0xf, 0xa0, 0x5e, 0x90, 0x6f, 0x2a, 0x67, 0x4c, 0x1e, 0x35, 0x6b, 0x2e, 0x11, 0xf5, 0x93, 0xe7, 0x13, 0x0, 0xc2, 0x42, 0x32, 0x34, 0xce, 0x93, 0x26, 0xd5, 0x78, 0xd9, 0xba, 0x85, 0x17, 0xbd, 0x5a, 0x5b, 0x5e, 0xa5, 0x4b, 0xd0, 0x26, 0x18, 0x7c, 0xc5, 0x33, 0xcc, 0x7e, 0xf8, 0xea, 0x19, 0x36, 0xb3, 0xf3, 0x21, 0x0, 0x16, 0x81, 0x12, 0x1f, 0xae, 0x8a, 0xe2, 0x13, 0x2d, 0x18, 0xf2, 0x22, 0x4, 0xe7, 0x3c, 0xef, 0x7, 0xe6, 0xaf, 0xfc, 0x87, 0xad, 0xc8, 0xee, 0x8b, 0x1d, 0xa, 0xd6, 0x8a, 0x84, 0xe6, 0x66, 0xfd, 0x98, 0x2d, 0x34, 0xce, 0x3f, 0x24, 0xbc, 0x4d, 0x9a, 0x4d, 0x30, 0x66, 0x1d, 0xc0, 0x97, 0x48, 0xfe, 0x15, 0xe0, 0x3b, 0x20, 0xdf, 0x23, 0xd4, 0xec, 0x5a, 0x65, 0xd2, 0xe9, 0x86, 0x46, 0xeb, 0x66, 0xba, 0x1, 0xd8, 0xd7, 0x5a, 0xdb, 0x7, 0xd2, 0x0, 0xc9, 0x8e, 0x24, 0x74, 0xb0, 0xa4, 0x8f, 0x1, 0x3a, 0x0, 0xb2, 0xfb, 0x86, 0xab, 0xc2, 0x90, 0xcf, 0x7a, 0x1, 0x33, 0xa8, 0x75, 0x7d, 0xa, 0xe4, 0xfd, 0x8, 0x33, 0x40, 0x41, 0x13, 0xa, 0x3b, 0xc6, 0x7a, 0x35, 0xb2, 0x74, 0x1a, 0xe6, 0x34, 0xef, 0xdc, 0x7e, 0xd5, 0x5f, 0x1e, 0xb8, 0x3a, 0xf1, 0x15, 0x48, 0x15, 0x9, 0x81, 0xee, 0x96, 0xbf, 0xd, 0x92, 0xdb, 0xf2, 0x7d, 0x80, 0xa0, 0x6f, 0xb0, 0xf7, 0xb0, 0x9f, 0x9b, 0xb7, 0x40, 0xde, 0x23, 0xab, 0x88, 0x82, 0xb9, 0xa7, 0xd0, 0xff, 0x1c, 0xc5, 0x43, 0x2c, 0xc3, 0xa8, 0xc6, 0xdb, 0x2a, 0x2c, 0xb0, 0x93, 0x4, 0x62, 0x86, 0xfc, 0x29, 0x78, 0x80, 0x7c, 0xf, 0x30, 0x9b, 0x4, 0xb3, 0x96, 0x4e, 0x6a, 0x71, 0x3a, 0xd5, 0xf0, 0xe0, 0xea, 0x3b, 0x27, 0x95, 0x33, 0xa0, 0xb4, 0x0, 0xd8, 0xa, 0xe0, 0x2d, 0x0, 0x1b, 0x1, 0x3c, 0x15, 0xbc, 0x18, 0x30, 0xe9, 0xce, 0x7e, 0xb2, 0x99, 0x89, 0x80, 0x8e, 0x83, 0xec, 0xa1, 0x92, 0x3d, 0x8, 0x42, 0x63, 0xa0, 0xc1, 0x7a, 0x79, 0x2a, 0x50, 0x79, 0x42, 0x66, 0xcc, 0xbc, 0xab, 0x40, 0x58, 0xd, 0xca, 0xd7, 0x3b, 0xa8, 0x17, 0xfc, 0x70, 0xbf, 0x4a, 0xfe, 0xa, 0x88, 0xc0, 0x30, 0x26, 0xc1, 0x48, 0xee, 0x99, 0x4d, 0xdd, 0xf7, 0x5a, 0xe, 0xe0, 0xf6, 0xa4, 0x19, 0xa0, 0xa2, 0x1e, 0x60, 0xe0, 0x5, 0x77, 0x9e, 0xea, 0x66, 0x76, 0x3e, 0x26, 0xc9, 0x84, 0xb1, 0xdf, 0x91, 0x10, 0xb2, 0x15, 0xcb, 0xd7, 0x32, 0x7c, 0xe, 0xe0, 0xfb, 0x24, 0xdf, 0xa2, 0x49, 0xdd, 0x6c, 0x1c, 0x67, 0xf6, 0xda, 0x5, 0x53, 0xda, 0xbc, 0x48, 0xa4, 0xad, 0x30, 0x60, 0xd2, 0xbc, 0x43, 0x21, 0xf7, 0xbb, 0x92, 0x1d, 0x29, 0xeb, 0x7e, 0x2, 0x52, 0x93, 0xbf, 0x4c, 0x2d, 0xd4, 0x10, 0x12, 0xad, 0x6b, 0xde, 0xa7, 0x91, 0xce, 0x12, 0xa6, 0xf6, 0x38, 0x75, 0xfd, 0xc2, 0xb, 0x9a, 0x93, 0xcc, 0xa3, 0x32, 0x6, 0x98, 0x7c, 0x57, 0xa3, 0xcd, 0x36, 0x9f, 0x23, 0xb7, 0xe5, 0x4e, 0x40, 0x4e, 0xe0, 0x80, 0xd9, 0x51, 0xf6, 0xfb, 0x80, 0xf8, 0x61, 0x84, 0x4b, 0xd8, 0x49, 0x60, 0x87, 0x49, 0x37, 0x7e, 0x7b, 0xdd, 0xc2, 0x8b, 0x6e, 0x6c, 0xf7, 0x42, 0x0, 0x18, 0x30, 0xf9, 0xee, 0x94, 0x32, 0xdb, 0xe7, 0xca, 0xba, 0xa7, 0x1, 0xda, 0x3f, 0xb7, 0x78, 0x25, 0xef, 0x26, 0x98, 0x38, 0x42, 0x24, 0xb9, 0x34, 0xa9, 0x7b, 0x36, 0xdc, 0x3d, 0xf5, 0x82, 0x24, 0xd3, 0xad, 0x5c, 0x8, 0x9c, 0xbc, 0x70, 0xf, 0xeb, 0x66, 0x2f, 0xb3, 0xd9, 0xe6, 0x19, 0xf0, 0xc7, 0x5b, 0x4f, 0x14, 0xc8, 0x69, 0x57, 0x25, 0xd2, 0x2c, 0x67, 0x15, 0xb, 0xc7, 0x29, 0xf2, 0xe5, 0xf7, 0xa7, 0x46, 0xe1, 0x59, 0x19, 0xe1, 0x79, 0xd2, 0x3a, 0x5b, 0x61, 0x9c, 0xdb, 0x68, 0x52, 0x5f, 0x5f, 0xbf, 0x70, 0x72, 0x87, 0xb9, 0x52, 0x7, 0x30, 0x70, 0xf2, 0xcf, 0xbb, 0xb9, 0x2d, 0xdb, 0x97, 0x41, 0xb6, 0x2f, 0xc0, 0x3d, 0x2, 0xe7, 0x64, 0x32, 0xf0, 0x48, 0xe, 0x44, 0xa4, 0x52, 0xe, 0xe6, 0xc5, 0x78, 0x88, 0x14, 0x72, 0x25, 0x89, 0xa0, 0x59, 0xed, 0xa4, 0x1a, 0x3f, 0xb7, 0x6e, 0xe1, 0x94, 0xb7, 0xc2, 0x2f, 0x47, 0x5e, 0xb3, 0x94, 0x3b, 0xdf, 0x7b, 0xc5, 0xd0, 0x69, 0xa0, 0xcd, 0x6c, 0x27, 0x4d, 0x9a, 0x0, 0xdd, 0x75, 0xb, 0x2e, 0x70, 0xcb, 0xd5, 0xa1, 0x2a, 0x2e, 0x1d, 0x34, 0xf9, 0xe7, 0x7b, 0x58, 0xb7, 0xe5, 0xdb, 0x36, 0xdb, 0xf2, 0x75, 0x2, 0x26, 0x34, 0xf0, 0x33, 0x69, 0x57, 0xae, 0x70, 0x97, 0xf, 0x8f, 0xf8, 0x2, 0x0, 0x63, 0xcc, 0x66, 0xa6, 0x1a, 0xc7, 0xae, 0x5b, 0x30, 0x39, 0x51, 0x7, 0x89, 0x6a, 0x60, 0xc0, 0xa4, 0x79, 0xd7, 0xd9, 0x6c, 0xf3, 0x37, 0x0, 0xed, 0xcb, 0xb0, 0x47, 0x50, 0x72, 0x26, 0xab, 0x80, 0xe9, 0x41, 0x93, 0x7a, 0x7e, 0xc3, 0xdd, 0x53, 0x8f, 0x1f, 0x34, 0xe5, 0xee, 0x46, 0x9b, 0x6d, 0xa6, 0x71, 0x1a, 0x9a, 0x24, 0xb7, 0x2f, 0xa4, 0x8f, 0x9, 0xea, 0x49, 0xa0, 0x87, 0xa4, 0x3, 0x69, 0x9c, 0x17, 0x20, 0xf7, 0xf9, 0x75, 0xb, 0x2f, 0xca, 0x94, 0x4a, 0xbc, 0xea, 0xc2, 0xd, 0xbc, 0x70, 0x61, 0x83, 0x6c, 0xf6, 0xdf, 0xe5, 0xb6, 0x7c, 0x13, 0x64, 0xb0, 0x20, 0x23, 0xbf, 0xd8, 0x22, 0x49, 0x8, 0x98, 0x4a, 0x82, 0xa4, 0xac, 0x71, 0x52, 0xcf, 0x3b, 0xd, 0xdd, 0xce, 0x5e, 0x33, 0xef, 0xbc, 0xf, 0x92, 0xcf, 0xac, 0x5a, 0x7c, 0x2c, 0x18, 0x63, 0xb3, 0xbb, 0xe6, 0xc9, 0xda, 0x83, 0x3d, 0x43, 0x17, 0x3, 0x49, 0xbe, 0xf6, 0x6, 0x91, 0x5f, 0xdc, 0x2, 0x1, 0xbb, 0x48, 0xf3, 0x1a, 0xa4, 0xde, 0x80, 0x7a, 0x2, 0x28, 0xd2, 0x81, 0x82, 0x7b, 0xae, 0x34, 0xa9, 0xc6, 0xeb, 0xd6, 0x2d, 0x9c, 0xfc, 0x54, 0xa9, 0xa4, 0xab, 0xf6, 0x9, 0x5c, 0xb7, 0xe0, 0x82, 0x16, 0xa7, 0xb1, 0xfb, 0x7f, 0x99, 0x54, 0xe3, 0x75, 0x4, 0xb2, 0x8, 0x69, 0x33, 0x89, 0x9b, 0x45, 0x7c, 0x24, 0x90, 0xcc, 0x1a, 0x27, 0xfd, 0xf0, 0xfa, 0xbb, 0x2e, 0x19, 0x53, 0x4f, 0xc4, 0xf7, 0xf0, 0x71, 0xe1, 0xd3, 0x26, 0xd5, 0x78, 0xa, 0xe9, 0x6c, 0x40, 0x41, 0xd9, 0x6b, 0x77, 0x6d, 0x43, 0xe1, 0x6f, 0x23, 0x64, 0xf, 0x3, 0xb4, 0x17, 0x8a, 0xde, 0x15, 0xde, 0x6b, 0x88, 0xa0, 0x7f, 0x29, 0x57, 0xee, 0x9a, 0x9c, 0x42, 0xd7, 0xdc, 0x3e, 0x3e, 0xeb, 0x34, 0x74, 0x9f, 0x69, 0x52, 0x4d, 0x53, 0x4, 0xbe, 0xdf, 0x76, 0x8b, 0x60, 0x18, 0x4a, 0x85, 0x31, 0xc7, 0xd6, 0x5e, 0xbf, 0x9f, 0x7a, 0x72, 0xfd, 0x5d, 0x17, 0x9f, 0x95, 0x18, 0xd5, 0x12, 0x86, 0x75, 0xb, 0x26, 0xff, 0xc9, 0x34, 0x34, 0x9d, 0x49, 0xe3, 0x2c, 0xf7, 0x2d, 0x8e, 0xfe, 0xf0, 0x15, 0x26, 0x63, 0x31, 0x59, 0x4b, 0x85, 0x79, 0xcf, 0x7e, 0x7, 0x2b, 0xd2, 0xc8, 0xf3, 0x31, 0xd, 0x2e, 0x8a, 0x34, 0xc1, 0xd4, 0x51, 0x51, 0x47, 0x6c, 0xc, 0x81, 0x4f, 0x7e, 0xea, 0xc2, 0x87, 0x4a, 0xf6, 0x3e, 0x35, 0x7b, 0x5, 0xaf, 0xbe, 0xfd, 0x9c, 0x2c, 0x53, 0xd, 0xf7, 0x93, 0xdc, 0x51, 0x64, 0xa, 0x29, 0x1, 0x51, 0xcc, 0x50, 0x18, 0x26, 0xbf, 0x1f, 0x83, 0xe7, 0x2b, 0x0, 0xe3, 0xa4, 0x9f, 0x6c, 0x49, 0xf7, 0x3a, 0xbd, 0xdd, 0xa8, 0x97, 0x10, 0xac, 0x9b, 0x7f, 0xc1, 0x2b, 0x26, 0xd5, 0x38, 0x85, 0xc6, 0x59, 0x82, 0xfc, 0xec, 0x28, 0xa2, 0x99, 0x1c, 0x65, 0xc2, 0xf2, 0xcf, 0xcc, 0xdb, 0xa9, 0xc3, 0xef, 0x99, 0x7f, 0x95, 0x8b, 0x27, 0x4f, 0x39, 0x12, 0xac, 0xcd, 0x9e, 0xd7, 0x9d, 0x1f, 0x4e, 0x2c, 0x55, 0xde, 0x44, 0xdc, 0xc2, 0x6d, 0x36, 0xd3, 0xf, 0x40, 0xda, 0xa3, 0x17, 0x13, 0x71, 0xe7, 0x26, 0xd, 0x5, 0x58, 0x6f, 0x4a, 0x3c, 0xfd, 0xa8, 0x93, 0x6e, 0x1a, 0xff, 0xf2, 0xbc, 0xd3, 0x77, 0x8b, 0xcd, 0x98, 0xd6, 0xce, 0xbf, 0x60, 0x23, 0x4c, 0x6a, 0x16, 0xe9, 0xbc, 0xec, 0x4d, 0x31, 0x18, 0xc9, 0x53, 0x97, 0x6a, 0xc6, 0x4b, 0x1b, 0x2e, 0x6, 0xb3, 0x6d, 0x90, 0xfa, 0xca, 0xaa, 0x7f, 0xfb, 0x33, 0x80, 0x9b, 0x99, 0x1, 0x70, 0xdf, 0x9a, 0x13, 0x2a, 0x4, 0x1, 0x34, 0x34, 0xce, 0x5a, 0x9a, 0xf4, 0xd, 0x6b, 0xe6, 0x9d, 0xf7, 0x61, 0x7b, 0x11, 0xac, 0x3d, 0x60, 0xfd, 0xc2, 0xc9, 0xf7, 0xc0, 0xa4, 0x6e, 0x7, 0xb9, 0xcd, 0xb7, 0x57, 0x75, 0x98, 0xd1, 0x2c, 0xbc, 0x48, 0x56, 0x50, 0x8f, 0x52, 0x71, 0x6b, 0x66, 0x80, 0x23, 0xa7, 0xdc, 0xb5, 0x17, 0x60, 0x87, 0x92, 0x48, 0xe5, 0xf5, 0xde, 0x44, 0xc4, 0x1e, 0x92, 0xdc, 0x42, 0x93, 0x5a, 0xb0, 0x76, 0xfe, 0xa4, 0xc7, 0x3a, 0xa, 0x79, 0x49, 0x82, 0x31, 0xce, 0x2c, 0x9a, 0xd4, 0xbd, 0xbe, 0x8d, 0x3a, 0x98, 0x25, 0x69, 0xf7, 0x19, 0xc5, 0x80, 0xf8, 0xbe, 0xf6, 0x7c, 0xe4, 0xc0, 0xc9, 0xb, 0x87, 0xc4, 0x96, 0xb1, 0x96, 0xa, 0x1e, 0x7d, 0xed, 0xef, 0x8, 0x72, 0x38, 0x80, 0xb4, 0x97, 0xa1, 0xd7, 0xcd, 0xd5, 0xd2, 0x83, 0xf9, 0x5, 0xf7, 0x2a, 0xe0, 0xa4, 0x1e, 0x0, 0x4d, 0xe2, 0xf6, 0xef, 0x8e, 0x82, 0xb5, 0xf3, 0x27, 0x6d, 0x31, 0x4e, 0xfa, 0x36, 0x18, 0x67, 0x29, 0xfc, 0x3e, 0xd9, 0x9f, 0xe9, 0xab, 0xc, 0x27, 0x11, 0xf7, 0x88, 0x9, 0xf7, 0x47, 0x1, 0xff, 0x3f, 0x1, 0x6b, 0x4f, 0x80, 0x74, 0x76, 0x5c, 0x19, 0x6b, 0x62, 0x80, 0x6d, 0xff, 0xd8, 0x48, 0xeb, 0x66, 0xcf, 0x25, 0x4d, 0xca, 0x2f, 0x51, 0xcd, 0xeb, 0x79, 0x7c, 0x75, 0x9f, 0xa0, 0x79, 0x15, 0x30, 0xf7, 0xaf, 0x9b, 0x3f, 0xa9, 0xa2, 0xdd, 0xbf, 0xea, 0xd, 0xd6, 0xde, 0x79, 0xfe, 0xb, 0x34, 0xa9, 0xc5, 0x0, 0x0, 0x1a, 0x11, 0xac, 0x58, 0x31, 0x64, 0xc4, 0x3d, 0x63, 0xc2, 0x8b, 0xf0, 0x28, 0x92, 0xd, 0x24, 0xfa, 0xc6, 0x95, 0xaf, 0x26, 0x6, 0x58, 0x7f, 0xd7, 0xc5, 0x56, 0x6e, 0x76, 0x2c, 0xa0, 0x34, 0x69, 0xc2, 0x5b, 0xaf, 0x54, 0x7e, 0x91, 0x81, 0xe4, 0xef, 0xf5, 0x22, 0xc6, 0x59, 0x44, 0x63, 0x1e, 0xef, 0x6c, 0x2, 0x26, 0x1, 0xa4, 0x59, 0x4c, 0x93, 0x7a, 0x12, 0xfe, 0x7e, 0x46, 0x28, 0x35, 0xc, 0xb0, 0xb6, 0x6, 0x54, 0x98, 0x16, 0x82, 0x6e, 0xb5, 0xf1, 0xd3, 0xe3, 0xe7, 0x46, 0xd2, 0xba, 0x26, 0x6, 0x18, 0x74, 0xd1, 0x3d, 0x7d, 0x41, 0xf4, 0xf6, 0xc4, 0x76, 0x28, 0xa7, 0xf2, 0x56, 0x39, 0xec, 0xfb, 0x92, 0x3f, 0x49, 0xf3, 0x16, 0x8d, 0xf3, 0xd4, 0xda, 0x3b, 0xcf, 0xdf, 0xde, 0xd9, 0xc4, 0x4b, 0x2, 0xd6, 0xde, 0x79, 0xfe, 0x5a, 0x3a, 0xa9, 0xf9, 0x5e, 0x25, 0x73, 0xe, 0x1f, 0x25, 0xc4, 0x9f, 0xda, 0x2f, 0xcf, 0xaf, 0xc4, 0x50, 0x9e, 0xf5, 0xb4, 0x67, 0x63, 0xb7, 0x1e, 0x7, 0x46, 0x95, 0xad, 0x6a, 0x6, 0x18, 0x7c, 0xc9, 0xfd, 0x29, 0x59, 0x3b, 0xa, 0xa0, 0x4d, 0xa2, 0xe4, 0x81, 0x1, 0x3, 0x20, 0x68, 0x9c, 0xf9, 0x34, 0xce, 0x8a, 0xce, 0x26, 0x5c, 0xa2, 0x40, 0xf3, 0x57, 0xd2, 0xbc, 0x8b, 0x76, 0x76, 0x9f, 0xb, 0x5c, 0xe2, 0xfc, 0x1d, 0x67, 0xe0, 0x73, 0xc3, 0xc1, 0x10, 0x3e, 0x1d, 0x55, 0xac, 0xaa, 0x19, 0x60, 0xf5, 0x6d, 0x67, 0x67, 0x9, 0x7d, 0x26, 0x34, 0xd3, 0x55, 0x93, 0x9a, 0xc3, 0xdc, 0x46, 0x4e, 0x0, 0x4d, 0x6a, 0xd9, 0x9a, 0x3b, 0x26, 0xee, 0xd6, 0x63, 0x7f, 0x31, 0x18, 0x63, 0xd6, 0x9b, 0x54, 0xc3, 0x6c, 0xff, 0x51, 0x91, 0x5b, 0x91, 0xd7, 0x0, 0x85, 0x3e, 0x9, 0x9e, 0x22, 0xe8, 0xd, 0xa5, 0xe6, 0x15, 0x3a, 0xa9, 0xfb, 0x49, 0xf3, 0x46, 0xd4, 0x77, 0x6d, 0xf6, 0x8, 0x1a, 0x74, 0xd1, 0xdd, 0x4d, 0xa4, 0xb3, 0xbf, 0xac, 0xed, 0x2b, 0xe8, 0x40, 0x2, 0x7b, 0x43, 0xee, 0x98, 0xdc, 0x86, 0x8d, 0xc9, 0xa8, 0xb9, 0x24, 0xb9, 0x9, 0xe0, 0xa6, 0x24, 0x91, 0x53, 0xf, 0xb0, 0xfa, 0xf6, 0x9, 0x9b, 0x7, 0x7f, 0x71, 0xd1, 0x43, 0x0, 0xfe, 0x3, 0x0, 0x61, 0x12, 0x30, 0xc1, 0x84, 0x26, 0x80, 0x48, 0x12, 0xb2, 0xca, 0xeb, 0x1, 0x7c, 0x97, 0xc6, 0x79, 0x96, 0x74, 0x16, 0x64, 0x65, 0x16, 0x6f, 0xb8, 0x73, 0x42, 0x36, 0x2a, 0x89, 0x58, 0x6, 0x18, 0x74, 0xd1, 0xbd, 0x3d, 0x21, 0x1d, 0xe, 0xe8, 0x40, 0x90, 0x7b, 0x41, 0xea, 0x25, 0x65, 0x8f, 0x90, 0x75, 0x8f, 0x83, 0xf4, 0xe9, 0x60, 0xe1, 0x7a, 0x68, 0x51, 0x67, 0xad, 0x1e, 0x31, 0x9e, 0x3b, 0x21, 0x53, 0x33, 0x4, 0xac, 0x69, 0x2f, 0x42, 0x74, 0x26, 0x8, 0xb0, 0xa0, 0x79, 0x1f, 0xd2, 0x3e, 0x9, 0x35, 0x97, 0xc0, 0x21, 0xc7, 0x73, 0x8e, 0x1, 0x29, 0x70, 0x33, 0xc9, 0x55, 0x34, 0xa9, 0x87, 0x8c, 0x93, 0x9a, 0xbf, 0xfa, 0xf6, 0xf1, 0x9b, 0x4b, 0x25, 0x11, 0xc9, 0x0, 0x83, 0xbf, 0xb8, 0x68, 0x7f, 0x2b, 0xf7, 0x7c, 0x59, 0x77, 0x3a, 0x64, 0xf, 0x2f, 0xcc, 0x33, 0xa7, 0xb0, 0x7b, 0x4e, 0xa, 0xf0, 0xf9, 0xad, 0xb6, 0x1e, 0x20, 0x67, 0x2c, 0x37, 0x8e, 0xf3, 0xfc, 0x9a, 0x3b, 0x26, 0x6e, 0x4b, 0x8, 0xe7, 0x75, 0x5, 0x92, 0xb6, 0x3, 0xf8, 0x33, 0x80, 0x91, 0x40, 0xa2, 0xdb, 0xd7, 0x51, 0xe0, 0x3f, 0xe8, 0x38, 0xaf, 0x11, 0xe6, 0x41, 0x90, 0x3f, 0x5d, 0x3b, 0xef, 0xdc, 0x36, 0x9, 0xd0, 0x31, 0x3d, 0x80, 0xc6, 0xcb, 0x75, 0xbf, 0x5, 0xe8, 0x63, 0x60, 0xd8, 0xf1, 0xb3, 0xc0, 0x41, 0x23, 0x34, 0x3f, 0xd1, 0x26, 0xb7, 0xed, 0x92, 0x15, 0xc8, 0xff, 0x7c, 0x74, 0xd7, 0x86, 0x93, 0x7c, 0x1b, 0x26, 0xf5, 0x88, 0x6c, 0x76, 0x24, 0x22, 0x5d, 0xca, 0x83, 0xa0, 0x72, 0x4b, 0x90, 0x82, 0x77, 0xca, 0xe1, 0x8d, 0x4e, 0xfa, 0x47, 0xae, 0xab, 0x19, 0x1b, 0x16, 0x9c, 0x57, 0xd6, 0xb, 0x28, 0xc, 0x91, 0x3, 0x91, 0x80, 0x5e, 0x0, 0x1a, 0xbc, 0x42, 0x7b, 0x53, 0x8f, 0x79, 0xe9, 0xd2, 0x14, 0x49, 0xb1, 0x40, 0xe9, 0xe7, 0x8a, 0x6c, 0x1, 0xbb, 0x4, 0x54, 0x54, 0x81, 0xdd, 0x9, 0xd6, 0xdc, 0x31, 0xe1, 0x7d, 0x1a, 0xe7, 0x49, 0x1f, 0x47, 0x11, 0xb6, 0x80, 0x0, 0x8a, 0x9f, 0x11, 0xf3, 0x2e, 0xf7, 0xed, 0x7, 0x80, 0xb9, 0xad, 0x52, 0xe2, 0x3, 0x31, 0x3d, 0x80, 0x64, 0xf, 0x0, 0xb0, 0x97, 0x37, 0xbf, 0xac, 0xfc, 0xc6, 0x36, 0xde, 0x5b, 0x54, 0xd6, 0x73, 0xb5, 0x69, 0x95, 0x6c, 0xb0, 0x2e, 0xe7, 0x1d, 0x82, 0x1d, 0xee, 0xdb, 0xd7, 0x91, 0x40, 0xf2, 0x3d, 0x1f, 0xaf, 0x3e, 0x46, 0x8b, 0x5b, 0x7d, 0x2e, 0x66, 0x4c, 0xa, 0xa1, 0xb5, 0x29, 0xc1, 0xa2, 0x8, 0xc3, 0xb4, 0xe3, 0x38, 0x4d, 0xd5, 0x94, 0x27, 0x7a, 0x8, 0x10, 0x7a, 0xe6, 0xed, 0xcb, 0xc5, 0x63, 0x55, 0xa5, 0x3d, 0x74, 0xb9, 0xf8, 0x61, 0x2c, 0xf0, 0x75, 0x10, 0x89, 0xbb, 0x73, 0xd7, 0x15, 0xd0, 0x8, 0x84, 0x65, 0x68, 0x51, 0x4d, 0x8, 0xf, 0x6d, 0x49, 0x20, 0x7f, 0x97, 0x1f, 0x2d, 0x53, 0x81, 0x3c, 0x56, 0x29, 0x44, 0x32, 0x0, 0x8d, 0x69, 0x90, 0x6b, 0xbd, 0x1d, 0x2c, 0x3b, 0x60, 0x1a, 0x33, 0xe7, 0xf2, 0x47, 0xf3, 0x6, 0xc0, 0x8f, 0x34, 0x3, 0x10, 0x70, 0x9, 0xbe, 0x2f, 0x69, 0xbf, 0x4, 0x51, 0x9b, 0xaa, 0x56, 0x9c, 0x4c, 0x68, 0x9f, 0xc0, 0x72, 0xe3, 0x15, 0x4b, 0xbe, 0xf3, 0x1a, 0x3, 0x41, 0xf2, 0x4d, 0x48, 0x1f, 0x69, 0x6, 0x10, 0xe0, 0xa, 0xfc, 0xb0, 0xd0, 0xc1, 0x27, 0x6a, 0xfc, 0x8f, 0xc3, 0x1d, 0xc3, 0x69, 0xe5, 0xce, 0x2f, 0xaa, 0xd6, 0x1b, 0x37, 0x46, 0xb, 0xc8, 0xa9, 0x7a, 0x68, 0xd5, 0xfb, 0xc7, 0xa, 0xf8, 0x8c, 0x7e, 0x9f, 0xb, 0x63, 0xc9, 0xef, 0xe5, 0x2f, 0xa2, 0xfb, 0xe8, 0xea, 0x0, 0x7e, 0x3d, 0x73, 0xf5, 0x67, 0xcc, 0x6f, 0x14, 0xc4, 0x31, 0x41, 0x58, 0xbe, 0xaa, 0xe, 0x71, 0xd1, 0x43, 0x0, 0x0, 0x5, 0xd4, 0x8a, 0xcc, 0x3b, 0x1c, 0xa8, 0x88, 0xf7, 0x25, 0xca, 0xcf, 0xf0, 0x4d, 0x78, 0x55, 0x2c, 0x1, 0xe0, 0x0, 0xd0, 0x54, 0x25, 0xcc, 0xec, 0x2e, 0x40, 0xd2, 0x11, 0xb0, 0x77, 0x69, 0x7a, 0x85, 0x9, 0x1c, 0x77, 0xf, 0xd0, 0x3f, 0x5b, 0x43, 0x82, 0x6b, 0xad, 0xad, 0xca, 0xb4, 0x1c, 0xad, 0x5, 0x0, 0x2d, 0x79, 0xcb, 0x5e, 0x39, 0x83, 0x45, 0x2d, 0x4d, 0xb6, 0x90, 0x91, 0x8, 0xf4, 0x21, 0xf9, 0x91, 0x67, 0x0, 0x92, 0xfb, 0xb4, 0x6d, 0xb9, 0x0, 0xdb, 0x78, 0xaf, 0x6c, 0xb5, 0x64, 0x88, 0x1e, 0x2, 0xc8, 0xf, 0x19, 0xd8, 0xaa, 0xb, 0x8e, 0xef, 0x8, 0xfa, 0xe8, 0xfc, 0x26, 0x56, 0x5e, 0x9c, 0x10, 0x8f, 0x94, 0xdd, 0x46, 0xa5, 0x88, 0x9f, 0x7c, 0x63, 0xa6, 0x9f, 0xcf, 0x81, 0x0, 0x1a, 0x13, 0xc1, 0x74, 0xdd, 0x82, 0xf2, 0x7b, 0xa9, 0x28, 0x68, 0x5f, 0xc5, 0x50, 0xac, 0x71, 0x17, 0xf5, 0x94, 0x2c, 0x5a, 0x73, 0xe, 0x66, 0x43, 0x1b, 0x74, 0x55, 0x4, 0x91, 0x42, 0x20, 0x61, 0xde, 0x20, 0xb8, 0x85, 0xe1, 0x15, 0x27, 0x40, 0x91, 0x5c, 0x10, 0xb2, 0x7, 0x15, 0xcb, 0x9, 0xa5, 0x64, 0xc2, 0xe2, 0x97, 0x21, 0x9b, 0xa2, 0xa4, 0x8f, 0xeb, 0x23, 0xcf, 0x0, 0xec, 0x5, 0x20, 0xd8, 0x53, 0x0, 0x28, 0x25, 0xf4, 0x15, 0xc, 0x97, 0x21, 0x9c, 0x7, 0x32, 0x9a, 0x2f, 0x48, 0x12, 0xcc, 0x0, 0xa8, 0xea, 0xd0, 0xa9, 0x18, 0x4b, 0xa0, 0xde, 0x2, 0xd9, 0x82, 0x60, 0xc1, 0x81, 0xc7, 0xb6, 0x8, 0x76, 0x44, 0x60, 0x3b, 0xfc, 0xf9, 0x5a, 0x40, 0x13, 0xeb, 0x68, 0x3, 0xeb, 0xa4, 0x61, 0xf0, 0xd4, 0x5f, 0xed, 0x6b, 0xad, 0x7b, 0x8a, 0x8f, 0x57, 0x26, 0x85, 0x3b, 0x49, 0x7b, 0x3, 0xfa, 0xe6, 0xe0, 0x8b, 0x7f, 0x51, 0xb1, 0x56, 0x17, 0xed, 0x26, 0xe4, 0xa4, 0x1e, 0x4, 0x9d, 0x6f, 0xd3, 0x38, 0xcf, 0x6, 0x3e, 0x5a, 0xde, 0xaf, 0xaf, 0xaf, 0x3, 0x40, 0xfe, 0x8, 0xc7, 0x3c, 0x37, 0x16, 0x34, 0xee, 0x98, 0x6e, 0x20, 0x1c, 0x3f, 0xb0, 0x68, 0x41, 0xa2, 0x31, 0x5, 0x61, 0x1f, 0x45, 0x20, 0x4d, 0x2f, 0x40, 0xa7, 0xe5, 0x10, 0x17, 0x65, 0xd5, 0xcd, 0xbd, 0x63, 0x99, 0x9e, 0x34, 0x7f, 0x43, 0x43, 0xc8, 0xba, 0x97, 0x3, 0x7c, 0x7a, 0xf0, 0x25, 0xf7, 0xfd, 0xf7, 0xe0, 0xa9, 0xf, 0xec, 0xdd, 0xe6, 0x32, 0xc5, 0xbd, 0x18, 0x3c, 0xf5, 0x57, 0xdd, 0x1, 0xf6, 0x85, 0xec, 0x41, 0x20, 0x7a, 0x43, 0x38, 0x4, 0xd0, 0x27, 0x25, 0x7b, 0x24, 0x81, 0x81, 0xf0, 0xe7, 0xa, 0x80, 0xf0, 0x36, 0xaf, 0x35, 0x51, 0xcf, 0x3f, 0xf, 0x32, 0xf5, 0x75, 0xe3, 0xa4, 0x6f, 0x5c, 0x75, 0xf3, 0xbf, 0xb6, 0xf9, 0x4, 0xae, 0xdd, 0x5, 0x86, 0x5c, 0xfa, 0xc0, 0x30, 0x9b, 0x6d, 0xf9, 0xd, 0x80, 0xbd, 0x93, 0x30, 0x2, 0x85, 0xf6, 0xc7, 0x9, 0x6f, 0xba, 0xb9, 0x85, 0x34, 0x2b, 0x5, 0x3e, 0x44, 0x63, 0xee, 0x5c, 0x7d, 0xeb, 0x59, 0x25, 0xf, 0x9f, 0x6a, 0x73, 0x29, 0x86, 0x5d, 0xfe, 0x70, 0xf, 0x6b, 0xdd, 0x7d, 0x65, 0xed, 0x1, 0x34, 0x66, 0x7f, 0x59, 0xdb, 0xb, 0x72, 0xaf, 0x96, 0x6c, 0xff, 0xd6, 0x66, 0xcd, 0x1a, 0x2a, 0x44, 0xbe, 0xe9, 0x38, 0xd, 0x13, 0x56, 0xdd, 0x32, 0xf6, 0x85, 0x24, 0xd2, 0xac, 0x27, 0x18, 0x3c, 0xf5, 0x57, 0x23, 0xe5, 0x66, 0x5e, 0xf4, 0x77, 0x15, 0x49, 0x62, 0x15, 0x7d, 0xab, 0xa3, 0x66, 0x82, 0xd3, 0xc7, 0x4, 0x6c, 0x26, 0xcd, 0xb, 0x34, 0xce, 0x42, 0xc7, 0x98, 0xfb, 0x56, 0xde, 0x3c, 0x36, 0x72, 0x99, 0x78, 0x9b, 0x3d, 0x82, 0x56, 0xce, 0x3d, 0x63, 0x2b, 0xbc, 0x7d, 0x74, 0x5e, 0xb, 0x55, 0x68, 0x20, 0x2d, 0xfa, 0x79, 0x25, 0x49, 0x64, 0xd3, 0x2c, 0x1, 0xe8, 0x63, 0xa5, 0x83, 0x6a, 0xc5, 0x4c, 0xbd, 0xc1, 0xd0, 0xcb, 0x16, 0xef, 0x67, 0x6d, 0x76, 0x9c, 0x3f, 0xcc, 0x55, 0x61, 0x62, 0x8f, 0xd4, 0xc6, 0xb, 0xf4, 0xe8, 0xd0, 0xbe, 0x8c, 0x22, 0xb0, 0x2f, 0xa0, 0x33, 0x61, 0xdd, 0xc1, 0x2e, 0x30, 0x74, 0xf0, 0xd4, 0x7, 0x17, 0xac, 0xbe, 0x75, 0xec, 0xba, 0xe2, 0x4, 0xaa, 0x6e, 0xb9, 0xc3, 0xa6, 0x3f, 0x96, 0x32, 0x34, 0xbf, 0xf7, 0x48, 0xef, 0x2f, 0x45, 0xaa, 0x68, 0xf6, 0x37, 0x34, 0xce, 0xf9, 0xaa, 0x65, 0xde, 0xb1, 0x44, 0x9f, 0x19, 0x7a, 0xd9, 0x83, 0xfb, 0x77, 0x14, 0x71, 0x3a, 0x6, 0x34, 0x0, 0xd6, 0x9d, 0xee, 0xf, 0x94, 0x2c, 0xa8, 0x7b, 0x9b, 0xfc, 0x44, 0x59, 0x6, 0x87, 0x41, 0xfb, 0xcb, 0x9d, 0x5b, 0x24, 0x6f, 0x22, 0x4f, 0x9f, 0x80, 0xec, 0x38, 0x52, 0x7d, 0xa2, 0x4a, 0x55, 0x35, 0x3, 0xac, 0x9c, 0xf3, 0xf9, 0xac, 0x80, 0x17, 0xe0, 0x9f, 0xa3, 0x5a, 0x9d, 0xdc, 0x9f, 0x2f, 0xb7, 0xa7, 0x6d, 0x4, 0x9a, 0x86, 0xbd, 0x40, 0xc2, 0x88, 0xce, 0x26, 0x59, 0x92, 0x20, 0xd9, 0x43, 0x1, 0xec, 0x7, 0x50, 0x85, 0xcb, 0x3b, 0xc2, 0x78, 0xa8, 0x1c, 0x87, 0x28, 0xfe, 0xb6, 0x50, 0xbb, 0xa0, 0xdf, 0xad, 0xbe, 0x4a, 0xe3, 0x6c, 0x8c, 0x2a, 0x57, 0x4d, 0x63, 0xf7, 0x1f, 0x6e, 0x19, 0xfb, 0x2a, 0x8d, 0x79, 0x33, 0x98, 0x32, 0x8e, 0x76, 0x74, 0x8d, 0x9a, 0xf4, 0x88, 0xb3, 0x6d, 0x53, 0x0, 0x5, 0xe9, 0xe3, 0xb2, 0xf6, 0xe4, 0x21, 0x97, 0x2d, 0xee, 0xd9, 0xb9, 0x64, 0x4b, 0x6, 0x6, 0x5f, 0xfa, 0xe0, 0x60, 0x59, 0x4d, 0xf6, 0x55, 0xdd, 0xdc, 0x36, 0x37, 0x49, 0x40, 0xac, 0xd7, 0x40, 0xce, 0x96, 0xf, 0x10, 0xdc, 0xd2, 0xd0, 0xfd, 0x63, 0xaf, 0x47, 0xc5, 0xab, 0x89, 0x1, 0x6, 0x5f, 0x72, 0x9f, 0x1, 0xcc, 0x3, 0x2, 0x32, 0x2, 0x90, 0x53, 0xe5, 0xa, 0x2e, 0x14, 0x75, 0x61, 0xc5, 0x5d, 0x5f, 0x41, 0x78, 0x9e, 0x71, 0xa1, 0xf1, 0xb2, 0xf6, 0xd4, 0xc4, 0xa9, 0xd1, 0x9, 0x40, 0xe0, 0xc, 0xc0, 0x8e, 0xf1, 0x1c, 0xab, 0x0, 0x76, 0xc0, 0x89, 0x68, 0x34, 0x39, 0x5f, 0x3e, 0x90, 0x66, 0x57, 0xf1, 0x9, 0xa6, 0x1, 0xd4, 0xc4, 0x0, 0xd, 0x3d, 0x7a, 0xb, 0x34, 0xf7, 0x4a, 0xc8, 0xfa, 0x54, 0x8c, 0x98, 0x19, 0x2a, 0x35, 0x25, 0x5c, 0x1c, 0xb7, 0x60, 0x37, 0xb0, 0x83, 0x49, 0x9d, 0x3d, 0xe4, 0xd2, 0x87, 0x7a, 0x77, 0x36, 0x1, 0x6b, 0x81, 0x21, 0x97, 0x3e, 0x74, 0x2, 0x64, 0xc7, 0xe6, 0x25, 0xff, 0xf0, 0xa, 0xea, 0xb6, 0xe0, 0xaa, 0x54, 0x58, 0xdc, 0xb7, 0x61, 0x13, 0x2d, 0x77, 0xd1, 0x98, 0x57, 0xe2, 0xca, 0x57, 0x13, 0x3, 0x2c, 0xfb, 0xe9, 0xb1, 0xa2, 0x71, 0x56, 0x80, 0x39, 0x37, 0x2e, 0x86, 0x57, 0xf8, 0xb4, 0x86, 0x52, 0x52, 0x8e, 0xf7, 0x3e, 0xef, 0x2e, 0x45, 0x48, 0x1a, 0x7, 0xe0, 0x92, 0x76, 0xa0, 0x4b, 0x87, 0xc0, 0xb0, 0x69, 0x8f, 0xf4, 0x4, 0xf4, 0x45, 0x49, 0x47, 0x7b, 0x92, 0xbf, 0x9, 0x26, 0x4f, 0x22, 0xf0, 0x11, 0x87, 0xab, 0x52, 0x61, 0xb1, 0xd, 0xcb, 0x77, 0x15, 0x20, 0x40, 0x2e, 0x91, 0x70, 0x7f, 0x5c, 0x19, 0x6b, 0xd6, 0xdf, 0x57, 0xcd, 0x3d, 0x7d, 0xab, 0x31, 0xce, 0x8b, 0x20, 0x4b, 0xc, 0x3, 0x95, 0x76, 0x5f, 0x26, 0x30, 0x3e, 0x76, 0x87, 0xec, 0x85, 0x43, 0x2e, 0x7d, 0x68, 0x6c, 0x47, 0x10, 0x2c, 0x69, 0x90, 0xb5, 0x57, 0x49, 0xf6, 0xdc, 0xd0, 0xce, 0x1d, 0x55, 0xe2, 0x4, 0x95, 0xc6, 0xb, 0xe5, 0x65, 0x56, 0xff, 0xe1, 0x96, 0x33, 0x63, 0xd7, 0x59, 0x24, 0x62, 0xc0, 0x31, 0x4e, 0xea, 0x1a, 0x0, 0x9b, 0xdb, 0xd2, 0xc9, 0xc7, 0x89, 0x7f, 0x45, 0xcf, 0x7e, 0x55, 0x68, 0x25, 0xdb, 0x1f, 0xd0, 0x15, 0xc3, 0xa7, 0x3f, 0xba, 0x17, 0x76, 0x23, 0x18, 0x7a, 0xf9, 0xc3, 0x17, 0xc9, 0xba, 0x97, 0x90, 0xec, 0xe6, 0x1f, 0x22, 0xdb, 0xca, 0x15, 0x24, 0xa, 0x3f, 0xa5, 0xde, 0xb0, 0x8d, 0xf1, 0x82, 0x85, 0x96, 0xfe, 0x53, 0xc9, 0x35, 0x16, 0xc9, 0x30, 0x80, 0x49, 0xfd, 0x15, 0x60, 0x16, 0x2c, 0xa7, 0xb4, 0xb4, 0x56, 0x78, 0xe2, 0x9e, 0x7d, 0x7f, 0x44, 0x43, 0x1a, 0x40, 0xfa, 0xbc, 0xeb, 0x66, 0xef, 0x4e, 0x88, 0x36, 0xed, 0xe, 0xc3, 0xa6, 0x3d, 0x72, 0x34, 0x64, 0xaf, 0x4, 0xd1, 0x97, 0x9e, 0xda, 0xc7, 0xb0, 0x7a, 0x86, 0x12, 0xf8, 0x29, 0x3b, 0x61, 0x56, 0x3e, 0x9e, 0x48, 0xe3, 0xef, 0x4b, 0x65, 0x5e, 0x26, 0xcd, 0xba, 0x52, 0x65, 0xad, 0x99, 0x1, 0x86, 0x5f, 0xf1, 0x44, 0xca, 0x75, 0x33, 0x17, 0x93, 0xdc, 0xb3, 0x60, 0x82, 0xa3, 0xc6, 0x8b, 0x86, 0x14, 0x4, 0x1a, 0x7a, 0x9b, 0x2b, 0xc9, 0x9e, 0x36, 0xf4, 0xf2, 0xc5, 0x8b, 0x3b, 0x9b, 0xb8, 0xe5, 0x60, 0xd8, 0xb4, 0x47, 0x87, 0x59, 0xd7, 0x9d, 0x2b, 0xd9, 0x91, 0xb9, 0x63, 0x71, 0x88, 0xa, 0x8d, 0x64, 0x85, 0x97, 0x2, 0xa5, 0x2e, 0x3e, 0x9d, 0x70, 0x78, 0x4e, 0x93, 0x22, 0x9d, 0x7b, 0xff, 0x70, 0xf3, 0xbf, 0xfe, 0xb2, 0x54, 0x79, 0x6b, 0x62, 0x80, 0x61, 0x57, 0x3c, 0x9e, 0x92, 0xcd, 0x5c, 0x27, 0xeb, 0xde, 0x0, 0xa0, 0x67, 0xc1, 0x92, 0xe4, 0x4, 0x2e, 0x7f, 0xdf, 0x3b, 0xfa, 0x27, 0x8c, 0xc1, 0xba, 0xf6, 0xb3, 0x43, 0x2e, 0x5b, 0x7c, 0x7f, 0x65, 0xa5, 0xec, 0x38, 0x18, 0x7a, 0xf9, 0xa3, 0x43, 0x25, 0xf7, 0x2e, 0x40, 0x47, 0xfa, 0x36, 0xd, 0x86, 0x7e, 0x6b, 0xc1, 0x3, 0xbd, 0x65, 0xfe, 0x8, 0x7e, 0xc3, 0x57, 0xee, 0x14, 0x94, 0xf0, 0x5, 0xc0, 0xa5, 0xe1, 0xdf, 0xca, 0x95, 0xb9, 0x6a, 0x6, 0x18, 0x7a, 0xf9, 0xa3, 0xd, 0x72, 0x33, 0xdf, 0xb3, 0xae, 0xfb, 0xdf, 0x0, 0xd3, 0x5e, 0x68, 0xb4, 0x64, 0x5f, 0x9d, 0x2a, 0xd3, 0x3a, 0xdc, 0x18, 0xa6, 0x21, 0x9d, 0x39, 0xe4, 0xd2, 0x87, 0x7e, 0x3b, 0xf4, 0xf2, 0x47, 0x92, 0xde, 0x95, 0xac, 0x26, 0x18, 0x36, 0xed, 0xb1, 0x93, 0xad, 0xcd, 0x3c, 0x28, 0xab, 0xc3, 0xa, 0xd7, 0x52, 0x94, 0xd2, 0x7a, 0xe2, 0x70, 0x81, 0xd6, 0x71, 0xf3, 0x9a, 0xdd, 0x2e, 0x92, 0x1b, 0x40, 0xf3, 0xa6, 0x84, 0x5d, 0xa, 0xb6, 0x53, 0x4, 0x43, 0x62, 0x86, 0x27, 0xfc, 0x9, 0x6c, 0x75, 0x68, 0x67, 0x31, 0x54, 0xc5, 0x0, 0xc3, 0xaf, 0x78, 0xbc, 0x1b, 0xa0, 0x1f, 0x59, 0x6b, 0xaf, 0x3, 0xe1, 0xd0, 0x10, 0xc1, 0x21, 0xc7, 0x85, 0x2b, 0xc7, 0xa2, 0x18, 0x9f, 0x45, 0xe1, 0xcc, 0x8b, 0x2b, 0x5, 0x78, 0x8, 0xb8, 0x9f, 0xa1, 0x74, 0x9, 0x10, 0x46, 0xd0, 0xd1, 0xd6, 0xba, 0x2f, 0xf, 0xb9, 0xfc, 0x91, 0xe3, 0x3a, 0x8c, 0xc2, 0x25, 0x60, 0xc8, 0x65, 0xf, 0xff, 0xa7, 0xb5, 0xd9, 0x45, 0x24, 0xf, 0xa, 0xd4, 0x6f, 0x1a, 0xe3, 0xf9, 0x39, 0x17, 0x8a, 0x3f, 0x85, 0xf5, 0x46, 0xc, 0x2e, 0xa, 0xf1, 0x26, 0x3f, 0x2e, 0x7d, 0x7c, 0xac, 0x5c, 0x75, 0xf3, 0x99, 0x3, 0x8d, 0x93, 0xfe, 0x94, 0x49, 0x35, 0xee, 0x63, 0x52, 0x4d, 0x4d, 0x26, 0x95, 0xee, 0x63, 0x9c, 0xf4, 0x20, 0x3a, 0xe9, 0xd1, 0x74, 0xd2, 0x67, 0xd1, 0x38, 0x5f, 0xa6, 0x71, 0xbe, 0x44, 0xf0, 0xd9, 0x72, 0x65, 0x2f, 0x27, 0xb8, 0x47, 0x10, 0xff, 0xd7, 0x7b, 0xca, 0xda, 0xaf, 0x4a, 0xf6, 0x3b, 0x8, 0x56, 0xa3, 0xb0, 0xd2, 0x95, 0xae, 0x55, 0x2d, 0x8c, 0xf5, 0xd8, 0x5b, 0x62, 0xc8, 0xb9, 0x70, 0x2b, 0x68, 0x1e, 0x4b, 0x77, 0xdb, 0xe7, 0xbc, 0x17, 0x67, 0x1c, 0xd3, 0xe1, 0x9b, 0x48, 0xe, 0xbf, 0xe2, 0x89, 0x46, 0xeb, 0x66, 0xd6, 0xca, 0xba, 0x7, 0x91, 0xdc, 0x23, 0x98, 0x92, 0x87, 0xc4, 0x44, 0x71, 0x12, 0x78, 0xe8, 0x92, 0xab, 0x40, 0xe7, 0xe4, 0x95, 0x73, 0x3e, 0xf7, 0x7e, 0x71, 0x94, 0xa3, 0xbe, 0xf2, 0x5b, 0xb6, 0x6c, 0x7b, 0x97, 0x4e, 0xba, 0x81, 0xb2, 0xd6, 0x48, 0xd6, 0x5d, 0x35, 0xf7, 0x8c, 0xb2, 0x47, 0xcc, 0x54, 0x44, 0x85, 0xa1, 0xd3, 0x1e, 0xed, 0xe, 0x60, 0x32, 0xac, 0x9d, 0x5, 0xf8, 0x67, 0xff, 0xa1, 0xe3, 0xf, 0x8c, 0x40, 0xe1, 0x3c, 0x78, 0xb, 0xc8, 0xb7, 0x4, 0xde, 0xea, 0x66, 0xb3, 0xd7, 0xaf, 0xb9, 0xf5, 0xcc, 0x4c, 0xd, 0x59, 0xb4, 0x9, 0x86, 0x5c, 0xfe, 0x48, 0x9a, 0xc0, 0x22, 0x12, 0x47, 0xc9, 0xda, 0xdc, 0x2c, 0x1b, 0x2b, 0x26, 0x7a, 0x25, 0x55, 0x46, 0x56, 0xe0, 0x5d, 0xab, 0xe6, 0x9e, 0x3e, 0x25, 0xc9, 0xba, 0x54, 0x54, 0xd8, 0x61, 0xd3, 0x1e, 0x3b, 0x49, 0x72, 0x7f, 0xe3, 0x89, 0xb5, 0x1e, 0x9b, 0xb7, 0x4a, 0x2d, 0xee, 0xec, 0x87, 0x70, 0xcc, 0xb8, 0xc5, 0x23, 0x2c, 0x8a, 0xab, 0xc8, 0x38, 0x91, 0xa7, 0x83, 0x49, 0xda, 0x4a, 0x9a, 0xd7, 0x40, 0x2e, 0x2, 0xcc, 0x4f, 0x56, 0xce, 0xf9, 0x6c, 0xe2, 0x1e, 0x45, 0xc3, 0xaf, 0x78, 0x7c, 0xa8, 0xb5, 0xee, 0xb5, 0xde, 0xde, 0x48, 0x3a, 0x88, 0xa4, 0xbf, 0x3f, 0x62, 0x20, 0xaa, 0x7b, 0xc7, 0x27, 0xb6, 0xaa, 0x53, 0xb8, 0x2e, 0x51, 0x38, 0x2a, 0xf6, 0xa4, 0x2e, 0xc4, 0x97, 0xbf, 0xf, 0x3, 0x9f, 0x4d, 0x35, 0x34, 0x7d, 0x6e, 0xd9, 0xcf, 0x4e, 0x4a, 0xf4, 0xc8, 0x98, 0x8a, 0xe, 0x8d, 0x12, 0xf0, 0x16, 0xc0, 0x55, 0x20, 0x86, 0x12, 0x85, 0x47, 0xb7, 0x14, 0x54, 0xa8, 0x18, 0xca, 0x59, 0x7f, 0xc2, 0x61, 0x2c, 0xfb, 0x5d, 0x1e, 0xb5, 0xb9, 0x19, 0x70, 0x89, 0x64, 0xf, 0xc9, 0xe, 0x84, 0x78, 0x10, 0xa9, 0xb, 0x87, 0x4e, 0x7b, 0x74, 0x29, 0xc0, 0xc5, 0x0, 0x9f, 0x58, 0x75, 0xd3, 0xe7, 0x3e, 0xac, 0x16, 0x41, 0x43, 0xa7, 0x3d, 0x76, 0x24, 0x81, 0x33, 0x41, 0x9c, 0x62, 0xdd, 0xec, 0x27, 0x1, 0xf4, 0x26, 0xd1, 0xe4, 0x17, 0x26, 0xe7, 0xa, 0x17, 0xb9, 0x8c, 0x92, 0x6d, 0xb8, 0x8f, 0x7f, 0xe, 0xed, 0xba, 0xc2, 0xd7, 0x68, 0xcc, 0x6d, 0x49, 0x13, 0x3f, 0x8e, 0x14, 0x25, 0x61, 0xd8, 0xf4, 0x5f, 0x9f, 0x2e, 0xeb, 0x3e, 0xc, 0x44, 0xad, 0x70, 0xed, 0x70, 0x28, 0x68, 0x57, 0xa1, 0x1d, 0x4b, 0x20, 0xa9, 0x19, 0xe4, 0x3f, 0x0, 0xbc, 0xb, 0xe0, 0x6d, 0x80, 0x7f, 0x34, 0xc6, 0xbc, 0x28, 0x61, 0x83, 0x64, 0x37, 0x1b, 0x63, 0xb6, 0x9, 0xcc, 0x2, 0x70, 0x8d, 0x31, 0x8e, 0x9b, 0xcd, 0x34, 0x2, 0xec, 0x66, 0xc, 0xf, 0x4, 0x74, 0x8c, 0xb5, 0x3a, 0xe, 0xd0, 0x1, 0x0, 0x7a, 0xc8, 0xda, 0xde, 0x24, 0xf7, 0xcb, 0x21, 0x2d, 0x7c, 0x42, 0xa, 0xa, 0xfb, 0xe9, 0x44, 0x2a, 0x15, 0x4a, 0x4f, 0x92, 0x5, 0xcd, 0x8d, 0x3d, 0xf7, 0xeb, 0x73, 0xd5, 0x33, 0xd7, 0xf, 0x4e, 0x5c, 0xce, 0xa9, 0xf8, 0xec, 0x60, 0x9, 0x2b, 0x40, 0xf3, 0x2, 0xa0, 0xe3, 0x2, 0x4f, 0x9e, 0xf0, 0x69, 0xd1, 0xed, 0xf, 0x5, 0x63, 0x49, 0xee, 0xc1, 0x3b, 0x69, 0x3b, 0x68, 0x3a, 0x10, 0xd, 0x1b, 0x25, 0x1c, 0x2, 0xe0, 0x10, 0x3f, 0xc6, 0x9, 0x92, 0x1d, 0x27, 0xe1, 0x7d, 0x48, 0xcd, 0x90, 0xcd, 0x10, 0xb4, 0x0, 0xe4, 0x66, 0xb2, 0x24, 0xe9, 0x0, 0x4a, 0x59, 0xab, 0xee, 0x80, 0xf6, 0x7, 0x90, 0xf3, 0x48, 0xa, 0x16, 0xc9, 0xf8, 0xe, 0xd1, 0x2c, 0x76, 0xe7, 0xab, 0x9c, 0xf8, 0xc5, 0xe3, 0x40, 0x1, 0x7e, 0x45, 0x43, 0x4a, 0xb0, 0x0, 0xc, 0x69, 0x9e, 0x14, 0xf9, 0x83, 0xf6, 0x20, 0x3e, 0x50, 0x5, 0x3, 0x90, 0x7c, 0x17, 0xe4, 0x77, 0x64, 0xdd, 0x27, 0xdb, 0xeb, 0xb8, 0xb4, 0xa, 0x4a, 0x13, 0x2a, 0x57, 0x48, 0x81, 0x24, 0xc2, 0x4e, 0x97, 0xc1, 0x88, 0xda, 0x1d, 0x40, 0x5f, 0x40, 0x7d, 0xc1, 0x9c, 0x4a, 0x91, 0x4b, 0x26, 0x70, 0x79, 0xf, 0x8c, 0x6e, 0xc8, 0x7f, 0x9b, 0xcb, 0x28, 0xbf, 0x59, 0x46, 0xb2, 0x65, 0x2f, 0xc4, 0x6f, 0xee, 0x5c, 0x24, 0x43, 0x72, 0x9, 0x8d, 0xf3, 0x5f, 0x2b, 0x67, 0x9f, 0x5a, 0xd6, 0xa0, 0x53, 0x2d, 0x54, 0xdc, 0x85, 0xaf, 0x9c, 0xf3, 0x59, 0x57, 0x56, 0xcf, 0x1, 0xe6, 0x7, 0xcc, 0x4f, 0x3b, 0x29, 0xce, 0xae, 0xf, 0xc4, 0xdb, 0xb2, 0x11, 0x11, 0x16, 0xf5, 0x1e, 0x31, 0xdf, 0x44, 0x7d, 0xe7, 0x3f, 0x33, 0x58, 0x72, 0xe, 0x7f, 0x5b, 0x4e, 0x7f, 0x7e, 0x1, 0x86, 0x6, 0x86, 0x26, 0xbf, 0xb6, 0xda, 0xf, 0xf3, 0xe6, 0x1c, 0x20, 0xd2, 0x0, 0xfe, 0x7d, 0xb1, 0x52, 0x5e, 0x6c, 0xcf, 0x47, 0x4c, 0x19, 0x4b, 0xc5, 0x61, 0x89, 0xfa, 0x86, 0x5d, 0xb9, 0xe8, 0x19, 0x73, 0x1e, 0x58, 0x31, 0xfb, 0xd4, 0x76, 0xf5, 0x8e, 0xae, 0x6a, 0xc, 0x5f, 0x75, 0xd3, 0xe7, 0x32, 0xc6, 0x71, 0x66, 0xd0, 0x98, 0x3f, 0x7a, 0x1e, 0x81, 0xf0, 0x14, 0x83, 0xbc, 0xcd, 0x1a, 0xa0, 0x77, 0x94, 0x27, 0x3, 0x79, 0x3d, 0xf8, 0xf1, 0xc3, 0xe4, 0x1b, 0x11, 0x7c, 0xbb, 0x49, 0x7e, 0x4d, 0x8, 0xb, 0xc3, 0xa, 0xec, 0x61, 0x21, 0x3b, 0x49, 0x2e, 0x6e, 0x48, 0x78, 0x6c, 0x65, 0x53, 0x2a, 0x8e, 0x1b, 0x32, 0x52, 0x79, 0xc6, 0x2b, 0x22, 0xbc, 0xcd, 0xa1, 0x77, 0xa, 0x8b, 0x1f, 0x25, 0x7c, 0x5f, 0x9c, 0x6f, 0x51, 0x18, 0x23, 0xca, 0x15, 0x67, 0xe3, 0x29, 0x28, 0x77, 0x44, 0x1d, 0xa, 0x3b, 0x6, 0x56, 0xdc, 0x43, 0x77, 0x8, 0x3, 0x0, 0xc0, 0x8a, 0xd9, 0xa7, 0xbc, 0x9, 0x98, 0x6f, 0x48, 0xb0, 0xc1, 0x4a, 0x97, 0x90, 0xcd, 0x3a, 0xa8, 0x72, 0x40, 0x71, 0xff, 0x40, 0x54, 0x13, 0xd8, 0xaa, 0x3d, 0xd3, 0x5e, 0xb0, 0xb5, 0x1d, 0x22, 0x30, 0x57, 0x80, 0xc5, 0x8, 0xec, 0xc6, 0xc5, 0x47, 0x1b, 0xe2, 0x17, 0x7f, 0xc7, 0x32, 0xf9, 0x97, 0xcb, 0xaf, 0x5c, 0x1e, 0x95, 0x94, 0xc5, 0xbb, 0xf7, 0x27, 0xc0, 0x34, 0x61, 0xd8, 0x15, 0x4f, 0x8c, 0xa9, 0x4b, 0x6, 0x0, 0x80, 0x15, 0x37, 0x9e, 0xf2, 0x2b, 0x81, 0x73, 0xfd, 0x59, 0x89, 0xe0, 0xbc, 0xdb, 0x9c, 0xdf, 0xa3, 0x1f, 0x6, 0x1, 0xaf, 0xd0, 0x38, 0xf3, 0x40, 0xf3, 0x3d, 0x90, 0x8f, 0xa3, 0x50, 0x4b, 0x66, 0x72, 0x3e, 0x92, 0x9d, 0x24, 0x8a, 0x24, 0x8, 0x61, 0x1c, 0x2, 0x1a, 0xe, 0x60, 0xca, 0x51, 0x57, 0x3d, 0x9d, 0x6e, 0xaf, 0xfc, 0x6a, 0x56, 0xe3, 0x68, 0x9c, 0xaf, 0xd2, 0x38, 0xbf, 0x1, 0xe8, 0x2, 0xc, 0x66, 0xa5, 0x8, 0xf0, 0x3, 0x81, 0x4f, 0x1, 0x9c, 0x4d, 0x9a, 0xff, 0x30, 0xc6, 0x4c, 0x5f, 0x31, 0xfb, 0x94, 0x6f, 0x3, 0xe6, 0x6b, 0xa0, 0xf9, 0x6d, 0x28, 0xae, 0xef, 0x27, 0x17, 0xb5, 0x6d, 0x5a, 0xa5, 0x17, 0x6a, 0xfc, 0xbe, 0xf3, 0x2f, 0x7f, 0xd2, 0x43, 0x79, 0xbc, 0x68, 0x8c, 0x9b, 0x75, 0xcf, 0x6b, 0x2f, 0x6, 0x48, 0xa4, 0xc9, 0x8c, 0xb8, 0xf2, 0xa9, 0x23, 0x24, 0xfb, 0x6b, 0x49, 0x69, 0x49, 0x1b, 0xc, 0xb9, 0x95, 0xc6, 0xac, 0x0, 0x78, 0xf3, 0xf2, 0x59, 0x27, 0xbd, 0x19, 0x11, 0xff, 0x13, 0xd6, 0xba, 0xf3, 0x25, 0x9d, 0x60, 0x72, 0xaa, 0x5b, 0xe8, 0xa0, 0xe4, 0x92, 0xc5, 0x6d, 0x4b, 0x6f, 0xd1, 0xd6, 0x78, 0x51, 0x71, 0xc3, 0xcf, 0x95, 0xa4, 0x53, 0xd, 0x4, 0x55, 0x8d, 0xcd, 0x43, 0x5e, 0x2f, 0xca, 0x47, 0x68, 0xcc, 0xf8, 0x95, 0xb3, 0x4f, 0x2e, 0x77, 0xa, 0x7a, 0xd5, 0x25, 0xa8, 0x19, 0x46, 0x5c, 0xf9, 0xd4, 0xf5, 0x92, 0x5e, 0x7, 0x39, 0x6f, 0xc5, 0xac, 0x93, 0xca, 0x6e, 0xf5, 0x3a, 0xfc, 0x4b, 0x4f, 0x35, 0x42, 0xf6, 0x69, 0x41, 0xc7, 0x78, 0x2, 0x1e, 0x73, 0x15, 0x66, 0x58, 0xa7, 0x8b, 0x41, 0x51, 0x78, 0xc, 0x29, 0x45, 0x22, 0x96, 0xf9, 0xbe, 0x38, 0x4e, 0x71, 0xfc, 0x28, 0x4, 0x29, 0x26, 0x8d, 0xf6, 0x60, 0x15, 0x7f, 0x78, 0x7c, 0x97, 0x34, 0x3f, 0x58, 0x31, 0xfb, 0xe4, 0x1f, 0x26, 0x9d, 0x7e, 0xa7, 0xe, 0x9a, 0x23, 0xaf, 0x59, 0x4a, 0xb7, 0x65, 0xfb, 0xe3, 0x24, 0x8e, 0x6, 0xd0, 0xc3, 0xdb, 0x3c, 0x23, 0xd8, 0x87, 0x24, 0x8a, 0x5, 0x18, 0xf1, 0x5c, 0xe9, 0xe4, 0x43, 0x5c, 0xba, 0xa5, 0x58, 0x24, 0xa, 0x65, 0xc5, 0xdf, 0x95, 0xcb, 0x2f, 0xae, 0x4c, 0x8c, 0xf9, 0x46, 0xc1, 0x7a, 0x4b, 0xff, 0xe0, 0x68, 0x3e, 0x63, 0x85, 0xcf, 0xaf, 0xba, 0xf1, 0x94, 0x44, 0xcd, 0xc1, 0x9d, 0x6a, 0xca, 0x5d, 0xf6, 0xd3, 0x63, 0xb5, 0xf2, 0xc6, 0x53, 0x4f, 0x25, 0x53, 0xb7, 0x4a, 0x7c, 0xc3, 0x57, 0xd5, 0x19, 0xbd, 0xce, 0x90, 0x31, 0xcf, 0x61, 0x4d, 0xa1, 0x54, 0xdc, 0x8, 0xbd, 0x32, 0x36, 0x9d, 0xb8, 0x30, 0x96, 0xf8, 0xae, 0x5c, 0x7e, 0x71, 0x71, 0xe2, 0xbe, 0xf1, 0xe4, 0xe3, 0x90, 0x6e, 0x3b, 0x84, 0xe4, 0xb7, 0x92, 0xa6, 0x41, 0x67, 0xdb, 0xf2, 0x1, 0x0, 0xcb, 0x67, 0x8d, 0xb9, 0x16, 0x34, 0xd7, 0x4a, 0x58, 0xf, 0xef, 0x4, 0x92, 0x28, 0x4a, 0xed, 0x56, 0x57, 0xb0, 0xb7, 0x72, 0xb9, 0xb0, 0x52, 0xdf, 0x6, 0x2e, 0x71, 0x7e, 0xf8, 0x36, 0x0, 0x1f, 0x24, 0x8d, 0xfb, 0xba, 0xd2, 0x9b, 0x86, 0x7f, 0xe9, 0xe9, 0xde, 0xa0, 0x1e, 0x25, 0x30, 0x24, 0x5f, 0xbc, 0xb8, 0x3d, 0x74, 0x6b, 0x19, 0x71, 0x4b, 0xa5, 0xd1, 0x16, 0xa9, 0x22, 0x4e, 0x7a, 0xc8, 0x7d, 0x17, 0xac, 0x95, 0xf4, 0x67, 0x2d, 0x73, 0x5d, 0x9b, 0xef, 0xc9, 0x62, 0x5b, 0x4f, 0xa5, 0x7, 0xdd, 0xbe, 0xb7, 0x4b, 0x46, 0xfe, 0x5b, 0x0, 0x92, 0x5e, 0x27, 0xf9, 0xff, 0x56, 0xcc, 0x3e, 0x69, 0x66, 0xd2, 0x38, 0x6f, 0x77, 0x4b, 0x53, 0x25, 0x60, 0xc, 0xcf, 0x12, 0xb0, 0x7f, 0xa1, 0x46, 0x10, 0xc7, 0xa3, 0x49, 0xf0, 0x6e, 0xb5, 0x69, 0xb3, 0xd5, 0x73, 0x89, 0x19, 0x41, 0x17, 0x40, 0xd6, 0x6f, 0xdc, 0x8d, 0x3e, 0x81, 0x63, 0x36, 0x88, 0x28, 0xdc, 0x37, 0xc0, 0x8f, 0xf3, 0xf, 0xc7, 0x38, 0xd7, 0x2f, 0xfb, 0xd9, 0x89, 0xb3, 0xd1, 0xe, 0x50, 0x17, 0x43, 0x40, 0x0, 0x56, 0x9a, 0x2, 0xb0, 0x4f, 0xcc, 0xa0, 0x19, 0x46, 0x54, 0x95, 0x57, 0xf8, 0xfb, 0xa8, 0xb4, 0xa2, 0xde, 0x17, 0x43, 0x41, 0x9a, 0xf2, 0xaf, 0x90, 0x15, 0x34, 0x6c, 0x14, 0x33, 0x24, 0xcd, 0x12, 0x63, 0x9c, 0x13, 0x49, 0x73, 0xa9, 0xf2, 0x7b, 0x39, 0xd2, 0x5b, 0xff, 0x58, 0xd0, 0xe5, 0xe7, 0xbc, 0x87, 0x83, 0xd6, 0xef, 0xf9, 0xf4, 0xf3, 0xb2, 0xf6, 0x22, 0x3e, 0x50, 0x6f, 0x3d, 0x0, 0xb9, 0xb7, 0x7f, 0xab, 0xe8, 0xa6, 0x5f, 0x6b, 0xab, 0x2f, 0x47, 0xe4, 0x36, 0x30, 0x41, 0x99, 0x11, 0x42, 0xc1, 0xc6, 0xf7, 0xc4, 0x12, 0x49, 0xff, 0x43, 0xf2, 0xe9, 0x65, 0x33, 0x47, 0x67, 0x0, 0xfc, 0x6e, 0xe4, 0x55, 0xcf, 0xbe, 0x2d, 0x6b, 0x7f, 0x9, 0x61, 0xcf, 0x12, 0xbe, 0x23, 0x16, 0xa0, 0x1, 0xf9, 0x24, 0xc9, 0x6f, 0x2e, 0x9b, 0x39, 0x7a, 0x59, 0x72, 0x18, 0x6e, 0xd, 0x75, 0xd3, 0x3, 0xc, 0xbf, 0xf2, 0x99, 0x43, 0xad, 0xd4, 0xd8, 0x7a, 0x7d, 0x21, 0x4a, 0x48, 0xe2, 0x40, 0xbc, 0x74, 0x8f, 0x98, 0x6f, 0xa3, 0x24, 0x7d, 0xc4, 0xe4, 0x17, 0x91, 0x6, 0x10, 0x78, 0xfb, 0x22, 0x98, 0xb4, 0xb, 0xc9, 0x76, 0xa4, 0x31, 0xf, 0xd2, 0x38, 0xa3, 0x40, 0xf3, 0x79, 0x3a, 0xd, 0x4f, 0x2c, 0xff, 0xd9, 0x89, 0x39, 0x1f, 0xc5, 0x65, 0x33, 0x47, 0x3f, 0xe, 0x9a, 0xa1, 0x2, 0x7e, 0xed, 0x37, 0x79, 0x81, 0x94, 0x37, 0xc9, 0xc8, 0x60, 0x1, 0x89, 0x1, 0x79, 0x9b, 0x80, 0x69, 0xed, 0x4d, 0x7c, 0xa0, 0x9e, 0x7a, 0x0, 0xa2, 0x1f, 0xc1, 0xc6, 0xdc, 0x53, 0x4e, 0xb2, 0x2a, 0xd7, 0x52, 0x5b, 0x79, 0xd0, 0xf8, 0xdd, 0x27, 0x83, 0x77, 0x88, 0x77, 0x57, 0x60, 0x44, 0x7a, 0xe5, 0x7b, 0x89, 0xfc, 0x9c, 0x7d, 0xe0, 0xe, 0x61, 0xfe, 0xa, 0x70, 0x11, 0xa8, 0x5b, 0x1, 0xbc, 0xe, 0x68, 0xe7, 0xf2, 0x99, 0xa3, 0x23, 0x3d, 0x72, 0x97, 0xff, 0x6c, 0xf4, 0x9f, 0x47, 0x5c, 0xf5, 0xec, 0x64, 0x8, 0x93, 0x24, 0x3b, 0x23, 0xa8, 0x82, 0xef, 0xdc, 0x42, 0x80, 0x5f, 0x3, 0x79, 0xc7, 0x8a, 0x99, 0x27, 0xbc, 0xd7, 0x11, 0x68, 0xaf, 0x1f, 0x6, 0x0, 0x8e, 0x5, 0xd8, 0xc3, 0xf7, 0xc9, 0xa8, 0xc8, 0xc9, 0xc4, 0x9f, 0x7d, 0xa, 0x3c, 0x68, 0x2, 0x46, 0x0, 0x80, 0xd0, 0x92, 0x6c, 0x0, 0x21, 0x71, 0xbd, 0x48, 0x66, 0xab, 0xc6, 0x9b, 0x97, 0x0, 0xb2, 0x20, 0x7, 0x81, 0xdc, 0x22, 0x69, 0xeb, 0xf2, 0x99, 0xa3, 0xdb, 0xe4, 0x88, 0xba, 0x7c, 0xe6, 0xe8, 0x77, 0x46, 0x5e, 0xbd, 0x64, 0x2e, 0xc4, 0xc5, 0x90, 0x9e, 0x5, 0x70, 0xa0, 0xa4, 0x77, 0x40, 0x4e, 0x4, 0xf4, 0xc2, 0xa, 0x6f, 0xc8, 0xe8, 0x10, 0xa8, 0x1b, 0x35, 0x70, 0xf8, 0x97, 0x9f, 0x7d, 0x9e, 0xc4, 0x31, 0xbe, 0x27, 0x47, 0x5b, 0x9, 0x92, 0xd7, 0xbb, 0x3c, 0xcf, 0xd9, 0xdb, 0x1, 0x2c, 0x5, 0x70, 0x32, 0xa0, 0xb3, 0x51, 0x62, 0xdb, 0xd9, 0x90, 0xb7, 0x50, 0x45, 0x6e, 0xed, 0x45, 0xbd, 0x4d, 0x66, 0xf9, 0xcc, 0xd1, 0xd, 0x6d, 0xfa, 0x30, 0x6, 0x46, 0x5e, 0xbd, 0xe4, 0x50, 0x49, 0xc3, 0x0, 0xac, 0x5f, 0x3e, 0xf3, 0x84, 0xd, 0xed, 0x89, 0xe3, 0x48, 0x3c, 0x74, 0x74, 0x86, 0x71, 0x30, 0xe2, 0xaa, 0xe7, 0xde, 0x2, 0xd0, 0x2b, 0xbc, 0xdf, 0x50, 0x29, 0xa2, 0x14, 0xbf, 0x97, 0xf4, 0x17, 0x80, 0x13, 0x1, 0xac, 0xa1, 0x77, 0x9e, 0x71, 0x2f, 0x0, 0x7b, 0x4a, 0x6a, 0x80, 0x77, 0xbc, 0x7d, 0xf, 0x0, 0x9f, 0x2, 0xd4, 0x17, 0xc0, 0xbe, 0x0, 0x3e, 0x9, 0x78, 0x1b, 0x51, 0x55, 0xea, 0xcf, 0x1f, 0xc, 0x33, 0x92, 0x32, 0xa4, 0xe9, 0xb6, 0x7c, 0xe6, 0xf1, 0xd9, 0xb6, 0x7e, 0x1b, 0x5, 0x47, 0x7f, 0x65, 0x69, 0xea, 0xf7, 0x33, 0x8e, 0xad, 0x29, 0x8d, 0x6a, 0xa1, 0x6e, 0x86, 0x0, 0x82, 0x3f, 0x17, 0xf4, 0x15, 0xf9, 0xb, 0xa1, 0x3c, 0xbf, 0x48, 0x8f, 0x28, 0x11, 0x94, 0xf1, 0x37, 0x44, 0xf4, 0x5, 0x32, 0x6f, 0x14, 0xb8, 0xce, 0xcd, 0xba, 0x7f, 0x58, 0x39, 0xfb, 0x44, 0xb, 0x60, 0x93, 0x7f, 0xe5, 0x60, 0xc4, 0xd5, 0x2f, 0x90, 0xb0, 0x3d, 0x0, 0xee, 0x9, 0x8f, 0x21, 0xfa, 0xc8, 0x6a, 0x89, 0x31, 0x74, 0x0, 0x6f, 0x71, 0x65, 0x5, 0x83, 0x8e, 0x7f, 0xca, 0x6d, 0x32, 0xde, 0x81, 0x9d, 0x45, 0x7c, 0xa0, 0x8e, 0x18, 0x40, 0xc0, 0x8f, 0x48, 0xb3, 0x44, 0xb2, 0x97, 0x82, 0x3c, 0x2d, 0x24, 0x4, 0x14, 0xf4, 0xba, 0x7e, 0x80, 0xbf, 0xf, 0x1e, 0x20, 0x6b, 0x9, 0xe0, 0xfb, 0x12, 0x1f, 0xf5, 0x89, 0x1f, 0x9, 0xcb, 0x6f, 0x38, 0x4e, 0x0, 0xb6, 0xf8, 0x17, 0x46, 0x5c, 0xb5, 0xe4, 0x75, 0x92, 0xbf, 0x15, 0x70, 0x1c, 0x80, 0x22, 0x51, 0xa1, 0x75, 0xe1, 0x42, 0x5c, 0xa8, 0xd0, 0x9e, 0x8c, 0xdb, 0xea, 0xa8, 0x13, 0xad, 0xa, 0xea, 0x46, 0xd, 0x5c, 0x3e, 0xf3, 0xf8, 0xd7, 0x97, 0xdd, 0x30, 0xea, 0x3e, 0x80, 0xd7, 0x1, 0xbc, 0x58, 0xc2, 0xaf, 0x3, 0xe7, 0x92, 0x22, 0x87, 0x11, 0x92, 0x46, 0xa1, 0x77, 0xbf, 0x7, 0xf8, 0xbf, 0xcb, 0x67, 0x1e, 0x5f, 0xd1, 0x59, 0x43, 0xc6, 0x18, 0xd2, 0x98, 0xbb, 0x42, 0xf6, 0xf9, 0x78, 0x3b, 0x7d, 0xa1, 0x4b, 0x97, 0x6f, 0xac, 0x81, 0x5, 0xf8, 0x1a, 0xda, 0xd7, 0x61, 0xa0, 0xdd, 0xa1, 0x6e, 0xd9, 0x77, 0xc4, 0x55, 0x4b, 0x8e, 0x4, 0x30, 0x82, 0xe4, 0x89, 0x0, 0xc6, 0x1, 0x8, 0x6f, 0x11, 0x13, 0x8c, 0xc1, 0x9b, 0x1, 0x9c, 0xb5, 0x7c, 0xe6, 0xf1, 0x4b, 0xaa, 0xc9, 0x63, 0xe4, 0xd5, 0x2f, 0x1c, 0x28, 0xd9, 0x4d, 0xfe, 0xb9, 0x88, 0xa5, 0x5c, 0x0, 0xa, 0xc0, 0xd7, 0x30, 0x32, 0x92, 0x16, 0x1, 0x98, 0xbc, 0x7c, 0xe6, 0xf1, 0x65, 0x17, 0x61, 0xd6, 0x2b, 0xd4, 0x2d, 0x3, 0x4, 0x30, 0xe2, 0xea, 0xe7, 0xfb, 0x0, 0x38, 0x3, 0xc0, 0xbf, 0x10, 0x3c, 0xa, 0xc0, 0x18, 0xdf, 0x4a, 0xb0, 0x43, 0xd0, 0x95, 0xcb, 0x6f, 0x18, 0x75, 0x47, 0x8d, 0xe9, 0x3f, 0x65, 0x68, 0x8e, 0x87, 0x77, 0xf6, 0x9e, 0xe7, 0x25, 0x1c, 0xc3, 0xa, 0xb2, 0x5, 0xea, 0xc2, 0x2e, 0x2b, 0xfb, 0x9f, 0x0, 0x7e, 0xb8, 0xfc, 0x86, 0x51, 0x5d, 0xc, 0xd0, 0x11, 0x70, 0xd4, 0x57, 0x96, 0xe, 0x7, 0x30, 0x9, 0x5e, 0x6f, 0xb0, 0xe9, 0xc5, 0x19, 0xc7, 0x7e, 0xb7, 0x96, 0xf4, 0x46, 0x5e, 0xb3, 0x94, 0x92, 0x3d, 0x95, 0xe4, 0xaf, 0x0, 0xec, 0x11, 0xee, 0x5, 0x22, 0xb4, 0x90, 0x9c, 0xfc, 0xe1, 0x3f, 0x5b, 0x0, 0x63, 0x49, 0xf3, 0x48, 0x67, 0x2c, 0x4d, 0x4f, 0xa, 0x76, 0x2b, 0x6, 0x68, 0xf, 0x18, 0x79, 0xcd, 0xd2, 0x3d, 0x24, 0xbd, 0x4c, 0xf2, 0xc0, 0x62, 0xb5, 0x33, 0xce, 0x5b, 0x59, 0xd2, 0x26, 0x92, 0x2f, 0x91, 0xbc, 0xf8, 0xc5, 0x19, 0xc7, 0x6c, 0x6a, 0x4b, 0x3e, 0xf5, 0xa, 0xff, 0xf4, 0xc, 0x0, 0x0, 0x23, 0xaf, 0x7e, 0xe1, 0x7a, 0x1a, 0x5e, 0x7, 0x20, 0xe5, 0xfb, 0x61, 0x65, 0x0, 0xec, 0x82, 0xb0, 0xb, 0xc4, 0xe, 0x0, 0x5b, 0x24, 0x6d, 0x26, 0xb9, 0xd, 0xc2, 0x66, 0x41, 0x4b, 0x8c, 0x31, 0xbf, 0xfb, 0xfd, 0x4f, 0x8e, 0x59, 0x57, 0x63, 0xd6, 0x9d, 0xe, 0x75, 0xa3, 0x6, 0x76, 0x26, 0xd0, 0x98, 0xff, 0x91, 0x74, 0x8, 0x80, 0x1e, 0x24, 0xb7, 0xc0, 0xdb, 0x5b, 0x6f, 0x33, 0xd, 0xdf, 0x3, 0xf0, 0xb6, 0xa4, 0x57, 0x1, 0xbc, 0xf4, 0xe2, 0x8c, 0x63, 0xdf, 0xe9, 0xec, 0xb2, 0x76, 0x41, 0x17, 0x74, 0x41, 0x17, 0x74, 0x41, 0x17, 0x74, 0x41, 0x17, 0x74, 0x41, 0x17, 0x74, 0x41, 0x17, 0xd4, 0x6, 0xff, 0x1f, 0x32, 0x68, 0x5, 0x7e, 0x99, 0xd5, 0x97, 0x49, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char option_arrow_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x8,0x4,0x0,0x0,0x0,0xfc,0x7c,0x94,0x6c,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x5f,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0x20,0xc,0xee,0x27,0xdc,0x4f,0xc0,0x22,0xfc,0x50,0xfb,0xc1,0x97,0x7,0x5f,0x1e,0x6a,0xc3,0xf8,0x4c,0x10,0xea,0x5,0xf7,0xff,0x55,0xc,0xdc,0xc,0xdc,0xff,0x57,0xbd,0xe0,0x46,0x91,0xf8,0x39,0x85,0x41,0x8b,0x81,0x81,0x81,0x81,0x41,0xeb,0xe7,0x14,0x22,0x6c,0xc5,0x7,0x1e,0xce,0x7f,0xf0,0x1f,0x2,0x1f,0xce,0x87,0x88,0x30,0xc2,0x2c,0xff,0x71,0x8a,0x41,0x8b,0x81,0x81,0xe1,0x1a,0x87,0x99,0xc4,0x57,0xbc,0xce,0x25,0xec,0x41,0x74,0x0,0x0,0xec,0x66,0x28,0xba,0x76,0x22,0x7a,0x72,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char option_arrow_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x4, 0x0, 0x0, 0x0, 0xfc, 0x7c, 0x94, 0x6c, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x5f, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0x20, 0xc, 0xee, 0x27, 0xdc, 0x4f, 0xc0, 0x22, 0xfc, 0x50, 0xfb, 0xc1, 0x97, 0x7, 0x5f, 0x1e, 0x6a, 0xc3, 0xf8, 0x4c, 0x10, 0xea, 0x5, 0xf7, 0xff, 0x55, 0xc, 0xdc, 0xc, 0xdc, 0xff, 0x57, 0xbd, 0xe0, 0x46, 0x91, 0xf8, 0x39, 0x85, 0x41, 0x8b, 0x81, 0x81, 0x81, 0x81, 0x41, 0xeb, 0xe7, 0x14, 0x22, 0x6c, 0xc5, 0x7, 0x1e, 0xce, 0x7f, 0xf0, 0x1f, 0x2, 0x1f, 0xce, 0x87, 0x88, 0x30, 0xc2, 0x2c, 0xff, 0x71, 0x8a, 0x41, 0x8b, 0x81, 0x81, 0xe1, 0x1a, 0x87, 0x99, 0xc4, 0x57, 0xbc, 0xce, 0x25, 0xec, 0x41, 0x74, 0x0, 0x0, 0xec, 0x66, 0x28, 0xba, 0x76, 0x22, 0x7a, 0x72, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char option_button_disabled_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x40,0xde,0x8d,0x6b,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x32,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0x3f,0x3f,0x5a,0x5a,0x5a,0x2b,0x2b,0x31,0x2e,0x2e,0x34,0x59,0x59,0x59,0x2a,0x2a,0x30,0x4b,0x4b,0x4b,0x22,0x22,0x27,0x35,0x35,0x35,0x4a,0x4a,0x4a,0x24,0x24,0x28,0x24,0x24,0x29,0x56,0x56,0x56,0x62,0x62,0x62,0x2a,0x2a,0x31,0x2a,0x2a,0x30,0x2d,0x2d,0x34,0x2f,0x2f,0x36,0x2e,0x2e,0x35,0x2c,0x2c,0x32,0x48,0x48,0x48,0x44,0x44,0x44,0x43,0x43,0x43,0x54,0x54,0x54,0x26,0x26,0x2b,0x24,0x24,0x28,0x27,0x27,0x2d,0x29,0x29,0x2f,0x28,0x28,0x2e,0x25,0x25,0x2b,0x23,0x23,0x28,0x26,0x26,0x2c,0x25,0x25,0x2a,0x2a,0x2a,0x2f,0x2b,0x2b,0x31,0x22,0x22,0x26,0x52,0x52,0x52,0x42,0x42,0x42,0x2d,0x2d,0x33,0x22,0x22,0x27,0x51,0x51,0x51,0x40,0x40,0x40,0x27,0x27,0x2b,0x2e,0x2e,0x34,0x2c,0x2c,0x31,0x29,0x29,0x2e,0x4f,0x4f,0x4f,0x3f,0x3f,0x3f,0x4d,0x4d,0x4d,0x3e,0x3e,0x3e,0x24,0x24,0x2a,0x24,0x24,0x29,0x20,0x20,0x25,0x4c,0x4c,0x4c,0x3d,0x3d,0x3d,0x28,0x28,0x2d,0x2b,0x2b,0x30,0x29,0x29,0x2d,0x20,0x20,0x23,0x4a,0x4a,0x4a,0x3b,0x3b,0x3b,0x22,0x22,0x28,0x27,0x27,0x2c,0x1e,0x1e,0x22,0x49,0x49,0x49,0x3a,0x3a,0x3a,0x21,0x21,0x26,0x21,0x21,0x25,0x23,0x23,0x27,0x20,0x20,0x24,0x1d,0x1d,0x21,0x39,0x39,0x39,0x47,0x47,0x47,0x1f,0x1f,0x24,0x1f,0x1f,0x23,0x1e,0x1e,0x21,0x46,0x46,0x46,0xff,0xff,0xff,0xbd,0x3f,0x83,0xbb,0x0,0x0,0x0,0x24,0x74,0x52,0x4e,0x53,0x0,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x1d,0x16,0xd,0x7,0x2,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x43,0x3a,0x2d,0x1b,0x77,0xef,0xe6,0x49,0xef,0xe6,0xef,0xe7,0x77,0xef,0xe4,0x4a,0xba,0xea,0xc1,0xeb,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x65,0xb5,0xdd,0x88,0x9f,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x1,0xb,0x49,0x44,0x41,0x54,0x28,0xcf,0x8d,0xd1,0xd9,0x56,0xc2,0x30,0x10,0x80,0x61,0xd6,0xa2,0xa8,0x6c,0x75,0xdf,0x10,0x54,0xa8,0x82,0x74,0xd2,0x4a,0x49,0x5b,0xa4,0xb5,0x5a,0x44,0x10,0x5c,0xd0,0xaa,0x80,0x8a,0xcb,0xfb,0x3f,0x83,0x21,0x24,0x1c,0x8e,0x5e,0xe8,0x77,0xfd,0x9f,0x93,0x99,0x89,0xcf,0x1f,0x8,0x86,0xc2,0x42,0x84,0x10,0x66,0x66,0xa3,0x73,0xf3,0xbe,0x9f,0x2,0xb,0xb1,0x78,0x22,0x99,0x12,0x45,0x71,0x71,0x69,0x79,0x25,0xea,0xff,0x15,0x4,0x63,0xab,0x6b,0x7b,0xcc,0x7e,0x2e,0x2f,0x1d,0x30,0x87,0x52,0x21,0xbf,0xbe,0x41,0x82,0x50,0x7c,0xb3,0x78,0x54,0x1a,0x93,0x1,0x29,0x2a,0x73,0xac,0x94,0x35,0x6d,0x8b,0x4,0xe1,0x84,0x5c,0xe2,0xe4,0xa,0xd6,0xb,0x8c,0xa1,0x2b,0xd8,0x54,0x48,0x20,0x24,0xab,0x27,0x5c,0xb5,0x2,0x39,0x89,0xa9,0x19,0x2a,0x58,0xa3,0x20,0x92,0xb2,0x4f,0x39,0xdb,0x1,0xe3,0x8c,0xa9,0x9d,0xbb,0x60,0x3a,0xa3,0x40,0xac,0x5f,0x70,0xf5,0xe9,0xc0,0x20,0x1,0xd0,0xa0,0x71,0xc9,0x35,0xca,0x4d,0x75,0x6a,0x86,0xd6,0x15,0xa6,0x4f,0xb4,0x3b,0x5c,0x1b,0xa1,0xeb,0x1b,0x46,0xbf,0x5,0xed,0xe,0xd1,0x21,0xbb,0xf7,0x5c,0xf7,0xc1,0xf2,0x26,0x6b,0x7a,0x4d,0xeb,0xd1,0xa2,0x6b,0x3e,0x3d,0x73,0xc5,0x5e,0x1f,0x7b,0xc,0xe0,0xc1,0xcb,0xab,0x49,0xf,0xb5,0xdd,0x79,0x63,0x86,0xbd,0x77,0xd,0x33,0xad,0x41,0xff,0xe3,0x33,0x4d,0x4f,0xbd,0x93,0x19,0x7e,0x8d,0xd9,0x0,0xee,0x64,0x6,0xd7,0x41,0xd9,0xdd,0xff,0x7c,0xd6,0x5f,0xdf,0xfd,0xd,0xbf,0xaa,0x55,0xdf,0x7c,0xb2,0x44,0x90,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char option_button_disabled_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x40, 0xde, 0x8d, 0x6b, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x32, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0x3f, 0x3f, 0x5a, 0x5a, 0x5a, 0x2b, 0x2b, 0x31, 0x2e, 0x2e, 0x34, 0x59, 0x59, 0x59, 0x2a, 0x2a, 0x30, 0x4b, 0x4b, 0x4b, 0x22, 0x22, 0x27, 0x35, 0x35, 0x35, 0x4a, 0x4a, 0x4a, 0x24, 0x24, 0x28, 0x24, 0x24, 0x29, 0x56, 0x56, 0x56, 0x62, 0x62, 0x62, 0x2a, 0x2a, 0x31, 0x2a, 0x2a, 0x30, 0x2d, 0x2d, 0x34, 0x2f, 0x2f, 0x36, 0x2e, 0x2e, 0x35, 0x2c, 0x2c, 0x32, 0x48, 0x48, 0x48, 0x44, 0x44, 0x44, 0x43, 0x43, 0x43, 0x54, 0x54, 0x54, 0x26, 0x26, 0x2b, 0x24, 0x24, 0x28, 0x27, 0x27, 0x2d, 0x29, 0x29, 0x2f, 0x28, 0x28, 0x2e, 0x25, 0x25, 0x2b, 0x23, 0x23, 0x28, 0x26, 0x26, 0x2c, 0x25, 0x25, 0x2a, 0x2a, 0x2a, 0x2f, 0x2b, 0x2b, 0x31, 0x22, 0x22, 0x26, 0x52, 0x52, 0x52, 0x42, 0x42, 0x42, 0x2d, 0x2d, 0x33, 0x22, 0x22, 0x27, 0x51, 0x51, 0x51, 0x40, 0x40, 0x40, 0x27, 0x27, 0x2b, 0x2e, 0x2e, 0x34, 0x2c, 0x2c, 0x31, 0x29, 0x29, 0x2e, 0x4f, 0x4f, 0x4f, 0x3f, 0x3f, 0x3f, 0x4d, 0x4d, 0x4d, 0x3e, 0x3e, 0x3e, 0x24, 0x24, 0x2a, 0x24, 0x24, 0x29, 0x20, 0x20, 0x25, 0x4c, 0x4c, 0x4c, 0x3d, 0x3d, 0x3d, 0x28, 0x28, 0x2d, 0x2b, 0x2b, 0x30, 0x29, 0x29, 0x2d, 0x20, 0x20, 0x23, 0x4a, 0x4a, 0x4a, 0x3b, 0x3b, 0x3b, 0x22, 0x22, 0x28, 0x27, 0x27, 0x2c, 0x1e, 0x1e, 0x22, 0x49, 0x49, 0x49, 0x3a, 0x3a, 0x3a, 0x21, 0x21, 0x26, 0x21, 0x21, 0x25, 0x23, 0x23, 0x27, 0x20, 0x20, 0x24, 0x1d, 0x1d, 0x21, 0x39, 0x39, 0x39, 0x47, 0x47, 0x47, 0x1f, 0x1f, 0x24, 0x1f, 0x1f, 0x23, 0x1e, 0x1e, 0x21, 0x46, 0x46, 0x46, 0xff, 0xff, 0xff, 0xbd, 0x3f, 0x83, 0xbb, 0x0, 0x0, 0x0, 0x24, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x1d, 0x16, 0xd, 0x7, 0x2, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x43, 0x3a, 0x2d, 0x1b, 0x77, 0xef, 0xe6, 0x49, 0xef, 0xe6, 0xef, 0xe7, 0x77, 0xef, 0xe4, 0x4a, 0xba, 0xea, 0xc1, 0xeb, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x65, 0xb5, 0xdd, 0x88, 0x9f, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x1, 0xb, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x8d, 0xd1, 0xd9, 0x56, 0xc2, 0x30, 0x10, 0x80, 0x61, 0xd6, 0xa2, 0xa8, 0x6c, 0x75, 0xdf, 0x10, 0x54, 0xa8, 0x82, 0x74, 0xd2, 0x4a, 0x49, 0x5b, 0xa4, 0xb5, 0x5a, 0x44, 0x10, 0x5c, 0xd0, 0xaa, 0x80, 0x8a, 0xcb, 0xfb, 0x3f, 0x83, 0x21, 0x24, 0x1c, 0x8e, 0x5e, 0xe8, 0x77, 0xfd, 0x9f, 0x93, 0x99, 0x89, 0xcf, 0x1f, 0x8, 0x86, 0xc2, 0x42, 0x84, 0x10, 0x66, 0x66, 0xa3, 0x73, 0xf3, 0xbe, 0x9f, 0x2, 0xb, 0xb1, 0x78, 0x22, 0x99, 0x12, 0x45, 0x71, 0x71, 0x69, 0x79, 0x25, 0xea, 0xff, 0x15, 0x4, 0x63, 0xab, 0x6b, 0x7b, 0xcc, 0x7e, 0x2e, 0x2f, 0x1d, 0x30, 0x87, 0x52, 0x21, 0xbf, 0xbe, 0x41, 0x82, 0x50, 0x7c, 0xb3, 0x78, 0x54, 0x1a, 0x93, 0x1, 0x29, 0x2a, 0x73, 0xac, 0x94, 0x35, 0x6d, 0x8b, 0x4, 0xe1, 0x84, 0x5c, 0xe2, 0xe4, 0xa, 0xd6, 0xb, 0x8c, 0xa1, 0x2b, 0xd8, 0x54, 0x48, 0x20, 0x24, 0xab, 0x27, 0x5c, 0xb5, 0x2, 0x39, 0x89, 0xa9, 0x19, 0x2a, 0x58, 0xa3, 0x20, 0x92, 0xb2, 0x4f, 0x39, 0xdb, 0x1, 0xe3, 0x8c, 0xa9, 0x9d, 0xbb, 0x60, 0x3a, 0xa3, 0x40, 0xac, 0x5f, 0x70, 0xf5, 0xe9, 0xc0, 0x20, 0x1, 0xd0, 0xa0, 0x71, 0xc9, 0x35, 0xca, 0x4d, 0x75, 0x6a, 0x86, 0xd6, 0x15, 0xa6, 0x4f, 0xb4, 0x3b, 0x5c, 0x1b, 0xa1, 0xeb, 0x1b, 0x46, 0xbf, 0x5, 0xed, 0xe, 0xd1, 0x21, 0xbb, 0xf7, 0x5c, 0xf7, 0xc1, 0xf2, 0x26, 0x6b, 0x7a, 0x4d, 0xeb, 0xd1, 0xa2, 0x6b, 0x3e, 0x3d, 0x73, 0xc5, 0x5e, 0x1f, 0x7b, 0xc, 0xe0, 0xc1, 0xcb, 0xab, 0x49, 0xf, 0xb5, 0xdd, 0x79, 0x63, 0x86, 0xbd, 0x77, 0xd, 0x33, 0xad, 0x41, 0xff, 0xe3, 0x33, 0x4d, 0x4f, 0xbd, 0x93, 0x19, 0x7e, 0x8d, 0xd9, 0x0, 0xee, 0x64, 0x6, 0xd7, 0x41, 0xd9, 0xdd, 0xff, 0x7c, 0xd6, 0x5f, 0xdf, 0xfd, 0xd, 0xbf, 0xaa, 0x55, 0xdf, 0x7c, 0xb2, 0x44, 0x90, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char option_button_focus_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xb4,0x50,0x4c,0x54,0x45,0x95,0xa9,0xb0,0x92,0xa7,0xae,0x8e,0xa2,0xa9,0x8a,0x9d,0xa4,0x85,0x98,0x9f,0x80,0x93,0x9b,0x7b,0x8f,0x96,0x77,0x8a,0x92,0x72,0x86,0x8c,0x6e,0x80,0x88,0x69,0x7c,0x84,0x64,0x77,0x7f,0x60,0x72,0x7a,0x5b,0x6e,0x75,0x56,0x69,0x71,0xc8,0xe3,0xe7,0xc8,0xe2,0xe7,0xca,0xe3,0xe7,0xce,0xe6,0xe9,0xce,0xe6,0xea,0xd0,0xe6,0xe9,0xce,0xe5,0xea,0xd0,0xe6,0xea,0xce,0xe5,0xe9,0xd0,0xe5,0xe9,0xd3,0xe7,0xeb,0xd4,0xe7,0xeb,0xd9,0xea,0xed,0xd7,0xe9,0xed,0xd7,0xea,0xed,0xdc,0xec,0xef,0xdc,0xeb,0xef,0xe0,0xed,0xf1,0xdf,0xee,0xf1,0xdf,0xed,0xf1,0xe0,0xee,0xf1,0xe3,0xf0,0xf2,0xe2,0xef,0xf2,0xe3,0xef,0xf2,0xe6,0xf1,0xf3,0xe8,0xf2,0xf5,0xe8,0xf3,0xf4,0xe8,0xf2,0xf4,0xe8,0xf3,0xf5,0xd6,0x5a,0x5b,0xd4,0x57,0x58,0xe5,0x89,0x89,0xd5,0x57,0x59,0xd5,0x58,0x59,0xd5,0x59,0x5a,0xd6,0x59,0x5a,0xd6,0x5a,0x5c,0xd7,0x5b,0x5c,0xd7,0x5b,0x5d,0xd8,0x5c,0x5d,0xd8,0x5c,0x5e,0xd8,0x5d,0x5f,0xd9,0x5d,0x5f,0xe8,0x6c,0x6e,0xff,0xff,0xff,0xa1,0xe,0x37,0x8c,0x0,0x0,0x0,0x2c,0x74,0x52,0x4e,0x53,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0xac,0x80,0x68,0x47,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x3b,0x39,0xe,0xf4,0x6c,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xa3,0x49,0x44,0x41,0x54,0x18,0xd3,0x5d,0xce,0xdb,0x16,0x42,0x60,0x18,0x84,0xe1,0x4f,0x8,0x65,0x57,0x2a,0x45,0xd9,0x15,0xf9,0xa3,0x89,0x28,0xea,0xfe,0x2f,0x2c,0x4e,0x2c,0x79,0xd6,0xbc,0xe7,0x43,0x34,0xc5,0xe5,0x7f,0x38,0x9a,0xdd,0x31,0x72,0x9f,0x11,0xff,0x80,0x61,0x18,0xa6,0x69,0xac,0xba,0x50,0xf0,0x24,0x14,0x58,0x5b,0x9b,0xed,0xce,0xb6,0x6d,0x6b,0x8f,0x42,0x20,0xb1,0xc4,0xc1,0x71,0xe,0x7d,0x8e,0x83,0x52,0xa4,0xf9,0x13,0xae,0x7b,0x74,0x7b,0xa7,0x13,0x9e,0x73,0x92,0x72,0x78,0xbe,0xef,0x75,0x7c,0xcf,0x47,0x2e,0x91,0x5c,0x21,0x8,0xc2,0x20,0x8c,0x82,0x73,0x18,0xa1,0x92,0x49,0xa9,0x71,0x89,0xe3,0x38,0x49,0xba,0x25,0xa8,0x15,0x5a,0xbc,0x70,0x1d,0xe0,0xb5,0xa0,0xe5,0x1b,0x69,0xca,0xd8,0x8d,0x31,0x96,0x65,0x68,0x96,0xa4,0x36,0x60,0x3,0x34,0x2a,0x69,0xed,0xf8,0x7a,0xab,0x91,0xfe,0xf9,0x8e,0x7c,0x74,0xd2,0x27,0x7e,0x7e,0x46,0x20,0x17,0xe,0x2d,0x4e,0x9,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char option_button_focus_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xb4, 0x50, 0x4c, 0x54, 0x45, 0x95, 0xa9, 0xb0, 0x92, 0xa7, 0xae, 0x8e, 0xa2, 0xa9, 0x8a, 0x9d, 0xa4, 0x85, 0x98, 0x9f, 0x80, 0x93, 0x9b, 0x7b, 0x8f, 0x96, 0x77, 0x8a, 0x92, 0x72, 0x86, 0x8c, 0x6e, 0x80, 0x88, 0x69, 0x7c, 0x84, 0x64, 0x77, 0x7f, 0x60, 0x72, 0x7a, 0x5b, 0x6e, 0x75, 0x56, 0x69, 0x71, 0xc8, 0xe3, 0xe7, 0xc8, 0xe2, 0xe7, 0xca, 0xe3, 0xe7, 0xce, 0xe6, 0xe9, 0xce, 0xe6, 0xea, 0xd0, 0xe6, 0xe9, 0xce, 0xe5, 0xea, 0xd0, 0xe6, 0xea, 0xce, 0xe5, 0xe9, 0xd0, 0xe5, 0xe9, 0xd3, 0xe7, 0xeb, 0xd4, 0xe7, 0xeb, 0xd9, 0xea, 0xed, 0xd7, 0xe9, 0xed, 0xd7, 0xea, 0xed, 0xdc, 0xec, 0xef, 0xdc, 0xeb, 0xef, 0xe0, 0xed, 0xf1, 0xdf, 0xee, 0xf1, 0xdf, 0xed, 0xf1, 0xe0, 0xee, 0xf1, 0xe3, 0xf0, 0xf2, 0xe2, 0xef, 0xf2, 0xe3, 0xef, 0xf2, 0xe6, 0xf1, 0xf3, 0xe8, 0xf2, 0xf5, 0xe8, 0xf3, 0xf4, 0xe8, 0xf2, 0xf4, 0xe8, 0xf3, 0xf5, 0xd6, 0x5a, 0x5b, 0xd4, 0x57, 0x58, 0xe5, 0x89, 0x89, 0xd5, 0x57, 0x59, 0xd5, 0x58, 0x59, 0xd5, 0x59, 0x5a, 0xd6, 0x59, 0x5a, 0xd6, 0x5a, 0x5c, 0xd7, 0x5b, 0x5c, 0xd7, 0x5b, 0x5d, 0xd8, 0x5c, 0x5d, 0xd8, 0x5c, 0x5e, 0xd8, 0x5d, 0x5f, 0xd9, 0x5d, 0x5f, 0xe8, 0x6c, 0x6e, 0xff, 0xff, 0xff, 0xa1, 0xe, 0x37, 0x8c, 0x0, 0x0, 0x0, 0x2c, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0xac, 0x80, 0x68, 0x47, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x3b, 0x39, 0xe, 0xf4, 0x6c, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xa3, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x5d, 0xce, 0xdb, 0x16, 0x42, 0x60, 0x18, 0x84, 0xe1, 0x4f, 0x8, 0x65, 0x57, 0x2a, 0x45, 0xd9, 0x15, 0xf9, 0xa3, 0x89, 0x28, 0xea, 0xfe, 0x2f, 0x2c, 0x4e, 0x2c, 0x79, 0xd6, 0xbc, 0xe7, 0x43, 0x34, 0xc5, 0xe5, 0x7f, 0x38, 0x9a, 0xdd, 0x31, 0x72, 0x9f, 0x11, 0xff, 0x80, 0x61, 0x18, 0xa6, 0x69, 0xac, 0xba, 0x50, 0xf0, 0x24, 0x14, 0x58, 0x5b, 0x9b, 0xed, 0xce, 0xb6, 0x6d, 0x6b, 0x8f, 0x42, 0x20, 0xb1, 0xc4, 0xc1, 0x71, 0xe, 0x7d, 0x8e, 0x83, 0x52, 0xa4, 0xf9, 0x13, 0xae, 0x7b, 0x74, 0x7b, 0xa7, 0x13, 0x9e, 0x73, 0x92, 0x72, 0x78, 0xbe, 0xef, 0x75, 0x7c, 0xcf, 0x47, 0x2e, 0x91, 0x5c, 0x21, 0x8, 0xc2, 0x20, 0x8c, 0x82, 0x73, 0x18, 0xa1, 0x92, 0x49, 0xa9, 0x71, 0x89, 0xe3, 0x38, 0x49, 0xba, 0x25, 0xa8, 0x15, 0x5a, 0xbc, 0x70, 0x1d, 0xe0, 0xb5, 0xa0, 0xe5, 0x1b, 0x69, 0xca, 0xd8, 0x8d, 0x31, 0x96, 0x65, 0x68, 0x96, 0xa4, 0x36, 0x60, 0x3, 0x34, 0x2a, 0x69, 0xed, 0xf8, 0x7a, 0xab, 0x91, 0xfe, 0xf9, 0x8e, 0x7c, 0x74, 0xd2, 0x27, 0x7e, 0x7e, 0x46, 0x20, 0x17, 0xe, 0x2d, 0x4e, 0x9, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char option_button_hover_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x40,0xde,0x8d,0x6b,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x44,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x42,0x40,0x4b,0x5f,0x5a,0x6c,0x2b,0x2b,0x31,0x2e,0x2e,0x34,0x5f,0x5a,0x6b,0x2a,0x2a,0x30,0x56,0x53,0x64,0x22,0x22,0x27,0x3e,0x3b,0x46,0x57,0x53,0x63,0x24,0x24,0x28,0x24,0x24,0x29,0x5b,0x57,0x68,0x5a,0x56,0x67,0x67,0x63,0x76,0x2a,0x2a,0x31,0x2a,0x2a,0x30,0x2d,0x2d,0x34,0x2f,0x2f,0x36,0x2e,0x2e,0x35,0x2c,0x2c,0x32,0x4d,0x4a,0x57,0x49,0x46,0x52,0x48,0x45,0x51,0x5a,0x56,0x65,0x26,0x26,0x2b,0x24,0x24,0x28,0x27,0x27,0x2d,0x29,0x29,0x2f,0x28,0x28,0x2e,0x25,0x25,0x2b,0x23,0x23,0x28,0x5b,0x57,0x66,0x26,0x26,0x2c,0x25,0x25,0x2a,0x2a,0x2a,0x2f,0x2b,0x2b,0x31,0x22,0x22,0x26,0x59,0x55,0x64,0x47,0x44,0x50,0x2d,0x2d,0x33,0x22,0x22,0x27,0x58,0x54,0x64,0x46,0x43,0x50,0x27,0x27,0x2b,0x2e,0x2e,0x34,0x2c,0x2c,0x31,0x29,0x29,0x2e,0x56,0x53,0x63,0x45,0x42,0x4f,0x56,0x53,0x62,0x45,0x42,0x4e,0x24,0x24,0x2a,0x24,0x24,0x29,0x20,0x20,0x25,0x55,0x51,0x62,0x44,0x41,0x4e,0x28,0x28,0x2d,0x2b,0x2b,0x30,0x29,0x29,0x2d,0x20,0x20,0x23,0x55,0x51,0x60,0x44,0x41,0x4d,0x22,0x22,0x28,0x27,0x27,0x2c,0x1e,0x1e,0x22,0x43,0x40,0x4c,0x54,0x50,0x5f,0x21,0x21,0x26,0x21,0x21,0x25,0x23,0x23,0x27,0x20,0x20,0x24,0x1d,0x1d,0x21,0x47,0x43,0x51,0x43,0x3f,0x4d,0x42,0x3f,0x4c,0x53,0x4f,0x5f,0x1f,0x1f,0x24,0x1f,0x1f,0x23,0x1e,0x1e,0x21,0x53,0x50,0x5f,0x53,0x4f,0x5e,0x5f,0x5a,0x6c,0xff,0xff,0xff,0xd1,0x85,0xc5,0x5,0x0,0x0,0x0,0x24,0x74,0x52,0x4e,0x53,0x0,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x1d,0x16,0xd,0x7,0x2,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x43,0x3a,0x2d,0x1b,0x77,0xef,0xe6,0x49,0xef,0xe6,0xef,0xe7,0x77,0xef,0xe4,0x4a,0xba,0xea,0xc1,0xeb,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x6b,0x52,0x65,0xa5,0x98,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x1,0x10,0x49,0x44,0x41,0x54,0x28,0xcf,0x8d,0xd1,0xd9,0x52,0xc2,0x30,0x14,0x80,0x61,0xd6,0xa2,0xa8,0x6c,0x75,0xdf,0x77,0xa8,0xa2,0x70,0xd2,0x4a,0x25,0x6d,0x81,0x62,0xa1,0x88,0x20,0x6e,0xc5,0xaa,0x80,0xfb,0xfa,0xfe,0xf,0x60,0x49,0x13,0x86,0xd1,0xb,0xfd,0x6e,0xf3,0xcf,0xe4,0x24,0xc7,0xe3,0xf5,0xf9,0x3,0x41,0x2e,0xe4,0xe0,0x46,0x46,0xc3,0x63,0xe3,0x9e,0x9f,0x7c,0x13,0x91,0x68,0x2c,0x9e,0xe0,0x79,0x7e,0x72,0x6a,0x7a,0x26,0xec,0xfd,0x15,0xf8,0x23,0xb3,0x73,0x9b,0x5b,0xae,0xed,0x64,0x4a,0xd8,0xa1,0x76,0x85,0x74,0x6a,0x7e,0xc1,0x9,0x2,0xd1,0xc5,0xbd,0xfd,0x8c,0x2b,0xb,0x48,0x94,0xa8,0x3,0x31,0x27,0xcb,0x4b,0x4e,0x10,0x8c,0x1d,0xb2,0xf3,0x4c,0x36,0x8f,0x95,0x34,0xa5,0x2a,0x22,0xd6,0x44,0x27,0xe0,0xe2,0x85,0x22,0x53,0xc8,0x43,0x52,0xa0,0x4a,0xaa,0x4,0x7a,0x3f,0x8,0x25,0xca,0x47,0x4c,0xd9,0x0,0xb5,0x42,0x95,0xaa,0x26,0x68,0x46,0x3f,0xe0,0x6b,0xc7,0x4c,0x6d,0x38,0x50,0x9d,0x0,0x48,0x50,0x3f,0x61,0xea,0xb9,0x86,0x34,0x34,0x43,0xf3,0x14,0x93,0x2b,0x5a,0x67,0x4c,0xb,0xa1,0xf3,0xb,0x4a,0xb9,0x4,0xf9,0xa,0x91,0x21,0xad,0x36,0x63,0x5d,0xeb,0xf6,0xe0,0x99,0x76,0x43,0xbf,0xd1,0xc9,0x33,0xad,0xf6,0x2d,0x75,0xd7,0xe9,0x62,0x9b,0x2,0xdc,0xbb,0x7f,0xd0,0xc8,0x47,0x2d,0x3f,0x3e,0x3d,0xbb,0x5e,0x3a,0xaf,0x32,0xa6,0x9a,0xbd,0xee,0xdb,0xfb,0xa,0xf9,0xea,0xd5,0xb5,0x8f,0x4f,0xd7,0x17,0x80,0x39,0x98,0xc1,0x34,0xd0,0xfa,0xc6,0x7f,0x96,0xf5,0xd7,0xba,0xbf,0x1,0xfe,0x22,0x58,0x7c,0xf4,0xd2,0xd1,0x68,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char option_button_hover_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x40, 0xde, 0x8d, 0x6b, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x44, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x42, 0x40, 0x4b, 0x5f, 0x5a, 0x6c, 0x2b, 0x2b, 0x31, 0x2e, 0x2e, 0x34, 0x5f, 0x5a, 0x6b, 0x2a, 0x2a, 0x30, 0x56, 0x53, 0x64, 0x22, 0x22, 0x27, 0x3e, 0x3b, 0x46, 0x57, 0x53, 0x63, 0x24, 0x24, 0x28, 0x24, 0x24, 0x29, 0x5b, 0x57, 0x68, 0x5a, 0x56, 0x67, 0x67, 0x63, 0x76, 0x2a, 0x2a, 0x31, 0x2a, 0x2a, 0x30, 0x2d, 0x2d, 0x34, 0x2f, 0x2f, 0x36, 0x2e, 0x2e, 0x35, 0x2c, 0x2c, 0x32, 0x4d, 0x4a, 0x57, 0x49, 0x46, 0x52, 0x48, 0x45, 0x51, 0x5a, 0x56, 0x65, 0x26, 0x26, 0x2b, 0x24, 0x24, 0x28, 0x27, 0x27, 0x2d, 0x29, 0x29, 0x2f, 0x28, 0x28, 0x2e, 0x25, 0x25, 0x2b, 0x23, 0x23, 0x28, 0x5b, 0x57, 0x66, 0x26, 0x26, 0x2c, 0x25, 0x25, 0x2a, 0x2a, 0x2a, 0x2f, 0x2b, 0x2b, 0x31, 0x22, 0x22, 0x26, 0x59, 0x55, 0x64, 0x47, 0x44, 0x50, 0x2d, 0x2d, 0x33, 0x22, 0x22, 0x27, 0x58, 0x54, 0x64, 0x46, 0x43, 0x50, 0x27, 0x27, 0x2b, 0x2e, 0x2e, 0x34, 0x2c, 0x2c, 0x31, 0x29, 0x29, 0x2e, 0x56, 0x53, 0x63, 0x45, 0x42, 0x4f, 0x56, 0x53, 0x62, 0x45, 0x42, 0x4e, 0x24, 0x24, 0x2a, 0x24, 0x24, 0x29, 0x20, 0x20, 0x25, 0x55, 0x51, 0x62, 0x44, 0x41, 0x4e, 0x28, 0x28, 0x2d, 0x2b, 0x2b, 0x30, 0x29, 0x29, 0x2d, 0x20, 0x20, 0x23, 0x55, 0x51, 0x60, 0x44, 0x41, 0x4d, 0x22, 0x22, 0x28, 0x27, 0x27, 0x2c, 0x1e, 0x1e, 0x22, 0x43, 0x40, 0x4c, 0x54, 0x50, 0x5f, 0x21, 0x21, 0x26, 0x21, 0x21, 0x25, 0x23, 0x23, 0x27, 0x20, 0x20, 0x24, 0x1d, 0x1d, 0x21, 0x47, 0x43, 0x51, 0x43, 0x3f, 0x4d, 0x42, 0x3f, 0x4c, 0x53, 0x4f, 0x5f, 0x1f, 0x1f, 0x24, 0x1f, 0x1f, 0x23, 0x1e, 0x1e, 0x21, 0x53, 0x50, 0x5f, 0x53, 0x4f, 0x5e, 0x5f, 0x5a, 0x6c, 0xff, 0xff, 0xff, 0xd1, 0x85, 0xc5, 0x5, 0x0, 0x0, 0x0, 0x24, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x1d, 0x16, 0xd, 0x7, 0x2, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x43, 0x3a, 0x2d, 0x1b, 0x77, 0xef, 0xe6, 0x49, 0xef, 0xe6, 0xef, 0xe7, 0x77, 0xef, 0xe4, 0x4a, 0xba, 0xea, 0xc1, 0xeb, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x6b, 0x52, 0x65, 0xa5, 0x98, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x1, 0x10, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x8d, 0xd1, 0xd9, 0x52, 0xc2, 0x30, 0x14, 0x80, 0x61, 0xd6, 0xa2, 0xa8, 0x6c, 0x75, 0xdf, 0x77, 0xa8, 0xa2, 0x70, 0xd2, 0x4a, 0x25, 0x6d, 0x81, 0x62, 0xa1, 0x88, 0x20, 0x6e, 0xc5, 0xaa, 0x80, 0xfb, 0xfa, 0xfe, 0xf, 0x60, 0x49, 0x13, 0x86, 0xd1, 0xb, 0xfd, 0x6e, 0xf3, 0xcf, 0xe4, 0x24, 0xc7, 0xe3, 0xf5, 0xf9, 0x3, 0x41, 0x2e, 0xe4, 0xe0, 0x46, 0x46, 0xc3, 0x63, 0xe3, 0x9e, 0x9f, 0x7c, 0x13, 0x91, 0x68, 0x2c, 0x9e, 0xe0, 0x79, 0x7e, 0x72, 0x6a, 0x7a, 0x26, 0xec, 0xfd, 0x15, 0xf8, 0x23, 0xb3, 0x73, 0x9b, 0x5b, 0xae, 0xed, 0x64, 0x4a, 0xd8, 0xa1, 0x76, 0x85, 0x74, 0x6a, 0x7e, 0xc1, 0x9, 0x2, 0xd1, 0xc5, 0xbd, 0xfd, 0x8c, 0x2b, 0xb, 0x48, 0x94, 0xa8, 0x3, 0x31, 0x27, 0xcb, 0x4b, 0x4e, 0x10, 0x8c, 0x1d, 0xb2, 0xf3, 0x4c, 0x36, 0x8f, 0x95, 0x34, 0xa5, 0x2a, 0x22, 0xd6, 0x44, 0x27, 0xe0, 0xe2, 0x85, 0x22, 0x53, 0xc8, 0x43, 0x52, 0xa0, 0x4a, 0xaa, 0x4, 0x7a, 0x3f, 0x8, 0x25, 0xca, 0x47, 0x4c, 0xd9, 0x0, 0xb5, 0x42, 0x95, 0xaa, 0x26, 0x68, 0x46, 0x3f, 0xe0, 0x6b, 0xc7, 0x4c, 0x6d, 0x38, 0x50, 0x9d, 0x0, 0x48, 0x50, 0x3f, 0x61, 0xea, 0xb9, 0x86, 0x34, 0x34, 0x43, 0xf3, 0x14, 0x93, 0x2b, 0x5a, 0x67, 0x4c, 0xb, 0xa1, 0xf3, 0xb, 0x4a, 0xb9, 0x4, 0xf9, 0xa, 0x91, 0x21, 0xad, 0x36, 0x63, 0x5d, 0xeb, 0xf6, 0xe0, 0x99, 0x76, 0x43, 0xbf, 0xd1, 0xc9, 0x33, 0xad, 0xf6, 0x2d, 0x75, 0xd7, 0xe9, 0x62, 0x9b, 0x2, 0xdc, 0xbb, 0x7f, 0xd0, 0xc8, 0x47, 0x2d, 0x3f, 0x3e, 0x3d, 0xbb, 0x5e, 0x3a, 0xaf, 0x32, 0xa6, 0x9a, 0xbd, 0xee, 0xdb, 0xfb, 0xa, 0xf9, 0xea, 0xd5, 0xb5, 0x8f, 0x4f, 0xd7, 0x17, 0x80, 0x39, 0x98, 0xc1, 0x34, 0xd0, 0xfa, 0xc6, 0x7f, 0x96, 0xf5, 0xd7, 0xba, 0xbf, 0x1, 0xfe, 0x22, 0x58, 0x7c, 0xf4, 0xd2, 0xd1, 0x68, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char option_button_normal_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x40,0xde,0x8d,0x6b,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x44,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x3a,0x44,0x56,0x53,0x61,0x2b,0x2b,0x31,0x2e,0x2e,0x34,0x56,0x52,0x60,0x2a,0x2a,0x30,0x47,0x44,0x52,0x22,0x22,0x27,0x33,0x31,0x39,0x47,0x44,0x50,0x24,0x24,0x28,0x24,0x24,0x29,0x52,0x50,0x5d,0x51,0x4f,0x5d,0x5d,0x5a,0x6a,0x2a,0x2a,0x31,0x2a,0x2a,0x30,0x2d,0x2d,0x34,0x2f,0x2f,0x36,0x2e,0x2e,0x35,0x2c,0x2c,0x32,0x46,0x42,0x4e,0x42,0x3e,0x4a,0x41,0x3e,0x49,0x51,0x4e,0x5b,0x26,0x26,0x2b,0x24,0x24,0x28,0x27,0x27,0x2d,0x29,0x29,0x2f,0x28,0x28,0x2e,0x25,0x25,0x2b,0x23,0x23,0x28,0x40,0x3e,0x48,0x50,0x4e,0x5a,0x26,0x26,0x2c,0x25,0x25,0x2a,0x2a,0x2a,0x2f,0x2b,0x2b,0x31,0x22,0x22,0x26,0x4f,0x4c,0x59,0x3f,0x3d,0x47,0x2d,0x2d,0x33,0x22,0x22,0x27,0x4e,0x4a,0x58,0x3e,0x3b,0x46,0x27,0x27,0x2b,0x2e,0x2e,0x34,0x2c,0x2c,0x31,0x29,0x29,0x2e,0x4b,0x49,0x55,0x3c,0x3a,0x44,0x4a,0x47,0x54,0x3b,0x39,0x43,0x24,0x24,0x2a,0x24,0x24,0x29,0x20,0x20,0x25,0x49,0x46,0x53,0x3a,0x38,0x42,0x28,0x28,0x2d,0x2b,0x2b,0x30,0x29,0x29,0x2d,0x20,0x20,0x23,0x47,0x45,0x50,0x39,0x37,0x40,0x22,0x22,0x28,0x27,0x27,0x2c,0x1e,0x1e,0x22,0x47,0x43,0x50,0x38,0x35,0x3f,0x46,0x42,0x4f,0x21,0x21,0x26,0x21,0x21,0x25,0x23,0x23,0x27,0x20,0x20,0x24,0x1d,0x1d,0x21,0x36,0x34,0x3e,0x44,0x41,0x4e,0x1f,0x1f,0x24,0x1f,0x1f,0x23,0x1e,0x1e,0x21,0x44,0x42,0x4d,0x44,0x41,0x4c,0x4e,0x4b,0x58,0xff,0xff,0xff,0xd7,0xc8,0xfe,0x88,0x0,0x0,0x0,0x24,0x74,0x52,0x4e,0x53,0x0,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x1d,0x16,0xd,0x7,0x2,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x43,0x3a,0x2d,0x1b,0x77,0xef,0xe6,0x49,0xef,0xe6,0xef,0xe7,0x77,0xef,0xe4,0x4a,0xba,0xea,0xc1,0xeb,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x6b,0x52,0x65,0xa5,0x98,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x1,0xe,0x49,0x44,0x41,0x54,0x28,0xcf,0x8d,0xd1,0xd7,0x56,0xc2,0x40,0x10,0x80,0x61,0x6a,0x50,0x54,0x5a,0xec,0xbd,0x43,0x14,0x85,0xdd,0x44,0xa2,0x6c,0x12,0x20,0x18,0xd,0x22,0x8,0x16,0x34,0x16,0xc0,0x5e,0xde,0xff,0x1,0x5c,0x36,0xb3,0x1c,0x8e,0x5e,0xe8,0x77,0xfd,0x9f,0xb3,0x33,0xb3,0x1e,0xaf,0xcf,0x1f,0x8,0xa,0x21,0x4a,0x18,0x1a,0xe,0x8f,0x8c,0x7a,0x7e,0xf2,0x8d,0x45,0xa2,0xb1,0x78,0x42,0x14,0xc5,0xf1,0x89,0xc9,0xa9,0xb0,0xf7,0x57,0xe0,0x8f,0x4c,0xcf,0xac,0x6f,0xb8,0x36,0x93,0x29,0x69,0xb,0x6c,0x4b,0xe9,0xd4,0xec,0x1c,0xd,0x2,0xd1,0xf9,0x9d,0xdd,0x8c,0x2b,0x8b,0xb0,0xac,0x80,0x3d,0x39,0xa7,0xaa,0xb,0x34,0x8,0xc6,0xb2,0x99,0x7d,0x70,0x90,0x27,0x5a,0x1a,0xe8,0x9a,0x4c,0xc,0x99,0x6,0x42,0xbc,0x50,0xe4,0xa,0x79,0x94,0x94,0x40,0x49,0x57,0x90,0xd9,0xb,0x42,0x89,0xf2,0x21,0x57,0xb6,0x90,0x7e,0x4,0x4a,0xc7,0x36,0x32,0xac,0x5e,0x20,0x56,0x4e,0xb8,0xca,0x60,0xa0,0xd3,0x0,0xb1,0xa0,0x7a,0xca,0x55,0x73,0x35,0x65,0x60,0x86,0xfa,0x19,0x61,0x4f,0x34,0x9a,0x5c,0x3,0xe3,0xf3,0xb,0xa0,0x5d,0x22,0xf5,0xa,0xb3,0x21,0x5b,0xd7,0x5c,0xeb,0xc6,0x74,0xfa,0x6b,0x3a,0x35,0xf3,0xd6,0x64,0x6b,0xde,0xdd,0x73,0xf,0xed,0xe,0x71,0x0,0x22,0xdd,0xc7,0x27,0x83,0x1d,0x6a,0xb1,0xf9,0xc,0x5e,0xda,0xaf,0x2a,0x1,0xf5,0x6e,0xe7,0xed,0x7d,0x89,0x9d,0x7a,0x79,0xe5,0xe3,0xd3,0xf5,0x85,0x90,0xdd,0x9f,0xc1,0xb6,0xf0,0xea,0xda,0x7f,0x3e,0xeb,0xaf,0xef,0xfe,0x6,0x1a,0x96,0x59,0x89,0x91,0xf7,0xf1,0x7b,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char option_button_normal_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x40, 0xde, 0x8d, 0x6b, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x44, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3c, 0x3a, 0x44, 0x56, 0x53, 0x61, 0x2b, 0x2b, 0x31, 0x2e, 0x2e, 0x34, 0x56, 0x52, 0x60, 0x2a, 0x2a, 0x30, 0x47, 0x44, 0x52, 0x22, 0x22, 0x27, 0x33, 0x31, 0x39, 0x47, 0x44, 0x50, 0x24, 0x24, 0x28, 0x24, 0x24, 0x29, 0x52, 0x50, 0x5d, 0x51, 0x4f, 0x5d, 0x5d, 0x5a, 0x6a, 0x2a, 0x2a, 0x31, 0x2a, 0x2a, 0x30, 0x2d, 0x2d, 0x34, 0x2f, 0x2f, 0x36, 0x2e, 0x2e, 0x35, 0x2c, 0x2c, 0x32, 0x46, 0x42, 0x4e, 0x42, 0x3e, 0x4a, 0x41, 0x3e, 0x49, 0x51, 0x4e, 0x5b, 0x26, 0x26, 0x2b, 0x24, 0x24, 0x28, 0x27, 0x27, 0x2d, 0x29, 0x29, 0x2f, 0x28, 0x28, 0x2e, 0x25, 0x25, 0x2b, 0x23, 0x23, 0x28, 0x40, 0x3e, 0x48, 0x50, 0x4e, 0x5a, 0x26, 0x26, 0x2c, 0x25, 0x25, 0x2a, 0x2a, 0x2a, 0x2f, 0x2b, 0x2b, 0x31, 0x22, 0x22, 0x26, 0x4f, 0x4c, 0x59, 0x3f, 0x3d, 0x47, 0x2d, 0x2d, 0x33, 0x22, 0x22, 0x27, 0x4e, 0x4a, 0x58, 0x3e, 0x3b, 0x46, 0x27, 0x27, 0x2b, 0x2e, 0x2e, 0x34, 0x2c, 0x2c, 0x31, 0x29, 0x29, 0x2e, 0x4b, 0x49, 0x55, 0x3c, 0x3a, 0x44, 0x4a, 0x47, 0x54, 0x3b, 0x39, 0x43, 0x24, 0x24, 0x2a, 0x24, 0x24, 0x29, 0x20, 0x20, 0x25, 0x49, 0x46, 0x53, 0x3a, 0x38, 0x42, 0x28, 0x28, 0x2d, 0x2b, 0x2b, 0x30, 0x29, 0x29, 0x2d, 0x20, 0x20, 0x23, 0x47, 0x45, 0x50, 0x39, 0x37, 0x40, 0x22, 0x22, 0x28, 0x27, 0x27, 0x2c, 0x1e, 0x1e, 0x22, 0x47, 0x43, 0x50, 0x38, 0x35, 0x3f, 0x46, 0x42, 0x4f, 0x21, 0x21, 0x26, 0x21, 0x21, 0x25, 0x23, 0x23, 0x27, 0x20, 0x20, 0x24, 0x1d, 0x1d, 0x21, 0x36, 0x34, 0x3e, 0x44, 0x41, 0x4e, 0x1f, 0x1f, 0x24, 0x1f, 0x1f, 0x23, 0x1e, 0x1e, 0x21, 0x44, 0x42, 0x4d, 0x44, 0x41, 0x4c, 0x4e, 0x4b, 0x58, 0xff, 0xff, 0xff, 0xd7, 0xc8, 0xfe, 0x88, 0x0, 0x0, 0x0, 0x24, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x1d, 0x16, 0xd, 0x7, 0x2, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x43, 0x3a, 0x2d, 0x1b, 0x77, 0xef, 0xe6, 0x49, 0xef, 0xe6, 0xef, 0xe7, 0x77, 0xef, 0xe4, 0x4a, 0xba, 0xea, 0xc1, 0xeb, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x6b, 0x52, 0x65, 0xa5, 0x98, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x1, 0xe, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x8d, 0xd1, 0xd7, 0x56, 0xc2, 0x40, 0x10, 0x80, 0x61, 0x6a, 0x50, 0x54, 0x5a, 0xec, 0xbd, 0x43, 0x14, 0x85, 0xdd, 0x44, 0xa2, 0x6c, 0x12, 0x20, 0x18, 0xd, 0x22, 0x8, 0x16, 0x34, 0x16, 0xc0, 0x5e, 0xde, 0xff, 0x1, 0x5c, 0x36, 0xb3, 0x1c, 0x8e, 0x5e, 0xe8, 0x77, 0xfd, 0x9f, 0xb3, 0x33, 0xb3, 0x1e, 0xaf, 0xcf, 0x1f, 0x8, 0xa, 0x21, 0x4a, 0x18, 0x1a, 0xe, 0x8f, 0x8c, 0x7a, 0x7e, 0xf2, 0x8d, 0x45, 0xa2, 0xb1, 0x78, 0x42, 0x14, 0xc5, 0xf1, 0x89, 0xc9, 0xa9, 0xb0, 0xf7, 0x57, 0xe0, 0x8f, 0x4c, 0xcf, 0xac, 0x6f, 0xb8, 0x36, 0x93, 0x29, 0x69, 0xb, 0x6c, 0x4b, 0xe9, 0xd4, 0xec, 0x1c, 0xd, 0x2, 0xd1, 0xf9, 0x9d, 0xdd, 0x8c, 0x2b, 0x8b, 0xb0, 0xac, 0x80, 0x3d, 0x39, 0xa7, 0xaa, 0xb, 0x34, 0x8, 0xc6, 0xb2, 0x99, 0x7d, 0x70, 0x90, 0x27, 0x5a, 0x1a, 0xe8, 0x9a, 0x4c, 0xc, 0x99, 0x6, 0x42, 0xbc, 0x50, 0xe4, 0xa, 0x79, 0x94, 0x94, 0x40, 0x49, 0x57, 0x90, 0xd9, 0xb, 0x42, 0x89, 0xf2, 0x21, 0x57, 0xb6, 0x90, 0x7e, 0x4, 0x4a, 0xc7, 0x36, 0x32, 0xac, 0x5e, 0x20, 0x56, 0x4e, 0xb8, 0xca, 0x60, 0xa0, 0xd3, 0x0, 0xb1, 0xa0, 0x7a, 0xca, 0x55, 0x73, 0x35, 0x65, 0x60, 0x86, 0xfa, 0x19, 0x61, 0x4f, 0x34, 0x9a, 0x5c, 0x3, 0xe3, 0xf3, 0xb, 0xa0, 0x5d, 0x22, 0xf5, 0xa, 0xb3, 0x21, 0x5b, 0xd7, 0x5c, 0xeb, 0xc6, 0x74, 0xfa, 0x6b, 0x3a, 0x35, 0xf3, 0xd6, 0x64, 0x6b, 0xde, 0xdd, 0x73, 0xf, 0xed, 0xe, 0x71, 0x0, 0x22, 0xdd, 0xc7, 0x27, 0x83, 0x1d, 0x6a, 0xb1, 0xf9, 0xc, 0x5e, 0xda, 0xaf, 0x2a, 0x1, 0xf5, 0x6e, 0xe7, 0xed, 0x7d, 0x89, 0x9d, 0x7a, 0x79, 0xe5, 0xe3, 0xd3, 0xf5, 0x85, 0x90, 0xdd, 0x9f, 0xc1, 0xb6, 0xf0, 0xea, 0xda, 0x7f, 0x3e, 0xeb, 0xaf, 0xef, 0xfe, 0x6, 0x1a, 0x96, 0x59, 0x89, 0x91, 0xf7, 0xf1, 0x7b, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char option_button_pressed_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x40,0xde,0x8d,0x6b,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x4d,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x31,0x2f,0x37,0x46,0x43,0x4f,0x2b,0x2b,0x31,0x2e,0x2e,0x34,0x47,0x44,0x50,0x2a,0x2a,0x30,0x55,0x52,0x5f,0x22,0x22,0x27,0x3d,0x3a,0x45,0x56,0x52,0x60,0x24,0x24,0x28,0x24,0x24,0x29,0x43,0x40,0x4c,0x42,0x40,0x4b,0x4c,0x49,0x56,0x2a,0x2a,0x31,0x2a,0x2a,0x30,0x2d,0x2d,0x34,0x2f,0x2f,0x36,0x2e,0x2e,0x35,0x2c,0x2c,0x32,0x3a,0x38,0x41,0x36,0x34,0x3d,0x44,0x41,0x4c,0x26,0x26,0x2b,0x24,0x24,0x28,0x27,0x27,0x2d,0x29,0x29,0x2f,0x28,0x28,0x2e,0x25,0x25,0x2b,0x23,0x23,0x28,0x44,0x42,0x4e,0x36,0x34,0x3e,0x44,0x41,0x4e,0x26,0x26,0x2c,0x25,0x25,0x2a,0x2a,0x2a,0x2f,0x2b,0x2b,0x31,0x22,0x22,0x26,0x46,0x42,0x4f,0x38,0x35,0x3f,0x2d,0x2d,0x33,0x22,0x22,0x27,0x47,0x45,0x50,0x39,0x37,0x40,0x27,0x27,0x2b,0x2e,0x2e,0x34,0x2c,0x2c,0x31,0x29,0x29,0x2e,0x49,0x46,0x53,0x3a,0x38,0x42,0x4a,0x47,0x54,0x3b,0x39,0x43,0x24,0x24,0x2a,0x24,0x24,0x29,0x20,0x20,0x25,0x4b,0x49,0x55,0x3c,0x3a,0x44,0x28,0x28,0x2d,0x2b,0x2b,0x30,0x29,0x29,0x2d,0x20,0x20,0x23,0x4e,0x4a,0x58,0x3e,0x3b,0x46,0x22,0x22,0x28,0x27,0x27,0x2c,0x1e,0x1e,0x22,0x50,0x4d,0x5a,0x3f,0x3d,0x48,0x3f,0x3d,0x47,0x4f,0x4c,0x59,0x21,0x21,0x26,0x21,0x21,0x25,0x23,0x23,0x27,0x20,0x20,0x24,0x1d,0x1d,0x21,0x45,0x42,0x4d,0x41,0x3e,0x49,0x40,0x3e,0x48,0x50,0x4e,0x5a,0x1f,0x1f,0x24,0x1f,0x1f,0x23,0x1e,0x1e,0x21,0x52,0x4e,0x5c,0x51,0x4e,0x5b,0x5d,0x59,0x69,0xff,0xff,0xff,0x2,0x4e,0xff,0xf1,0x0,0x0,0x0,0x24,0x74,0x52,0x4e,0x53,0x0,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x1d,0x16,0xd,0x7,0x2,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x43,0x3a,0x2d,0x1b,0x77,0xef,0xe6,0x49,0xef,0xe6,0xef,0xe7,0x77,0xef,0xe4,0x4a,0xba,0xea,0xc1,0xeb,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x6e,0x22,0xf,0x51,0x17,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x1,0xe,0x49,0x44,0x41,0x54,0x28,0xcf,0x8d,0xd1,0x57,0x53,0xc2,0x40,0x10,0xc0,0x71,0x6a,0x50,0x54,0x5a,0xec,0xbd,0x43,0x14,0xf5,0x2e,0x91,0xa8,0x5c,0x12,0x20,0x18,0xd,0x22,0x88,0xd,0x8d,0xd,0xb0,0xd7,0xef,0xff,0xea,0x71,0xd9,0x63,0x18,0x7d,0xd0,0xdf,0xf3,0x7f,0xe6,0x76,0xf7,0x3c,0x5e,0x9f,0x3f,0x10,0x14,0x42,0x94,0xd0,0xd3,0x1b,0xee,0xeb,0xf7,0xfc,0xe4,0x1b,0x88,0x44,0x63,0xf1,0x84,0x28,0x8a,0x83,0x43,0xc3,0x23,0x61,0xef,0xaf,0xc0,0x1f,0x19,0x1d,0x5b,0x5c,0x72,0x2d,0x27,0x53,0xd2,0xa,0x58,0x95,0xd2,0xa9,0xf1,0x9,0x1a,0x4,0xa2,0x93,0x6b,0xeb,0x60,0x3,0x61,0x59,0x1,0x9b,0x72,0x46,0x55,0xa7,0x68,0x10,0x8c,0x6d,0x6d,0x73,0x3b,0x59,0xa2,0xa5,0x81,0xae,0xc9,0xc4,0x90,0x69,0x20,0xc4,0x73,0x79,0x2e,0x97,0x45,0x49,0x9,0x14,0x74,0x5,0x99,0xed,0x20,0x94,0x28,0xee,0x72,0x45,0xb,0xe9,0x7b,0xa0,0xb0,0x6f,0x23,0xc3,0x6a,0x7,0x62,0xe9,0x80,0x2b,0x75,0x7,0x3a,0xd,0x10,0xb,0xca,0x87,0x5c,0x39,0x53,0x51,0xba,0x66,0xa8,0x1e,0x11,0xf6,0x44,0xed,0x98,0xab,0x61,0x7c,0x72,0xa,0xb4,0x33,0xa4,0x9e,0x63,0x36,0x64,0xfd,0x82,0xab,0x5f,0x9a,0x4e,0x67,0x4d,0xa7,0x62,0x5e,0x99,0x6c,0xcd,0xeb,0x9b,0x5b,0x70,0xd7,0x68,0x12,0x7,0x20,0xd2,0xba,0x7f,0x30,0xd8,0xa1,0xa6,0x1f,0x9f,0x9e,0x5d,0x2f,0x8d,0x57,0x95,0x80,0x6a,0xab,0xf9,0xf6,0x3e,0xc3,0x4e,0x3d,0x3b,0xf7,0xf1,0xe9,0xfa,0x42,0xc8,0xee,0xcc,0x60,0x5b,0x78,0x7e,0xe1,0x3f,0x9f,0xf5,0xd7,0x77,0x7f,0x3,0x1c,0x7f,0x59,0xc2,0x5e,0xdd,0xbf,0x43,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char option_button_pressed_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x40, 0xde, 0x8d, 0x6b, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x4d, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x31, 0x2f, 0x37, 0x46, 0x43, 0x4f, 0x2b, 0x2b, 0x31, 0x2e, 0x2e, 0x34, 0x47, 0x44, 0x50, 0x2a, 0x2a, 0x30, 0x55, 0x52, 0x5f, 0x22, 0x22, 0x27, 0x3d, 0x3a, 0x45, 0x56, 0x52, 0x60, 0x24, 0x24, 0x28, 0x24, 0x24, 0x29, 0x43, 0x40, 0x4c, 0x42, 0x40, 0x4b, 0x4c, 0x49, 0x56, 0x2a, 0x2a, 0x31, 0x2a, 0x2a, 0x30, 0x2d, 0x2d, 0x34, 0x2f, 0x2f, 0x36, 0x2e, 0x2e, 0x35, 0x2c, 0x2c, 0x32, 0x3a, 0x38, 0x41, 0x36, 0x34, 0x3d, 0x44, 0x41, 0x4c, 0x26, 0x26, 0x2b, 0x24, 0x24, 0x28, 0x27, 0x27, 0x2d, 0x29, 0x29, 0x2f, 0x28, 0x28, 0x2e, 0x25, 0x25, 0x2b, 0x23, 0x23, 0x28, 0x44, 0x42, 0x4e, 0x36, 0x34, 0x3e, 0x44, 0x41, 0x4e, 0x26, 0x26, 0x2c, 0x25, 0x25, 0x2a, 0x2a, 0x2a, 0x2f, 0x2b, 0x2b, 0x31, 0x22, 0x22, 0x26, 0x46, 0x42, 0x4f, 0x38, 0x35, 0x3f, 0x2d, 0x2d, 0x33, 0x22, 0x22, 0x27, 0x47, 0x45, 0x50, 0x39, 0x37, 0x40, 0x27, 0x27, 0x2b, 0x2e, 0x2e, 0x34, 0x2c, 0x2c, 0x31, 0x29, 0x29, 0x2e, 0x49, 0x46, 0x53, 0x3a, 0x38, 0x42, 0x4a, 0x47, 0x54, 0x3b, 0x39, 0x43, 0x24, 0x24, 0x2a, 0x24, 0x24, 0x29, 0x20, 0x20, 0x25, 0x4b, 0x49, 0x55, 0x3c, 0x3a, 0x44, 0x28, 0x28, 0x2d, 0x2b, 0x2b, 0x30, 0x29, 0x29, 0x2d, 0x20, 0x20, 0x23, 0x4e, 0x4a, 0x58, 0x3e, 0x3b, 0x46, 0x22, 0x22, 0x28, 0x27, 0x27, 0x2c, 0x1e, 0x1e, 0x22, 0x50, 0x4d, 0x5a, 0x3f, 0x3d, 0x48, 0x3f, 0x3d, 0x47, 0x4f, 0x4c, 0x59, 0x21, 0x21, 0x26, 0x21, 0x21, 0x25, 0x23, 0x23, 0x27, 0x20, 0x20, 0x24, 0x1d, 0x1d, 0x21, 0x45, 0x42, 0x4d, 0x41, 0x3e, 0x49, 0x40, 0x3e, 0x48, 0x50, 0x4e, 0x5a, 0x1f, 0x1f, 0x24, 0x1f, 0x1f, 0x23, 0x1e, 0x1e, 0x21, 0x52, 0x4e, 0x5c, 0x51, 0x4e, 0x5b, 0x5d, 0x59, 0x69, 0xff, 0xff, 0xff, 0x2, 0x4e, 0xff, 0xf1, 0x0, 0x0, 0x0, 0x24, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x1d, 0x16, 0xd, 0x7, 0x2, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x43, 0x3a, 0x2d, 0x1b, 0x77, 0xef, 0xe6, 0x49, 0xef, 0xe6, 0xef, 0xe7, 0x77, 0xef, 0xe4, 0x4a, 0xba, 0xea, 0xc1, 0xeb, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x6e, 0x22, 0xf, 0x51, 0x17, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x1, 0xe, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x8d, 0xd1, 0x57, 0x53, 0xc2, 0x40, 0x10, 0xc0, 0x71, 0x6a, 0x50, 0x54, 0x5a, 0xec, 0xbd, 0x43, 0x14, 0xf5, 0x2e, 0x91, 0xa8, 0x5c, 0x12, 0x20, 0x18, 0xd, 0x22, 0x88, 0xd, 0x8d, 0xd, 0xb0, 0xd7, 0xef, 0xff, 0xea, 0x71, 0xd9, 0x63, 0x18, 0x7d, 0xd0, 0xdf, 0xf3, 0x7f, 0xe6, 0x76, 0xf7, 0x3c, 0x5e, 0x9f, 0x3f, 0x10, 0x14, 0x42, 0x94, 0xd0, 0xd3, 0x1b, 0xee, 0xeb, 0xf7, 0xfc, 0xe4, 0x1b, 0x88, 0x44, 0x63, 0xf1, 0x84, 0x28, 0x8a, 0x83, 0x43, 0xc3, 0x23, 0x61, 0xef, 0xaf, 0xc0, 0x1f, 0x19, 0x1d, 0x5b, 0x5c, 0x72, 0x2d, 0x27, 0x53, 0xd2, 0xa, 0x58, 0x95, 0xd2, 0xa9, 0xf1, 0x9, 0x1a, 0x4, 0xa2, 0x93, 0x6b, 0xeb, 0x60, 0x3, 0x61, 0x59, 0x1, 0x9b, 0x72, 0x46, 0x55, 0xa7, 0x68, 0x10, 0x8c, 0x6d, 0x6d, 0x73, 0x3b, 0x59, 0xa2, 0xa5, 0x81, 0xae, 0xc9, 0xc4, 0x90, 0x69, 0x20, 0xc4, 0x73, 0x79, 0x2e, 0x97, 0x45, 0x49, 0x9, 0x14, 0x74, 0x5, 0x99, 0xed, 0x20, 0x94, 0x28, 0xee, 0x72, 0x45, 0xb, 0xe9, 0x7b, 0xa0, 0xb0, 0x6f, 0x23, 0xc3, 0x6a, 0x7, 0x62, 0xe9, 0x80, 0x2b, 0x75, 0x7, 0x3a, 0xd, 0x10, 0xb, 0xca, 0x87, 0x5c, 0x39, 0x53, 0x51, 0xba, 0x66, 0xa8, 0x1e, 0x11, 0xf6, 0x44, 0xed, 0x98, 0xab, 0x61, 0x7c, 0x72, 0xa, 0xb4, 0x33, 0xa4, 0x9e, 0x63, 0x36, 0x64, 0xfd, 0x82, 0xab, 0x5f, 0x9a, 0x4e, 0x67, 0x4d, 0xa7, 0x62, 0x5e, 0x99, 0x6c, 0xcd, 0xeb, 0x9b, 0x5b, 0x70, 0xd7, 0x68, 0x12, 0x7, 0x20, 0xd2, 0xba, 0x7f, 0x30, 0xd8, 0xa1, 0xa6, 0x1f, 0x9f, 0x9e, 0x5d, 0x2f, 0x8d, 0x57, 0x95, 0x80, 0x6a, 0xab, 0xf9, 0xf6, 0x3e, 0xc3, 0x4e, 0x3d, 0x3b, 0xf7, 0xf1, 0xe9, 0xfa, 0x42, 0xc8, 0xee, 0xcc, 0x60, 0x5b, 0x78, 0x7e, 0xe1, 0x3f, 0x9f, 0xf5, 0xd7, 0x77, 0x7f, 0x3, 0x1c, 0x7f, 0x59, 0xc2, 0x5e, 0xdd, 0xbf, 0x43, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char panel_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x1,0x3,0x0,0x0,0x0,0xfe,0xc1,0x2c,0xc8,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x25,0x25,0x2a,0x35,0x32,0x3b,0x4a,0x73,0x58,0x4a,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1,0xff,0x2,0x2d,0xde,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xb,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x40,0x5,0x0,0x0,0x10,0x0,0x1,0xa1,0xc5,0x21,0xc1,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char panel_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x1, 0x3, 0x0, 0x0, 0x0, 0xfe, 0xc1, 0x2c, 0xc8, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x50, 0x4c, 0x54, 0x45, 0x25, 0x25, 0x2a, 0x35, 0x32, 0x3b, 0x4a, 0x73, 0x58, 0x4a, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1, 0xff, 0x2, 0x2d, 0xde, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xb, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x40, 0x5, 0x0, 0x0, 0x10, 0x0, 0x1, 0xa1, 0xc5, 0x21, 0xc1, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char popup_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xa5,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3b,0x3b,0x43,0x42,0x42,0x4b,0x3e,0x3e,0x47,0x3e,0x3e,0x46,0x41,0x41,0x4a,0x0,0x0,0x0,0x3d,0x3d,0x45,0x3b,0x3b,0x43,0x3a,0x3a,0x42,0x38,0x38,0x41,0x37,0x37,0x3e,0x36,0x36,0x3d,0x35,0x35,0x3c,0x0,0x0,0x0,0x38,0x38,0x40,0x38,0x38,0x40,0x31,0x31,0x38,0x34,0x34,0x3b,0x34,0x34,0x3b,0x39,0x39,0x3f,0x31,0x31,0x38,0x2f,0x2f,0x36,0x2d,0x2d,0x33,0x2c,0x2c,0x32,0x2b,0x2b,0x31,0x2a,0x2a,0x31,0x2a,0x2a,0x30,0x29,0x29,0x30,0x29,0x29,0x2f,0x28,0x28,0x2e,0x28,0x28,0x2d,0x27,0x27,0x2d,0x27,0x27,0x2c,0x29,0x29,0x2e,0x26,0x26,0x2c,0x35,0x32,0x3b,0xf,0xeb,0x7f,0x60,0x0,0x0,0x0,0x28,0x74,0x52,0x4e,0x53,0x0,0x1,0x3,0x5,0x8,0xa,0xb,0x4,0x13,0x19,0x1f,0x22,0x23,0x16,0x27,0x35,0x3f,0x45,0x46,0x94,0xf5,0xfa,0xfb,0xf5,0x40,0xfc,0xfb,0xfb,0xfb,0xfb,0xfc,0xfc,0x1a,0xf5,0xf6,0x95,0xfa,0xfb,0xf4,0x94,0x71,0xda,0xac,0x92,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x36,0x47,0xbf,0x88,0xd1,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xaf,0x49,0x44,0x41,0x54,0x18,0xd3,0x65,0xcf,0xc9,0x12,0x82,0x30,0x10,0x4,0xd0,0x1,0x12,0xb6,0x0,0x21,0x2c,0xb2,0xaa,0xa0,0xa8,0x80,0x88,0x8,0xf8,0xff,0xbf,0x66,0x98,0x93,0xa5,0xef,0xd8,0x55,0xd3,0xd5,0x3,0xa0,0xa8,0x1a,0xa1,0xba,0x44,0x89,0xa6,0x2a,0x0,0x8a,0x41,0x4d,0xcb,0x66,0x8e,0xc3,0x6c,0xcb,0xa4,0x86,0x2,0x2a,0x75,0x3d,0xee,0x8b,0x20,0x10,0x3e,0xf7,0x5c,0xaa,0x82,0x66,0x7a,0x61,0x14,0xef,0xa4,0x38,0xa,0x3d,0x53,0x3,0x62,0xf1,0xa4,0xed,0x50,0x9b,0x70,0x8b,0x0,0xb5,0xd3,0xac,0xeb,0x51,0x97,0xa5,0x36,0x5,0x9d,0x89,0xbc,0xbf,0xa3,0x3e,0x17,0x4c,0x7,0xdd,0x9,0x8a,0xe1,0x81,0x86,0x22,0x70,0x30,0x28,0xc7,0x27,0x1a,0x4b,0xc,0x98,0xd8,0x4f,0x2f,0x34,0xed,0xb7,0x13,0x59,0x7a,0x98,0x17,0x34,0x1f,0xb7,0x52,0x52,0xf1,0x7a,0x5d,0xde,0xd2,0xb2,0x9e,0x78,0x45,0xb6,0x61,0xe7,0xba,0xb9,0x48,0xcd,0xf5,0xb6,0xd,0xc3,0xe9,0xe9,0xd7,0xf4,0xbf,0xe7,0x7e,0xdf,0xff,0x0,0xda,0x19,0x15,0x34,0xd5,0xa4,0x90,0x50,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char popup_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xa5, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3b, 0x3b, 0x43, 0x42, 0x42, 0x4b, 0x3e, 0x3e, 0x47, 0x3e, 0x3e, 0x46, 0x41, 0x41, 0x4a, 0x0, 0x0, 0x0, 0x3d, 0x3d, 0x45, 0x3b, 0x3b, 0x43, 0x3a, 0x3a, 0x42, 0x38, 0x38, 0x41, 0x37, 0x37, 0x3e, 0x36, 0x36, 0x3d, 0x35, 0x35, 0x3c, 0x0, 0x0, 0x0, 0x38, 0x38, 0x40, 0x38, 0x38, 0x40, 0x31, 0x31, 0x38, 0x34, 0x34, 0x3b, 0x34, 0x34, 0x3b, 0x39, 0x39, 0x3f, 0x31, 0x31, 0x38, 0x2f, 0x2f, 0x36, 0x2d, 0x2d, 0x33, 0x2c, 0x2c, 0x32, 0x2b, 0x2b, 0x31, 0x2a, 0x2a, 0x31, 0x2a, 0x2a, 0x30, 0x29, 0x29, 0x30, 0x29, 0x29, 0x2f, 0x28, 0x28, 0x2e, 0x28, 0x28, 0x2d, 0x27, 0x27, 0x2d, 0x27, 0x27, 0x2c, 0x29, 0x29, 0x2e, 0x26, 0x26, 0x2c, 0x35, 0x32, 0x3b, 0xf, 0xeb, 0x7f, 0x60, 0x0, 0x0, 0x0, 0x28, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x1, 0x3, 0x5, 0x8, 0xa, 0xb, 0x4, 0x13, 0x19, 0x1f, 0x22, 0x23, 0x16, 0x27, 0x35, 0x3f, 0x45, 0x46, 0x94, 0xf5, 0xfa, 0xfb, 0xf5, 0x40, 0xfc, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0x1a, 0xf5, 0xf6, 0x95, 0xfa, 0xfb, 0xf4, 0x94, 0x71, 0xda, 0xac, 0x92, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x36, 0x47, 0xbf, 0x88, 0xd1, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xaf, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x65, 0xcf, 0xc9, 0x12, 0x82, 0x30, 0x10, 0x4, 0xd0, 0x1, 0x12, 0xb6, 0x0, 0x21, 0x2c, 0xb2, 0xaa, 0xa0, 0xa8, 0x80, 0x88, 0x8, 0xf8, 0xff, 0xbf, 0x66, 0x98, 0x93, 0xa5, 0xef, 0xd8, 0x55, 0xd3, 0xd5, 0x3, 0xa0, 0xa8, 0x1a, 0xa1, 0xba, 0x44, 0x89, 0xa6, 0x2a, 0x0, 0x8a, 0x41, 0x4d, 0xcb, 0x66, 0x8e, 0xc3, 0x6c, 0xcb, 0xa4, 0x86, 0x2, 0x2a, 0x75, 0x3d, 0xee, 0x8b, 0x20, 0x10, 0x3e, 0xf7, 0x5c, 0xaa, 0x82, 0x66, 0x7a, 0x61, 0x14, 0xef, 0xa4, 0x38, 0xa, 0x3d, 0x53, 0x3, 0x62, 0xf1, 0xa4, 0xed, 0x50, 0x9b, 0x70, 0x8b, 0x0, 0xb5, 0xd3, 0xac, 0xeb, 0x51, 0x97, 0xa5, 0x36, 0x5, 0x9d, 0x89, 0xbc, 0xbf, 0xa3, 0x3e, 0x17, 0x4c, 0x7, 0xdd, 0x9, 0x8a, 0xe1, 0x81, 0x86, 0x22, 0x70, 0x30, 0x28, 0xc7, 0x27, 0x1a, 0x4b, 0xc, 0x98, 0xd8, 0x4f, 0x2f, 0x34, 0xed, 0xb7, 0x13, 0x59, 0x7a, 0x98, 0x17, 0x34, 0x1f, 0xb7, 0x52, 0x52, 0xf1, 0x7a, 0x5d, 0xde, 0xd2, 0xb2, 0x9e, 0x78, 0x45, 0xb6, 0x61, 0xe7, 0xba, 0xb9, 0x48, 0xcd, 0xf5, 0xb6, 0xd, 0xc3, 0xe9, 0xe9, 0xd7, 0xf4, 0xbf, 0xe7, 0x7e, 0xdf, 0xff, 0x0, 0xda, 0x19, 0x15, 0x34, 0xd5, 0xa4, 0x90, 0x50, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char popup_bg_disabled_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x7b,0x50,0x4c,0x54,0x45,0xff,0x0,0xff,0x67,0x7a,0x85,0x66,0x7a,0x86,0x68,0x7b,0x86,0x57,0x51,0x51,0x4c,0x42,0x40,0x4d,0x43,0x41,0x56,0x4c,0x4b,0x4d,0x44,0x41,0x4e,0x44,0x42,0x4f,0x45,0x43,0x67,0x7b,0x87,0x4f,0x44,0x43,0x50,0x45,0x44,0x52,0x46,0x44,0x51,0x46,0x45,0x4b,0x40,0x3f,0x51,0x47,0x45,0x52,0x48,0x46,0x53,0x48,0x47,0x4b,0x41,0x3f,0x54,0x49,0x46,0x55,0x4a,0x47,0x55,0x49,0x47,0x68,0x7c,0x88,0x4a,0x40,0x3e,0x55,0x4b,0x49,0x56,0x4d,0x4b,0x53,0x49,0x47,0x50,0x46,0x44,0x4a,0x41,0x3e,0x48,0x3e,0x3c,0x4b,0x42,0x3f,0x49,0x3f,0x3d,0x46,0x3d,0x3c,0x47,0x3d,0x3b,0x47,0x3e,0x3b,0x49,0x40,0x3d,0x45,0x3c,0x3b,0x46,0x3c,0x3a,0xff,0xff,0xff,0x2e,0x48,0xbd,0x3e,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x28,0xbd,0xb0,0xb5,0xb2,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xb3,0x49,0x44,0x41,0x54,0x18,0xd3,0x2d,0x8f,0xdb,0x16,0x82,0x20,0x10,0x45,0x11,0x19,0x12,0x91,0x54,0x44,0x93,0xb2,0x48,0xa1,0xfc,0xff,0x3f,0xec,0xa0,0xed,0xb7,0xd9,0x73,0xd6,0x5c,0x18,0x3,0x5,0x2f,0x1,0x2f,0xd8,0x49,0xc1,0x5,0x49,0x40,0xe2,0x54,0xc5,0x85,0x2a,0xa9,0x80,0xac,0x48,0x64,0xc3,0x89,0x64,0x7d,0x20,0x89,0x34,0x2,0x82,0x48,0x35,0xe6,0x7a,0x6d,0x1b,0x45,0x39,0xc2,0x3b,0x92,0x4d,0x6f,0x87,0xc1,0xf6,0x30,0x4e,0x33,0xed,0xb2,0x18,0xa7,0xdb,0x64,0x8d,0x24,0x37,0x33,0xed,0x9d,0xac,0xfb,0xf1,0xfe,0x18,0x97,0xa7,0x3a,0xc4,0xcb,0x51,0x16,0xf7,0xc9,0x42,0x78,0x88,0xf0,0x76,0xca,0xb4,0xcb,0x62,0xd,0x2,0x2b,0xc4,0x16,0x7c,0x5e,0x63,0x9e,0x35,0x75,0x6b,0xd4,0x58,0x9b,0x3e,0x98,0x8b,0xbb,0xd0,0x8f,0xa2,0x64,0x88,0xc4,0xb0,0x7a,0xe7,0x3a,0x1f,0x12,0x2,0xf9,0xb2,0x6f,0x8c,0x31,0x84,0x18,0xd3,0x26,0xf8,0xf1,0x8c,0x16,0xfb,0x9e,0xd2,0xbe,0xb,0x5d,0xfe,0xff,0xe5,0x7a,0x6,0x67,0xf9,0x3,0x92,0x36,0xd,0x2d,0xc1,0xf2,0x6d,0x3c,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char popup_bg_disabled_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x7b, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x0, 0xff, 0x67, 0x7a, 0x85, 0x66, 0x7a, 0x86, 0x68, 0x7b, 0x86, 0x57, 0x51, 0x51, 0x4c, 0x42, 0x40, 0x4d, 0x43, 0x41, 0x56, 0x4c, 0x4b, 0x4d, 0x44, 0x41, 0x4e, 0x44, 0x42, 0x4f, 0x45, 0x43, 0x67, 0x7b, 0x87, 0x4f, 0x44, 0x43, 0x50, 0x45, 0x44, 0x52, 0x46, 0x44, 0x51, 0x46, 0x45, 0x4b, 0x40, 0x3f, 0x51, 0x47, 0x45, 0x52, 0x48, 0x46, 0x53, 0x48, 0x47, 0x4b, 0x41, 0x3f, 0x54, 0x49, 0x46, 0x55, 0x4a, 0x47, 0x55, 0x49, 0x47, 0x68, 0x7c, 0x88, 0x4a, 0x40, 0x3e, 0x55, 0x4b, 0x49, 0x56, 0x4d, 0x4b, 0x53, 0x49, 0x47, 0x50, 0x46, 0x44, 0x4a, 0x41, 0x3e, 0x48, 0x3e, 0x3c, 0x4b, 0x42, 0x3f, 0x49, 0x3f, 0x3d, 0x46, 0x3d, 0x3c, 0x47, 0x3d, 0x3b, 0x47, 0x3e, 0x3b, 0x49, 0x40, 0x3d, 0x45, 0x3c, 0x3b, 0x46, 0x3c, 0x3a, 0xff, 0xff, 0xff, 0x2e, 0x48, 0xbd, 0x3e, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x28, 0xbd, 0xb0, 0xb5, 0xb2, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xb3, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x2d, 0x8f, 0xdb, 0x16, 0x82, 0x20, 0x10, 0x45, 0x11, 0x19, 0x12, 0x91, 0x54, 0x44, 0x93, 0xb2, 0x48, 0xa1, 0xfc, 0xff, 0x3f, 0xec, 0xa0, 0xed, 0xb7, 0xd9, 0x73, 0xd6, 0x5c, 0x18, 0x3, 0x5, 0x2f, 0x1, 0x2f, 0xd8, 0x49, 0xc1, 0x5, 0x49, 0x40, 0xe2, 0x54, 0xc5, 0x85, 0x2a, 0xa9, 0x80, 0xac, 0x48, 0x64, 0xc3, 0x89, 0x64, 0x7d, 0x20, 0x89, 0x34, 0x2, 0x82, 0x48, 0x35, 0xe6, 0x7a, 0x6d, 0x1b, 0x45, 0x39, 0xc2, 0x3b, 0x92, 0x4d, 0x6f, 0x87, 0xc1, 0xf6, 0x30, 0x4e, 0x33, 0xed, 0xb2, 0x18, 0xa7, 0xdb, 0x64, 0x8d, 0x24, 0x37, 0x33, 0xed, 0x9d, 0xac, 0xfb, 0xf1, 0xfe, 0x18, 0x97, 0xa7, 0x3a, 0xc4, 0xcb, 0x51, 0x16, 0xf7, 0xc9, 0x42, 0x78, 0x88, 0xf0, 0x76, 0xca, 0xb4, 0xcb, 0x62, 0xd, 0x2, 0x2b, 0xc4, 0x16, 0x7c, 0x5e, 0x63, 0x9e, 0x35, 0x75, 0x6b, 0xd4, 0x58, 0x9b, 0x3e, 0x98, 0x8b, 0xbb, 0xd0, 0x8f, 0xa2, 0x64, 0x88, 0xc4, 0xb0, 0x7a, 0xe7, 0x3a, 0x1f, 0x12, 0x2, 0xf9, 0xb2, 0x6f, 0x8c, 0x31, 0x84, 0x18, 0xd3, 0x26, 0xf8, 0xf1, 0x8c, 0x16, 0xfb, 0x9e, 0xd2, 0xbe, 0xb, 0x5d, 0xfe, 0xff, 0xe5, 0x7a, 0x6, 0x67, 0xf9, 0x3, 0x92, 0x36, 0xd, 0x2d, 0xc1, 0xf2, 0x6d, 0x3c, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char popup_checked_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x8,0x4,0x0,0x0,0x0,0x6e,0x6,0x76,0x0,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x6c,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x40,0x3,0x8c,0x8,0xe6,0xd,0x5e,0xf6,0xbd,0x8c,0x3f,0x99,0x60,0xdc,0xff,0x8c,0x1c,0xb,0x18,0x4d,0x19,0xb8,0xe0,0xf2,0xf,0x6a,0x1e,0xfc,0x7f,0xf0,0xee,0xb1,0xa,0xe3,0x83,0xc3,0xc,0x9c,0x7f,0xbc,0x58,0x4c,0x18,0x36,0x33,0x30,0x30,0xf8,0x2a,0x6c,0x63,0xf9,0xcf,0xce,0x68,0xcc,0x72,0x80,0x41,0x92,0x81,0x89,0xa1,0x46,0x61,0x1b,0x3,0x3,0xc3,0x1d,0xb1,0x7,0x97,0x1f,0xfc,0x7f,0xf0,0xff,0xc1,0xda,0xff,0x8c,0x50,0x5b,0xee,0x88,0xb1,0x6c,0x65,0xf8,0xfd,0xc3,0x5d,0xe3,0x33,0x3,0x3,0x3,0x3,0x0,0x6a,0x54,0x21,0x0,0x96,0x26,0x52,0xa9,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char popup_checked_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x8, 0x4, 0x0, 0x0, 0x0, 0x6e, 0x6, 0x76, 0x0, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x6c, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x40, 0x3, 0x8c, 0x8, 0xe6, 0xd, 0x5e, 0xf6, 0xbd, 0x8c, 0x3f, 0x99, 0x60, 0xdc, 0xff, 0x8c, 0x1c, 0xb, 0x18, 0x4d, 0x19, 0xb8, 0xe0, 0xf2, 0xf, 0x6a, 0x1e, 0xfc, 0x7f, 0xf0, 0xee, 0xb1, 0xa, 0xe3, 0x83, 0xc3, 0xc, 0x9c, 0x7f, 0xbc, 0x58, 0x4c, 0x18, 0x36, 0x33, 0x30, 0x30, 0xf8, 0x2a, 0x6c, 0x63, 0xf9, 0xcf, 0xce, 0x68, 0xcc, 0x72, 0x80, 0x41, 0x92, 0x81, 0x89, 0xa1, 0x46, 0x61, 0x1b, 0x3, 0x3, 0xc3, 0x1d, 0xb1, 0x7, 0x97, 0x1f, 0xfc, 0x7f, 0xf0, 0xff, 0xc1, 0xda, 0xff, 0x8c, 0x50, 0x5b, 0xee, 0x88, 0xb1, 0x6c, 0x65, 0xf8, 0xfd, 0xc3, 0x5d, 0xe3, 0x33, 0x3, 0x3, 0x3, 0x3, 0x0, 0x6a, 0x54, 0x21, 0x0, 0x96, 0x26, 0x52, 0xa9, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char popup_hover_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x30,0x50,0x4c,0x54,0x45,0xff,0x0,0xff,0x20,0x2e,0x31,0x83,0xae,0xb7,0xb3,0xd8,0xe1,0xaf,0xd5,0xde,0xac,0xd2,0xdb,0xa9,0xcf,0xd8,0xa5,0xcc,0xd5,0xa2,0xc9,0xd2,0x9e,0xc6,0xcf,0x9b,0xc3,0xcc,0x97,0xc0,0xc9,0x94,0xbd,0xc6,0x91,0xba,0xc3,0x8d,0xb7,0xc0,0xff,0xff,0xff,0x73,0xd4,0x4e,0xcb,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xf,0x18,0xba,0x0,0xd9,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x4c,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x14,0x4,0x3,0x1,0x6,0x21,0x25,0x30,0x50,0x64,0x10,0x32,0x6,0x3,0x20,0xc3,0x5,0xc,0x80,0x8c,0x50,0x30,0x0,0x32,0xd2,0xc0,0x0,0xc8,0x28,0x7,0x3,0x20,0xa3,0x3,0xc,0x80,0x8c,0x99,0x60,0x0,0x64,0xac,0x2,0x3,0x20,0x63,0x37,0x18,0x0,0x19,0x67,0xc0,0x0,0xc8,0xb8,0xb,0x6,0x40,0xc6,0x3b,0x30,0x50,0x44,0x58,0xa,0x73,0x6,0x0,0xe9,0xb4,0x2d,0xf5,0x51,0xd4,0xb8,0xa1,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char popup_hover_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x30, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x0, 0xff, 0x20, 0x2e, 0x31, 0x83, 0xae, 0xb7, 0xb3, 0xd8, 0xe1, 0xaf, 0xd5, 0xde, 0xac, 0xd2, 0xdb, 0xa9, 0xcf, 0xd8, 0xa5, 0xcc, 0xd5, 0xa2, 0xc9, 0xd2, 0x9e, 0xc6, 0xcf, 0x9b, 0xc3, 0xcc, 0x97, 0xc0, 0xc9, 0x94, 0xbd, 0xc6, 0x91, 0xba, 0xc3, 0x8d, 0xb7, 0xc0, 0xff, 0xff, 0xff, 0x73, 0xd4, 0x4e, 0xcb, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xf, 0x18, 0xba, 0x0, 0xd9, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x14, 0x4, 0x3, 0x1, 0x6, 0x21, 0x25, 0x30, 0x50, 0x64, 0x10, 0x32, 0x6, 0x3, 0x20, 0xc3, 0x5, 0xc, 0x80, 0x8c, 0x50, 0x30, 0x0, 0x32, 0xd2, 0xc0, 0x0, 0xc8, 0x28, 0x7, 0x3, 0x20, 0xa3, 0x3, 0xc, 0x80, 0x8c, 0x99, 0x60, 0x0, 0x64, 0xac, 0x2, 0x3, 0x20, 0x63, 0x37, 0x18, 0x0, 0x19, 0x67, 0xc0, 0x0, 0xc8, 0xb8, 0xb, 0x6, 0x40, 0xc6, 0x3b, 0x30, 0x50, 0x44, 0x58, 0xa, 0x73, 0x6, 0x0, 0xe9, 0xb4, 0x2d, 0xf5, 0x51, 0xd4, 0xb8, 0xa1, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char popup_unchecked_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x1,0x3,0x0,0x0,0x0,0xfe,0xc1,0x2c,0xc8,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0xff,0x0,0xff,0xff,0xff,0xff,0x9f,0x18,0x32,0xe0,0x0,0x0,0x0,0x1,0x74,0x52,0x4e,0x53,0x0,0x40,0xe6,0xd8,0x66,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1,0xff,0x2,0x2d,0xde,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0xb,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x40,0x5,0x0,0x0,0x10,0x0,0x1,0xa1,0xc5,0x21,0xc1,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char popup_unchecked_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x1, 0x3, 0x0, 0x0, 0x0, 0xfe, 0xc1, 0x2c, 0xc8, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x50, 0x4c, 0x54, 0x45, 0xff, 0x0, 0xff, 0xff, 0xff, 0xff, 0x9f, 0x18, 0x32, 0xe0, 0x0, 0x0, 0x0, 0x1, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x40, 0xe6, 0xd8, 0x66, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1, 0xff, 0x2, 0x2d, 0xde, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0xb, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x40, 0x5, 0x0, 0x0, 0x10, 0x0, 0x1, 0xa1, 0xc5, 0x21, 0xc1, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char popup_window_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x2a,0x0,0x0,0x0,0x46,0x8,0x3,0x0,0x0,0x0,0x8d,0x2b,0xf6,0x48,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x6e,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xe8,0xe5,0xf1,0x0,0x0,0x0,0x0,0x0,0x0,0x1f,0x1d,0x22,0x0,0x0,0x0,0x1a,0x19,0x1c,0x0,0x0,0x0,0x0,0x0,0x0,0x20,0x1e,0x23,0x0,0x0,0x0,0x0,0x0,0x0,0x1f,0x1d,0x21,0x17,0x16,0x19,0x0,0x0,0x0,0x0,0x0,0x0,0x21,0x1f,0x24,0x1b,0x1a,0x1d,0x0,0x0,0x0,0x0,0x0,0x0,0x21,0x1f,0x24,0x1e,0x1c,0x20,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x22,0x20,0x25,0x20,0x1e,0x23,0x0,0x0,0x0,0x0,0x0,0x0,0x21,0x1f,0x24,0x0,0x0,0x0,0x21,0x1f,0x24,0x0,0x0,0x0,0x0,0x0,0x0,0x22,0x20,0x25,0x0,0x0,0x0,0x20,0x20,0x25,0x20,0x1d,0x25,0x20,0x1d,0x22,0x1d,0x1d,0x22,0x1d,0x1d,0x20,0x1d,0x1a,0x20,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x32,0x30,0x38,0xe8,0xe5,0xf1,0xe5,0xe2,0xeb,0xe3,0xe1,0xe8,0xe1,0xdf,0xe7,0xe0,0xde,0xe6,0xdf,0xdd,0xe5,0xde,0xdc,0xe4,0xdd,0xdb,0xe3,0xdc,0xda,0xe2,0xda,0xd8,0xe0,0xd9,0xd7,0xdf,0xd7,0xd6,0xdf,0xd6,0xd4,0xdd,0xd5,0xd3,0xdc,0xd4,0xd1,0xdb,0xd3,0xd0,0xda,0xd1,0xce,0xd8,0xd0,0xcd,0xd7,0xcf,0xcd,0xd7,0xe2,0xdf,0xeb,0x48,0x46,0x51,0x42,0x40,0x4b,0x40,0x3e,0x48,0x40,0x3d,0x48,0x48,0x45,0x50,0x42,0x3f,0x4a,0x3f,0x3d,0x48,0x47,0x44,0x50,0x41,0x3f,0x4a,0x3f,0x3d,0x47,0x41,0x3e,0x49,0x3f,0x3c,0x47,0x46,0x43,0x4f,0x3e,0x3c,0x46,0x40,0x3e,0x49,0x3d,0x3b,0x46,0x45,0x43,0x4e,0x3d,0x3b,0x45,0x44,0x42,0x4d,0x3d,0x3a,0x45,0x3e,0x3c,0x47,0x3c,0x3a,0x44,0x43,0x42,0x4c,0x43,0x40,0x4c,0x3e,0x3b,0x46,0x3b,0x39,0x43,0x43,0x3f,0x4c,0x43,0x3f,0x4b,0x3a,0x38,0x42,0x42,0x3e,0x4b,0x42,0x3e,0x49,0x3a,0x37,0x41,0x39,0x37,0x41,0x3f,0x3e,0x48,0x39,0x37,0x40,0x38,0x36,0x40,0x3e,0x3d,0x48,0x38,0x36,0x3f,0x3e,0x3d,0x47,0x3a,0x38,0x41,0x38,0x35,0x3f,0x37,0x35,0x3e,0x39,0x36,0x40,0x37,0x34,0x3e,0x3d,0x3a,0x46,0x36,0x34,0x3d,0x3d,0x3a,0x44,0x37,0x35,0x3f,0x35,0x33,0x3c,0x46,0x44,0x4f,0xff,0xff,0xff,0x7e,0xde,0x1d,0x81,0x0,0x0,0x0,0x33,0x74,0x52,0x4e,0x53,0x0,0xa2,0x3,0x9,0x17,0xc,0x20,0xf,0x2a,0x5e,0x12,0x30,0x68,0x46,0x20,0x4e,0xa2,0x7d,0x3a,0x4f,0xa4,0x7d,0x3f,0x25,0x60,0xc0,0xb8,0x57,0x1d,0xba,0x59,0xbd,0x5b,0x22,0xbf,0x5e,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xa1,0x9f,0x9e,0x52,0x92,0x15,0x44,0x7e,0xd8,0x5,0xc7,0xf4,0xac,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x79,0xa1,0xdc,0xd4,0xd0,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x1,0xe8,0x49,0x44,0x41,0x54,0x48,0xc7,0xd5,0xd6,0xd9,0x53,0xd3,0x60,0x14,0xc6,0xe1,0x92,0x5a,0xa3,0x44,0xa3,0xd6,0x85,0xa0,0xb1,0x5a,0xcb,0xda,0xbd,0x7c,0xb8,0xef,0x2b,0x69,0x21,0xd0,0xda,0x22,0x25,0xd,0x69,0x20,0x60,0x69,0x11,0x2a,0x22,0xcb,0x9f,0xef,0x78,0x97,0x7e,0xe7,0x3d,0x33,0x1d,0xbd,0x70,0xfc,0x5d,0x3f,0x77,0xe7,0xe2,0x3d,0x91,0xc8,0x7f,0xd8,0x88,0x60,0x1a,0x21,0x54,0xcc,0x3f,0x84,0xcd,0xb,0x4a,0x1f,0x31,0xfd,0x1d,0x7d,0xcc,0x4,0xe8,0x13,0x26,0x40,0x9f,0x32,0x1,0xfa,0x8c,0x9,0xd0,0xe7,0x4c,0x80,0xbe,0x60,0x2,0xf4,0x25,0x13,0xa0,0xaf,0x98,0x0,0x7d,0xcd,0x44,0xa8,0x22,0xde,0x30,0x49,0x54,0x89,0x9e,0x13,0x6f,0x99,0x64,0x1a,0x3b,0x2f,0xde,0x31,0x49,0x54,0xbd,0x70,0x51,0xbc,0x67,0x92,0xe8,0xa8,0x76,0x49,0x7c,0x60,0x12,0x97,0xf5,0x68,0x88,0xea,0x57,0xae,0x8a,0x8f,0x4c,0xe2,0x5a,0x7c,0x34,0x4c,0xaf,0xdf,0x10,0x9f,0x98,0xc4,0xcd,0x5b,0x21,0xaa,0x8c,0x19,0xe3,0xb,0x56,0x19,0x66,0x2d,0xdc,0xbe,0x63,0x2a,0x43,0xd2,0xbb,0x9,0x7d,0x58,0x7a,0xef,0x7e,0x72,0x58,0xfa,0x20,0x35,0x36,0x2c,0x1d,0x37,0x8,0xad,0xc0,0x0,0x5d,0x5c,0xb2,0x61,0x4b,0x8b,0x32,0x9d,0x58,0x5e,0xa9,0xc2,0x56,0x96,0x27,0x8,0xad,0x7d,0x86,0xd5,0x28,0xad,0xd7,0x1a,0xb0,0x5a,0x9d,0xd2,0x55,0x4c,0x57,0x1,0xad,0x7c,0x81,0x55,0x8,0x9d,0x5c,0xb3,0x9b,0x30,0x7b,0x6d,0x52,0xa2,0x53,0xeb,0x55,0x7,0x56,0x5d,0x9f,0x22,0xb4,0xe5,0xc2,0x5a,0x94,0x6e,0x34,0x30,0x6d,0x6c,0x10,0xea,0xb5,0x7d,0x58,0xdb,0x93,0xe9,0xf4,0x66,0x13,0xd3,0xe6,0xe6,0xb4,0x4c,0xb7,0x9c,0x0,0xe6,0x6c,0x11,0xba,0xed,0x62,0xea,0x6e,0x13,0xba,0xe3,0x7e,0x85,0xb9,0x3b,0x84,0x96,0xfd,0xe,0xcc,0x2f,0x13,0xba,0xeb,0x77,0x61,0xfe,0x2e,0xa1,0x76,0xd0,0x83,0x5,0x36,0xa1,0x7b,0xc1,0x37,0x58,0xb0,0x27,0xd3,0x99,0xfd,0x83,0x3e,0xec,0x60,0x7f,0x46,0xa2,0xb3,0xad,0xce,0x77,0x58,0xa7,0x35,0x2b,0xd3,0xf6,0x21,0xa6,0x87,0x6d,0x40,0x7f,0xc0,0x0,0x3d,0xea,0xfd,0x84,0xf5,0x8e,0x8,0x75,0xfa,0x98,0xf6,0x1d,0x42,0x8f,0x39,0x7a,0x4c,0xe9,0xc9,0x29,0xec,0x64,0x90,0x46,0x92,0xa9,0xb4,0x75,0xca,0x64,0xa5,0x53,0xc9,0xc8,0x1f,0xd2,0xc,0x4f,0x33,0x3,0x54,0x4f,0x64,0x79,0x9a,0x4d,0xe8,0x21,0x6a,0xe6,0xf2,0x1e,0x47,0xbd,0x7c,0xce,0xc,0xd1,0x42,0xb1,0x54,0xef,0x62,0xd9,0x3d,0x2b,0x15,0xb,0x21,0xaa,0x6a,0xc6,0xdc,0x99,0x67,0x81,0xbc,0xfa,0x9c,0xa1,0xa9,0x21,0x1a,0x35,0xe3,0x46,0x29,0x9f,0xcd,0xa4,0xa5,0x32,0xd9,0x7c,0xc9,0x88,0x9b,0xe1,0xe1,0x54,0x62,0xa6,0x56,0xcc,0x25,0x52,0xa4,0x44,0xae,0xa8,0x99,0xb1,0xd0,0x5,0x7e,0x3f,0x4,0x6a,0xc1,0xd4,0x93,0x24,0xdd,0x2c,0xa8,0xd1,0x1,0xf9,0xf,0xfb,0x5,0x66,0x6f,0x2a,0x9a,0xa8,0x51,0x81,0xce,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char popup_window_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x46, 0x8, 0x3, 0x0, 0x0, 0x0, 0x8d, 0x2b, 0xf6, 0x48, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x6e, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0xe8, 0xe5, 0xf1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x1d, 0x22, 0x0, 0x0, 0x0, 0x1a, 0x19, 0x1c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x1e, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x1d, 0x21, 0x17, 0x16, 0x19, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x1b, 0x1a, 0x1d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x1e, 0x1c, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x22, 0x20, 0x25, 0x20, 0x1e, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x0, 0x0, 0x0, 0x21, 0x1f, 0x24, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x22, 0x20, 0x25, 0x0, 0x0, 0x0, 0x20, 0x20, 0x25, 0x20, 0x1d, 0x25, 0x20, 0x1d, 0x22, 0x1d, 0x1d, 0x22, 0x1d, 0x1d, 0x20, 0x1d, 0x1a, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x32, 0x30, 0x38, 0xe8, 0xe5, 0xf1, 0xe5, 0xe2, 0xeb, 0xe3, 0xe1, 0xe8, 0xe1, 0xdf, 0xe7, 0xe0, 0xde, 0xe6, 0xdf, 0xdd, 0xe5, 0xde, 0xdc, 0xe4, 0xdd, 0xdb, 0xe3, 0xdc, 0xda, 0xe2, 0xda, 0xd8, 0xe0, 0xd9, 0xd7, 0xdf, 0xd7, 0xd6, 0xdf, 0xd6, 0xd4, 0xdd, 0xd5, 0xd3, 0xdc, 0xd4, 0xd1, 0xdb, 0xd3, 0xd0, 0xda, 0xd1, 0xce, 0xd8, 0xd0, 0xcd, 0xd7, 0xcf, 0xcd, 0xd7, 0xe2, 0xdf, 0xeb, 0x48, 0x46, 0x51, 0x42, 0x40, 0x4b, 0x40, 0x3e, 0x48, 0x40, 0x3d, 0x48, 0x48, 0x45, 0x50, 0x42, 0x3f, 0x4a, 0x3f, 0x3d, 0x48, 0x47, 0x44, 0x50, 0x41, 0x3f, 0x4a, 0x3f, 0x3d, 0x47, 0x41, 0x3e, 0x49, 0x3f, 0x3c, 0x47, 0x46, 0x43, 0x4f, 0x3e, 0x3c, 0x46, 0x40, 0x3e, 0x49, 0x3d, 0x3b, 0x46, 0x45, 0x43, 0x4e, 0x3d, 0x3b, 0x45, 0x44, 0x42, 0x4d, 0x3d, 0x3a, 0x45, 0x3e, 0x3c, 0x47, 0x3c, 0x3a, 0x44, 0x43, 0x42, 0x4c, 0x43, 0x40, 0x4c, 0x3e, 0x3b, 0x46, 0x3b, 0x39, 0x43, 0x43, 0x3f, 0x4c, 0x43, 0x3f, 0x4b, 0x3a, 0x38, 0x42, 0x42, 0x3e, 0x4b, 0x42, 0x3e, 0x49, 0x3a, 0x37, 0x41, 0x39, 0x37, 0x41, 0x3f, 0x3e, 0x48, 0x39, 0x37, 0x40, 0x38, 0x36, 0x40, 0x3e, 0x3d, 0x48, 0x38, 0x36, 0x3f, 0x3e, 0x3d, 0x47, 0x3a, 0x38, 0x41, 0x38, 0x35, 0x3f, 0x37, 0x35, 0x3e, 0x39, 0x36, 0x40, 0x37, 0x34, 0x3e, 0x3d, 0x3a, 0x46, 0x36, 0x34, 0x3d, 0x3d, 0x3a, 0x44, 0x37, 0x35, 0x3f, 0x35, 0x33, 0x3c, 0x46, 0x44, 0x4f, 0xff, 0xff, 0xff, 0x7e, 0xde, 0x1d, 0x81, 0x0, 0x0, 0x0, 0x33, 0x74, 0x52, 0x4e, 0x53, 0x0, 0xa2, 0x3, 0x9, 0x17, 0xc, 0x20, 0xf, 0x2a, 0x5e, 0x12, 0x30, 0x68, 0x46, 0x20, 0x4e, 0xa2, 0x7d, 0x3a, 0x4f, 0xa4, 0x7d, 0x3f, 0x25, 0x60, 0xc0, 0xb8, 0x57, 0x1d, 0xba, 0x59, 0xbd, 0x5b, 0x22, 0xbf, 0x5e, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xa1, 0x9f, 0x9e, 0x52, 0x92, 0x15, 0x44, 0x7e, 0xd8, 0x5, 0xc7, 0xf4, 0xac, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x79, 0xa1, 0xdc, 0xd4, 0xd0, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x1, 0xe8, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xd5, 0xd6, 0xd9, 0x53, 0xd3, 0x60, 0x14, 0xc6, 0xe1, 0x92, 0x5a, 0xa3, 0x44, 0xa3, 0xd6, 0x85, 0xa0, 0xb1, 0x5a, 0xcb, 0xda, 0xbd, 0x7c, 0xb8, 0xef, 0x2b, 0x69, 0x21, 0xd0, 0xda, 0x22, 0x25, 0xd, 0x69, 0x20, 0x60, 0x69, 0x11, 0x2a, 0x22, 0xcb, 0x9f, 0xef, 0x78, 0x97, 0x7e, 0xe7, 0x3d, 0x33, 0x1d, 0xbd, 0x70, 0xfc, 0x5d, 0x3f, 0x77, 0xe7, 0xe2, 0x3d, 0x91, 0xc8, 0x7f, 0xd8, 0x88, 0x60, 0x1a, 0x21, 0x54, 0xcc, 0x3f, 0x84, 0xcd, 0xb, 0x4a, 0x1f, 0x31, 0xfd, 0x1d, 0x7d, 0xcc, 0x4, 0xe8, 0x13, 0x26, 0x40, 0x9f, 0x32, 0x1, 0xfa, 0x8c, 0x9, 0xd0, 0xe7, 0x4c, 0x80, 0xbe, 0x60, 0x2, 0xf4, 0x25, 0x13, 0xa0, 0xaf, 0x98, 0x0, 0x7d, 0xcd, 0x44, 0xa8, 0x22, 0xde, 0x30, 0x49, 0x54, 0x89, 0x9e, 0x13, 0x6f, 0x99, 0x64, 0x1a, 0x3b, 0x2f, 0xde, 0x31, 0x49, 0x54, 0xbd, 0x70, 0x51, 0xbc, 0x67, 0x92, 0xe8, 0xa8, 0x76, 0x49, 0x7c, 0x60, 0x12, 0x97, 0xf5, 0x68, 0x88, 0xea, 0x57, 0xae, 0x8a, 0x8f, 0x4c, 0xe2, 0x5a, 0x7c, 0x34, 0x4c, 0xaf, 0xdf, 0x10, 0x9f, 0x98, 0xc4, 0xcd, 0x5b, 0x21, 0xaa, 0x8c, 0x19, 0xe3, 0xb, 0x56, 0x19, 0x66, 0x2d, 0xdc, 0xbe, 0x63, 0x2a, 0x43, 0xd2, 0xbb, 0x9, 0x7d, 0x58, 0x7a, 0xef, 0x7e, 0x72, 0x58, 0xfa, 0x20, 0x35, 0x36, 0x2c, 0x1d, 0x37, 0x8, 0xad, 0xc0, 0x0, 0x5d, 0x5c, 0xb2, 0x61, 0x4b, 0x8b, 0x32, 0x9d, 0x58, 0x5e, 0xa9, 0xc2, 0x56, 0x96, 0x27, 0x8, 0xad, 0x7d, 0x86, 0xd5, 0x28, 0xad, 0xd7, 0x1a, 0xb0, 0x5a, 0x9d, 0xd2, 0x55, 0x4c, 0x57, 0x1, 0xad, 0x7c, 0x81, 0x55, 0x8, 0x9d, 0x5c, 0xb3, 0x9b, 0x30, 0x7b, 0x6d, 0x52, 0xa2, 0x53, 0xeb, 0x55, 0x7, 0x56, 0x5d, 0x9f, 0x22, 0xb4, 0xe5, 0xc2, 0x5a, 0x94, 0x6e, 0x34, 0x30, 0x6d, 0x6c, 0x10, 0xea, 0xb5, 0x7d, 0x58, 0xdb, 0x93, 0xe9, 0xf4, 0x66, 0x13, 0xd3, 0xe6, 0xe6, 0xb4, 0x4c, 0xb7, 0x9c, 0x0, 0xe6, 0x6c, 0x11, 0xba, 0xed, 0x62, 0xea, 0x6e, 0x13, 0xba, 0xe3, 0x7e, 0x85, 0xb9, 0x3b, 0x84, 0x96, 0xfd, 0xe, 0xcc, 0x2f, 0x13, 0xba, 0xeb, 0x77, 0x61, 0xfe, 0x2e, 0xa1, 0x76, 0xd0, 0x83, 0x5, 0x36, 0xa1, 0x7b, 0xc1, 0x37, 0x58, 0xb0, 0x27, 0xd3, 0x99, 0xfd, 0x83, 0x3e, 0xec, 0x60, 0x7f, 0x46, 0xa2, 0xb3, 0xad, 0xce, 0x77, 0x58, 0xa7, 0x35, 0x2b, 0xd3, 0xf6, 0x21, 0xa6, 0x87, 0x6d, 0x40, 0x7f, 0xc0, 0x0, 0x3d, 0xea, 0xfd, 0x84, 0xf5, 0x8e, 0x8, 0x75, 0xfa, 0x98, 0xf6, 0x1d, 0x42, 0x8f, 0x39, 0x7a, 0x4c, 0xe9, 0xc9, 0x29, 0xec, 0x64, 0x90, 0x46, 0x92, 0xa9, 0xb4, 0x75, 0xca, 0x64, 0xa5, 0x53, 0xc9, 0xc8, 0x1f, 0xd2, 0xc, 0x4f, 0x33, 0x3, 0x54, 0x4f, 0x64, 0x79, 0x9a, 0x4d, 0xe8, 0x21, 0x6a, 0xe6, 0xf2, 0x1e, 0x47, 0xbd, 0x7c, 0xce, 0xc, 0xd1, 0x42, 0xb1, 0x54, 0xef, 0x62, 0xd9, 0x3d, 0x2b, 0x15, 0xb, 0x21, 0xaa, 0x6a, 0xc6, 0xdc, 0x99, 0x67, 0x81, 0xbc, 0xfa, 0x9c, 0xa1, 0xa9, 0x21, 0x1a, 0x35, 0xe3, 0x46, 0x29, 0x9f, 0xcd, 0xa4, 0xa5, 0x32, 0xd9, 0x7c, 0xc9, 0x88, 0x9b, 0xe1, 0xe1, 0x54, 0x62, 0xa6, 0x56, 0xcc, 0x25, 0x52, 0xa4, 0x44, 0xae, 0xa8, 0x99, 0xb1, 0xd0, 0x5, 0x7e, 0x3f, 0x4, 0x6a, 0xc1, 0xd4, 0x93, 0x24, 0xdd, 0x2c, 0xa8, 0xd1, 0x1, 0xf9, 0xf, 0xfb, 0x5, 0x66, 0x6f, 0x2a, 0x9a, 0xa8, 0x51, 0x81, 0xce, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char progress_bar_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x33,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2d,0x2c,0x2f,0x48,0x46,0x4a,0x4c,0x4a,0x4e,0x48,0x46,0x4a,0x40,0x3e,0x42,0x38,0x36,0x3a,0x27,0x27,0x27,0xe1,0x1d,0x66,0x4d,0x0,0x0,0x0,0xc,0x74,0x52,0x4e,0x53,0xa,0x1a,0x26,0x29,0x2a,0x48,0x65,0x6d,0x6e,0x66,0xf5,0xfe,0xb7,0x4a,0xbe,0x33,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x10,0x95,0xb2,0xd,0x2c,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x44,0x49,0x44,0x41,0x54,0x18,0xd3,0xc5,0xcf,0x31,0x16,0x0,0x10,0xc,0x44,0xc1,0x4d,0x84,0x4,0xc1,0xfd,0x6f,0xab,0xc9,0x53,0x70,0x0,0x53,0x6e,0xb5,0x1f,0x20,0x4e,0x12,0x12,0x13,0x40,0xb9,0xa8,0x5,0x2d,0x99,0xc0,0xb5,0x75,0xf,0xbd,0x55,0x86,0xe8,0x98,0x2b,0xcc,0xa1,0x2,0x31,0x5f,0x87,0xdb,0xbf,0xe1,0x3e,0xf6,0x5c,0x7f,0xe2,0xee,0xfc,0xd,0x60,0x3b,0xa,0x1d,0x9e,0x6a,0x29,0x33,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char progress_bar_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x33, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2d, 0x2c, 0x2f, 0x48, 0x46, 0x4a, 0x4c, 0x4a, 0x4e, 0x48, 0x46, 0x4a, 0x40, 0x3e, 0x42, 0x38, 0x36, 0x3a, 0x27, 0x27, 0x27, 0xe1, 0x1d, 0x66, 0x4d, 0x0, 0x0, 0x0, 0xc, 0x74, 0x52, 0x4e, 0x53, 0xa, 0x1a, 0x26, 0x29, 0x2a, 0x48, 0x65, 0x6d, 0x6e, 0x66, 0xf5, 0xfe, 0xb7, 0x4a, 0xbe, 0x33, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x10, 0x95, 0xb2, 0xd, 0x2c, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x44, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0xc5, 0xcf, 0x31, 0x16, 0x0, 0x10, 0xc, 0x44, 0xc1, 0x4d, 0x84, 0x4, 0xc1, 0xfd, 0x6f, 0xab, 0xc9, 0x53, 0x70, 0x0, 0x53, 0x6e, 0xb5, 0x1f, 0x20, 0x4e, 0x12, 0x12, 0x13, 0x40, 0xb9, 0xa8, 0x5, 0x2d, 0x99, 0xc0, 0xb5, 0x75, 0xf, 0xbd, 0x55, 0x86, 0xe8, 0x98, 0x2b, 0xcc, 0xa1, 0x2, 0x31, 0x5f, 0x87, 0xdb, 0xbf, 0xe1, 0x3e, 0xf6, 0x5c, 0x7f, 0xe2, 0xee, 0xfc, 0xd, 0x60, 0x3b, 0xa, 0x1d, 0x9e, 0x6a, 0x29, 0x33, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char progress_fill_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0x26,0x78,0x80,0xa6,0xcf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x60,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0x18,0x78,0xc0,0x8,0x63,0x38,0x58,0x7c,0xde,0xf8,0x45,0xc,0xc2,0xe6,0x79,0xc5,0xeb,0x7f,0xe0,0x4,0x9a,0x2,0xe3,0x97,0x1f,0xb9,0xff,0x70,0x43,0xd8,0x2c,0x5f,0xf9,0xbf,0x9e,0x15,0x87,0xb2,0x61,0xa,0xbe,0x88,0xfd,0x81,0x1b,0xfb,0x87,0xfb,0xb,0x37,0x8c,0xcd,0x44,0xc8,0xd,0x54,0x54,0xc0,0xf3,0x8a,0xe5,0x2b,0x8c,0xcd,0xf2,0x95,0xe7,0x15,0x86,0x2,0x5e,0x7f,0xfe,0xaf,0xec,0xc,0x10,0xc8,0xff,0x95,0xd7,0x9f,0xe6,0x1,0x4c,0x2,0x0,0x0,0x68,0x3f,0x16,0xd7,0xea,0x7c,0xdd,0x1a,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char progress_fill_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x26, 0x78, 0x80, 0xa6, 0xcf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x60, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x18, 0x78, 0xc0, 0x8, 0x63, 0x38, 0x58, 0x7c, 0xde, 0xf8, 0x45, 0xc, 0xc2, 0xe6, 0x79, 0xc5, 0xeb, 0x7f, 0xe0, 0x4, 0x9a, 0x2, 0xe3, 0x97, 0x1f, 0xb9, 0xff, 0x70, 0x43, 0xd8, 0x2c, 0x5f, 0xf9, 0xbf, 0x9e, 0x15, 0x87, 0xb2, 0x61, 0xa, 0xbe, 0x88, 0xfd, 0x81, 0x1b, 0xfb, 0x87, 0xfb, 0xb, 0x37, 0x8c, 0xcd, 0x44, 0xc8, 0xd, 0x54, 0x54, 0xc0, 0xf3, 0x8a, 0xe5, 0x2b, 0x8c, 0xcd, 0xf2, 0x95, 0xe7, 0x15, 0x86, 0x2, 0x5e, 0x7f, 0xfe, 0xaf, 0xec, 0xc, 0x10, 0xc8, 0xff, 0x95, 0xd7, 0x9f, 0xe6, 0x1, 0x4c, 0x2, 0x0, 0x0, 0x68, 0x3f, 0x16, 0xd7, 0xea, 0x7c, 0xdd, 0x1a, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char radio_checked_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x45,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x4,0x3,0x4,0x9,0x9,0x9,0x6,0x6,0x6,0xa,0xa,0xb,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x7f,0x7f,0x82,0xd8,0xd8,0xd8,0xd9,0xd9,0xd9,0x47,0x47,0x48,0xd3,0xd3,0xd3,0xa2,0xa2,0xa2,0x79,0x79,0x79,0x73,0x73,0x73,0x1c,0x1c,0x1c,0x3,0x3,0x3,0x0,0x0,0x0,0xff,0xff,0xff,0xa,0x69,0x4,0xd4,0x0,0x0,0x0,0xb,0x74,0x52,0x4e,0x53,0x0,0x0,0x0,0x0,0x0,0x1b,0x88,0xd1,0xf7,0x64,0xf6,0x2,0xb3,0xed,0xd7,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x16,0x7c,0xd1,0xa8,0x19,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x69,0x49,0x44,0x41,0x54,0x18,0xd3,0x6d,0x8f,0xdb,0xe,0xc0,0x20,0x8,0x43,0xdd,0xc5,0x3b,0x9d,0xa8,0xec,0xff,0x7f,0x75,0x6a,0x96,0x2c,0x8b,0xf6,0xad,0x27,0x14,0x8a,0x52,0x2b,0x69,0x63,0x9d,0xb3,0x46,0xbf,0x76,0xf3,0x21,0x12,0x40,0x31,0xf8,0x7d,0x0,0x7f,0x35,0xdb,0x45,0x97,0x1f,0xf3,0x81,0x90,0x38,0x67,0x4e,0xa0,0xd0,0x53,0x26,0x22,0x95,0x2a,0x52,0x4b,0x42,0x34,0xd,0x58,0x2,0xd7,0xbb,0xa9,0x32,0xc8,0x36,0xe0,0x80,0x2c,0x1d,0x48,0x6,0xdc,0xa,0x4c,0x91,0x69,0xe9,0x74,0x76,0x2a,0xa6,0x8e,0xaf,0xfa,0xb9,0x7e,0xee,0xaf,0x7,0xb9,0xfb,0x8,0xe7,0x90,0x1c,0x65,0x49,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char radio_checked_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x45, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x4, 0x3, 0x4, 0x9, 0x9, 0x9, 0x6, 0x6, 0x6, 0xa, 0xa, 0xb, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x7f, 0x7f, 0x82, 0xd8, 0xd8, 0xd8, 0xd9, 0xd9, 0xd9, 0x47, 0x47, 0x48, 0xd3, 0xd3, 0xd3, 0xa2, 0xa2, 0xa2, 0x79, 0x79, 0x79, 0x73, 0x73, 0x73, 0x1c, 0x1c, 0x1c, 0x3, 0x3, 0x3, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xa, 0x69, 0x4, 0xd4, 0x0, 0x0, 0x0, 0xb, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1b, 0x88, 0xd1, 0xf7, 0x64, 0xf6, 0x2, 0xb3, 0xed, 0xd7, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x16, 0x7c, 0xd1, 0xa8, 0x19, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x69, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x6d, 0x8f, 0xdb, 0xe, 0xc0, 0x20, 0x8, 0x43, 0xdd, 0xc5, 0x3b, 0x9d, 0xa8, 0xec, 0xff, 0x7f, 0x75, 0x6a, 0x96, 0x2c, 0x8b, 0xf6, 0xad, 0x27, 0x14, 0x8a, 0x52, 0x2b, 0x69, 0x63, 0x9d, 0xb3, 0x46, 0xbf, 0x76, 0xf3, 0x21, 0x12, 0x40, 0x31, 0xf8, 0x7d, 0x0, 0x7f, 0x35, 0xdb, 0x45, 0x97, 0x1f, 0xf3, 0x81, 0x90, 0x38, 0x67, 0x4e, 0xa0, 0xd0, 0x53, 0x26, 0x22, 0x95, 0x2a, 0x52, 0x4b, 0x42, 0x34, 0xd, 0x58, 0x2, 0xd7, 0xbb, 0xa9, 0x32, 0xc8, 0x36, 0xe0, 0x80, 0x2c, 0x1d, 0x48, 0x6, 0xdc, 0xa, 0x4c, 0x91, 0x69, 0xe9, 0x74, 0x76, 0x2a, 0xa6, 0x8e, 0xaf, 0xfa, 0xb9, 0x7e, 0xee, 0xaf, 0x7, 0xb9, 0xfb, 0x8, 0xe7, 0x90, 0x1c, 0x65, 0x49, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char radio_unchecked_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2d,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x4,0x3,0x4,0x9,0x9,0x9,0x6,0x6,0x6,0xa,0xa,0xb,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x7f,0x7f,0x82,0xd9,0xd9,0xd9,0x47,0x47,0x48,0xff,0xff,0xff,0xbd,0x7d,0x89,0x66,0x0,0x0,0x0,0xb,0x74,0x52,0x4e,0x53,0x0,0x0,0x0,0x0,0x0,0x1b,0x88,0xd1,0xf7,0x64,0xf6,0x2,0xb3,0xed,0xd7,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xe,0x6f,0xbd,0x30,0x4f,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x4a,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x40,0x80,0xb0,0x8a,0xf6,0x54,0x10,0x2d,0xb9,0xfa,0xcc,0x99,0x5d,0x93,0x80,0x8c,0xb9,0x67,0x80,0xe0,0x26,0x3,0x3,0xeb,0x1a,0x10,0xe3,0x54,0x0,0x3,0xdb,0x1e,0x10,0xe3,0x74,0x2,0x3,0xfb,0x19,0x30,0x28,0x60,0xe0,0x80,0x30,0x1a,0x10,0xc,0xb8,0x14,0x5c,0x31,0x5c,0x3b,0xdc,0x40,0x6,0x4b,0x90,0x15,0x53,0x90,0x2d,0x85,0x2,0x0,0x37,0xca,0x3d,0x81,0xc4,0xfc,0x38,0x7b,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char radio_unchecked_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2d, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x4, 0x3, 0x4, 0x9, 0x9, 0x9, 0x6, 0x6, 0x6, 0xa, 0xa, 0xb, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x7f, 0x7f, 0x82, 0xd9, 0xd9, 0xd9, 0x47, 0x47, 0x48, 0xff, 0xff, 0xff, 0xbd, 0x7d, 0x89, 0x66, 0x0, 0x0, 0x0, 0xb, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1b, 0x88, 0xd1, 0xf7, 0x64, 0xf6, 0x2, 0xb3, 0xed, 0xd7, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xe, 0x6f, 0xbd, 0x30, 0x4f, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x4a, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x40, 0x80, 0xb0, 0x8a, 0xf6, 0x54, 0x10, 0x2d, 0xb9, 0xfa, 0xcc, 0x99, 0x5d, 0x93, 0x80, 0x8c, 0xb9, 0x67, 0x80, 0xe0, 0x26, 0x3, 0x3, 0xeb, 0x1a, 0x10, 0xe3, 0x54, 0x0, 0x3, 0xdb, 0x1e, 0x10, 0xe3, 0x74, 0x2, 0x3, 0xfb, 0x19, 0x30, 0x28, 0x60, 0xe0, 0x80, 0x30, 0x1a, 0x10, 0xc, 0xb8, 0x14, 0x5c, 0x31, 0x5c, 0x3b, 0xdc, 0x40, 0x6, 0x4b, 0x90, 0x15, 0x53, 0x90, 0x2d, 0x85, 0x2, 0x0, 0x37, 0xca, 0x3d, 0x81, 0xc4, 0xfc, 0x38, 0x7b, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char reference_border_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xf,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0xff,0xd1,0xd1,0xff,0xb7,0xb7,0xff,0x41,0x41,0xff,0xff,0xff,0xd5,0xfa,0x24,0x40,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x4,0x8f,0x68,0xd9,0x51,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x27,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x50,0x32,0x6,0x3,0x25,0x6,0x5,0x6,0x30,0x60,0x62,0x30,0x10,0x4,0x3,0x66,0x6,0x3,0x1,0x90,0x0,0x23,0x2d,0x18,0x30,0x2b,0xe0,0x96,0xc2,0x9c,0x1,0x0,0x5,0x29,0x7,0xb,0xf6,0x43,0xc2,0xd4,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char reference_border_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xf, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0xff, 0xd1, 0xd1, 0xff, 0xb7, 0xb7, 0xff, 0x41, 0x41, 0xff, 0xff, 0xff, 0xd5, 0xfa, 0x24, 0x40, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x76, 0x93, 0xcd, 0x38, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x4, 0x8f, 0x68, 0xd9, 0x51, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x27, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x50, 0x32, 0x6, 0x3, 0x25, 0x6, 0x5, 0x6, 0x30, 0x60, 0x62, 0x30, 0x10, 0x4, 0x3, 0x66, 0x6, 0x3, 0x1, 0x90, 0x0, 0x23, 0x2d, 0x18, 0x30, 0x2b, 0xe0, 0x96, 0xc2, 0x9c, 0x1, 0x0, 0x5, 0x29, 0x7, 0xb, 0xf6, 0x43, 0xc2, 0xd4, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x8,0x3,0x0,0x0,0x0,0x61,0xab,0xac,0xd5,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x48,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x40,0x3e,0x4a,0x2a,0x29,0x2f,0x20,0x20,0x24,0x3f,0x3e,0x49,0x1f,0x1f,0x24,0x20,0x20,0x24,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x3f,0x3e,0x49,0x3f,0x3e,0x49,0x1e,0x1e,0x23,0x20,0x20,0x25,0x22,0x22,0x27,0x23,0x23,0x27,0x23,0x23,0x28,0x25,0x25,0x2a,0xff,0xff,0xff,0x34,0x3f,0xa6,0x65,0x0,0x0,0x0,0x11,0x74,0x52,0x4e,0x53,0x0,0x4,0x19,0x40,0x5d,0x66,0x28,0x93,0xf0,0xfc,0x94,0xfc,0xfd,0x67,0x1a,0x96,0x95,0x1c,0xf0,0x43,0x52,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x17,0xb,0xd6,0x98,0x8f,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x5c,0x49,0x44,0x41,0x54,0x8,0xd7,0x55,0x8e,0x49,0xe,0xc0,0x20,0xc,0x3,0x3,0x61,0x9,0x3b,0x61,0xfb,0xff,0x53,0x4b,0x5b,0x55,0x15,0x73,0x1b,0xc9,0xb2,0xd,0x20,0x24,0x2a,0xad,0x15,0x4a,0x1,0x20,0x8c,0x25,0xc7,0xec,0xc8,0x1a,0x1,0xd2,0x87,0xd6,0xc7,0xe8,0x2d,0x78,0x9,0x48,0x6d,0xae,0xcd,0x6c,0x84,0xa0,0x62,0x5f,0xf,0x3d,0x2a,0x48,0x3c,0x5e,0x19,0x9c,0x4e,0x39,0x62,0x47,0x41,0x2e,0x5f,0x75,0xc9,0x7b,0xb4,0x52,0x64,0x8e,0x54,0xcd,0x7d,0xe1,0xbf,0x73,0x1,0x30,0x2f,0x7,0x53,0x16,0x34,0xbd,0xfa,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x3, 0x0, 0x0, 0x0, 0x61, 0xab, 0xac, 0xd5, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x48, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x40, 0x3e, 0x4a, 0x2a, 0x29, 0x2f, 0x20, 0x20, 0x24, 0x3f, 0x3e, 0x49, 0x1f, 0x1f, 0x24, 0x20, 0x20, 0x24, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x3f, 0x3e, 0x49, 0x3f, 0x3e, 0x49, 0x1e, 0x1e, 0x23, 0x20, 0x20, 0x25, 0x22, 0x22, 0x27, 0x23, 0x23, 0x27, 0x23, 0x23, 0x28, 0x25, 0x25, 0x2a, 0xff, 0xff, 0xff, 0x34, 0x3f, 0xa6, 0x65, 0x0, 0x0, 0x0, 0x11, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x4, 0x19, 0x40, 0x5d, 0x66, 0x28, 0x93, 0xf0, 0xfc, 0x94, 0xfc, 0xfd, 0x67, 0x1a, 0x96, 0x95, 0x1c, 0xf0, 0x43, 0x52, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x17, 0xb, 0xd6, 0x98, 0x8f, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x5c, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x55, 0x8e, 0x49, 0xe, 0xc0, 0x20, 0xc, 0x3, 0x3, 0x61, 0x9, 0x3b, 0x61, 0xfb, 0xff, 0x53, 0x4b, 0x5b, 0x55, 0x15, 0x73, 0x1b, 0xc9, 0xb2, 0xd, 0x20, 0x24, 0x2a, 0xad, 0x15, 0x4a, 0x1, 0x20, 0x8c, 0x25, 0xc7, 0xec, 0xc8, 0x1a, 0x1, 0xd2, 0x87, 0xd6, 0xc7, 0xe8, 0x2d, 0x78, 0x9, 0x48, 0x6d, 0xae, 0xcd, 0x6c, 0x84, 0xa0, 0x62, 0x5f, 0xf, 0x3d, 0x2a, 0x48, 0x3c, 0x5e, 0x19, 0x9c, 0x4e, 0x39, 0x62, 0x47, 0x41, 0x2e, 0x5f, 0x75, 0xc9, 0x7b, 0xb4, 0x52, 0x64, 0x8e, 0x54, 0xcd, 0x7d, 0xe1, 0xbf, 0x73, 0x1, 0x30, 0x2f, 0x7, 0x53, 0x16, 0x34, 0xbd, 0xfa, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_button_down_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x21,0x50,0x4c,0x54,0x45,0x2d,0x2c,0x2f,0x48,0x46,0x4a,0x2d,0x2c,0x2f,0x2d,0x2c,0x2f,0x2d,0x2c,0x2f,0x4c,0x4a,0x4e,0x48,0x46,0x4a,0x40,0x3e,0x42,0x38,0x36,0x3a,0xc3,0xc3,0xc3,0x59,0x59,0x59,0xb3,0x52,0xf2,0x5,0x0,0x0,0x0,0x5,0x74,0x52,0x4e,0x53,0x8,0xfe,0x9,0xd,0x19,0x4a,0xb6,0xc1,0xe6,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xa,0x68,0xd0,0xf4,0x56,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x33,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc,0x5,0x3,0x21,0x86,0xf4,0xe,0x30,0x28,0x63,0x88,0x80,0x30,0x5a,0xf1,0x33,0x66,0x2,0x1,0x2a,0xa3,0x73,0xe6,0xcc,0x19,0x10,0x35,0x40,0x1,0x8,0xa3,0x73,0x6,0x1,0x73,0xe0,0x96,0x1a,0x42,0x9c,0x21,0x2,0x0,0x5a,0xfa,0x3d,0xf9,0xfa,0xe2,0x64,0xe2,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_button_down_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x21, 0x50, 0x4c, 0x54, 0x45, 0x2d, 0x2c, 0x2f, 0x48, 0x46, 0x4a, 0x2d, 0x2c, 0x2f, 0x2d, 0x2c, 0x2f, 0x2d, 0x2c, 0x2f, 0x4c, 0x4a, 0x4e, 0x48, 0x46, 0x4a, 0x40, 0x3e, 0x42, 0x38, 0x36, 0x3a, 0xc3, 0xc3, 0xc3, 0x59, 0x59, 0x59, 0xb3, 0x52, 0xf2, 0x5, 0x0, 0x0, 0x0, 0x5, 0x74, 0x52, 0x4e, 0x53, 0x8, 0xfe, 0x9, 0xd, 0x19, 0x4a, 0xb6, 0xc1, 0xe6, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xa, 0x68, 0xd0, 0xf4, 0x56, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x33, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc, 0x5, 0x3, 0x21, 0x86, 0xf4, 0xe, 0x30, 0x28, 0x63, 0x88, 0x80, 0x30, 0x5a, 0xf1, 0x33, 0x66, 0x2, 0x1, 0x2a, 0xa3, 0x73, 0xe6, 0xcc, 0x19, 0x10, 0x35, 0x40, 0x1, 0x8, 0xa3, 0x73, 0x6, 0x1, 0x73, 0xe0, 0x96, 0x1a, 0x42, 0x9c, 0x21, 0x2, 0x0, 0x5a, 0xfa, 0x3d, 0xf9, 0xfa, 0xe2, 0x64, 0xe2, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_button_down_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x21,0x50,0x4c,0x54,0x45,0x3d,0x3b,0x3f,0x60,0x5d,0x62,0x3d,0x3b,0x3f,0x3d,0x3b,0x3f,0x3d,0x3b,0x3f,0x65,0x62,0x67,0x60,0x5d,0x62,0x56,0x53,0x58,0x4b,0x49,0x4e,0xce,0xce,0xce,0x59,0x59,0x59,0xb8,0xf5,0x6d,0x48,0x0,0x0,0x0,0x5,0x74,0x52,0x4e,0x53,0x7,0xfe,0xc,0x9,0x1c,0xda,0x2b,0xa5,0x57,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xa,0x68,0xd0,0xf4,0x56,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x33,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc,0x5,0x3,0x21,0x86,0xf4,0xe,0x30,0x28,0x63,0x88,0x80,0x30,0x5a,0xf1,0x33,0x66,0x2,0x1,0x2a,0xa3,0x73,0xe6,0xcc,0x19,0x10,0x35,0x40,0x1,0x8,0xa3,0x73,0x6,0x1,0x73,0xe0,0x96,0x1a,0x42,0x9c,0x21,0x2,0x0,0x5a,0xfa,0x3d,0xf9,0xfa,0xe2,0x64,0xe2,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_button_down_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x21, 0x50, 0x4c, 0x54, 0x45, 0x3d, 0x3b, 0x3f, 0x60, 0x5d, 0x62, 0x3d, 0x3b, 0x3f, 0x3d, 0x3b, 0x3f, 0x3d, 0x3b, 0x3f, 0x65, 0x62, 0x67, 0x60, 0x5d, 0x62, 0x56, 0x53, 0x58, 0x4b, 0x49, 0x4e, 0xce, 0xce, 0xce, 0x59, 0x59, 0x59, 0xb8, 0xf5, 0x6d, 0x48, 0x0, 0x0, 0x0, 0x5, 0x74, 0x52, 0x4e, 0x53, 0x7, 0xfe, 0xc, 0x9, 0x1c, 0xda, 0x2b, 0xa5, 0x57, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xa, 0x68, 0xd0, 0xf4, 0x56, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x33, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc, 0x5, 0x3, 0x21, 0x86, 0xf4, 0xe, 0x30, 0x28, 0x63, 0x88, 0x80, 0x30, 0x5a, 0xf1, 0x33, 0x66, 0x2, 0x1, 0x2a, 0xa3, 0x73, 0xe6, 0xcc, 0x19, 0x10, 0x35, 0x40, 0x1, 0x8, 0xa3, 0x73, 0x6, 0x1, 0x73, 0xe0, 0x96, 0x1a, 0x42, 0x9c, 0x21, 0x2, 0x0, 0x5a, 0xfa, 0x3d, 0xf9, 0xfa, 0xe2, 0x64, 0xe2, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_button_left_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x30,0x50,0x4c,0x54,0x45,0x2d,0x2c,0x2f,0x48,0x46,0x4a,0x2d,0x2c,0x2f,0x2d,0x2c,0x2f,0x2d,0x2c,0x2f,0x4c,0x4a,0x4e,0x48,0x46,0x4a,0x40,0x3e,0x42,0x38,0x36,0x3a,0xc3,0xc3,0xc3,0xc2,0xc2,0xc2,0xc1,0xc1,0xc1,0xc0,0xc0,0xc0,0xbf,0xbf,0xbf,0xbe,0xbe,0xbe,0x59,0x59,0x59,0x8e,0x47,0x76,0xf1,0x0,0x0,0x0,0x5,0x74,0x52,0x4e,0x53,0x8,0xfe,0x9,0xd,0x19,0x4a,0xb6,0xc1,0xe6,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xf,0x18,0xba,0x0,0xd9,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x3e,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc,0x5,0x3,0x21,0x86,0xf4,0xe,0x30,0x28,0x63,0x88,0x80,0x30,0x5a,0x51,0x19,0x33,0xa1,0x8c,0xae,0x55,0x50,0xc6,0x2e,0x28,0xa3,0x7b,0xf7,0x6e,0x8,0xa3,0xe7,0xcc,0x19,0xa8,0x14,0x9c,0xd1,0x7b,0x17,0xa6,0xfd,0x1d,0x86,0x81,0x60,0x6,0xdc,0x52,0x43,0x88,0x33,0x44,0x0,0xcc,0x4e,0x3f,0xd1,0x4,0x90,0xbf,0x60,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_button_left_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x30, 0x50, 0x4c, 0x54, 0x45, 0x2d, 0x2c, 0x2f, 0x48, 0x46, 0x4a, 0x2d, 0x2c, 0x2f, 0x2d, 0x2c, 0x2f, 0x2d, 0x2c, 0x2f, 0x4c, 0x4a, 0x4e, 0x48, 0x46, 0x4a, 0x40, 0x3e, 0x42, 0x38, 0x36, 0x3a, 0xc3, 0xc3, 0xc3, 0xc2, 0xc2, 0xc2, 0xc1, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0, 0xbf, 0xbf, 0xbf, 0xbe, 0xbe, 0xbe, 0x59, 0x59, 0x59, 0x8e, 0x47, 0x76, 0xf1, 0x0, 0x0, 0x0, 0x5, 0x74, 0x52, 0x4e, 0x53, 0x8, 0xfe, 0x9, 0xd, 0x19, 0x4a, 0xb6, 0xc1, 0xe6, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xf, 0x18, 0xba, 0x0, 0xd9, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x3e, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc, 0x5, 0x3, 0x21, 0x86, 0xf4, 0xe, 0x30, 0x28, 0x63, 0x88, 0x80, 0x30, 0x5a, 0x51, 0x19, 0x33, 0xa1, 0x8c, 0xae, 0x55, 0x50, 0xc6, 0x2e, 0x28, 0xa3, 0x7b, 0xf7, 0x6e, 0x8, 0xa3, 0xe7, 0xcc, 0x19, 0xa8, 0x14, 0x9c, 0xd1, 0x7b, 0x17, 0xa6, 0xfd, 0x1d, 0x86, 0x81, 0x60, 0x6, 0xdc, 0x52, 0x43, 0x88, 0x33, 0x44, 0x0, 0xcc, 0x4e, 0x3f, 0xd1, 0x4, 0x90, 0xbf, 0x60, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_button_left_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x33,0x50,0x4c,0x54,0x45,0x3d,0x3b,0x3f,0x60,0x5d,0x62,0x3d,0x3b,0x3f,0x3d,0x3b,0x3f,0x3d,0x3b,0x3f,0x65,0x62,0x67,0x60,0x5d,0x62,0x56,0x53,0x58,0x4b,0x49,0x4e,0xc9,0xc9,0xc9,0xc8,0xc8,0xc8,0xc6,0xc6,0xc6,0xc7,0xc7,0xc7,0xc5,0xc5,0xc5,0xc4,0xc4,0xc4,0xc3,0xc3,0xc3,0x59,0x59,0x59,0x2a,0x13,0xff,0x12,0x0,0x0,0x0,0x5,0x74,0x52,0x4e,0x53,0x7,0xfe,0xc,0x9,0x1c,0xda,0x2b,0xa5,0x57,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x10,0x95,0xb2,0xd,0x2c,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x4c,0x49,0x44,0x41,0x54,0x18,0xd3,0x85,0xcf,0xcb,0xe,0x80,0x20,0xc,0x44,0xd1,0xa2,0x96,0x47,0x7,0xe4,0xff,0xff,0x16,0xdc,0x90,0xe,0xc6,0x78,0x97,0x27,0x69,0xd3,0x8a,0x4,0x75,0x85,0x43,0x62,0xca,0xae,0x14,0x45,0x33,0xa5,0xdf,0x50,0xa,0x83,0x99,0x11,0xa0,0xa2,0x7a,0x0,0xd0,0xe0,0xa1,0x3d,0xd1,0xc8,0x3d,0xe3,0xa5,0xbd,0x6f,0x30,0xe5,0xef,0xb0,0x5,0xaf,0xe7,0x4e,0x7e,0xff,0x1a,0xb,0x26,0x7,0xac,0xd9,0xa3,0x51,0xe3,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_button_left_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x33, 0x50, 0x4c, 0x54, 0x45, 0x3d, 0x3b, 0x3f, 0x60, 0x5d, 0x62, 0x3d, 0x3b, 0x3f, 0x3d, 0x3b, 0x3f, 0x3d, 0x3b, 0x3f, 0x65, 0x62, 0x67, 0x60, 0x5d, 0x62, 0x56, 0x53, 0x58, 0x4b, 0x49, 0x4e, 0xc9, 0xc9, 0xc9, 0xc8, 0xc8, 0xc8, 0xc6, 0xc6, 0xc6, 0xc7, 0xc7, 0xc7, 0xc5, 0xc5, 0xc5, 0xc4, 0xc4, 0xc4, 0xc3, 0xc3, 0xc3, 0x59, 0x59, 0x59, 0x2a, 0x13, 0xff, 0x12, 0x0, 0x0, 0x0, 0x5, 0x74, 0x52, 0x4e, 0x53, 0x7, 0xfe, 0xc, 0x9, 0x1c, 0xda, 0x2b, 0xa5, 0x57, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x10, 0x95, 0xb2, 0xd, 0x2c, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x85, 0xcf, 0xcb, 0xe, 0x80, 0x20, 0xc, 0x44, 0xd1, 0xa2, 0x96, 0x47, 0x7, 0xe4, 0xff, 0xff, 0x16, 0xdc, 0x90, 0xe, 0xc6, 0x78, 0x97, 0x27, 0x69, 0xd3, 0x8a, 0x4, 0x75, 0x85, 0x43, 0x62, 0xca, 0xae, 0x14, 0x45, 0x33, 0xa5, 0xdf, 0x50, 0xa, 0x83, 0x99, 0x11, 0xa0, 0xa2, 0x7a, 0x0, 0xd0, 0xe0, 0xa1, 0x3d, 0xd1, 0xc8, 0x3d, 0xe3, 0xa5, 0xbd, 0x6f, 0x30, 0xe5, 0xef, 0xb0, 0x5, 0xaf, 0xe7, 0x4e, 0x7e, 0xff, 0x1a, 0xb, 0x26, 0x7, 0xac, 0xd9, 0xa3, 0x51, 0xe3, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_button_right_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x30,0x50,0x4c,0x54,0x45,0x2d,0x2c,0x2f,0x48,0x46,0x4a,0x2d,0x2c,0x2f,0x2d,0x2c,0x2f,0x2d,0x2c,0x2f,0x4c,0x4a,0x4e,0x48,0x46,0x4a,0x40,0x3e,0x42,0x38,0x36,0x3a,0xc3,0xc3,0xc3,0xc2,0xc2,0xc2,0xc1,0xc1,0xc1,0xc0,0xc0,0xc0,0xbf,0xbf,0xbf,0xbe,0xbe,0xbe,0x59,0x59,0x59,0x8e,0x47,0x76,0xf1,0x0,0x0,0x0,0x5,0x74,0x52,0x4e,0x53,0x8,0xfe,0x9,0xd,0x19,0x4a,0xb6,0xc1,0xe6,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xf,0x18,0xba,0x0,0xd9,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x40,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc,0x5,0x3,0x21,0x86,0xf4,0xe,0x30,0x28,0x63,0x88,0x80,0x30,0x5a,0x51,0x18,0x33,0x61,0x8c,0x59,0x2b,0xa0,0x8c,0x5d,0xab,0xa0,0x8c,0xdd,0xbb,0x77,0x40,0x18,0x67,0xce,0x9c,0x80,0x31,0xa0,0x52,0x77,0x6f,0x40,0x19,0xef,0x30,0xc,0x84,0x30,0xe0,0x96,0x1a,0x42,0x9c,0x21,0x2,0x0,0xfd,0x36,0x40,0x93,0xf1,0x83,0x5f,0xf2,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_button_right_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x30, 0x50, 0x4c, 0x54, 0x45, 0x2d, 0x2c, 0x2f, 0x48, 0x46, 0x4a, 0x2d, 0x2c, 0x2f, 0x2d, 0x2c, 0x2f, 0x2d, 0x2c, 0x2f, 0x4c, 0x4a, 0x4e, 0x48, 0x46, 0x4a, 0x40, 0x3e, 0x42, 0x38, 0x36, 0x3a, 0xc3, 0xc3, 0xc3, 0xc2, 0xc2, 0xc2, 0xc1, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0, 0xbf, 0xbf, 0xbf, 0xbe, 0xbe, 0xbe, 0x59, 0x59, 0x59, 0x8e, 0x47, 0x76, 0xf1, 0x0, 0x0, 0x0, 0x5, 0x74, 0x52, 0x4e, 0x53, 0x8, 0xfe, 0x9, 0xd, 0x19, 0x4a, 0xb6, 0xc1, 0xe6, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xf, 0x18, 0xba, 0x0, 0xd9, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x40, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc, 0x5, 0x3, 0x21, 0x86, 0xf4, 0xe, 0x30, 0x28, 0x63, 0x88, 0x80, 0x30, 0x5a, 0x51, 0x18, 0x33, 0x61, 0x8c, 0x59, 0x2b, 0xa0, 0x8c, 0x5d, 0xab, 0xa0, 0x8c, 0xdd, 0xbb, 0x77, 0x40, 0x18, 0x67, 0xce, 0x9c, 0x80, 0x31, 0xa0, 0x52, 0x77, 0x6f, 0x40, 0x19, 0xef, 0x30, 0xc, 0x84, 0x30, 0xe0, 0x96, 0x1a, 0x42, 0x9c, 0x21, 0x2, 0x0, 0xfd, 0x36, 0x40, 0x93, 0xf1, 0x83, 0x5f, 0xf2, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_button_right_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x36,0x50,0x4c,0x54,0x45,0x3d,0x3b,0x3f,0x60,0x5d,0x62,0x3d,0x3b,0x3f,0x3d,0x3b,0x3f,0x3d,0x3b,0x3f,0x65,0x62,0x67,0x60,0x5d,0x62,0x56,0x53,0x58,0x4b,0x49,0x4e,0xc9,0xc9,0xc9,0xc8,0xc8,0xc8,0xc6,0xc6,0xc6,0xc7,0xc7,0xc7,0xc5,0xc5,0xc5,0xc4,0xc4,0xc4,0xc3,0xc3,0xc3,0xc2,0xc2,0xc2,0x59,0x59,0x59,0x56,0xec,0x9e,0xdc,0x0,0x0,0x0,0x5,0x74,0x52,0x4e,0x53,0x7,0xfe,0xc,0x9,0x1c,0xda,0x2b,0xa5,0x57,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x11,0xe2,0xb5,0x3d,0xba,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x4c,0x49,0x44,0x41,0x54,0x18,0xd3,0x85,0xcf,0xcb,0xe,0x80,0x30,0x8,0x44,0x51,0xaa,0xd2,0x7,0xb4,0xd2,0xff,0xff,0xda,0xea,0x6e,0x46,0x63,0xbc,0xcb,0x93,0x40,0x40,0x24,0x29,0x94,0x36,0xc9,0xa5,0x42,0x25,0x8b,0x56,0x4a,0xbf,0xa0,0xb5,0x7,0x98,0x19,0x83,0x77,0xef,0xc,0x3e,0xdc,0x11,0xc6,0x1d,0xc2,0x79,0x45,0x23,0x11,0xc1,0x4b,0xe7,0xfc,0x3b,0xc,0xe0,0xf5,0xdc,0xce,0xef,0x1f,0xb,0xc,0x30,0x7,0xaf,0x1f,0x5b,0x76,0x12,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_button_right_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x36, 0x50, 0x4c, 0x54, 0x45, 0x3d, 0x3b, 0x3f, 0x60, 0x5d, 0x62, 0x3d, 0x3b, 0x3f, 0x3d, 0x3b, 0x3f, 0x3d, 0x3b, 0x3f, 0x65, 0x62, 0x67, 0x60, 0x5d, 0x62, 0x56, 0x53, 0x58, 0x4b, 0x49, 0x4e, 0xc9, 0xc9, 0xc9, 0xc8, 0xc8, 0xc8, 0xc6, 0xc6, 0xc6, 0xc7, 0xc7, 0xc7, 0xc5, 0xc5, 0xc5, 0xc4, 0xc4, 0xc4, 0xc3, 0xc3, 0xc3, 0xc2, 0xc2, 0xc2, 0x59, 0x59, 0x59, 0x56, 0xec, 0x9e, 0xdc, 0x0, 0x0, 0x0, 0x5, 0x74, 0x52, 0x4e, 0x53, 0x7, 0xfe, 0xc, 0x9, 0x1c, 0xda, 0x2b, 0xa5, 0x57, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x11, 0xe2, 0xb5, 0x3d, 0xba, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x85, 0xcf, 0xcb, 0xe, 0x80, 0x30, 0x8, 0x44, 0x51, 0xaa, 0xd2, 0x7, 0xb4, 0xd2, 0xff, 0xff, 0xda, 0xea, 0x6e, 0x46, 0x63, 0xbc, 0xcb, 0x93, 0x40, 0x40, 0x24, 0x29, 0x94, 0x36, 0xc9, 0xa5, 0x42, 0x25, 0x8b, 0x56, 0x4a, 0xbf, 0xa0, 0xb5, 0x7, 0x98, 0x19, 0x83, 0x77, 0xef, 0xc, 0x3e, 0xdc, 0x11, 0xc6, 0x1d, 0xc2, 0x79, 0x45, 0x23, 0x11, 0xc1, 0x4b, 0xe7, 0xfc, 0x3b, 0xc, 0xe0, 0xf5, 0xdc, 0xce, 0xef, 0x1f, 0xb, 0xc, 0x30, 0x7, 0xaf, 0x1f, 0x5b, 0x76, 0x12, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_button_up_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x21,0x50,0x4c,0x54,0x45,0x2d,0x2c,0x2f,0x48,0x46,0x4a,0x2d,0x2c,0x2f,0x2d,0x2c,0x2f,0x2d,0x2c,0x2f,0x4c,0x4a,0x4e,0x48,0x46,0x4a,0x40,0x3e,0x42,0x38,0x36,0x3a,0xc3,0xc3,0xc3,0x59,0x59,0x59,0xb3,0x52,0xf2,0x5,0x0,0x0,0x0,0x5,0x74,0x52,0x4e,0x53,0x8,0xfe,0x9,0xd,0x19,0x4a,0xb6,0xc1,0xe6,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xa,0x68,0xd0,0xf4,0x56,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x36,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc,0x5,0x3,0x21,0x86,0xf4,0xe,0x30,0x28,0x63,0x88,0x80,0x30,0x5a,0xb1,0x33,0x3a,0x67,0x40,0x19,0x33,0x67,0x42,0x18,0x9d,0x33,0x67,0xce,0x0,0x33,0x66,0x2,0x1,0x2a,0x3,0x9f,0x39,0x10,0x6,0xdc,0x52,0x43,0x88,0x33,0x44,0x0,0x59,0xc8,0x3d,0xf9,0xf,0x68,0xc5,0xa9,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_button_up_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x21, 0x50, 0x4c, 0x54, 0x45, 0x2d, 0x2c, 0x2f, 0x48, 0x46, 0x4a, 0x2d, 0x2c, 0x2f, 0x2d, 0x2c, 0x2f, 0x2d, 0x2c, 0x2f, 0x4c, 0x4a, 0x4e, 0x48, 0x46, 0x4a, 0x40, 0x3e, 0x42, 0x38, 0x36, 0x3a, 0xc3, 0xc3, 0xc3, 0x59, 0x59, 0x59, 0xb3, 0x52, 0xf2, 0x5, 0x0, 0x0, 0x0, 0x5, 0x74, 0x52, 0x4e, 0x53, 0x8, 0xfe, 0x9, 0xd, 0x19, 0x4a, 0xb6, 0xc1, 0xe6, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xa, 0x68, 0xd0, 0xf4, 0x56, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x36, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc, 0x5, 0x3, 0x21, 0x86, 0xf4, 0xe, 0x30, 0x28, 0x63, 0x88, 0x80, 0x30, 0x5a, 0xb1, 0x33, 0x3a, 0x67, 0x40, 0x19, 0x33, 0x67, 0x42, 0x18, 0x9d, 0x33, 0x67, 0xce, 0x0, 0x33, 0x66, 0x2, 0x1, 0x2a, 0x3, 0x9f, 0x39, 0x10, 0x6, 0xdc, 0x52, 0x43, 0x88, 0x33, 0x44, 0x0, 0x59, 0xc8, 0x3d, 0xf9, 0xf, 0x68, 0xc5, 0xa9, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_button_up_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x21,0x50,0x4c,0x54,0x45,0x3d,0x3b,0x3f,0x60,0x5d,0x62,0x3d,0x3b,0x3f,0x3d,0x3b,0x3f,0x3d,0x3b,0x3f,0x65,0x62,0x67,0x60,0x5d,0x62,0x56,0x53,0x58,0x4b,0x49,0x4e,0xce,0xce,0xce,0x59,0x59,0x59,0xb8,0xf5,0x6d,0x48,0x0,0x0,0x0,0x5,0x74,0x52,0x4e,0x53,0x7,0xfe,0xc,0x9,0x1c,0xda,0x2b,0xa5,0x57,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xa,0x68,0xd0,0xf4,0x56,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x36,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc,0x5,0x3,0x21,0x86,0xf4,0xe,0x30,0x28,0x63,0x88,0x80,0x30,0x5a,0xb1,0x33,0x3a,0x67,0x40,0x19,0x33,0x67,0x42,0x18,0x9d,0x33,0x67,0xce,0x0,0x33,0x66,0x2,0x1,0x2a,0x3,0x9f,0x39,0x10,0x6,0xdc,0x52,0x43,0x88,0x33,0x44,0x0,0x59,0xc8,0x3d,0xf9,0xf,0x68,0xc5,0xa9,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_button_up_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x21, 0x50, 0x4c, 0x54, 0x45, 0x3d, 0x3b, 0x3f, 0x60, 0x5d, 0x62, 0x3d, 0x3b, 0x3f, 0x3d, 0x3b, 0x3f, 0x3d, 0x3b, 0x3f, 0x65, 0x62, 0x67, 0x60, 0x5d, 0x62, 0x56, 0x53, 0x58, 0x4b, 0x49, 0x4e, 0xce, 0xce, 0xce, 0x59, 0x59, 0x59, 0xb8, 0xf5, 0x6d, 0x48, 0x0, 0x0, 0x0, 0x5, 0x74, 0x52, 0x4e, 0x53, 0x7, 0xfe, 0xc, 0x9, 0x1c, 0xda, 0x2b, 0xa5, 0x57, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xa, 0x68, 0xd0, 0xf4, 0x56, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x36, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc, 0x5, 0x3, 0x21, 0x86, 0xf4, 0xe, 0x30, 0x28, 0x63, 0x88, 0x80, 0x30, 0x5a, 0xb1, 0x33, 0x3a, 0x67, 0x40, 0x19, 0x33, 0x67, 0x42, 0x18, 0x9d, 0x33, 0x67, 0xce, 0x0, 0x33, 0x66, 0x2, 0x1, 0x2a, 0x3, 0x9f, 0x39, 0x10, 0x6, 0xdc, 0x52, 0x43, 0x88, 0x33, 0x44, 0x0, 0x59, 0xc8, 0x3d, 0xf9, 0xf, 0x68, 0xc5, 0xa9, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_grabber_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x8,0x3,0x0,0x0,0x0,0x61,0xab,0xac,0xd5,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x60,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x5b,0x59,0x61,0x5b,0x59,0x61,0x5a,0x58,0x60,0x59,0x57,0x5f,0x5a,0x58,0x60,0x5a,0x58,0x60,0x57,0x56,0x5e,0x58,0x56,0x5e,0x56,0x55,0x5d,0x57,0x55,0x5d,0x57,0x55,0x5d,0x55,0x53,0x5b,0x55,0x53,0x5b,0x54,0x53,0x5b,0x55,0x54,0x5c,0x54,0x52,0x5a,0x55,0x53,0x5b,0x5a,0x58,0x60,0x56,0x54,0x5c,0x54,0x53,0x5a,0x55,0x53,0x5b,0x53,0x51,0x59,0x52,0x51,0x59,0x52,0x50,0x58,0x51,0x50,0x58,0x51,0x4f,0x57,0x50,0x4e,0x56,0x4f,0x4d,0x55,0x50,0x4f,0x57,0x54,0x52,0x5a,0xff,0xff,0xff,0xc7,0x51,0xc2,0xf2,0x0,0x0,0x0,0x12,0x74,0x52,0x4e,0x53,0x0,0x2c,0xb8,0xf4,0x2e,0xf2,0xb8,0xf4,0xf5,0xf4,0xf5,0xb8,0x2f,0xf2,0x2e,0xb8,0xf4,0xb8,0x66,0xf6,0xf7,0x12,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1f,0x5,0xd,0x10,0xbd,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x50,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc0,0x7,0x18,0x99,0x98,0x85,0x98,0x18,0x21,0x6c,0x16,0x56,0x61,0x11,0x11,0x61,0x56,0x16,0x30,0x87,0x4d,0x54,0xc,0x8,0x44,0xd9,0xc0,0x1c,0x76,0x71,0x9,0x20,0x10,0xe7,0x0,0x73,0x38,0x25,0xa5,0x80,0x40,0x92,0xb,0xcc,0xe1,0x96,0x90,0x6,0x2,0x9,0x6e,0x30,0x87,0x87,0x57,0x4a,0x46,0x46,0x96,0x97,0x7,0x62,0x1c,0x1f,0xbf,0x80,0x9c,0x20,0x1f,0x5e,0xdb,0x1,0x23,0xfd,0x4,0x11,0x2d,0x48,0xcb,0xd2,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_grabber_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x3, 0x0, 0x0, 0x0, 0x61, 0xab, 0xac, 0xd5, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x60, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x5b, 0x59, 0x61, 0x5b, 0x59, 0x61, 0x5a, 0x58, 0x60, 0x59, 0x57, 0x5f, 0x5a, 0x58, 0x60, 0x5a, 0x58, 0x60, 0x57, 0x56, 0x5e, 0x58, 0x56, 0x5e, 0x56, 0x55, 0x5d, 0x57, 0x55, 0x5d, 0x57, 0x55, 0x5d, 0x55, 0x53, 0x5b, 0x55, 0x53, 0x5b, 0x54, 0x53, 0x5b, 0x55, 0x54, 0x5c, 0x54, 0x52, 0x5a, 0x55, 0x53, 0x5b, 0x5a, 0x58, 0x60, 0x56, 0x54, 0x5c, 0x54, 0x53, 0x5a, 0x55, 0x53, 0x5b, 0x53, 0x51, 0x59, 0x52, 0x51, 0x59, 0x52, 0x50, 0x58, 0x51, 0x50, 0x58, 0x51, 0x4f, 0x57, 0x50, 0x4e, 0x56, 0x4f, 0x4d, 0x55, 0x50, 0x4f, 0x57, 0x54, 0x52, 0x5a, 0xff, 0xff, 0xff, 0xc7, 0x51, 0xc2, 0xf2, 0x0, 0x0, 0x0, 0x12, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x2c, 0xb8, 0xf4, 0x2e, 0xf2, 0xb8, 0xf4, 0xf5, 0xf4, 0xf5, 0xb8, 0x2f, 0xf2, 0x2e, 0xb8, 0xf4, 0xb8, 0x66, 0xf6, 0xf7, 0x12, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1f, 0x5, 0xd, 0x10, 0xbd, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x50, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc0, 0x7, 0x18, 0x99, 0x98, 0x85, 0x98, 0x18, 0x21, 0x6c, 0x16, 0x56, 0x61, 0x11, 0x11, 0x61, 0x56, 0x16, 0x30, 0x87, 0x4d, 0x54, 0xc, 0x8, 0x44, 0xd9, 0xc0, 0x1c, 0x76, 0x71, 0x9, 0x20, 0x10, 0xe7, 0x0, 0x73, 0x38, 0x25, 0xa5, 0x80, 0x40, 0x92, 0xb, 0xcc, 0xe1, 0x96, 0x90, 0x6, 0x2, 0x9, 0x6e, 0x30, 0x87, 0x87, 0x57, 0x4a, 0x46, 0x46, 0x96, 0x97, 0x7, 0x62, 0x1c, 0x1f, 0xbf, 0x80, 0x9c, 0x20, 0x1f, 0x5e, 0xdb, 0x1, 0x23, 0xfd, 0x4, 0x11, 0x2d, 0x48, 0xcb, 0xd2, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char scroll_grabber_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0xc,0x8,0x3,0x0,0x0,0x0,0x61,0xab,0xac,0xd5,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6c,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x97,0xd0,0xdf,0x92,0xcb,0xdc,0x84,0xbb,0xd4,0x92,0xca,0xdc,0x95,0xd0,0xdd,0x83,0xbb,0xd3,0x8b,0xc8,0xd7,0x79,0xb5,0xcb,0x78,0xb4,0xca,0x73,0xb0,0xc7,0x73,0xb0,0xc7,0x7b,0xc0,0xcf,0x79,0xc5,0xd1,0x6b,0xae,0xc1,0x75,0xc6,0xcf,0x70,0xbc,0xca,0x64,0xa6,0xbc,0x71,0xbc,0xc9,0x82,0xba,0xd4,0x6a,0xa2,0xc6,0x62,0x9a,0xc2,0x61,0x9a,0xc1,0x68,0x9f,0xc2,0x5d,0x92,0xbb,0x5c,0x92,0xb8,0x58,0x8d,0xb6,0x59,0x8e,0xb3,0x56,0x89,0xb0,0x5c,0x91,0xb2,0x53,0x84,0xa9,0x58,0x8f,0xae,0x54,0x83,0xa4,0x57,0x8e,0xad,0x64,0xa5,0xba,0xff,0xff,0xff,0xbb,0x65,0x65,0x27,0x0,0x0,0x0,0x13,0x74,0x52,0x4e,0x53,0x0,0x25,0xad,0xf1,0xad,0x27,0xef,0xad,0xf1,0xf3,0xf1,0xf3,0xad,0x28,0xef,0x27,0xad,0xf2,0xad,0xcd,0x8a,0x27,0xfe,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x23,0x2a,0x62,0x6c,0x3a,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x50,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc0,0x7,0x18,0x99,0x98,0x85,0x59,0x18,0x21,0x6c,0x56,0x36,0x11,0x51,0x31,0x11,0x36,0x56,0x30,0x87,0x5d,0x5c,0x2,0x8,0xc4,0xd9,0xc1,0x1c,0xe,0x49,0x29,0x20,0x90,0xe4,0x4,0x73,0xb8,0xa4,0x65,0x80,0x40,0x9a,0x1b,0xcc,0xe1,0x91,0x95,0x3,0x2,0x59,0x1e,0x30,0x87,0x97,0x4f,0x5e,0x41,0x41,0x91,0x8f,0x17,0x62,0x1c,0xbf,0x80,0xa0,0x92,0x10,0x3f,0x5e,0xdb,0x1,0x41,0x87,0x4,0x7d,0x15,0xc4,0xfd,0x6a,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char scroll_grabber_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0xc, 0x8, 0x3, 0x0, 0x0, 0x0, 0x61, 0xab, 0xac, 0xd5, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6c, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x97, 0xd0, 0xdf, 0x92, 0xcb, 0xdc, 0x84, 0xbb, 0xd4, 0x92, 0xca, 0xdc, 0x95, 0xd0, 0xdd, 0x83, 0xbb, 0xd3, 0x8b, 0xc8, 0xd7, 0x79, 0xb5, 0xcb, 0x78, 0xb4, 0xca, 0x73, 0xb0, 0xc7, 0x73, 0xb0, 0xc7, 0x7b, 0xc0, 0xcf, 0x79, 0xc5, 0xd1, 0x6b, 0xae, 0xc1, 0x75, 0xc6, 0xcf, 0x70, 0xbc, 0xca, 0x64, 0xa6, 0xbc, 0x71, 0xbc, 0xc9, 0x82, 0xba, 0xd4, 0x6a, 0xa2, 0xc6, 0x62, 0x9a, 0xc2, 0x61, 0x9a, 0xc1, 0x68, 0x9f, 0xc2, 0x5d, 0x92, 0xbb, 0x5c, 0x92, 0xb8, 0x58, 0x8d, 0xb6, 0x59, 0x8e, 0xb3, 0x56, 0x89, 0xb0, 0x5c, 0x91, 0xb2, 0x53, 0x84, 0xa9, 0x58, 0x8f, 0xae, 0x54, 0x83, 0xa4, 0x57, 0x8e, 0xad, 0x64, 0xa5, 0xba, 0xff, 0xff, 0xff, 0xbb, 0x65, 0x65, 0x27, 0x0, 0x0, 0x0, 0x13, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x25, 0xad, 0xf1, 0xad, 0x27, 0xef, 0xad, 0xf1, 0xf3, 0xf1, 0xf3, 0xad, 0x28, 0xef, 0x27, 0xad, 0xf2, 0xad, 0xcd, 0x8a, 0x27, 0xfe, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x23, 0x2a, 0x62, 0x6c, 0x3a, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x50, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc0, 0x7, 0x18, 0x99, 0x98, 0x85, 0x59, 0x18, 0x21, 0x6c, 0x56, 0x36, 0x11, 0x51, 0x31, 0x11, 0x36, 0x56, 0x30, 0x87, 0x5d, 0x5c, 0x2, 0x8, 0xc4, 0xd9, 0xc1, 0x1c, 0xe, 0x49, 0x29, 0x20, 0x90, 0xe4, 0x4, 0x73, 0xb8, 0xa4, 0x65, 0x80, 0x40, 0x9a, 0x1b, 0xcc, 0xe1, 0x91, 0x95, 0x3, 0x2, 0x59, 0x1e, 0x30, 0x87, 0x97, 0x4f, 0x5e, 0x41, 0x41, 0x91, 0x8f, 0x17, 0x62, 0x1c, 0xbf, 0x80, 0xa0, 0x92, 0x10, 0x3f, 0x5e, 0xdb, 0x1, 0x41, 0x87, 0x4, 0x7d, 0x15, 0xc4, 0xfd, 0x6a, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char selection_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2d,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfd,0xfb,0xff,0xfd,0xf7,0xff,0xfd,0xf7,0xff,0xfd,0xf7,0xff,0xfd,0xf6,0xff,0xf6,0xf4,0xff,0x15,0x15,0x17,0xff,0x70,0xc0,0x21,0x0,0x0,0x0,0xe,0x74,0x52,0x4e,0x53,0x6,0xf,0x16,0x18,0x2a,0x3b,0x40,0x3c,0x6,0x3d,0x44,0x3e,0x31,0x25,0x8,0x3d,0x16,0xb4,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xe,0x6f,0xbd,0x30,0x4f,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x37,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x54,0x36,0x6,0x2,0x23,0x1,0x6,0x91,0xb0,0x34,0x20,0x48,0x75,0x64,0x50,0xef,0x5c,0x5,0x4,0x33,0x8a,0x18,0xcc,0xf6,0xdc,0x5,0x82,0xd3,0xc9,0xc,0x66,0x6b,0x41,0x8c,0x5b,0x94,0x33,0x60,0x6,0xc2,0xad,0x80,0x5b,0xa,0x73,0x6,0x0,0x45,0x34,0x48,0x41,0xa3,0xc5,0x91,0x23,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char selection_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2d, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfd, 0xfb, 0xff, 0xfd, 0xf7, 0xff, 0xfd, 0xf7, 0xff, 0xfd, 0xf7, 0xff, 0xfd, 0xf6, 0xff, 0xf6, 0xf4, 0xff, 0x15, 0x15, 0x17, 0xff, 0x70, 0xc0, 0x21, 0x0, 0x0, 0x0, 0xe, 0x74, 0x52, 0x4e, 0x53, 0x6, 0xf, 0x16, 0x18, 0x2a, 0x3b, 0x40, 0x3c, 0x6, 0x3d, 0x44, 0x3e, 0x31, 0x25, 0x8, 0x3d, 0x16, 0xb4, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xe, 0x6f, 0xbd, 0x30, 0x4f, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x37, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x54, 0x36, 0x6, 0x2, 0x23, 0x1, 0x6, 0x91, 0xb0, 0x34, 0x20, 0x48, 0x75, 0x64, 0x50, 0xef, 0x5c, 0x5, 0x4, 0x33, 0x8a, 0x18, 0xcc, 0xf6, 0xdc, 0x5, 0x82, 0xd3, 0xc9, 0xc, 0x66, 0x6b, 0x41, 0x8c, 0x5b, 0x94, 0x33, 0x60, 0x6, 0xc2, 0xad, 0x80, 0x5b, 0xa, 0x73, 0x6, 0x0, 0x45, 0x34, 0x48, 0x41, 0xa3, 0xc5, 0x91, 0x23, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char selection_oof_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x4,0x3,0x0,0x0,0x0,0xed,0xdd,0xe2,0x52,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x30,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2c,0x2,0xfd,0xfb,0xff,0xfd,0xfb,0xff,0xfd,0xfb,0xff,0xfd,0xfb,0xff,0x15,0x15,0x17,0xe9,0x54,0x1,0x21,0x0,0x0,0x0,0xf,0x74,0x52,0x4e,0x53,0xa,0x1a,0x26,0x29,0x2a,0x48,0x65,0x6d,0x6e,0x66,0x3,0x20,0x25,0x16,0xc,0x1f,0x74,0xbf,0x74,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xf,0x18,0xba,0x0,0xd9,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x38,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x54,0x76,0x1,0x2,0x23,0x1,0x6,0xd1,0xf4,0xe,0x20,0x28,0xb,0x64,0xd0,0x5c,0x7d,0x6,0x8,0x76,0x4d,0x62,0x70,0xdf,0xfb,0xe,0x8,0x6e,0x97,0x30,0x78,0x9c,0x3,0x31,0xde,0xb4,0x50,0xca,0x80,0x1b,0x8,0xb7,0x2,0x6e,0x29,0xcc,0x19,0x0,0x1a,0x23,0x52,0x59,0xa4,0x2f,0x3d,0xa7,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char selection_oof_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x4, 0x3, 0x0, 0x0, 0x0, 0xed, 0xdd, 0xe2, 0x52, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x30, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2c, 0x2, 0xfd, 0xfb, 0xff, 0xfd, 0xfb, 0xff, 0xfd, 0xfb, 0xff, 0xfd, 0xfb, 0xff, 0x15, 0x15, 0x17, 0xe9, 0x54, 0x1, 0x21, 0x0, 0x0, 0x0, 0xf, 0x74, 0x52, 0x4e, 0x53, 0xa, 0x1a, 0x26, 0x29, 0x2a, 0x48, 0x65, 0x6d, 0x6e, 0x66, 0x3, 0x20, 0x25, 0x16, 0xc, 0x1f, 0x74, 0xbf, 0x74, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xf, 0x18, 0xba, 0x0, 0xd9, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x38, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x54, 0x76, 0x1, 0x2, 0x23, 0x1, 0x6, 0xd1, 0xf4, 0xe, 0x20, 0x28, 0xb, 0x64, 0xd0, 0x5c, 0x7d, 0x6, 0x8, 0x76, 0x4d, 0x62, 0x70, 0xdf, 0xfb, 0xe, 0x8, 0x6e, 0x97, 0x30, 0x78, 0x9c, 0x3, 0x31, 0xde, 0xb4, 0x50, 0xca, 0x80, 0x1b, 0x8, 0xb7, 0x2, 0x6e, 0x29, 0xcc, 0x19, 0x0, 0x1a, 0x23, 0x52, 0x59, 0xa4, 0x2f, 0x3d, 0xa7, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char spinbox_updown_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x76,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0x20,0xd,0xdc,0x4f,0x7f,0x98,0x86,0x47,0xfa,0x81,0xe5,0x83,0x1f,0xf,0x7e,0x3d,0xb2,0x45,0x16,0x63,0x44,0xd2,0x2d,0xc1,0x78,0x86,0x41,0x9a,0x81,0x81,0xe1,0x5,0xb3,0x89,0xec,0x53,0x98,0x28,0x13,0x8c,0x71,0x86,0x95,0x61,0x15,0x83,0x34,0x3,0x3,0x3,0x3,0x83,0xc4,0xdf,0x35,0xb7,0xd9,0x31,0x14,0x8,0x4f,0x61,0x44,0x18,0x6d,0xc1,0x36,0x93,0x44,0xc7,0xd3,0x7,0xdc,0x9f,0xf9,0xe0,0x3f,0x2,0x3e,0x9c,0x81,0xe1,0x8b,0xb7,0x39,0xff,0xf,0xc3,0x55,0x1f,0xff,0x95,0x4f,0x74,0x40,0xa1,0x5a,0x63,0x81,0x19,0xd4,0x68,0xe0,0x61,0x1a,0xde,0xc8,0xc2,0x6,0x0,0x74,0x4d,0x32,0x61,0xa3,0xda,0x8e,0xb3,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char spinbox_updown_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x76, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x20, 0xd, 0xdc, 0x4f, 0x7f, 0x98, 0x86, 0x47, 0xfa, 0x81, 0xe5, 0x83, 0x1f, 0xf, 0x7e, 0x3d, 0xb2, 0x45, 0x16, 0x63, 0x44, 0xd2, 0x2d, 0xc1, 0x78, 0x86, 0x41, 0x9a, 0x81, 0x81, 0xe1, 0x5, 0xb3, 0x89, 0xec, 0x53, 0x98, 0x28, 0x13, 0x8c, 0x71, 0x86, 0x95, 0x61, 0x15, 0x83, 0x34, 0x3, 0x3, 0x3, 0x3, 0x83, 0xc4, 0xdf, 0x35, 0xb7, 0xd9, 0x31, 0x14, 0x8, 0x4f, 0x61, 0x44, 0x18, 0x6d, 0xc1, 0x36, 0x93, 0x44, 0xc7, 0xd3, 0x7, 0xdc, 0x9f, 0xf9, 0xe0, 0x3f, 0x2, 0x3e, 0x9c, 0x81, 0xe1, 0x8b, 0xb7, 0x39, 0xff, 0xf, 0xc3, 0x55, 0x1f, 0xff, 0x95, 0x4f, 0x74, 0x40, 0xa1, 0x5a, 0x63, 0x81, 0x19, 0xd4, 0x68, 0xe0, 0x61, 0x1a, 0xde, 0xc8, 0xc2, 0x6, 0x0, 0x74, 0x4d, 0x32, 0x61, 0xa3, 0xda, 0x8e, 0xb3, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char submenu_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x8,0x4,0x0,0x0,0x0,0x6e,0x6,0x76,0x0,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x4d,0x49,0x44,0x41,0x54,0x8,0xd7,0x55,0xc8,0xa1,0x19,0x40,0x40,0x18,0x0,0xd0,0x77,0x8a,0x60,0x1,0x4d,0xb7,0x80,0x4d,0x64,0x3,0x18,0xc7,0x14,0xf6,0xa1,0xba,0x68,0x81,0xb,0xd2,0x2f,0xf9,0xbe,0xf3,0xe2,0x43,0x8e,0x1c,0x39,0xae,0x5,0x48,0xe4,0x0,0x25,0x4d,0xc3,0x41,0xe3,0xd3,0xc5,0x7e,0x77,0x75,0x30,0x3e,0xdb,0x3f,0xf0,0x8f,0xb3,0x5d,0xeb,0x28,0x69,0xee,0x4b,0x15,0xb1,0xe,0x7,0xbc,0x18,0xe0,0x15,0x49,0xfb,0x84,0x18,0x58,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char submenu_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x8, 0x4, 0x0, 0x0, 0x0, 0x6e, 0x6, 0x76, 0x0, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x4d, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x55, 0xc8, 0xa1, 0x19, 0x40, 0x40, 0x18, 0x0, 0xd0, 0x77, 0x8a, 0x60, 0x1, 0x4d, 0xb7, 0x80, 0x4d, 0x64, 0x3, 0x18, 0xc7, 0x14, 0xf6, 0xa1, 0xba, 0x68, 0x81, 0xb, 0xd2, 0x2f, 0xf9, 0xbe, 0xf3, 0xe2, 0x43, 0x8e, 0x1c, 0x39, 0xae, 0x5, 0x48, 0xe4, 0x0, 0x25, 0x4d, 0xc3, 0x41, 0xe3, 0xd3, 0xc5, 0x7e, 0x77, 0x75, 0x30, 0x3e, 0xdb, 0x3f, 0xf0, 0x8f, 0xb3, 0x5d, 0xeb, 0x28, 0x69, 0xee, 0x4b, 0x15, 0xb1, 0xe, 0x7, 0xbc, 0x18, 0xe0, 0x15, 0x49, 0xfb, 0x84, 0x18, 0x58, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tab_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x8,0x4,0x0,0x0,0x0,0x6e,0x6,0x76,0x0,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0x0,0xaa,0x8d,0x23,0x32,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x1f,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0xc0,0x4,0xff,0x23,0xff,0x8b,0xfc,0x17,0xf9,0x1f,0x49,0xac,0x10,0x13,0x3,0x3,0x61,0x53,0xb0,0x98,0x80,0xc,0x0,0xa8,0x3e,0x18,0x31,0xbe,0x78,0xfc,0x7a,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tab_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x8, 0x4, 0x0, 0x0, 0x0, 0x6e, 0x6, 0x76, 0x0, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0x0, 0xaa, 0x8d, 0x23, 0x32, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x1f, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0xc0, 0x4, 0xff, 0x23, 0xff, 0x8b, 0xfc, 0x17, 0xf9, 0x1f, 0x49, 0xac, 0x10, 0x13, 0x3, 0x3, 0x61, 0x53, 0xb0, 0x98, 0x80, 0xc, 0x0, 0xa8, 0x3e, 0x18, 0x31, 0xbe, 0x78, 0xfc, 0x7a, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tab_behind_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x5a,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x30,0x2e,0x36,0x43,0x40,0x4d,0x0,0x0,0x0,0x43,0x40,0x4c,0x3e,0x3c,0x47,0x3e,0x3b,0x46,0x31,0x2f,0x38,0x2d,0x2b,0x33,0x3f,0x3c,0x47,0x35,0x32,0x3b,0x5b,0xb0,0x1,0xb7,0x0,0x0,0x0,0x18,0x74,0x52,0x4e,0x53,0x0,0x1,0x3,0x5,0x8,0xa,0xb,0xc,0x4,0x11,0x19,0x1f,0x22,0x24,0x15,0x25,0x34,0x3f,0x46,0x47,0x77,0xf3,0x7,0xef,0xd3,0x51,0x5e,0xca,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1d,0xeb,0x3,0x71,0x91,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x6e,0x49,0x44,0x41,0x54,0x18,0xd3,0xb5,0xcc,0x49,0xe,0x80,0x20,0x10,0x44,0xd1,0x2,0x6c,0x90,0x49,0x26,0x27,0xd4,0xfb,0x9f,0x53,0x63,0x34,0x2e,0x58,0xfb,0x97,0x2f,0xa9,0x2,0x18,0x17,0x1d,0x49,0xa5,0x24,0x75,0x82,0x33,0x80,0xf5,0xa4,0x8d,0x75,0xde,0x3b,0x6b,0x34,0xf5,0xc,0x9c,0x86,0x10,0x53,0x2e,0x25,0xa7,0x18,0x6,0xe2,0x10,0x3a,0x8c,0xd3,0x5a,0xaf,0xd6,0x69,0xc,0x5a,0x60,0x36,0x71,0xd9,0xf6,0xbb,0x6d,0x89,0x66,0x6,0xd9,0x74,0xec,0x4f,0x47,0xb2,0x4,0xe9,0x72,0x7d,0xa1,0x66,0x27,0xa1,0x7c,0xf9,0xa0,0x78,0xd5,0x42,0x33,0x69,0x4e,0xff,0x80,0x13,0xce,0x8,0x12,0xa9,0x90,0xd8,0x47,0x93,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tab_behind_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x5a, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x2e, 0x36, 0x43, 0x40, 0x4d, 0x0, 0x0, 0x0, 0x43, 0x40, 0x4c, 0x3e, 0x3c, 0x47, 0x3e, 0x3b, 0x46, 0x31, 0x2f, 0x38, 0x2d, 0x2b, 0x33, 0x3f, 0x3c, 0x47, 0x35, 0x32, 0x3b, 0x5b, 0xb0, 0x1, 0xb7, 0x0, 0x0, 0x0, 0x18, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x1, 0x3, 0x5, 0x8, 0xa, 0xb, 0xc, 0x4, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x77, 0xf3, 0x7, 0xef, 0xd3, 0x51, 0x5e, 0xca, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1d, 0xeb, 0x3, 0x71, 0x91, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x6e, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0xb5, 0xcc, 0x49, 0xe, 0x80, 0x20, 0x10, 0x44, 0xd1, 0x2, 0x6c, 0x90, 0x49, 0x26, 0x27, 0xd4, 0xfb, 0x9f, 0x53, 0x63, 0x34, 0x2e, 0x58, 0xfb, 0x97, 0x2f, 0xa9, 0x2, 0x18, 0x17, 0x1d, 0x49, 0xa5, 0x24, 0x75, 0x82, 0x33, 0x80, 0xf5, 0xa4, 0x8d, 0x75, 0xde, 0x3b, 0x6b, 0x34, 0xf5, 0xc, 0x9c, 0x86, 0x10, 0x53, 0x2e, 0x25, 0xa7, 0x18, 0x6, 0xe2, 0x10, 0x3a, 0x8c, 0xd3, 0x5a, 0xaf, 0xd6, 0x69, 0xc, 0x5a, 0x60, 0x36, 0x71, 0xd9, 0xf6, 0xbb, 0x6d, 0x89, 0x66, 0x6, 0xd9, 0x74, 0xec, 0x4f, 0x47, 0xb2, 0x4, 0xe9, 0x72, 0x7d, 0xa1, 0x66, 0x27, 0xa1, 0x7c, 0xf9, 0xa0, 0x78, 0xd5, 0x42, 0x33, 0x69, 0x4e, 0xff, 0x80, 0x13, 0xce, 0x8, 0x12, 0xa9, 0x90, 0xd8, 0x47, 0x93, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tab_close_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xb9,0x49,0x44,0x41,0x54,0x28,0xcf,0xad,0x90,0x5d,0xa,0x82,0x40,0x14,0x85,0xbf,0x31,0xb7,0xa0,0xd4,0x63,0x50,0x94,0x60,0x4b,0x28,0xe9,0x67,0x11,0x2e,0x36,0xa3,0xb6,0x90,0x82,0xc5,0x8,0xce,0x63,0xd0,0x12,0x34,0xa7,0x87,0xc9,0x1c,0x7b,0xa,0xea,0x3c,0xdd,0xcb,0xf9,0xe,0xf7,0x70,0xe1,0x4f,0x2a,0xe3,0xc2,0xb7,0xf7,0xc2,0x2f,0xe3,0x9e,0xad,0x1a,0x95,0x76,0x48,0xe1,0xab,0x54,0x35,0x6,0x71,0x0,0xea,0x44,0x67,0x84,0xee,0x49,0x8d,0x0,0xa4,0x37,0xd8,0x13,0x72,0xe5,0x8,0x20,0x4c,0x46,0x7a,0x6e,0x22,0x16,0x5c,0xd8,0x54,0xb5,0x99,0xf4,0x7a,0x7c,0xb3,0x80,0x16,0x11,0x52,0xd7,0x4,0x9d,0x6d,0x1,0x20,0x3d,0xf7,0x24,0x2,0xa0,0xd0,0xcb,0xd6,0x7e,0x75,0xf8,0x94,0xb0,0x62,0x4e,0xef,0x44,0xa0,0x25,0x39,0x13,0xe,0xa6,0xae,0x5,0xbc,0x4b,0xae,0xaa,0x48,0xa7,0xcc,0x6d,0x4,0x90,0x5e,0x79,0x56,0x5a,0xe5,0xe5,0xd0,0xde,0xc,0xe2,0x0,0xb8,0x5b,0x11,0x92,0xd5,0x91,0xa9,0x36,0xbd,0x3f,0x76,0x64,0xcc,0x74,0xf4,0xfd,0xab,0x7f,0xd2,0x13,0xed,0xc6,0x57,0xcd,0xb6,0x96,0x72,0x87,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tab_close_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xb9, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0xad, 0x90, 0x5d, 0xa, 0x82, 0x40, 0x14, 0x85, 0xbf, 0x31, 0xb7, 0xa0, 0xd4, 0x63, 0x50, 0x94, 0x60, 0x4b, 0x28, 0xe9, 0x67, 0x11, 0x2e, 0x36, 0xa3, 0xb6, 0x90, 0x82, 0xc5, 0x8, 0xce, 0x63, 0xd0, 0x12, 0x34, 0xa7, 0x87, 0xc9, 0x1c, 0x7b, 0xa, 0xea, 0x3c, 0xdd, 0xcb, 0xf9, 0xe, 0xf7, 0x70, 0xe1, 0x4f, 0x2a, 0xe3, 0xc2, 0xb7, 0xf7, 0xc2, 0x2f, 0xe3, 0x9e, 0xad, 0x1a, 0x95, 0x76, 0x48, 0xe1, 0xab, 0x54, 0x35, 0x6, 0x71, 0x0, 0xea, 0x44, 0x67, 0x84, 0xee, 0x49, 0x8d, 0x0, 0xa4, 0x37, 0xd8, 0x13, 0x72, 0xe5, 0x8, 0x20, 0x4c, 0x46, 0x7a, 0x6e, 0x22, 0x16, 0x5c, 0xd8, 0x54, 0xb5, 0x99, 0xf4, 0x7a, 0x7c, 0xb3, 0x80, 0x16, 0x11, 0x52, 0xd7, 0x4, 0x9d, 0x6d, 0x1, 0x20, 0x3d, 0xf7, 0x24, 0x2, 0xa0, 0xd0, 0xcb, 0xd6, 0x7e, 0x75, 0xf8, 0x94, 0xb0, 0x62, 0x4e, 0xef, 0x44, 0xa0, 0x25, 0x39, 0x13, 0xe, 0xa6, 0xae, 0x5, 0xbc, 0x4b, 0xae, 0xaa, 0x48, 0xa7, 0xcc, 0x6d, 0x4, 0x90, 0x5e, 0x79, 0x56, 0x5a, 0xe5, 0xe5, 0xd0, 0xde, 0xc, 0xe2, 0x0, 0xb8, 0x5b, 0x11, 0x92, 0xd5, 0x91, 0xa9, 0x36, 0xbd, 0x3f, 0x76, 0x64, 0xcc, 0x74, 0xf4, 0xfd, 0xab, 0x7f, 0xd2, 0x13, 0xed, 0xc6, 0x57, 0xcd, 0xb6, 0x96, 0x72, 0x87, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tab_container_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x8a,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3c,0x3a,0x44,0x56,0x53,0x61,0x56,0x52,0x60,0x47,0x44,0x52,0x33,0x31,0x39,0x47,0x44,0x50,0x47,0x44,0x51,0x52,0x50,0x5d,0x51,0x4f,0x5d,0x46,0x42,0x4e,0x42,0x3e,0x4a,0x41,0x3e,0x49,0x51,0x4e,0x5b,0x40,0x3e,0x48,0x4f,0x4c,0x59,0x3f,0x3d,0x47,0x4e,0x4a,0x58,0x3e,0x3b,0x46,0x4b,0x49,0x55,0x3c,0x3a,0x44,0x4a,0x47,0x54,0x3b,0x39,0x43,0x49,0x46,0x53,0x3a,0x38,0x42,0x47,0x45,0x50,0x39,0x37,0x40,0x47,0x43,0x50,0x38,0x35,0x3f,0x36,0x34,0x3e,0x44,0x42,0x4d,0x44,0x41,0x4c,0xff,0xff,0xff,0xe5,0x37,0x10,0x78,0x0,0x0,0x0,0x15,0x74,0x52,0x4e,0x53,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x77,0xef,0xef,0xef,0x77,0xef,0xed,0xe8,0xff,0x76,0xed,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x2d,0xcd,0xda,0x41,0x3d,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x93,0x49,0x44,0x41,0x54,0x18,0xd3,0x65,0xcf,0x47,0x12,0x82,0x40,0x10,0x5,0xd0,0x9e,0xc8,0x44,0x92,0x22,0x41,0x54,0x44,0x40,0x14,0xef,0x7f,0x3e,0x7,0x8a,0xea,0x85,0xbe,0xe5,0xaf,0xea,0xf0,0x1,0x8,0x65,0x5c,0xc8,0x40,0x70,0x46,0x9,0x0,0x89,0x94,0x36,0xd6,0x79,0xef,0xac,0xd1,0x2a,0x22,0x40,0x55,0x9c,0x14,0xa7,0x4d,0x91,0xc4,0x8a,0x2,0xd3,0x69,0x59,0xd5,0x9b,0xaa,0x4c,0x35,0x3,0x6e,0x9a,0xfa,0xbc,0xab,0x1b,0xc3,0x41,0xd8,0xf6,0x82,0x5a,0x2b,0x40,0xba,0xeb,0xd,0x5d,0x9d,0x4,0xe9,0xbb,0x3b,0xea,0xfc,0x1a,0xf4,0xf,0xd4,0xaf,0x81,0x1b,0x46,0x34,0x84,0x11,0x61,0xa7,0x27,0x9a,0xc2,0x52,0x6e,0xe6,0x17,0x9a,0xc3,0x59,0xa6,0xb3,0xf1,0xbd,0x1b,0xb3,0xf0,0x18,0x55,0xf9,0x61,0xf9,0x6c,0x96,0x63,0x1e,0x5e,0xff,0x2b,0xf7,0x5b,0xff,0xb,0x69,0x5a,0x14,0xfa,0x84,0xf6,0xc2,0x8,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tab_container_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x8a, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3c, 0x3a, 0x44, 0x56, 0x53, 0x61, 0x56, 0x52, 0x60, 0x47, 0x44, 0x52, 0x33, 0x31, 0x39, 0x47, 0x44, 0x50, 0x47, 0x44, 0x51, 0x52, 0x50, 0x5d, 0x51, 0x4f, 0x5d, 0x46, 0x42, 0x4e, 0x42, 0x3e, 0x4a, 0x41, 0x3e, 0x49, 0x51, 0x4e, 0x5b, 0x40, 0x3e, 0x48, 0x4f, 0x4c, 0x59, 0x3f, 0x3d, 0x47, 0x4e, 0x4a, 0x58, 0x3e, 0x3b, 0x46, 0x4b, 0x49, 0x55, 0x3c, 0x3a, 0x44, 0x4a, 0x47, 0x54, 0x3b, 0x39, 0x43, 0x49, 0x46, 0x53, 0x3a, 0x38, 0x42, 0x47, 0x45, 0x50, 0x39, 0x37, 0x40, 0x47, 0x43, 0x50, 0x38, 0x35, 0x3f, 0x36, 0x34, 0x3e, 0x44, 0x42, 0x4d, 0x44, 0x41, 0x4c, 0xff, 0xff, 0xff, 0xe5, 0x37, 0x10, 0x78, 0x0, 0x0, 0x0, 0x15, 0x74, 0x52, 0x4e, 0x53, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x77, 0xef, 0xef, 0xef, 0x77, 0xef, 0xed, 0xe8, 0xff, 0x76, 0xed, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x2d, 0xcd, 0xda, 0x41, 0x3d, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x93, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x65, 0xcf, 0x47, 0x12, 0x82, 0x40, 0x10, 0x5, 0xd0, 0x9e, 0xc8, 0x44, 0x92, 0x22, 0x41, 0x54, 0x44, 0x40, 0x14, 0xef, 0x7f, 0x3e, 0x7, 0x8a, 0xea, 0x85, 0xbe, 0xe5, 0xaf, 0xea, 0xf0, 0x1, 0x8, 0x65, 0x5c, 0xc8, 0x40, 0x70, 0x46, 0x9, 0x0, 0x89, 0x94, 0x36, 0xd6, 0x79, 0xef, 0xac, 0xd1, 0x2a, 0x22, 0x40, 0x55, 0x9c, 0x14, 0xa7, 0x4d, 0x91, 0xc4, 0x8a, 0x2, 0xd3, 0x69, 0x59, 0xd5, 0x9b, 0xaa, 0x4c, 0x35, 0x3, 0x6e, 0x9a, 0xfa, 0xbc, 0xab, 0x1b, 0xc3, 0x41, 0xd8, 0xf6, 0x82, 0x5a, 0x2b, 0x40, 0xba, 0xeb, 0xd, 0x5d, 0x9d, 0x4, 0xe9, 0xbb, 0x3b, 0xea, 0xfc, 0x1a, 0xf4, 0xf, 0xd4, 0xaf, 0x81, 0x1b, 0x46, 0x34, 0x84, 0x11, 0x61, 0xa7, 0x27, 0x9a, 0xc2, 0x52, 0x6e, 0xe6, 0x17, 0x9a, 0xc3, 0x59, 0xa6, 0xb3, 0xf1, 0xbd, 0x1b, 0xb3, 0xf0, 0x18, 0x55, 0xf9, 0x61, 0xf9, 0x6c, 0x96, 0x63, 0x1e, 0x5e, 0xff, 0x2b, 0xf7, 0x5b, 0xff, 0xb, 0x69, 0x5a, 0x14, 0xfa, 0x84, 0xf6, 0xc2, 0x8, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tab_current_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x9c,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3f,0x3d,0x48,0x5b,0x58,0x66,0x5b,0x57,0x65,0x57,0x54,0x62,0x55,0x53,0x62,0x4a,0x46,0x52,0x46,0x41,0x4e,0x45,0x41,0x4d,0x55,0x52,0x60,0x44,0x41,0x4c,0x53,0x50,0x5e,0x43,0x40,0x4b,0x52,0x4e,0x5d,0x41,0x3e,0x4a,0x4f,0x4d,0x5a,0x3f,0x3d,0x48,0x4e,0x4b,0x59,0x3e,0x3c,0x47,0x4d,0x4a,0x58,0x3d,0x3b,0x46,0x4b,0x49,0x54,0x3c,0x3a,0x44,0x4b,0x47,0x54,0x3b,0x39,0x43,0x3b,0x39,0x42,0x3b,0x38,0x43,0x3b,0x38,0x42,0x3a,0x37,0x41,0x39,0x37,0x41,0x3a,0x38,0x41,0x39,0x36,0x3f,0x38,0x36,0x3f,0x39,0x36,0x40,0x38,0x36,0x40,0x37,0x35,0x3e,0x37,0x34,0x3e,0x36,0x35,0x3d,0x35,0x32,0x3b,0x59,0xdd,0xd3,0xff,0x0,0x0,0x0,0x11,0x74,0x52,0x4e,0x53,0x4,0xa,0x11,0x19,0x1f,0x22,0x24,0x15,0x25,0x34,0x3f,0x46,0x47,0x48,0x77,0xef,0xef,0xa3,0x31,0x6b,0xc2,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x33,0x37,0xd5,0x7c,0x5e,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xa2,0x49,0x44,0x41,0x54,0x18,0xd3,0x45,0xcd,0xd9,0x12,0x82,0x30,0xc,0x40,0xd1,0x0,0x2d,0x4b,0x5b,0x36,0x59,0x44,0x44,0x44,0xa4,0x68,0x59,0x54,0xfc,0xff,0x8f,0x33,0x30,0x4c,0x3d,0x93,0xa7,0x3b,0x93,0x4,0xc0,0x30,0x2d,0x42,0x6d,0x44,0x89,0x65,0x1a,0x0,0x86,0xe3,0x7a,0x8c,0xb,0xdf,0x17,0x9c,0x79,0xae,0x63,0x80,0xe9,0x6,0x61,0x7c,0xd8,0xc4,0x61,0xe0,0x9a,0x60,0x79,0x51,0x92,0x66,0x9b,0x34,0x89,0x3c,0xb,0x8,0xcb,0xb3,0xe3,0x2e,0xcb,0x19,0x1,0xca,0x8b,0x93,0x56,0x70,0xa,0xb6,0x28,0xcf,0x5a,0x29,0x6c,0xb0,0xfd,0xea,0xa2,0x55,0xfe,0x1a,0xea,0xab,0x56,0xaf,0x41,0x34,0x37,0xad,0xc1,0x15,0xca,0xdb,0xbb,0xd6,0xe2,0x51,0xc2,0xba,0x7f,0xe8,0xf0,0x2d,0x6,0x29,0xfb,0x5e,0xca,0xc7,0x53,0xca,0x3d,0xa8,0x61,0x50,0xc3,0xa8,0xc6,0x41,0xed,0x61,0x9a,0xa6,0x19,0xbd,0xe6,0xf7,0x1e,0x3e,0xcb,0x82,0x83,0xbe,0x18,0x7e,0xa1,0xe5,0x17,0x1f,0xcf,0x5d,0x82,0x6b,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tab_current_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x9c, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0x3d, 0x48, 0x5b, 0x58, 0x66, 0x5b, 0x57, 0x65, 0x57, 0x54, 0x62, 0x55, 0x53, 0x62, 0x4a, 0x46, 0x52, 0x46, 0x41, 0x4e, 0x45, 0x41, 0x4d, 0x55, 0x52, 0x60, 0x44, 0x41, 0x4c, 0x53, 0x50, 0x5e, 0x43, 0x40, 0x4b, 0x52, 0x4e, 0x5d, 0x41, 0x3e, 0x4a, 0x4f, 0x4d, 0x5a, 0x3f, 0x3d, 0x48, 0x4e, 0x4b, 0x59, 0x3e, 0x3c, 0x47, 0x4d, 0x4a, 0x58, 0x3d, 0x3b, 0x46, 0x4b, 0x49, 0x54, 0x3c, 0x3a, 0x44, 0x4b, 0x47, 0x54, 0x3b, 0x39, 0x43, 0x3b, 0x39, 0x42, 0x3b, 0x38, 0x43, 0x3b, 0x38, 0x42, 0x3a, 0x37, 0x41, 0x39, 0x37, 0x41, 0x3a, 0x38, 0x41, 0x39, 0x36, 0x3f, 0x38, 0x36, 0x3f, 0x39, 0x36, 0x40, 0x38, 0x36, 0x40, 0x37, 0x35, 0x3e, 0x37, 0x34, 0x3e, 0x36, 0x35, 0x3d, 0x35, 0x32, 0x3b, 0x59, 0xdd, 0xd3, 0xff, 0x0, 0x0, 0x0, 0x11, 0x74, 0x52, 0x4e, 0x53, 0x4, 0xa, 0x11, 0x19, 0x1f, 0x22, 0x24, 0x15, 0x25, 0x34, 0x3f, 0x46, 0x47, 0x48, 0x77, 0xef, 0xef, 0xa3, 0x31, 0x6b, 0xc2, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x33, 0x37, 0xd5, 0x7c, 0x5e, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xa2, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x45, 0xcd, 0xd9, 0x12, 0x82, 0x30, 0xc, 0x40, 0xd1, 0x0, 0x2d, 0x4b, 0x5b, 0x36, 0x59, 0x44, 0x44, 0x44, 0xa4, 0x68, 0x59, 0x54, 0xfc, 0xff, 0x8f, 0x33, 0x30, 0x4c, 0x3d, 0x93, 0xa7, 0x3b, 0x93, 0x4, 0xc0, 0x30, 0x2d, 0x42, 0x6d, 0x44, 0x89, 0x65, 0x1a, 0x0, 0x86, 0xe3, 0x7a, 0x8c, 0xb, 0xdf, 0x17, 0x9c, 0x79, 0xae, 0x63, 0x80, 0xe9, 0x6, 0x61, 0x7c, 0xd8, 0xc4, 0x61, 0xe0, 0x9a, 0x60, 0x79, 0x51, 0x92, 0x66, 0x9b, 0x34, 0x89, 0x3c, 0xb, 0x8, 0xcb, 0xb3, 0xe3, 0x2e, 0xcb, 0x19, 0x1, 0xca, 0x8b, 0x93, 0x56, 0x70, 0xa, 0xb6, 0x28, 0xcf, 0x5a, 0x29, 0x6c, 0xb0, 0xfd, 0xea, 0xa2, 0x55, 0xfe, 0x1a, 0xea, 0xab, 0x56, 0xaf, 0x41, 0x34, 0x37, 0xad, 0xc1, 0x15, 0xca, 0xdb, 0xbb, 0xd6, 0xe2, 0x51, 0xc2, 0xba, 0x7f, 0xe8, 0xf0, 0x2d, 0x6, 0x29, 0xfb, 0x5e, 0xca, 0xc7, 0x53, 0xca, 0x3d, 0xa8, 0x61, 0x50, 0xc3, 0xa8, 0xc6, 0x41, 0xed, 0x61, 0x9a, 0xa6, 0x19, 0xbd, 0xe6, 0xf7, 0x1e, 0x3e, 0xcb, 0x82, 0x83, 0xbe, 0x18, 0x7e, 0xa1, 0xe5, 0x17, 0x1f, 0xcf, 0x5d, 0x82, 0x6b, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tab_menu_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x4c,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0x18,0x5,0xc,0xc,0xc,0xc,0x8c,0x30,0xc6,0x83,0xff,0xa8,0x12,0xa,0x50,0x19,0x26,0x42,0x26,0x10,0xaf,0x80,0x31,0x9e,0xe1,0x2b,0x5c,0xf4,0x3b,0x63,0x3a,0x16,0xb5,0xf7,0x35,0xee,0x5f,0x7a,0xf0,0xff,0xc1,0xff,0x7,0xd7,0x1f,0xeb,0x62,0x71,0x24,0x3,0x3,0x3,0xc3,0xb,0xee,0x9f,0x53,0x18,0x18,0xd8,0x73,0x24,0xbe,0x32,0x50,0x11,0x0,0x0,0x6,0x9b,0x11,0xfa,0xe0,0x26,0x3d,0x9f,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tab_menu_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x18, 0x5, 0xc, 0xc, 0xc, 0xc, 0x8c, 0x30, 0xc6, 0x83, 0xff, 0xa8, 0x12, 0xa, 0x50, 0x19, 0x26, 0x42, 0x26, 0x10, 0xaf, 0x80, 0x31, 0x9e, 0xe1, 0x2b, 0x5c, 0xf4, 0x3b, 0x63, 0x3a, 0x16, 0xb5, 0xf7, 0x35, 0xee, 0x5f, 0x7a, 0xf0, 0xff, 0xc1, 0xff, 0x7, 0xd7, 0x1f, 0xeb, 0x62, 0x71, 0x24, 0x3, 0x3, 0x3, 0xc3, 0xb, 0xee, 0x9f, 0x53, 0x18, 0x18, 0xd8, 0x73, 0x24, 0xbe, 0x32, 0x50, 0x11, 0x0, 0x0, 0x6, 0x9b, 0x11, 0xfa, 0xe0, 0x26, 0x3d, 0x9f, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tab_menu_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x4c,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0x18,0x5,0xc,0xc,0xc,0xc,0x8c,0x30,0xc6,0x83,0xff,0xa8,0x12,0xa,0x50,0x19,0x26,0x42,0x26,0x10,0xaf,0x80,0x31,0x9e,0xe1,0x2b,0x5c,0xf4,0x3b,0x63,0x3a,0x16,0xb5,0xf7,0x35,0xee,0x5f,0x7a,0xf0,0xff,0xc1,0xff,0x7,0xd7,0x1f,0xeb,0x62,0x71,0x24,0x3,0x3,0x3,0xc3,0xb,0xee,0x9f,0x53,0x18,0x18,0xd8,0x73,0x24,0xbe,0x32,0x50,0x11,0x0,0x0,0x6,0x9b,0x11,0xfa,0xe0,0x26,0x3d,0x9f,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tab_menu_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0x18, 0x5, 0xc, 0xc, 0xc, 0xc, 0x8c, 0x30, 0xc6, 0x83, 0xff, 0xa8, 0x12, 0xa, 0x50, 0x19, 0x26, 0x42, 0x26, 0x10, 0xaf, 0x80, 0x31, 0x9e, 0xe1, 0x2b, 0x5c, 0xf4, 0x3b, 0x63, 0x3a, 0x16, 0xb5, 0xf7, 0x35, 0xee, 0x5f, 0x7a, 0xf0, 0xff, 0xc1, 0xff, 0x7, 0xd7, 0x1f, 0xeb, 0x62, 0x71, 0x24, 0x3, 0x3, 0x3, 0xc3, 0xb, 0xee, 0x9f, 0x53, 0x18, 0x18, 0xd8, 0x73, 0x24, 0xbe, 0x32, 0x50, 0x11, 0x0, 0x0, 0x6, 0x9b, 0x11, 0xfa, 0xe0, 0x26, 0x3d, 0x9f, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char toggle_off_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x20,0x8,0x3,0x0,0x0,0x0,0x95,0x43,0x8e,0xb6,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x7a,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x14,0x14,0x17,0x20,0x20,0x25,0x24,0x24,0x28,0x24,0x24,0x29,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x10,0x10,0x13,0x22,0x22,0x27,0x0,0x0,0x0,0x0,0x0,0x0,0x19,0x19,0x1c,0x1a,0x1a,0x1d,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0x14,0x12,0x12,0x14,0x23,0x23,0x27,0x0,0x0,0x0,0x0,0x0,0x0,0x15,0x15,0x18,0x20,0x20,0x25,0x20,0x20,0x24,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x24,0x28,0x0,0x0,0x0,0x24,0x24,0x28,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x24,0x27,0x15,0x15,0x18,0x23,0x23,0x28,0x12,0x12,0x14,0x0,0x0,0x0,0x1a,0x1a,0x1e,0x0,0x0,0x0,0x11,0x11,0x13,0x22,0x22,0x26,0x0,0x0,0x0,0x0,0x0,0x0,0x24,0x24,0x29,0x25,0x25,0x2a,0x24,0x24,0x28,0x25,0x25,0x28,0x25,0x25,0x29,0x25,0x25,0x27,0x2d,0x26,0x2c,0x4d,0x2b,0x37,0x63,0x2f,0x3f,0x6e,0x31,0x43,0x71,0x32,0x44,0x6c,0x31,0x42,0x51,0x2c,0x39,0x47,0x2a,0x35,0x66,0x30,0x40,0x4d,0x2b,0x38,0x32,0x26,0x2e,0x26,0x25,0x2a,0x2e,0x25,0x2c,0x3c,0x28,0x31,0x52,0x2c,0x39,0x68,0x30,0x40,0x27,0x25,0x2a,0x50,0x2c,0x38,0x5f,0x2e,0x3d,0x35,0x27,0x2f,0x38,0x27,0x30,0x5e,0x2e,0x3d,0x43,0x2a,0x34,0x5f,0x2f,0x3e,0x2f,0x25,0x2c,0x44,0x2a,0x34,0x2b,0x26,0x2c,0x64,0x2f,0x3f,0x36,0x27,0x30,0x37,0x27,0x30,0x66,0x2f,0x40,0x2c,0x26,0x2c,0x46,0x2a,0x35,0x53,0x2c,0x39,0x40,0x40,0x44,0xad,0xad,0xaf,0xff,0xff,0xff,0xf2,0xf2,0xf2,0x77,0x77,0x7a,0x5b,0x5b,0x5f,0x32,0x32,0x37,0x5d,0x2e,0x3d,0x3e,0x29,0x32,0xc9,0xc9,0xca,0xbb,0xbb,0xbd,0x69,0x69,0x6c,0x69,0x30,0x41,0x2f,0x26,0x2d,0x84,0x84,0x87,0xd6,0xd6,0xd7,0x92,0x92,0x94,0xa0,0xa0,0xa2,0x4e,0x4e,0x52,0x48,0x2b,0x36,0x2c,0x26,0x2b,0x97,0xb0,0x86,0xb4,0x0,0x0,0x0,0x41,0x74,0x52,0x4e,0x53,0x0,0x1,0x2,0x3,0x4,0x9,0xe,0x13,0x16,0x18,0x19,0xa,0x26,0x36,0x44,0x4d,0x52,0x54,0x55,0x6,0x12,0x27,0x43,0x98,0xe5,0xfa,0xfe,0x8,0x17,0x35,0x86,0xf3,0x7,0x3a,0xb4,0xb9,0xb,0x28,0x8a,0x8b,0xf6,0x45,0x5,0x9b,0xe6,0xe6,0x37,0xf,0xfb,0x4c,0xfe,0x4e,0x4f,0x50,0xfb,0x9c,0xf6,0x8c,0x3b,0xbb,0x3c,0x87,0xf3,0x53,0x14,0xe5,0x7c,0xf3,0x66,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x6b,0x52,0x65,0xa5,0x98,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x2,0x47,0x49,0x44,0x41,0x54,0x48,0xc7,0xd5,0x55,0xfb,0x5b,0x93,0x50,0x18,0x96,0x3,0xc,0x48,0x60,0xde,0x70,0x9b,0x43,0x37,0x75,0xa6,0x9b,0xb5,0xad,0x56,0x59,0x99,0xe9,0xc6,0x39,0xb3,0x56,0x59,0xcd,0x4c,0xbb,0xd9,0x3d,0xdb,0xd,0x74,0xa6,0xa3,0xdb,0xff,0x1e,0x70,0x68,0x6e,0xc0,0xe0,0xe9,0xe9,0x97,0x7a,0x79,0x9e,0x3,0xf,0x7c,0xdf,0xcb,0x7b,0xbe,0xf3,0x5d,0x86,0x86,0xfe,0x21,0x10,0x80,0x24,0xa9,0x40,0x90,0x24,0x20,0x3c,0xdd,0x1,0x45,0x87,0x18,0x96,0x3b,0x17,0x0,0x8e,0x65,0x42,0x34,0x5,0xdc,0x7f,0xa7,0x86,0x59,0x5e,0x10,0xc3,0x23,0xa3,0x63,0xbe,0x18,0x1d,0x9,0x8b,0x2,0xcf,0xe,0x53,0xe,0x15,0x60,0x7c,0x42,0x9a,0x8c,0x44,0x63,0x53,0xc5,0x52,0x0,0x8a,0x53,0xb1,0x68,0x64,0x52,0x9a,0x18,0xef,0x13,0x1,0xe2,0xf2,0xf4,0x4c,0x42,0x81,0x10,0x21,0x84,0xed,0x90,0x9,0x88,0xca,0xc8,0x93,0x24,0x31,0x33,0x2d,0xc7,0x7b,0x18,0x88,0x24,0x37,0x3b,0xa7,0xc0,0xcd,0x3b,0x77,0x2b,0xf7,0x30,0xee,0x3f,0xd8,0xb4,0x58,0xca,0x70,0x80,0x8e,0xb9,0x59,0x2e,0x49,0x9c,0xed,0x9f,0x11,0xe6,0x15,0xb4,0xf5,0xf0,0xd1,0xe3,0xaa,0xf5,0xb9,0xba,0xfd,0x64,0xe7,0xe9,0xd6,0xae,0xa5,0x64,0xd0,0x4e,0xe6,0x5,0xa6,0x1b,0x7,0x90,0x5a,0x38,0xaf,0xa0,0xbd,0x67,0xcf,0x7b,0x2d,0x5e,0xbc,0xdc,0xdb,0xf5,0x8d,0xc5,0xe2,0x42,0xea,0xf7,0x26,0x28,0x59,0x5c,0x82,0xaf,0xf6,0xb7,0xfb,0x2d,0x5e,0xef,0xbf,0xa9,0xfa,0x31,0x2c,0xa5,0xe5,0xc,0x96,0x40,0xd0,0xfc,0x32,0x7c,0xfb,0xee,0xbd,0xd3,0xe2,0xc3,0xc7,0x4f,0xbe,0xe7,0xb1,0xcc,0xd3,0x98,0x0,0x84,0x84,0xb,0xf0,0x60,0xc7,0x6d,0xf1,0xf9,0xc0,0x7e,0xa8,0xd5,0x1b,0xcd,0x56,0x49,0x6d,0x18,0xb0,0x16,0xcd,0x7a,0x7b,0x31,0x9b,0xc3,0x7b,0x20,0x19,0x31,0x86,0xe,0x8f,0xdc,0x4,0x47,0x87,0xf6,0x43,0xfb,0xb8,0xf6,0xa5,0x51,0x53,0x4d,0x47,0xd5,0xf6,0x36,0x90,0x4f,0x33,0x24,0x26,0x60,0x2f,0x5d,0x46,0x27,0xa7,0x6e,0x82,0xd3,0x13,0x5b,0x80,0xe9,0x74,0xdc,0x51,0x75,0x93,0x40,0xef,0x12,0x14,0xb,0x2c,0x85,0x9,0xe4,0x2b,0xa,0xaa,0x78,0x4,0xac,0x5a,0xc1,0x77,0x55,0x37,0x96,0xaf,0x75,0xb5,0xdd,0x6e,0x6b,0xd6,0x62,0x7f,0xbf,0x2a,0xdb,0x4,0x6c,0x58,0xf1,0x55,0xa0,0x99,0xa,0xea,0xdf,0x54,0xd3,0x53,0x6d,0x7b,0x28,0x60,0xc4,0x6b,0xd0,0x37,0x6,0x7a,0xa7,0xa4,0x35,0x5b,0x4e,0x82,0x6e,0xc,0x40,0x28,0x1b,0x70,0xa,0x6a,0x53,0x6f,0xd6,0x4b,0x4e,0x82,0xee,0x29,0x18,0x79,0xb0,0x12,0x90,0x7,0x5a,0xe7,0xbb,0x11,0xcb,0x96,0x66,0x2f,0x18,0x2b,0x92,0x9d,0x7,0x66,0x26,0x5e,0x47,0x7f,0x91,0x89,0x66,0x2d,0x2c,0xfe,0x79,0x2d,0xdc,0x38,0xab,0x5,0xef,0x6a,0xfc,0xe1,0xef,0xdf,0x5b,0x8d,0x66,0x3f,0xb8,0xb9,0xaa,0xc0,0x9f,0xce,0x7e,0xe0,0xe3,0xbf,0x7a,0xab,0xa7,0x1f,0x98,0x1d,0x89,0x13,0xd6,0x6e,0xc3,0x32,0xc4,0xd,0x9,0xd9,0x80,0xc6,0xe5,0xe9,0x9f,0x58,0x13,0xb8,0x78,0x7f,0x4f,0x4b,0x32,0x92,0x18,0x89,0xe6,0x3,0x5b,0xa2,0xf1,0xf3,0x7c,0x34,0x22,0x4a,0x4c,0xd2,0xd1,0x98,0x9,0x2a,0xc5,0xf2,0xd9,0x74,0x61,0x7d,0x2c,0x0,0xeb,0x85,0x74,0x96,0x67,0x53,0x94,0x6b,0x36,0x10,0x20,0x43,0xe7,0x36,0xe4,0xe0,0xb9,0x20,0x6f,0xe4,0xe8,0x8c,0xf7,0x6c,0x31,0x26,0x53,0xf0,0x60,0x32,0x46,0xd3,0x80,0xc9,0xf4,0xff,0xe2,0x17,0x82,0xde,0x40,0xde,0x2d,0xc3,0x2a,0xca,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char toggle_off_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x20, 0x8, 0x3, 0x0, 0x0, 0x0, 0x95, 0x43, 0x8e, 0xb6, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x7a, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x14, 0x14, 0x17, 0x20, 0x20, 0x25, 0x24, 0x24, 0x28, 0x24, 0x24, 0x29, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x10, 0x13, 0x22, 0x22, 0x27, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x19, 0x19, 0x1c, 0x1a, 0x1a, 0x1d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x11, 0x11, 0x14, 0x12, 0x12, 0x14, 0x23, 0x23, 0x27, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x15, 0x15, 0x18, 0x20, 0x20, 0x25, 0x20, 0x20, 0x24, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x24, 0x24, 0x28, 0x0, 0x0, 0x0, 0x24, 0x24, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x24, 0x24, 0x27, 0x15, 0x15, 0x18, 0x23, 0x23, 0x28, 0x12, 0x12, 0x14, 0x0, 0x0, 0x0, 0x1a, 0x1a, 0x1e, 0x0, 0x0, 0x0, 0x11, 0x11, 0x13, 0x22, 0x22, 0x26, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x24, 0x24, 0x29, 0x25, 0x25, 0x2a, 0x24, 0x24, 0x28, 0x25, 0x25, 0x28, 0x25, 0x25, 0x29, 0x25, 0x25, 0x27, 0x2d, 0x26, 0x2c, 0x4d, 0x2b, 0x37, 0x63, 0x2f, 0x3f, 0x6e, 0x31, 0x43, 0x71, 0x32, 0x44, 0x6c, 0x31, 0x42, 0x51, 0x2c, 0x39, 0x47, 0x2a, 0x35, 0x66, 0x30, 0x40, 0x4d, 0x2b, 0x38, 0x32, 0x26, 0x2e, 0x26, 0x25, 0x2a, 0x2e, 0x25, 0x2c, 0x3c, 0x28, 0x31, 0x52, 0x2c, 0x39, 0x68, 0x30, 0x40, 0x27, 0x25, 0x2a, 0x50, 0x2c, 0x38, 0x5f, 0x2e, 0x3d, 0x35, 0x27, 0x2f, 0x38, 0x27, 0x30, 0x5e, 0x2e, 0x3d, 0x43, 0x2a, 0x34, 0x5f, 0x2f, 0x3e, 0x2f, 0x25, 0x2c, 0x44, 0x2a, 0x34, 0x2b, 0x26, 0x2c, 0x64, 0x2f, 0x3f, 0x36, 0x27, 0x30, 0x37, 0x27, 0x30, 0x66, 0x2f, 0x40, 0x2c, 0x26, 0x2c, 0x46, 0x2a, 0x35, 0x53, 0x2c, 0x39, 0x40, 0x40, 0x44, 0xad, 0xad, 0xaf, 0xff, 0xff, 0xff, 0xf2, 0xf2, 0xf2, 0x77, 0x77, 0x7a, 0x5b, 0x5b, 0x5f, 0x32, 0x32, 0x37, 0x5d, 0x2e, 0x3d, 0x3e, 0x29, 0x32, 0xc9, 0xc9, 0xca, 0xbb, 0xbb, 0xbd, 0x69, 0x69, 0x6c, 0x69, 0x30, 0x41, 0x2f, 0x26, 0x2d, 0x84, 0x84, 0x87, 0xd6, 0xd6, 0xd7, 0x92, 0x92, 0x94, 0xa0, 0xa0, 0xa2, 0x4e, 0x4e, 0x52, 0x48, 0x2b, 0x36, 0x2c, 0x26, 0x2b, 0x97, 0xb0, 0x86, 0xb4, 0x0, 0x0, 0x0, 0x41, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x1, 0x2, 0x3, 0x4, 0x9, 0xe, 0x13, 0x16, 0x18, 0x19, 0xa, 0x26, 0x36, 0x44, 0x4d, 0x52, 0x54, 0x55, 0x6, 0x12, 0x27, 0x43, 0x98, 0xe5, 0xfa, 0xfe, 0x8, 0x17, 0x35, 0x86, 0xf3, 0x7, 0x3a, 0xb4, 0xb9, 0xb, 0x28, 0x8a, 0x8b, 0xf6, 0x45, 0x5, 0x9b, 0xe6, 0xe6, 0x37, 0xf, 0xfb, 0x4c, 0xfe, 0x4e, 0x4f, 0x50, 0xfb, 0x9c, 0xf6, 0x8c, 0x3b, 0xbb, 0x3c, 0x87, 0xf3, 0x53, 0x14, 0xe5, 0x7c, 0xf3, 0x66, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x6b, 0x52, 0x65, 0xa5, 0x98, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x2, 0x47, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xd5, 0x55, 0xfb, 0x5b, 0x93, 0x50, 0x18, 0x96, 0x3, 0xc, 0x48, 0x60, 0xde, 0x70, 0x9b, 0x43, 0x37, 0x75, 0xa6, 0x9b, 0xb5, 0xad, 0x56, 0x59, 0x99, 0xe9, 0xc6, 0x39, 0xb3, 0x56, 0x59, 0xcd, 0x4c, 0xbb, 0xd9, 0x3d, 0xdb, 0xd, 0x74, 0xa6, 0xa3, 0xdb, 0xff, 0x1e, 0x70, 0x68, 0x6e, 0xc0, 0xe0, 0xe9, 0xe9, 0x97, 0x7a, 0x79, 0x9e, 0x3, 0xf, 0x7c, 0xdf, 0xcb, 0x7b, 0xbe, 0xf3, 0x5d, 0x86, 0x86, 0xfe, 0x21, 0x10, 0x80, 0x24, 0xa9, 0x40, 0x90, 0x24, 0x20, 0x3c, 0xdd, 0x1, 0x45, 0x87, 0x18, 0x96, 0x3b, 0x17, 0x0, 0x8e, 0x65, 0x42, 0x34, 0x5, 0xdc, 0x7f, 0xa7, 0x86, 0x59, 0x5e, 0x10, 0xc3, 0x23, 0xa3, 0x63, 0xbe, 0x18, 0x1d, 0x9, 0x8b, 0x2, 0xcf, 0xe, 0x53, 0xe, 0x15, 0x60, 0x7c, 0x42, 0x9a, 0x8c, 0x44, 0x63, 0x53, 0xc5, 0x52, 0x0, 0x8a, 0x53, 0xb1, 0x68, 0x64, 0x52, 0x9a, 0x18, 0xef, 0x13, 0x1, 0xe2, 0xf2, 0xf4, 0x4c, 0x42, 0x81, 0x10, 0x21, 0x84, 0xed, 0x90, 0x9, 0x88, 0xca, 0xc8, 0x93, 0x24, 0x31, 0x33, 0x2d, 0xc7, 0x7b, 0x18, 0x88, 0x24, 0x37, 0x3b, 0xa7, 0xc0, 0xcd, 0x3b, 0x77, 0x2b, 0xf7, 0x30, 0xee, 0x3f, 0xd8, 0xb4, 0x58, 0xca, 0x70, 0x80, 0x8e, 0xb9, 0x59, 0x2e, 0x49, 0x9c, 0xed, 0x9f, 0x11, 0xe6, 0x15, 0xb4, 0xf5, 0xf0, 0xd1, 0xe3, 0xaa, 0xf5, 0xb9, 0xba, 0xfd, 0x64, 0xe7, 0xe9, 0xd6, 0xae, 0xa5, 0x64, 0xd0, 0x4e, 0xe6, 0x5, 0xa6, 0x1b, 0x7, 0x90, 0x5a, 0x38, 0xaf, 0xa0, 0xbd, 0x67, 0xcf, 0x7b, 0x2d, 0x5e, 0xbc, 0xdc, 0xdb, 0xf5, 0x8d, 0xc5, 0xe2, 0x42, 0xea, 0xf7, 0x26, 0x28, 0x59, 0x5c, 0x82, 0xaf, 0xf6, 0xb7, 0xfb, 0x2d, 0x5e, 0xef, 0xbf, 0xa9, 0xfa, 0x31, 0x2c, 0xa5, 0xe5, 0xc, 0x96, 0x40, 0xd0, 0xfc, 0x32, 0x7c, 0xfb, 0xee, 0xbd, 0xd3, 0xe2, 0xc3, 0xc7, 0x4f, 0xbe, 0xe7, 0xb1, 0xcc, 0xd3, 0x98, 0x0, 0x84, 0x84, 0xb, 0xf0, 0x60, 0xc7, 0x6d, 0xf1, 0xf9, 0xc0, 0x7e, 0xa8, 0xd5, 0x1b, 0xcd, 0x56, 0x49, 0x6d, 0x18, 0xb0, 0x16, 0xcd, 0x7a, 0x7b, 0x31, 0x9b, 0xc3, 0x7b, 0x20, 0x19, 0x31, 0x86, 0xe, 0x8f, 0xdc, 0x4, 0x47, 0x87, 0xf6, 0x43, 0xfb, 0xb8, 0xf6, 0xa5, 0x51, 0x53, 0x4d, 0x47, 0xd5, 0xf6, 0x36, 0x90, 0x4f, 0x33, 0x24, 0x26, 0x60, 0x2f, 0x5d, 0x46, 0x27, 0xa7, 0x6e, 0x82, 0xd3, 0x13, 0x5b, 0x80, 0xe9, 0x74, 0xdc, 0x51, 0x75, 0x93, 0x40, 0xef, 0x12, 0x14, 0xb, 0x2c, 0x85, 0x9, 0xe4, 0x2b, 0xa, 0xaa, 0x78, 0x4, 0xac, 0x5a, 0xc1, 0x77, 0x55, 0x37, 0x96, 0xaf, 0x75, 0xb5, 0xdd, 0x6e, 0x6b, 0xd6, 0x62, 0x7f, 0xbf, 0x2a, 0xdb, 0x4, 0x6c, 0x58, 0xf1, 0x55, 0xa0, 0x99, 0xa, 0xea, 0xdf, 0x54, 0xd3, 0x53, 0x6d, 0x7b, 0x28, 0x60, 0xc4, 0x6b, 0xd0, 0x37, 0x6, 0x7a, 0xa7, 0xa4, 0x35, 0x5b, 0x4e, 0x82, 0x6e, 0xc, 0x40, 0x28, 0x1b, 0x70, 0xa, 0x6a, 0x53, 0x6f, 0xd6, 0x4b, 0x4e, 0x82, 0xee, 0x29, 0x18, 0x79, 0xb0, 0x12, 0x90, 0x7, 0x5a, 0xe7, 0xbb, 0x11, 0xcb, 0x96, 0x66, 0x2f, 0x18, 0x2b, 0x92, 0x9d, 0x7, 0x66, 0x26, 0x5e, 0x47, 0x7f, 0x91, 0x89, 0x66, 0x2d, 0x2c, 0xfe, 0x79, 0x2d, 0xdc, 0x38, 0xab, 0x5, 0xef, 0x6a, 0xfc, 0xe1, 0xef, 0xdf, 0x5b, 0x8d, 0x66, 0x3f, 0xb8, 0xb9, 0xaa, 0xc0, 0x9f, 0xce, 0x7e, 0xe0, 0xe3, 0xbf, 0x7a, 0xab, 0xa7, 0x1f, 0x98, 0x1d, 0x89, 0x13, 0xd6, 0x6e, 0xc3, 0x32, 0xc4, 0xd, 0x9, 0xd9, 0x80, 0xc6, 0xe5, 0xe9, 0x9f, 0x58, 0x13, 0xb8, 0x78, 0x7f, 0x4f, 0x4b, 0x32, 0x92, 0x18, 0x89, 0xe6, 0x3, 0x5b, 0xa2, 0xf1, 0xf3, 0x7c, 0x34, 0x22, 0x4a, 0x4c, 0xd2, 0xd1, 0x98, 0x9, 0x2a, 0xc5, 0xf2, 0xd9, 0x74, 0x61, 0x7d, 0x2c, 0x0, 0xeb, 0x85, 0x74, 0x96, 0x67, 0x53, 0x94, 0x6b, 0x36, 0x10, 0x20, 0x43, 0xe7, 0x36, 0xe4, 0xe0, 0xb9, 0x20, 0x6f, 0xe4, 0xe8, 0x8c, 0xf7, 0x6c, 0x31, 0x26, 0x53, 0xf0, 0x60, 0x32, 0x46, 0xd3, 0x80, 0xc9, 0xf4, 0xff, 0xe2, 0x17, 0x82, 0xde, 0x40, 0xde, 0x2d, 0xc3, 0x2a, 0xca, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char toggle_on_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x20,0x8,0x3,0x0,0x0,0x0,0x95,0x43,0x8e,0xb6,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x1,0x74,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xd,0xd,0xf,0x1a,0x1a,0x1e,0x20,0x20,0x24,0x22,0x22,0x27,0x24,0x24,0x29,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xa,0xa,0xc,0x1d,0x1d,0x21,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0x14,0x23,0x23,0x28,0x12,0x12,0x15,0x0,0x0,0x0,0x0,0x0,0x0,0xb,0xb,0xd,0x23,0x23,0x28,0xb,0xb,0xd,0x1e,0x1e,0x22,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0xe,0x10,0x1a,0x1a,0x1e,0x1a,0x1a,0x1d,0x0,0x0,0x0,0x0,0x0,0x0,0x20,0x20,0x24,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0xe,0x10,0xb,0xb,0xd,0x0,0x0,0x0,0x13,0x13,0x15,0x0,0x0,0x0,0xb,0xb,0xc,0x1d,0x1d,0x21,0x0,0x0,0x0,0x0,0x0,0x0,0x25,0x25,0x2a,0x24,0x24,0x29,0x25,0x2c,0x36,0x27,0x49,0x65,0x29,0x5d,0x85,0x2a,0x66,0x95,0x2a,0x68,0x99,0x29,0x64,0x92,0x28,0x4c,0x6b,0x25,0x27,0x2d,0x27,0x43,0x5c,0x29,0x5f,0x89,0x27,0x49,0x66,0x25,0x30,0x3e,0x25,0x26,0x2d,0x25,0x25,0x2b,0x25,0x26,0x2c,0x25,0x2d,0x38,0x25,0x3a,0x4c,0x27,0x4d,0x6b,0x29,0x60,0x8c,0x27,0x44,0x5c,0x27,0x4b,0x69,0x28,0x59,0x7f,0x25,0x34,0x43,0x25,0x35,0x45,0x28,0x58,0x7f,0x25,0x26,0x2b,0x27,0x40,0x57,0x27,0x41,0x57,0x25,0x2a,0x33,0x29,0x5d,0x87,0x25,0x34,0x44,0x25,0x2b,0x34,0x40,0x40,0x44,0xad,0xad,0xaf,0xff,0xff,0xff,0xf2,0xf2,0xf2,0x77,0x77,0x7a,0x5b,0x5b,0x5f,0x4e,0x4e,0x52,0xc9,0xc9,0xca,0x27,0x43,0x5b,0x27,0x4d,0x6c,0x27,0x4e,0x6d,0xbb,0xbb,0xbd,0x69,0x69,0x6c,0x28,0x56,0x7b,0x26,0x3b,0x4e,0x26,0x3a,0x4e,0x32,0x32,0x37,0x84,0x84,0x87,0xd6,0xd6,0xd7,0x29,0x61,0x8d,0x25,0x2e,0x39,0x92,0x92,0x94,0xa0,0xa0,0xa2,0xe4,0xe4,0xe5,0x27,0x44,0x5d,0xdd,0xc9,0xf2,0x7e,0x0,0x0,0x0,0x41,0x74,0x52,0x4e,0x53,0x0,0x1,0x2,0x3,0x4,0x9,0xe,0x13,0x16,0x18,0x19,0xa,0x26,0x36,0x44,0x4d,0x52,0x54,0x55,0x6,0x12,0x27,0x43,0x80,0xc5,0xe7,0xf5,0xfe,0x8,0x17,0x35,0x73,0xd9,0x7,0x3a,0x96,0xf9,0x9a,0xb,0x28,0x76,0xfb,0x77,0xde,0x45,0x5,0x82,0xc6,0xc6,0x37,0xf,0xe9,0x4c,0x4e,0x4f,0x50,0x83,0x78,0x3b,0x9c,0x3c,0x74,0xda,0x53,0x14,0x37,0x21,0x5a,0x6c,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x65,0xb5,0xdd,0x88,0x9f,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x2,0x28,0x49,0x44,0x41,0x54,0x48,0xc7,0xd5,0x55,0x69,0x57,0xd3,0x40,0x14,0x25,0x93,0xa4,0x49,0x24,0x49,0xd9,0x42,0xd7,0x0,0x85,0x50,0x2c,0xb4,0x68,0x5b,0xab,0x28,0xb2,0xc,0x4b,0x95,0x82,0x56,0xab,0x42,0x45,0x5c,0x9b,0xad,0x45,0x11,0x6d,0x3,0xa8,0x7f,0xde,0xc4,0x94,0x26,0x69,0x30,0x89,0xc7,0x2f,0x7a,0x3f,0xe4,0x9c,0xcc,0x3b,0xef,0xce,0x7d,0x6f,0xde,0x32,0x30,0xf0,0xf,0x1,0x1,0x28,0x8a,0xf9,0x2,0x45,0x1,0x72,0xa5,0x3b,0xc0,0xf0,0x10,0x41,0x52,0xd7,0x7c,0x40,0x91,0x44,0x8,0xc7,0x80,0xfb,0x76,0x6c,0x90,0xa4,0x19,0x36,0x3c,0x34,0x3c,0xe2,0x89,0xe1,0xa1,0x30,0xcb,0xd0,0xe4,0x20,0xd6,0xa7,0x2,0x8c,0x8e,0x71,0xe3,0x91,0x68,0x2c,0x9e,0x80,0x3e,0x48,0xc4,0x63,0xd1,0xc8,0x38,0x37,0x36,0xea,0x10,0x1,0x92,0xfc,0xc4,0xe4,0xd4,0x86,0x9f,0xf3,0x25,0x36,0xa6,0x26,0x27,0xf8,0xa4,0x8d,0x1,0x49,0x51,0xd3,0x33,0x82,0xa7,0xcf,0xe6,0xd6,0x76,0xf9,0x81,0x89,0x87,0x3b,0x9b,0x50,0x98,0x99,0xa6,0x52,0x88,0x15,0x3f,0xc1,0xcc,0x7a,0x6a,0xaf,0xec,0xee,0x3d,0x7a,0x5c,0x7d,0x62,0xe0,0x69,0xed,0xd9,0xf3,0x17,0xfb,0x95,0xc4,0x2c,0x43,0xf4,0xf2,0x0,0xd2,0x73,0xd7,0x33,0x9e,0xfe,0x7,0xf5,0x97,0xf6,0xff,0xc3,0x57,0x7,0x95,0xcc,0xfc,0x5c,0xfa,0x32,0x8,0x8c,0x67,0x17,0xbc,0xfc,0x8f,0x5e,0xd7,0x6b,0xce,0x93,0x5a,0xfd,0xcd,0xd1,0x42,0x96,0xcf,0x99,0x12,0x10,0x9c,0x5e,0xf4,0x8c,0xff,0xed,0xbb,0xf7,0xfd,0x47,0x87,0x7b,0x1f,0xe0,0x22,0x8d,0x9b,0x4,0x20,0xc4,0xdc,0xb0,0x4c,0xd,0x51,0x92,0x15,0xa8,0x4a,0x4d,0xa8,0xb6,0xba,0x47,0xc7,0x1f,0xdd,0xa4,0x9f,0x8e,0xe1,0xcd,0x7c,0xc1,0x8c,0x1,0x25,0xd8,0x98,0x65,0x69,0x9d,0x34,0x3e,0x4b,0xd,0x55,0x6a,0x59,0x4,0xa7,0x5f,0xdc,0x4,0x5f,0x4f,0x61,0x31,0x4b,0xa0,0x26,0x1,0x79,0x2b,0x6e,0x9,0x90,0xda,0x10,0x9e,0x74,0x54,0x4d,0x56,0x7b,0x4,0x67,0xe7,0x6e,0x82,0xf3,0x33,0x28,0x94,0x48,0xcc,0x24,0xe0,0x6f,0x5b,0x6f,0xa8,0x6a,0xfa,0xe7,0x42,0x54,0x5b,0x17,0x5a,0x8f,0xa0,0x5c,0x75,0x13,0x54,0xcb,0x10,0xde,0xe1,0xbb,0x4,0x64,0xd8,0x2a,0xa2,0xb6,0xa1,0x40,0xfc,0xa6,0x3b,0x7f,0x17,0x3,0x2b,0x20,0xd8,0xa2,0x65,0xd1,0x3a,0xb0,0x2d,0x2b,0x3a,0x81,0x22,0x5,0xcd,0x1,0x8,0xe5,0x6d,0xaf,0xa0,0xca,0x9a,0x2c,0xfe,0x4a,0xa0,0x16,0xf4,0x15,0xf4,0x3a,0x58,0xb2,0x99,0xda,0x9d,0xa6,0x9e,0x4b,0x5,0xc2,0xa6,0xe2,0x5d,0x7,0x4b,0x5c,0xb7,0xe,0xfe,0xba,0x12,0x8d,0x5e,0x98,0xff,0xf3,0x5e,0xb8,0x6b,0xf5,0x42,0x80,0x6e,0xdc,0x77,0x76,0xe3,0xf,0x67,0x37,0x1a,0xf3,0xe0,0xde,0xb2,0xa7,0x86,0xfe,0x79,0x90,0x59,0xbe,0x6f,0x9b,0x7,0xc6,0x44,0xa2,0x98,0x95,0x55,0x18,0x18,0xab,0x2b,0xc,0x95,0x74,0xce,0xb4,0x14,0xc1,0xb1,0x91,0x68,0x51,0xf0,0x77,0x16,0x8a,0xd1,0x8,0xcb,0x11,0xa9,0xbe,0xc1,0x8c,0x60,0x69,0x92,0xce,0x67,0x4b,0x6b,0x23,0x3e,0x58,0x2b,0x65,0xf3,0x34,0x99,0xc6,0x5c,0xbb,0x1,0x1,0x39,0xbc,0xb0,0xce,0xfb,0xef,0x5,0x7e,0xbd,0x80,0xe7,0xae,0xde,0x2d,0xfa,0x66,0xf2,0x5f,0x4c,0xfa,0x6a,0xfa,0xcd,0x66,0xfa,0x7f,0xf1,0x13,0xb7,0x71,0x36,0xc6,0x87,0x41,0xd4,0x5,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char toggle_on_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x20, 0x8, 0x3, 0x0, 0x0, 0x0, 0x95, 0x43, 0x8e, 0xb6, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x1, 0x74, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xd, 0xd, 0xf, 0x1a, 0x1a, 0x1e, 0x20, 0x20, 0x24, 0x22, 0x22, 0x27, 0x24, 0x24, 0x29, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0xa, 0xc, 0x1d, 0x1d, 0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x11, 0x11, 0x14, 0x23, 0x23, 0x28, 0x12, 0x12, 0x15, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb, 0xb, 0xd, 0x23, 0x23, 0x28, 0xb, 0xb, 0xd, 0x1e, 0x1e, 0x22, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0xe, 0x10, 0x1a, 0x1a, 0x1e, 0x1a, 0x1a, 0x1d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x20, 0x24, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0xe, 0x10, 0xb, 0xb, 0xd, 0x0, 0x0, 0x0, 0x13, 0x13, 0x15, 0x0, 0x0, 0x0, 0xb, 0xb, 0xc, 0x1d, 0x1d, 0x21, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x25, 0x25, 0x2a, 0x24, 0x24, 0x29, 0x25, 0x2c, 0x36, 0x27, 0x49, 0x65, 0x29, 0x5d, 0x85, 0x2a, 0x66, 0x95, 0x2a, 0x68, 0x99, 0x29, 0x64, 0x92, 0x28, 0x4c, 0x6b, 0x25, 0x27, 0x2d, 0x27, 0x43, 0x5c, 0x29, 0x5f, 0x89, 0x27, 0x49, 0x66, 0x25, 0x30, 0x3e, 0x25, 0x26, 0x2d, 0x25, 0x25, 0x2b, 0x25, 0x26, 0x2c, 0x25, 0x2d, 0x38, 0x25, 0x3a, 0x4c, 0x27, 0x4d, 0x6b, 0x29, 0x60, 0x8c, 0x27, 0x44, 0x5c, 0x27, 0x4b, 0x69, 0x28, 0x59, 0x7f, 0x25, 0x34, 0x43, 0x25, 0x35, 0x45, 0x28, 0x58, 0x7f, 0x25, 0x26, 0x2b, 0x27, 0x40, 0x57, 0x27, 0x41, 0x57, 0x25, 0x2a, 0x33, 0x29, 0x5d, 0x87, 0x25, 0x34, 0x44, 0x25, 0x2b, 0x34, 0x40, 0x40, 0x44, 0xad, 0xad, 0xaf, 0xff, 0xff, 0xff, 0xf2, 0xf2, 0xf2, 0x77, 0x77, 0x7a, 0x5b, 0x5b, 0x5f, 0x4e, 0x4e, 0x52, 0xc9, 0xc9, 0xca, 0x27, 0x43, 0x5b, 0x27, 0x4d, 0x6c, 0x27, 0x4e, 0x6d, 0xbb, 0xbb, 0xbd, 0x69, 0x69, 0x6c, 0x28, 0x56, 0x7b, 0x26, 0x3b, 0x4e, 0x26, 0x3a, 0x4e, 0x32, 0x32, 0x37, 0x84, 0x84, 0x87, 0xd6, 0xd6, 0xd7, 0x29, 0x61, 0x8d, 0x25, 0x2e, 0x39, 0x92, 0x92, 0x94, 0xa0, 0xa0, 0xa2, 0xe4, 0xe4, 0xe5, 0x27, 0x44, 0x5d, 0xdd, 0xc9, 0xf2, 0x7e, 0x0, 0x0, 0x0, 0x41, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x1, 0x2, 0x3, 0x4, 0x9, 0xe, 0x13, 0x16, 0x18, 0x19, 0xa, 0x26, 0x36, 0x44, 0x4d, 0x52, 0x54, 0x55, 0x6, 0x12, 0x27, 0x43, 0x80, 0xc5, 0xe7, 0xf5, 0xfe, 0x8, 0x17, 0x35, 0x73, 0xd9, 0x7, 0x3a, 0x96, 0xf9, 0x9a, 0xb, 0x28, 0x76, 0xfb, 0x77, 0xde, 0x45, 0x5, 0x82, 0xc6, 0xc6, 0x37, 0xf, 0xe9, 0x4c, 0x4e, 0x4f, 0x50, 0x83, 0x78, 0x3b, 0x9c, 0x3c, 0x74, 0xda, 0x53, 0x14, 0x37, 0x21, 0x5a, 0x6c, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x65, 0xb5, 0xdd, 0x88, 0x9f, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x2, 0x28, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xd5, 0x55, 0x69, 0x57, 0xd3, 0x40, 0x14, 0x25, 0x93, 0xa4, 0x49, 0x24, 0x49, 0xd9, 0x42, 0xd7, 0x0, 0x85, 0x50, 0x2c, 0xb4, 0x68, 0x5b, 0xab, 0x28, 0xb2, 0xc, 0x4b, 0x95, 0x82, 0x56, 0xab, 0x42, 0x45, 0x5c, 0x9b, 0xad, 0x45, 0x11, 0x6d, 0x3, 0xa8, 0x7f, 0xde, 0xc4, 0x94, 0x26, 0x69, 0x30, 0x89, 0xc7, 0x2f, 0x7a, 0x3f, 0xe4, 0x9c, 0xcc, 0x3b, 0xef, 0xce, 0x7d, 0x6f, 0xde, 0x32, 0x30, 0xf0, 0xf, 0x1, 0x1, 0x28, 0x8a, 0xf9, 0x2, 0x45, 0x1, 0x72, 0xa5, 0x3b, 0xc0, 0xf0, 0x10, 0x41, 0x52, 0xd7, 0x7c, 0x40, 0x91, 0x44, 0x8, 0xc7, 0x80, 0xfb, 0x76, 0x6c, 0x90, 0xa4, 0x19, 0x36, 0x3c, 0x34, 0x3c, 0xe2, 0x89, 0xe1, 0xa1, 0x30, 0xcb, 0xd0, 0xe4, 0x20, 0xd6, 0xa7, 0x2, 0x8c, 0x8e, 0x71, 0xe3, 0x91, 0x68, 0x2c, 0x9e, 0x80, 0x3e, 0x48, 0xc4, 0x63, 0xd1, 0xc8, 0x38, 0x37, 0x36, 0xea, 0x10, 0x1, 0x92, 0xfc, 0xc4, 0xe4, 0xd4, 0x86, 0x9f, 0xf3, 0x25, 0x36, 0xa6, 0x26, 0x27, 0xf8, 0xa4, 0x8d, 0x1, 0x49, 0x51, 0xd3, 0x33, 0x82, 0xa7, 0xcf, 0xe6, 0xd6, 0x76, 0xf9, 0x81, 0x89, 0x87, 0x3b, 0x9b, 0x50, 0x98, 0x99, 0xa6, 0x52, 0x88, 0x15, 0x3f, 0xc1, 0xcc, 0x7a, 0x6a, 0xaf, 0xec, 0xee, 0x3d, 0x7a, 0x5c, 0x7d, 0x62, 0xe0, 0x69, 0xed, 0xd9, 0xf3, 0x17, 0xfb, 0x95, 0xc4, 0x2c, 0x43, 0xf4, 0xf2, 0x0, 0xd2, 0x73, 0xd7, 0x33, 0x9e, 0xfe, 0x7, 0xf5, 0x97, 0xf6, 0xff, 0xc3, 0x57, 0x7, 0x95, 0xcc, 0xfc, 0x5c, 0xfa, 0x32, 0x8, 0x8c, 0x67, 0x17, 0xbc, 0xfc, 0x8f, 0x5e, 0xd7, 0x6b, 0xce, 0x93, 0x5a, 0xfd, 0xcd, 0xd1, 0x42, 0x96, 0xcf, 0x99, 0x12, 0x10, 0x9c, 0x5e, 0xf4, 0x8c, 0xff, 0xed, 0xbb, 0xf7, 0xfd, 0x47, 0x87, 0x7b, 0x1f, 0xe0, 0x22, 0x8d, 0x9b, 0x4, 0x20, 0xc4, 0xdc, 0xb0, 0x4c, 0xd, 0x51, 0x92, 0x15, 0xa8, 0x4a, 0x4d, 0xa8, 0xb6, 0xba, 0x47, 0xc7, 0x1f, 0xdd, 0xa4, 0x9f, 0x8e, 0xe1, 0xcd, 0x7c, 0xc1, 0x8c, 0x1, 0x25, 0xd8, 0x98, 0x65, 0x69, 0x9d, 0x34, 0x3e, 0x4b, 0xd, 0x55, 0x6a, 0x59, 0x4, 0xa7, 0x5f, 0xdc, 0x4, 0x5f, 0x4f, 0x61, 0x31, 0x4b, 0xa0, 0x26, 0x1, 0x79, 0x2b, 0x6e, 0x9, 0x90, 0xda, 0x10, 0x9e, 0x74, 0x54, 0x4d, 0x56, 0x7b, 0x4, 0x67, 0xe7, 0x6e, 0x82, 0xf3, 0x33, 0x28, 0x94, 0x48, 0xcc, 0x24, 0xe0, 0x6f, 0x5b, 0x6f, 0xa8, 0x6a, 0xfa, 0xe7, 0x42, 0x54, 0x5b, 0x17, 0x5a, 0x8f, 0xa0, 0x5c, 0x75, 0x13, 0x54, 0xcb, 0x10, 0xde, 0xe1, 0xbb, 0x4, 0x64, 0xd8, 0x2a, 0xa2, 0xb6, 0xa1, 0x40, 0xfc, 0xa6, 0x3b, 0x7f, 0x17, 0x3, 0x2b, 0x20, 0xd8, 0xa2, 0x65, 0xd1, 0x3a, 0xb0, 0x2d, 0x2b, 0x3a, 0x81, 0x22, 0x5, 0xcd, 0x1, 0x8, 0xe5, 0x6d, 0xaf, 0xa0, 0xca, 0x9a, 0x2c, 0xfe, 0x4a, 0xa0, 0x16, 0xf4, 0x15, 0xf4, 0x3a, 0x58, 0xb2, 0x99, 0xda, 0x9d, 0xa6, 0x9e, 0x4b, 0x5, 0xc2, 0xa6, 0xe2, 0x5d, 0x7, 0x4b, 0x5c, 0xb7, 0xe, 0xfe, 0xba, 0x12, 0x8d, 0x5e, 0x98, 0xff, 0xf3, 0x5e, 0xb8, 0x6b, 0xf5, 0x42, 0x80, 0x6e, 0xdc, 0x77, 0x76, 0xe3, 0xf, 0x67, 0x37, 0x1a, 0xf3, 0xe0, 0xde, 0xb2, 0xa7, 0x86, 0xfe, 0x79, 0x90, 0x59, 0xbe, 0x6f, 0x9b, 0x7, 0xc6, 0x44, 0xa2, 0x98, 0x95, 0x55, 0x18, 0x18, 0xab, 0x2b, 0xc, 0x95, 0x74, 0xce, 0xb4, 0x14, 0xc1, 0xb1, 0x91, 0x68, 0x51, 0xf0, 0x77, 0x16, 0x8a, 0xd1, 0x8, 0xcb, 0x11, 0xa9, 0xbe, 0xc1, 0x8c, 0x60, 0x69, 0x92, 0xce, 0x67, 0x4b, 0x6b, 0x23, 0x3e, 0x58, 0x2b, 0x65, 0xf3, 0x34, 0x99, 0xc6, 0x5c, 0xbb, 0x1, 0x1, 0x39, 0xbc, 0xb0, 0xce, 0xfb, 0xef, 0x5, 0x7e, 0xbd, 0x80, 0xe7, 0xae, 0xde, 0x2d, 0xfa, 0x66, 0xf2, 0x5f, 0x4c, 0xfa, 0x6a, 0xfa, 0xcd, 0x66, 0xfa, 0x7f, 0xf1, 0x13, 0xb7, 0x71, 0x36, 0xc6, 0x87, 0x41, 0xd4, 0x5, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tool_button_pressed_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x2,0x1,0x50,0x4c,0x54,0x45,0x29,0x3a,0x40,0x2d,0x3e,0x44,0x26,0x34,0x3b,0x24,0x34,0x39,0x23,0x31,0x38,0x22,0x31,0x37,0x22,0x31,0x37,0x22,0x30,0x36,0x22,0x31,0x36,0x26,0x34,0x3c,0x32,0x44,0x4c,0x26,0x34,0x39,0x23,0x31,0x36,0x21,0x2e,0x34,0x1f,0x2c,0x30,0x1f,0x2b,0x2f,0x1f,0x2a,0x2e,0x1e,0x2b,0x2f,0x1f,0x2b,0x2e,0x36,0x4b,0x52,0x25,0x33,0x38,0x20,0x2f,0x32,0x1c,0x29,0x2e,0x1b,0x26,0x2a,0x1a,0x23,0x26,0x18,0x22,0x26,0x19,0x22,0x26,0x19,0x23,0x26,0x19,0x26,0x29,0x20,0x2d,0x32,0x25,0x31,0x38,0x3c,0x51,0x59,0x23,0x31,0x37,0x1f,0x2b,0x31,0x1a,0x25,0x2b,0x17,0x20,0x24,0x15,0x1c,0x21,0x14,0x1b,0x21,0x14,0x1c,0x21,0x13,0x1b,0x21,0x15,0x1d,0x21,0x1a,0x25,0x2a,0x40,0x57,0x60,0x23,0x31,0x36,0x1f,0x2b,0x31,0x1b,0x25,0x29,0x16,0x1e,0x23,0x14,0x1b,0x1d,0x12,0x19,0x1d,0x12,0x1b,0x1d,0x14,0x1a,0x1d,0x45,0x5e,0x67,0x22,0x32,0x37,0x20,0x2d,0x31,0x1a,0x26,0x2a,0x15,0x1f,0x25,0x14,0x1c,0x1f,0x12,0x1b,0x1f,0x12,0x1b,0x20,0x14,0x1b,0x1f,0x15,0x1e,0x24,0x1a,0x25,0x29,0x4b,0x64,0x6d,0x23,0x32,0x38,0x20,0x2e,0x32,0x1b,0x27,0x2b,0x17,0x22,0x27,0x16,0x1e,0x23,0x14,0x1e,0x23,0x16,0x20,0x24,0x14,0x1e,0x22,0x15,0x1e,0x22,0x17,0x21,0x27,0x1c,0x27,0x2c,0x4f,0x6a,0x75,0x21,0x2f,0x33,0x1d,0x29,0x2d,0x19,0x23,0x2a,0x18,0x22,0x27,0x16,0x21,0x27,0x18,0x23,0x29,0x17,0x21,0x26,0x19,0x23,0x29,0x1c,0x28,0x2d,0x21,0x2e,0x33,0x54,0x70,0x7c,0x23,0x33,0x38,0x22,0x30,0x34,0x1e,0x2a,0x2f,0x1a,0x26,0x2d,0x1a,0x25,0x2b,0x19,0x25,0x2b,0x1a,0x26,0x2d,0x1a,0x26,0x2c,0x18,0x25,0x2a,0x1a,0x24,0x2a,0x1a,0x25,0x2c,0x1d,0x2a,0x2f,0x22,0x2f,0x34,0x59,0x77,0x82,0x23,0x33,0x39,0x22,0x30,0x35,0x1f,0x2c,0x31,0x1c,0x28,0x30,0x1c,0x28,0x2e,0x1b,0x29,0x2f,0x1c,0x2a,0x31,0x1b,0x28,0x2f,0x1c,0x28,0x2d,0x1b,0x27,0x2f,0x1f,0x2b,0x31,0x5e,0x7d,0x8a,0x24,0x34,0x39,0x21,0x2f,0x37,0x20,0x2d,0x34,0x1d,0x2b,0x33,0x1d,0x2b,0x32,0x1d,0x2d,0x35,0x1e,0x2e,0x36,0x1f,0x2e,0x36,0x1d,0x2b,0x34,0x1d,0x2b,0x31,0x1d,0x2b,0x32,0x20,0x2d,0x32,0x21,0x2f,0x36,0x63,0x83,0x90,0x25,0x34,0x39,0x21,0x31,0x36,0x1f,0x2e,0x34,0x1f,0x2e,0x34,0x1f,0x2e,0x36,0x20,0x31,0x39,0x21,0x33,0x3b,0x21,0x32,0x3b,0x1f,0x30,0x37,0x1f,0x2e,0x35,0x1e,0x2d,0x33,0x1f,0x2d,0x33,0x21,0x30,0x36,0x67,0x8a,0x97,0x24,0x33,0x39,0x20,0x30,0x36,0x1f,0x2f,0x35,0x21,0x30,0x37,0x22,0x32,0x39,0x21,0x35,0x3e,0x24,0x37,0x41,0x24,0x36,0x41,0x21,0x33,0x3c,0x21,0x31,0x38,0x1e,0x2f,0x35,0x1e,0x2e,0x35,0x20,0x2e,0x35,0x24,0x31,0x39,0x6c,0x90,0x9e,0x22,0x30,0x36,0x1f,0x2e,0x36,0x20,0x30,0x36,0x20,0x31,0x39,0x23,0x34,0x3d,0x23,0x37,0x41,0x26,0x3c,0x47,0x26,0x3b,0x46,0x22,0x35,0x3f,0x22,0x32,0x3b,0x1f,0x30,0x37,0x1f,0x2e,0x35,0x1f,0x2d,0x35,0x21,0x30,0x36,0x72,0x96,0xa5,0x72,0x96,0xa5,0xe8,0x14,0xaa,0x3f,0x0,0x0,0x0,0xaa,0x74,0x52,0x4e,0x53,0xc3,0xc3,0xe6,0xd7,0xcb,0xc3,0xbf,0xbe,0xbd,0xe5,0xc3,0xd7,0xc0,0xac,0xa0,0x9a,0x98,0x98,0x98,0xc3,0xcb,0xac,0x92,0x82,0x7b,0x78,0x78,0x7b,0x82,0xac,0xcb,0xc3,0xc3,0xa0,0x82,0x6f,0x67,0x64,0x63,0x64,0x67,0x82,0xc3,0xbf,0x9a,0x7a,0x67,0x5e,0x5b,0x5a,0x5e,0xc3,0xbd,0x98,0x78,0x64,0x5b,0x57,0x57,0x5b,0x64,0x78,0xc3,0xbd,0x98,0x78,0x63,0x5a,0x57,0x56,0x57,0x5a,0x63,0x77,0xc3,0x98,0x78,0x63,0x5a,0x57,0x56,0x5a,0x63,0x77,0x98,0xc3,0xbd,0x98,0x78,0x63,0x5a,0x57,0x56,0x56,0x57,0x5a,0x63,0x77,0x98,0xc3,0xbd,0x98,0x77,0x63,0x5a,0x57,0x56,0x57,0x5a,0x63,0x77,0xc3,0xbb,0x96,0x76,0x63,0x5a,0x57,0x56,0x56,0x57,0x5a,0x63,0x76,0x96,0xc3,0xb5,0x92,0x75,0x62,0x5a,0x57,0x56,0x56,0x57,0x59,0x62,0x74,0x92,0xc3,0xa9,0x8b,0x71,0x61,0x59,0x57,0x56,0x56,0x57,0x59,0x61,0x71,0x8b,0xa9,0xc3,0x95,0x7e,0x6b,0x5e,0x59,0x57,0x56,0x56,0x57,0x59,0x5e,0x6b,0x7e,0x95,0xc3,0x4f,0x78,0x99,0x30,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xa9,0x27,0xf,0x6,0x4,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xff,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0x40,0x7,0x8c,0x4c,0xcc,0x2c,0xac,0x6c,0xec,0x1c,0x1c,0x1c,0x6c,0xac,0x2c,0xcc,0x9c,0x8c,0xc,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc,0x2,0x82,0x82,0x42,0xfc,0x7c,0xbc,0x3c,0xdc,0x5c,0xc,0xc2,0x22,0xa2,0x62,0xe2,0x12,0x92,0x52,0x52,0x92,0xd2,0x32,0x62,0xb2,0x72,0xc2,0xc,0xf2,0xa,0x8a,0x4a,0xca,0x2a,0xaa,0x6a,0x6a,0xea,0x1a,0xca,0x9a,0x8a,0xa,0xf2,0xc,0x5a,0xda,0x3a,0xba,0x7a,0xfa,0x6,0x86,0x86,0x6,0x46,0x7a,0xba,0x3a,0xda,0x5a,0xc,0xc6,0x26,0xa6,0x66,0xe6,0x16,0x96,0x56,0x56,0x96,0xd6,0x36,0xb6,0xa6,0x26,0xc6,0xc,0x76,0xf6,0xe,0x8e,0x4e,0xce,0x2e,0xae,0xae,0x6e,0xee,0x1e,0x9e,0xe,0x26,0x76,0xc,0x5e,0xf6,0xde,0x3e,0xbe,0x7e,0xfe,0x1,0x1,0xfe,0x81,0x41,0xc1,0x21,0xf6,0x5e,0xc,0xa1,0x61,0xe1,0x11,0x91,0x51,0xd1,0x31,0xb1,0x71,0xf1,0x9,0x89,0x49,0x61,0xa1,0xc,0xc9,0x29,0xa9,0x69,0xe9,0x19,0x99,0x59,0x59,0xd9,0x39,0xb9,0x79,0xa9,0x29,0xc9,0xc,0xf9,0x5,0x85,0x45,0xc5,0x25,0xa5,0x65,0xe5,0x15,0x95,0x55,0xd5,0x35,0x5,0xf9,0xc,0xb5,0x75,0xf5,0xd,0x8d,0x4d,0xcd,0x2d,0xad,0x6d,0xed,0x1d,0x9d,0x5d,0x75,0xb5,0xc,0xdd,0x3d,0xbd,0x7d,0xfd,0x13,0x26,0x4e,0x9a,0x3c,0x65,0xea,0xb4,0xe9,0x33,0x66,0x76,0x33,0xcc,0x9a,0x3d,0x67,0xee,0xbc,0xf9,0xb,0x16,0x2e,0x5a,0xbc,0x64,0xe9,0xb2,0xe5,0x2b,0x66,0x31,0xac,0x44,0x3,0x0,0xa4,0xd7,0x4d,0x73,0x12,0x21,0x19,0xde,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tool_button_pressed_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x2, 0x1, 0x50, 0x4c, 0x54, 0x45, 0x29, 0x3a, 0x40, 0x2d, 0x3e, 0x44, 0x26, 0x34, 0x3b, 0x24, 0x34, 0x39, 0x23, 0x31, 0x38, 0x22, 0x31, 0x37, 0x22, 0x31, 0x37, 0x22, 0x30, 0x36, 0x22, 0x31, 0x36, 0x26, 0x34, 0x3c, 0x32, 0x44, 0x4c, 0x26, 0x34, 0x39, 0x23, 0x31, 0x36, 0x21, 0x2e, 0x34, 0x1f, 0x2c, 0x30, 0x1f, 0x2b, 0x2f, 0x1f, 0x2a, 0x2e, 0x1e, 0x2b, 0x2f, 0x1f, 0x2b, 0x2e, 0x36, 0x4b, 0x52, 0x25, 0x33, 0x38, 0x20, 0x2f, 0x32, 0x1c, 0x29, 0x2e, 0x1b, 0x26, 0x2a, 0x1a, 0x23, 0x26, 0x18, 0x22, 0x26, 0x19, 0x22, 0x26, 0x19, 0x23, 0x26, 0x19, 0x26, 0x29, 0x20, 0x2d, 0x32, 0x25, 0x31, 0x38, 0x3c, 0x51, 0x59, 0x23, 0x31, 0x37, 0x1f, 0x2b, 0x31, 0x1a, 0x25, 0x2b, 0x17, 0x20, 0x24, 0x15, 0x1c, 0x21, 0x14, 0x1b, 0x21, 0x14, 0x1c, 0x21, 0x13, 0x1b, 0x21, 0x15, 0x1d, 0x21, 0x1a, 0x25, 0x2a, 0x40, 0x57, 0x60, 0x23, 0x31, 0x36, 0x1f, 0x2b, 0x31, 0x1b, 0x25, 0x29, 0x16, 0x1e, 0x23, 0x14, 0x1b, 0x1d, 0x12, 0x19, 0x1d, 0x12, 0x1b, 0x1d, 0x14, 0x1a, 0x1d, 0x45, 0x5e, 0x67, 0x22, 0x32, 0x37, 0x20, 0x2d, 0x31, 0x1a, 0x26, 0x2a, 0x15, 0x1f, 0x25, 0x14, 0x1c, 0x1f, 0x12, 0x1b, 0x1f, 0x12, 0x1b, 0x20, 0x14, 0x1b, 0x1f, 0x15, 0x1e, 0x24, 0x1a, 0x25, 0x29, 0x4b, 0x64, 0x6d, 0x23, 0x32, 0x38, 0x20, 0x2e, 0x32, 0x1b, 0x27, 0x2b, 0x17, 0x22, 0x27, 0x16, 0x1e, 0x23, 0x14, 0x1e, 0x23, 0x16, 0x20, 0x24, 0x14, 0x1e, 0x22, 0x15, 0x1e, 0x22, 0x17, 0x21, 0x27, 0x1c, 0x27, 0x2c, 0x4f, 0x6a, 0x75, 0x21, 0x2f, 0x33, 0x1d, 0x29, 0x2d, 0x19, 0x23, 0x2a, 0x18, 0x22, 0x27, 0x16, 0x21, 0x27, 0x18, 0x23, 0x29, 0x17, 0x21, 0x26, 0x19, 0x23, 0x29, 0x1c, 0x28, 0x2d, 0x21, 0x2e, 0x33, 0x54, 0x70, 0x7c, 0x23, 0x33, 0x38, 0x22, 0x30, 0x34, 0x1e, 0x2a, 0x2f, 0x1a, 0x26, 0x2d, 0x1a, 0x25, 0x2b, 0x19, 0x25, 0x2b, 0x1a, 0x26, 0x2d, 0x1a, 0x26, 0x2c, 0x18, 0x25, 0x2a, 0x1a, 0x24, 0x2a, 0x1a, 0x25, 0x2c, 0x1d, 0x2a, 0x2f, 0x22, 0x2f, 0x34, 0x59, 0x77, 0x82, 0x23, 0x33, 0x39, 0x22, 0x30, 0x35, 0x1f, 0x2c, 0x31, 0x1c, 0x28, 0x30, 0x1c, 0x28, 0x2e, 0x1b, 0x29, 0x2f, 0x1c, 0x2a, 0x31, 0x1b, 0x28, 0x2f, 0x1c, 0x28, 0x2d, 0x1b, 0x27, 0x2f, 0x1f, 0x2b, 0x31, 0x5e, 0x7d, 0x8a, 0x24, 0x34, 0x39, 0x21, 0x2f, 0x37, 0x20, 0x2d, 0x34, 0x1d, 0x2b, 0x33, 0x1d, 0x2b, 0x32, 0x1d, 0x2d, 0x35, 0x1e, 0x2e, 0x36, 0x1f, 0x2e, 0x36, 0x1d, 0x2b, 0x34, 0x1d, 0x2b, 0x31, 0x1d, 0x2b, 0x32, 0x20, 0x2d, 0x32, 0x21, 0x2f, 0x36, 0x63, 0x83, 0x90, 0x25, 0x34, 0x39, 0x21, 0x31, 0x36, 0x1f, 0x2e, 0x34, 0x1f, 0x2e, 0x34, 0x1f, 0x2e, 0x36, 0x20, 0x31, 0x39, 0x21, 0x33, 0x3b, 0x21, 0x32, 0x3b, 0x1f, 0x30, 0x37, 0x1f, 0x2e, 0x35, 0x1e, 0x2d, 0x33, 0x1f, 0x2d, 0x33, 0x21, 0x30, 0x36, 0x67, 0x8a, 0x97, 0x24, 0x33, 0x39, 0x20, 0x30, 0x36, 0x1f, 0x2f, 0x35, 0x21, 0x30, 0x37, 0x22, 0x32, 0x39, 0x21, 0x35, 0x3e, 0x24, 0x37, 0x41, 0x24, 0x36, 0x41, 0x21, 0x33, 0x3c, 0x21, 0x31, 0x38, 0x1e, 0x2f, 0x35, 0x1e, 0x2e, 0x35, 0x20, 0x2e, 0x35, 0x24, 0x31, 0x39, 0x6c, 0x90, 0x9e, 0x22, 0x30, 0x36, 0x1f, 0x2e, 0x36, 0x20, 0x30, 0x36, 0x20, 0x31, 0x39, 0x23, 0x34, 0x3d, 0x23, 0x37, 0x41, 0x26, 0x3c, 0x47, 0x26, 0x3b, 0x46, 0x22, 0x35, 0x3f, 0x22, 0x32, 0x3b, 0x1f, 0x30, 0x37, 0x1f, 0x2e, 0x35, 0x1f, 0x2d, 0x35, 0x21, 0x30, 0x36, 0x72, 0x96, 0xa5, 0x72, 0x96, 0xa5, 0xe8, 0x14, 0xaa, 0x3f, 0x0, 0x0, 0x0, 0xaa, 0x74, 0x52, 0x4e, 0x53, 0xc3, 0xc3, 0xe6, 0xd7, 0xcb, 0xc3, 0xbf, 0xbe, 0xbd, 0xe5, 0xc3, 0xd7, 0xc0, 0xac, 0xa0, 0x9a, 0x98, 0x98, 0x98, 0xc3, 0xcb, 0xac, 0x92, 0x82, 0x7b, 0x78, 0x78, 0x7b, 0x82, 0xac, 0xcb, 0xc3, 0xc3, 0xa0, 0x82, 0x6f, 0x67, 0x64, 0x63, 0x64, 0x67, 0x82, 0xc3, 0xbf, 0x9a, 0x7a, 0x67, 0x5e, 0x5b, 0x5a, 0x5e, 0xc3, 0xbd, 0x98, 0x78, 0x64, 0x5b, 0x57, 0x57, 0x5b, 0x64, 0x78, 0xc3, 0xbd, 0x98, 0x78, 0x63, 0x5a, 0x57, 0x56, 0x57, 0x5a, 0x63, 0x77, 0xc3, 0x98, 0x78, 0x63, 0x5a, 0x57, 0x56, 0x5a, 0x63, 0x77, 0x98, 0xc3, 0xbd, 0x98, 0x78, 0x63, 0x5a, 0x57, 0x56, 0x56, 0x57, 0x5a, 0x63, 0x77, 0x98, 0xc3, 0xbd, 0x98, 0x77, 0x63, 0x5a, 0x57, 0x56, 0x57, 0x5a, 0x63, 0x77, 0xc3, 0xbb, 0x96, 0x76, 0x63, 0x5a, 0x57, 0x56, 0x56, 0x57, 0x5a, 0x63, 0x76, 0x96, 0xc3, 0xb5, 0x92, 0x75, 0x62, 0x5a, 0x57, 0x56, 0x56, 0x57, 0x59, 0x62, 0x74, 0x92, 0xc3, 0xa9, 0x8b, 0x71, 0x61, 0x59, 0x57, 0x56, 0x56, 0x57, 0x59, 0x61, 0x71, 0x8b, 0xa9, 0xc3, 0x95, 0x7e, 0x6b, 0x5e, 0x59, 0x57, 0x56, 0x56, 0x57, 0x59, 0x5e, 0x6b, 0x7e, 0x95, 0xc3, 0x4f, 0x78, 0x99, 0x30, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xa9, 0x27, 0xf, 0x6, 0x4, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xff, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0x40, 0x7, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x1c, 0x1c, 0x6c, 0xac, 0x2c, 0xcc, 0x9c, 0x8c, 0xc, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x2, 0x82, 0x82, 0x42, 0xfc, 0x7c, 0xbc, 0x3c, 0xdc, 0x5c, 0xc, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0x52, 0x92, 0xd2, 0x32, 0x62, 0xb2, 0x72, 0xc2, 0xc, 0xf2, 0xa, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0x6a, 0xea, 0x1a, 0xca, 0x9a, 0x8a, 0xa, 0xf2, 0xc, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x6, 0x86, 0x86, 0x6, 0x46, 0x7a, 0xba, 0x3a, 0xda, 0x5a, 0xc, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0x56, 0x96, 0xd6, 0x36, 0xb6, 0xa6, 0x26, 0xc6, 0xc, 0x76, 0xf6, 0xe, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0xe, 0x26, 0x76, 0xc, 0x5e, 0xf6, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x1, 0x1, 0xfe, 0x81, 0x41, 0xc1, 0x21, 0xf6, 0x5e, 0xc, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x9, 0x89, 0x49, 0x61, 0xa1, 0xc, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xa9, 0x29, 0xc9, 0xc, 0xf9, 0x5, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0x5, 0xf9, 0xc, 0xb5, 0x75, 0xf5, 0xd, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0x75, 0xb5, 0xc, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x13, 0x26, 0x4e, 0x9a, 0x3c, 0x65, 0xea, 0xb4, 0xe9, 0x33, 0x66, 0x76, 0x33, 0xcc, 0x9a, 0x3d, 0x67, 0xee, 0xbc, 0xf9, 0xb, 0x16, 0x2e, 0x5a, 0xbc, 0x64, 0xe9, 0xb2, 0xe5, 0x2b, 0x66, 0x31, 0xac, 0x44, 0x3, 0x0, 0xa4, 0xd7, 0x4d, 0x73, 0x12, 0x21, 0x19, 0xde, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tooltip_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x33,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2d,0x2c,0x2f,0x48,0x46,0x4a,0xdd,0xdd,0xdd,0x4c,0x4a,0x4e,0x48,0x46,0x4a,0x40,0x3e,0x42,0xdd,0xdd,0xdd,0xfe,0x3f,0x83,0xa9,0x0,0x0,0x0,0xd,0x74,0x52,0x4e,0x53,0xa,0x1a,0x26,0x29,0x2a,0x48,0x65,0x6d,0x6e,0x66,0xf5,0xfe,0xcc,0xff,0xb7,0x4a,0xbe,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xc,0x81,0xb3,0x51,0x63,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x44,0x49,0x44,0x41,0x54,0x18,0xd3,0xc5,0xcf,0xbb,0x15,0x0,0x20,0x8,0x43,0xd1,0x80,0x28,0xf8,0x41,0xf7,0xdf,0xd6,0x86,0x63,0xa1,0x3,0x78,0xcb,0x54,0x79,0x0,0x71,0x92,0x90,0x98,0x0,0xca,0x45,0x2d,0x68,0xc9,0x4,0xae,0xad,0x7b,0xe8,0xad,0x32,0x44,0xe7,0x1a,0x61,0x4d,0x15,0x88,0xf9,0x38,0xdc,0xfe,0xd,0xf7,0xb1,0xe7,0xfa,0x13,0x77,0xe7,0x6f,0xdc,0x6c,0x9,0x25,0x82,0x67,0x68,0x78,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tooltip_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x33, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2d, 0x2c, 0x2f, 0x48, 0x46, 0x4a, 0xdd, 0xdd, 0xdd, 0x4c, 0x4a, 0x4e, 0x48, 0x46, 0x4a, 0x40, 0x3e, 0x42, 0xdd, 0xdd, 0xdd, 0xfe, 0x3f, 0x83, 0xa9, 0x0, 0x0, 0x0, 0xd, 0x74, 0x52, 0x4e, 0x53, 0xa, 0x1a, 0x26, 0x29, 0x2a, 0x48, 0x65, 0x6d, 0x6e, 0x66, 0xf5, 0xfe, 0xcc, 0xff, 0xb7, 0x4a, 0xbe, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xc, 0x81, 0xb3, 0x51, 0x63, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x44, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0xc5, 0xcf, 0xbb, 0x15, 0x0, 0x20, 0x8, 0x43, 0xd1, 0x80, 0x28, 0xf8, 0x41, 0xf7, 0xdf, 0xd6, 0x86, 0x63, 0xa1, 0x3, 0x78, 0xcb, 0x54, 0x79, 0x0, 0x71, 0x92, 0x90, 0x98, 0x0, 0xca, 0x45, 0x2d, 0x68, 0xc9, 0x4, 0xae, 0xad, 0x7b, 0xe8, 0xad, 0x32, 0x44, 0xe7, 0x1a, 0x61, 0x4d, 0x15, 0x88, 0xf9, 0x38, 0xdc, 0xfe, 0xd, 0xf7, 0xb1, 0xe7, 0xfa, 0x13, 0x77, 0xe7, 0x6f, 0xdc, 0x6c, 0x9, 0x25, 0x82, 0x67, 0x68, 0x78, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tree_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xa,0x0,0x0,0x0,0xa,0x4,0x3,0x0,0x0,0x0,0x7f,0x1c,0xd2,0x8e,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2a,0x50,0x4c,0x54,0x45,0x17,0x16,0x1a,0x1d,0x1c,0x21,0x20,0x1e,0x24,0x21,0x1f,0x25,0x1d,0x1c,0x21,0x20,0x1e,0x24,0x1d,0x1c,0x21,0x1d,0x1c,0x21,0x24,0x22,0x29,0x28,0x26,0x2d,0x28,0x26,0x2e,0x2b,0x2a,0x31,0x2c,0x2a,0x32,0xff,0xff,0xff,0xb9,0x11,0x56,0x3e,0x0,0x0,0x0,0x8,0x74,0x52,0x4e,0x53,0x6f,0xef,0xf7,0xf7,0xf0,0xf9,0xf1,0xee,0xcf,0x21,0xd2,0xdf,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0xd,0xf6,0xb4,0x61,0xf5,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x2d,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x54,0x36,0x36,0x12,0x60,0xf0,0x98,0xb5,0x6a,0x65,0xb,0x43,0xe4,0x9e,0x33,0xa7,0xa7,0x32,0x58,0x9d,0x39,0x73,0x66,0x31,0x16,0x12,0x22,0xb,0x52,0xd9,0xc6,0xc0,0x2,0xd4,0x55,0x0,0x0,0xc,0x14,0x1a,0x90,0x55,0x1a,0xec,0xdb,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tree_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0xa, 0x4, 0x3, 0x0, 0x0, 0x0, 0x7f, 0x1c, 0xd2, 0x8e, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2a, 0x50, 0x4c, 0x54, 0x45, 0x17, 0x16, 0x1a, 0x1d, 0x1c, 0x21, 0x20, 0x1e, 0x24, 0x21, 0x1f, 0x25, 0x1d, 0x1c, 0x21, 0x20, 0x1e, 0x24, 0x1d, 0x1c, 0x21, 0x1d, 0x1c, 0x21, 0x24, 0x22, 0x29, 0x28, 0x26, 0x2d, 0x28, 0x26, 0x2e, 0x2b, 0x2a, 0x31, 0x2c, 0x2a, 0x32, 0xff, 0xff, 0xff, 0xb9, 0x11, 0x56, 0x3e, 0x0, 0x0, 0x0, 0x8, 0x74, 0x52, 0x4e, 0x53, 0x6f, 0xef, 0xf7, 0xf7, 0xf0, 0xf9, 0xf1, 0xee, 0xcf, 0x21, 0xd2, 0xdf, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xd, 0xf6, 0xb4, 0x61, 0xf5, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x2d, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x54, 0x36, 0x36, 0x12, 0x60, 0xf0, 0x98, 0xb5, 0x6a, 0x65, 0xb, 0x43, 0xe4, 0x9e, 0x33, 0xa7, 0xa7, 0x32, 0x58, 0x9d, 0x39, 0x73, 0x66, 0x31, 0x16, 0x12, 0x22, 0xb, 0x52, 0xd9, 0xc6, 0xc0, 0x2, 0xd4, 0x55, 0x0, 0x0, 0xc, 0x14, 0x1a, 0x90, 0x55, 0x1a, 0xec, 0xdb, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tree_bg_focus_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x6,0x0,0x0,0x0,0x73,0x7a,0x7a,0xf4,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdb,0xb,0x4,0x12,0x2d,0x3a,0xb5,0x1b,0x14,0x49,0x0,0x0,0x2,0xd9,0x49,0x44,0x41,0x54,0x58,0xc3,0xc5,0x57,0x31,0x8e,0x14,0x31,0x10,0xac,0xea,0x3d,0x11,0x91,0xdf,0x49,0xf7,0xf,0x78,0x1,0xf,0x40,0x84,0x44,0x10,0xf2,0x20,0x42,0x62,0x12,0xc4,0x3,0x78,0x1,0xff,0x21,0x42,0xb8,0x8a,0xc0,0x1e,0x4f,0xdb,0xe3,0xb9,0xbb,0x45,0x20,0x7c,0x1a,0xdd,0x8c,0xec,0xed,0xae,0xae,0xea,0xee,0xe9,0xe1,0xfd,0xed,0xdd,0xb,0x0,0xdf,0xf1,0x7f,0xd6,0x4b,0xde,0xdf,0xde,0xf9,0xcb,0xeb,0x9f,0xff,0xc5,0xfb,0x9b,0xaf,0xcf,0x70,0xb3,0x3d,0x3c,0xff,0xf0,0xd,0x24,0x11,0x71,0x1,0x49,0x90,0x4,0x0,0x4,0xd3,0x2f,0xb6,0x7b,0xf,0xff,0x86,0x2d,0x8c,0x47,0x60,0x1b,0x0,0x61,0x1b,0xb6,0x21,0x15,0xd8,0xc6,0x8f,0x8f,0xaf,0x0,0x60,0x7,0x0,0xa2,0x2,0x20,0x11,0x41,0x30,0xa2,0x2,0xc1,0xb5,0x0,0x8c,0x79,0xd9,0x80,0x24,0x48,0x0,0x48,0x28,0x9d,0xb9,0xd9,0xd,0xb0,0x31,0x40,0x5c,0x2e,0x1,0x46,0x0,0xd,0xd0,0xb6,0xef,0x35,0x8e,0x13,0x6,0xbc,0x33,0x60,0xa3,0x9a,0x11,0x6c,0x82,0xe6,0xa,0x0,0x86,0xe8,0x2f,0x71,0xa9,0xf7,0x9c,0x4d,0x1f,0x69,0x5e,0x1,0xd8,0xa3,0x37,0xa4,0xa,0x27,0x1a,0x13,0x79,0x25,0x9,0xaa,0xe3,0xd8,0x9c,0x5f,0xea,0x7d,0x67,0x80,0xd7,0x31,0x20,0xab,0x3,0x20,0x5,0x20,0x2a,0x13,0x41,0x40,0x2b,0x0,0x76,0x22,0xb9,0xb1,0xd1,0x92,0x91,0x5d,0x86,0xf3,0x35,0xef,0x5,0xa3,0x25,0x60,0xd,0x6e,0x66,0xe5,0x0,0xc0,0xa8,0x54,0x1,0x6,0xe9,0x16,0x9f,0x4f,0xdc,0x1c,0x13,0xed,0xb1,0x55,0x31,0x78,0x70,0x8e,0xca,0xcb,0x8e,0x6a,0xbe,0x56,0x88,0x67,0x38,0xdb,0x75,0x58,0x76,0xdf,0x1b,0x6c,0x7a,0xc,0x6c,0x90,0x0,0xfd,0xe0,0xe8,0x98,0xe4,0x4,0xe2,0x69,0xc,0xe4,0x40,0xaa,0xf9,0x63,0x70,0xbb,0x4,0x16,0x9c,0x12,0xa7,0x3e,0xe7,0x38,0xb3,0x4,0x2b,0x6f,0xc7,0x23,0xbb,0xc3,0x66,0xdb,0x38,0x7,0x0,0xcf,0x32,0x34,0xb6,0x52,0xb4,0x3c,0xf7,0x35,0x10,0xd9,0xf7,0x6,0x56,0x93,0x4,0x4b,0x0,0x43,0x28,0xf9,0x4a,0x3d,0x6e,0xb0,0x3e,0x9,0x31,0xa9,0x62,0xd6,0xc4,0x36,0x9c,0xf2,0xd9,0xbd,0x41,0x2d,0x24,0x68,0xc7,0x1f,0x62,0x60,0x6a,0xc1,0x7f,0x95,0x81,0xaa,0x13,0x61,0x9,0xa6,0xf6,0x1c,0x30,0x17,0x11,0x6f,0x48,0x12,0x3b,0xf3,0x7b,0xc2,0xeb,0xca,0x92,0xb7,0x72,0x5f,0x31,0x90,0x11,0x4e,0x48,0xb3,0x13,0xa6,0xcc,0x3e,0x51,0x60,0x91,0x53,0x55,0x87,0xf3,0x2a,0x98,0xff,0x7c,0x6c,0x1a,0xf9,0xec,0xda,0xeb,0x94,0x13,0x43,0xdd,0x3f,0x2a,0x41,0xd2,0xb,0x27,0x65,0xe8,0x13,0x20,0x29,0x3f,0xc6,0x7c,0x48,0x65,0x8,0x41,0xda,0xa4,0xd5,0x11,0xc0,0x2a,0x61,0xce,0x18,0x58,0xd2,0xbe,0x98,0x48,0x96,0xdd,0xf5,0xbc,0x11,0x65,0xb6,0x12,0x55,0xcb,0xde,0xb3,0x78,0x27,0x78,0xdc,0xcb,0x72,0xe6,0xd7,0x8a,0x27,0xe6,0x52,0x1f,0x10,0xe0,0xb8,0x92,0x81,0xb4,0x3f,0x1,0x1d,0xed,0x6c,0xd4,0xef,0x12,0x2f,0x73,0xa0,0xe,0xf,0x42,0x24,0x20,0xf,0x91,0xbf,0x6e,0x44,0xfb,0xde,0xa1,0x4,0xa5,0x7,0xaa,0xa0,0x23,0xad,0xd4,0x4b,0xaa,0x73,0x0,0xb7,0xa1,0x82,0x87,0x46,0x74,0x9a,0xf,0x48,0x5d,0xb3,0xd,0xa2,0xb0,0x96,0xe5,0x7d,0xc8,0x81,0x19,0xf1,0x36,0x2b,0xba,0xbd,0x5e,0xb3,0xb7,0x55,0x12,0x76,0x90,0xc4,0x3a,0x1,0xa7,0x66,0xbc,0x3,0x90,0xe0,0x8,0xc8,0x42,0x29,0xa5,0x7b,0xa2,0x63,0x9f,0x88,0x26,0xa,0x9c,0x85,0x6f,0x7b,0x2b,0x0,0x92,0x51,0x4a,0x81,0x5c,0x2a,0xcb,0x2a,0x47,0x0,0xb0,0x2b,0x8,0x11,0x62,0x20,0x58,0x20,0x47,0x77,0x5a,0xe5,0x98,0x43,0x3f,0x2,0xd8,0xc1,0xa5,0x39,0x40,0x82,0xb5,0xd9,0xd7,0x5a,0x2,0x59,0x80,0x9,0x8a,0x0,0x7f,0x1,0x8,0x44,0x8,0x64,0xe0,0xe8,0x6e,0x4b,0xb4,0x87,0xa6,0xc4,0x3d,0x17,0x24,0xa3,0xa8,0xc0,0x32,0x8a,0xea,0x33,0x67,0x0,0x6e,0xc,0x94,0x5e,0xe2,0x46,0x11,0x3a,0x0,0x82,0x57,0x1,0x98,0xbf,0xb,0xa4,0xf6,0x55,0xd4,0x2a,0xe1,0x0,0x40,0xf5,0xf3,0xa5,0xd3,0x16,0x6a,0xb4,0xa7,0x19,0xfa,0x4f,0x18,0xe8,0x2c,0x34,0xfb,0x92,0x20,0xbb,0xf,0xa3,0x1d,0xc0,0xcd,0xe7,0xb7,0x83,0xf9,0xf2,0x24,0xd3,0xd7,0xaf,0x40,0x9a,0x84,0x1,0xf0,0xfe,0xf6,0xee,0x1d,0x80,0x4f,0xff,0xc8,0xdf,0x63,0xeb,0xfd,0x6f,0x3,0x74,0x35,0xa7,0x2a,0xf0,0x17,0xed,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tree_bg_focus_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x20, 0x8, 0x6, 0x0, 0x0, 0x0, 0x73, 0x7a, 0x7a, 0xf4, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xdb, 0xb, 0x4, 0x12, 0x2d, 0x3a, 0xb5, 0x1b, 0x14, 0x49, 0x0, 0x0, 0x2, 0xd9, 0x49, 0x44, 0x41, 0x54, 0x58, 0xc3, 0xc5, 0x57, 0x31, 0x8e, 0x14, 0x31, 0x10, 0xac, 0xea, 0x3d, 0x11, 0x91, 0xdf, 0x49, 0xf7, 0xf, 0x78, 0x1, 0xf, 0x40, 0x84, 0x44, 0x10, 0xf2, 0x20, 0x42, 0x62, 0x12, 0xc4, 0x3, 0x78, 0x1, 0xff, 0x21, 0x42, 0xb8, 0x8a, 0xc0, 0x1e, 0x4f, 0xdb, 0xe3, 0xb9, 0xbb, 0x45, 0x20, 0x7c, 0x1a, 0xdd, 0x8c, 0xec, 0xed, 0xae, 0xae, 0xea, 0xee, 0xe9, 0xe1, 0xfd, 0xed, 0xdd, 0xb, 0x0, 0xdf, 0xf1, 0x7f, 0xd6, 0x4b, 0xde, 0xdf, 0xde, 0xf9, 0xcb, 0xeb, 0x9f, 0xff, 0xc5, 0xfb, 0x9b, 0xaf, 0xcf, 0x70, 0xb3, 0x3d, 0x3c, 0xff, 0xf0, 0xd, 0x24, 0x11, 0x71, 0x1, 0x49, 0x90, 0x4, 0x0, 0x4, 0xd3, 0x2f, 0xb6, 0x7b, 0xf, 0xff, 0x86, 0x2d, 0x8c, 0x47, 0x60, 0x1b, 0x0, 0x61, 0x1b, 0xb6, 0x21, 0x15, 0xd8, 0xc6, 0x8f, 0x8f, 0xaf, 0x0, 0x60, 0x7, 0x0, 0xa2, 0x2, 0x20, 0x11, 0x41, 0x30, 0xa2, 0x2, 0xc1, 0xb5, 0x0, 0x8c, 0x79, 0xd9, 0x80, 0x24, 0x48, 0x0, 0x48, 0x28, 0x9d, 0xb9, 0xd9, 0xd, 0xb0, 0x31, 0x40, 0x5c, 0x2e, 0x1, 0x46, 0x0, 0xd, 0xd0, 0xb6, 0xef, 0x35, 0x8e, 0x13, 0x6, 0xbc, 0x33, 0x60, 0xa3, 0x9a, 0x11, 0x6c, 0x82, 0xe6, 0xa, 0x0, 0x86, 0xe8, 0x2f, 0x71, 0xa9, 0xf7, 0x9c, 0x4d, 0x1f, 0x69, 0x5e, 0x1, 0xd8, 0xa3, 0x37, 0xa4, 0xa, 0x27, 0x1a, 0x13, 0x79, 0x25, 0x9, 0xaa, 0xe3, 0xd8, 0x9c, 0x5f, 0xea, 0x7d, 0x67, 0x80, 0xd7, 0x31, 0x20, 0xab, 0x3, 0x20, 0x5, 0x20, 0x2a, 0x13, 0x41, 0x40, 0x2b, 0x0, 0x76, 0x22, 0xb9, 0xb1, 0xd1, 0x92, 0x91, 0x5d, 0x86, 0xf3, 0x35, 0xef, 0x5, 0xa3, 0x25, 0x60, 0xd, 0x6e, 0x66, 0xe5, 0x0, 0xc0, 0xa8, 0x54, 0x1, 0x6, 0xe9, 0x16, 0x9f, 0x4f, 0xdc, 0x1c, 0x13, 0xed, 0xb1, 0x55, 0x31, 0x78, 0x70, 0x8e, 0xca, 0xcb, 0x8e, 0x6a, 0xbe, 0x56, 0x88, 0x67, 0x38, 0xdb, 0x75, 0x58, 0x76, 0xdf, 0x1b, 0x6c, 0x7a, 0xc, 0x6c, 0x90, 0x0, 0xfd, 0xe0, 0xe8, 0x98, 0xe4, 0x4, 0xe2, 0x69, 0xc, 0xe4, 0x40, 0xaa, 0xf9, 0x63, 0x70, 0xbb, 0x4, 0x16, 0x9c, 0x12, 0xa7, 0x3e, 0xe7, 0x38, 0xb3, 0x4, 0x2b, 0x6f, 0xc7, 0x23, 0xbb, 0xc3, 0x66, 0xdb, 0x38, 0x7, 0x0, 0xcf, 0x32, 0x34, 0xb6, 0x52, 0xb4, 0x3c, 0xf7, 0x35, 0x10, 0xd9, 0xf7, 0x6, 0x56, 0x93, 0x4, 0x4b, 0x0, 0x43, 0x28, 0xf9, 0x4a, 0x3d, 0x6e, 0xb0, 0x3e, 0x9, 0x31, 0xa9, 0x62, 0xd6, 0xc4, 0x36, 0x9c, 0xf2, 0xd9, 0xbd, 0x41, 0x2d, 0x24, 0x68, 0xc7, 0x1f, 0x62, 0x60, 0x6a, 0xc1, 0x7f, 0x95, 0x81, 0xaa, 0x13, 0x61, 0x9, 0xa6, 0xf6, 0x1c, 0x30, 0x17, 0x11, 0x6f, 0x48, 0x12, 0x3b, 0xf3, 0x7b, 0xc2, 0xeb, 0xca, 0x92, 0xb7, 0x72, 0x5f, 0x31, 0x90, 0x11, 0x4e, 0x48, 0xb3, 0x13, 0xa6, 0xcc, 0x3e, 0x51, 0x60, 0x91, 0x53, 0x55, 0x87, 0xf3, 0x2a, 0x98, 0xff, 0x7c, 0x6c, 0x1a, 0xf9, 0xec, 0xda, 0xeb, 0x94, 0x13, 0x43, 0xdd, 0x3f, 0x2a, 0x41, 0xd2, 0xb, 0x27, 0x65, 0xe8, 0x13, 0x20, 0x29, 0x3f, 0xc6, 0x7c, 0x48, 0x65, 0x8, 0x41, 0xda, 0xa4, 0xd5, 0x11, 0xc0, 0x2a, 0x61, 0xce, 0x18, 0x58, 0xd2, 0xbe, 0x98, 0x48, 0x96, 0xdd, 0xf5, 0xbc, 0x11, 0x65, 0xb6, 0x12, 0x55, 0xcb, 0xde, 0xb3, 0x78, 0x27, 0x78, 0xdc, 0xcb, 0x72, 0xe6, 0xd7, 0x8a, 0x27, 0xe6, 0x52, 0x1f, 0x10, 0xe0, 0xb8, 0x92, 0x81, 0xb4, 0x3f, 0x1, 0x1d, 0xed, 0x6c, 0xd4, 0xef, 0x12, 0x2f, 0x73, 0xa0, 0xe, 0xf, 0x42, 0x24, 0x20, 0xf, 0x91, 0xbf, 0x6e, 0x44, 0xfb, 0xde, 0xa1, 0x4, 0xa5, 0x7, 0xaa, 0xa0, 0x23, 0xad, 0xd4, 0x4b, 0xaa, 0x73, 0x0, 0xb7, 0xa1, 0x82, 0x87, 0x46, 0x74, 0x9a, 0xf, 0x48, 0x5d, 0xb3, 0xd, 0xa2, 0xb0, 0x96, 0xe5, 0x7d, 0xc8, 0x81, 0x19, 0xf1, 0x36, 0x2b, 0xba, 0xbd, 0x5e, 0xb3, 0xb7, 0x55, 0x12, 0x76, 0x90, 0xc4, 0x3a, 0x1, 0xa7, 0x66, 0xbc, 0x3, 0x90, 0xe0, 0x8, 0xc8, 0x42, 0x29, 0xa5, 0x7b, 0xa2, 0x63, 0x9f, 0x88, 0x26, 0xa, 0x9c, 0x85, 0x6f, 0x7b, 0x2b, 0x0, 0x92, 0x51, 0x4a, 0x81, 0x5c, 0x2a, 0xcb, 0x2a, 0x47, 0x0, 0xb0, 0x2b, 0x8, 0x11, 0x62, 0x20, 0x58, 0x20, 0x47, 0x77, 0x5a, 0xe5, 0x98, 0x43, 0x3f, 0x2, 0xd8, 0xc1, 0xa5, 0x39, 0x40, 0x82, 0xb5, 0xd9, 0xd7, 0x5a, 0x2, 0x59, 0x80, 0x9, 0x8a, 0x0, 0x7f, 0x1, 0x8, 0x44, 0x8, 0x64, 0xe0, 0xe8, 0x6e, 0x4b, 0xb4, 0x87, 0xa6, 0xc4, 0x3d, 0x17, 0x24, 0xa3, 0xa8, 0xc0, 0x32, 0x8a, 0xea, 0x33, 0x67, 0x0, 0x6e, 0xc, 0x94, 0x5e, 0xe2, 0x46, 0x11, 0x3a, 0x0, 0x82, 0x57, 0x1, 0x98, 0xbf, 0xb, 0xa4, 0xf6, 0x55, 0xd4, 0x2a, 0xe1, 0x0, 0x40, 0xf5, 0xf3, 0xa5, 0xd3, 0x16, 0x6a, 0xb4, 0xa7, 0x19, 0xfa, 0x4f, 0x18, 0xe8, 0x2c, 0x34, 0xfb, 0x92, 0x20, 0xbb, 0xf, 0xa3, 0x1d, 0xc0, 0xcd, 0xe7, 0xb7, 0x83, 0xf9, 0xf2, 0x24, 0xd3, 0xd7, 0xaf, 0x40, 0x9a, 0x84, 0x1, 0xf0, 0xfe, 0xf6, 0xee, 0x1d, 0x80, 0x4f, 0xff, 0xc8, 0xdf, 0x63, 0xeb, 0xfd, 0x6f, 0x3, 0x74, 0x35, 0xa7, 0x2a, 0xf0, 0x17, 0xed, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tree_cursor_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xe,0x0,0x0,0x0,0xe,0x8,0x3,0x0,0x0,0x0,0x28,0x96,0xdd,0xe3,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xc6,0x50,0x4c,0x54,0x45,0xd4,0xab,0x9e,0xd3,0xaa,0x9d,0xd4,0xab,0x9e,0xd3,0xaa,0x9d,0xd4,0xab,0x9c,0xd4,0xac,0x9e,0xd5,0xaf,0xa3,0xd5,0xb0,0xa3,0xd5,0xaf,0xa3,0xd5,0xad,0xa1,0xd5,0xaf,0xa3,0xd5,0xad,0xa1,0xd5,0xb0,0xa3,0xd6,0xad,0xa0,0xd6,0xad,0xa0,0xd5,0xb0,0xa3,0xd7,0xb1,0xa5,0xd7,0xb1,0xa7,0xd7,0xb1,0xa7,0xd7,0xb1,0xa7,0xd7,0xb1,0xa7,0xd7,0xb1,0xa5,0xd7,0xb1,0xa5,0xd8,0xb3,0xa8,0xd8,0xb5,0xaa,0xda,0xb3,0xa8,0xda,0xb3,0xa8,0xd8,0xb3,0xa8,0xd8,0xb5,0xaa,0xda,0xb3,0xa8,0xd8,0xb3,0xa8,0xdb,0xb7,0xad,0xda,0xb8,0xae,0xdb,0xb9,0xad,0xdb,0xb9,0xad,0xdb,0xb7,0xad,0xdd,0xba,0xb1,0xdd,0xbb,0xb1,0xdd,0xbd,0xb1,0xdd,0xbf,0xb3,0xdd,0xbd,0xb3,0xdf,0xc1,0xb7,0xdf,0xc0,0xb5,0xdf,0xbf,0xb5,0xe1,0xc3,0xb9,0xe1,0xc3,0xbb,0xe1,0xc5,0xbb,0xe2,0xc7,0xbe,0xe1,0xc5,0xbd,0xe4,0xcb,0xc2,0xe3,0xca,0xc1,0xe3,0xcb,0xc3,0xe6,0xce,0xc6,0xe6,0xd0,0xc6,0xe8,0xd1,0xca,0xe8,0xd1,0xca,0xe8,0xd0,0xca,0xe8,0xcf,0xca,0xb7,0x7d,0x69,0xb1,0x77,0x63,0xac,0x73,0x5c,0xa6,0x69,0x56,0x9c,0x67,0x54,0x93,0x62,0x51,0x88,0x60,0x50,0x0,0x0,0x0,0x39,0x76,0x1d,0xc2,0x0,0x0,0x0,0x3a,0x74,0x52,0x4e,0x53,0x32,0x2f,0x30,0x33,0x38,0x40,0x32,0x2f,0x2f,0x2f,0x31,0x33,0x33,0x33,0x36,0x38,0x31,0x2f,0x30,0x31,0x33,0x33,0x35,0x2f,0x2f,0x2f,0x30,0x32,0x33,0x33,0x33,0x2f,0x2f,0x2f,0x30,0x30,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x32,0x2f,0x2f,0x2f,0xb8,0xf,0x95,0x41,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x41,0x89,0xde,0x6c,0x4e,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x9e,0x49,0x44,0x41,0x54,0x8,0xd7,0x55,0xcf,0x5b,0x17,0x81,0x40,0x14,0x5,0xe0,0xe3,0x9a,0x4b,0x2e,0x31,0x14,0x62,0x22,0x53,0x4d,0x83,0x44,0xc,0xa6,0xa9,0xf9,0xff,0xbf,0xca,0xd4,0x5a,0x1e,0x7c,0xfb,0xec,0xb5,0x9f,0xf,0x7c,0xfe,0x80,0x80,0x86,0xd6,0x6c,0x69,0xed,0x8e,0x80,0xbc,0x6b,0x18,0xbd,0xfe,0x60,0x68,0x9a,0xa3,0xf1,0x24,0x7,0x39,0xb5,0x2c,0x6b,0x36,0x47,0x68,0x81,0xd0,0x52,0x42,0x61,0x3b,0xb6,0xb3,0x72,0xd6,0x1b,0x77,0xeb,0xee,0xa,0x28,0x31,0xc6,0x9e,0x87,0x3d,0xbc,0x3f,0xf8,0x7e,0x9,0xea,0x48,0x8,0x9,0xc2,0x28,0x22,0x21,0x9,0x14,0x28,0x1a,0x33,0x16,0xd3,0x98,0xb2,0x98,0x51,0x5,0xe5,0x49,0x3b,0xeb,0x5e,0x74,0x4a,0x28,0x92,0xca,0xb5,0xbe,0xa4,0x0,0x99,0xde,0xd2,0xca,0xbd,0x5a,0x9,0x79,0x96,0x3d,0xb2,0x9f,0x1c,0xc4,0x93,0xf3,0x17,0xaf,0xfb,0xe6,0x2,0xfe,0x5f,0xf8,0x2,0x30,0xbc,0x1f,0xb4,0x2b,0xfc,0x80,0xca,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tree_cursor_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0xe, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x96, 0xdd, 0xe3, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xc6, 0x50, 0x4c, 0x54, 0x45, 0xd4, 0xab, 0x9e, 0xd3, 0xaa, 0x9d, 0xd4, 0xab, 0x9e, 0xd3, 0xaa, 0x9d, 0xd4, 0xab, 0x9c, 0xd4, 0xac, 0x9e, 0xd5, 0xaf, 0xa3, 0xd5, 0xb0, 0xa3, 0xd5, 0xaf, 0xa3, 0xd5, 0xad, 0xa1, 0xd5, 0xaf, 0xa3, 0xd5, 0xad, 0xa1, 0xd5, 0xb0, 0xa3, 0xd6, 0xad, 0xa0, 0xd6, 0xad, 0xa0, 0xd5, 0xb0, 0xa3, 0xd7, 0xb1, 0xa5, 0xd7, 0xb1, 0xa7, 0xd7, 0xb1, 0xa7, 0xd7, 0xb1, 0xa7, 0xd7, 0xb1, 0xa7, 0xd7, 0xb1, 0xa5, 0xd7, 0xb1, 0xa5, 0xd8, 0xb3, 0xa8, 0xd8, 0xb5, 0xaa, 0xda, 0xb3, 0xa8, 0xda, 0xb3, 0xa8, 0xd8, 0xb3, 0xa8, 0xd8, 0xb5, 0xaa, 0xda, 0xb3, 0xa8, 0xd8, 0xb3, 0xa8, 0xdb, 0xb7, 0xad, 0xda, 0xb8, 0xae, 0xdb, 0xb9, 0xad, 0xdb, 0xb9, 0xad, 0xdb, 0xb7, 0xad, 0xdd, 0xba, 0xb1, 0xdd, 0xbb, 0xb1, 0xdd, 0xbd, 0xb1, 0xdd, 0xbf, 0xb3, 0xdd, 0xbd, 0xb3, 0xdf, 0xc1, 0xb7, 0xdf, 0xc0, 0xb5, 0xdf, 0xbf, 0xb5, 0xe1, 0xc3, 0xb9, 0xe1, 0xc3, 0xbb, 0xe1, 0xc5, 0xbb, 0xe2, 0xc7, 0xbe, 0xe1, 0xc5, 0xbd, 0xe4, 0xcb, 0xc2, 0xe3, 0xca, 0xc1, 0xe3, 0xcb, 0xc3, 0xe6, 0xce, 0xc6, 0xe6, 0xd0, 0xc6, 0xe8, 0xd1, 0xca, 0xe8, 0xd1, 0xca, 0xe8, 0xd0, 0xca, 0xe8, 0xcf, 0xca, 0xb7, 0x7d, 0x69, 0xb1, 0x77, 0x63, 0xac, 0x73, 0x5c, 0xa6, 0x69, 0x56, 0x9c, 0x67, 0x54, 0x93, 0x62, 0x51, 0x88, 0x60, 0x50, 0x0, 0x0, 0x0, 0x39, 0x76, 0x1d, 0xc2, 0x0, 0x0, 0x0, 0x3a, 0x74, 0x52, 0x4e, 0x53, 0x32, 0x2f, 0x30, 0x33, 0x38, 0x40, 0x32, 0x2f, 0x2f, 0x2f, 0x31, 0x33, 0x33, 0x33, 0x36, 0x38, 0x31, 0x2f, 0x30, 0x31, 0x33, 0x33, 0x35, 0x2f, 0x2f, 0x2f, 0x30, 0x32, 0x33, 0x33, 0x33, 0x2f, 0x2f, 0x2f, 0x30, 0x30, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x32, 0x2f, 0x2f, 0x2f, 0xb8, 0xf, 0x95, 0x41, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x41, 0x89, 0xde, 0x6c, 0x4e, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x9e, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x55, 0xcf, 0x5b, 0x17, 0x81, 0x40, 0x14, 0x5, 0xe0, 0xe3, 0x9a, 0x4b, 0x2e, 0x31, 0x14, 0x62, 0x22, 0x53, 0x4d, 0x83, 0x44, 0xc, 0xa6, 0xa9, 0xf9, 0xff, 0xbf, 0xca, 0xd4, 0x5a, 0x1e, 0x7c, 0xfb, 0xec, 0xb5, 0x9f, 0xf, 0x7c, 0xfe, 0x80, 0x80, 0x86, 0xd6, 0x6c, 0x69, 0xed, 0x8e, 0x80, 0xbc, 0x6b, 0x18, 0xbd, 0xfe, 0x60, 0x68, 0x9a, 0xa3, 0xf1, 0x24, 0x7, 0x39, 0xb5, 0x2c, 0x6b, 0x36, 0x47, 0x68, 0x81, 0xd0, 0x52, 0x42, 0x61, 0x3b, 0xb6, 0xb3, 0x72, 0xd6, 0x1b, 0x77, 0xeb, 0xee, 0xa, 0x28, 0x31, 0xc6, 0x9e, 0x87, 0x3d, 0xbc, 0x3f, 0xf8, 0x7e, 0x9, 0xea, 0x48, 0x8, 0x9, 0xc2, 0x28, 0x22, 0x21, 0x9, 0x14, 0x28, 0x1a, 0x33, 0x16, 0xd3, 0x98, 0xb2, 0x98, 0x51, 0x5, 0xe5, 0x49, 0x3b, 0xeb, 0x5e, 0x74, 0x4a, 0x28, 0x92, 0xca, 0xb5, 0xbe, 0xa4, 0x0, 0x99, 0xde, 0xd2, 0xca, 0xbd, 0x5a, 0x9, 0x79, 0x96, 0x3d, 0xb2, 0x9f, 0x1c, 0xc4, 0x93, 0xf3, 0x17, 0xaf, 0xfb, 0xe6, 0x2, 0xfe, 0x5f, 0xf8, 0x2, 0x30, 0xbc, 0x1f, 0xb4, 0x2b, 0xfc, 0x80, 0xca, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tree_cursor_unfocus_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xe,0x0,0x0,0x0,0xe,0x8,0x3,0x0,0x0,0x0,0x28,0x96,0xdd,0xe3,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x99,0x50,0x4c,0x54,0x45,0xc0,0xb5,0xb2,0xbf,0xb4,0xb1,0xc0,0xb5,0xb2,0xbf,0xb4,0xb1,0xbf,0xb5,0xb1,0xc0,0xb5,0xb2,0xc3,0xb8,0xb5,0xc3,0xb8,0xb5,0xc2,0xb7,0xb4,0xc3,0xb8,0xb5,0xc2,0xb7,0xb4,0xc3,0xb8,0xb5,0xc2,0xb7,0xb4,0xc3,0xb8,0xb5,0xc5,0xba,0xb7,0xc5,0xbc,0xb9,0xc5,0xbc,0xb9,0xc5,0xbc,0xb9,0xc5,0xbc,0xb9,0xc5,0xba,0xb7,0xc5,0xba,0xb7,0xc6,0xbd,0xba,0xc7,0xbe,0xbb,0xc7,0xbe,0xbb,0xc6,0xbd,0xba,0xc7,0xbe,0xbb,0xc6,0xbd,0xba,0xca,0xc1,0xbe,0xca,0xc1,0xbe,0xcd,0xc4,0xc1,0xcd,0xc6,0xc3,0xd0,0xc9,0xc6,0xcf,0xc8,0xc5,0xd2,0xcb,0xc8,0xd3,0xcb,0xc9,0xd3,0xcc,0xc9,0xd5,0xcd,0xcb,0xd4,0xcc,0xca,0xd7,0xd1,0xcf,0xd6,0xd0,0xce,0xda,0xd4,0xd2,0xdd,0xd7,0xd5,0xdd,0xd7,0xd5,0x9a,0x8b,0x86,0x94,0x85,0x80,0x8e,0x80,0x7a,0x88,0x79,0x74,0x81,0x75,0x6f,0x7a,0x6f,0x6a,0x73,0x69,0x65,0x0,0x0,0x0,0xfb,0x87,0x71,0x8e,0x0,0x0,0x0,0x2b,0x74,0x52,0x4e,0x53,0x32,0x2f,0x30,0x33,0x38,0x40,0x32,0x2f,0x2f,0x31,0x33,0x33,0x36,0x38,0x31,0x2f,0x30,0x31,0x33,0x33,0x35,0x2f,0x2f,0x30,0x32,0x33,0x33,0x2f,0x30,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x2f,0x32,0x2f,0x82,0xd8,0x8a,0x2f,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x32,0x40,0xd2,0x4c,0xc8,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x82,0x49,0x44,0x41,0x54,0x8,0xd7,0x55,0xcf,0xe9,0x16,0xc1,0x30,0x14,0x4,0xe0,0xb1,0x96,0x16,0x25,0x34,0x84,0x26,0x2d,0xaa,0xb6,0xac,0xef,0xff,0x72,0x6e,0x38,0xe,0xfd,0xe6,0xce,0x99,0xdf,0x17,0xcf,0xe,0x68,0xf4,0x48,0x7f,0x40,0x86,0x23,0xd,0x33,0x4e,0x92,0x64,0x32,0x4d,0xb3,0x2c,0x9d,0xcd,0xd,0xec,0x22,0xcf,0xf3,0xe5,0x8a,0xb1,0x35,0x63,0x1b,0xb,0x57,0xf0,0x82,0x73,0xbe,0xdd,0x9,0x21,0xf6,0xe,0xfe,0xf0,0x55,0x96,0xa5,0x47,0x90,0x91,0x52,0x4a,0x2a,0x29,0x3,0x42,0x55,0x93,0xaa,0x8e,0x53,0x5,0xf8,0x23,0x39,0x51,0xcf,0x14,0xf,0xd7,0x44,0x97,0xf7,0x35,0xe,0xb6,0xbd,0xb6,0x1f,0xb4,0x16,0xe6,0xf6,0xc7,0x40,0xdf,0x1f,0x3f,0x1a,0xdd,0x17,0x5e,0xc0,0x36,0x18,0x83,0x7f,0x54,0x76,0x87,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tree_cursor_unfocus_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0xe, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x96, 0xdd, 0xe3, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x99, 0x50, 0x4c, 0x54, 0x45, 0xc0, 0xb5, 0xb2, 0xbf, 0xb4, 0xb1, 0xc0, 0xb5, 0xb2, 0xbf, 0xb4, 0xb1, 0xbf, 0xb5, 0xb1, 0xc0, 0xb5, 0xb2, 0xc3, 0xb8, 0xb5, 0xc3, 0xb8, 0xb5, 0xc2, 0xb7, 0xb4, 0xc3, 0xb8, 0xb5, 0xc2, 0xb7, 0xb4, 0xc3, 0xb8, 0xb5, 0xc2, 0xb7, 0xb4, 0xc3, 0xb8, 0xb5, 0xc5, 0xba, 0xb7, 0xc5, 0xbc, 0xb9, 0xc5, 0xbc, 0xb9, 0xc5, 0xbc, 0xb9, 0xc5, 0xbc, 0xb9, 0xc5, 0xba, 0xb7, 0xc5, 0xba, 0xb7, 0xc6, 0xbd, 0xba, 0xc7, 0xbe, 0xbb, 0xc7, 0xbe, 0xbb, 0xc6, 0xbd, 0xba, 0xc7, 0xbe, 0xbb, 0xc6, 0xbd, 0xba, 0xca, 0xc1, 0xbe, 0xca, 0xc1, 0xbe, 0xcd, 0xc4, 0xc1, 0xcd, 0xc6, 0xc3, 0xd0, 0xc9, 0xc6, 0xcf, 0xc8, 0xc5, 0xd2, 0xcb, 0xc8, 0xd3, 0xcb, 0xc9, 0xd3, 0xcc, 0xc9, 0xd5, 0xcd, 0xcb, 0xd4, 0xcc, 0xca, 0xd7, 0xd1, 0xcf, 0xd6, 0xd0, 0xce, 0xda, 0xd4, 0xd2, 0xdd, 0xd7, 0xd5, 0xdd, 0xd7, 0xd5, 0x9a, 0x8b, 0x86, 0x94, 0x85, 0x80, 0x8e, 0x80, 0x7a, 0x88, 0x79, 0x74, 0x81, 0x75, 0x6f, 0x7a, 0x6f, 0x6a, 0x73, 0x69, 0x65, 0x0, 0x0, 0x0, 0xfb, 0x87, 0x71, 0x8e, 0x0, 0x0, 0x0, 0x2b, 0x74, 0x52, 0x4e, 0x53, 0x32, 0x2f, 0x30, 0x33, 0x38, 0x40, 0x32, 0x2f, 0x2f, 0x31, 0x33, 0x33, 0x36, 0x38, 0x31, 0x2f, 0x30, 0x31, 0x33, 0x33, 0x35, 0x2f, 0x2f, 0x30, 0x32, 0x33, 0x33, 0x2f, 0x30, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x32, 0x2f, 0x82, 0xd8, 0x8a, 0x2f, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x32, 0x40, 0xd2, 0x4c, 0xc8, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x82, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x55, 0xcf, 0xe9, 0x16, 0xc1, 0x30, 0x14, 0x4, 0xe0, 0xb1, 0x96, 0x16, 0x25, 0x34, 0x84, 0x26, 0x2d, 0xaa, 0xb6, 0xac, 0xef, 0xff, 0x72, 0x6e, 0x38, 0xe, 0xfd, 0xe6, 0xce, 0x99, 0xdf, 0x17, 0xcf, 0xe, 0x68, 0xf4, 0x48, 0x7f, 0x40, 0x86, 0x23, 0xd, 0x33, 0x4e, 0x92, 0x64, 0x32, 0x4d, 0xb3, 0x2c, 0x9d, 0xcd, 0xd, 0xec, 0x22, 0xcf, 0xf3, 0xe5, 0x8a, 0xb1, 0x35, 0x63, 0x1b, 0xb, 0x57, 0xf0, 0x82, 0x73, 0xbe, 0xdd, 0x9, 0x21, 0xf6, 0xe, 0xfe, 0xf0, 0x55, 0x96, 0xa5, 0x47, 0x90, 0x91, 0x52, 0x4a, 0x2a, 0x29, 0x3, 0x42, 0x55, 0x93, 0xaa, 0x8e, 0x53, 0x5, 0xf8, 0x23, 0x39, 0x51, 0xcf, 0x14, 0xf, 0xd7, 0x44, 0x97, 0xf7, 0x35, 0xe, 0xb6, 0xbd, 0xb6, 0x1f, 0xb4, 0x16, 0xe6, 0xf6, 0xc7, 0x40, 0xdf, 0x1f, 0x3f, 0x1a, 0xdd, 0x17, 0x5e, 0xc0, 0x36, 0x18, 0x83, 0x7f, 0x54, 0x76, 0x87, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tree_title_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x1,0x3,0x0,0x0,0x0,0x25,0x3d,0x6d,0x22,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x25,0x23,0x25,0x4c,0x4a,0x4e,0x1,0xf9,0x98,0x2e,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1,0xff,0x2,0x2d,0xde,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xc,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x20,0xd,0x0,0x0,0x0,0x30,0x0,0x1,0xc7,0xaa,0x85,0x8e,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tree_title_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x1, 0x3, 0x0, 0x0, 0x0, 0x25, 0x3d, 0x6d, 0x22, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x50, 0x4c, 0x54, 0x45, 0x25, 0x23, 0x25, 0x4c, 0x4a, 0x4e, 0x1, 0xf9, 0x98, 0x2e, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1, 0xff, 0x2, 0x2d, 0xde, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xc, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x20, 0xd, 0x0, 0x0, 0x0, 0x30, 0x0, 0x1, 0xc7, 0xaa, 0x85, 0x8e, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char tree_title_pressed_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x1,0x3,0x0,0x0,0x0,0x25,0x3d,0x6d,0x22,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x36,0x34,0x36,0x4c,0x4a,0x4e,0x14,0xd7,0x5b,0xf8,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1,0xff,0x2,0x2d,0xde,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xc,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x20,0xd,0x0,0x0,0x0,0x30,0x0,0x1,0xc7,0xaa,0x85,0x8e,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char tree_title_pressed_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x1, 0x3, 0x0, 0x0, 0x0, 0x25, 0x3d, 0x6d, 0x22, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x50, 0x4c, 0x54, 0x45, 0x36, 0x34, 0x36, 0x4c, 0x4a, 0x4e, 0x14, 0xd7, 0x5b, 0xf8, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1, 0xff, 0x2, 0x2d, 0xde, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xc, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x20, 0xd, 0x0, 0x0, 0x0, 0x30, 0x0, 0x1, 0xc7, 0xaa, 0x85, 0x8e, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char unchecked_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x36,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x38,0x37,0x40,0x20,0x20,0x24,0x20,0x20,0x24,0x38,0x36,0x40,0x20,0x20,0x25,0x1e,0x1e,0x22,0x1f,0x1f,0x23,0x20,0x20,0x24,0x22,0x22,0x27,0x23,0x23,0x28,0x25,0x25,0x2a,0xff,0xff,0xff,0xf7,0x93,0x46,0x7a,0x0,0x0,0x0,0xb,0x74,0x52,0x4e,0x53,0x0,0x7,0x27,0x50,0x66,0x68,0xb4,0xfa,0xfb,0xb4,0xfa,0xa4,0x7f,0xe1,0x5a,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x11,0xe2,0xb5,0x3d,0xba,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x53,0x49,0x44,0x41,0x54,0x18,0xd3,0xb5,0xcf,0xc1,0x12,0x80,0x20,0x8,0x45,0x51,0x5,0x14,0xd,0x5,0xff,0xff,0x6b,0x23,0x27,0x67,0x9a,0x6c,0xdb,0x5d,0x9e,0xd,0x8f,0x10,0xb6,0x22,0x20,0xa5,0x19,0x21,0x44,0x7,0xc8,0x2c,0x6d,0x26,0x9c,0xc1,0x1,0xb9,0xab,0xcd,0xb4,0x33,0x3a,0x90,0xe8,0xb8,0x53,0x21,0x87,0xd4,0x6c,0x81,0xb5,0xf4,0x17,0x6c,0x67,0x9f,0xc3,0xca,0x35,0xc,0x6a,0x59,0xd3,0x8f,0xa,0x5f,0xcf,0xbd,0x3a,0x1,0x93,0xe2,0x8,0xa4,0xb1,0xeb,0xd3,0x56,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char unchecked_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x36, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x38, 0x37, 0x40, 0x20, 0x20, 0x24, 0x20, 0x20, 0x24, 0x38, 0x36, 0x40, 0x20, 0x20, 0x25, 0x1e, 0x1e, 0x22, 0x1f, 0x1f, 0x23, 0x20, 0x20, 0x24, 0x22, 0x22, 0x27, 0x23, 0x23, 0x28, 0x25, 0x25, 0x2a, 0xff, 0xff, 0xff, 0xf7, 0x93, 0x46, 0x7a, 0x0, 0x0, 0x0, 0xb, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x7, 0x27, 0x50, 0x66, 0x68, 0xb4, 0xfa, 0xfb, 0xb4, 0xfa, 0xa4, 0x7f, 0xe1, 0x5a, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x11, 0xe2, 0xb5, 0x3d, 0xba, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x53, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0xb5, 0xcf, 0xc1, 0x12, 0x80, 0x20, 0x8, 0x45, 0x51, 0x5, 0x14, 0xd, 0x5, 0xff, 0xff, 0x6b, 0x23, 0x27, 0x67, 0x9a, 0x6c, 0xdb, 0x5d, 0x9e, 0xd, 0x8f, 0x10, 0xb6, 0x22, 0x20, 0xa5, 0x19, 0x21, 0x44, 0x7, 0xc8, 0x2c, 0x6d, 0x26, 0x9c, 0xc1, 0x1, 0xb9, 0xab, 0xcd, 0xb4, 0x33, 0x3a, 0x90, 0xe8, 0xb8, 0x53, 0x21, 0x87, 0xd4, 0x6c, 0x81, 0xb5, 0xf4, 0x17, 0x6c, 0x67, 0x9f, 0xc3, 0xca, 0x35, 0xc, 0x6a, 0x59, 0xd3, 0x8f, 0xa, 0x5f, 0xcf, 0xbd, 0x3a, 0x1, 0x93, 0xe2, 0x8, 0xa4, 0xb1, 0xeb, 0xd3, 0x56, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char updown_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0x81,0x83,0xf6,0xf6,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x4,0x4e,0x1d,0x2,0xaf,0x0,0x0,0x0,0x86,0x49,0x44,0x41,0x54,0x18,0xd3,0x85,0x8e,0x21,0x12,0xc2,0x30,0x10,0x45,0x5f,0x98,0x9d,0xe9,0x70,0x81,0x3d,0x41,0x1c,0x75,0xe5,0x4,0xc4,0xc1,0x79,0xa9,0xb,0x6,0x49,0x5d,0x8b,0x5b,0x11,0x9d,0xb,0xd4,0xec,0x4c,0x10,0xad,0x43,0xf4,0xb9,0x6f,0xfe,0x7b,0x70,0x44,0x0,0x30,0x95,0x27,0xf8,0x23,0x56,0xb6,0x59,0xe6,0xd2,0x4a,0x2b,0xb3,0x29,0x4,0x53,0x79,0x71,0x61,0x1,0x7a,0xbe,0x7e,0xb,0xe5,0xc3,0x95,0xc5,0x13,0x48,0xa6,0x67,0x3a,0xb5,0x95,0xc9,0x53,0xac,0xb1,0x7a,0x62,0x6a,0xeb,0xa1,0x95,0x50,0xde,0x9c,0xfd,0x1e,0x2b,0x98,0xca,0xc8,0x7a,0x6a,0x1d,0x83,0x64,0x53,0x53,0xc9,0xc,0xad,0xb,0xa6,0x92,0xe9,0x77,0xed,0xe2,0xe9,0x3f,0x6c,0x4f,0x1f,0x61,0x7b,0x3a,0xe6,0x7,0x73,0x18,0x40,0x43,0x76,0xe2,0x28,0x4e,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xba,0x84,0x14,0xff,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x35,0x3a,0x35,0x30,0x2b,0x30,0x32,0x3a,0x30,0x30,0xcb,0xd9,0xac,0x43,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char updown_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0x81, 0x83, 0xf6, 0xf6, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x4, 0x4e, 0x1d, 0x2, 0xaf, 0x0, 0x0, 0x0, 0x86, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x85, 0x8e, 0x21, 0x12, 0xc2, 0x30, 0x10, 0x45, 0x5f, 0x98, 0x9d, 0xe9, 0x70, 0x81, 0x3d, 0x41, 0x1c, 0x75, 0xe5, 0x4, 0xc4, 0xc1, 0x79, 0xa9, 0xb, 0x6, 0x49, 0x5d, 0x8b, 0x5b, 0x11, 0x9d, 0xb, 0xd4, 0xec, 0x4c, 0x10, 0xad, 0x43, 0xf4, 0xb9, 0x6f, 0xfe, 0x7b, 0x70, 0x44, 0x0, 0x30, 0x95, 0x27, 0xf8, 0x23, 0x56, 0xb6, 0x59, 0xe6, 0xd2, 0x4a, 0x2b, 0xb3, 0x29, 0x4, 0x53, 0x79, 0x71, 0x61, 0x1, 0x7a, 0xbe, 0x7e, 0xb, 0xe5, 0xc3, 0x95, 0xc5, 0x13, 0x48, 0xa6, 0x67, 0x3a, 0xb5, 0x95, 0xc9, 0x53, 0xac, 0xb1, 0x7a, 0x62, 0x6a, 0xeb, 0xa1, 0x95, 0x50, 0xde, 0x9c, 0xfd, 0x1e, 0x2b, 0x98, 0xca, 0xc8, 0x7a, 0x6a, 0x1d, 0x83, 0x64, 0x53, 0x53, 0xc9, 0xc, 0xad, 0xb, 0xa6, 0x92, 0xe9, 0x77, 0xed, 0xe2, 0xe9, 0x3f, 0x6c, 0x4f, 0x1f, 0x61, 0x7b, 0x3a, 0xe6, 0x7, 0x73, 0x18, 0x40, 0x43, 0x76, 0xe2, 0x28, 0x4e, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xba, 0x84, 0x14, 0xff, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x35, 0x3a, 0x35, 0x30, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xcb, 0xd9, 0xac, 0x43, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char vseparator_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x2,0x3,0x0,0x0,0x0,0xb9,0x61,0x56,0x18,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xc,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x73,0x9b,0xaa,0xce,0xdc,0xe1,0xff,0xff,0xff,0x64,0x6c,0x1,0xd2,0x0,0x0,0x0,0x3,0x74,0x52,0x4e,0x53,0x0,0xb3,0xb3,0x67,0xf6,0xdb,0x93,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x3,0x11,0xc,0x4c,0xf2,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x10,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x80,0x81,0xac,0x95,0xc,0x48,0x0,0x0,0xe,0x79,0x1,0x14,0xa1,0xc9,0x59,0x2,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char vseparator_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x2, 0x3, 0x0, 0x0, 0x0, 0xb9, 0x61, 0x56, 0x18, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xc, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x73, 0x9b, 0xaa, 0xce, 0xdc, 0xe1, 0xff, 0xff, 0xff, 0x64, 0x6c, 0x1, 0xd2, 0x0, 0x0, 0x0, 0x3, 0x74, 0x52, 0x4e, 0x53, 0x0, 0xb3, 0xb3, 0x67, 0xf6, 0xdb, 0x93, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x3, 0x11, 0xc, 0x4c, 0xf2, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x10, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x80, 0x81, 0xac, 0x95, 0xc, 0x48, 0x0, 0x0, 0xe, 0x79, 0x1, 0x14, 0xa1, 0xc9, 0x59, 0x2, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char vslider_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x54,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x4d,0x4b,0x59,0x34,0x33,0x3a,0x2d,0x2c,0x32,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x4d,0x4b,0x59,0x3f,0x3e,0x49,0x2a,0x29,0x2f,0x20,0x20,0x24,0x3f,0x3e,0x49,0x3f,0x3e,0x49,0x1f,0x1f,0x24,0x40,0x3e,0x4a,0x20,0x20,0x24,0x34,0x33,0x3a,0x20,0x20,0x25,0x22,0x22,0x27,0x23,0x23,0x28,0x25,0x25,0x2a,0x1e,0x1e,0x23,0x23,0x23,0x27,0x2d,0x2c,0x32,0x1f,0x1f,0x23,0xff,0xff,0xff,0x3,0x35,0xf1,0x5f,0x0,0x0,0x0,0x13,0x74,0x52,0x4e,0x53,0x0,0x0,0x0,0x0,0x4,0x1a,0x40,0x5d,0x19,0x28,0x96,0xf0,0xfd,0x94,0x95,0xfc,0x93,0xfc,0xc0,0x0,0xb4,0xa,0x5f,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1b,0x2,0x60,0xd4,0xa4,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x64,0x49,0x44,0x41,0x54,0x18,0xd3,0x9d,0xcf,0x39,0x2,0x80,0x20,0x10,0x3,0xc0,0xe5,0x90,0x43,0x50,0x94,0x1b,0xfe,0xff,0x50,0x5,0x69,0x94,0xce,0x94,0x53,0xec,0x26,0x0,0x0,0x88,0x2e,0x8c,0x73,0x26,0x28,0x82,0x1e,0x44,0xe5,0xaa,0xb4,0x56,0x9b,0x1c,0x82,0xc4,0x6e,0x9c,0xf7,0xce,0x1c,0x62,0x0,0x53,0x2e,0xc4,0x18,0x9c,0x62,0x3,0xb8,0xf6,0xf1,0x8e,0x3f,0xf9,0x3,0xd8,0xa6,0xdc,0x20,0x27,0x8b,0x3b,0x90,0x52,0x43,0x83,0x50,0xb,0xf9,0xb,0xd3,0xd1,0xe9,0xed,0x5c,0x6c,0xaa,0xfe,0x1d,0xf7,0x9e,0x7f,0x1,0x89,0x5c,0xa,0x6b,0x1f,0xe5,0xca,0x60,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char vslider_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x54, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x4d, 0x4b, 0x59, 0x34, 0x33, 0x3a, 0x2d, 0x2c, 0x32, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x4d, 0x4b, 0x59, 0x3f, 0x3e, 0x49, 0x2a, 0x29, 0x2f, 0x20, 0x20, 0x24, 0x3f, 0x3e, 0x49, 0x3f, 0x3e, 0x49, 0x1f, 0x1f, 0x24, 0x40, 0x3e, 0x4a, 0x20, 0x20, 0x24, 0x34, 0x33, 0x3a, 0x20, 0x20, 0x25, 0x22, 0x22, 0x27, 0x23, 0x23, 0x28, 0x25, 0x25, 0x2a, 0x1e, 0x1e, 0x23, 0x23, 0x23, 0x27, 0x2d, 0x2c, 0x32, 0x1f, 0x1f, 0x23, 0xff, 0xff, 0xff, 0x3, 0x35, 0xf1, 0x5f, 0x0, 0x0, 0x0, 0x13, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x0, 0x0, 0x4, 0x1a, 0x40, 0x5d, 0x19, 0x28, 0x96, 0xf0, 0xfd, 0x94, 0x95, 0xfc, 0x93, 0xfc, 0xc0, 0x0, 0xb4, 0xa, 0x5f, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1b, 0x2, 0x60, 0xd4, 0xa4, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x64, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x9d, 0xcf, 0x39, 0x2, 0x80, 0x20, 0x10, 0x3, 0xc0, 0xe5, 0x90, 0x43, 0x50, 0x94, 0x1b, 0xfe, 0xff, 0x50, 0x5, 0x69, 0x94, 0xce, 0x94, 0x53, 0xec, 0x26, 0x0, 0x0, 0x88, 0x2e, 0x8c, 0x73, 0x26, 0x28, 0x82, 0x1e, 0x44, 0xe5, 0xaa, 0xb4, 0x56, 0x9b, 0x1c, 0x82, 0xc4, 0x6e, 0x9c, 0xf7, 0xce, 0x1c, 0x62, 0x0, 0x53, 0x2e, 0xc4, 0x18, 0x9c, 0x62, 0x3, 0xb8, 0xf6, 0xf1, 0x8e, 0x3f, 0xf9, 0x3, 0xd8, 0xa6, 0xdc, 0x20, 0x27, 0x8b, 0x3b, 0x90, 0x52, 0x43, 0x83, 0x50, 0xb, 0xf9, 0xb, 0xd3, 0xd1, 0xe9, 0xed, 0x5c, 0x6c, 0xaa, 0xfe, 0x1d, 0xf7, 0x9e, 0x7f, 0x1, 0x89, 0x5c, 0xa, 0x6b, 0x1f, 0xe5, 0xca, 0x60, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char vslider_grabber_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x4,0x0,0x0,0x0,0xb5,0xfa,0x37,0xea,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xf8,0x49,0x44,0x41,0x54,0x28,0xcf,0xbd,0x90,0xaf,0x4b,0x43,0x51,0x18,0x86,0x9f,0xf3,0x43,0xcf,0x76,0xae,0xde,0xb9,0xc9,0x1c,0x82,0x86,0xa1,0x16,0x15,0x87,0xc3,0x20,0x68,0x30,0x58,0xb4,0x5a,0x6c,0x62,0x37,0x88,0xff,0x81,0xc5,0xe4,0x5f,0x70,0x8b,0x75,0x45,0xb3,0xc1,0xa6,0x41,0x4,0x19,0xc,0x19,0x18,0x4,0x8d,0xb,0x82,0xdb,0xd8,0x81,0x29,0xf7,0x1e,0x8b,0x6e,0x43,0x30,0xea,0x93,0x5e,0xf8,0x5e,0x5e,0x78,0x3e,0xf8,0x73,0xc4,0x40,0x92,0x18,0x46,0x9,0x18,0xc6,0xd3,0xa1,0x89,0x23,0xee,0x17,0x86,0xc8,0x14,0xa7,0x97,0x57,0x4a,0xdb,0xe1,0xa2,0xc9,0x4b,0xdf,0xac,0x3d,0x9d,0x47,0x15,0x5e,0x89,0x5,0x20,0xb0,0x23,0xc5,0x83,0xc3,0xc2,0xa6,0x99,0xea,0xaa,0xf,0x62,0xc0,0xa0,0x1b,0xf,0x27,0xd1,0x19,0x6d,0x8d,0x66,0x6c,0x75,0x6d,0xf7,0x54,0xcd,0x3a,0x1c,0xc9,0xd7,0x60,0x8c,0x2d,0xcc,0xec,0x70,0x41,0x5b,0x63,0x8e,0xf6,0xe6,0x8f,0xdf,0x82,0x4e,0xef,0x8,0xe0,0xe9,0x92,0x5d,0x22,0x0,0x89,0x48,0x59,0xd4,0xef,0x16,0x8a,0xe4,0xba,0xde,0xaa,0x2e,0x94,0x53,0xb9,0x4,0x8f,0xef,0x29,0xa5,0x71,0x77,0x57,0x15,0x5a,0x8a,0x4,0xf7,0xfc,0x72,0x73,0x39,0xc7,0xf8,0x44,0x90,0x11,0x2,0x24,0x92,0x34,0xba,0xf1,0x18,0xdd,0xdf,0xf2,0xde,0xd7,0xc,0x75,0x7e,0x6b,0x7d,0x63,0x5f,0x4c,0x9a,0x9c,0xfa,0xa1,0xf9,0x8d,0xc4,0x12,0x62,0xd1,0x83,0x8f,0xfa,0x7,0x3e,0x1,0x87,0xd0,0x4a,0x12,0xcf,0xee,0xfb,0xd8,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char vslider_grabber_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x4, 0x0, 0x0, 0x0, 0xb5, 0xfa, 0x37, 0xea, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xf8, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0xbd, 0x90, 0xaf, 0x4b, 0x43, 0x51, 0x18, 0x86, 0x9f, 0xf3, 0x43, 0xcf, 0x76, 0xae, 0xde, 0xb9, 0xc9, 0x1c, 0x82, 0x86, 0xa1, 0x16, 0x15, 0x87, 0xc3, 0x20, 0x68, 0x30, 0x58, 0xb4, 0x5a, 0x6c, 0x62, 0x37, 0x88, 0xff, 0x81, 0xc5, 0xe4, 0x5f, 0x70, 0x8b, 0x75, 0x45, 0xb3, 0xc1, 0xa6, 0x41, 0x4, 0x19, 0xc, 0x19, 0x18, 0x4, 0x8d, 0xb, 0x82, 0xdb, 0xd8, 0x81, 0x29, 0xf7, 0x1e, 0x8b, 0x6e, 0x43, 0x30, 0xea, 0x93, 0x5e, 0xf8, 0x5e, 0x5e, 0x78, 0x3e, 0xf8, 0x73, 0xc4, 0x40, 0x92, 0x18, 0x46, 0x9, 0x18, 0xc6, 0xd3, 0xa1, 0x89, 0x23, 0xee, 0x17, 0x86, 0xc8, 0x14, 0xa7, 0x97, 0x57, 0x4a, 0xdb, 0xe1, 0xa2, 0xc9, 0x4b, 0xdf, 0xac, 0x3d, 0x9d, 0x47, 0x15, 0x5e, 0x89, 0x5, 0x20, 0xb0, 0x23, 0xc5, 0x83, 0xc3, 0xc2, 0xa6, 0x99, 0xea, 0xaa, 0xf, 0x62, 0xc0, 0xa0, 0x1b, 0xf, 0x27, 0xd1, 0x19, 0x6d, 0x8d, 0x66, 0x6c, 0x75, 0x6d, 0xf7, 0x54, 0xcd, 0x3a, 0x1c, 0xc9, 0xd7, 0x60, 0x8c, 0x2d, 0xcc, 0xec, 0x70, 0x41, 0x5b, 0x63, 0x8e, 0xf6, 0xe6, 0x8f, 0xdf, 0x82, 0x4e, 0xef, 0x8, 0xe0, 0xe9, 0x92, 0x5d, 0x22, 0x0, 0x89, 0x48, 0x59, 0xd4, 0xef, 0x16, 0x8a, 0xe4, 0xba, 0xde, 0xaa, 0x2e, 0x94, 0x53, 0xb9, 0x4, 0x8f, 0xef, 0x29, 0xa5, 0x71, 0x77, 0x57, 0x15, 0x5a, 0x8a, 0x4, 0xf7, 0xfc, 0x72, 0x73, 0x39, 0xc7, 0xf8, 0x44, 0x90, 0x11, 0x2, 0x24, 0x92, 0x34, 0xba, 0xf1, 0x18, 0xdd, 0xdf, 0xf2, 0xde, 0xd7, 0xc, 0x75, 0x7e, 0x6b, 0x7d, 0x63, 0x5f, 0x4c, 0x9a, 0x9c, 0xfa, 0xa1, 0xf9, 0x8d, 0xc4, 0x12, 0x62, 0xd1, 0x83, 0x8f, 0xfa, 0x7, 0x3e, 0x1, 0x87, 0xd0, 0x4a, 0x12, 0xcf, 0xee, 0xfb, 0xd8, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char vslider_grabber_hl_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x3,0x0,0x0,0x0,0x28,0x2d,0xf,0x53,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0xc6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x17,0x2a,0x29,0x3a,0x69,0x69,0x5b,0xa6,0xa5,0x61,0xb3,0xbc,0x63,0xb7,0xc8,0x65,0xbb,0xca,0x60,0xaf,0xb1,0x48,0x83,0x83,0x0,0x0,0x0,0x0,0x0,0x0,0x8,0xf,0xf,0x55,0x9b,0x9a,0x60,0xb2,0xbd,0x5e,0xb1,0xcd,0x61,0xb3,0xc2,0x0,0x0,0x0,0x27,0x48,0x47,0x62,0xb4,0xbd,0x51,0x93,0x92,0x68,0xc0,0xcf,0x0,0x0,0x0,0x56,0x9d,0x9c,0x68,0xc1,0xcf,0x2d,0x52,0x52,0x63,0xb7,0xbf,0x52,0x96,0x95,0x62,0xb3,0xbf,0x5e,0xb0,0xcd,0x0,0x0,0x0,0x3,0x5,0x5,0x36,0x63,0x63,0x63,0xb4,0xb6,0x60,0xb1,0xbc,0x63,0xb7,0xc7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x55,0xa3,0xc8,0x4f,0x98,0xc4,0x4b,0x93,0xc2,0x4c,0x94,0xc2,0x54,0xa2,0xc8,0x5a,0xab,0xcb,0x4e,0x97,0xc4,0x49,0x8f,0xc0,0x47,0x8c,0xbf,0x48,0x8e,0xc0,0x52,0x9e,0xc6,0x51,0x9d,0xc6,0x5a,0xac,0xcc,0x53,0x9f,0xc7,0x4d,0x96,0xc3,0x4b,0x92,0xc2,0xff,0xff,0xff,0xec,0x37,0x7,0xf6,0x0,0x0,0x0,0x31,0x74,0x52,0x4e,0x53,0x0,0x1,0x3,0xa,0x17,0x22,0x28,0x27,0x1c,0xd,0x5,0x14,0x31,0x65,0xaf,0xdb,0xf0,0xef,0xc1,0x6e,0x16,0xb,0x2c,0x9c,0xe0,0xfc,0xe8,0x4,0x4f,0xdb,0x73,0xf4,0xc,0x7d,0xf7,0x55,0xdc,0x95,0xe0,0xfe,0x13,0x28,0x64,0xc5,0xde,0xf0,0x2,0x1a,0x24,0x77,0x58,0x79,0x88,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x41,0x89,0xde,0x6c,0x4e,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x7d,0x49,0x44,0x41,0x54,0x18,0xd3,0x63,0x60,0x20,0xf,0x30,0x32,0x31,0xb3,0xb0,0xb2,0xb1,0x73,0x70,0x32,0x41,0xf8,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc,0x2,0x82,0x42,0xc2,0x22,0x20,0x11,0x46,0x51,0x31,0x71,0x9,0x49,0x43,0x23,0x63,0x13,0x53,0x29,0x61,0x4e,0x6,0x6,0x69,0x6e,0x19,0x59,0x33,0x73,0xb,0x4b,0x20,0xb0,0x32,0x15,0xe2,0x60,0x60,0x10,0x95,0x93,0xb7,0x6,0x73,0x81,0xc0,0x44,0x90,0x9d,0x81,0x41,0x41,0x51,0xc9,0x6,0x45,0x40,0x5a,0x44,0x59,0xc5,0x16,0x59,0xb,0x3,0xa3,0x82,0x98,0xaa,0x9a,0xba,0x9d,0xbd,0x3,0xd4,0x50,0x90,0xb5,0x1a,0x9a,0x5a,0xda,0x3a,0xba,0x30,0x6b,0x41,0x40,0x4f,0x41,0xdf,0x0,0xc9,0x61,0x24,0x2,0x0,0x9d,0x96,0x10,0xf9,0x6,0xb2,0x58,0x28,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char vslider_grabber_hl_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x8, 0x3, 0x0, 0x0, 0x0, 0x28, 0x2d, 0xf, 0x53, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0xc6, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x17, 0x2a, 0x29, 0x3a, 0x69, 0x69, 0x5b, 0xa6, 0xa5, 0x61, 0xb3, 0xbc, 0x63, 0xb7, 0xc8, 0x65, 0xbb, 0xca, 0x60, 0xaf, 0xb1, 0x48, 0x83, 0x83, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0xf, 0xf, 0x55, 0x9b, 0x9a, 0x60, 0xb2, 0xbd, 0x5e, 0xb1, 0xcd, 0x61, 0xb3, 0xc2, 0x0, 0x0, 0x0, 0x27, 0x48, 0x47, 0x62, 0xb4, 0xbd, 0x51, 0x93, 0x92, 0x68, 0xc0, 0xcf, 0x0, 0x0, 0x0, 0x56, 0x9d, 0x9c, 0x68, 0xc1, 0xcf, 0x2d, 0x52, 0x52, 0x63, 0xb7, 0xbf, 0x52, 0x96, 0x95, 0x62, 0xb3, 0xbf, 0x5e, 0xb0, 0xcd, 0x0, 0x0, 0x0, 0x3, 0x5, 0x5, 0x36, 0x63, 0x63, 0x63, 0xb4, 0xb6, 0x60, 0xb1, 0xbc, 0x63, 0xb7, 0xc7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x55, 0xa3, 0xc8, 0x4f, 0x98, 0xc4, 0x4b, 0x93, 0xc2, 0x4c, 0x94, 0xc2, 0x54, 0xa2, 0xc8, 0x5a, 0xab, 0xcb, 0x4e, 0x97, 0xc4, 0x49, 0x8f, 0xc0, 0x47, 0x8c, 0xbf, 0x48, 0x8e, 0xc0, 0x52, 0x9e, 0xc6, 0x51, 0x9d, 0xc6, 0x5a, 0xac, 0xcc, 0x53, 0x9f, 0xc7, 0x4d, 0x96, 0xc3, 0x4b, 0x92, 0xc2, 0xff, 0xff, 0xff, 0xec, 0x37, 0x7, 0xf6, 0x0, 0x0, 0x0, 0x31, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x1, 0x3, 0xa, 0x17, 0x22, 0x28, 0x27, 0x1c, 0xd, 0x5, 0x14, 0x31, 0x65, 0xaf, 0xdb, 0xf0, 0xef, 0xc1, 0x6e, 0x16, 0xb, 0x2c, 0x9c, 0xe0, 0xfc, 0xe8, 0x4, 0x4f, 0xdb, 0x73, 0xf4, 0xc, 0x7d, 0xf7, 0x55, 0xdc, 0x95, 0xe0, 0xfe, 0x13, 0x28, 0x64, 0xc5, 0xde, 0xf0, 0x2, 0x1a, 0x24, 0x77, 0x58, 0x79, 0x88, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x41, 0x89, 0xde, 0x6c, 0x4e, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x7d, 0x49, 0x44, 0x41, 0x54, 0x18, 0xd3, 0x63, 0x60, 0x20, 0xf, 0x30, 0x32, 0x31, 0xb3, 0xb0, 0xb2, 0xb1, 0x73, 0x70, 0x32, 0x41, 0xf8, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x2, 0x82, 0x42, 0xc2, 0x22, 0x20, 0x11, 0x46, 0x51, 0x31, 0x71, 0x9, 0x49, 0x43, 0x23, 0x63, 0x13, 0x53, 0x29, 0x61, 0x4e, 0x6, 0x6, 0x69, 0x6e, 0x19, 0x59, 0x33, 0x73, 0xb, 0x4b, 0x20, 0xb0, 0x32, 0x15, 0xe2, 0x60, 0x60, 0x10, 0x95, 0x93, 0xb7, 0x6, 0x73, 0x81, 0xc0, 0x44, 0x90, 0x9d, 0x81, 0x41, 0x41, 0x51, 0xc9, 0x6, 0x45, 0x40, 0x5a, 0x44, 0x59, 0xc5, 0x16, 0x59, 0xb, 0x3, 0xa3, 0x82, 0x98, 0xaa, 0x9a, 0xba, 0x9d, 0xbd, 0x3, 0xd4, 0x50, 0x90, 0xb5, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x30, 0x6b, 0x41, 0x40, 0x4f, 0x41, 0xdf, 0x0, 0xc9, 0x61, 0x24, 0x2, 0x0, 0x9d, 0x96, 0x10, 0xf9, 0x6, 0xb2, 0x58, 0x28, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char vslider_tick_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x4,0x4,0x3,0x0,0x0,0x0,0x75,0x9a,0xa2,0xdf,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x1e,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x81,0xa2,0xad,0x8c,0xac,0xb8,0x38,0x55,0x5f,0x82,0x82,0x82,0x8d,0x8d,0x8d,0x98,0x98,0x98,0x4e,0x4e,0x4e,0x4e,0x4e,0x4e,0xff,0xff,0xff,0xe1,0x56,0x59,0xc8,0x0,0x0,0x0,0x9,0x74,0x52,0x4e,0x53,0x0,0x0,0x0,0x0,0x79,0x79,0x79,0x31,0x1c,0x18,0xed,0xfe,0x2b,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x9,0xf1,0xd9,0xa5,0xec,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x1d,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x80,0x1,0xd7,0x44,0x5,0x6,0x6,0xe6,0x92,0x30,0x86,0xf2,0x62,0x3,0x20,0xa3,0xbd,0x1c,0x2e,0x3,0x0,0x3f,0xce,0x3,0xaf,0xf9,0x94,0x50,0x96,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char vslider_tick_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x4, 0x4, 0x3, 0x0, 0x0, 0x0, 0x75, 0x9a, 0xa2, 0xdf, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x1e, 0x50, 0x4c, 0x54, 0x45, 0x0, 0x0, 0x0, 0x81, 0xa2, 0xad, 0x8c, 0xac, 0xb8, 0x38, 0x55, 0x5f, 0x82, 0x82, 0x82, 0x8d, 0x8d, 0x8d, 0x98, 0x98, 0x98, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xff, 0xff, 0xff, 0xe1, 0x56, 0x59, 0xc8, 0x0, 0x0, 0x0, 0x9, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x0, 0x0, 0x79, 0x79, 0x79, 0x31, 0x1c, 0x18, 0xed, 0xfe, 0x2b, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x9, 0xf1, 0xd9, 0xa5, 0xec, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x1d, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x80, 0x1, 0xd7, 0x44, 0x5, 0x6, 0x6, 0xe6, 0x92, 0x30, 0x86, 0xf2, 0x62, 0x3, 0x20, 0xa3, 0xbd, 0x1c, 0x2e, 0x3, 0x0, 0x3f, 0xce, 0x3, 0xaf, 0xf9, 0x94, 0x50, 0x96, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char vsplit_bg_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x8,0x1,0x3,0x0,0x0,0x0,0xfe,0xc1,0x2c,0xc8,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x27,0x27,0x29,0xff,0xff,0xff,0x11,0xab,0xb9,0xf3,0x0,0x0,0x0,0x1,0x62,0x4b,0x47,0x44,0x1,0xff,0x2,0x2d,0xde,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0xb,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x40,0x5,0x0,0x0,0x10,0x0,0x1,0xa1,0xc5,0x21,0xc1,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char vsplit_bg_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x1, 0x3, 0x0, 0x0, 0x0, 0xfe, 0xc1, 0x2c, 0xc8, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x50, 0x4c, 0x54, 0x45, 0x27, 0x27, 0x29, 0xff, 0xff, 0xff, 0x11, 0xab, 0xb9, 0xf3, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0x1, 0xff, 0x2, 0x2d, 0xde, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0xb, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x40, 0x5, 0x0, 0x0, 0x10, 0x0, 0x1, 0xa1, 0xc5, 0x21, 0xc1, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
-
-static const unsigned char vsplitter_png[]={
-0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x8,0x8,0x0,0x0,0x0,0x0,0x6c,0x9,0xa6,0x3,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0xff,0x87,0x8f,0xcc,0xbf,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x0,0x1f,0x49,0x44,0x41,0x54,0x28,0xcf,0x63,0x60,0xa0,0x10,0x30,0x33,0x2c,0x10,0x3d,0x47,0x9,0x66,0x66,0x10,0xbd,0xf6,0x98,0x22,0x3c,0xe0,0x60,0x18,0x84,0x1,0x0,0x59,0x34,0x6a,0x2d,0x64,0xeb,0x72,0x24,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+static const unsigned char vsplitter_png[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0x6c, 0x9, 0xa6, 0x3, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x74, 0x52, 0x4e, 0x53, 0x0, 0x0, 0x76, 0x93, 0xcd, 0x38, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x1f, 0x49, 0x44, 0x41, 0x54, 0x28, 0xcf, 0x63, 0x60, 0xa0, 0x10, 0x30, 0x33, 0x2c, 0x10, 0x3d, 0x47, 0x9, 0x66, 0x66, 0x10, 0xbd, 0xf6, 0x98, 0x22, 0x3c, 0xe0, 0x60, 0x18, 0x84, 0x1, 0x0, 0x59, 0x34, 0x6a, 0x2d, 0x64, 0xeb, 0x72, 0x24, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
+static const char *uv_editor_shader_code =
+ "vec3 nd1sl2=vec3(UV,0);"
+ "uniform float H=0;"
+ "float nd4sl0=H;"
+ "float nd7sl0=nd1sl2.x;"
+ "float nd7sl1=nd1sl2.y;"
+ "float nd7sl2=nd1sl2.z;"
+ "float nd2sl1def=-1;"
+ "float nd2sl0=nd7sl1*nd2sl1def;"
+ "float nd6sl1def=1;"
+ "float nd6sl0=nd2sl0+nd6sl1def;"
+ "vec3 nd3sl0=vec3(nd4sl0,nd7sl0,nd6sl0);"
+ "vec3 nd5sl0;"
+ "{"
+ " vec3 c = nd3sl0;"
+ " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
+ " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
+ " nd5sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
+ "}"
+ "COLOR.rgb=nd5sl0;";
-
-
-
-static const char *uv_editor_shader_code=
- "vec3 nd1sl2=vec3(UV,0);"
- "uniform float H=0;"
- "float nd4sl0=H;"
- "float nd7sl0=nd1sl2.x;"
- "float nd7sl1=nd1sl2.y;"
- "float nd7sl2=nd1sl2.z;"
- "float nd2sl1def=-1;"
- "float nd2sl0=nd7sl1*nd2sl1def;"
- "float nd6sl1def=1;"
- "float nd6sl0=nd2sl0+nd6sl1def;"
- "vec3 nd3sl0=vec3(nd4sl0,nd7sl0,nd6sl0);"
- "vec3 nd5sl0;"
- "{"
- " vec3 c = nd3sl0;"
- " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
- " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
- " nd5sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
- "}"
- "COLOR.rgb=nd5sl0;";
-
-
-static const char *w_editor_shader_code=
- "vec3 nd1sl2=vec3(UV,0);"
- "float nd2sl1=1-nd1sl2.y;"
- "vec3 nd3sl0=vec3(nd2sl1,1,1);"
- "vec3 nd6sl0;"
- "{"
- " vec3 c = nd3sl0;"
- " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
- " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
- " nd6sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
- "}"
- "COLOR.rgb=nd6sl0;";
-
-
+static const char *w_editor_shader_code =
+ "vec3 nd1sl2=vec3(UV,0);"
+ "float nd2sl1=1-nd1sl2.y;"
+ "vec3 nd3sl0=vec3(nd2sl1,1,1);"
+ "vec3 nd6sl0;"
+ "{"
+ " vec3 c = nd3sl0;"
+ " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);"
+ " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);"
+ " nd6sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);"
+ "}"
+ "COLOR.rgb=nd6sl0;";
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 06093bac2..a144b790d 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -31,9 +31,9 @@
#include "os/file_access.h"
#include "os/os.h"
-bool DynamicFontData::CacheID::operator< (CacheID right) const{
+bool DynamicFontData::CacheID::operator<(CacheID right) const {
- if (size<right.size)
+ if (size < right.size)
return true;
if (mipmaps != right.mipmaps)
return right.mipmaps;
@@ -42,37 +42,34 @@ bool DynamicFontData::CacheID::operator< (CacheID right) const{
return false;
}
-Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_id){
-
+Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(CacheID p_id) {
if (size_cache.has(p_id)) {
- return Ref<DynamicFontAtSize>( size_cache[p_id] );
+ return Ref<DynamicFontAtSize>(size_cache[p_id]);
}
-
Ref<DynamicFontAtSize> dfas;
dfas.instance();
- dfas->font=Ref<DynamicFontData>( this );
+ dfas->font = Ref<DynamicFontData>(this);
- size_cache[p_id]=dfas.ptr();
- dfas->id=p_id;
+ size_cache[p_id] = dfas.ptr();
+ dfas->id = p_id;
dfas->_load();
return dfas;
-
}
-void DynamicFontData::set_font_ptr(const uint8_t* p_font_mem,int p_font_mem_size) {
+void DynamicFontData::set_font_ptr(const uint8_t *p_font_mem, int p_font_mem_size) {
- font_mem=p_font_mem;
- font_mem_size=p_font_mem_size;
+ font_mem = p_font_mem;
+ font_mem_size = p_font_mem_size;
}
-void DynamicFontData::set_font_path(const String& p_path) {
+void DynamicFontData::set_font_path(const String &p_path) {
- font_path=p_path;
+ font_path = p_path;
}
String DynamicFontData::get_font_path() const {
@@ -81,44 +78,38 @@ String DynamicFontData::get_font_path() const {
void DynamicFontData::set_force_autohinter(bool p_force) {
- force_autohinter=p_force;
+ force_autohinter = p_force;
}
void DynamicFontData::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_font_path","path"),&DynamicFontData::set_font_path);
- ObjectTypeDB::bind_method(_MD("get_font_path"),&DynamicFontData::get_font_path);
+ ObjectTypeDB::bind_method(_MD("set_font_path", "path"), &DynamicFontData::set_font_path);
+ ObjectTypeDB::bind_method(_MD("get_font_path"), &DynamicFontData::get_font_path);
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"font_path",PROPERTY_HINT_FILE,"*.ttf,*.otf"),_SCS("set_font_path"),_SCS("get_font_path"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "font_path", PROPERTY_HINT_FILE, "*.ttf,*.otf"), _SCS("set_font_path"), _SCS("get_font_path"));
}
-DynamicFontData::DynamicFontData()
-{
+DynamicFontData::DynamicFontData() {
- force_autohinter=false;
- font_mem=NULL;
- font_mem_size=0;
+ force_autohinter = false;
+ font_mem = NULL;
+ font_mem_size = 0;
}
-DynamicFontData::~DynamicFontData()
-{
-
+DynamicFontData::~DynamicFontData() {
}
-
-
////////////////////
-HashMap< String, Vector<uint8_t> > DynamicFontAtSize::_fontdata;
+HashMap<String, Vector<uint8_t> > DynamicFontAtSize::_fontdata;
Error DynamicFontAtSize::_load() {
-
- int error = FT_Init_FreeType( &library );
+ int error = FT_Init_FreeType(&library);
ERR_EXPLAIN(TTR("Error initializing FreeType."));
- ERR_FAIL_COND_V( error !=0, ERR_CANT_CREATE );
+ ERR_FAIL_COND_V(error != 0, ERR_CANT_CREATE);
// FT_OPEN_STREAM is extremely slow only on Android.
- if (OS::get_singleton()->get_name()=="Android" && font->font_mem==NULL && font->font_path!=String()) {
+ if (OS::get_singleton()->get_name() == "Android" && font->font_mem == NULL && font->font_path != String()) {
// cache font only once for each font->font_path
if (_fontdata.has(font->font_path)) {
@@ -126,52 +117,51 @@ Error DynamicFontAtSize::_load() {
} else {
- FileAccess *f=FileAccess::open(font->font_path,FileAccess::READ);
- ERR_FAIL_COND_V(!f,ERR_CANT_OPEN);
+ FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ);
+ ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
- size_t len=f->get_len();
- _fontdata[font->font_path]=Vector<uint8_t>();
- Vector<uint8_t>& fontdata=_fontdata[font->font_path];
+ size_t len = f->get_len();
+ _fontdata[font->font_path] = Vector<uint8_t>();
+ Vector<uint8_t> &fontdata = _fontdata[font->font_path];
fontdata.resize(len);
f->get_buffer(fontdata.ptr(), len);
font->set_font_ptr(fontdata.ptr(), len);
f->close();
-
}
}
- if (font->font_mem==NULL && font->font_path!=String()) {
+ if (font->font_mem == NULL && font->font_path != String()) {
- FileAccess *f=FileAccess::open(font->font_path,FileAccess::READ);
- ERR_FAIL_COND_V(!f,ERR_CANT_OPEN);
+ FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ);
+ ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);
- memset(&stream,0,sizeof(FT_StreamRec));
- stream.base=NULL;
- stream.size=f->get_len();
- stream.pos=0;
- stream.descriptor.pointer=f;
- stream.read=_ft_stream_io;
- stream.close=_ft_stream_close;
+ memset(&stream, 0, sizeof(FT_StreamRec));
+ stream.base = NULL;
+ stream.size = f->get_len();
+ stream.pos = 0;
+ stream.descriptor.pointer = f;
+ stream.read = _ft_stream_io;
+ stream.close = _ft_stream_close;
FT_Open_Args fargs;
- memset(&fargs,0,sizeof(FT_Open_Args));
- fargs.flags=FT_OPEN_STREAM;
- fargs.stream=&stream;
- error = FT_Open_Face( library,&fargs,0,&face);
+ memset(&fargs, 0, sizeof(FT_Open_Args));
+ fargs.flags = FT_OPEN_STREAM;
+ fargs.stream = &stream;
+ error = FT_Open_Face(library, &fargs, 0, &face);
} else if (font->font_mem) {
- memset(&stream,0,sizeof(FT_StreamRec));
- stream.base=(unsigned char*)font->font_mem;
- stream.size=font->font_mem_size;
- stream.pos=0;
+ memset(&stream, 0, sizeof(FT_StreamRec));
+ stream.base = (unsigned char *)font->font_mem;
+ stream.size = font->font_mem_size;
+ stream.pos = 0;
FT_Open_Args fargs;
- memset(&fargs,0,sizeof(FT_Open_Args));
- fargs.memory_base=(unsigned char*)font->font_mem;
- fargs.memory_size=font->font_mem_size;
- fargs.flags= FT_OPEN_MEMORY;
- fargs.stream=&stream;
- error = FT_Open_Face( library,&fargs,0,&face);
+ memset(&fargs, 0, sizeof(FT_Open_Args));
+ fargs.memory_base = (unsigned char *)font->font_mem;
+ fargs.memory_size = font->font_mem_size;
+ fargs.flags = FT_OPEN_MEMORY;
+ fargs.stream = &stream;
+ error = FT_Open_Face(library, &fargs, 0, &face);
} else {
ERR_EXPLAIN("DynamicFont uninitialized");
@@ -180,19 +170,17 @@ Error DynamicFontAtSize::_load() {
//error = FT_New_Face( library, src_path.utf8().get_data(),0,&face );
- if ( error == FT_Err_Unknown_File_Format ) {
+ if (error == FT_Err_Unknown_File_Format) {
ERR_EXPLAIN(TTR("Unknown font format."));
- FT_Done_FreeType( library );
+ FT_Done_FreeType(library);
- } else if ( error ) {
+ } else if (error) {
ERR_EXPLAIN(TTR("Error loading font."));
- FT_Done_FreeType( library );
-
+ FT_Done_FreeType(library);
}
- ERR_FAIL_COND_V(error,ERR_FILE_CANT_OPEN);
-
+ ERR_FAIL_COND_V(error, ERR_FILE_CANT_OPEN);
/*error = FT_Set_Char_Size(face,0,64*size,512,512);
@@ -202,26 +190,26 @@ Error DynamicFontAtSize::_load() {
ERR_FAIL_COND_V( error, ERR_INVALID_PARAMETER );
}*/
- error = FT_Set_Pixel_Sizes(face,0,id.size);
+ error = FT_Set_Pixel_Sizes(face, 0, id.size);
- ascent=face->size->metrics.ascender>>6;
- descent=-face->size->metrics.descender>>6;
- linegap=0;
- texture_flags=0;
+ ascent = face->size->metrics.ascender >> 6;
+ descent = -face->size->metrics.descender >> 6;
+ linegap = 0;
+ texture_flags = 0;
if (id.mipmaps)
- texture_flags|=Texture::FLAG_MIPMAPS;
+ texture_flags |= Texture::FLAG_MIPMAPS;
if (id.filter)
- texture_flags|=Texture::FLAG_FILTER;
+ texture_flags |= Texture::FLAG_FILTER;
//print_line("ASCENT: "+itos(ascent)+" descent "+itos(descent)+" hinted: "+itos(face->face_flags&FT_FACE_FLAG_HINTER));
- valid=true;
+ valid = true;
return OK;
}
float DynamicFontAtSize::get_height() const {
- return ascent+descent;
+ return ascent + descent;
}
float DynamicFontAtSize::get_ascent() const {
@@ -233,23 +221,23 @@ float DynamicFontAtSize::get_descent() const {
return descent;
}
-Size2 DynamicFontAtSize::get_char_size(CharType p_char,CharType p_next,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const {
+Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const {
if (!valid)
- return Size2(1,1);
- const_cast<DynamicFontAtSize*>(this)->_update_char(p_char);
+ return Size2(1, 1);
+ const_cast<DynamicFontAtSize *>(this)->_update_char(p_char);
const Character *c = char_map.getptr(p_char);
- ERR_FAIL_COND_V(!c,Size2());
+ ERR_FAIL_COND_V(!c, Size2());
- Size2 ret(0,get_height());
+ Size2 ret(0, get_height());
if (!c->found) {
//not found, try in fallbacks
- for(int i=0;i<p_fallbacks.size();i++) {
+ for (int i = 0; i < p_fallbacks.size(); i++) {
- DynamicFontAtSize *fb = const_cast<DynamicFontAtSize*>(p_fallbacks[i].ptr());
+ DynamicFontAtSize *fb = const_cast<DynamicFontAtSize *>(p_fallbacks[i].ptr());
if (!fb->valid)
continue;
@@ -260,83 +248,79 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char,CharType p_next,const Vec
if (!ch->found)
continue;
- c=ch;
+ c = ch;
break;
}
//not found, try 0xFFFD to display 'not found'.
if (!c->found) {
- const_cast<DynamicFontAtSize*>(this)->_update_char(0xFFFD);
+ const_cast<DynamicFontAtSize *>(this)->_update_char(0xFFFD);
c = char_map.getptr(0xFFFD);
- ERR_FAIL_COND_V(!c,Size2());
-
+ ERR_FAIL_COND_V(!c, Size2());
}
}
if (c->found) {
- ret.x=c->advance;
+ ret.x = c->advance;
}
-
if (p_next) {
- FT_Vector delta;
- FT_Get_Kerning( face, p_char,p_next, FT_KERNING_DEFAULT, &delta );
+ FT_Vector delta;
+ FT_Get_Kerning(face, p_char, p_next, FT_KERNING_DEFAULT, &delta);
- if (delta.x==0) {
- for(int i=0;i<p_fallbacks.size();i++) {
+ if (delta.x == 0) {
+ for (int i = 0; i < p_fallbacks.size(); i++) {
- DynamicFontAtSize *fb = const_cast<DynamicFontAtSize*>(p_fallbacks[i].ptr());
+ DynamicFontAtSize *fb = const_cast<DynamicFontAtSize *>(p_fallbacks[i].ptr());
if (!fb->valid)
continue;
- FT_Get_Kerning( fb->face, p_char,p_next, FT_KERNING_DEFAULT, &delta );
+ FT_Get_Kerning(fb->face, p_char, p_next, FT_KERNING_DEFAULT, &delta);
- if (delta.x==0)
+ if (delta.x == 0)
continue;
- ret.x+=delta.x>>6;
+ ret.x += delta.x >> 6;
break;
}
} else {
- ret.x+=delta.x>>6;
+ ret.x += delta.x >> 6;
}
-
-
}
return ret;
}
-void DynamicFontAtSize::set_texture_flags(uint32_t p_flags){
-
- texture_flags=p_flags;
- for(int i=0;i<textures.size();i++) {
+void DynamicFontAtSize::set_texture_flags(uint32_t p_flags) {
+
+ texture_flags = p_flags;
+ for (int i = 0; i < textures.size(); i++) {
Ref<ImageTexture> &tex = textures[i].texture;
if (!tex.is_null())
tex->set_flags(p_flags);
}
}
-float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const {
+float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const {
if (!valid)
return 0;
- const_cast<DynamicFontAtSize*>(this)->_update_char(p_char);
+ const_cast<DynamicFontAtSize *>(this)->_update_char(p_char);
- const Character * c = char_map.getptr(p_char);
+ const Character *c = char_map.getptr(p_char);
- float advance=0;
+ float advance = 0;
if (!c->found) {
//not found, try in fallbacks
- bool used_fallback=false;
+ bool used_fallback = false;
- for(int i=0;i<p_fallbacks.size();i++) {
+ for (int i = 0; i < p_fallbacks.size(); i++) {
- DynamicFontAtSize *fb = const_cast<DynamicFontAtSize*>(p_fallbacks[i].ptr());
+ DynamicFontAtSize *fb = const_cast<DynamicFontAtSize *>(p_fallbacks[i].ptr());
if (!fb->valid)
continue;
@@ -347,93 +331,87 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2& p_pos, CharT
if (!ch->found)
continue;
- Point2 cpos=p_pos;
- cpos.x+=ch->h_align;
- cpos.y-=get_ascent();
- cpos.y+=ch->v_align;
- ERR_FAIL_COND_V( ch->texture_idx<-1 || ch->texture_idx>=fb->textures.size(),0);
- if (ch->texture_idx!=-1)
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region( p_canvas_item, Rect2( cpos, ch->rect.size ), fb->textures[ch->texture_idx].texture->get_rid(),ch->rect, p_modulate );
- advance=ch->advance;
- used_fallback=true;
+ Point2 cpos = p_pos;
+ cpos.x += ch->h_align;
+ cpos.y -= get_ascent();
+ cpos.y += ch->v_align;
+ ERR_FAIL_COND_V(ch->texture_idx < -1 || ch->texture_idx >= fb->textures.size(), 0);
+ if (ch->texture_idx != -1)
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), fb->textures[ch->texture_idx].texture->get_rid(), ch->rect, p_modulate);
+ advance = ch->advance;
+ used_fallback = true;
break;
}
//not found, try 0xFFFD to display 'not found'.
if (!used_fallback) {
- const_cast<DynamicFontAtSize*>(this)->_update_char(0xFFFD);
+ const_cast<DynamicFontAtSize *>(this)->_update_char(0xFFFD);
c = char_map.getptr(0xFFFD);
-
}
}
if (c->found) {
-
- Point2 cpos=p_pos;
- cpos.x+=c->h_align;
- cpos.y-=get_ascent();
- cpos.y+=c->v_align;
- ERR_FAIL_COND_V( c->texture_idx<-1 || c->texture_idx>=textures.size(),0);
- if (c->texture_idx!=-1)
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region( p_canvas_item, Rect2( cpos, c->rect.size ), textures[c->texture_idx].texture->get_rid(),c->rect, p_modulate );
- advance=c->advance;
+ Point2 cpos = p_pos;
+ cpos.x += c->h_align;
+ cpos.y -= get_ascent();
+ cpos.y += c->v_align;
+ ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), 0);
+ if (c->texture_idx != -1)
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx].texture->get_rid(), c->rect, p_modulate);
+ advance = c->advance;
//textures[c->texture_idx].texture->draw(p_canvas_item,Vector2());
}
-
if (p_next) {
- FT_Vector delta;
- FT_Get_Kerning( face, p_char,p_next, FT_KERNING_DEFAULT, &delta );
+ FT_Vector delta;
+ FT_Get_Kerning(face, p_char, p_next, FT_KERNING_DEFAULT, &delta);
- if (delta.x==0) {
- for(int i=0;i<p_fallbacks.size();i++) {
+ if (delta.x == 0) {
+ for (int i = 0; i < p_fallbacks.size(); i++) {
- DynamicFontAtSize *fb = const_cast<DynamicFontAtSize*>(p_fallbacks[i].ptr());
+ DynamicFontAtSize *fb = const_cast<DynamicFontAtSize *>(p_fallbacks[i].ptr());
if (!fb->valid)
continue;
- FT_Get_Kerning( fb->face, p_char,p_next, FT_KERNING_DEFAULT, &delta );
+ FT_Get_Kerning(fb->face, p_char, p_next, FT_KERNING_DEFAULT, &delta);
- if (delta.x==0)
+ if (delta.x == 0)
continue;
- advance+=delta.x>>6;
+ advance += delta.x >> 6;
break;
}
} else {
- advance+=delta.x>>6;
+ advance += delta.x >> 6;
}
}
return advance;
}
-unsigned long DynamicFontAtSize::_ft_stream_io(FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count ) {
+unsigned long DynamicFontAtSize::_ft_stream_io(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) {
+ FileAccess *f = (FileAccess *)stream->descriptor.pointer;
- FileAccess *f=(FileAccess*)stream->descriptor.pointer;
-
- if (f->get_pos()!=offset) {
+ if (f->get_pos() != offset) {
f->seek(offset);
-
}
- if (count==0)
+ if (count == 0)
return 0;
- return f->get_buffer(buffer,count);
+ return f->get_buffer(buffer, count);
}
void DynamicFontAtSize::_ft_stream_close(FT_Stream stream) {
- FileAccess *f=(FileAccess*)stream->descriptor.pointer;
+ FileAccess *f = (FileAccess *)stream->descriptor.pointer;
f->close();
memdelete(f);
}
-
void DynamicFontAtSize::_update_char(CharType p_char) {
if (char_map.has(p_char))
@@ -443,154 +421,146 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
FT_GlyphSlot slot = face->glyph;
- if (FT_Get_Char_Index( face, p_char)==0) {
+ if (FT_Get_Char_Index(face, p_char) == 0) {
//not found
Character ch;
- ch.texture_idx=-1;
- ch.advance=0;
- ch.h_align=0;
- ch.v_align=0;
- ch.found=false;
+ ch.texture_idx = -1;
+ ch.advance = 0;
+ ch.h_align = 0;
+ ch.v_align = 0;
+ ch.found = false;
- char_map[p_char]=ch;
+ char_map[p_char] = ch;
return;
}
- int error = FT_Load_Char( face, p_char, FT_LOAD_RENDER|(font->force_autohinter?FT_LOAD_FORCE_AUTOHINT:0) );
+ int error = FT_Load_Char(face, p_char, FT_LOAD_RENDER | (font->force_autohinter ? FT_LOAD_FORCE_AUTOHINT : 0));
if (!error) {
- error = FT_Render_Glyph( face->glyph, ft_render_mode_normal );
+ error = FT_Render_Glyph(face->glyph, ft_render_mode_normal);
}
if (error) {
- int advance=0;
+ int advance = 0;
//stbtt_GetCodepointHMetrics(&font->info, p_char, &advance, 0);
//print_line("char has no bitmap: "+itos(p_char)+" but advance is "+itos(advance*scale));
Character ch;
- ch.texture_idx=-1;
- ch.advance=advance;
- ch.h_align=0;
- ch.v_align=0;
- ch.found=false;
-
- char_map[p_char]=ch;
+ ch.texture_idx = -1;
+ ch.advance = advance;
+ ch.h_align = 0;
+ ch.v_align = 0;
+ ch.found = false;
+ char_map[p_char] = ch;
return;
}
-
-
int w = slot->bitmap.width;
int h = slot->bitmap.rows;
//int p = slot->bitmap.pitch;
- int yofs=slot->bitmap_top;
- int xofs=slot->bitmap_left;
- int advance=slot->advance.x>>6;
+ int yofs = slot->bitmap_top;
+ int xofs = slot->bitmap_left;
+ int advance = slot->advance.x >> 6;
+ int mw = w + rect_margin * 2;
+ int mh = h + rect_margin * 2;
- int mw=w+rect_margin*2;
- int mh=h+rect_margin*2;
+ if (mw > 4096 || mh > 4096) {
- if (mw>4096 || mh>4096) {
-
- ERR_FAIL_COND(mw>4096);
- ERR_FAIL_COND(mh>4096);
+ ERR_FAIL_COND(mw > 4096);
+ ERR_FAIL_COND(mh > 4096);
}
//find a texture to fit this...
- int tex_index=-1;
- int tex_x=0;
- int tex_y=0;
+ int tex_index = -1;
+ int tex_x = 0;
+ int tex_y = 0;
- for(int i=0;i<textures.size();i++) {
+ for (int i = 0; i < textures.size(); i++) {
- CharTexture &ct=textures[i];
+ CharTexture &ct = textures[i];
if (mw > ct.texture_size || mh > ct.texture_size) //too big for this texture
continue;
- tex_y=0x7FFFFFFF;
- tex_x=0;
+ tex_y = 0x7FFFFFFF;
+ tex_x = 0;
- for(int j=0;j<ct.texture_size-mw;j++) {
+ for (int j = 0; j < ct.texture_size - mw; j++) {
- int max_y=0;
+ int max_y = 0;
- for(int k=j;k<j+mw;k++) {
+ for (int k = j; k < j + mw; k++) {
int y = ct.offsets[k];
- if (y>max_y)
- max_y=y;
+ if (y > max_y)
+ max_y = y;
}
- if (max_y<tex_y) {
- tex_y=max_y;
- tex_x=j;
+ if (max_y < tex_y) {
+ tex_y = max_y;
+ tex_x = j;
}
}
- if (tex_y==0x7FFFFFFF || tex_y+mh > ct.texture_size)
+ if (tex_y == 0x7FFFFFFF || tex_y + mh > ct.texture_size)
continue; //fail, could not fit it here
- tex_index=i;
+ tex_index = i;
break;
}
-// print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
+ // print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
- if (tex_index==-1) {
+ if (tex_index == -1) {
//could not find texture to fit, create one
tex_x = 0;
tex_y = 0;
- int texsize = MAX(id.size*8,256);
- if (mw>texsize)
- texsize=mw; //special case, adapt to it?
- if (mh>texsize)
- texsize=mh; //special case, adapt to it?
+ int texsize = MAX(id.size * 8, 256);
+ if (mw > texsize)
+ texsize = mw; //special case, adapt to it?
+ if (mh > texsize)
+ texsize = mh; //special case, adapt to it?
- texsize=nearest_power_of_2(texsize);
-
- texsize=MIN(texsize,4096);
+ texsize = nearest_power_of_2(texsize);
+ texsize = MIN(texsize, 4096);
CharTexture tex;
- tex.texture_size=texsize;
- tex.imgdata.resize(texsize*texsize*2); //grayscale alpha
+ tex.texture_size = texsize;
+ tex.imgdata.resize(texsize * texsize * 2); //grayscale alpha
{
//zero texture
DVector<uint8_t>::Write w = tex.imgdata.write();
- ERR_FAIL_COND(texsize*texsize*2 > tex.imgdata.size());
- for(int i=0;i<texsize*texsize*2;i++) {
- w[i]=0;
+ ERR_FAIL_COND(texsize * texsize * 2 > tex.imgdata.size());
+ for (int i = 0; i < texsize * texsize * 2; i++) {
+ w[i] = 0;
}
}
tex.offsets.resize(texsize);
- for(int i=0;i<texsize;i++) //zero offsets
- tex.offsets[i]=0;
+ for (int i = 0; i < texsize; i++) //zero offsets
+ tex.offsets[i] = 0;
textures.push_back(tex);
- tex_index=textures.size()-1;
-
+ tex_index = textures.size() - 1;
}
-
//fit character in char texture
- CharTexture &tex=textures[tex_index];
+ CharTexture &tex = textures[tex_index];
{
DVector<uint8_t>::Write wr = tex.imgdata.write();
+ for (int i = 0; i < h; i++) {
+ for (int j = 0; j < w; j++) {
- for(int i=0;i<h;i++) {
- for(int j=0;j<w;j++) {
-
- int ofs = ( (i+tex_y+rect_margin)*tex.texture_size+j+tex_x+rect_margin)*2;
+ int ofs = ((i + tex_y + rect_margin) * tex.texture_size + j + tex_x + rect_margin) * 2;
ERR_FAIL_COND(ofs >= tex.imgdata.size());
- wr[ofs+0]=255; //grayscale as 1
- wr[ofs+1]=slot->bitmap.buffer[i*slot->bitmap.width+j];
+ wr[ofs + 0] = 255; //grayscale as 1
+ wr[ofs + 1] = slot->bitmap.buffer[i * slot->bitmap.width + j];
}
}
}
@@ -598,237 +568,224 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
//blit to image and texture
{
- Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_GRAYSCALE_ALPHA,tex.imgdata);
+ Image img(tex.texture_size, tex.texture_size, 0, Image::FORMAT_GRAYSCALE_ALPHA, tex.imgdata);
if (tex.texture.is_null()) {
tex.texture.instance();
- tex.texture->create_from_image(img,Texture::FLAG_VIDEO_SURFACE|texture_flags);
+ tex.texture->create_from_image(img, Texture::FLAG_VIDEO_SURFACE | texture_flags);
} else {
tex.texture->set_data(img); //update
}
-
}
-
// update height array
- for(int k=tex_x;k<tex_x+mw;k++) {
+ for (int k = tex_x; k < tex_x + mw; k++) {
- tex.offsets[k]=tex_y+mh;
+ tex.offsets[k] = tex_y + mh;
}
-
Character chr;
- chr.h_align=xofs;
- chr.v_align=ascent-yofs;// + ascent - descent;
- chr.advance=advance;
- chr.texture_idx=tex_index;
- chr.found=true;
-
+ chr.h_align = xofs;
+ chr.v_align = ascent - yofs; // + ascent - descent;
+ chr.advance = advance;
+ chr.texture_idx = tex_index;
+ chr.found = true;
- chr.rect=Rect2(tex_x+rect_margin,tex_y+rect_margin,w,h);
+ chr.rect = Rect2(tex_x + rect_margin, tex_y + rect_margin, w, h);
//print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" RECT: "+chr.rect+" X OFS: "+itos(xofs)+" Y OFS: "+itos(yofs));
- char_map[p_char]=chr;
-
-
+ char_map[p_char] = chr;
}
DynamicFontAtSize::DynamicFontAtSize() {
- valid=false;
- rect_margin=1;
- ascent=1;
- descent=1;
- linegap=1;
- texture_flags=0;
+ valid = false;
+ rect_margin = 1;
+ ascent = 1;
+ descent = 1;
+ linegap = 1;
+ texture_flags = 0;
}
-DynamicFontAtSize::~DynamicFontAtSize(){
+DynamicFontAtSize::~DynamicFontAtSize() {
if (valid) {
- FT_Done_FreeType( library );
+ FT_Done_FreeType(library);
font->size_cache.erase(id);
}
}
/////////////////////////
+void DynamicFont::_reload_cache() {
-void DynamicFont::_reload_cache(){
-
- ERR_FAIL_COND(cache_id.size<1);
+ ERR_FAIL_COND(cache_id.size < 1);
if (!data.is_valid())
return;
- data_at_size=data->_get_dynamic_font_at_size(cache_id);
- for (int i=0;i<fallbacks.size();i++){
- fallback_data_at_size[i]=fallbacks[i]->_get_dynamic_font_at_size(cache_id);
+ data_at_size = data->_get_dynamic_font_at_size(cache_id);
+ for (int i = 0; i < fallbacks.size(); i++) {
+ fallback_data_at_size[i] = fallbacks[i]->_get_dynamic_font_at_size(cache_id);
}
emit_changed();
_change_notify();
}
-void DynamicFont::set_font_data(const Ref<DynamicFontData>& p_data) {
+void DynamicFont::set_font_data(const Ref<DynamicFontData> &p_data) {
- data=p_data;
+ data = p_data;
if (data.is_valid())
- data_at_size=data->_get_dynamic_font_at_size(cache_id);
+ data_at_size = data->_get_dynamic_font_at_size(cache_id);
else
- data_at_size=Ref<DynamicFontAtSize>();
+ data_at_size = Ref<DynamicFontAtSize>();
emit_changed();
}
-
-Ref<DynamicFontData> DynamicFont::get_font_data() const{
+Ref<DynamicFontData> DynamicFont::get_font_data() const {
return data;
}
-void DynamicFont::set_size(int p_size){
+void DynamicFont::set_size(int p_size) {
- if (cache_id.size==p_size)
+ if (cache_id.size == p_size)
return;
- cache_id.size=p_size;
+ cache_id.size = p_size;
_reload_cache();
}
-int DynamicFont::get_size() const{
+int DynamicFont::get_size() const {
return cache_id.size;
}
-bool DynamicFont::get_use_mipmaps() const{
+bool DynamicFont::get_use_mipmaps() const {
return cache_id.mipmaps;
}
-void DynamicFont::set_use_mipmaps(bool p_enable){
+void DynamicFont::set_use_mipmaps(bool p_enable) {
- if (cache_id.mipmaps==p_enable)
+ if (cache_id.mipmaps == p_enable)
return;
- cache_id.mipmaps=p_enable;
+ cache_id.mipmaps = p_enable;
_reload_cache();
}
-bool DynamicFont::get_use_filter() const{
+bool DynamicFont::get_use_filter() const {
return cache_id.filter;
}
-void DynamicFont::set_use_filter(bool p_enable){
+void DynamicFont::set_use_filter(bool p_enable) {
- if (cache_id.filter==p_enable)
+ if (cache_id.filter == p_enable)
return;
- cache_id.filter=p_enable;
+ cache_id.filter = p_enable;
_reload_cache();
}
-int DynamicFont::get_spacing(int p_type) const{
+int DynamicFont::get_spacing(int p_type) const {
- if (p_type == SPACING_TOP){
+ if (p_type == SPACING_TOP) {
return spacing_top;
- }else if (p_type == SPACING_BOTTOM){
+ } else if (p_type == SPACING_BOTTOM) {
return spacing_bottom;
- }else if (p_type == SPACING_CHAR){
+ } else if (p_type == SPACING_CHAR) {
return spacing_char;
- }else if (p_type == SPACING_SPACE){
+ } else if (p_type == SPACING_SPACE) {
return spacing_space;
}
return 0;
}
-void DynamicFont::set_spacing(int p_type, int p_value){
+void DynamicFont::set_spacing(int p_type, int p_value) {
- if (p_type == SPACING_TOP){
- spacing_top=p_value;
- }else if (p_type == SPACING_BOTTOM){
- spacing_bottom=p_value;
- }else if (p_type == SPACING_CHAR){
- spacing_char=p_value;
- }else if (p_type == SPACING_SPACE){
- spacing_space=p_value;
+ if (p_type == SPACING_TOP) {
+ spacing_top = p_value;
+ } else if (p_type == SPACING_BOTTOM) {
+ spacing_bottom = p_value;
+ } else if (p_type == SPACING_CHAR) {
+ spacing_char = p_value;
+ } else if (p_type == SPACING_SPACE) {
+ spacing_space = p_value;
}
emit_changed();
_change_notify();
}
-float DynamicFont::get_height() const{
+float DynamicFont::get_height() const {
if (!data_at_size.is_valid())
return 1;
- return data_at_size->get_height()+spacing_top+spacing_bottom;
+ return data_at_size->get_height() + spacing_top + spacing_bottom;
}
-float DynamicFont::get_ascent() const{
+float DynamicFont::get_ascent() const {
if (!data_at_size.is_valid())
return 1;
- return data_at_size->get_ascent()+spacing_top;
+ return data_at_size->get_ascent() + spacing_top;
}
-float DynamicFont::get_descent() const{
+float DynamicFont::get_descent() const {
if (!data_at_size.is_valid())
return 1;
- return data_at_size->get_descent()+spacing_bottom;
-
+ return data_at_size->get_descent() + spacing_bottom;
}
-Size2 DynamicFont::get_char_size(CharType p_char,CharType p_next) const{
+Size2 DynamicFont::get_char_size(CharType p_char, CharType p_next) const {
if (!data_at_size.is_valid())
- return Size2(1,1);
+ return Size2(1, 1);
- Size2 ret=data_at_size->get_char_size(p_char,p_next,fallback_data_at_size);
- if (p_char==' ')
- ret.width+=spacing_space+spacing_char;
+ Size2 ret = data_at_size->get_char_size(p_char, p_next, fallback_data_at_size);
+ if (p_char == ' ')
+ ret.width += spacing_space + spacing_char;
else if (p_next)
- ret.width+=spacing_char;
+ ret.width += spacing_char;
return ret;
-
}
-bool DynamicFont::is_distance_field_hint() const{
+bool DynamicFont::is_distance_field_hint() const {
return false;
}
-float DynamicFont::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate) const {
+float DynamicFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate) const {
if (!data_at_size.is_valid())
return 0;
- return data_at_size->draw_char(p_canvas_item,p_pos,p_char,p_next,p_modulate,fallback_data_at_size)+spacing_char;
-
+ return data_at_size->draw_char(p_canvas_item, p_pos, p_char, p_next, p_modulate, fallback_data_at_size) + spacing_char;
}
-void DynamicFont::set_fallback(int p_idx,const Ref<DynamicFontData>& p_data) {
+void DynamicFont::set_fallback(int p_idx, const Ref<DynamicFontData> &p_data) {
ERR_FAIL_COND(p_data.is_null());
- ERR_FAIL_INDEX(p_idx,fallbacks.size());
- fallbacks[p_idx]=p_data;
- fallback_data_at_size[p_idx]=fallbacks[p_idx]->_get_dynamic_font_at_size(cache_id);
-
+ ERR_FAIL_INDEX(p_idx, fallbacks.size());
+ fallbacks[p_idx] = p_data;
+ fallback_data_at_size[p_idx] = fallbacks[p_idx]->_get_dynamic_font_at_size(cache_id);
}
-void DynamicFont::add_fallback(const Ref<DynamicFontData>& p_data) {
+void DynamicFont::add_fallback(const Ref<DynamicFontData> &p_data) {
ERR_FAIL_COND(p_data.is_null());
fallbacks.push_back(p_data);
- fallback_data_at_size.push_back(fallbacks[fallbacks.size()-1]->_get_dynamic_font_at_size(cache_id)); //const..
+ fallback_data_at_size.push_back(fallbacks[fallbacks.size() - 1]->_get_dynamic_font_at_size(cache_id)); //const..
_change_notify();
emit_changed();
_change_notify();
-
}
int DynamicFont::get_fallback_count() const {
@@ -836,37 +793,37 @@ int DynamicFont::get_fallback_count() const {
}
Ref<DynamicFontData> DynamicFont::get_fallback(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,fallbacks.size(),Ref<DynamicFontData>());
+ ERR_FAIL_INDEX_V(p_idx, fallbacks.size(), Ref<DynamicFontData>());
return fallbacks[p_idx];
}
void DynamicFont::remove_fallback(int p_idx) {
- ERR_FAIL_INDEX(p_idx,fallbacks.size());
+ ERR_FAIL_INDEX(p_idx, fallbacks.size());
fallbacks.remove(p_idx);
fallback_data_at_size.remove(p_idx);
emit_changed();
_change_notify();
}
-bool DynamicFont::_set(const StringName& p_name, const Variant& p_value) {
+bool DynamicFont::_set(const StringName &p_name, const Variant &p_value) {
String str = p_name;
if (str.begins_with("fallback/")) {
- int idx = str.get_slicec('/',1).to_int();
+ int idx = str.get_slicec('/', 1).to_int();
Ref<DynamicFontData> fd = p_value;
if (fd.is_valid()) {
- if (idx==fallbacks.size()) {
+ if (idx == fallbacks.size()) {
add_fallback(fd);
return true;
- } else if (idx>=0 && idx<fallbacks.size()) {
- set_fallback(idx,fd);
+ } else if (idx >= 0 && idx < fallbacks.size()) {
+ set_fallback(idx, fd);
return true;
} else {
return false;
}
- } else if (idx>=0 && idx<fallbacks.size()) {
+ } else if (idx >= 0 && idx < fallbacks.size()) {
remove_fallback(idx);
return true;
}
@@ -875,97 +832,92 @@ bool DynamicFont::_set(const StringName& p_name, const Variant& p_value) {
return false;
}
-bool DynamicFont::_get(const StringName& p_name,Variant &r_ret) const{
+bool DynamicFont::_get(const StringName &p_name, Variant &r_ret) const {
String str = p_name;
if (str.begins_with("fallback/")) {
- int idx = str.get_slicec('/',1).to_int();
+ int idx = str.get_slicec('/', 1).to_int();
- if (idx==fallbacks.size()) {
- r_ret=Ref<DynamicFontData>();
+ if (idx == fallbacks.size()) {
+ r_ret = Ref<DynamicFontData>();
return true;
- } else if (idx>=0 && idx<fallbacks.size()) {
- r_ret=get_fallback(idx);
+ } else if (idx >= 0 && idx < fallbacks.size()) {
+ r_ret = get_fallback(idx);
return true;
}
}
return false;
}
-void DynamicFont::_get_property_list( List<PropertyInfo> *p_list) const{
+void DynamicFont::_get_property_list(List<PropertyInfo> *p_list) const {
- for(int i=0;i<fallbacks.size();i++) {
- p_list->push_back(PropertyInfo(Variant::OBJECT,"fallback/"+itos(i),PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"));
+ for (int i = 0; i < fallbacks.size(); i++) {
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "fallback/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "DynamicFontData"));
}
- p_list->push_back(PropertyInfo(Variant::OBJECT,"fallback/"+itos(fallbacks.size()),PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "fallback/" + itos(fallbacks.size()), PROPERTY_HINT_RESOURCE_TYPE, "DynamicFontData"));
}
-
void DynamicFont::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
- ObjectTypeDB::bind_method(_MD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
-
- ObjectTypeDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size);
- ObjectTypeDB::bind_method(_MD("get_size"),&DynamicFont::get_size);
+ ObjectTypeDB::bind_method(_MD("set_font_data", "data:DynamicFontData"), &DynamicFont::set_font_data);
+ ObjectTypeDB::bind_method(_MD("get_font_data:DynamicFontData"), &DynamicFont::get_font_data);
- ObjectTypeDB::bind_method(_MD("set_use_mipmaps","enable"),&DynamicFont::set_use_mipmaps);
- ObjectTypeDB::bind_method(_MD("get_use_mipmaps"),&DynamicFont::get_use_mipmaps);
- ObjectTypeDB::bind_method(_MD("set_use_filter","enable"),&DynamicFont::set_use_filter);
- ObjectTypeDB::bind_method(_MD("get_use_filter"),&DynamicFont::get_use_filter);
- ObjectTypeDB::bind_method(_MD("set_spacing","type","value"),&DynamicFont::set_spacing);
- ObjectTypeDB::bind_method(_MD("get_spacing","type"),&DynamicFont::get_spacing);
+ ObjectTypeDB::bind_method(_MD("set_size", "data"), &DynamicFont::set_size);
+ ObjectTypeDB::bind_method(_MD("get_size"), &DynamicFont::get_size);
- ObjectTypeDB::bind_method(_MD("add_fallback","data:DynamicFontData"),&DynamicFont::add_fallback);
- ObjectTypeDB::bind_method(_MD("set_fallback","idx","data:DynamicFontData"),&DynamicFont::set_fallback);
- ObjectTypeDB::bind_method(_MD("get_fallback:DynamicFontData","idx"),&DynamicFont::get_fallback);
- ObjectTypeDB::bind_method(_MD("remove_fallback","idx"),&DynamicFont::remove_fallback);
- ObjectTypeDB::bind_method(_MD("get_fallback_count"),&DynamicFont::get_fallback_count);
+ ObjectTypeDB::bind_method(_MD("set_use_mipmaps", "enable"), &DynamicFont::set_use_mipmaps);
+ ObjectTypeDB::bind_method(_MD("get_use_mipmaps"), &DynamicFont::get_use_mipmaps);
+ ObjectTypeDB::bind_method(_MD("set_use_filter", "enable"), &DynamicFont::set_use_filter);
+ ObjectTypeDB::bind_method(_MD("get_use_filter"), &DynamicFont::get_use_filter);
+ ObjectTypeDB::bind_method(_MD("set_spacing", "type", "value"), &DynamicFont::set_spacing);
+ ObjectTypeDB::bind_method(_MD("get_spacing", "type"), &DynamicFont::get_spacing);
+ ObjectTypeDB::bind_method(_MD("add_fallback", "data:DynamicFontData"), &DynamicFont::add_fallback);
+ ObjectTypeDB::bind_method(_MD("set_fallback", "idx", "data:DynamicFontData"), &DynamicFont::set_fallback);
+ ObjectTypeDB::bind_method(_MD("get_fallback:DynamicFontData", "idx"), &DynamicFont::get_fallback);
+ ObjectTypeDB::bind_method(_MD("remove_fallback", "idx"), &DynamicFont::remove_fallback);
+ ObjectTypeDB::bind_method(_MD("get_fallback_count"), &DynamicFont::get_fallback_count);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"font/size"),_SCS("set_size"),_SCS("get_size"));
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing/top"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_TOP);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing/bottom"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_BOTTOM);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing/char"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_CHAR);
- ADD_PROPERTYINZ(PropertyInfo(Variant::INT,"extra_spacing/space"),_SCS("set_spacing"),_SCS("get_spacing"),SPACING_SPACE);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"font/use_mipmaps"),_SCS("set_use_mipmaps"),_SCS("get_use_mipmaps"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"font/use_filter"),_SCS("set_use_filter"),_SCS("get_use_filter"));
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font/font",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "font/size"), _SCS("set_size"), _SCS("get_size"));
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "extra_spacing/top"), _SCS("set_spacing"), _SCS("get_spacing"), SPACING_TOP);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "extra_spacing/bottom"), _SCS("set_spacing"), _SCS("get_spacing"), SPACING_BOTTOM);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "extra_spacing/char"), _SCS("set_spacing"), _SCS("get_spacing"), SPACING_CHAR);
+ ADD_PROPERTYINZ(PropertyInfo(Variant::INT, "extra_spacing/space"), _SCS("set_spacing"), _SCS("get_spacing"), SPACING_SPACE);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "font/use_mipmaps"), _SCS("set_use_mipmaps"), _SCS("get_use_mipmaps"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "font/use_filter"), _SCS("set_use_filter"), _SCS("get_use_filter"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "font/font", PROPERTY_HINT_RESOURCE_TYPE, "DynamicFontData"), _SCS("set_font_data"), _SCS("get_font_data"));
- BIND_CONSTANT( SPACING_TOP );
- BIND_CONSTANT( SPACING_BOTTOM );
- BIND_CONSTANT( SPACING_CHAR );
- BIND_CONSTANT( SPACING_SPACE );
+ BIND_CONSTANT(SPACING_TOP);
+ BIND_CONSTANT(SPACING_BOTTOM);
+ BIND_CONSTANT(SPACING_CHAR);
+ BIND_CONSTANT(SPACING_SPACE);
}
DynamicFont::DynamicFont() {
- spacing_top=0;
- spacing_bottom=0;
- spacing_char=0;
- spacing_space=0;
+ spacing_top = 0;
+ spacing_bottom = 0;
+ spacing_char = 0;
+ spacing_space = 0;
}
DynamicFont::~DynamicFont() {
-
}
/////////////////////////
-
-RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String& p_original_path, Error *r_error) {
+RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String &p_original_path, Error *r_error) {
if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
+ *r_error = ERR_FILE_CANT_OPEN;
Ref<DynamicFontData> dfont;
dfont.instance();
dfont->set_font_path(p_path);
-
if (r_error)
- *r_error=OK;
+ *r_error = OK;
return dfont;
}
@@ -976,18 +928,17 @@ void ResourceFormatLoaderDynamicFont::get_recognized_extensions(List<String> *p_
p_extensions->push_back("otf");
}
-bool ResourceFormatLoaderDynamicFont::handles_type(const String& p_type) const {
+bool ResourceFormatLoaderDynamicFont::handles_type(const String &p_type) const {
- return (p_type=="DynamicFontData");
+ return (p_type == "DynamicFontData");
}
String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) const {
String el = p_path.extension().to_lower();
- if (el=="ttf" || el=="otf")
+ if (el == "ttf" || el == "otf")
return "DynamicFontData";
return "";
}
-
#endif
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index 9d31a092f..f70da3841 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -30,54 +30,55 @@
#define DYNAMIC_FONT_H
#ifdef FREETYPE_ENABLED
-#include "scene/resources/font.h"
-#include "os/thread_safe.h"
#include "io/resource_loader.h"
+#include "os/thread_safe.h"
+#include "scene/resources/font.h"
#include <ft2build.h>
#include FT_FREETYPE_H
-
class DynamicFontAtSize;
class DynamicFont;
class DynamicFontData : public Resource {
- OBJ_TYPE(DynamicFontData,Resource);
+ OBJ_TYPE(DynamicFontData, Resource);
public:
-
- struct CacheID{
+ struct CacheID {
int size;
bool mipmaps;
bool filter;
- bool operator< (CacheID right) const;
- CacheID() { size=16; mipmaps=false; filter=false; }
+ bool operator<(CacheID right) const;
+ CacheID() {
+ size = 16;
+ mipmaps = false;
+ filter = false;
+ }
};
private:
-
const uint8_t *font_mem;
int font_mem_size;
bool force_autohinter;
String font_path;
- Map<CacheID,DynamicFontAtSize*> size_cache;
+ Map<CacheID, DynamicFontAtSize *> size_cache;
friend class DynamicFontAtSize;
-friend class DynamicFont;
+ friend class DynamicFont;
Ref<DynamicFontAtSize> _get_dynamic_font_at_size(CacheID p_cache);
-protected:
+protected:
static void _bind_methods();
-public:
- void set_font_ptr(const uint8_t* p_font_mem,int p_font_mem_size);
- void set_font_path(const String& p_path);
+public:
+ void set_font_ptr(const uint8_t *p_font_mem, int p_font_mem_size);
+ void set_font_path(const String &p_path);
String get_font_path() const;
void set_force_autohinter(bool p_force);
@@ -85,15 +86,14 @@ public:
~DynamicFontData();
};
-
class DynamicFontAtSize : public Reference {
- OBJ_TYPE(DynamicFontAtSize,Reference)
+ OBJ_TYPE(DynamicFontAtSize, Reference)
_THREAD_SAFE_CLASS_
- FT_Library library; /* handle to library */
- FT_Face face; /* handle to face object */
+ FT_Library library; /* handle to library */
+ FT_Face face; /* handle to face object */
FT_StreamRec stream;
int ascent;
@@ -124,39 +124,36 @@ class DynamicFontAtSize : public Reference {
float h_align;
float advance;
- Character() { texture_idx=0; v_align=0; }
+ Character() {
+ texture_idx = 0;
+ v_align = 0;
+ }
};
+ static unsigned long _ft_stream_io(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count);
+ static void _ft_stream_close(FT_Stream stream);
- static unsigned long _ft_stream_io(FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count );
- static void _ft_stream_close(FT_Stream stream);
-
- HashMap< CharType, Character > char_map;
+ HashMap<CharType, Character> char_map;
_FORCE_INLINE_ void _update_char(CharType p_char);
-friend class DynamicFontData;
+ friend class DynamicFontData;
Ref<DynamicFontData> font;
DynamicFontData::CacheID id;
-
- static HashMap< String, Vector<uint8_t> > _fontdata;
+ static HashMap<String, Vector<uint8_t> > _fontdata;
Error _load();
-protected:
-
-
+protected:
public:
-
-
float get_height() const;
float get_ascent() const;
float get_descent() const;
- Size2 get_char_size(CharType p_char,CharType p_next,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const;
+ Size2 get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const;
- float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate,const Vector<Ref<DynamicFontAtSize> >& p_fallbacks) const;
+ float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks) const;
void set_texture_flags(uint32_t p_flags);
@@ -168,11 +165,10 @@ public:
class DynamicFont : public Font {
- OBJ_TYPE( DynamicFont, Font );
+ OBJ_TYPE(DynamicFont, Font);
public:
-
- enum SpacingType{
+ enum SpacingType {
SPACING_TOP,
SPACING_BOTTOM,
SPACING_CHAR,
@@ -180,13 +176,11 @@ public:
};
private:
-
Ref<DynamicFontData> data;
Ref<DynamicFontAtSize> data_at_size;
- Vector< Ref<DynamicFontData> > fallbacks;
- Vector< Ref<DynamicFontAtSize> > fallback_data_at_size;
-
+ Vector<Ref<DynamicFontData> > fallbacks;
+ Vector<Ref<DynamicFontAtSize> > fallback_data_at_size;
DynamicFontData::CacheID cache_id;
bool valid;
@@ -196,18 +190,16 @@ private:
int spacing_space;
protected:
-
void _reload_cache();
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
- void set_font_data(const Ref<DynamicFontData>& p_data);
+ void set_font_data(const Ref<DynamicFontData> &p_data);
Ref<DynamicFontData> get_font_data() const;
void set_size(int p_size);
@@ -222,8 +214,8 @@ public:
int get_spacing(int p_type) const;
void set_spacing(int p_type, int p_value);
- void add_fallback(const Ref<DynamicFontData>& p_data);
- void set_fallback(int p_idx,const Ref<DynamicFontData>& p_data);
+ void add_fallback(const Ref<DynamicFontData> &p_data);
+ void set_fallback(int p_idx, const Ref<DynamicFontData> &p_data);
int get_fallback_count() const;
Ref<DynamicFontData> get_fallback(int p_idx) const;
void remove_fallback(int p_idx);
@@ -233,32 +225,26 @@ public:
virtual float get_ascent() const;
virtual float get_descent() const;
- virtual Size2 get_char_size(CharType p_char,CharType p_next=0) const;
+ virtual Size2 get_char_size(CharType p_char, CharType p_next = 0) const;
virtual bool is_distance_field_hint() const;
- virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const;
+ virtual float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next = 0, const Color &p_modulate = Color(1, 1, 1)) const;
DynamicFont();
~DynamicFont();
-
};
-
-
/////////////
class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader {
public:
-
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
+ virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
-
};
-
#endif
#endif
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index 456e6a5ee..eb7d71692 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -3,24 +3,24 @@
#ifndef FREETYPE_ENABLED
#define STB_TRUETYPE_IMPLEMENTATION
-#include "stb_truetype.h"
#include "os/file_access.h"
+#include "stb_truetype.h"
void DynamicFontData::lock() {
- fr=font_data.read();
+ fr = font_data.read();
- if (fr.ptr()!=last_data_ptr) {
+ if (fr.ptr() != last_data_ptr) {
- last_data_ptr=fr.ptr();
+ last_data_ptr = fr.ptr();
if (!stbtt_InitFont(&info, last_data_ptr, 0)) {
- valid=false;
+ valid = false;
} else {
- valid=true;
+ valid = true;
}
- last_data_ptr=fr.ptr();
+ last_data_ptr = fr.ptr();
}
}
@@ -29,26 +29,26 @@ void DynamicFontData::unlock() {
fr = DVector<uint8_t>::Read();
}
-void DynamicFontData::set_font_data(const DVector<uint8_t>& p_font) {
+void DynamicFontData::set_font_data(const DVector<uint8_t> &p_font) {
//clear caches and stuff
- ERR_FAIL_COND(font_data.size()) ;
- font_data=p_font;
+ ERR_FAIL_COND(font_data.size());
+ font_data = p_font;
lock();
if (valid) {
stbtt_GetFontVMetrics(&info, &ascent, &descent, &linegap);
- descent=-descent + linegap;
+ descent = -descent + linegap;
- for(int i=32;i<1024;i++) {
- for(int j=32;j<1024;j++) {
+ for (int i = 32; i < 1024; i++) {
+ for (int j = 32; j < 1024; j++) {
- int kern = stbtt_GetCodepointKernAdvance(&info, i,j);
- if (kern!=0) {
+ int kern = stbtt_GetCodepointKernAdvance(&info, i, j);
+ if (kern != 0) {
KerningPairKey kpk;
- kpk.A=i;
- kpk.B=j;
- kerning_map[kpk]=kern;
+ kpk.A = i;
+ kpk.B = j;
+ kerning_map[kpk] = kern;
}
}
}
@@ -62,21 +62,20 @@ void DynamicFontData::set_font_data(const DVector<uint8_t>& p_font) {
Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(int p_size) {
- ERR_FAIL_COND_V(!valid,Ref<DynamicFontAtSize>());
+ ERR_FAIL_COND_V(!valid, Ref<DynamicFontAtSize>());
if (size_cache.has(p_size)) {
- return Ref<DynamicFontAtSize>( size_cache[p_size] );
+ return Ref<DynamicFontAtSize>(size_cache[p_size]);
}
-
Ref<DynamicFontAtSize> dfas;
dfas.instance();
- dfas->font=Ref<DynamicFontData>( this );
+ dfas->font = Ref<DynamicFontData>(this);
- size_cache[p_size]=dfas.ptr();
+ size_cache[p_size] = dfas.ptr();
- dfas->size=p_size;
+ dfas->size = p_size;
lock();
@@ -85,100 +84,90 @@ Ref<DynamicFontAtSize> DynamicFontData::_get_dynamic_font_at_size(int p_size) {
unlock();
return dfas;
-
}
-DynamicFontData::DynamicFontData()
-{
- last_data_ptr=NULL;
- valid=false;
+DynamicFontData::DynamicFontData() {
+ last_data_ptr = NULL;
+ valid = false;
}
-DynamicFontData::~DynamicFontData()
-{
-
+DynamicFontData::~DynamicFontData() {
}
-
-
////////////////////
float DynamicFontAtSize::get_height() const {
- return (font->ascent+font->descent)*scale;
+ return (font->ascent + font->descent) * scale;
}
float DynamicFontAtSize::get_ascent() const {
- return font->ascent*scale;
+ return font->ascent * scale;
}
float DynamicFontAtSize::get_descent() const {
- return font->descent*scale;
+ return font->descent * scale;
}
-Size2 DynamicFontAtSize::get_char_size(CharType p_char,CharType p_next) const {
+Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next) const {
- const_cast<DynamicFontAtSize*>(this)->_update_char(p_char);
+ const_cast<DynamicFontAtSize *>(this)->_update_char(p_char);
const Character *c = char_map.getptr(p_char);
- ERR_FAIL_COND_V(!c,Size2());
+ ERR_FAIL_COND_V(!c, Size2());
- Size2 ret( c->advance, get_height());
+ Size2 ret(c->advance, get_height());
if (p_next) {
DynamicFontData::KerningPairKey kpk;
- kpk.A=p_char;
- kpk.B=p_next;
+ kpk.A = p_char;
+ kpk.B = p_next;
- const Map<DynamicFontData::KerningPairKey,int>::Element *K=font->kerning_map.find(kpk);
+ const Map<DynamicFontData::KerningPairKey, int>::Element *K = font->kerning_map.find(kpk);
if (K) {
- ret.x+=K->get()*scale;
+ ret.x += K->get() * scale;
}
-
}
return ret;
}
+float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate) const {
-float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate) const {
+ const_cast<DynamicFontAtSize *>(this)->_update_char(p_char);
- const_cast<DynamicFontAtSize*>(this)->_update_char(p_char);
-
- const Character * c = char_map.getptr(p_char);
+ const Character *c = char_map.getptr(p_char);
if (!c) {
return 0;
}
- Point2 cpos=p_pos;
- cpos.x+=c->h_align;
- cpos.y-=get_ascent();
- cpos.y+=c->v_align;
- ERR_FAIL_COND_V( c->texture_idx<-1 || c->texture_idx>=textures.size(),0);
- if (c->texture_idx!=-1)
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region( p_canvas_item, Rect2( cpos, c->rect.size ), textures[c->texture_idx].texture->get_rid(),c->rect, p_modulate );
+ Point2 cpos = p_pos;
+ cpos.x += c->h_align;
+ cpos.y -= get_ascent();
+ cpos.y += c->v_align;
+ ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), 0);
+ if (c->texture_idx != -1)
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx].texture->get_rid(), c->rect, p_modulate);
//textures[c->texture_idx].texture->draw(p_canvas_item,Vector2());
float ret = c->advance;
if (p_next) {
DynamicFontData::KerningPairKey kpk;
- kpk.A=p_char;
- kpk.B=p_next;
+ kpk.A = p_char;
+ kpk.B = p_next;
- const Map<DynamicFontData::KerningPairKey,int>::Element *K=font->kerning_map.find(kpk);
+ const Map<DynamicFontData::KerningPairKey, int>::Element *K = font->kerning_map.find(kpk);
if (K) {
- ret+=K->get()*scale;
+ ret += K->get() * scale;
}
-
}
return ret;
}
-
void DynamicFontAtSize::_update_char(CharType p_char) {
if (char_map.has(p_char))
@@ -186,9 +175,8 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
font->lock();
-
- int w,h,xofs,yofs;
- unsigned char * cpbitmap = stbtt_GetCodepointBitmap(&font->info, scale, scale, p_char, &w, &h, &xofs, &yofs );
+ int w, h, xofs, yofs;
+ unsigned char *cpbitmap = stbtt_GetCodepointBitmap(&font->info, scale, scale, p_char, &w, &h, &xofs, &yofs);
if (!cpbitmap) {
//no glyph
@@ -197,123 +185,120 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
stbtt_GetCodepointHMetrics(&font->info, p_char, &advance, 0);
//print_line("char has no bitmap: "+itos(p_char)+" but advance is "+itos(advance*scale));
Character ch;
- ch.texture_idx=-1;
- ch.advance=advance*scale;
- ch.h_align=0;
- ch.v_align=0;
+ ch.texture_idx = -1;
+ ch.advance = advance * scale;
+ ch.h_align = 0;
+ ch.v_align = 0;
- char_map[p_char]=ch;
+ char_map[p_char] = ch;
font->unlock();
return;
}
- int mw=w+rect_margin*2;
- int mh=h+rect_margin*2;
+ int mw = w + rect_margin * 2;
+ int mh = h + rect_margin * 2;
- if (mw>4096 || mh>4096) {
+ if (mw > 4096 || mh > 4096) {
- stbtt_FreeBitmap(cpbitmap,NULL);
+ stbtt_FreeBitmap(cpbitmap, NULL);
font->unlock();
- ERR_FAIL_COND(mw>4096);
- ERR_FAIL_COND(mh>4096);
+ ERR_FAIL_COND(mw > 4096);
+ ERR_FAIL_COND(mh > 4096);
}
//find a texture to fit this...
- int tex_index=-1;
- int tex_x=0;
- int tex_y=0;
+ int tex_index = -1;
+ int tex_x = 0;
+ int tex_y = 0;
- for(int i=0;i<textures.size();i++) {
+ for (int i = 0; i < textures.size(); i++) {
- CharTexture &ct=textures[i];
+ CharTexture &ct = textures[i];
if (mw > ct.texture_size || mh > ct.texture_size) //too big for this texture
continue;
- tex_y=0x7FFFFFFF;
- tex_x=0;
+ tex_y = 0x7FFFFFFF;
+ tex_x = 0;
- for(int j=0;j<ct.texture_size-mw;j++) {
+ for (int j = 0; j < ct.texture_size - mw; j++) {
- int max_y=0;
+ int max_y = 0;
- for(int k=j;k<j+mw;k++) {
+ for (int k = j; k < j + mw; k++) {
int y = ct.offsets[k];
- if (y>max_y)
- max_y=y;
+ if (y > max_y)
+ max_y = y;
}
- if (max_y<tex_y) {
- tex_y=max_y;
- tex_x=j;
+ if (max_y < tex_y) {
+ tex_y = max_y;
+ tex_x = j;
}
}
- if (tex_y==0x7FFFFFFF || tex_y+mh > ct.texture_size)
+ if (tex_y == 0x7FFFFFFF || tex_y + mh > ct.texture_size)
continue; //fail, could not fit it here
- tex_index=i;
+ tex_index = i;
break;
}
-// print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
+ // print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" X: "+itos(tex_x)+" Y: "+itos(tex_y));
- if (tex_index==-1) {
+ if (tex_index == -1) {
//could not find texture to fit, create one
tex_x = 0;
tex_y = 0;
- int texsize = MAX(size*8,256);
- if (mw>texsize)
- texsize=mw; //special case, adapt to it?
- if (mh>texsize)
- texsize=mh; //special case, adapt to it?
-
- texsize=nearest_power_of_2(texsize);
+ int texsize = MAX(size * 8, 256);
+ if (mw > texsize)
+ texsize = mw; //special case, adapt to it?
+ if (mh > texsize)
+ texsize = mh; //special case, adapt to it?
- texsize=MIN(texsize,4096);
+ texsize = nearest_power_of_2(texsize);
+ texsize = MIN(texsize, 4096);
CharTexture tex;
- tex.texture_size=texsize;
- tex.imgdata.resize(texsize*texsize*2); //grayscale alpha
+ tex.texture_size = texsize;
+ tex.imgdata.resize(texsize * texsize * 2); //grayscale alpha
{
//zero texture
DVector<uint8_t>::Write w = tex.imgdata.write();
- ERR_FAIL_COND(texsize*texsize*2 > tex.imgdata.size());
- for(int i=0;i<texsize*texsize*2;i++) {
- w[i]=0;
+ ERR_FAIL_COND(texsize * texsize * 2 > tex.imgdata.size());
+ for (int i = 0; i < texsize * texsize * 2; i++) {
+ w[i] = 0;
}
}
tex.offsets.resize(texsize);
- for(int i=0;i<texsize;i++) //zero offsets
- tex.offsets[i]=0;
+ for (int i = 0; i < texsize; i++) //zero offsets
+ tex.offsets[i] = 0;
textures.push_back(tex);
- tex_index=textures.size()-1;
-
+ tex_index = textures.size() - 1;
}
-
//fit character in char texture
- CharTexture &tex=textures[tex_index];
+ CharTexture &tex = textures[tex_index];
{
DVector<uint8_t>::Write wr = tex.imgdata.write();
- for(int i=0;i<h;i++) {
- for(int j=0;j<w;j++) {
+ for (int i = 0; i < h; i++) {
+ for (int j = 0; j < w; j++) {
- int ofs = ( (i+tex_y+rect_margin)*tex.texture_size+j+tex_x+rect_margin)*2;
+ int ofs = ((i + tex_y + rect_margin) * tex.texture_size + j + tex_x + rect_margin) * 2;
ERR_FAIL_COND(ofs >= tex.imgdata.size());
- wr[ofs+0]=255; //grayscale as 1
- wr[ofs+1]=cpbitmap[i*w+j]; //alpha as 0
+ wr[ofs + 0] = 255; //grayscale as 1
+ wr[ofs + 1] = cpbitmap[i * w + j]; //alpha as 0
}
}
}
@@ -321,53 +306,49 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
//blit to image and texture
{
- Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_GRAYSCALE_ALPHA,tex.imgdata);
+ Image img(tex.texture_size, tex.texture_size, 0, Image::FORMAT_GRAYSCALE_ALPHA, tex.imgdata);
if (tex.texture.is_null()) {
tex.texture.instance();
- tex.texture->create_from_image(img,Texture::FLAG_FILTER);
+ tex.texture->create_from_image(img, Texture::FLAG_FILTER);
} else {
tex.texture->set_data(img); //update
}
-
}
-
// update height array
- for(int k=tex_x;k<tex_x+mw;k++) {
+ for (int k = tex_x; k < tex_x + mw; k++) {
- tex.offsets[k]=tex_y+mh;
+ tex.offsets[k] = tex_y + mh;
}
int advance;
stbtt_GetCodepointHMetrics(&font->info, p_char, &advance, 0);
Character chr;
- chr.h_align=xofs;
- chr.v_align=yofs + get_ascent();
- chr.advance=advance*scale;
- chr.texture_idx=tex_index;
+ chr.h_align = xofs;
+ chr.v_align = yofs + get_ascent();
+ chr.advance = advance * scale;
+ chr.texture_idx = tex_index;
-
- chr.rect=Rect2(tex_x+rect_margin,tex_y+rect_margin,w,h);
+ chr.rect = Rect2(tex_x + rect_margin, tex_y + rect_margin, w, h);
//print_line("CHAR: "+String::chr(p_char)+" TEX INDEX: "+itos(tex_index)+" RECT: "+chr.rect+" X OFS: "+itos(xofs)+" Y OFS: "+itos(yofs));
- char_map[p_char]=chr;
+ char_map[p_char] = chr;
- stbtt_FreeBitmap(cpbitmap,NULL);
+ stbtt_FreeBitmap(cpbitmap, NULL);
font->unlock();
-
}
DynamicFontAtSize::DynamicFontAtSize() {
- rect_margin=1;
+ rect_margin = 1;
}
-DynamicFontAtSize::~DynamicFontAtSize(){
+DynamicFontAtSize::~DynamicFontAtSize() {
ERR_FAIL_COND(!font.ptr());
font->size_cache.erase(size);
@@ -375,48 +356,45 @@ DynamicFontAtSize::~DynamicFontAtSize(){
/////////////////////////
-
void DynamicFont::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_font_data","data:DynamicFontData"),&DynamicFont::set_font_data);
- ObjectTypeDB::bind_method(_MD("get_font_data:DynamicFontData"),&DynamicFont::get_font_data);
+ ObjectTypeDB::bind_method(_MD("set_font_data", "data:DynamicFontData"), &DynamicFont::set_font_data);
+ ObjectTypeDB::bind_method(_MD("get_font_data:DynamicFontData"), &DynamicFont::get_font_data);
- ObjectTypeDB::bind_method(_MD("set_size","data"),&DynamicFont::set_size);
- ObjectTypeDB::bind_method(_MD("get_size"),&DynamicFont::get_size);
+ ObjectTypeDB::bind_method(_MD("set_size", "data"), &DynamicFont::set_size);
+ ObjectTypeDB::bind_method(_MD("get_size"), &DynamicFont::get_size);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"font/size"),_SCS("set_size"),_SCS("get_size"));
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"font/font",PROPERTY_HINT_RESOURCE_TYPE,"DynamicFontData"),_SCS("set_font_data"),_SCS("get_font_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "font/size"), _SCS("set_size"), _SCS("get_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "font/font", PROPERTY_HINT_RESOURCE_TYPE, "DynamicFontData"), _SCS("set_font_data"), _SCS("get_font_data"));
}
+void DynamicFont::set_font_data(const Ref<DynamicFontData> &p_data) {
-void DynamicFont::set_font_data(const Ref<DynamicFontData>& p_data) {
-
- data=p_data;
- data_at_size=data->_get_dynamic_font_at_size(size);
+ data = p_data;
+ data_at_size = data->_get_dynamic_font_at_size(size);
}
-Ref<DynamicFontData> DynamicFont::get_font_data() const{
+Ref<DynamicFontData> DynamicFont::get_font_data() const {
return data;
}
-void DynamicFont::set_size(int p_size){
+void DynamicFont::set_size(int p_size) {
- if (size==p_size)
+ if (size == p_size)
return;
- size=p_size;
- ERR_FAIL_COND(p_size<1);
+ size = p_size;
+ ERR_FAIL_COND(p_size < 1);
if (!data.is_valid())
return;
- data_at_size=data->_get_dynamic_font_at_size(size);
-
+ data_at_size = data->_get_dynamic_font_at_size(size);
}
-int DynamicFont::get_size() const{
+int DynamicFont::get_size() const {
return size;
}
-float DynamicFont::get_height() const{
+float DynamicFont::get_height() const {
if (!data_at_size.is_valid())
return 1;
@@ -424,7 +402,7 @@ float DynamicFont::get_height() const{
return data_at_size->get_height();
}
-float DynamicFont::get_ascent() const{
+float DynamicFont::get_ascent() const {
if (!data_at_size.is_valid())
return 1;
@@ -432,68 +410,62 @@ float DynamicFont::get_ascent() const{
return data_at_size->get_ascent();
}
-float DynamicFont::get_descent() const{
+float DynamicFont::get_descent() const {
if (!data_at_size.is_valid())
return 1;
return data_at_size->get_descent();
-
}
-Size2 DynamicFont::get_char_size(CharType p_char,CharType p_next) const{
+Size2 DynamicFont::get_char_size(CharType p_char, CharType p_next) const {
if (!data_at_size.is_valid())
- return Size2(1,1);
-
- return data_at_size->get_char_size(p_char,p_next);
+ return Size2(1, 1);
+ return data_at_size->get_char_size(p_char, p_next);
}
-bool DynamicFont::is_distance_field_hint() const{
+bool DynamicFont::is_distance_field_hint() const {
return false;
}
-float DynamicFont::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next,const Color& p_modulate) const {
+float DynamicFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate) const {
if (!data_at_size.is_valid())
return 0;
- return data_at_size->draw_char(p_canvas_item,p_pos,p_char,p_next,p_modulate);
-
+ return data_at_size->draw_char(p_canvas_item, p_pos, p_char, p_next, p_modulate);
}
DynamicFont::DynamicFont() {
- size=16;
+ size = 16;
}
DynamicFont::~DynamicFont() {
-
}
/////////////////////////
-
-RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String& p_original_path, Error *r_error) {
+RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String &p_original_path, Error *r_error) {
if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
-
+ *r_error = ERR_FILE_CANT_OPEN;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
- ERR_FAIL_COND_V(!f,RES());
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
+ ERR_FAIL_COND_V(!f, RES());
DVector<uint8_t> data;
data.resize(f->get_len());
- ERR_FAIL_COND_V(data.size()==0,RES());
+ ERR_FAIL_COND_V(data.size() == 0, RES());
{
DVector<uint8_t>::Write w = data.write();
- f->get_buffer(w.ptr(),data.size());
+ f->get_buffer(w.ptr(), data.size());
}
Ref<DynamicFontData> dfd;
@@ -501,7 +473,7 @@ RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String& p_
dfd->set_font_data(data);
if (r_error)
- *r_error=OK;
+ *r_error = OK;
return dfd;
}
@@ -511,15 +483,15 @@ void ResourceFormatLoaderDynamicFont::get_recognized_extensions(List<String> *p_
p_extensions->push_back("ttf");
}
-bool ResourceFormatLoaderDynamicFont::handles_type(const String& p_type) const {
+bool ResourceFormatLoaderDynamicFont::handles_type(const String &p_type) const {
- return (p_type=="DynamicFontData");
+ return (p_type == "DynamicFontData");
}
String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) const {
String el = p_path.extension().to_lower();
- if (el=="ttf")
+ if (el == "ttf")
return "DynamicFontData";
return "";
}
diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h
index 136edff2f..f2a11b8db 100644
--- a/scene/resources/dynamic_font_stb.h
+++ b/scene/resources/dynamic_font_stb.h
@@ -4,43 +4,40 @@
#ifndef FREETYPE_ENABLED
#include "font.h"
-#include "stb_truetype.h"
#include "io/resource_loader.h"
-
-
+#include "stb_truetype.h"
class DynamicFontAtSize;
class DynamicFont;
class DynamicFontData : public Resource {
- OBJ_TYPE(DynamicFontData,Resource);
+ OBJ_TYPE(DynamicFontData, Resource);
bool valid;
DVector<uint8_t> font_data;
DVector<uint8_t>::Read fr;
- const uint8_t* last_data_ptr;
+ const uint8_t *last_data_ptr;
struct KerningPairKey {
union {
struct {
- uint32_t A,B;
+ uint32_t A, B;
};
uint64_t pair;
};
- _FORCE_INLINE_ bool operator<(const KerningPairKey& p_r) const { return pair<p_r.pair; }
+ _FORCE_INLINE_ bool operator<(const KerningPairKey &p_r) const { return pair < p_r.pair; }
};
- Map<KerningPairKey,int> kerning_map;
+ Map<KerningPairKey, int> kerning_map;
+ Map<int, DynamicFontAtSize *> size_cache;
- Map<int,DynamicFontAtSize*> size_cache;
-
-friend class DynamicFontAtSize;
+ friend class DynamicFontAtSize;
stbtt_fontinfo info;
int ascent;
@@ -50,22 +47,19 @@ friend class DynamicFontAtSize;
void lock();
void unlock();
-friend class DynamicFont;
-
+ friend class DynamicFont;
Ref<DynamicFontAtSize> _get_dynamic_font_at_size(int p_size);
-public:
- void set_font_data(const DVector<uint8_t>& p_font);
+public:
+ void set_font_data(const DVector<uint8_t> &p_font);
DynamicFontData();
~DynamicFontData();
};
-
class DynamicFontAtSize : public Reference {
- OBJ_TYPE(DynamicFontAtSize,Reference);
-
+ OBJ_TYPE(DynamicFontAtSize, Reference);
int rect_margin;
@@ -87,34 +81,31 @@ class DynamicFontAtSize : public Reference {
float h_align;
float advance;
- Character() { texture_idx=0; v_align=0; }
+ Character() {
+ texture_idx = 0;
+ v_align = 0;
+ }
};
-
-
- HashMap< CharType, Character > char_map;
+ HashMap<CharType, Character> char_map;
_FORCE_INLINE_ void _update_char(CharType p_char);
-friend class DynamicFontData;
+ friend class DynamicFontData;
Ref<DynamicFontData> font;
float scale;
int size;
protected:
-
public:
-
float get_height() const;
float get_ascent() const;
float get_descent() const;
- Size2 get_char_size(CharType p_char,CharType p_next=0) const;
-
- float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const;
-
+ Size2 get_char_size(CharType p_char, CharType p_next = 0) const;
+ float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next = 0, const Color &p_modulate = Color(1, 1, 1)) const;
DynamicFontAtSize();
~DynamicFontAtSize();
@@ -124,20 +115,17 @@ public:
class DynamicFont : public Font {
- OBJ_TYPE( DynamicFont, Font );
+ OBJ_TYPE(DynamicFont, Font);
Ref<DynamicFontData> data;
Ref<DynamicFontAtSize> data_at_size;
int size;
-
protected:
-
static void _bind_methods();
public:
-
- void set_font_data(const Ref<DynamicFontData>& p_data);
+ void set_font_data(const Ref<DynamicFontData> &p_data);
Ref<DynamicFontData> get_font_data() const;
void set_size(int p_size);
@@ -148,31 +136,25 @@ public:
virtual float get_ascent() const;
virtual float get_descent() const;
- virtual Size2 get_char_size(CharType p_char,CharType p_next=0) const;
+ virtual Size2 get_char_size(CharType p_char, CharType p_next = 0) const;
virtual bool is_distance_field_hint() const;
- virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const;
+ virtual float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next = 0, const Color &p_modulate = Color(1, 1, 1)) const;
DynamicFont();
~DynamicFont();
-
};
-
-
/////////////
class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader {
public:
-
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
+ virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
-
};
-
#endif
#endif // DYNAMICFONT_H
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index a7b7d291d..7138952b4 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -30,56 +30,50 @@
#include "texture.h"
void Environment::set_background(BG p_bg) {
- ERR_FAIL_INDEX(p_bg,BG_MAX);
- bg_mode=p_bg;
- VS::get_singleton()->environment_set_background(environment,VS::EnvironmentBG(p_bg));
+ ERR_FAIL_INDEX(p_bg, BG_MAX);
+ bg_mode = p_bg;
+ VS::get_singleton()->environment_set_background(environment, VS::EnvironmentBG(p_bg));
}
-Environment::BG Environment::get_background() const{
+Environment::BG Environment::get_background() const {
return bg_mode;
}
-void Environment::set_background_param(BGParam p_param, const Variant& p_value){
-
- ERR_FAIL_INDEX(p_param,BG_PARAM_MAX);
- bg_param[p_param]=p_value;
- VS::get_singleton()->environment_set_background_param(environment,VS::EnvironmentBGParam(p_param),p_value);
+void Environment::set_background_param(BGParam p_param, const Variant &p_value) {
+ ERR_FAIL_INDEX(p_param, BG_PARAM_MAX);
+ bg_param[p_param] = p_value;
+ VS::get_singleton()->environment_set_background_param(environment, VS::EnvironmentBGParam(p_param), p_value);
}
-Variant Environment::get_background_param(BGParam p_param) const{
+Variant Environment::get_background_param(BGParam p_param) const {
- ERR_FAIL_INDEX_V(p_param,BG_PARAM_MAX,Variant());
+ ERR_FAIL_INDEX_V(p_param, BG_PARAM_MAX, Variant());
return bg_param[p_param];
-
}
-void Environment::set_enable_fx(Fx p_effect,bool p_enabled){
-
- ERR_FAIL_INDEX(p_effect,FX_MAX);
- fx_enabled[p_effect]=p_enabled;
- VS::get_singleton()->environment_set_enable_fx(environment,VS::EnvironmentFx(p_effect),p_enabled);
+void Environment::set_enable_fx(Fx p_effect, bool p_enabled) {
+ ERR_FAIL_INDEX(p_effect, FX_MAX);
+ fx_enabled[p_effect] = p_enabled;
+ VS::get_singleton()->environment_set_enable_fx(environment, VS::EnvironmentFx(p_effect), p_enabled);
}
-bool Environment::is_fx_enabled(Fx p_effect) const{
+bool Environment::is_fx_enabled(Fx p_effect) const {
- ERR_FAIL_INDEX_V(p_effect,FX_MAX,false);
+ ERR_FAIL_INDEX_V(p_effect, FX_MAX, false);
return fx_enabled[p_effect];
-
}
-void Environment::fx_set_param(FxParam p_param,const Variant& p_value){
-
- ERR_FAIL_INDEX(p_param,FX_PARAM_MAX);
- fx_param[p_param]=p_value;
- VS::get_singleton()->environment_fx_set_param(environment,VS::EnvironmentFxParam(p_param),p_value);
+void Environment::fx_set_param(FxParam p_param, const Variant &p_value) {
+ ERR_FAIL_INDEX(p_param, FX_PARAM_MAX);
+ fx_param[p_param] = p_value;
+ VS::get_singleton()->environment_fx_set_param(environment, VS::EnvironmentFxParam(p_param), p_value);
}
-Variant Environment::fx_get_param(FxParam p_param) const{
+Variant Environment::fx_get_param(FxParam p_param) const {
- ERR_FAIL_INDEX_V(p_param,FX_PARAM_MAX,Variant());
+ ERR_FAIL_INDEX_V(p_param, FX_PARAM_MAX, Variant());
return fx_param[p_param];
-
}
RID Environment::get_rid() const {
@@ -89,71 +83,66 @@ RID Environment::get_rid() const {
void Environment::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_background","bgmode"),&Environment::set_background);
- ObjectTypeDB::bind_method(_MD("get_background"),&Environment::get_background);
-
- ObjectTypeDB::bind_method(_MD("set_background_param","param","value"),&Environment::set_background_param);
- ObjectTypeDB::bind_method(_MD("get_background_param","param"),&Environment::get_background_param);
-
- ObjectTypeDB::bind_method(_MD("set_enable_fx","effect","enabled"),&Environment::set_enable_fx);
- ObjectTypeDB::bind_method(_MD("is_fx_enabled","effect"),&Environment::is_fx_enabled);
+ ObjectTypeDB::bind_method(_MD("set_background", "bgmode"), &Environment::set_background);
+ ObjectTypeDB::bind_method(_MD("get_background"), &Environment::get_background);
- ObjectTypeDB::bind_method(_MD("fx_set_param","param","value"),&Environment::fx_set_param);
- ObjectTypeDB::bind_method(_MD("fx_get_param","param"),&Environment::fx_get_param);
+ ObjectTypeDB::bind_method(_MD("set_background_param", "param", "value"), &Environment::set_background_param);
+ ObjectTypeDB::bind_method(_MD("get_background_param", "param"), &Environment::get_background_param);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"ambient_light/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_AMBIENT_LIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"ambient_light/color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"ambient_light/energy",PROPERTY_HINT_RANGE,"0,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_ENERGY);
+ ObjectTypeDB::bind_method(_MD("set_enable_fx", "effect", "enabled"), &Environment::set_enable_fx);
+ ObjectTypeDB::bind_method(_MD("is_fx_enabled", "effect"), &Environment::is_fx_enabled);
+ ObjectTypeDB::bind_method(_MD("fx_set_param", "param", "value"), &Environment::fx_set_param);
+ ObjectTypeDB::bind_method(_MD("fx_get_param", "param"), &Environment::fx_get_param);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fxaa/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FXAA);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ambient_light/enabled"), _SCS("set_enable_fx"), _SCS("is_fx_enabled"), FX_AMBIENT_LIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "ambient_light/color", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_COLOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "ambient_light/energy", PROPERTY_HINT_RANGE, "0,64,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_ENERGY);
- ADD_PROPERTY( PropertyInfo(Variant::INT,"background/mode",PROPERTY_HINT_ENUM,"Keep,Default Color,Color,Texture,Cubemap,Canvas"),_SCS("set_background"),_SCS("get_background"));
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"background/color"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_TEXTURE);
- ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/cubemap",PROPERTY_HINT_RESOURCE_TYPE,"CubeMap"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CUBEMAP);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/energy",PROPERTY_HINT_RANGE,"0,128,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_ENERGY);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/scale",PROPERTY_HINT_RANGE,"0.001,16,0.001"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/glow",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_GLOW);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"background/canvas_max_layer"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CANVAS_MAX_LAYER);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fxaa/enabled"), _SCS("set_enable_fx"), _SCS("is_fx_enabled"), FX_FXAA);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"glow/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_GLOW);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_PASSES);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_scale",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_strength",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_STRENGTH);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_blend_mode",PROPERTY_HINT_ENUM,"Additive,Screen,SoftLight"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_BLEND_MODE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom",PROPERTY_HINT_RANGE,"0,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom_treshold",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM_TRESHOLD);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"dof_blur/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_DOF_BLUR);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"dof_blur/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_PASSES);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"dof_blur/begin",PROPERTY_HINT_RANGE,"0,4096,0.1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_BEGIN);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"dof_blur/range",PROPERTY_HINT_RANGE,"0,4096,0.1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_RANGE);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"hdr/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_HDR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/tonemapper",PROPERTY_HINT_ENUM,"Linear,Log,Reinhardt,ReinhardtAutoWhite"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_TONEMAPPER);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/exposure",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/white",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_WHITE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/glow_treshold",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_GLOW_TRESHOLD);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/glow_scale",PROPERTY_HINT_RANGE,"0.00,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_GLOW_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/min_luminance",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_MIN_LUMINANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/max_luminance",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_MAX_LUMINANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/exposure_adj_speed",PROPERTY_HINT_RANGE,"0.001,64,0.001"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fog/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FOG);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"fog/begin",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BEGIN);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"fog/begin_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BEGIN_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"fog/end_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_END_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"fog/attenuation",PROPERTY_HINT_EXP_EASING),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_ATTENUATION);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fog/bg"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BG);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"bcs/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_BCS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_BRIGHTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_CONTRAST);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/saturation",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_SATURATION);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"srgb/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_SRGB);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "background/mode", PROPERTY_HINT_ENUM, "Keep,Default Color,Color,Texture,Cubemap,Canvas"), _SCS("set_background"), _SCS("get_background"));
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "background/color"), _SCS("set_background_param"), _SCS("get_background_param"), BG_PARAM_COLOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "background/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_background_param"), _SCS("get_background_param"), BG_PARAM_TEXTURE);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "background/cubemap", PROPERTY_HINT_RESOURCE_TYPE, "CubeMap"), _SCS("set_background_param"), _SCS("get_background_param"), BG_PARAM_CUBEMAP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "background/energy", PROPERTY_HINT_RANGE, "0,128,0.01"), _SCS("set_background_param"), _SCS("get_background_param"), BG_PARAM_ENERGY);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "background/scale", PROPERTY_HINT_RANGE, "0.001,16,0.001"), _SCS("set_background_param"), _SCS("get_background_param"), BG_PARAM_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "background/glow", PROPERTY_HINT_RANGE, "0.00,8,0.01"), _SCS("set_background_param"), _SCS("get_background_param"), BG_PARAM_GLOW);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "background/canvas_max_layer"), _SCS("set_background_param"), _SCS("get_background_param"), BG_PARAM_CANVAS_MAX_LAYER);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow/enabled"), _SCS("set_enable_fx"), _SCS("is_fx_enabled"), FX_GLOW);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "glow/blur_passes", PROPERTY_HINT_RANGE, "1,4,1"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_PASSES);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "glow/blur_scale", PROPERTY_HINT_RANGE, "0.01,4,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "glow/blur_strength", PROPERTY_HINT_RANGE, "0.01,4,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_STRENGTH);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "glow/blur_blend_mode", PROPERTY_HINT_ENUM, "Additive,Screen,SoftLight"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_BLEND_MODE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "glow/bloom", PROPERTY_HINT_RANGE, "0,8,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "glow/bloom_treshold", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM_TRESHOLD);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "dof_blur/enabled"), _SCS("set_enable_fx"), _SCS("is_fx_enabled"), FX_DOF_BLUR);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, "dof_blur/blur_passes", PROPERTY_HINT_RANGE, "1,4,1"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_DOF_BLUR_PASSES);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "dof_blur/begin", PROPERTY_HINT_RANGE, "0,4096,0.1"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_DOF_BLUR_BEGIN);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "dof_blur/range", PROPERTY_HINT_RANGE, "0,4096,0.1"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_DOF_BLUR_RANGE);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "hdr/enabled"), _SCS("set_enable_fx"), _SCS("is_fx_enabled"), FX_HDR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hdr/tonemapper", PROPERTY_HINT_ENUM, "Linear,Log,Reinhardt,ReinhardtAutoWhite"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_HDR_TONEMAPPER);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hdr/exposure", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hdr/white", PROPERTY_HINT_RANGE, "0.01,16,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_HDR_WHITE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hdr/glow_treshold", PROPERTY_HINT_RANGE, "0.00,8,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_HDR_GLOW_TRESHOLD);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hdr/glow_scale", PROPERTY_HINT_RANGE, "0.00,16,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_HDR_GLOW_SCALE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hdr/min_luminance", PROPERTY_HINT_RANGE, "0.01,64,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_HDR_MIN_LUMINANCE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hdr/max_luminance", PROPERTY_HINT_RANGE, "0.01,64,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_HDR_MAX_LUMINANCE);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "hdr/exposure_adj_speed", PROPERTY_HINT_RANGE, "0.001,64,0.001"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fog/enabled"), _SCS("set_enable_fx"), _SCS("is_fx_enabled"), FX_FOG);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "fog/begin", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_FOG_BEGIN);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "fog/begin_color", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_FOG_BEGIN_COLOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "fog/end_color", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_FOG_END_COLOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "fog/attenuation", PROPERTY_HINT_EXP_EASING), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_FOG_ATTENUATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fog/bg"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_FOG_BG);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "bcs/enabled"), _SCS("set_enable_fx"), _SCS("is_fx_enabled"), FX_BCS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "bcs/brightness", PROPERTY_HINT_RANGE, "0.01,8,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_BCS_BRIGHTNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "bcs/contrast", PROPERTY_HINT_RANGE, "0.01,8,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_BCS_CONTRAST);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "bcs/saturation", PROPERTY_HINT_RANGE, "0.01,8,0.01"), _SCS("fx_set_param"), _SCS("fx_get_param"), FX_PARAM_BCS_SATURATION);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "srgb/enabled"), _SCS("set_enable_fx"), _SCS("is_fx_enabled"), FX_SRGB);
-
-
-
-/*
+ /*
FX_PARAM_BLOOM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_BLOOM_GLOW_BLUR_PASSES,
FX_PARAM_BLOOM_AMOUNT=VS::ENV_FX_PARAM_BLOOM_AMOUNT,
FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
@@ -178,72 +167,69 @@ void Environment::_bind_methods() {
FX_PARAM_MAX=VS::ENV_FX_PARAM_MAX
*/
- BIND_CONSTANT( BG_KEEP );
- BIND_CONSTANT( BG_DEFAULT_COLOR );
- BIND_CONSTANT( BG_COLOR );
- BIND_CONSTANT( BG_TEXTURE );
- BIND_CONSTANT( BG_CUBEMAP );
- BIND_CONSTANT( BG_CANVAS );
- BIND_CONSTANT( BG_MAX );
-
- BIND_CONSTANT( BG_PARAM_CANVAS_MAX_LAYER );
- BIND_CONSTANT( BG_PARAM_COLOR );
- BIND_CONSTANT( BG_PARAM_TEXTURE );
- BIND_CONSTANT( BG_PARAM_CUBEMAP );
- BIND_CONSTANT( BG_PARAM_ENERGY );
- BIND_CONSTANT( BG_PARAM_GLOW );
- BIND_CONSTANT( BG_PARAM_MAX );
+ BIND_CONSTANT(BG_KEEP);
+ BIND_CONSTANT(BG_DEFAULT_COLOR);
+ BIND_CONSTANT(BG_COLOR);
+ BIND_CONSTANT(BG_TEXTURE);
+ BIND_CONSTANT(BG_CUBEMAP);
+ BIND_CONSTANT(BG_CANVAS);
+ BIND_CONSTANT(BG_MAX);
+ BIND_CONSTANT(BG_PARAM_CANVAS_MAX_LAYER);
+ BIND_CONSTANT(BG_PARAM_COLOR);
+ BIND_CONSTANT(BG_PARAM_TEXTURE);
+ BIND_CONSTANT(BG_PARAM_CUBEMAP);
+ BIND_CONSTANT(BG_PARAM_ENERGY);
+ BIND_CONSTANT(BG_PARAM_GLOW);
+ BIND_CONSTANT(BG_PARAM_MAX);
- BIND_CONSTANT( FX_AMBIENT_LIGHT );
- BIND_CONSTANT( FX_FXAA );
- BIND_CONSTANT( FX_GLOW );
- BIND_CONSTANT( FX_DOF_BLUR );
- BIND_CONSTANT( FX_HDR );
- BIND_CONSTANT( FX_FOG );
- BIND_CONSTANT( FX_BCS);
- BIND_CONSTANT( FX_SRGB );
- BIND_CONSTANT( FX_MAX );
+ BIND_CONSTANT(FX_AMBIENT_LIGHT);
+ BIND_CONSTANT(FX_FXAA);
+ BIND_CONSTANT(FX_GLOW);
+ BIND_CONSTANT(FX_DOF_BLUR);
+ BIND_CONSTANT(FX_HDR);
+ BIND_CONSTANT(FX_FOG);
+ BIND_CONSTANT(FX_BCS);
+ BIND_CONSTANT(FX_SRGB);
+ BIND_CONSTANT(FX_MAX);
+ BIND_CONSTANT(FX_BLUR_BLEND_MODE_ADDITIVE);
+ BIND_CONSTANT(FX_BLUR_BLEND_MODE_SCREEN);
+ BIND_CONSTANT(FX_BLUR_BLEND_MODE_SOFTLIGHT);
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_ADDITIVE );
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_SCREEN );
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_SOFTLIGHT );
-
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_LINEAR );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_LOG );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_REINHARDT );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE );
-
- BIND_CONSTANT( FX_PARAM_AMBIENT_LIGHT_COLOR );
- BIND_CONSTANT( FX_PARAM_AMBIENT_LIGHT_ENERGY );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_PASSES );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_SCALE );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_STRENGTH );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_BLEND_MODE );
- BIND_CONSTANT( FX_PARAM_GLOW_BLOOM);
- BIND_CONSTANT( FX_PARAM_GLOW_BLOOM_TRESHOLD);
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_PASSES );
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_BEGIN );
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_RANGE );
- BIND_CONSTANT( FX_PARAM_HDR_TONEMAPPER);
- BIND_CONSTANT( FX_PARAM_HDR_EXPOSURE );
- BIND_CONSTANT( FX_PARAM_HDR_WHITE );
- BIND_CONSTANT( FX_PARAM_HDR_GLOW_TRESHOLD );
- BIND_CONSTANT( FX_PARAM_HDR_GLOW_SCALE );
- BIND_CONSTANT( FX_PARAM_HDR_MIN_LUMINANCE );
- BIND_CONSTANT( FX_PARAM_HDR_MAX_LUMINANCE );
- BIND_CONSTANT( FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED );
- BIND_CONSTANT( FX_PARAM_FOG_BEGIN );
- BIND_CONSTANT( FX_PARAM_FOG_ATTENUATION );
- BIND_CONSTANT( FX_PARAM_FOG_BEGIN_COLOR );
- BIND_CONSTANT( FX_PARAM_FOG_END_COLOR );
- BIND_CONSTANT( FX_PARAM_FOG_BG );
- BIND_CONSTANT( FX_PARAM_BCS_BRIGHTNESS );
- BIND_CONSTANT( FX_PARAM_BCS_CONTRAST );
- BIND_CONSTANT( FX_PARAM_BCS_SATURATION );
- BIND_CONSTANT( FX_PARAM_MAX );
+ BIND_CONSTANT(FX_HDR_TONE_MAPPER_LINEAR);
+ BIND_CONSTANT(FX_HDR_TONE_MAPPER_LOG);
+ BIND_CONSTANT(FX_HDR_TONE_MAPPER_REINHARDT);
+ BIND_CONSTANT(FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE);
+ BIND_CONSTANT(FX_PARAM_AMBIENT_LIGHT_COLOR);
+ BIND_CONSTANT(FX_PARAM_AMBIENT_LIGHT_ENERGY);
+ BIND_CONSTANT(FX_PARAM_GLOW_BLUR_PASSES);
+ BIND_CONSTANT(FX_PARAM_GLOW_BLUR_SCALE);
+ BIND_CONSTANT(FX_PARAM_GLOW_BLUR_STRENGTH);
+ BIND_CONSTANT(FX_PARAM_GLOW_BLUR_BLEND_MODE);
+ BIND_CONSTANT(FX_PARAM_GLOW_BLOOM);
+ BIND_CONSTANT(FX_PARAM_GLOW_BLOOM_TRESHOLD);
+ BIND_CONSTANT(FX_PARAM_DOF_BLUR_PASSES);
+ BIND_CONSTANT(FX_PARAM_DOF_BLUR_BEGIN);
+ BIND_CONSTANT(FX_PARAM_DOF_BLUR_RANGE);
+ BIND_CONSTANT(FX_PARAM_HDR_TONEMAPPER);
+ BIND_CONSTANT(FX_PARAM_HDR_EXPOSURE);
+ BIND_CONSTANT(FX_PARAM_HDR_WHITE);
+ BIND_CONSTANT(FX_PARAM_HDR_GLOW_TRESHOLD);
+ BIND_CONSTANT(FX_PARAM_HDR_GLOW_SCALE);
+ BIND_CONSTANT(FX_PARAM_HDR_MIN_LUMINANCE);
+ BIND_CONSTANT(FX_PARAM_HDR_MAX_LUMINANCE);
+ BIND_CONSTANT(FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED);
+ BIND_CONSTANT(FX_PARAM_FOG_BEGIN);
+ BIND_CONSTANT(FX_PARAM_FOG_ATTENUATION);
+ BIND_CONSTANT(FX_PARAM_FOG_BEGIN_COLOR);
+ BIND_CONSTANT(FX_PARAM_FOG_END_COLOR);
+ BIND_CONSTANT(FX_PARAM_FOG_BG);
+ BIND_CONSTANT(FX_PARAM_BCS_BRIGHTNESS);
+ BIND_CONSTANT(FX_PARAM_BCS_CONTRAST);
+ BIND_CONSTANT(FX_PARAM_BCS_SATURATION);
+ BIND_CONSTANT(FX_PARAM_MAX);
}
Environment::Environment() {
@@ -251,43 +237,42 @@ Environment::Environment() {
environment = VS::get_singleton()->environment_create();
set_background(BG_DEFAULT_COLOR);
- set_background_param(BG_PARAM_COLOR,Color(0,0,0));
- set_background_param(BG_PARAM_TEXTURE,Ref<ImageTexture>());
- set_background_param(BG_PARAM_CUBEMAP,Ref<CubeMap>());
- set_background_param(BG_PARAM_ENERGY,1.0);
- set_background_param(BG_PARAM_SCALE,1.0);
- set_background_param(BG_PARAM_GLOW,0.0);
-
- for(int i=0;i<FX_MAX;i++)
- set_enable_fx(Fx(i),false);
+ set_background_param(BG_PARAM_COLOR, Color(0, 0, 0));
+ set_background_param(BG_PARAM_TEXTURE, Ref<ImageTexture>());
+ set_background_param(BG_PARAM_CUBEMAP, Ref<CubeMap>());
+ set_background_param(BG_PARAM_ENERGY, 1.0);
+ set_background_param(BG_PARAM_SCALE, 1.0);
+ set_background_param(BG_PARAM_GLOW, 0.0);
- fx_set_param(FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_AMBIENT_LIGHT_ENERGY,1.0);
- fx_set_param(FX_PARAM_GLOW_BLUR_PASSES,1);
- fx_set_param(FX_PARAM_GLOW_BLUR_SCALE,1);
- fx_set_param(FX_PARAM_GLOW_BLUR_STRENGTH,1);
- fx_set_param(FX_PARAM_GLOW_BLOOM,0.0);
- fx_set_param(FX_PARAM_GLOW_BLOOM_TRESHOLD,0.5);
- fx_set_param(FX_PARAM_DOF_BLUR_PASSES,1);
- fx_set_param(FX_PARAM_DOF_BLUR_BEGIN,100.0);
- fx_set_param(FX_PARAM_DOF_BLUR_RANGE,10.0);
- fx_set_param(FX_PARAM_HDR_TONEMAPPER,FX_HDR_TONE_MAPPER_LINEAR);
- fx_set_param(FX_PARAM_HDR_EXPOSURE,0.4);
- fx_set_param(FX_PARAM_HDR_WHITE,1.0);
- fx_set_param(FX_PARAM_HDR_GLOW_TRESHOLD,0.95);
- fx_set_param(FX_PARAM_HDR_GLOW_SCALE,0.2);
- fx_set_param(FX_PARAM_HDR_MIN_LUMINANCE,0.4);
- fx_set_param(FX_PARAM_HDR_MAX_LUMINANCE,8.0);
- fx_set_param(FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,0.5);
- fx_set_param(FX_PARAM_FOG_BEGIN,100.0);
- fx_set_param(FX_PARAM_FOG_ATTENUATION,1.0);
- fx_set_param(FX_PARAM_FOG_BEGIN_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_FOG_END_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_FOG_BG,true);
- fx_set_param(FX_PARAM_BCS_BRIGHTNESS,1.0);
- fx_set_param(FX_PARAM_BCS_CONTRAST,1.0);
- fx_set_param(FX_PARAM_BCS_SATURATION,1.0);
+ for (int i = 0; i < FX_MAX; i++)
+ set_enable_fx(Fx(i), false);
+ fx_set_param(FX_PARAM_AMBIENT_LIGHT_COLOR, Color(0, 0, 0));
+ fx_set_param(FX_PARAM_AMBIENT_LIGHT_ENERGY, 1.0);
+ fx_set_param(FX_PARAM_GLOW_BLUR_PASSES, 1);
+ fx_set_param(FX_PARAM_GLOW_BLUR_SCALE, 1);
+ fx_set_param(FX_PARAM_GLOW_BLUR_STRENGTH, 1);
+ fx_set_param(FX_PARAM_GLOW_BLOOM, 0.0);
+ fx_set_param(FX_PARAM_GLOW_BLOOM_TRESHOLD, 0.5);
+ fx_set_param(FX_PARAM_DOF_BLUR_PASSES, 1);
+ fx_set_param(FX_PARAM_DOF_BLUR_BEGIN, 100.0);
+ fx_set_param(FX_PARAM_DOF_BLUR_RANGE, 10.0);
+ fx_set_param(FX_PARAM_HDR_TONEMAPPER, FX_HDR_TONE_MAPPER_LINEAR);
+ fx_set_param(FX_PARAM_HDR_EXPOSURE, 0.4);
+ fx_set_param(FX_PARAM_HDR_WHITE, 1.0);
+ fx_set_param(FX_PARAM_HDR_GLOW_TRESHOLD, 0.95);
+ fx_set_param(FX_PARAM_HDR_GLOW_SCALE, 0.2);
+ fx_set_param(FX_PARAM_HDR_MIN_LUMINANCE, 0.4);
+ fx_set_param(FX_PARAM_HDR_MAX_LUMINANCE, 8.0);
+ fx_set_param(FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED, 0.5);
+ fx_set_param(FX_PARAM_FOG_BEGIN, 100.0);
+ fx_set_param(FX_PARAM_FOG_ATTENUATION, 1.0);
+ fx_set_param(FX_PARAM_FOG_BEGIN_COLOR, Color(0, 0, 0));
+ fx_set_param(FX_PARAM_FOG_END_COLOR, Color(0, 0, 0));
+ fx_set_param(FX_PARAM_FOG_BG, true);
+ fx_set_param(FX_PARAM_BCS_BRIGHTNESS, 1.0);
+ fx_set_param(FX_PARAM_BCS_CONTRAST, 1.0);
+ fx_set_param(FX_PARAM_BCS_SATURATION, 1.0);
}
Environment::~Environment() {
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index c00fa0ab5..74a5796c8 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -34,42 +34,42 @@
class Environment : public Resource {
- OBJ_TYPE(Environment,Resource);
-public:
+ OBJ_TYPE(Environment, Resource);
+public:
enum BG {
- BG_KEEP=VS::ENV_BG_KEEP,
- BG_DEFAULT_COLOR=VS::ENV_BG_DEFAULT_COLOR,
- BG_COLOR=VS::ENV_BG_COLOR,
- BG_TEXTURE=VS::ENV_BG_TEXTURE,
- BG_CUBEMAP=VS::ENV_BG_CUBEMAP,
- BG_CANVAS=VS::ENV_BG_CANVAS,
- BG_MAX=VS::ENV_BG_MAX
+ BG_KEEP = VS::ENV_BG_KEEP,
+ BG_DEFAULT_COLOR = VS::ENV_BG_DEFAULT_COLOR,
+ BG_COLOR = VS::ENV_BG_COLOR,
+ BG_TEXTURE = VS::ENV_BG_TEXTURE,
+ BG_CUBEMAP = VS::ENV_BG_CUBEMAP,
+ BG_CANVAS = VS::ENV_BG_CANVAS,
+ BG_MAX = VS::ENV_BG_MAX
};
enum BGParam {
- BG_PARAM_CANVAS_MAX_LAYER=VS::ENV_BG_PARAM_CANVAS_MAX_LAYER,
- BG_PARAM_COLOR=VS::ENV_BG_PARAM_COLOR,
- BG_PARAM_TEXTURE=VS::ENV_BG_PARAM_TEXTURE,
- BG_PARAM_CUBEMAP=VS::ENV_BG_PARAM_CUBEMAP,
- BG_PARAM_ENERGY=VS::ENV_BG_PARAM_ENERGY,
- BG_PARAM_SCALE=VS::ENV_BG_PARAM_SCALE,
- BG_PARAM_GLOW=VS::ENV_BG_PARAM_GLOW,
- BG_PARAM_MAX=VS::ENV_BG_PARAM_MAX
+ BG_PARAM_CANVAS_MAX_LAYER = VS::ENV_BG_PARAM_CANVAS_MAX_LAYER,
+ BG_PARAM_COLOR = VS::ENV_BG_PARAM_COLOR,
+ BG_PARAM_TEXTURE = VS::ENV_BG_PARAM_TEXTURE,
+ BG_PARAM_CUBEMAP = VS::ENV_BG_PARAM_CUBEMAP,
+ BG_PARAM_ENERGY = VS::ENV_BG_PARAM_ENERGY,
+ BG_PARAM_SCALE = VS::ENV_BG_PARAM_SCALE,
+ BG_PARAM_GLOW = VS::ENV_BG_PARAM_GLOW,
+ BG_PARAM_MAX = VS::ENV_BG_PARAM_MAX
};
enum Fx {
- FX_AMBIENT_LIGHT=VS::ENV_FX_AMBIENT_LIGHT,
- FX_FXAA=VS::ENV_FX_FXAA,
- FX_GLOW=VS::ENV_FX_GLOW,
- FX_DOF_BLUR=VS::ENV_FX_DOF_BLUR,
- FX_HDR=VS::ENV_FX_HDR,
- FX_FOG=VS::ENV_FX_FOG,
- FX_BCS=VS::ENV_FX_BCS,
- FX_SRGB=VS::ENV_FX_SRGB,
- FX_MAX=VS::ENV_FX_MAX,
+ FX_AMBIENT_LIGHT = VS::ENV_FX_AMBIENT_LIGHT,
+ FX_FXAA = VS::ENV_FX_FXAA,
+ FX_GLOW = VS::ENV_FX_GLOW,
+ FX_DOF_BLUR = VS::ENV_FX_DOF_BLUR,
+ FX_HDR = VS::ENV_FX_HDR,
+ FX_FOG = VS::ENV_FX_FOG,
+ FX_BCS = VS::ENV_FX_BCS,
+ FX_SRGB = VS::ENV_FX_SRGB,
+ FX_MAX = VS::ENV_FX_MAX,
};
enum FxBlurBlendMode {
@@ -86,37 +86,37 @@ public:
};
enum FxParam {
- FX_PARAM_AMBIENT_LIGHT_COLOR=VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR,
- FX_PARAM_AMBIENT_LIGHT_ENERGY=VS::ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY,
- FX_PARAM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_GLOW_BLUR_PASSES,
- FX_PARAM_GLOW_BLUR_SCALE=VS::ENV_FX_PARAM_GLOW_BLUR_SCALE,
- FX_PARAM_GLOW_BLUR_STRENGTH=VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH,
- FX_PARAM_GLOW_BLUR_BLEND_MODE=VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE,
- FX_PARAM_GLOW_BLOOM=VS::ENV_FX_PARAM_GLOW_BLOOM,
- FX_PARAM_GLOW_BLOOM_TRESHOLD=VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD,
- FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
- FX_PARAM_DOF_BLUR_BEGIN=VS::ENV_FX_PARAM_DOF_BLUR_BEGIN,
- FX_PARAM_DOF_BLUR_RANGE=VS::ENV_FX_PARAM_DOF_BLUR_RANGE,
- FX_PARAM_HDR_EXPOSURE=VS::ENV_FX_PARAM_HDR_EXPOSURE,
- FX_PARAM_HDR_TONEMAPPER=VS::ENV_FX_PARAM_HDR_TONEMAPPER,
- FX_PARAM_HDR_WHITE=VS::ENV_FX_PARAM_HDR_WHITE,
- FX_PARAM_HDR_GLOW_TRESHOLD=VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
- FX_PARAM_HDR_GLOW_SCALE=VS::ENV_FX_PARAM_HDR_GLOW_SCALE,
- FX_PARAM_HDR_MIN_LUMINANCE=VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE,
- FX_PARAM_HDR_MAX_LUMINANCE=VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE,
- FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED=VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,
- FX_PARAM_FOG_BEGIN=VS::ENV_FX_PARAM_FOG_BEGIN,
- FX_PARAM_FOG_BEGIN_COLOR=VS::ENV_FX_PARAM_FOG_BEGIN_COLOR,
- FX_PARAM_FOG_END_COLOR=VS::ENV_FX_PARAM_FOG_END_COLOR,
- FX_PARAM_FOG_ATTENUATION=VS::ENV_FX_PARAM_FOG_ATTENUATION,
- FX_PARAM_FOG_BG=VS::ENV_FX_PARAM_FOG_BG,
- FX_PARAM_BCS_BRIGHTNESS=VS::ENV_FX_PARAM_BCS_BRIGHTNESS,
- FX_PARAM_BCS_CONTRAST=VS::ENV_FX_PARAM_BCS_CONTRAST,
- FX_PARAM_BCS_SATURATION=VS::ENV_FX_PARAM_BCS_SATURATION,
- FX_PARAM_MAX=VS::ENV_FX_PARAM_MAX
+ FX_PARAM_AMBIENT_LIGHT_COLOR = VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR,
+ FX_PARAM_AMBIENT_LIGHT_ENERGY = VS::ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY,
+ FX_PARAM_GLOW_BLUR_PASSES = VS::ENV_FX_PARAM_GLOW_BLUR_PASSES,
+ FX_PARAM_GLOW_BLUR_SCALE = VS::ENV_FX_PARAM_GLOW_BLUR_SCALE,
+ FX_PARAM_GLOW_BLUR_STRENGTH = VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH,
+ FX_PARAM_GLOW_BLUR_BLEND_MODE = VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE,
+ FX_PARAM_GLOW_BLOOM = VS::ENV_FX_PARAM_GLOW_BLOOM,
+ FX_PARAM_GLOW_BLOOM_TRESHOLD = VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD,
+ FX_PARAM_DOF_BLUR_PASSES = VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
+ FX_PARAM_DOF_BLUR_BEGIN = VS::ENV_FX_PARAM_DOF_BLUR_BEGIN,
+ FX_PARAM_DOF_BLUR_RANGE = VS::ENV_FX_PARAM_DOF_BLUR_RANGE,
+ FX_PARAM_HDR_EXPOSURE = VS::ENV_FX_PARAM_HDR_EXPOSURE,
+ FX_PARAM_HDR_TONEMAPPER = VS::ENV_FX_PARAM_HDR_TONEMAPPER,
+ FX_PARAM_HDR_WHITE = VS::ENV_FX_PARAM_HDR_WHITE,
+ FX_PARAM_HDR_GLOW_TRESHOLD = VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
+ FX_PARAM_HDR_GLOW_SCALE = VS::ENV_FX_PARAM_HDR_GLOW_SCALE,
+ FX_PARAM_HDR_MIN_LUMINANCE = VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE,
+ FX_PARAM_HDR_MAX_LUMINANCE = VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE,
+ FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED = VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,
+ FX_PARAM_FOG_BEGIN = VS::ENV_FX_PARAM_FOG_BEGIN,
+ FX_PARAM_FOG_BEGIN_COLOR = VS::ENV_FX_PARAM_FOG_BEGIN_COLOR,
+ FX_PARAM_FOG_END_COLOR = VS::ENV_FX_PARAM_FOG_END_COLOR,
+ FX_PARAM_FOG_ATTENUATION = VS::ENV_FX_PARAM_FOG_ATTENUATION,
+ FX_PARAM_FOG_BG = VS::ENV_FX_PARAM_FOG_BG,
+ FX_PARAM_BCS_BRIGHTNESS = VS::ENV_FX_PARAM_BCS_BRIGHTNESS,
+ FX_PARAM_BCS_CONTRAST = VS::ENV_FX_PARAM_BCS_CONTRAST,
+ FX_PARAM_BCS_SATURATION = VS::ENV_FX_PARAM_BCS_SATURATION,
+ FX_PARAM_MAX = VS::ENV_FX_PARAM_MAX
};
-private:
+private:
BG bg_mode;
Variant bg_param[BG_PARAM_MAX];
bool fx_enabled[FX_MAX];
@@ -124,19 +124,19 @@ private:
RID environment;
protected:
-
static void _bind_methods();
+
public:
void set_background(BG p_bg);
BG get_background() const;
- void set_background_param(BGParam p_param, const Variant& p_value);
+ void set_background_param(BGParam p_param, const Variant &p_value);
Variant get_background_param(BGParam p_param) const;
- void set_enable_fx(Fx p_effect,bool p_enabled);
+ void set_enable_fx(Fx p_effect, bool p_enabled);
bool is_fx_enabled(Fx p_effect) const;
- void fx_set_param(FxParam p_param,const Variant& p_value);
+ void fx_set_param(FxParam p_param, const Variant &p_value);
Variant fx_get_param(FxParam p_param) const;
virtual RID get_rid() const;
@@ -145,9 +145,9 @@ public:
~Environment();
};
-VARIANT_ENUM_CAST( Environment::BG );
-VARIANT_ENUM_CAST( Environment::BGParam );
-VARIANT_ENUM_CAST( Environment::Fx );
-VARIANT_ENUM_CAST( Environment::FxParam );
+VARIANT_ENUM_CAST(Environment::BG);
+VARIANT_ENUM_CAST(Environment::BGParam);
+VARIANT_ENUM_CAST(Environment::Fx);
+VARIANT_ENUM_CAST(Environment::FxParam);
#endif // ENVIRONMENT_H
diff --git a/scene/resources/event_stream.cpp b/scene/resources/event_stream.cpp
index 521f30532..9f255c702 100644
--- a/scene/resources/event_stream.cpp
+++ b/scene/resources/event_stream.cpp
@@ -28,7 +28,6 @@
/*************************************************************************/
#include "event_stream.h"
-
Error EventStreamPlayback::play() {
if (stream.is_valid())
stop();
@@ -37,49 +36,37 @@ Error EventStreamPlayback::play() {
if (err)
return err;
-
- playing=true;
- AudioServer::get_singleton()->stream_set_active(stream,true);
+ playing = true;
+ AudioServer::get_singleton()->stream_set_active(stream, true);
return OK;
}
-void EventStreamPlayback::stop(){
+void EventStreamPlayback::stop() {
if (!playing)
return;
- AudioServer::get_singleton()->stream_set_active(stream,false);
+ AudioServer::get_singleton()->stream_set_active(stream, false);
_stop();
- playing=false;
-
-
+ playing = false;
}
-bool EventStreamPlayback::is_playing() const{
+bool EventStreamPlayback::is_playing() const {
return playing;
}
-
EventStreamPlayback::EventStreamPlayback() {
- playing=false;
- estream.playback=this;
- stream=AudioServer::get_singleton()->event_stream_create(&estream);
-
+ playing = false;
+ estream.playback = this;
+ stream = AudioServer::get_singleton()->event_stream_create(&estream);
}
EventStreamPlayback::~EventStreamPlayback() {
AudioServer::get_singleton()->free(stream);
-
}
-
-
-EventStream::EventStream()
-{
-
-
+EventStream::EventStream() {
}
-
diff --git a/scene/resources/event_stream.h b/scene/resources/event_stream.h
index 82a59ebab..e703dd45d 100644
--- a/scene/resources/event_stream.h
+++ b/scene/resources/event_stream.h
@@ -34,83 +34,75 @@
class EventStreamPlayback : public Reference {
- OBJ_TYPE(EventStreamPlayback,Reference);
+ OBJ_TYPE(EventStreamPlayback, Reference);
class InternalEventStream : public AudioServer::EventStream {
public:
- AudioMixer *_get_mixer(){ return get_mixer(); }
+ AudioMixer *_get_mixer() { return get_mixer(); }
EventStreamPlayback *playback;
virtual void update(uint64_t p_usec) {
- playback->_update(get_mixer(),p_usec);
+ playback->_update(get_mixer(), p_usec);
}
-
virtual ~InternalEventStream() {}
};
-
InternalEventStream estream;
RID stream;
bool playing;
-
protected:
+ virtual AudioMixer *_get_mixer() { return estream._get_mixer(); }
+ virtual Error _play() = 0;
+ virtual bool _update(AudioMixer *p_mixer, uint64_t p_usec) = 0;
+ virtual void _stop() = 0;
- virtual AudioMixer* _get_mixer() { return estream._get_mixer(); }
- virtual Error _play()=0;
- virtual bool _update(AudioMixer* p_mixer, uint64_t p_usec)=0;
- virtual void _stop()=0;
public:
-
virtual Error play();
virtual void stop();
virtual bool is_playing() const;
- virtual void set_paused(bool p_paused)=0;
- virtual bool is_paused() const=0;
+ virtual void set_paused(bool p_paused) = 0;
+ virtual bool is_paused() const = 0;
- virtual void set_loop(bool p_loop)=0;
- virtual bool is_loop_enabled() const=0;
+ virtual void set_loop(bool p_loop) = 0;
+ virtual bool is_loop_enabled() const = 0;
- virtual int get_loop_count() const=0;
+ virtual int get_loop_count() const = 0;
- virtual float get_pos() const=0;
- virtual void seek_pos(float p_time)=0;
+ virtual float get_pos() const = 0;
+ virtual void seek_pos(float p_time) = 0;
- virtual void set_volume(float p_vol)=0;
- virtual float get_volume() const=0;
+ virtual void set_volume(float p_vol) = 0;
+ virtual float get_volume() const = 0;
- virtual void set_pitch_scale(float p_pitch_scale)=0;
- virtual float get_pitch_scale() const=0;
+ virtual void set_pitch_scale(float p_pitch_scale) = 0;
+ virtual float get_pitch_scale() const = 0;
- virtual void set_tempo_scale(float p_tempo_scale)=0;
- virtual float get_tempo_scale() const=0;
+ virtual void set_tempo_scale(float p_tempo_scale) = 0;
+ virtual float get_tempo_scale() const = 0;
- virtual void set_channel_volume(int p_channel,float p_volume)=0;
- virtual float get_channel_volume(int p_channel) const=0;
+ virtual void set_channel_volume(int p_channel, float p_volume) = 0;
+ virtual float get_channel_volume(int p_channel) const = 0;
- virtual float get_last_note_time(int p_channel) const=0;
+ virtual float get_last_note_time(int p_channel) const = 0;
EventStreamPlayback();
~EventStreamPlayback();
-
};
class EventStream : public Resource {
- OBJ_TYPE(EventStream,Resource);
- OBJ_SAVE_TYPE( EventStream ); //children are all saved as EventStream, so they can be exchanged
+ OBJ_TYPE(EventStream, Resource);
+ OBJ_SAVE_TYPE(EventStream); //children are all saved as EventStream, so they can be exchanged
public:
+ virtual Ref<EventStreamPlayback> instance_playback() = 0;
- virtual Ref<EventStreamPlayback> instance_playback()=0;
-
- virtual String get_stream_name() const=0;
- virtual float get_length() const=0;
- virtual int get_channel_count() const=0;
-
-
+ virtual String get_stream_name() const = 0;
+ virtual float get_length() const = 0;
+ virtual int get_channel_count() const = 0;
EventStream();
};
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 743a0b1fc..38928efc3 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -28,46 +28,44 @@
/*************************************************************************/
#include "font.h"
-#include "core/os/file_access.h"
#include "core/io/resource_loader.h"
+#include "core/os/file_access.h"
+void Font::draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, float p_width, const String &p_text, const Color &p_modulate) const {
-
-void Font::draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate) const {
-
- float length=get_string_size(p_text).width;
- if (length>=p_width) {
- draw(p_canvas_item,p_pos,p_text,p_modulate,p_width);
+ float length = get_string_size(p_text).width;
+ if (length >= p_width) {
+ draw(p_canvas_item, p_pos, p_text, p_modulate, p_width);
return;
}
float ofs;
- switch(p_align) {
+ switch (p_align) {
case HALIGN_LEFT: {
- ofs=0;
+ ofs = 0;
} break;
case HALIGN_CENTER: {
- ofs = Math::floor( (p_width-length) / 2.0 );
+ ofs = Math::floor((p_width - length) / 2.0);
} break;
case HALIGN_RIGHT: {
- ofs=p_width-length;
+ ofs = p_width - length;
} break;
}
- draw(p_canvas_item,p_pos+Point2(ofs,0),p_text,p_modulate,p_width);
+ draw(p_canvas_item, p_pos + Point2(ofs, 0), p_text, p_modulate, p_width);
}
-void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, const Color& p_modulate,int p_clip_w) const {
+void Font::draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) const {
Vector2 ofs;
- for (int i=0;i<p_text.length();i++) {
+ for (int i = 0; i < p_text.length(); i++) {
int width = get_char_size(p_text[i]).width;
- if (p_clip_w>=0 && (ofs.x+width)>p_clip_w)
+ if (p_clip_w >= 0 && (ofs.x + width) > p_clip_w)
break; //clip
- ofs.x+=draw_char(p_canvas_item,p_pos+ofs,p_text[i],p_text[i+1],p_modulate);
+ ofs.x += draw_char(p_canvas_item, p_pos + ofs, p_text[i], p_text[i + 1], p_modulate);
}
}
@@ -78,53 +76,47 @@ void Font::update_changes() {
void Font::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_ascent"),&Font::get_ascent);
- ObjectTypeDB::bind_method(_MD("get_descent"),&Font::get_descent);
- ObjectTypeDB::bind_method(_MD("get_height"),&Font::get_height);
- ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
- ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
- ObjectTypeDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
- ObjectTypeDB::bind_method(_MD("update_changes"),&Font::update_changes);
-
+ ObjectTypeDB::bind_method(_MD("draw", "canvas_item", "pos", "string", "modulate", "clip_w"), &Font::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("get_ascent"), &Font::get_ascent);
+ ObjectTypeDB::bind_method(_MD("get_descent"), &Font::get_descent);
+ ObjectTypeDB::bind_method(_MD("get_height"), &Font::get_height);
+ ObjectTypeDB::bind_method(_MD("is_distance_field_hint"), &Font::is_distance_field_hint);
+ ObjectTypeDB::bind_method(_MD("get_string_size", "string"), &Font::get_string_size);
+ ObjectTypeDB::bind_method(_MD("draw_char", "canvas_item", "pos", "char", "next", "modulate"), &Font::draw_char, DEFVAL(-1), DEFVAL(Color(1, 1, 1)));
+ ObjectTypeDB::bind_method(_MD("update_changes"), &Font::update_changes);
}
-
Font::Font() {
-
-
}
/////////////////////////////////////////////////////////////////
-void BitmapFont::_set_chars(const DVector<int>& p_chars) {
+void BitmapFont::_set_chars(const DVector<int> &p_chars) {
int len = p_chars.size();
//char 1 charsize 1 texture, 4 rect, 2 align, advance 1
- ERR_FAIL_COND(len%9);
+ ERR_FAIL_COND(len % 9);
if (!len)
return; //none to do
- int chars = len/9;
+ int chars = len / 9;
+ DVector<int>::Read r = p_chars.read();
+ for (int i = 0; i < chars; i++) {
- DVector<int>::Read r=p_chars.read();
- for(int i=0;i<chars;i++) {
-
- const int* data = &r[i*9];
- add_char(data[0],data[1],Rect2(data[2],data[3],data[4],data[5]), Size2(data[6],data[7]),data[8]);
+ const int *data = &r[i * 9];
+ add_char(data[0], data[1], Rect2(data[2], data[3], data[4], data[5]), Size2(data[6], data[7]), data[8]);
}
-
}
DVector<int> BitmapFont::_get_chars() const {
DVector<int> chars;
- const CharType* key=NULL;
+ const CharType *key = NULL;
- while((key=char_map.next(key))) {
+ while ((key = char_map.next(key))) {
- const Character *c=char_map.getptr(*key);
+ const Character *c = char_map.getptr(*key);
chars.push_back(*key);
chars.push_back(c->texture_idx);
chars.push_back(c->rect.pos.x);
@@ -140,18 +132,18 @@ DVector<int> BitmapFont::_get_chars() const {
return chars;
}
-void BitmapFont::_set_kernings(const DVector<int>& p_kernings) {
+void BitmapFont::_set_kernings(const DVector<int> &p_kernings) {
- int len=p_kernings.size();
- ERR_FAIL_COND(len%3);
+ int len = p_kernings.size();
+ ERR_FAIL_COND(len % 3);
if (!len)
return;
- DVector<int>::Read r=p_kernings.read();
+ DVector<int>::Read r = p_kernings.read();
- for(int i=0;i<len/3;i++) {
+ for (int i = 0; i < len / 3; i++) {
- const int* data = &r[i*3];
- add_kerning_pair(data[0],data[1],data[2]);
+ const int *data = &r[i * 3];
+ add_kerning_pair(data[0], data[1], data[2]);
}
}
@@ -159,7 +151,7 @@ DVector<int> BitmapFont::_get_kernings() const {
DVector<int> kernings;
- for(Map<KerningPairKey,int>::Element *E=kerning_map.front();E;E=E->next()) {
+ for (Map<KerningPairKey, int>::Element *E = kerning_map.front(); E; E = E->next()) {
kernings.push_back(E->key().A);
kernings.push_back(E->key().B);
@@ -169,105 +161,98 @@ DVector<int> BitmapFont::_get_kernings() const {
return kernings;
}
+void BitmapFont::_set_textures(const Vector<Variant> &p_textures) {
-void BitmapFont::_set_textures(const Vector<Variant> & p_textures) {
-
- for(int i=0;i<p_textures.size();i++) {
+ for (int i = 0; i < p_textures.size(); i++) {
Ref<Texture> tex = p_textures[i];
ERR_CONTINUE(!tex.is_valid());
add_texture(tex);
}
-
}
Vector<Variant> BitmapFont::_get_textures() const {
Vector<Variant> rtextures;
- for(int i=0;i<textures.size();i++)
+ for (int i = 0; i < textures.size(); i++)
rtextures.push_back(textures[i].get_ref_ptr());
return rtextures;
}
-Error BitmapFont::create_from_fnt(const String& p_string) {
+Error BitmapFont::create_from_fnt(const String &p_string) {
//fnt format used by angelcode bmfont
//http://www.angelcode.com/products/bmfont/
- FileAccess *f = FileAccess::open(p_string,FileAccess::READ);
+ FileAccess *f = FileAccess::open(p_string, FileAccess::READ);
if (!f) {
- ERR_EXPLAIN("Can't open font: "+p_string);
+ ERR_EXPLAIN("Can't open font: " + p_string);
ERR_FAIL_V(ERR_FILE_NOT_FOUND);
}
clear();
- while(true) {
+ while (true) {
- String line=f->get_line();
+ String line = f->get_line();
- int delimiter=line.find(" ");
- String type=line.substr(0,delimiter);
- int pos = delimiter+1;
- Map<String,String> keys;
+ int delimiter = line.find(" ");
+ String type = line.substr(0, delimiter);
+ int pos = delimiter + 1;
+ Map<String, String> keys;
- while (pos < line.size() && line[pos]==' ')
+ while (pos < line.size() && line[pos] == ' ')
pos++;
+ while (pos < line.size()) {
- while(pos<line.size()) {
-
- int eq = line.find("=",pos);
- if (eq==-1)
+ int eq = line.find("=", pos);
+ if (eq == -1)
break;
- String key=line.substr(pos,eq-pos);
- int end=-1;
+ String key = line.substr(pos, eq - pos);
+ int end = -1;
String value;
- if (line[eq+1]=='"') {
- end=line.find("\"",eq+2);
- if (end==-1)
+ if (line[eq + 1] == '"') {
+ end = line.find("\"", eq + 2);
+ if (end == -1)
break;
- value=line.substr(eq+2,end-1-eq-1);
- pos=end+1;
+ value = line.substr(eq + 2, end - 1 - eq - 1);
+ pos = end + 1;
} else {
- end=line.find(" ",eq+1);
- if (end==-1)
- end=line.size();
+ end = line.find(" ", eq + 1);
+ if (end == -1)
+ end = line.size();
- value=line.substr(eq+1,end-eq);
-
- pos=end;
+ value = line.substr(eq + 1, end - eq);
+ pos = end;
}
- while (pos<line.size() && line[pos]==' ')
+ while (pos < line.size() && line[pos] == ' ')
pos++;
-
- keys[key]=value;
-
+ keys[key] = value;
}
-
- if (type=="info") {
+ if (type == "info") {
if (keys.has("face"))
set_name(keys["face"]);
//if (keys.has("size"))
// font->set_height(keys["size"].to_int());
- } else if (type=="common") {
+ } else if (type == "common") {
if (keys.has("lineHeight"))
set_height(keys["lineHeight"].to_int());
if (keys.has("base"))
set_ascent(keys["base"].to_int());
- } else if (type=="page") {
+ } else if (type == "page") {
if (keys.has("file")) {
String file = keys["file"];
- file=p_string.get_base_dir()+"/"+file;
+ file = p_string.get_base_dir() + "/" + file;
Ref<Texture> tex = ResourceLoader::load(file);
if (tex.is_null()) {
ERR_PRINT("Can't load font texture!");
@@ -275,80 +260,75 @@ Error BitmapFont::create_from_fnt(const String& p_string) {
add_texture(tex);
}
}
- } else if (type=="char") {
+ } else if (type == "char") {
- CharType idx=0;
+ CharType idx = 0;
if (keys.has("id"))
- idx=keys["id"].to_int();
+ idx = keys["id"].to_int();
Rect2 rect;
if (keys.has("x"))
- rect.pos.x=keys["x"].to_int();
+ rect.pos.x = keys["x"].to_int();
if (keys.has("y"))
- rect.pos.y=keys["y"].to_int();
+ rect.pos.y = keys["y"].to_int();
if (keys.has("width"))
- rect.size.width=keys["width"].to_int();
+ rect.size.width = keys["width"].to_int();
if (keys.has("height"))
- rect.size.height=keys["height"].to_int();
+ rect.size.height = keys["height"].to_int();
Point2 ofs;
if (keys.has("xoffset"))
- ofs.x=keys["xoffset"].to_int();
+ ofs.x = keys["xoffset"].to_int();
if (keys.has("yoffset"))
- ofs.y=keys["yoffset"].to_int();
+ ofs.y = keys["yoffset"].to_int();
- int texture=0;
+ int texture = 0;
if (keys.has("page"))
- texture=keys["page"].to_int();
- int advance=-1;
+ texture = keys["page"].to_int();
+ int advance = -1;
if (keys.has("xadvance"))
- advance=keys["xadvance"].to_int();
+ advance = keys["xadvance"].to_int();
- add_char(idx,texture,rect,ofs,advance);
+ add_char(idx, texture, rect, ofs, advance);
- } else if (type=="kerning") {
+ } else if (type == "kerning") {
- CharType first=0,second=0;
- int k=0;
+ CharType first = 0, second = 0;
+ int k = 0;
if (keys.has("first"))
- first=keys["first"].to_int();
+ first = keys["first"].to_int();
if (keys.has("second"))
- second=keys["second"].to_int();
+ second = keys["second"].to_int();
if (keys.has("amount"))
- k=keys["amount"].to_int();
-
- add_kerning_pair(first,second,-k);
+ k = keys["amount"].to_int();
+ add_kerning_pair(first, second, -k);
}
if (f->eof_reached())
break;
}
-
-
memdelete(f);
return OK;
}
-
-
void BitmapFont::set_height(float p_height) {
- height=p_height;
+ height = p_height;
}
-float BitmapFont::get_height() const{
+float BitmapFont::get_height() const {
return height;
}
-void BitmapFont::set_ascent(float p_ascent){
+void BitmapFont::set_ascent(float p_ascent) {
- ascent=p_ascent;
+ ascent = p_ascent;
}
float BitmapFont::get_ascent() const {
@@ -356,13 +336,13 @@ float BitmapFont::get_ascent() const {
}
float BitmapFont::get_descent() const {
- return height-ascent;
+ return height - ascent;
}
-void BitmapFont::add_texture(const Ref<Texture>& p_texture) {
+void BitmapFont::add_texture(const Ref<Texture> &p_texture) {
- ERR_FAIL_COND( p_texture.is_null());
- textures.push_back( p_texture );
+ ERR_FAIL_COND(p_texture.is_null());
+ textures.push_back(p_texture);
}
int BitmapFont::get_texture_count() const {
@@ -385,9 +365,9 @@ Vector<CharType> BitmapFont::get_char_keys() const {
Vector<CharType> chars;
chars.resize(char_map.size());
- const CharType* ct = NULL;
+ const CharType *ct = NULL;
int count = 0;
- while ( (ct = char_map.next(ct)) ) {
+ while ((ct = char_map.next(ct))) {
chars[count++] = *ct;
};
@@ -404,60 +384,56 @@ BitmapFont::Character BitmapFont::get_character(CharType p_char) const {
return char_map[p_char];
};
-void BitmapFont::add_char(CharType p_char, int p_texture_idx, const Rect2& p_rect, const Size2& p_align, float p_advance) {
+void BitmapFont::add_char(CharType p_char, int p_texture_idx, const Rect2 &p_rect, const Size2 &p_align, float p_advance) {
- if (p_advance<0)
- p_advance=p_rect.size.width;
+ if (p_advance < 0)
+ p_advance = p_rect.size.width;
Character c;
- c.rect=p_rect;
- c.texture_idx=p_texture_idx;
- c.v_align=p_align.y;
- c.advance=p_advance;
- c.h_align=p_align.x;
+ c.rect = p_rect;
+ c.texture_idx = p_texture_idx;
+ c.v_align = p_align.y;
+ c.advance = p_advance;
+ c.h_align = p_align.x;
- char_map[p_char]=c;
+ char_map[p_char] = c;
}
-void BitmapFont::add_kerning_pair(CharType p_A,CharType p_B,int p_kerning) {
-
+void BitmapFont::add_kerning_pair(CharType p_A, CharType p_B, int p_kerning) {
KerningPairKey kpk;
- kpk.A=p_A;
- kpk.B=p_B;
+ kpk.A = p_A;
+ kpk.B = p_B;
- if (p_kerning==0 && kerning_map.has(kpk)) {
+ if (p_kerning == 0 && kerning_map.has(kpk)) {
kerning_map.erase(kpk);
} else {
- kerning_map[kpk]=p_kerning;
+ kerning_map[kpk] = p_kerning;
}
}
Vector<BitmapFont::KerningPairKey> BitmapFont::get_kerning_pair_keys() const {
-
Vector<BitmapFont::KerningPairKey> ret;
ret.resize(kerning_map.size());
- int i=0;
-
- for (Map<KerningPairKey,int>::Element *E=kerning_map.front();E;E=E->next()) {
- ret[i++]=E->key();
+ int i = 0;
+ for (Map<KerningPairKey, int>::Element *E = kerning_map.front(); E; E = E->next()) {
+ ret[i++] = E->key();
}
return ret;
-
}
-int BitmapFont::get_kerning_pair(CharType p_A,CharType p_B) const {
+int BitmapFont::get_kerning_pair(CharType p_A, CharType p_B) const {
KerningPairKey kpk;
- kpk.A=p_A;
- kpk.B=p_B;
+ kpk.A = p_A;
+ kpk.B = p_B;
- const Map<KerningPairKey,int>::Element *E=kerning_map.find(kpk);
+ const Map<KerningPairKey, int>::Element *E = kerning_map.find(kpk);
if (E)
return E->get();
@@ -466,96 +442,94 @@ int BitmapFont::get_kerning_pair(CharType p_A,CharType p_B) const {
void BitmapFont::set_distance_field_hint(bool p_distance_field) {
- distance_field_hint=p_distance_field;
+ distance_field_hint = p_distance_field;
emit_changed();
}
-bool BitmapFont::is_distance_field_hint() const{
+bool BitmapFont::is_distance_field_hint() const {
return distance_field_hint;
}
-
void BitmapFont::clear() {
- height=1;
- ascent=0;
+ height = 1;
+ ascent = 0;
char_map.clear();
textures.clear();
kerning_map.clear();
- distance_field_hint=false;
+ distance_field_hint = false;
}
-Size2 Font::get_string_size(const String& p_string) const {
+Size2 Font::get_string_size(const String &p_string) const {
- float w=0;
+ float w = 0;
int l = p_string.length();
- if (l==0)
- return Size2(0,get_height());
+ if (l == 0)
+ return Size2(0, get_height());
const CharType *sptr = &p_string[0];
- for (int i=0;i<l;i++) {
+ for (int i = 0; i < l; i++) {
- w+=get_char_size(sptr[i],sptr[i+1]).width;
+ w += get_char_size(sptr[i], sptr[i + 1]).width;
}
- return Size2(w,get_height());
+ return Size2(w, get_height());
}
void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) {
- fallback=p_fallback;
+ fallback = p_fallback;
}
-Ref<BitmapFont> BitmapFont::get_fallback() const{
+Ref<BitmapFont> BitmapFont::get_fallback() const {
return fallback;
}
-float BitmapFont::draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char, CharType p_next, const Color& p_modulate) const {
+float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate) const {
- const Character * c = char_map.getptr(p_char);
+ const Character *c = char_map.getptr(p_char);
if (!c) {
if (fallback.is_valid())
- return fallback->draw_char(p_canvas_item,p_pos,p_char,p_next,p_modulate);
+ return fallback->draw_char(p_canvas_item, p_pos, p_char, p_next, p_modulate);
return 0;
}
- Point2 cpos=p_pos;
- cpos.x+=c->h_align;
- cpos.y-=ascent;
- cpos.y+=c->v_align;
- ERR_FAIL_COND_V( c->texture_idx<-1 || c->texture_idx>=textures.size(),0);
- if (c->texture_idx!=-1)
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region( p_canvas_item, Rect2( cpos, c->rect.size ), textures[c->texture_idx]->get_rid(),c->rect, p_modulate );
+ Point2 cpos = p_pos;
+ cpos.x += c->h_align;
+ cpos.y -= ascent;
+ cpos.y += c->v_align;
+ ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), 0);
+ if (c->texture_idx != -1)
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate);
- return get_char_size(p_char,p_next).width;
+ return get_char_size(p_char, p_next).width;
}
+Size2 BitmapFont::get_char_size(CharType p_char, CharType p_next) const {
-Size2 BitmapFont::get_char_size(CharType p_char,CharType p_next) const {
-
- const Character * c = char_map.getptr(p_char);
+ const Character *c = char_map.getptr(p_char);
if (!c) {
if (fallback.is_valid())
- return fallback->get_char_size(p_char,p_next);
+ return fallback->get_char_size(p_char, p_next);
return Size2();
}
- Size2 ret(c->advance,c->rect.size.y);
+ Size2 ret(c->advance, c->rect.size.y);
if (p_next) {
KerningPairKey kpk;
- kpk.A=p_char;
- kpk.B=p_next;
+ kpk.A = p_char;
+ kpk.B = p_next;
- const Map<KerningPairKey,int>::Element *E=kerning_map.find(kpk);
+ const Map<KerningPairKey, int>::Element *E = kerning_map.find(kpk);
if (E) {
- ret.width-=E->get();
+ ret.width -= E->get();
}
}
@@ -564,63 +538,54 @@ Size2 BitmapFont::get_char_size(CharType p_char,CharType p_next) const {
void BitmapFont::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create_from_fnt","path"),&BitmapFont::create_from_fnt);
- ObjectTypeDB::bind_method(_MD("set_height","px"),&BitmapFont::set_height);
+ ObjectTypeDB::bind_method(_MD("create_from_fnt", "path"), &BitmapFont::create_from_fnt);
+ ObjectTypeDB::bind_method(_MD("set_height", "px"), &BitmapFont::set_height);
- ObjectTypeDB::bind_method(_MD("set_ascent","px"),&BitmapFont::set_ascent);
+ ObjectTypeDB::bind_method(_MD("set_ascent", "px"), &BitmapFont::set_ascent);
- ObjectTypeDB::bind_method(_MD("add_kerning_pair","char_a","char_b","kerning"),&BitmapFont::add_kerning_pair);
- ObjectTypeDB::bind_method(_MD("get_kerning_pair","char_a","char_b"),&BitmapFont::get_kerning_pair);
+ ObjectTypeDB::bind_method(_MD("add_kerning_pair", "char_a", "char_b", "kerning"), &BitmapFont::add_kerning_pair);
+ ObjectTypeDB::bind_method(_MD("get_kerning_pair", "char_a", "char_b"), &BitmapFont::get_kerning_pair);
- ObjectTypeDB::bind_method(_MD("add_texture","texture:Texture"),&BitmapFont::add_texture);
- ObjectTypeDB::bind_method(_MD("add_char","character","texture","rect","align","advance"),&BitmapFont::add_char,DEFVAL(Point2()),DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("add_texture", "texture:Texture"), &BitmapFont::add_texture);
+ ObjectTypeDB::bind_method(_MD("add_char", "character", "texture", "rect", "align", "advance"), &BitmapFont::add_char, DEFVAL(Point2()), DEFVAL(-1));
+ ObjectTypeDB::bind_method(_MD("get_texture_count"), &BitmapFont::get_texture_count);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture", "idx"), &BitmapFont::get_texture);
- ObjectTypeDB::bind_method(_MD("get_texture_count"),&BitmapFont::get_texture_count);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture","idx"),&BitmapFont::get_texture);
+ ObjectTypeDB::bind_method(_MD("get_char_size", "char", "next"), &BitmapFont::get_char_size, DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("get_char_size","char","next"),&BitmapFont::get_char_size,DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("set_distance_field_hint", "enable"), &BitmapFont::set_distance_field_hint);
- ObjectTypeDB::bind_method(_MD("set_distance_field_hint","enable"),&BitmapFont::set_distance_field_hint);
+ ObjectTypeDB::bind_method(_MD("clear"), &BitmapFont::clear);
- ObjectTypeDB::bind_method(_MD("clear"),&BitmapFont::clear);
+ ObjectTypeDB::bind_method(_MD("_set_chars"), &BitmapFont::_set_chars);
+ ObjectTypeDB::bind_method(_MD("_get_chars"), &BitmapFont::_get_chars);
+ ObjectTypeDB::bind_method(_MD("_set_kernings"), &BitmapFont::_set_kernings);
+ ObjectTypeDB::bind_method(_MD("_get_kernings"), &BitmapFont::_get_kernings);
- ObjectTypeDB::bind_method(_MD("_set_chars"),&BitmapFont::_set_chars);
- ObjectTypeDB::bind_method(_MD("_get_chars"),&BitmapFont::_get_chars);
+ ObjectTypeDB::bind_method(_MD("_set_textures"), &BitmapFont::_set_textures);
+ ObjectTypeDB::bind_method(_MD("_get_textures"), &BitmapFont::_get_textures);
- ObjectTypeDB::bind_method(_MD("_set_kernings"),&BitmapFont::_set_kernings);
- ObjectTypeDB::bind_method(_MD("_get_kernings"),&BitmapFont::_get_kernings);
+ ObjectTypeDB::bind_method(_MD("set_fallback", "fallback"), &BitmapFont::set_fallback);
+ ObjectTypeDB::bind_method(_MD("get_fallback"), &BitmapFont::get_fallback);
- ObjectTypeDB::bind_method(_MD("_set_textures"),&BitmapFont::_set_textures);
- ObjectTypeDB::bind_method(_MD("_get_textures"),&BitmapFont::_get_textures);
-
- ObjectTypeDB::bind_method(_MD("set_fallback","fallback"),&BitmapFont::set_fallback);
- ObjectTypeDB::bind_method(_MD("get_fallback"),&BitmapFont::get_fallback);
-
- ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "textures", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_textures"), _SCS("_get_textures") );
- ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "chars", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_chars"), _SCS("_get_chars") );
- ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "kernings", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_kernings"), _SCS("_get_kernings") );
-
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint") );
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE,"BitmapFont" ), _SCS("set_fallback"), _SCS("get_fallback") );
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_textures"), _SCS("_get_textures"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT_ARRAY, "chars", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_chars"), _SCS("_get_chars"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT_ARRAY, "kernings", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_kernings"), _SCS("_get_kernings"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "-1024,1024,1"), _SCS("set_height"), _SCS("get_height"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "ascent", PROPERTY_HINT_RANGE, "-1024,1024,1"), _SCS("set_ascent"), _SCS("get_ascent"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distance_field"), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE, "BitmapFont"), _SCS("set_fallback"), _SCS("get_fallback"));
}
BitmapFont::BitmapFont() {
clear();
-
-
-
}
-
BitmapFont::~BitmapFont() {
clear();
}
-
-
diff --git a/scene/resources/font.h b/scene/resources/font.h
index f31179655..bd8527e9e 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -29,50 +29,45 @@
#ifndef FONT_H
#define FONT_H
+#include "map.h"
#include "resource.h"
#include "scene/resources/texture.h"
-#include "map.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
class Font : public Resource {
- OBJ_TYPE( Font, Resource );
+ OBJ_TYPE(Font, Resource);
protected:
-
static void _bind_methods();
public:
+ virtual float get_height() const = 0;
- virtual float get_height() const=0;
+ virtual float get_ascent() const = 0;
+ virtual float get_descent() const = 0;
- virtual float get_ascent() const=0;
- virtual float get_descent() const=0;
+ virtual Size2 get_char_size(CharType p_char, CharType p_next = 0) const = 0;
+ Size2 get_string_size(const String &p_string) const;
- virtual Size2 get_char_size(CharType p_char,CharType p_next=0) const=0;
- Size2 get_string_size(const String& p_string) const;
+ virtual bool is_distance_field_hint() const = 0;
- virtual bool is_distance_field_hint() const=0;
-
- void draw(RID p_canvas_item, const Point2& p_pos, const String& p_text,const Color& p_modulate=Color(1,1,1),int p_clip_w=-1) const;
- void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const;
- virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char, CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const=0;
+ void draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1) const;
+ void draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, float p_width, const String &p_text, const Color &p_modulate = Color(1, 1, 1)) const;
+ virtual float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next = 0, const Color &p_modulate = Color(1, 1, 1)) const = 0;
void update_changes();
Font();
-
};
-
class BitmapFont : public Font {
- OBJ_TYPE( BitmapFont, Font );
+ OBJ_TYPE(BitmapFont, Font);
RES_BASE_EXTENSION("fnt");
- Vector< Ref<Texture> > textures;
+ Vector<Ref<Texture> > textures;
public:
struct Character {
@@ -83,47 +78,47 @@ public:
float h_align;
float advance;
- Character() { texture_idx=0; v_align=0; }
+ Character() {
+ texture_idx = 0;
+ v_align = 0;
+ }
};
struct KerningPairKey {
union {
struct {
- uint32_t A,B;
+ uint32_t A, B;
};
uint64_t pair;
};
- _FORCE_INLINE_ bool operator<(const KerningPairKey& p_r) const { return pair<p_r.pair; }
+ _FORCE_INLINE_ bool operator<(const KerningPairKey &p_r) const { return pair < p_r.pair; }
};
private:
-
-
- HashMap< CharType, Character > char_map;
- Map<KerningPairKey,int> kerning_map;
+ HashMap<CharType, Character> char_map;
+ Map<KerningPairKey, int> kerning_map;
float height;
float ascent;
bool distance_field_hint;
- void _set_chars(const DVector<int>& p_chars);
+ void _set_chars(const DVector<int> &p_chars);
DVector<int> _get_chars() const;
- void _set_kernings(const DVector<int>& p_kernings);
+ void _set_kernings(const DVector<int> &p_kernings);
DVector<int> _get_kernings() const;
- void _set_textures(const Vector<Variant> & p_textures);
+ void _set_textures(const Vector<Variant> &p_textures);
Vector<Variant> _get_textures() const;
Ref<BitmapFont> fallback;
-protected:
+protected:
static void _bind_methods();
public:
-
- Error create_from_fnt(const String& p_file);
+ Error create_from_fnt(const String &p_file);
void set_height(float p_height);
float get_height() const;
@@ -132,8 +127,8 @@ public:
float get_ascent() const;
float get_descent() const;
- void add_texture(const Ref<Texture>& p_texture);
- void add_char(CharType p_char, int p_texture_idx, const Rect2& p_rect, const Size2& p_align, float p_advance=-1);
+ void add_texture(const Ref<Texture> &p_texture);
+ void add_char(CharType p_char, int p_texture_idx, const Rect2 &p_rect, const Size2 &p_align, float p_advance = -1);
int get_character_count() const;
Vector<CharType> get_char_keys() const;
@@ -142,11 +137,11 @@ public:
int get_texture_count() const;
Ref<Texture> get_texture(int p_idx) const;
- void add_kerning_pair(CharType p_A,CharType p_B,int p_kerning);
- int get_kerning_pair(CharType p_A,CharType p_B) const;
+ void add_kerning_pair(CharType p_A, CharType p_B, int p_kerning);
+ int get_kerning_pair(CharType p_A, CharType p_B) const;
Vector<KerningPairKey> get_kerning_pair_keys() const;
- Size2 get_char_size(CharType p_char,CharType p_next=0) const;
+ Size2 get_char_size(CharType p_char, CharType p_next = 0) const;
void set_fallback(const Ref<BitmapFont> &p_fallback);
Ref<BitmapFont> get_fallback() const;
@@ -156,14 +151,10 @@ public:
void set_distance_field_hint(bool p_distance_field);
bool is_distance_field_hint() const;
- float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char,CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const;
+ float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next = 0, const Color &p_modulate = Color(1, 1, 1)) const;
BitmapFont();
~BitmapFont();
};
-
-
-
-
#endif
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 2ecd2cc07..129df3d98 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -29,8 +29,7 @@
#include "material.h"
#include "scene/scene_string_names.h"
-
-static const char*_flag_names[Material::FLAG_MAX]={
+static const char *_flag_names[Material::FLAG_MAX] = {
"visible",
"double_sided",
"invert_faces",
@@ -40,8 +39,7 @@ static const char*_flag_names[Material::FLAG_MAX]={
"colarray_is_srgb"
};
-
-static const Material::Flag _flag_indices[Material::FLAG_MAX]={
+static const Material::Flag _flag_indices[Material::FLAG_MAX] = {
Material::FLAG_VISIBLE,
Material::FLAG_DOUBLE_SIDED,
Material::FLAG_INVERT_FACES,
@@ -51,26 +49,24 @@ static const Material::Flag _flag_indices[Material::FLAG_MAX]={
Material::FLAG_COLOR_ARRAY_SRGB,
};
-
RID Material::get_rid() const {
return material;
}
-void Material::set_flag(Flag p_flag,bool p_enabled) {
+void Material::set_flag(Flag p_flag, bool p_enabled) {
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags[p_flag]=p_enabled;
- VisualServer::get_singleton()->material_set_flag(material,(VS::MaterialFlag)p_flag,p_enabled);
+ ERR_FAIL_INDEX(p_flag, FLAG_MAX);
+ flags[p_flag] = p_enabled;
+ VisualServer::get_singleton()->material_set_flag(material, (VS::MaterialFlag)p_flag, p_enabled);
_change_notify();
}
-
void Material::set_blend_mode(BlendMode p_blend_mode) {
- ERR_FAIL_INDEX(p_blend_mode,4);
- blend_mode=p_blend_mode;
- VisualServer::get_singleton()->material_set_blend_mode(material,(VS::MaterialBlendMode)p_blend_mode);
+ ERR_FAIL_INDEX(p_blend_mode, 4);
+ blend_mode = p_blend_mode;
+ VisualServer::get_singleton()->material_set_blend_mode(material, (VS::MaterialBlendMode)p_blend_mode);
_change_notify();
}
@@ -79,11 +75,10 @@ Material::BlendMode Material::get_blend_mode() const {
return blend_mode;
}
-
void Material::set_depth_draw_mode(DepthDrawMode p_depth_draw_mode) {
- depth_draw_mode=p_depth_draw_mode;
- VisualServer::get_singleton()->material_set_depth_draw_mode(material,(VS::MaterialDepthDrawMode)p_depth_draw_mode);
+ depth_draw_mode = p_depth_draw_mode;
+ VisualServer::get_singleton()->material_set_depth_draw_mode(material, (VS::MaterialDepthDrawMode)p_depth_draw_mode);
}
Material::DepthDrawMode Material::get_depth_draw_mode() const {
@@ -93,14 +88,14 @@ Material::DepthDrawMode Material::get_depth_draw_mode() const {
bool Material::get_flag(Flag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+ ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
return flags[p_flag];
}
void Material::set_line_width(float p_width) {
- line_width=p_width;
- VisualServer::get_singleton()->material_set_line_width(material,p_width);
+ line_width = p_width;
+ VisualServer::get_singleton()->material_set_line_width(material, p_width);
_change_notify("line_width");
}
@@ -109,64 +104,60 @@ float Material::get_line_width() const {
return line_width;
}
-
void Material::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_flag","flag","enable"),&Material::set_flag);
- ObjectTypeDB::bind_method(_MD("get_flag","flag"),&Material::get_flag);
- ObjectTypeDB::bind_method(_MD("set_blend_mode","mode"),&Material::set_blend_mode);
- ObjectTypeDB::bind_method(_MD("get_blend_mode"),&Material::get_blend_mode);
- ObjectTypeDB::bind_method(_MD("set_line_width","width"),&Material::set_line_width);
- ObjectTypeDB::bind_method(_MD("get_line_width"),&Material::get_line_width);
- ObjectTypeDB::bind_method(_MD("set_depth_draw_mode","mode"),&Material::set_depth_draw_mode);
- ObjectTypeDB::bind_method(_MD("get_depth_draw_mode"),&Material::get_depth_draw_mode);
-
+ ObjectTypeDB::bind_method(_MD("set_flag", "flag", "enable"), &Material::set_flag);
+ ObjectTypeDB::bind_method(_MD("get_flag", "flag"), &Material::get_flag);
+ ObjectTypeDB::bind_method(_MD("set_blend_mode", "mode"), &Material::set_blend_mode);
+ ObjectTypeDB::bind_method(_MD("get_blend_mode"), &Material::get_blend_mode);
+ ObjectTypeDB::bind_method(_MD("set_line_width", "width"), &Material::set_line_width);
+ ObjectTypeDB::bind_method(_MD("get_line_width"), &Material::get_line_width);
+ ObjectTypeDB::bind_method(_MD("set_depth_draw_mode", "mode"), &Material::set_depth_draw_mode);
+ ObjectTypeDB::bind_method(_MD("get_depth_draw_mode"), &Material::get_depth_draw_mode);
- for(int i=0;i<FLAG_MAX;i++)
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, String()+"flags/"+_flag_names[i] ),_SCS("set_flag"),_SCS("get_flag"),_flag_indices[i]);
+ for (int i = 0; i < FLAG_MAX; i++)
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, String() + "flags/" + _flag_names[i]), _SCS("set_flag"), _SCS("get_flag"), _flag_indices[i]);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,PMAlpha" ), _SCS("set_blend_mode"),_SCS("get_blend_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/depth_draw",PROPERTY_HINT_ENUM,"Always,Opaque Only,Pre-Pass Alpha,Never" ), _SCS("set_depth_draw_mode"),_SCS("get_depth_draw_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/line_width",PROPERTY_HINT_RANGE,"0.1,32.0,0.1" ), _SCS("set_line_width"),_SCS("get_line_width"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "params/blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,PMAlpha"), _SCS("set_blend_mode"), _SCS("get_blend_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "params/depth_draw", PROPERTY_HINT_ENUM, "Always,Opaque Only,Pre-Pass Alpha,Never"), _SCS("set_depth_draw_mode"), _SCS("get_depth_draw_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "params/line_width", PROPERTY_HINT_RANGE, "0.1,32.0,0.1"), _SCS("set_line_width"), _SCS("get_line_width"));
- BIND_CONSTANT( FLAG_VISIBLE );
- BIND_CONSTANT( FLAG_DOUBLE_SIDED );
- BIND_CONSTANT( FLAG_INVERT_FACES );
- BIND_CONSTANT( FLAG_UNSHADED );
- BIND_CONSTANT( FLAG_ONTOP );
- BIND_CONSTANT( FLAG_LIGHTMAP_ON_UV2 );
- BIND_CONSTANT( FLAG_COLOR_ARRAY_SRGB );
- BIND_CONSTANT( FLAG_MAX );
+ BIND_CONSTANT(FLAG_VISIBLE);
+ BIND_CONSTANT(FLAG_DOUBLE_SIDED);
+ BIND_CONSTANT(FLAG_INVERT_FACES);
+ BIND_CONSTANT(FLAG_UNSHADED);
+ BIND_CONSTANT(FLAG_ONTOP);
+ BIND_CONSTANT(FLAG_LIGHTMAP_ON_UV2);
+ BIND_CONSTANT(FLAG_COLOR_ARRAY_SRGB);
+ BIND_CONSTANT(FLAG_MAX);
- BIND_CONSTANT( DEPTH_DRAW_ALWAYS );
- BIND_CONSTANT( DEPTH_DRAW_OPAQUE_ONLY );
- BIND_CONSTANT( DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA );
- BIND_CONSTANT( DEPTH_DRAW_NEVER );
-
- BIND_CONSTANT( BLEND_MODE_MIX );
- BIND_CONSTANT( BLEND_MODE_ADD );
- BIND_CONSTANT( BLEND_MODE_SUB );
- BIND_CONSTANT( BLEND_MODE_MUL );
- BIND_CONSTANT( BLEND_MODE_PREMULT_ALPHA );
+ BIND_CONSTANT(DEPTH_DRAW_ALWAYS);
+ BIND_CONSTANT(DEPTH_DRAW_OPAQUE_ONLY);
+ BIND_CONSTANT(DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA);
+ BIND_CONSTANT(DEPTH_DRAW_NEVER);
+ BIND_CONSTANT(BLEND_MODE_MIX);
+ BIND_CONSTANT(BLEND_MODE_ADD);
+ BIND_CONSTANT(BLEND_MODE_SUB);
+ BIND_CONSTANT(BLEND_MODE_MUL);
+ BIND_CONSTANT(BLEND_MODE_PREMULT_ALPHA);
}
-Material::Material(const RID& p_material) {
-
- material=p_material;
+Material::Material(const RID &p_material) {
- flags[FLAG_VISIBLE]=true;
- flags[FLAG_DOUBLE_SIDED]=false;
- flags[FLAG_INVERT_FACES]=false;
- flags[FLAG_UNSHADED]=false;
- flags[FLAG_ONTOP]=false;
- flags[FLAG_LIGHTMAP_ON_UV2]=true;
- flags[FLAG_COLOR_ARRAY_SRGB]=false;
+ material = p_material;
- depth_draw_mode=DEPTH_DRAW_OPAQUE_ONLY;
+ flags[FLAG_VISIBLE] = true;
+ flags[FLAG_DOUBLE_SIDED] = false;
+ flags[FLAG_INVERT_FACES] = false;
+ flags[FLAG_UNSHADED] = false;
+ flags[FLAG_ONTOP] = false;
+ flags[FLAG_LIGHTMAP_ON_UV2] = true;
+ flags[FLAG_COLOR_ARRAY_SRGB] = false;
- blend_mode=BLEND_MODE_MIX;
+ depth_draw_mode = DEPTH_DRAW_OPAQUE_ONLY;
+ blend_mode = BLEND_MODE_MIX;
}
Material::~Material() {
@@ -174,7 +165,7 @@ Material::~Material() {
VisualServer::get_singleton()->free(material);
}
-static const char*_param_names[FixedMaterial::PARAM_MAX]={
+static const char *_param_names[FixedMaterial::PARAM_MAX] = {
"diffuse",
"detail",
"specular",
@@ -185,7 +176,7 @@ static const char*_param_names[FixedMaterial::PARAM_MAX]={
"shade_param"
};
-static const char*_full_param_names[FixedMaterial::PARAM_MAX]={
+static const char *_full_param_names[FixedMaterial::PARAM_MAX] = {
"params/diffuse",
"params/detail",
"params/specular",
@@ -209,7 +200,7 @@ static const char*_texture_param_names[FixedMaterial::PARAM_MAX]={
"tex_shade_param"
};
*/
-static const FixedMaterial::Parameter _param_indices[FixedMaterial::PARAM_MAX]={
+static const FixedMaterial::Parameter _param_indices[FixedMaterial::PARAM_MAX] = {
FixedMaterial::PARAM_DIFFUSE,
FixedMaterial::PARAM_DETAIL,
FixedMaterial::PARAM_SPECULAR,
@@ -220,83 +211,78 @@ static const FixedMaterial::Parameter _param_indices[FixedMaterial::PARAM_MAX]={
FixedMaterial::PARAM_SHADE_PARAM,
};
+void FixedMaterial::set_parameter(Parameter p_parameter, const Variant &p_value) {
+ ERR_FAIL_INDEX(p_parameter, PARAM_MAX);
+ if ((p_parameter == PARAM_DIFFUSE || p_parameter == PARAM_SPECULAR || p_parameter == PARAM_EMISSION)) {
-
-void FixedMaterial::set_parameter(Parameter p_parameter, const Variant& p_value) {
-
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- if ((p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION)) {
-
- if (p_value.get_type()!=Variant::COLOR) {
- ERR_EXPLAIN(String(_param_names[p_parameter])+" expects Color");
+ if (p_value.get_type() != Variant::COLOR) {
+ ERR_EXPLAIN(String(_param_names[p_parameter]) + " expects Color");
ERR_FAIL();
}
} else {
if (!p_value.is_num()) {
- ERR_EXPLAIN(String(_param_names[p_parameter])+" expects scalar");
+ ERR_EXPLAIN(String(_param_names[p_parameter]) + " expects scalar");
ERR_FAIL();
}
}
- ERR_FAIL_COND( (p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION) && p_value.get_type()!=Variant::COLOR );
- ERR_FAIL_COND( p_parameter!=PARAM_SHADE_PARAM && p_parameter!=PARAM_DIFFUSE && p_parameter!=PARAM_DETAIL && p_parameter!=PARAM_SPECULAR && p_parameter!=PARAM_EMISSION && p_value.get_type()!=Variant::REAL && p_value.get_type()!=Variant::INT );
+ ERR_FAIL_COND((p_parameter == PARAM_DIFFUSE || p_parameter == PARAM_SPECULAR || p_parameter == PARAM_EMISSION) && p_value.get_type() != Variant::COLOR);
+ ERR_FAIL_COND(p_parameter != PARAM_SHADE_PARAM && p_parameter != PARAM_DIFFUSE && p_parameter != PARAM_DETAIL && p_parameter != PARAM_SPECULAR && p_parameter != PARAM_EMISSION && p_value.get_type() != Variant::REAL && p_value.get_type() != Variant::INT);
- param[p_parameter]=p_value;
+ param[p_parameter] = p_value;
- VisualServer::get_singleton()->fixed_material_set_param(material,(VS::FixedMaterialParam)p_parameter,p_value);
+ VisualServer::get_singleton()->fixed_material_set_param(material, (VS::FixedMaterialParam)p_parameter, p_value);
_change_notify(_full_param_names[p_parameter]);
}
Variant FixedMaterial::get_parameter(Parameter p_parameter) const {
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,Variant());
+ ERR_FAIL_INDEX_V(p_parameter, PARAM_MAX, Variant());
return param[p_parameter];
}
-
-
void FixedMaterial::set_texture(Parameter p_parameter, Ref<Texture> p_texture) {
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
+ ERR_FAIL_INDEX(p_parameter, PARAM_MAX);
- texture_param[p_parameter]=p_texture;
- VisualServer::get_singleton()->fixed_material_set_texture(material,(VS::FixedMaterialParam)p_parameter,p_texture.is_null()?RID():p_texture->get_rid());
+ texture_param[p_parameter] = p_texture;
+ VisualServer::get_singleton()->fixed_material_set_texture(material, (VS::FixedMaterialParam)p_parameter, p_texture.is_null() ? RID() : p_texture->get_rid());
_change_notify();
}
Ref<Texture> FixedMaterial::get_texture(Parameter p_parameter) const {
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_parameter, PARAM_MAX, Ref<Texture>());
return texture_param[p_parameter];
}
void FixedMaterial::set_texcoord_mode(Parameter p_parameter, TexCoordMode p_mode) {
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- ERR_FAIL_INDEX(p_mode,4);
+ ERR_FAIL_INDEX(p_parameter, PARAM_MAX);
+ ERR_FAIL_INDEX(p_mode, 4);
- if (p_mode==texture_texcoord[p_parameter])
+ if (p_mode == texture_texcoord[p_parameter])
return;
- texture_texcoord[p_parameter]=p_mode;
+ texture_texcoord[p_parameter] = p_mode;
- VisualServer::get_singleton()->fixed_material_set_texcoord_mode(material,(VS::FixedMaterialParam)p_parameter,(VS::FixedMaterialTexCoordMode)p_mode);
+ VisualServer::get_singleton()->fixed_material_set_texcoord_mode(material, (VS::FixedMaterialParam)p_parameter, (VS::FixedMaterialTexCoordMode)p_mode);
_change_notify();
}
FixedMaterial::TexCoordMode FixedMaterial::get_texcoord_mode(Parameter p_parameter) const {
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,TEXCOORD_UV);
+ ERR_FAIL_INDEX_V(p_parameter, PARAM_MAX, TEXCOORD_UV);
return texture_texcoord[p_parameter];
}
void FixedMaterial::set_light_shader(LightShader p_shader) {
- light_shader=p_shader;
- VS::get_singleton()->fixed_material_set_light_shader(material,VS::FixedMaterialLightShader(p_shader));
+ light_shader = p_shader;
+ VS::get_singleton()->fixed_material_set_light_shader(material, VS::FixedMaterialLightShader(p_shader));
}
FixedMaterial::LightShader FixedMaterial::get_light_shader() const {
@@ -304,11 +290,10 @@ FixedMaterial::LightShader FixedMaterial::get_light_shader() const {
return light_shader;
}
+void FixedMaterial::set_uv_transform(const Transform &p_transform) {
-void FixedMaterial::set_uv_transform(const Transform& p_transform) {
-
- uv_transform=p_transform;
- VisualServer::get_singleton()->fixed_material_set_uv_transform(material, p_transform );
+ uv_transform = p_transform;
+ VisualServer::get_singleton()->fixed_material_set_uv_transform(material, p_transform);
_change_notify();
}
@@ -317,172 +302,151 @@ Transform FixedMaterial::get_uv_transform() const {
return uv_transform;
}
-
-
-
-
void FixedMaterial::set_fixed_flag(FixedFlag p_flag, bool p_value) {
- ERR_FAIL_INDEX(p_flag,5);
- fixed_flags[p_flag]=p_value;
- VisualServer::get_singleton()->fixed_material_set_flag(material,(VS::FixedMaterialFlags)p_flag,p_value);
-
+ ERR_FAIL_INDEX(p_flag, 5);
+ fixed_flags[p_flag] = p_value;
+ VisualServer::get_singleton()->fixed_material_set_flag(material, (VS::FixedMaterialFlags)p_flag, p_value);
}
bool FixedMaterial::get_fixed_flag(FixedFlag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,5,false);
+ ERR_FAIL_INDEX_V(p_flag, 5, false);
return fixed_flags[p_flag];
}
void FixedMaterial::set_point_size(float p_size) {
- ERR_FAIL_COND(p_size<0);
- point_size=p_size;
- VisualServer::get_singleton()->fixed_material_set_point_size(material,p_size);
+ ERR_FAIL_COND(p_size < 0);
+ point_size = p_size;
+ VisualServer::get_singleton()->fixed_material_set_point_size(material, p_size);
}
-float FixedMaterial::get_point_size() const{
-
+float FixedMaterial::get_point_size() const {
return point_size;
}
-
void FixedMaterial::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_parameter", "param", "value"), &FixedMaterial::set_parameter);
+ ObjectTypeDB::bind_method(_MD("get_parameter", "param"), &FixedMaterial::get_parameter);
- ObjectTypeDB::bind_method(_MD("set_parameter","param","value"),&FixedMaterial::set_parameter);
- ObjectTypeDB::bind_method(_MD("get_parameter","param"),&FixedMaterial::get_parameter);
-
- ObjectTypeDB::bind_method(_MD("set_texture","param","texture:Texture"),&FixedMaterial::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture","param"),&FixedMaterial::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_texture", "param", "texture:Texture"), &FixedMaterial::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture", "param"), &FixedMaterial::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_texcoord_mode", "param", "mode"), &FixedMaterial::set_texcoord_mode);
+ ObjectTypeDB::bind_method(_MD("get_texcoord_mode", "param"), &FixedMaterial::get_texcoord_mode);
- ObjectTypeDB::bind_method(_MD("set_texcoord_mode","param","mode"),&FixedMaterial::set_texcoord_mode);
- ObjectTypeDB::bind_method(_MD("get_texcoord_mode","param"),&FixedMaterial::get_texcoord_mode);
+ ObjectTypeDB::bind_method(_MD("set_fixed_flag", "flag", "value"), &FixedMaterial::set_fixed_flag);
+ ObjectTypeDB::bind_method(_MD("get_fixed_flag", "flag"), &FixedMaterial::get_fixed_flag);
- ObjectTypeDB::bind_method(_MD("set_fixed_flag","flag","value"),&FixedMaterial::set_fixed_flag);
- ObjectTypeDB::bind_method(_MD("get_fixed_flag","flag"),&FixedMaterial::get_fixed_flag);
+ ObjectTypeDB::bind_method(_MD("set_uv_transform", "transform"), &FixedMaterial::set_uv_transform);
+ ObjectTypeDB::bind_method(_MD("get_uv_transform"), &FixedMaterial::get_uv_transform);
- ObjectTypeDB::bind_method(_MD("set_uv_transform","transform"),&FixedMaterial::set_uv_transform);
- ObjectTypeDB::bind_method(_MD("get_uv_transform"),&FixedMaterial::get_uv_transform);
+ ObjectTypeDB::bind_method(_MD("set_light_shader", "shader"), &FixedMaterial::set_light_shader);
+ ObjectTypeDB::bind_method(_MD("get_light_shader"), &FixedMaterial::get_light_shader);
- ObjectTypeDB::bind_method(_MD("set_light_shader","shader"),&FixedMaterial::set_light_shader);
- ObjectTypeDB::bind_method(_MD("get_light_shader"),&FixedMaterial::get_light_shader);
+ ObjectTypeDB::bind_method(_MD("set_point_size", "size"), &FixedMaterial::set_point_size);
+ ObjectTypeDB::bind_method(_MD("get_point_size"), &FixedMaterial::get_point_size);
- ObjectTypeDB::bind_method(_MD("set_point_size","size"),&FixedMaterial::set_point_size);
- ObjectTypeDB::bind_method(_MD("get_point_size"),&FixedMaterial::get_point_size);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_flags/use_alpha"), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_ALPHA);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_flags/use_color_array"), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_COLOR_ARRAY);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_flags/use_point_size"), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_POINT_SIZE);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_flags/discard_alpha"), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_DISCARD_ALPHA);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_flags/use_xy_normalmap"), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_XY_NORMALMAP);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "params/diffuse"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DIFFUSE);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "params/specular", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR);
+ ADD_PROPERTYI(PropertyInfo(Variant::COLOR, "params/emission", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_EMISSION);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/specular_exp", PROPERTY_HINT_RANGE, "1,64,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR_EXP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/detail_mix", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DETAIL);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/normal_depth", PROPERTY_HINT_RANGE, "-4,4,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_NORMAL);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "params/shader", PROPERTY_HINT_ENUM, "Lambert,Wrap,Velvet,Toon"), _SCS("set_light_shader"), _SCS("get_light_shader"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/shader_param", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADE_PARAM);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "params/glow", PROPERTY_HINT_RANGE, "0,8,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_GLOW);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "params/point_size", PROPERTY_HINT_RANGE, "0,1024,1"), _SCS("set_point_size"), _SCS("get_point_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "uv_xform"), _SCS("set_uv_transform"), _SCS("get_uv_transform"));
-
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_ALPHA);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_color_array" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_COLOR_ARRAY);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_point_size" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_POINT_SIZE);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/discard_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_DISCARD_ALPHA);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_xy_normalmap" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_XY_NORMALMAP);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/diffuse" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/specular", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR );
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/emission", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_EMISSION );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/specular_exp", PROPERTY_HINT_RANGE,"1,64,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR_EXP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/detail_mix", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DETAIL );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/normal_depth", PROPERTY_HINT_RANGE,"-4,4,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_NORMAL );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/shader", PROPERTY_HINT_ENUM,"Lambert,Wrap,Velvet,Toon" ), _SCS("set_light_shader"), _SCS("get_light_shader") );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/shader_param", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADE_PARAM );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/glow", PROPERTY_HINT_RANGE,"0,8,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_GLOW );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/point_size", PROPERTY_HINT_RANGE,"0,1024,1" ), _SCS("set_point_size"), _SCS("get_point_size"));
- ADD_PROPERTY( PropertyInfo( Variant::TRANSFORM, "uv_xform"), _SCS("set_uv_transform"), _SCS("get_uv_transform") );
-
- for(int i=0;i<PARAM_MAX;i++) {
- ADD_PROPERTYI( PropertyInfo( Variant::OBJECT, String()+"textures/"+_param_names[i],PROPERTY_HINT_RESOURCE_TYPE,"Texture" ), _SCS("set_texture"), _SCS("get_texture"), _param_indices[i]);
- ADD_PROPERTYI( PropertyInfo( Variant::INT, String()+"textures/"+_param_names[i]+"_tc",PROPERTY_HINT_ENUM,"UV,UV Xform,UV2,Sphere" ), _SCS("set_texcoord_mode"), _SCS("get_texcoord_mode"), _param_indices[i] );
+ for (int i = 0; i < PARAM_MAX; i++) {
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, String() + "textures/" + _param_names[i], PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"), _param_indices[i]);
+ ADD_PROPERTYI(PropertyInfo(Variant::INT, String() + "textures/" + _param_names[i] + "_tc", PROPERTY_HINT_ENUM, "UV,UV Xform,UV2,Sphere"), _SCS("set_texcoord_mode"), _SCS("get_texcoord_mode"), _param_indices[i]);
}
+ BIND_CONSTANT(PARAM_DIFFUSE);
+ BIND_CONSTANT(PARAM_DETAIL);
+ BIND_CONSTANT(PARAM_SPECULAR);
+ BIND_CONSTANT(PARAM_EMISSION);
+ BIND_CONSTANT(PARAM_SPECULAR_EXP);
+ BIND_CONSTANT(PARAM_GLOW);
+ BIND_CONSTANT(PARAM_NORMAL);
+ BIND_CONSTANT(PARAM_SHADE_PARAM);
+ BIND_CONSTANT(PARAM_MAX);
- BIND_CONSTANT( PARAM_DIFFUSE );
- BIND_CONSTANT( PARAM_DETAIL );
- BIND_CONSTANT( PARAM_SPECULAR );
- BIND_CONSTANT( PARAM_EMISSION );
- BIND_CONSTANT( PARAM_SPECULAR_EXP );
- BIND_CONSTANT( PARAM_GLOW );
- BIND_CONSTANT( PARAM_NORMAL );
- BIND_CONSTANT( PARAM_SHADE_PARAM );
- BIND_CONSTANT( PARAM_MAX );
-
- BIND_CONSTANT( TEXCOORD_UV );
- BIND_CONSTANT( TEXCOORD_UV_TRANSFORM );
- BIND_CONSTANT( TEXCOORD_UV2 );
- BIND_CONSTANT( TEXCOORD_SPHERE );
+ BIND_CONSTANT(TEXCOORD_UV);
+ BIND_CONSTANT(TEXCOORD_UV_TRANSFORM);
+ BIND_CONSTANT(TEXCOORD_UV2);
+ BIND_CONSTANT(TEXCOORD_SPHERE);
- BIND_CONSTANT( FLAG_USE_ALPHA );
- BIND_CONSTANT( FLAG_USE_COLOR_ARRAY );
- BIND_CONSTANT( FLAG_USE_POINT_SIZE );
- BIND_CONSTANT( FLAG_DISCARD_ALPHA );
-
- BIND_CONSTANT( LIGHT_SHADER_LAMBERT );
- BIND_CONSTANT( LIGHT_SHADER_WRAP );
- BIND_CONSTANT( LIGHT_SHADER_VELVET );
- BIND_CONSTANT( LIGHT_SHADER_TOON );
+ BIND_CONSTANT(FLAG_USE_ALPHA);
+ BIND_CONSTANT(FLAG_USE_COLOR_ARRAY);
+ BIND_CONSTANT(FLAG_USE_POINT_SIZE);
+ BIND_CONSTANT(FLAG_DISCARD_ALPHA);
+ BIND_CONSTANT(LIGHT_SHADER_LAMBERT);
+ BIND_CONSTANT(LIGHT_SHADER_WRAP);
+ BIND_CONSTANT(LIGHT_SHADER_VELVET);
+ BIND_CONSTANT(LIGHT_SHADER_TOON);
}
+FixedMaterial::FixedMaterial()
+ : Material(VS::get_singleton()->fixed_material_create()) {
-FixedMaterial::FixedMaterial() : Material(VS::get_singleton()->fixed_material_create()) {
-
-
-
- param[PARAM_DIFFUSE]=Color(1,1,1);
- param[PARAM_SPECULAR]=Color(0.0,0.0,0.0);
- param[PARAM_EMISSION]=Color(0.0,0.0,0.0);
- param[PARAM_SPECULAR_EXP]=40;
- param[PARAM_GLOW]=0;
- param[PARAM_NORMAL]=1;
- param[PARAM_SHADE_PARAM]=0.5;
- param[PARAM_DETAIL]=1.0;
+ param[PARAM_DIFFUSE] = Color(1, 1, 1);
+ param[PARAM_SPECULAR] = Color(0.0, 0.0, 0.0);
+ param[PARAM_EMISSION] = Color(0.0, 0.0, 0.0);
+ param[PARAM_SPECULAR_EXP] = 40;
+ param[PARAM_GLOW] = 0;
+ param[PARAM_NORMAL] = 1;
+ param[PARAM_SHADE_PARAM] = 0.5;
+ param[PARAM_DETAIL] = 1.0;
- set_flag(FLAG_COLOR_ARRAY_SRGB,true);
+ set_flag(FLAG_COLOR_ARRAY_SRGB, true);
- fixed_flags[FLAG_USE_ALPHA]=false;
- fixed_flags[FLAG_USE_COLOR_ARRAY]=false;
- fixed_flags[FLAG_USE_POINT_SIZE]=false;
- fixed_flags[FLAG_USE_XY_NORMALMAP]=false;
- fixed_flags[FLAG_DISCARD_ALPHA]=false;
+ fixed_flags[FLAG_USE_ALPHA] = false;
+ fixed_flags[FLAG_USE_COLOR_ARRAY] = false;
+ fixed_flags[FLAG_USE_POINT_SIZE] = false;
+ fixed_flags[FLAG_USE_XY_NORMALMAP] = false;
+ fixed_flags[FLAG_DISCARD_ALPHA] = false;
+ for (int i = 0; i < PARAM_MAX; i++) {
- for(int i=0;i<PARAM_MAX;i++) {
-
- texture_texcoord[i]=TEXCOORD_UV;
+ texture_texcoord[i] = TEXCOORD_UV;
}
- light_shader=LIGHT_SHADER_LAMBERT;
+ light_shader = LIGHT_SHADER_LAMBERT;
- point_size=1.0;
+ point_size = 1.0;
}
-
FixedMaterial::~FixedMaterial() {
-
}
+bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
-
-
-bool ShaderMaterial::_set(const StringName& p_name, const Variant& p_value) {
-
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
+ if (p_name == SceneStringNames::get_singleton()->shader_shader) {
set_shader(p_value);
return true;
} else {
if (shader.is_valid()) {
-
StringName pr = shader->remap_param(p_name);
if (!pr) {
String n = p_name;
- if (n.find("param/")==0) { //backwards compatibility
- pr = n.substr(6,n.length());
+ if (n.find("param/") == 0) { //backwards compatibility
+ pr = n.substr(6, n.length());
}
}
if (pr) {
- VisualServer::get_singleton()->material_set_param(material,pr,p_value);
+ VisualServer::get_singleton()->material_set_param(material, pr, p_value);
return true;
}
}
@@ -491,12 +455,11 @@ bool ShaderMaterial::_set(const StringName& p_name, const Variant& p_value) {
return false;
}
-bool ShaderMaterial::_get(const StringName& p_name,Variant &r_ret) const {
-
+bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
+ if (p_name == SceneStringNames::get_singleton()->shader_shader) {
- r_ret=get_shader();
+ r_ret = get_shader();
return true;
} else {
@@ -504,48 +467,42 @@ bool ShaderMaterial::_get(const StringName& p_name,Variant &r_ret) const {
StringName pr = shader->remap_param(p_name);
if (pr) {
- r_ret=VisualServer::get_singleton()->material_get_param(material,pr);
+ r_ret = VisualServer::get_singleton()->material_get_param(material, pr);
return true;
}
}
-
}
-
return false;
}
+void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
-void ShaderMaterial::_get_property_list( List<PropertyInfo> *p_list) const {
-
- p_list->push_back( PropertyInfo( Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE,"MaterialShader,MaterialShaderGraph" ) );
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE, "MaterialShader,MaterialShaderGraph"));
if (!shader.is_null()) {
shader->get_param_list(p_list);
}
-
}
-
void ShaderMaterial::_shader_changed() {
_change_notify(); //also all may have changed then
}
-void ShaderMaterial::set_shader(const Ref<Shader>& p_shader) {
+void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
- ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_MATERIAL);
+ ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode() != Shader::MODE_MATERIAL);
if (shader.is_valid())
- shader->disconnect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
- shader=p_shader;
- VS::get_singleton()->material_set_shader(material,shader.is_valid()?shader->get_rid():RID());
+ shader->disconnect(SceneStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_shader_changed);
+ shader = p_shader;
+ VS::get_singleton()->material_set_shader(material, shader.is_valid() ? shader->get_rid() : RID());
if (shader.is_valid()) {
- shader->connect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
+ shader->connect(SceneStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_shader_changed);
}
_change_notify();
-
}
Ref<Shader> ShaderMaterial::get_shader() const {
@@ -553,52 +510,45 @@ Ref<Shader> ShaderMaterial::get_shader() const {
return shader;
}
+void ShaderMaterial::set_shader_param(const StringName &p_param, const Variant &p_value) {
-void ShaderMaterial::set_shader_param(const StringName& p_param,const Variant& p_value) {
-
- VisualServer::get_singleton()->material_set_param(material,p_param,p_value);
-
+ VisualServer::get_singleton()->material_set_param(material, p_param, p_value);
}
-Variant ShaderMaterial::get_shader_param(const StringName& p_param) const{
+Variant ShaderMaterial::get_shader_param(const StringName &p_param) const {
- return VisualServer::get_singleton()->material_get_param(material,p_param);
+ return VisualServer::get_singleton()->material_get_param(material, p_param);
}
-
-
void ShaderMaterial::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shader","shader:Shader"), &ShaderMaterial::set_shader );
- ObjectTypeDB::bind_method(_MD("get_shader:Shader"), &ShaderMaterial::get_shader );
+ ObjectTypeDB::bind_method(_MD("set_shader", "shader:Shader"), &ShaderMaterial::set_shader);
+ ObjectTypeDB::bind_method(_MD("get_shader:Shader"), &ShaderMaterial::get_shader);
- ObjectTypeDB::bind_method(_MD("set_shader_param","param","value:Variant"), &ShaderMaterial::set_shader_param);
- ObjectTypeDB::bind_method(_MD("get_shader_param:Variant","param"), &ShaderMaterial::get_shader_param);
+ ObjectTypeDB::bind_method(_MD("set_shader_param", "param", "value:Variant"), &ShaderMaterial::set_shader_param);
+ ObjectTypeDB::bind_method(_MD("get_shader_param:Variant", "param"), &ShaderMaterial::get_shader_param);
- ObjectTypeDB::bind_method(_MD("_shader_changed"), &ShaderMaterial::_shader_changed );
+ ObjectTypeDB::bind_method(_MD("_shader_changed"), &ShaderMaterial::_shader_changed);
}
-
-void ShaderMaterial::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
+void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
String f = p_function.operator String();
- if ((f=="get_shader_param" || f=="set_shader_param") && p_idx==0) {
+ if ((f == "get_shader_param" || f == "set_shader_param") && p_idx == 0) {
if (shader.is_valid()) {
List<PropertyInfo> pl;
shader->get_param_list(&pl);
- for (List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {
- r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\"");
+ for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) {
+ r_options->push_back("\"" + E->get().name.replace_first("shader_param/", "") + "\"");
}
}
}
- Material::get_argument_options(p_function,p_idx,r_options);
+ Material::get_argument_options(p_function, p_idx, r_options);
}
-ShaderMaterial::ShaderMaterial() :Material(VisualServer::get_singleton()->material_create()){
-
-
+ShaderMaterial::ShaderMaterial()
+ : Material(VisualServer::get_singleton()->material_create()) {
}
-
/////////////////////////////////
diff --git a/scene/resources/material.h b/scene/resources/material.h
index fc1ea3d89..5b18ac61f 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -29,11 +29,11 @@
#ifndef MATERIAL_H
#define MATERIAL_H
-#include "servers/visual_server.h"
-#include "scene/resources/texture.h"
-#include "scene/resources/shader.h"
#include "resource.h"
+#include "scene/resources/shader.h"
+#include "scene/resources/texture.h"
#include "servers/visual/shader_language.h"
+#include "servers/visual_server.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
@@ -41,12 +41,11 @@
class Material : public Resource {
- OBJ_TYPE(Material,Resource);
+ OBJ_TYPE(Material, Resource);
RES_BASE_EXTENSION("mtl");
- OBJ_SAVE_TYPE( Material );
+ OBJ_SAVE_TYPE(Material);
public:
-
enum Flag {
FLAG_VISIBLE = VS::MATERIAL_FLAG_VISIBLE,
FLAG_DOUBLE_SIDED = VS::MATERIAL_FLAG_DOUBLE_SIDED,
@@ -74,20 +73,19 @@ public:
DEPTH_DRAW_NEVER = VS::MATERIAL_DEPTH_DRAW_NEVER
};
-
-
private:
BlendMode blend_mode;
bool flags[VS::MATERIAL_FLAG_MAX];
float line_width;
DepthDrawMode depth_draw_mode;
+
protected:
RID material;
static void _bind_methods();
public:
- void set_flag(Flag p_flag,bool p_enabled);
+ void set_flag(Flag p_flag, bool p_enabled);
bool get_flag(Flag p_flag) const;
void set_blend_mode(BlendMode p_blend_mode);
@@ -101,63 +99,58 @@ public:
virtual RID get_rid() const;
- Material(const RID& p_rid=RID());
+ Material(const RID &p_rid = RID());
virtual ~Material();
};
-VARIANT_ENUM_CAST( Material::Flag );
-VARIANT_ENUM_CAST( Material::DepthDrawMode );
-
-VARIANT_ENUM_CAST( Material::BlendMode );
+VARIANT_ENUM_CAST(Material::Flag);
+VARIANT_ENUM_CAST(Material::DepthDrawMode);
+VARIANT_ENUM_CAST(Material::BlendMode);
class FixedMaterial : public Material {
- OBJ_TYPE( FixedMaterial, Material );
+ OBJ_TYPE(FixedMaterial, Material);
REVERSE_GET_PROPERTY_LIST
public:
-
enum Parameter {
- PARAM_DIFFUSE=VS::FIXED_MATERIAL_PARAM_DIFFUSE,
- PARAM_DETAIL=VS::FIXED_MATERIAL_PARAM_DETAIL,
- PARAM_SPECULAR=VS::FIXED_MATERIAL_PARAM_SPECULAR,
- PARAM_EMISSION=VS::FIXED_MATERIAL_PARAM_EMISSION,
- PARAM_SPECULAR_EXP=VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP,
- PARAM_GLOW=VS::FIXED_MATERIAL_PARAM_GLOW,
- PARAM_NORMAL=VS::FIXED_MATERIAL_PARAM_NORMAL,
- PARAM_SHADE_PARAM=VS::FIXED_MATERIAL_PARAM_SHADE_PARAM,
- PARAM_MAX=VS::FIXED_MATERIAL_PARAM_MAX
+ PARAM_DIFFUSE = VS::FIXED_MATERIAL_PARAM_DIFFUSE,
+ PARAM_DETAIL = VS::FIXED_MATERIAL_PARAM_DETAIL,
+ PARAM_SPECULAR = VS::FIXED_MATERIAL_PARAM_SPECULAR,
+ PARAM_EMISSION = VS::FIXED_MATERIAL_PARAM_EMISSION,
+ PARAM_SPECULAR_EXP = VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP,
+ PARAM_GLOW = VS::FIXED_MATERIAL_PARAM_GLOW,
+ PARAM_NORMAL = VS::FIXED_MATERIAL_PARAM_NORMAL,
+ PARAM_SHADE_PARAM = VS::FIXED_MATERIAL_PARAM_SHADE_PARAM,
+ PARAM_MAX = VS::FIXED_MATERIAL_PARAM_MAX
};
-
enum TexCoordMode {
- TEXCOORD_UV=VS::FIXED_MATERIAL_TEXCOORD_UV,
- TEXCOORD_UV_TRANSFORM=VS::FIXED_MATERIAL_TEXCOORD_UV_TRANSFORM,
- TEXCOORD_UV2=VS::FIXED_MATERIAL_TEXCOORD_UV2,
- TEXCOORD_SPHERE=VS::FIXED_MATERIAL_TEXCOORD_SPHERE
+ TEXCOORD_UV = VS::FIXED_MATERIAL_TEXCOORD_UV,
+ TEXCOORD_UV_TRANSFORM = VS::FIXED_MATERIAL_TEXCOORD_UV_TRANSFORM,
+ TEXCOORD_UV2 = VS::FIXED_MATERIAL_TEXCOORD_UV2,
+ TEXCOORD_SPHERE = VS::FIXED_MATERIAL_TEXCOORD_SPHERE
};
enum FixedFlag {
- FLAG_USE_ALPHA=VS::FIXED_MATERIAL_FLAG_USE_ALPHA,
- FLAG_USE_COLOR_ARRAY=VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,
- FLAG_USE_POINT_SIZE=VS::FIXED_MATERIAL_FLAG_USE_POINT_SIZE,
- FLAG_DISCARD_ALPHA=VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA,
- FLAG_USE_XY_NORMALMAP=VS::FIXED_MATERIAL_FLAG_USE_XY_NORMALMAP,
- FLAG_MAX=VS::FIXED_MATERIAL_FLAG_MAX
+ FLAG_USE_ALPHA = VS::FIXED_MATERIAL_FLAG_USE_ALPHA,
+ FLAG_USE_COLOR_ARRAY = VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,
+ FLAG_USE_POINT_SIZE = VS::FIXED_MATERIAL_FLAG_USE_POINT_SIZE,
+ FLAG_DISCARD_ALPHA = VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA,
+ FLAG_USE_XY_NORMALMAP = VS::FIXED_MATERIAL_FLAG_USE_XY_NORMALMAP,
+ FLAG_MAX = VS::FIXED_MATERIAL_FLAG_MAX
};
enum LightShader {
- LIGHT_SHADER_LAMBERT=VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT,
- LIGHT_SHADER_WRAP=VS::FIXED_MATERIAL_LIGHT_SHADER_WRAP,
- LIGHT_SHADER_VELVET=VS::FIXED_MATERIAL_LIGHT_SHADER_VELVET,
- LIGHT_SHADER_TOON=VS::FIXED_MATERIAL_LIGHT_SHADER_TOON
+ LIGHT_SHADER_LAMBERT = VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT,
+ LIGHT_SHADER_WRAP = VS::FIXED_MATERIAL_LIGHT_SHADER_WRAP,
+ LIGHT_SHADER_VELVET = VS::FIXED_MATERIAL_LIGHT_SHADER_VELVET,
+ LIGHT_SHADER_TOON = VS::FIXED_MATERIAL_LIGHT_SHADER_TOON
};
private:
-
-
struct Node {
int param;
@@ -172,21 +165,16 @@ private:
bool fixed_flags[FLAG_MAX];
float point_size;
-
Transform uv_transform;
protected:
-
-
static void _bind_methods();
-
public:
-
void set_fixed_flag(FixedFlag p_flag, bool p_value);
bool get_fixed_flag(FixedFlag p_flag) const;
- void set_parameter(Parameter p_parameter, const Variant& p_value);
+ void set_parameter(Parameter p_parameter, const Variant &p_value);
Variant get_parameter(Parameter p_parameter) const;
void set_texture(Parameter p_parameter, Ref<Texture> p_texture);
@@ -198,7 +186,7 @@ public:
void set_light_shader(LightShader p_shader);
LightShader get_light_shader() const;
- void set_uv_transform(const Transform& p_transform);
+ void set_uv_transform(const Transform &p_transform);
Transform get_uv_transform() const;
void set_point_size(float p_transform);
@@ -206,53 +194,41 @@ public:
FixedMaterial();
~FixedMaterial();
-
};
-
-
-VARIANT_ENUM_CAST( FixedMaterial::Parameter );
-VARIANT_ENUM_CAST( FixedMaterial::TexCoordMode );
-VARIANT_ENUM_CAST( FixedMaterial::FixedFlag );
-VARIANT_ENUM_CAST( FixedMaterial::LightShader );
+VARIANT_ENUM_CAST(FixedMaterial::Parameter);
+VARIANT_ENUM_CAST(FixedMaterial::TexCoordMode);
+VARIANT_ENUM_CAST(FixedMaterial::FixedFlag);
+VARIANT_ENUM_CAST(FixedMaterial::LightShader);
class ShaderMaterial : public Material {
- OBJ_TYPE( ShaderMaterial, Material );
+ OBJ_TYPE(ShaderMaterial, Material);
Ref<Shader> shader;
-
-
void _shader_changed();
- static void _shader_parse(void*p_self,ShaderLanguage::ProgramNode*p_node);
+ static void _shader_parse(void *p_self, ShaderLanguage::ProgramNode *p_node);
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
- void set_shader(const Ref<Shader>& p_shader);
+ void set_shader(const Ref<Shader> &p_shader);
Ref<Shader> get_shader() const;
- void set_shader_param(const StringName& p_param,const Variant& p_value);
- Variant get_shader_param(const StringName& p_param) const;
+ void set_shader_param(const StringName &p_param, const Variant &p_value);
+ Variant get_shader_param(const StringName &p_param) const;
- void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
+ void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
ShaderMaterial();
};
//////////////////////
-
-
-
-
-
#endif
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 4932b5f66..29c532f8a 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -31,7 +31,7 @@
#include "scene/resources/convex_polygon_shape.h"
#include "surface_tool.h"
-static const char* _array_name[]={
+static const char *_array_name[] = {
"vertex_array",
"normal_array",
"tangent_array",
@@ -44,7 +44,7 @@ static const char* _array_name[]={
NULL
};
-static const Mesh::ArrayType _array_types[]={
+static const Mesh::ArrayType _array_types[] = {
Mesh::ARRAY_VERTEX,
Mesh::ARRAY_NORMAL,
@@ -57,9 +57,8 @@ static const Mesh::ArrayType _array_types[]={
Mesh::ARRAY_INDEX
};
-
/* compatibility */
-static const int _format_translate[]={
+static const int _format_translate[] = {
Mesh::ARRAY_FORMAT_VERTEX,
Mesh::ARRAY_FORMAT_NORMAL,
@@ -72,22 +71,21 @@ static const int _format_translate[]={
Mesh::ARRAY_FORMAT_INDEX,
};
+bool Mesh::_set(const StringName &p_name, const Variant &p_value) {
-bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
-
- String sname=p_name;
+ String sname = p_name;
- if (p_name=="morph_target/names") {
+ if (p_name == "morph_target/names") {
- DVector<String> sk=p_value;
+ DVector<String> sk = p_value;
int sz = sk.size();
DVector<String>::Read r = sk.read();
- for(int i=0;i<sz;i++)
+ for (int i = 0; i < sz; i++)
add_morph_target(r[i]);
return true;
}
- if (p_name=="morph_target/mode") {
+ if (p_name == "morph_target/mode") {
set_morph_target_mode(MorphTargetMode(int(p_value)));
return true;
@@ -95,19 +93,19 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
if (sname.begins_with("surface_")) {
- int sl=sname.find("/");
- if (sl==-1)
+ int sl = sname.find("/");
+ if (sl == -1)
return false;
- int idx=sname.substr(8,sl-8).to_int()-1;
- String what = sname.get_slicec('/',1);
- if (what=="material")
- surface_set_material(idx,p_value);
- else if (what=="name")
- surface_set_name(idx,p_value);
+ int idx = sname.substr(8, sl - 8).to_int() - 1;
+ String what = sname.get_slicec('/', 1);
+ if (what == "material")
+ surface_set_material(idx, p_value);
+ else if (what == "name")
+ surface_set_name(idx, p_value);
return true;
}
- if (sname=="custom_aabb/custom_aabb") {
+ if (sname == "custom_aabb/custom_aabb") {
set_custom_aabb(p_value);
return true;
@@ -116,239 +114,219 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
if (!sname.begins_with("surfaces"))
return false;
+ int idx = sname.get_slicec('/', 1).to_int();
+ String what = sname.get_slicec('/', 2);
- int idx=sname.get_slicec('/',1).to_int();
- String what=sname.get_slicec('/',2);
-
- if (idx==surfaces.size()) {
+ if (idx == surfaces.size()) {
- if (what=="custom") {
+ if (what == "custom") {
add_custom_surface(p_value);
return true;
-
}
//create
- Dictionary d=p_value;
- ERR_FAIL_COND_V(!d.has("primitive"),false);
- ERR_FAIL_COND_V(!d.has("arrays"),false);
- ERR_FAIL_COND_V(!d.has("morph_arrays"),false);
+ Dictionary d = p_value;
+ ERR_FAIL_COND_V(!d.has("primitive"), false);
+ ERR_FAIL_COND_V(!d.has("arrays"), false);
+ ERR_FAIL_COND_V(!d.has("morph_arrays"), false);
bool alphasort = d.has("alphasort") && bool(d["alphasort"]);
-
- add_surface(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"],alphasort);
+ add_surface(PrimitiveType(int(d["primitive"])), d["arrays"], d["morph_arrays"], alphasort);
if (d.has("material")) {
- surface_set_material(idx,d["material"]);
+ surface_set_material(idx, d["material"]);
}
if (d.has("name")) {
- surface_set_name(idx,d["name"]);
+ surface_set_name(idx, d["name"]);
}
-
return true;
}
return false;
}
-bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
+bool Mesh::_get(const StringName &p_name, Variant &r_ret) const {
- String sname=p_name;
+ String sname = p_name;
- if (p_name=="morph_target/names") {
+ if (p_name == "morph_target/names") {
DVector<String> sk;
- for(int i=0;i<morph_targets.size();i++)
+ for (int i = 0; i < morph_targets.size(); i++)
sk.push_back(morph_targets[i]);
- r_ret=sk;
+ r_ret = sk;
return true;
- } else if (p_name=="morph_target/mode") {
+ } else if (p_name == "morph_target/mode") {
r_ret = get_morph_target_mode();
return true;
} else if (sname.begins_with("surface_")) {
- int sl=sname.find("/");
- if (sl==-1)
+ int sl = sname.find("/");
+ if (sl == -1)
return false;
- int idx=sname.substr(8,sl-8).to_int()-1;
- String what = sname.get_slicec('/',1);
- if (what=="material")
- r_ret=surface_get_material(idx);
- else if (what=="name")
- r_ret=surface_get_name(idx);
+ int idx = sname.substr(8, sl - 8).to_int() - 1;
+ String what = sname.get_slicec('/', 1);
+ if (what == "material")
+ r_ret = surface_get_material(idx);
+ else if (what == "name")
+ r_ret = surface_get_name(idx);
return true;
- } else if (sname=="custom_aabb/custom_aabb") {
+ } else if (sname == "custom_aabb/custom_aabb") {
- r_ret=custom_aabb;
+ r_ret = custom_aabb;
return true;
} else if (!sname.begins_with("surfaces"))
return false;
-
- int idx=sname.get_slicec('/',1).to_int();
- ERR_FAIL_INDEX_V(idx,surfaces.size(),false);
+ int idx = sname.get_slicec('/', 1).to_int();
+ ERR_FAIL_INDEX_V(idx, surfaces.size(), false);
Dictionary d;
- d["primitive"]=surface_get_primitive_type(idx);
- d["arrays"]=surface_get_arrays(idx);
- d["morph_arrays"]=surface_get_morph_arrays(idx);
- d["alphasort"]=surface_is_alpha_sorting_enabled(idx);
+ d["primitive"] = surface_get_primitive_type(idx);
+ d["arrays"] = surface_get_arrays(idx);
+ d["morph_arrays"] = surface_get_morph_arrays(idx);
+ d["alphasort"] = surface_is_alpha_sorting_enabled(idx);
Ref<Material> m = surface_get_material(idx);
if (m.is_valid())
- d["material"]=m;
+ d["material"] = m;
String n = surface_get_name(idx);
- if (n!="")
- d["name"]=n;
+ if (n != "")
+ d["name"] = n;
- r_ret=d;
+ r_ret = d;
return true;
}
-void Mesh::_get_property_list( List<PropertyInfo> *p_list) const {
+void Mesh::_get_property_list(List<PropertyInfo> *p_list) const {
if (morph_targets.size()) {
- p_list->push_back(PropertyInfo(Variant::STRING_ARRAY,"morph_target/names",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
- p_list->push_back(PropertyInfo(Variant::INT,"morph_target/mode",PROPERTY_HINT_ENUM,"Normalized,Relative"));
+ p_list->push_back(PropertyInfo(Variant::STRING_ARRAY, "morph_target/names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::INT, "morph_target/mode", PROPERTY_HINT_ENUM, "Normalized,Relative"));
}
- for (int i=0;i<surfaces.size();i++) {
+ for (int i = 0; i < surfaces.size(); i++) {
- p_list->push_back( PropertyInfo( Variant::DICTIONARY,"surfaces/"+itos(i), PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ) );
- p_list->push_back( PropertyInfo( Variant::STRING,"surface_"+itos(i+1)+"/name", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR ) );
- p_list->push_back( PropertyInfo( Variant::OBJECT,"surface_"+itos(i+1)+"/material", PROPERTY_HINT_RESOURCE_TYPE,"Material",PROPERTY_USAGE_EDITOR ) );
+ p_list->push_back(PropertyInfo(Variant::DICTIONARY, "surfaces/" + itos(i), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
+ p_list->push_back(PropertyInfo(Variant::STRING, "surface_" + itos(i + 1) + "/name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "Material", PROPERTY_USAGE_EDITOR));
}
- p_list->push_back( PropertyInfo( Variant::_AABB,"custom_aabb/custom_aabb" ) );
-
+ p_list->push_back(PropertyInfo(Variant::_AABB, "custom_aabb/custom_aabb"));
}
-
void Mesh::_recompute_aabb() {
// regenerate AABB
- aabb=AABB();
+ aabb = AABB();
- for (int i=0;i<surfaces.size();i++) {
+ for (int i = 0; i < surfaces.size(); i++) {
- if (i==0)
- aabb=surfaces[i].aabb;
+ if (i == 0)
+ aabb = surfaces[i].aabb;
else
aabb.merge_with(surfaces[i].aabb);
}
-
}
-void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes,bool p_alphasort) {
-
+void Mesh::add_surface(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, bool p_alphasort) {
- ERR_FAIL_COND(p_arrays.size()!=ARRAY_MAX);
+ ERR_FAIL_COND(p_arrays.size() != ARRAY_MAX);
Surface s;
- VisualServer::get_singleton()->mesh_add_surface(mesh,(VisualServer::PrimitiveType)p_primitive, p_arrays,p_blend_shapes,p_alphasort);
+ VisualServer::get_singleton()->mesh_add_surface(mesh, (VisualServer::PrimitiveType)p_primitive, p_arrays, p_blend_shapes, p_alphasort);
surfaces.push_back(s);
-
-
/* make aABB? */ {
- DVector<Vector3> vertices=p_arrays[ARRAY_VERTEX];
- int len=vertices.size();
- ERR_FAIL_COND(len==0);
- DVector<Vector3>::Read r=vertices.read();
- const Vector3 *vtx=r.ptr();
+ DVector<Vector3> vertices = p_arrays[ARRAY_VERTEX];
+ int len = vertices.size();
+ ERR_FAIL_COND(len == 0);
+ DVector<Vector3>::Read r = vertices.read();
+ const Vector3 *vtx = r.ptr();
// check AABB
AABB aabb;
- for (int i=0;i<len;i++) {
+ for (int i = 0; i < len; i++) {
- if (i==0)
- aabb.pos=vtx[i];
+ if (i == 0)
+ aabb.pos = vtx[i];
else
aabb.expand_to(vtx[i]);
}
- surfaces[surfaces.size()-1].aabb=aabb;
- surfaces[surfaces.size()-1].alphasort=p_alphasort;
+ surfaces[surfaces.size() - 1].aabb = aabb;
+ surfaces[surfaces.size() - 1].alphasort = p_alphasort;
_recompute_aabb();
-
}
- triangle_mesh=Ref<TriangleMesh>();
+ triangle_mesh = Ref<TriangleMesh>();
_change_notify();
emit_changed();
-
}
Array Mesh::surface_get_arrays(int p_surface) const {
- ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
- return VisualServer::get_singleton()->mesh_get_surface_arrays(mesh,p_surface);
-
+ ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array());
+ return VisualServer::get_singleton()->mesh_get_surface_arrays(mesh, p_surface);
}
Array Mesh::surface_get_morph_arrays(int p_surface) const {
- ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
- return VisualServer::get_singleton()->mesh_get_surface_morph_arrays(mesh,p_surface);
-
+ ERR_FAIL_INDEX_V(p_surface, surfaces.size(), Array());
+ return VisualServer::get_singleton()->mesh_get_surface_morph_arrays(mesh, p_surface);
}
-
-
-void Mesh::add_custom_surface(const Variant& p_data) {
+void Mesh::add_custom_surface(const Variant &p_data) {
Surface s;
- s.aabb=AABB();
- VisualServer::get_singleton()->mesh_add_custom_surface(mesh,p_data);
+ s.aabb = AABB();
+ VisualServer::get_singleton()->mesh_add_custom_surface(mesh, p_data);
surfaces.push_back(s);
- triangle_mesh=Ref<TriangleMesh>();
+ triangle_mesh = Ref<TriangleMesh>();
_change_notify();
}
-
int Mesh::get_surface_count() const {
return surfaces.size();
}
-void Mesh::add_morph_target(const StringName& p_name) {
+void Mesh::add_morph_target(const StringName &p_name) {
if (surfaces.size()) {
ERR_EXPLAIN("Can't add a shape key count if surfaces are already created.");
ERR_FAIL_COND(surfaces.size());
}
- StringName name=p_name;
+ StringName name = p_name;
- if (morph_targets.find(name)!=-1 ) {
+ if (morph_targets.find(name) != -1) {
- int count=2;
+ int count = 2;
do {
name = String(p_name) + " " + itos(count);
count++;
- } while(morph_targets.find(name)!=-1);
+ } while (morph_targets.find(name) != -1);
}
morph_targets.push_back(name);
- VS::get_singleton()->mesh_set_morph_target_count(mesh,morph_targets.size());
-
+ VS::get_singleton()->mesh_set_morph_target_count(mesh, morph_targets.size());
}
-
int Mesh::get_morph_target_count() const {
return morph_targets.size();
}
StringName Mesh::get_morph_target_name(int p_index) const {
- ERR_FAIL_INDEX_V( p_index, morph_targets.size(),StringName() );
+ ERR_FAIL_INDEX_V(p_index, morph_targets.size(), StringName());
return morph_targets[p_index];
}
void Mesh::clear_morph_targets() {
@@ -363,8 +341,8 @@ void Mesh::clear_morph_targets() {
void Mesh::set_morph_target_mode(MorphTargetMode p_mode) {
- morph_target_mode=p_mode;
- VS::get_singleton()->mesh_set_morph_target_mode(mesh,(VS::MorphTargetMode)p_mode);
+ morph_target_mode = p_mode;
+ VS::get_singleton()->mesh_set_morph_target_mode(mesh, (VS::MorphTargetMode)p_mode);
}
Mesh::MorphTargetMode Mesh::get_morph_target_mode() const {
@@ -372,118 +350,105 @@ Mesh::MorphTargetMode Mesh::get_morph_target_mode() const {
return morph_target_mode;
}
-
void Mesh::surface_remove(int p_idx) {
- ERR_FAIL_INDEX(p_idx, surfaces.size() );
- VisualServer::get_singleton()->mesh_remove_surface(mesh,p_idx);
+ ERR_FAIL_INDEX(p_idx, surfaces.size());
+ VisualServer::get_singleton()->mesh_remove_surface(mesh, p_idx);
surfaces.remove(p_idx);
- triangle_mesh=Ref<TriangleMesh>();
+ triangle_mesh = Ref<TriangleMesh>();
_recompute_aabb();
_change_notify();
emit_changed();
}
-
-
-
-
int Mesh::surface_get_array_len(int p_idx) const {
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), -1 );
- return VisualServer::get_singleton()->mesh_surface_get_array_len( mesh, p_idx );
-
+ ERR_FAIL_INDEX_V(p_idx, surfaces.size(), -1);
+ return VisualServer::get_singleton()->mesh_surface_get_array_len(mesh, p_idx);
}
int Mesh::surface_get_array_index_len(int p_idx) const {
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), -1 );
- return VisualServer::get_singleton()->mesh_surface_get_array_index_len( mesh, p_idx );
-
+ ERR_FAIL_INDEX_V(p_idx, surfaces.size(), -1);
+ return VisualServer::get_singleton()->mesh_surface_get_array_index_len(mesh, p_idx);
}
uint32_t Mesh::surface_get_format(int p_idx) const {
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), 0 );
- return VisualServer::get_singleton()->mesh_surface_get_format( mesh, p_idx );
-
+ ERR_FAIL_INDEX_V(p_idx, surfaces.size(), 0);
+ return VisualServer::get_singleton()->mesh_surface_get_format(mesh, p_idx);
}
-
-
Mesh::PrimitiveType Mesh::surface_get_primitive_type(int p_idx) const {
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), PRIMITIVE_LINES );
- return (PrimitiveType)VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, p_idx );
+ ERR_FAIL_INDEX_V(p_idx, surfaces.size(), PRIMITIVE_LINES);
+ return (PrimitiveType)VisualServer::get_singleton()->mesh_surface_get_primitive_type(mesh, p_idx);
}
bool Mesh::surface_is_alpha_sorting_enabled(int p_idx) const {
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), 0 );
+ ERR_FAIL_INDEX_V(p_idx, surfaces.size(), 0);
return surfaces[p_idx].alphasort;
}
-void Mesh::surface_set_material(int p_idx, const Ref<Material>& p_material) {
+void Mesh::surface_set_material(int p_idx, const Ref<Material> &p_material) {
- ERR_FAIL_INDEX( p_idx, surfaces.size() );
- if (surfaces[p_idx].material==p_material)
+ ERR_FAIL_INDEX(p_idx, surfaces.size());
+ if (surfaces[p_idx].material == p_material)
return;
- surfaces[p_idx].material=p_material;
- VisualServer::get_singleton()->mesh_surface_set_material(mesh, p_idx, p_material.is_null()?RID():p_material->get_rid());
+ surfaces[p_idx].material = p_material;
+ VisualServer::get_singleton()->mesh_surface_set_material(mesh, p_idx, p_material.is_null() ? RID() : p_material->get_rid());
_change_notify("material");
}
-void Mesh::surface_set_name(int p_idx, const String& p_name) {
+void Mesh::surface_set_name(int p_idx, const String &p_name) {
- ERR_FAIL_INDEX( p_idx, surfaces.size() );
+ ERR_FAIL_INDEX(p_idx, surfaces.size());
- surfaces[p_idx].name=p_name;
+ surfaces[p_idx].name = p_name;
}
-String Mesh::surface_get_name(int p_idx) const{
+String Mesh::surface_get_name(int p_idx) const {
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(),String() );
+ ERR_FAIL_INDEX_V(p_idx, surfaces.size(), String());
return surfaces[p_idx].name;
-
}
-void Mesh::surface_set_custom_aabb(int p_idx,const AABB& p_aabb) {
+void Mesh::surface_set_custom_aabb(int p_idx, const AABB &p_aabb) {
- ERR_FAIL_INDEX( p_idx, surfaces.size() );
- surfaces[p_idx].aabb=p_aabb;
-// set custom aabb too?
+ ERR_FAIL_INDEX(p_idx, surfaces.size());
+ surfaces[p_idx].aabb = p_aabb;
+ // set custom aabb too?
}
-Ref<Material> Mesh::surface_get_material(int p_idx) const {
+Ref<Material> Mesh::surface_get_material(int p_idx) const {
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), Ref<Material>() );
+ ERR_FAIL_INDEX_V(p_idx, surfaces.size(), Ref<Material>());
return surfaces[p_idx].material;
-
}
-void Mesh::add_surface_from_mesh_data(const Geometry::MeshData& p_mesh_data) {
+void Mesh::add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data) {
- VisualServer::get_singleton()->mesh_add_surface_from_mesh_data( mesh, p_mesh_data );
+ VisualServer::get_singleton()->mesh_add_surface_from_mesh_data(mesh, p_mesh_data);
AABB aabb;
- for (int i=0;i<p_mesh_data.vertices.size();i++) {
+ for (int i = 0; i < p_mesh_data.vertices.size(); i++) {
- if (i==0)
- aabb.pos=p_mesh_data.vertices[i];
+ if (i == 0)
+ aabb.pos = p_mesh_data.vertices[i];
else
aabb.expand_to(p_mesh_data.vertices[i]);
}
-
Surface s;
- s.aabb=aabb;
- if (surfaces.size()==0)
- aabb=s.aabb;
+ s.aabb = aabb;
+ if (surfaces.size() == 0)
+ aabb = s.aabb;
else
aabb.merge_with(s.aabb);
- triangle_mesh=Ref<TriangleMesh>();
+ triangle_mesh = Ref<TriangleMesh>();
surfaces.push_back(s);
_change_notify();
@@ -500,11 +465,10 @@ AABB Mesh::get_aabb() const {
return aabb;
}
+void Mesh::set_custom_aabb(const AABB &p_custom) {
-void Mesh::set_custom_aabb(const AABB& p_custom) {
-
- custom_aabb=p_custom;
- VS::get_singleton()->mesh_set_custom_aabb(mesh,custom_aabb);
+ custom_aabb = p_custom;
+ VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
}
AABB Mesh::get_custom_aabb() const {
@@ -512,15 +476,13 @@ AABB Mesh::get_custom_aabb() const {
return custom_aabb;
}
-
DVector<Face3> Mesh::get_faces() const {
-
Ref<TriangleMesh> tm = generate_triangle_mesh();
if (tm.is_valid())
return tm->get_faces();
return DVector<Face3>();
-/*
+ /*
for (int i=0;i<surfaces.size();i++) {
if (VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, i ) != VisualServer::PRIMITIVE_TRIANGLES )
@@ -578,22 +540,20 @@ DVector<Face3> Mesh::get_faces() const {
}
*/
-
}
Ref<Shape> Mesh::create_convex_shape() const {
DVector<Vector3> vertices;
- for(int i=0;i<get_surface_count();i++) {
+ for (int i = 0; i < get_surface_count(); i++) {
Array a = surface_get_arrays(i);
- DVector<Vector3> v=a[ARRAY_VERTEX];
+ DVector<Vector3> v = a[ARRAY_VERTEX];
vertices.append_array(v);
-
}
- Ref<ConvexPolygonShape> shape = memnew( ConvexPolygonShape );
+ Ref<ConvexPolygonShape> shape = memnew(ConvexPolygonShape);
shape->set_points(vertices);
return shape;
}
@@ -601,26 +561,26 @@ Ref<Shape> Mesh::create_convex_shape() const {
Ref<Shape> Mesh::create_trimesh_shape() const {
DVector<Face3> faces = get_faces();
- if (faces.size()==0)
+ if (faces.size() == 0)
return Ref<Shape>();
DVector<Vector3> face_points;
- face_points.resize( faces.size()*3 );
+ face_points.resize(faces.size() * 3);
- for (int i=0;i<face_points.size();i++) {
+ for (int i = 0; i < face_points.size(); i++) {
- Face3 f = faces.get( i/3 );
- face_points.set(i, f.vertex[i%3] );
+ Face3 f = faces.get(i / 3);
+ face_points.set(i, f.vertex[i % 3]);
}
- Ref<ConcavePolygonShape> shape = memnew( ConcavePolygonShape );
+ Ref<ConcavePolygonShape> shape = memnew(ConcavePolygonShape);
shape->set_faces(face_points);
return shape;
}
void Mesh::center_geometry() {
-/*
+ /*
Vector3 ofs = aabb.pos+aabb.size*0.5;
for(int i=0;i<get_surface_count();i++) {
@@ -644,17 +604,15 @@ void Mesh::center_geometry() {
aabb.pos-=ofs;
*/
-
}
void Mesh::regen_normalmaps() {
+ Vector<Ref<SurfaceTool> > surfs;
+ for (int i = 0; i < get_surface_count(); i++) {
- Vector< Ref<SurfaceTool> > surfs;
- for(int i=0;i<get_surface_count();i++) {
-
- Ref<SurfaceTool> st = memnew( SurfaceTool );
- st->create_from(Ref<Mesh>(this),i);
+ Ref<SurfaceTool> st = memnew(SurfaceTool);
+ st->create_from(Ref<Mesh>(this), i);
surfs.push_back(st);
}
@@ -662,127 +620,119 @@ void Mesh::regen_normalmaps() {
surface_remove(0);
}
- for(int i=0;i<surfs.size();i++) {
+ for (int i = 0; i < surfs.size(); i++) {
surfs[i]->generate_tangents();
surfs[i]->commit(Ref<Mesh>(this));
}
}
-
-
Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
if (triangle_mesh.is_valid())
return triangle_mesh;
- int facecount=0;
+ int facecount = 0;
- for(int i=0;i<get_surface_count();i++) {
+ for (int i = 0; i < get_surface_count(); i++) {
- if (surface_get_primitive_type(i)!=PRIMITIVE_TRIANGLES)
+ if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES)
continue;
- if (surface_get_format(i)&ARRAY_FORMAT_INDEX) {
+ if (surface_get_format(i) & ARRAY_FORMAT_INDEX) {
- facecount+=surface_get_array_index_len(i);
+ facecount += surface_get_array_index_len(i);
} else {
- facecount+=surface_get_array_len(i);
+ facecount += surface_get_array_len(i);
}
-
}
- if (facecount==0 || (facecount%3)!=0)
+ if (facecount == 0 || (facecount % 3) != 0)
return triangle_mesh;
DVector<Vector3> faces;
faces.resize(facecount);
- DVector<Vector3>::Write facesw=faces.write();
+ DVector<Vector3>::Write facesw = faces.write();
- int widx=0;
+ int widx = 0;
- for(int i=0;i<get_surface_count();i++) {
+ for (int i = 0; i < get_surface_count(); i++) {
- if (surface_get_primitive_type(i)!=PRIMITIVE_TRIANGLES)
+ if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES)
continue;
Array a = surface_get_arrays(i);
int vc = surface_get_array_len(i);
DVector<Vector3> vertices = a[ARRAY_VERTEX];
- DVector<Vector3>::Read vr=vertices.read();
+ DVector<Vector3>::Read vr = vertices.read();
- if (surface_get_format(i)&ARRAY_FORMAT_INDEX) {
+ if (surface_get_format(i) & ARRAY_FORMAT_INDEX) {
- int ic=surface_get_array_index_len(i);
+ int ic = surface_get_array_index_len(i);
DVector<int> indices = a[ARRAY_INDEX];
DVector<int>::Read ir = indices.read();
- for(int i=0;i<ic;i++)
- facesw[widx++]=vr[ ir[i] ];
+ for (int i = 0; i < ic; i++)
+ facesw[widx++] = vr[ir[i]];
} else {
- for(int i=0;i<vc;i++)
- facesw[widx++]=vr[ i ];
+ for (int i = 0; i < vc; i++)
+ facesw[widx++] = vr[i];
}
-
}
- facesw=DVector<Vector3>::Write();
+ facesw = DVector<Vector3>::Write();
-
- triangle_mesh = Ref<TriangleMesh>( memnew( TriangleMesh ));
+ triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh));
triangle_mesh->create(faces);
return triangle_mesh;
-
-
}
Ref<Mesh> Mesh::create_outline(float p_margin) const {
-
Array arrays;
- int index_accum=0;
- for(int i=0;i<get_surface_count();i++) {
+ int index_accum = 0;
+ for (int i = 0; i < get_surface_count(); i++) {
- if (surface_get_primitive_type(i)!=PRIMITIVE_TRIANGLES)
+ if (surface_get_primitive_type(i) != PRIMITIVE_TRIANGLES)
continue;
Array a = surface_get_arrays(i);
- int vcount=0;
+ int vcount = 0;
- if (i==0) {
- arrays=a;
- DVector<Vector3> v=a[ARRAY_VERTEX];
- index_accum+=v.size();
+ if (i == 0) {
+ arrays = a;
+ DVector<Vector3> v = a[ARRAY_VERTEX];
+ index_accum += v.size();
} else {
- for(int j=0;j<arrays.size();j++) {
+ for (int j = 0; j < arrays.size(); j++) {
- if (arrays[j].get_type()==Variant::NIL || a[j].get_type()==Variant::NIL) {
+ if (arrays[j].get_type() == Variant::NIL || a[j].get_type() == Variant::NIL) {
//mismatch, do not use
- arrays[j]=Variant();
+ arrays[j] = Variant();
continue;
}
- switch(j) {
+ switch (j) {
case ARRAY_VERTEX:
- case ARRAY_NORMAL: {
+ case ARRAY_NORMAL: {
DVector<Vector3> dst = arrays[j];
DVector<Vector3> src = a[j];
- if (j==ARRAY_VERTEX)
- vcount=src.size();
- if (dst.size()==0 || src.size()==0) {
- arrays[j]=Variant();
+ if (j == ARRAY_VERTEX)
+ vcount = src.size();
+ if (dst.size() == 0 || src.size() == 0) {
+ arrays[j] = Variant();
continue;
}
dst.append_array(src);
- arrays[j]=dst;
+ arrays[j] = dst;
} break;
case ARRAY_TANGENT:
case ARRAY_BONES:
@@ -790,58 +740,56 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
DVector<real_t> dst = arrays[j];
DVector<real_t> src = a[j];
- if (dst.size()==0 || src.size()==0) {
- arrays[j]=Variant();
+ if (dst.size() == 0 || src.size() == 0) {
+ arrays[j] = Variant();
continue;
}
dst.append_array(src);
- arrays[j]=dst;
+ arrays[j] = dst;
} break;
case ARRAY_COLOR: {
DVector<Color> dst = arrays[j];
DVector<Color> src = a[j];
- if (dst.size()==0 || src.size()==0) {
- arrays[j]=Variant();
+ if (dst.size() == 0 || src.size() == 0) {
+ arrays[j] = Variant();
continue;
}
dst.append_array(src);
- arrays[j]=dst;
+ arrays[j] = dst;
} break;
case ARRAY_TEX_UV:
case ARRAY_TEX_UV2: {
DVector<Vector2> dst = arrays[j];
DVector<Vector2> src = a[j];
- if (dst.size()==0 || src.size()==0) {
- arrays[j]=Variant();
+ if (dst.size() == 0 || src.size() == 0) {
+ arrays[j] = Variant();
continue;
}
dst.append_array(src);
- arrays[j]=dst;
+ arrays[j] = dst;
} break;
case ARRAY_INDEX: {
DVector<int> dst = arrays[j];
DVector<int> src = a[j];
- if (dst.size()==0 || src.size()==0) {
- arrays[j]=Variant();
+ if (dst.size() == 0 || src.size() == 0) {
+ arrays[j] = Variant();
continue;
}
{
int ss = src.size();
DVector<int>::Write w = src.write();
- for(int k=0;k<ss;k++) {
- w[k]+=index_accum;
+ for (int k = 0; k < ss; k++) {
+ w[k] += index_accum;
}
-
}
dst.append_array(src);
- arrays[j]=dst;
- index_accum+=vcount;
+ arrays[j] = dst;
+ index_accum += vcount;
} break;
-
}
}
}
@@ -849,49 +797,47 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
{
DVector<int>::Write ir;
- DVector<int> indices =arrays[ARRAY_INDEX];
- bool has_indices=false;
- DVector<Vector3> vertices =arrays[ARRAY_VERTEX];
+ DVector<int> indices = arrays[ARRAY_INDEX];
+ bool has_indices = false;
+ DVector<Vector3> vertices = arrays[ARRAY_VERTEX];
int vc = vertices.size();
- ERR_FAIL_COND_V(!vc,Ref<Mesh>());
- DVector<Vector3>::Write r=vertices.write();
-
+ ERR_FAIL_COND_V(!vc, Ref<Mesh>());
+ DVector<Vector3>::Write r = vertices.write();
if (indices.size()) {
- vc=indices.size();
- ir=indices.write();
- has_indices=true;
+ vc = indices.size();
+ ir = indices.write();
+ has_indices = true;
}
- Map<Vector3,Vector3> normal_accum;
+ Map<Vector3, Vector3> normal_accum;
//fill normals with triangle normals
- for(int i=0;i<vc;i+=3) {
-
+ for (int i = 0; i < vc; i += 3) {
Vector3 t[3];
if (has_indices) {
- t[0]=r[ir[i+0]];
- t[1]=r[ir[i+1]];
- t[2]=r[ir[i+2]];
+ t[0] = r[ir[i + 0]];
+ t[1] = r[ir[i + 1]];
+ t[2] = r[ir[i + 2]];
} else {
- t[0]=r[i+0];
- t[1]=r[i+1];
- t[2]=r[i+2];
+ t[0] = r[i + 0];
+ t[1] = r[i + 1];
+ t[2] = r[i + 2];
}
- Vector3 n = Plane(t[0],t[1],t[2]).normal;
+ Vector3 n = Plane(t[0], t[1], t[2]).normal;
- for(int j=0;j<3;j++) {
+ for (int j = 0; j < 3; j++) {
- Map<Vector3,Vector3>::Element *E=normal_accum.find(t[j]);
+ Map<Vector3, Vector3>::Element *E = normal_accum.find(t[j]);
if (!E) {
- normal_accum[t[j]]=n;
+ normal_accum[t[j]] = n;
} else {
float d = n.dot(E->get());
- if (d<1.0)
- E->get()+=n*(1.0-d);
+ if (d < 1.0)
+ E->get() += n * (1.0 - d);
//E->get()+=n;
}
}
@@ -899,28 +845,26 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
//normalize
- for (Map<Vector3,Vector3>::Element *E=normal_accum.front();E;E=E->next()) {
+ for (Map<Vector3, Vector3>::Element *E = normal_accum.front(); E; E = E->next()) {
E->get().normalize();
}
-
//displace normals
int vc2 = vertices.size();
- for(int i=0;i<vc2;i++) {
+ for (int i = 0; i < vc2; i++) {
+ Vector3 t = r[i];
- Vector3 t=r[i];
-
- Map<Vector3,Vector3>::Element *E=normal_accum.find(t);
+ Map<Vector3, Vector3>::Element *E = normal_accum.find(t);
ERR_CONTINUE(!E);
- t+=E->get()*p_margin;
- r[i]=t;
+ t += E->get() * p_margin;
+ r[i] = t;
}
r = DVector<Vector3>::Write();
- arrays[ARRAY_VERTEX]=vertices;
+ arrays[ARRAY_VERTEX] = vertices;
if (!has_indices) {
@@ -928,112 +872,99 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
new_indices.resize(vertices.size());
DVector<int>::Write iw = new_indices.write();
- for(int j=0;j<vc2;j+=3) {
+ for (int j = 0; j < vc2; j += 3) {
- iw[j]=j;
- iw[j+1]=j+2;
- iw[j+2]=j+1;
+ iw[j] = j;
+ iw[j + 1] = j + 2;
+ iw[j + 2] = j + 1;
}
- iw=DVector<int>::Write();
- arrays[ARRAY_INDEX]=new_indices;
+ iw = DVector<int>::Write();
+ arrays[ARRAY_INDEX] = new_indices;
} else {
- for(int j=0;j<vc;j+=3) {
+ for (int j = 0; j < vc; j += 3) {
- SWAP(ir[j+1],ir[j+2]);
+ SWAP(ir[j + 1], ir[j + 2]);
}
- ir=DVector<int>::Write();
- arrays[ARRAY_INDEX]=indices;
-
+ ir = DVector<int>::Write();
+ arrays[ARRAY_INDEX] = indices;
}
}
-
-
-
- Ref<Mesh> newmesh = memnew( Mesh );
- newmesh->add_surface(PRIMITIVE_TRIANGLES,arrays);
+ Ref<Mesh> newmesh = memnew(Mesh);
+ newmesh->add_surface(PRIMITIVE_TRIANGLES, arrays);
return newmesh;
}
-
void Mesh::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_morph_target","name"),&Mesh::add_morph_target);
- ObjectTypeDB::bind_method(_MD("get_morph_target_count"),&Mesh::get_morph_target_count);
- ObjectTypeDB::bind_method(_MD("get_morph_target_name","index"),&Mesh::get_morph_target_name);
- ObjectTypeDB::bind_method(_MD("clear_morph_targets"),&Mesh::clear_morph_targets);
- ObjectTypeDB::bind_method(_MD("set_morph_target_mode","mode"),&Mesh::set_morph_target_mode);
- ObjectTypeDB::bind_method(_MD("get_morph_target_mode"),&Mesh::get_morph_target_mode);
-
- ObjectTypeDB::bind_method(_MD("add_surface","primitive","arrays","morph_arrays","alphasort"),&Mesh::add_surface,DEFVAL(Array()),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_surface_count"),&Mesh::get_surface_count);
- ObjectTypeDB::bind_method(_MD("surface_remove","surf_idx"),&Mesh::surface_remove);
- ObjectTypeDB::bind_method(_MD("surface_get_array_len","surf_idx"),&Mesh::surface_get_array_len);
- ObjectTypeDB::bind_method(_MD("surface_get_array_index_len","surf_idx"),&Mesh::surface_get_array_index_len);
- ObjectTypeDB::bind_method(_MD("surface_get_format","surf_idx"),&Mesh::surface_get_format);
- ObjectTypeDB::bind_method(_MD("surface_get_primitive_type","surf_idx"),&Mesh::surface_get_primitive_type);
- ObjectTypeDB::bind_method(_MD("surface_set_material","surf_idx","material:Material"),&Mesh::surface_set_material);
- ObjectTypeDB::bind_method(_MD("surface_get_material:Material","surf_idx"),&Mesh::surface_get_material);
- ObjectTypeDB::bind_method(_MD("surface_set_name","surf_idx","name"),&Mesh::surface_set_name);
- ObjectTypeDB::bind_method(_MD("surface_get_name","surf_idx"),&Mesh::surface_get_name);
- ObjectTypeDB::bind_method(_MD("center_geometry"),&Mesh::center_geometry);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("center_geometry"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("regen_normalmaps"),&Mesh::regen_normalmaps);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regen_normalmaps"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
-
- ObjectTypeDB::bind_method(_MD("set_custom_aabb","aabb"),&Mesh::set_custom_aabb);
- ObjectTypeDB::bind_method(_MD("get_custom_aabb"),&Mesh::get_custom_aabb);
+ ObjectTypeDB::bind_method(_MD("add_morph_target", "name"), &Mesh::add_morph_target);
+ ObjectTypeDB::bind_method(_MD("get_morph_target_count"), &Mesh::get_morph_target_count);
+ ObjectTypeDB::bind_method(_MD("get_morph_target_name", "index"), &Mesh::get_morph_target_name);
+ ObjectTypeDB::bind_method(_MD("clear_morph_targets"), &Mesh::clear_morph_targets);
+ ObjectTypeDB::bind_method(_MD("set_morph_target_mode", "mode"), &Mesh::set_morph_target_mode);
+ ObjectTypeDB::bind_method(_MD("get_morph_target_mode"), &Mesh::get_morph_target_mode);
+ ObjectTypeDB::bind_method(_MD("add_surface", "primitive", "arrays", "morph_arrays", "alphasort"), &Mesh::add_surface, DEFVAL(Array()), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_surface_count"), &Mesh::get_surface_count);
+ ObjectTypeDB::bind_method(_MD("surface_remove", "surf_idx"), &Mesh::surface_remove);
+ ObjectTypeDB::bind_method(_MD("surface_get_array_len", "surf_idx"), &Mesh::surface_get_array_len);
+ ObjectTypeDB::bind_method(_MD("surface_get_array_index_len", "surf_idx"), &Mesh::surface_get_array_index_len);
+ ObjectTypeDB::bind_method(_MD("surface_get_format", "surf_idx"), &Mesh::surface_get_format);
+ ObjectTypeDB::bind_method(_MD("surface_get_primitive_type", "surf_idx"), &Mesh::surface_get_primitive_type);
+ ObjectTypeDB::bind_method(_MD("surface_set_material", "surf_idx", "material:Material"), &Mesh::surface_set_material);
+ ObjectTypeDB::bind_method(_MD("surface_get_material:Material", "surf_idx"), &Mesh::surface_get_material);
+ ObjectTypeDB::bind_method(_MD("surface_set_name", "surf_idx", "name"), &Mesh::surface_set_name);
+ ObjectTypeDB::bind_method(_MD("surface_get_name", "surf_idx"), &Mesh::surface_get_name);
+ ObjectTypeDB::bind_method(_MD("center_geometry"), &Mesh::center_geometry);
+ ObjectTypeDB::set_method_flags(get_type_static(), _SCS("center_geometry"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ObjectTypeDB::bind_method(_MD("regen_normalmaps"), &Mesh::regen_normalmaps);
+ ObjectTypeDB::set_method_flags(get_type_static(), _SCS("regen_normalmaps"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
- BIND_CONSTANT( NO_INDEX_ARRAY );
- BIND_CONSTANT( ARRAY_WEIGHTS_SIZE );
+ ObjectTypeDB::bind_method(_MD("set_custom_aabb", "aabb"), &Mesh::set_custom_aabb);
+ ObjectTypeDB::bind_method(_MD("get_custom_aabb"), &Mesh::get_custom_aabb);
- BIND_CONSTANT( ARRAY_VERTEX );
- BIND_CONSTANT( ARRAY_NORMAL );
- BIND_CONSTANT( ARRAY_TANGENT );
- BIND_CONSTANT( ARRAY_COLOR );
- BIND_CONSTANT( ARRAY_TEX_UV );
- BIND_CONSTANT( ARRAY_TEX_UV2 );
- BIND_CONSTANT( ARRAY_BONES );
- BIND_CONSTANT( ARRAY_WEIGHTS );
- BIND_CONSTANT( ARRAY_INDEX );
+ BIND_CONSTANT(NO_INDEX_ARRAY);
+ BIND_CONSTANT(ARRAY_WEIGHTS_SIZE);
- BIND_CONSTANT( ARRAY_FORMAT_VERTEX );
- BIND_CONSTANT( ARRAY_FORMAT_NORMAL );
- BIND_CONSTANT( ARRAY_FORMAT_TANGENT );
- BIND_CONSTANT( ARRAY_FORMAT_COLOR );
- BIND_CONSTANT( ARRAY_FORMAT_TEX_UV );
- BIND_CONSTANT( ARRAY_FORMAT_TEX_UV2 );
- BIND_CONSTANT( ARRAY_FORMAT_BONES );
- BIND_CONSTANT( ARRAY_FORMAT_WEIGHTS );
- BIND_CONSTANT( ARRAY_FORMAT_INDEX );
+ BIND_CONSTANT(ARRAY_VERTEX);
+ BIND_CONSTANT(ARRAY_NORMAL);
+ BIND_CONSTANT(ARRAY_TANGENT);
+ BIND_CONSTANT(ARRAY_COLOR);
+ BIND_CONSTANT(ARRAY_TEX_UV);
+ BIND_CONSTANT(ARRAY_TEX_UV2);
+ BIND_CONSTANT(ARRAY_BONES);
+ BIND_CONSTANT(ARRAY_WEIGHTS);
+ BIND_CONSTANT(ARRAY_INDEX);
- BIND_CONSTANT( PRIMITIVE_POINTS );
- BIND_CONSTANT( PRIMITIVE_LINES );
- BIND_CONSTANT( PRIMITIVE_LINE_STRIP );
- BIND_CONSTANT( PRIMITIVE_LINE_LOOP );
- BIND_CONSTANT( PRIMITIVE_TRIANGLES );
- BIND_CONSTANT( PRIMITIVE_TRIANGLE_STRIP );
- BIND_CONSTANT( PRIMITIVE_TRIANGLE_FAN );
+ BIND_CONSTANT(ARRAY_FORMAT_VERTEX);
+ BIND_CONSTANT(ARRAY_FORMAT_NORMAL);
+ BIND_CONSTANT(ARRAY_FORMAT_TANGENT);
+ BIND_CONSTANT(ARRAY_FORMAT_COLOR);
+ BIND_CONSTANT(ARRAY_FORMAT_TEX_UV);
+ BIND_CONSTANT(ARRAY_FORMAT_TEX_UV2);
+ BIND_CONSTANT(ARRAY_FORMAT_BONES);
+ BIND_CONSTANT(ARRAY_FORMAT_WEIGHTS);
+ BIND_CONSTANT(ARRAY_FORMAT_INDEX);
+ BIND_CONSTANT(PRIMITIVE_POINTS);
+ BIND_CONSTANT(PRIMITIVE_LINES);
+ BIND_CONSTANT(PRIMITIVE_LINE_STRIP);
+ BIND_CONSTANT(PRIMITIVE_LINE_LOOP);
+ BIND_CONSTANT(PRIMITIVE_TRIANGLES);
+ BIND_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
+ BIND_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
}
-
-
Mesh::Mesh() {
- mesh=VisualServer::get_singleton()->mesh_create();
- morph_target_mode=MORPH_MODE_RELATIVE;
-
+ mesh = VisualServer::get_singleton()->mesh_create();
+ morph_target_mode = MORPH_MODE_RELATIVE;
}
-
Mesh::~Mesh() {
VisualServer::get_singleton()->free(mesh);
}
-
-
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index 61731b163..189b9a202 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -29,70 +29,69 @@
#ifndef MESH_H
#define MESH_H
-#include "servers/visual_server.h"
+#include "resource.h"
#include "scene/resources/material.h"
#include "scene/resources/shape.h"
-#include "resource.h"
+#include "servers/visual_server.h"
#include "triangle_mesh.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class Mesh : public Resource {
- OBJ_TYPE( Mesh, Resource );
+ OBJ_TYPE(Mesh, Resource);
RES_BASE_EXTENSION("msh");
public:
-
enum {
- NO_INDEX_ARRAY=VisualServer::NO_INDEX_ARRAY,
- ARRAY_WEIGHTS_SIZE=VisualServer::ARRAY_WEIGHTS_SIZE
+ NO_INDEX_ARRAY = VisualServer::NO_INDEX_ARRAY,
+ ARRAY_WEIGHTS_SIZE = VisualServer::ARRAY_WEIGHTS_SIZE
};
enum ArrayType {
- ARRAY_VERTEX=VisualServer::ARRAY_VERTEX,
- ARRAY_NORMAL=VisualServer::ARRAY_NORMAL,
- ARRAY_TANGENT=VisualServer::ARRAY_TANGENT,
- ARRAY_COLOR=VisualServer::ARRAY_COLOR,
- ARRAY_TEX_UV=VisualServer::ARRAY_TEX_UV,
- ARRAY_TEX_UV2=VisualServer::ARRAY_TEX_UV2,
- ARRAY_BONES=VisualServer::ARRAY_BONES,
- ARRAY_WEIGHTS=VisualServer::ARRAY_WEIGHTS,
- ARRAY_INDEX=VisualServer::ARRAY_INDEX,
- ARRAY_MAX=VisualServer::ARRAY_MAX
+ ARRAY_VERTEX = VisualServer::ARRAY_VERTEX,
+ ARRAY_NORMAL = VisualServer::ARRAY_NORMAL,
+ ARRAY_TANGENT = VisualServer::ARRAY_TANGENT,
+ ARRAY_COLOR = VisualServer::ARRAY_COLOR,
+ ARRAY_TEX_UV = VisualServer::ARRAY_TEX_UV,
+ ARRAY_TEX_UV2 = VisualServer::ARRAY_TEX_UV2,
+ ARRAY_BONES = VisualServer::ARRAY_BONES,
+ ARRAY_WEIGHTS = VisualServer::ARRAY_WEIGHTS,
+ ARRAY_INDEX = VisualServer::ARRAY_INDEX,
+ ARRAY_MAX = VisualServer::ARRAY_MAX
};
enum ArrayFormat {
/* ARRAY FORMAT FLAGS */
- ARRAY_FORMAT_VERTEX=1<<ARRAY_VERTEX, // mandatory
- ARRAY_FORMAT_NORMAL=1<<ARRAY_NORMAL,
- ARRAY_FORMAT_TANGENT=1<<ARRAY_TANGENT,
- ARRAY_FORMAT_COLOR=1<<ARRAY_COLOR,
- ARRAY_FORMAT_TEX_UV=1<<ARRAY_TEX_UV,
- ARRAY_FORMAT_TEX_UV2=1<<ARRAY_TEX_UV2,
- ARRAY_FORMAT_BONES=1<<ARRAY_BONES,
- ARRAY_FORMAT_WEIGHTS=1<<ARRAY_WEIGHTS,
- ARRAY_FORMAT_INDEX=1<<ARRAY_INDEX,
+ ARRAY_FORMAT_VERTEX = 1 << ARRAY_VERTEX, // mandatory
+ ARRAY_FORMAT_NORMAL = 1 << ARRAY_NORMAL,
+ ARRAY_FORMAT_TANGENT = 1 << ARRAY_TANGENT,
+ ARRAY_FORMAT_COLOR = 1 << ARRAY_COLOR,
+ ARRAY_FORMAT_TEX_UV = 1 << ARRAY_TEX_UV,
+ ARRAY_FORMAT_TEX_UV2 = 1 << ARRAY_TEX_UV2,
+ ARRAY_FORMAT_BONES = 1 << ARRAY_BONES,
+ ARRAY_FORMAT_WEIGHTS = 1 << ARRAY_WEIGHTS,
+ ARRAY_FORMAT_INDEX = 1 << ARRAY_INDEX,
};
enum PrimitiveType {
- PRIMITIVE_POINTS=VisualServer::PRIMITIVE_POINTS,
- PRIMITIVE_LINES=VisualServer::PRIMITIVE_LINES,
- PRIMITIVE_LINE_STRIP=VisualServer::PRIMITIVE_LINE_STRIP,
- PRIMITIVE_LINE_LOOP=VisualServer::PRIMITIVE_LINE_LOOP,
- PRIMITIVE_TRIANGLES=VisualServer::PRIMITIVE_TRIANGLES,
- PRIMITIVE_TRIANGLE_STRIP=VisualServer::PRIMITIVE_TRIANGLE_STRIP,
- PRIMITIVE_TRIANGLE_FAN=VisualServer::PRIMITIVE_TRIANGLE_FAN,
+ PRIMITIVE_POINTS = VisualServer::PRIMITIVE_POINTS,
+ PRIMITIVE_LINES = VisualServer::PRIMITIVE_LINES,
+ PRIMITIVE_LINE_STRIP = VisualServer::PRIMITIVE_LINE_STRIP,
+ PRIMITIVE_LINE_LOOP = VisualServer::PRIMITIVE_LINE_LOOP,
+ PRIMITIVE_TRIANGLES = VisualServer::PRIMITIVE_TRIANGLES,
+ PRIMITIVE_TRIANGLE_STRIP = VisualServer::PRIMITIVE_TRIANGLE_STRIP,
+ PRIMITIVE_TRIANGLE_FAN = VisualServer::PRIMITIVE_TRIANGLE_FAN,
};
enum MorphTargetMode {
- MORPH_MODE_NORMALIZED=VS::MORPH_MODE_NORMALIZED,
- MORPH_MODE_RELATIVE=VS::MORPH_MODE_RELATIVE,
+ MORPH_MODE_NORMALIZED = VS::MORPH_MODE_NORMALIZED,
+ MORPH_MODE_RELATIVE = VS::MORPH_MODE_RELATIVE,
};
private:
@@ -111,25 +110,23 @@ private:
mutable Ref<TriangleMesh> triangle_mesh;
-
void _recompute_aabb();
-protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
- void add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),bool p_alphasort=false);
+ void add_surface(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), bool p_alphasort = false);
Array surface_get_arrays(int p_surface) const;
virtual Array surface_get_morph_arrays(int p_surface) const;
- void add_custom_surface(const Variant& p_data); //only recognized by driver
+ void add_custom_surface(const Variant &p_data); //only recognized by driver
- void add_morph_target(const StringName& p_name);
+ void add_morph_target(const StringName &p_name);
int get_morph_target_count() const;
StringName get_morph_target_name(int p_index) const;
void clear_morph_targets();
@@ -140,8 +137,7 @@ public:
int get_surface_count() const;
void surface_remove(int p_idx);
- void surface_set_custom_aabb(int p_surface,const AABB& p_aabb); //only recognized by driver
-
+ void surface_set_custom_aabb(int p_surface, const AABB &p_aabb); //only recognized by driver
int surface_get_array_len(int p_idx) const;
int surface_get_array_index_len(int p_idx) const;
@@ -149,15 +145,15 @@ public:
PrimitiveType surface_get_primitive_type(int p_idx) const;
bool surface_is_alpha_sorting_enabled(int p_idx) const;
- void surface_set_material(int p_idx, const Ref<Material>& p_material);
+ void surface_set_material(int p_idx, const Ref<Material> &p_material);
Ref<Material> surface_get_material(int p_idx) const;
- void surface_set_name(int p_idx, const String& p_name);
+ void surface_set_name(int p_idx, const String &p_name);
String surface_get_name(int p_idx) const;
- void add_surface_from_mesh_data(const Geometry::MeshData& p_mesh_data);
+ void add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data);
- void set_custom_aabb(const AABB& p_custom);
+ void set_custom_aabb(const AABB &p_custom);
AABB get_custom_aabb() const;
AABB get_aabb() const;
@@ -176,11 +172,10 @@ public:
Mesh();
~Mesh();
-
};
-VARIANT_ENUM_CAST( Mesh::ArrayType );
-VARIANT_ENUM_CAST( Mesh::PrimitiveType );
-VARIANT_ENUM_CAST( Mesh::MorphTargetMode );
+VARIANT_ENUM_CAST(Mesh::ArrayType);
+VARIANT_ENUM_CAST(Mesh::PrimitiveType);
+VARIANT_ENUM_CAST(Mesh::MorphTargetMode);
#endif
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index df36390c0..6fb589820 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -28,152 +28,142 @@
/*************************************************************************/
#include "mesh_data_tool.h"
-
void MeshDataTool::clear() {
vertices.clear();
edges.clear();
faces.clear();
material = Ref<Material>();
- format=0;
+ format = 0;
}
+Error MeshDataTool::create_from_surface(const Ref<Mesh> &p_mesh, int p_surface) {
-Error MeshDataTool::create_from_surface(const Ref<Mesh>& p_mesh,int p_surface) {
-
- ERR_FAIL_COND_V(p_mesh.is_null(),ERR_INVALID_PARAMETER);
-
- ERR_FAIL_COND_V(p_mesh.is_null(),ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_mesh->surface_get_primitive_type(p_surface)!=Mesh::PRIMITIVE_TRIANGLES,ERR_INVALID_PARAMETER);
-
+ ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_mesh->surface_get_primitive_type(p_surface) != Mesh::PRIMITIVE_TRIANGLES, ERR_INVALID_PARAMETER);
Array arrays = p_mesh->surface_get_arrays(p_surface);
- ERR_FAIL_COND_V( arrays.empty(), ERR_INVALID_PARAMETER );
+ ERR_FAIL_COND_V(arrays.empty(), ERR_INVALID_PARAMETER);
DVector<Vector3> varray = arrays[Mesh::ARRAY_VERTEX];
int vcount = varray.size();
- ERR_FAIL_COND_V( vcount == 0, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(vcount == 0, ERR_INVALID_PARAMETER);
clear();
format = p_mesh->surface_get_format(p_surface);
- material=p_mesh->surface_get_material(p_surface);
+ material = p_mesh->surface_get_material(p_surface);
DVector<Vector3>::Read vr = varray.read();
DVector<Vector3>::Read nr;
- if (arrays[Mesh::ARRAY_NORMAL].get_type()!=Variant::NIL)
+ if (arrays[Mesh::ARRAY_NORMAL].get_type() != Variant::NIL)
nr = arrays[Mesh::ARRAY_NORMAL].operator DVector<Vector3>().read();
DVector<real_t>::Read ta;
- if (arrays[Mesh::ARRAY_TANGENT].get_type()!=Variant::NIL)
+ if (arrays[Mesh::ARRAY_TANGENT].get_type() != Variant::NIL)
ta = arrays[Mesh::ARRAY_TANGENT].operator DVector<real_t>().read();
DVector<Vector2>::Read uv;
- if (arrays[Mesh::ARRAY_TEX_UV].get_type()!=Variant::NIL)
+ if (arrays[Mesh::ARRAY_TEX_UV].get_type() != Variant::NIL)
uv = arrays[Mesh::ARRAY_TEX_UV].operator DVector<Vector2>().read();
DVector<Vector2>::Read uv2;
- if (arrays[Mesh::ARRAY_TEX_UV2].get_type()!=Variant::NIL)
+ if (arrays[Mesh::ARRAY_TEX_UV2].get_type() != Variant::NIL)
uv2 = arrays[Mesh::ARRAY_TEX_UV2].operator DVector<Vector2>().read();
DVector<Color>::Read col;
- if (arrays[Mesh::ARRAY_COLOR].get_type()!=Variant::NIL)
+ if (arrays[Mesh::ARRAY_COLOR].get_type() != Variant::NIL)
col = arrays[Mesh::ARRAY_COLOR].operator DVector<Color>().read();
DVector<real_t>::Read bo;
- if (arrays[Mesh::ARRAY_BONES].get_type()!=Variant::NIL)
+ if (arrays[Mesh::ARRAY_BONES].get_type() != Variant::NIL)
bo = arrays[Mesh::ARRAY_BONES].operator DVector<real_t>().read();
DVector<real_t>::Read we;
- if (arrays[Mesh::ARRAY_WEIGHTS].get_type()!=Variant::NIL)
+ if (arrays[Mesh::ARRAY_WEIGHTS].get_type() != Variant::NIL)
we = arrays[Mesh::ARRAY_WEIGHTS].operator DVector<real_t>().read();
-
vertices.resize(vcount);
- for(int i=0;i<vcount;i++) {
+ for (int i = 0; i < vcount; i++) {
Vertex v;
- v.vertex=vr[i];
+ v.vertex = vr[i];
if (nr.ptr())
- v.normal=nr[i];
+ v.normal = nr[i];
if (ta.ptr())
- v.tangent=Plane(ta[i*4+0],ta[i*4+1],ta[i*4+2],ta[i*4+3]);
+ v.tangent = Plane(ta[i * 4 + 0], ta[i * 4 + 1], ta[i * 4 + 2], ta[i * 4 + 3]);
if (uv.ptr())
- v.uv=uv[i];
+ v.uv = uv[i];
if (uv2.ptr())
- v.uv2=uv2[i];
+ v.uv2 = uv2[i];
if (col.ptr())
- v.color=col[i];
+ v.color = col[i];
if (we.ptr()) {
- v.weights.push_back(we[i*4+0]);
- v.weights.push_back(we[i*4+1]);
- v.weights.push_back(we[i*4+2]);
- v.weights.push_back(we[i*4+3]);
+ v.weights.push_back(we[i * 4 + 0]);
+ v.weights.push_back(we[i * 4 + 1]);
+ v.weights.push_back(we[i * 4 + 2]);
+ v.weights.push_back(we[i * 4 + 3]);
}
if (bo.ptr()) {
- v.bones.push_back(bo[i*4+0]);
- v.bones.push_back(bo[i*4+1]);
- v.bones.push_back(bo[i*4+2]);
- v.bones.push_back(bo[i*4+3]);
+ v.bones.push_back(bo[i * 4 + 0]);
+ v.bones.push_back(bo[i * 4 + 1]);
+ v.bones.push_back(bo[i * 4 + 2]);
+ v.bones.push_back(bo[i * 4 + 3]);
}
- vertices[i]=v;
-
-
+ vertices[i] = v;
}
-
DVector<int> indices;
- if (arrays[Mesh::ARRAY_INDEX].get_type()!=Variant::NIL) {
+ if (arrays[Mesh::ARRAY_INDEX].get_type() != Variant::NIL) {
indices = arrays[Mesh::ARRAY_INDEX];
} else {
//make code simpler
indices.resize(vcount);
- DVector<int>::Write iw=indices.write();
- for(int i=0;i<vcount;i++)
- iw[i]=i;
+ DVector<int>::Write iw = indices.write();
+ for (int i = 0; i < vcount; i++)
+ iw[i] = i;
}
-
- int icount=indices.size();
+ int icount = indices.size();
DVector<int>::Read r = indices.read();
+ Map<Point2i, int> edge_indices;
- Map<Point2i,int> edge_indices;
+ for (int i = 0; i < icount; i += 3) {
- for(int i=0;i<icount;i+=3) {
+ Vertex *v[3] = { &vertices[r[i + 0]], &vertices[r[i + 1]], &vertices[r[i + 2]] };
- Vertex*v[3]={ &vertices[r[i+0]], &vertices[r[i+1]], &vertices[r[i+2]] };
-
- int fidx=faces.size();
+ int fidx = faces.size();
Face face;
- for(int j=0;j<3;j++) {
+ for (int j = 0; j < 3; j++) {
- face.v[j]=r[i+j];
+ face.v[j] = r[i + j];
- Point2i edge(r[i+j],r[i+(j+1)%3]);
+ Point2i edge(r[i + j], r[i + (j + 1) % 3]);
if (edge.x > edge.y) {
- SWAP(edge.x,edge.y);
+ SWAP(edge.x, edge.y);
}
if (edge_indices.has(edge)) {
- face.edges[j]=edge_indices[edge];
+ face.edges[j] = edge_indices[edge];
} else {
- face.edges[j]=edge_indices.size();
- edge_indices[edge]=face.edges[j];
+ face.edges[j] = edge_indices.size();
+ edge_indices[edge] = face.edges[j];
Edge e;
- e.vertex[0]=edge.x;
- e.vertex[1]=edge.y;
+ e.vertex[0] = edge.x;
+ e.vertex[1] = edge.y;
edges.push_back(e);
}
@@ -182,22 +172,19 @@ Error MeshDataTool::create_from_surface(const Ref<Mesh>& p_mesh,int p_surface) {
v[j]->edges.push_back(face.edges[j]);
}
-
faces.push_back(face);
}
-
return OK;
}
-Error MeshDataTool::commit_to_surface(const Ref<Mesh>& p_mesh) {
+Error MeshDataTool::commit_to_surface(const Ref<Mesh> &p_mesh) {
- ERR_FAIL_COND_V(p_mesh.is_null(),ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_mesh.is_null(), ERR_INVALID_PARAMETER);
Array arr;
arr.resize(Mesh::ARRAY_MAX);
-
- int vcount=vertices.size();
+ int vcount = vertices.size();
DVector<Vector3> v;
DVector<Vector3> n;
@@ -212,124 +199,119 @@ Error MeshDataTool::commit_to_surface(const Ref<Mesh>& p_mesh) {
{
v.resize(vcount);
- DVector<Vector3>::Write vr=v.write();
+ DVector<Vector3>::Write vr = v.write();
DVector<Vector3>::Write nr;
- if (format&Mesh::ARRAY_FORMAT_NORMAL) {
+ if (format & Mesh::ARRAY_FORMAT_NORMAL) {
n.resize(vcount);
nr = n.write();
}
DVector<real_t>::Write ta;
- if (format&Mesh::ARRAY_FORMAT_TANGENT) {
- t.resize(vcount*4);
+ if (format & Mesh::ARRAY_FORMAT_TANGENT) {
+ t.resize(vcount * 4);
ta = t.write();
}
-
DVector<Vector2>::Write uv;
- if (format&Mesh::ARRAY_FORMAT_TEX_UV) {
+ if (format & Mesh::ARRAY_FORMAT_TEX_UV) {
u.resize(vcount);
uv = u.write();
}
DVector<Vector2>::Write uv2;
- if (format&Mesh::ARRAY_FORMAT_TEX_UV2) {
+ if (format & Mesh::ARRAY_FORMAT_TEX_UV2) {
u2.resize(vcount);
uv2 = u2.write();
}
DVector<Color>::Write col;
- if (format&Mesh::ARRAY_FORMAT_COLOR) {
+ if (format & Mesh::ARRAY_FORMAT_COLOR) {
c.resize(vcount);
col = c.write();
}
DVector<real_t>::Write bo;
- if (format&Mesh::ARRAY_FORMAT_BONES) {
- b.resize(vcount*4);
+ if (format & Mesh::ARRAY_FORMAT_BONES) {
+ b.resize(vcount * 4);
bo = b.write();
}
DVector<real_t>::Write we;
- if (format&Mesh::ARRAY_FORMAT_WEIGHTS) {
- w.resize(vcount*4);
+ if (format & Mesh::ARRAY_FORMAT_WEIGHTS) {
+ w.resize(vcount * 4);
we = w.write();
}
+ for (int i = 0; i < vcount; i++) {
- for(int i=0;i<vcount;i++) {
-
- Vertex &vtx=vertices[i];
+ Vertex &vtx = vertices[i];
- vr[i]=vtx.vertex;
+ vr[i] = vtx.vertex;
if (nr.ptr())
- nr[i]=vtx.normal;
+ nr[i] = vtx.normal;
if (ta.ptr()) {
- ta[i*4+0]=vtx.tangent.normal.x;
- ta[i*4+1]=vtx.tangent.normal.y;
- ta[i*4+2]=vtx.tangent.normal.z;
- ta[i*4+3]=vtx.tangent.d;
+ ta[i * 4 + 0] = vtx.tangent.normal.x;
+ ta[i * 4 + 1] = vtx.tangent.normal.y;
+ ta[i * 4 + 2] = vtx.tangent.normal.z;
+ ta[i * 4 + 3] = vtx.tangent.d;
}
if (uv.ptr())
- uv[i]=vtx.uv;
+ uv[i] = vtx.uv;
if (uv2.ptr())
- uv2[i]=vtx.uv2;
+ uv2[i] = vtx.uv2;
if (col.ptr())
- col[i]=vtx.color;
+ col[i] = vtx.color;
if (we.ptr()) {
- we[i*4+0]=vtx.weights[0];
- we[i*4+1]=vtx.weights[1];
- we[i*4+2]=vtx.weights[2];
- we[i*4+3]=vtx.weights[3];
-
+ we[i * 4 + 0] = vtx.weights[0];
+ we[i * 4 + 1] = vtx.weights[1];
+ we[i * 4 + 2] = vtx.weights[2];
+ we[i * 4 + 3] = vtx.weights[3];
}
if (bo.ptr()) {
- bo[i*4+0]=vtx.bones[0];
- bo[i*4+1]=vtx.bones[1];
- bo[i*4+2]=vtx.bones[2];
- bo[i*4+3]=vtx.bones[3];
+ bo[i * 4 + 0] = vtx.bones[0];
+ bo[i * 4 + 1] = vtx.bones[1];
+ bo[i * 4 + 2] = vtx.bones[2];
+ bo[i * 4 + 3] = vtx.bones[3];
}
-
}
int fc = faces.size();
- in.resize(fc*3);
- DVector<int>::Write iw=in.write();
- for(int i=0;i<fc;i++) {
+ in.resize(fc * 3);
+ DVector<int>::Write iw = in.write();
+ for (int i = 0; i < fc; i++) {
- iw[i*3+0]=faces[i].v[0];
- iw[i*3+1]=faces[i].v[1];
- iw[i*3+2]=faces[i].v[2];
+ iw[i * 3 + 0] = faces[i].v[0];
+ iw[i * 3 + 1] = faces[i].v[1];
+ iw[i * 3 + 2] = faces[i].v[2];
}
-
}
- arr[Mesh::ARRAY_VERTEX]=v;
- arr[Mesh::ARRAY_INDEX]=in;
+ arr[Mesh::ARRAY_VERTEX] = v;
+ arr[Mesh::ARRAY_INDEX] = in;
if (n.size())
- arr[Mesh::ARRAY_NORMAL]=n;
+ arr[Mesh::ARRAY_NORMAL] = n;
if (c.size())
- arr[Mesh::ARRAY_COLOR]=c;
+ arr[Mesh::ARRAY_COLOR] = c;
if (u.size())
- arr[Mesh::ARRAY_TEX_UV]=u;
+ arr[Mesh::ARRAY_TEX_UV] = u;
if (u2.size())
- arr[Mesh::ARRAY_TEX_UV2]=u2;
+ arr[Mesh::ARRAY_TEX_UV2] = u2;
if (t.size())
- arr[Mesh::ARRAY_TANGENT]=t;
+ arr[Mesh::ARRAY_TANGENT] = t;
if (b.size())
- arr[Mesh::ARRAY_BONES]=b;
+ arr[Mesh::ARRAY_BONES] = b;
if (w.size())
- arr[Mesh::ARRAY_WEIGHTS]=w;
+ arr[Mesh::ARRAY_WEIGHTS] = w;
- Ref<Mesh> ncmesh=p_mesh;
+ Ref<Mesh> ncmesh = p_mesh;
int sc = ncmesh->get_surface_count();
- ncmesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr);
- ncmesh->surface_set_material(sc,material);
+ ncmesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, arr);
+ ncmesh->surface_set_material(sc, material);
return OK;
}
@@ -343,213 +325,185 @@ int MeshDataTool::get_vertex_count() const {
return vertices.size();
}
-int MeshDataTool::get_edge_count() const{
+int MeshDataTool::get_edge_count() const {
return edges.size();
}
-int MeshDataTool::get_face_count() const{
+int MeshDataTool::get_face_count() const {
return faces.size();
}
Vector3 MeshDataTool::get_vertex(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Vector3());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3());
return vertices[p_idx].vertex;
}
-void MeshDataTool::set_vertex(int p_idx,const Vector3& p_vertex){
-
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].vertex=p_vertex;
+void MeshDataTool::set_vertex(int p_idx, const Vector3 &p_vertex) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].vertex = p_vertex;
}
-Vector3 MeshDataTool::get_vertex_normal(int p_idx) const{
+Vector3 MeshDataTool::get_vertex_normal(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Vector3());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector3());
return vertices[p_idx].normal;
-
}
-void MeshDataTool::set_vertex_normal(int p_idx,const Vector3& p_normal){
-
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].normal=p_normal;
- format|=Mesh::ARRAY_FORMAT_NORMAL;
+void MeshDataTool::set_vertex_normal(int p_idx, const Vector3 &p_normal) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].normal = p_normal;
+ format |= Mesh::ARRAY_FORMAT_NORMAL;
}
-Plane MeshDataTool::get_vertex_tangent(int p_idx) const{
+Plane MeshDataTool::get_vertex_tangent(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Plane());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Plane());
return vertices[p_idx].tangent;
-
}
-void MeshDataTool::set_vertex_tangent(int p_idx,const Plane& p_tangent){
-
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].tangent=p_tangent;
- format|=Mesh::ARRAY_FORMAT_TANGENT;
+void MeshDataTool::set_vertex_tangent(int p_idx, const Plane &p_tangent) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].tangent = p_tangent;
+ format |= Mesh::ARRAY_FORMAT_TANGENT;
}
-Vector2 MeshDataTool::get_vertex_uv(int p_idx) const{
+Vector2 MeshDataTool::get_vertex_uv(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Vector2());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2());
return vertices[p_idx].uv;
-
}
-void MeshDataTool::set_vertex_uv(int p_idx,const Vector2& p_uv){
-
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].uv=p_uv;
- format|=Mesh::ARRAY_FORMAT_TEX_UV;
+void MeshDataTool::set_vertex_uv(int p_idx, const Vector2 &p_uv) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].uv = p_uv;
+ format |= Mesh::ARRAY_FORMAT_TEX_UV;
}
-Vector2 MeshDataTool::get_vertex_uv2(int p_idx) const{
+Vector2 MeshDataTool::get_vertex_uv2(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Vector2());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector2());
return vertices[p_idx].uv2;
-
}
-void MeshDataTool::set_vertex_uv2(int p_idx,const Vector2& p_uv2){
-
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].uv2=p_uv2;
- format|=Mesh::ARRAY_FORMAT_TEX_UV2;
+void MeshDataTool::set_vertex_uv2(int p_idx, const Vector2 &p_uv2) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].uv2 = p_uv2;
+ format |= Mesh::ARRAY_FORMAT_TEX_UV2;
}
-Color MeshDataTool::get_vertex_color(int p_idx) const{
+Color MeshDataTool::get_vertex_color(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Color());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Color());
return vertices[p_idx].color;
-
-
}
-void MeshDataTool::set_vertex_color(int p_idx,const Color& p_color){
-
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].color=p_color;
- format|=Mesh::ARRAY_FORMAT_COLOR;
+void MeshDataTool::set_vertex_color(int p_idx, const Color &p_color) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].color = p_color;
+ format |= Mesh::ARRAY_FORMAT_COLOR;
}
-Vector<int> MeshDataTool::get_vertex_bones(int p_idx) const{
+Vector<int> MeshDataTool::get_vertex_bones(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Vector<int>());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
return vertices[p_idx].bones;
-
}
-void MeshDataTool::set_vertex_bones(int p_idx,const Vector<int>& p_bones){
-
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].bones=p_bones;
- format|=Mesh::ARRAY_FORMAT_BONES;
+void MeshDataTool::set_vertex_bones(int p_idx, const Vector<int> &p_bones) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].bones = p_bones;
+ format |= Mesh::ARRAY_FORMAT_BONES;
}
-Vector<float> MeshDataTool::get_vertex_weights(int p_idx) const{
+Vector<float> MeshDataTool::get_vertex_weights(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Vector<float>());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<float>());
return vertices[p_idx].weights;
-
}
-void MeshDataTool::set_vertex_weights(int p_idx,const Vector<float>& p_weights){
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].weights=p_weights;
- format|=Mesh::ARRAY_FORMAT_WEIGHTS;
-
-
+void MeshDataTool::set_vertex_weights(int p_idx, const Vector<float> &p_weights) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].weights = p_weights;
+ format |= Mesh::ARRAY_FORMAT_WEIGHTS;
}
-Variant MeshDataTool::get_vertex_meta(int p_idx) const{
+Variant MeshDataTool::get_vertex_meta(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Variant());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Variant());
return vertices[p_idx].meta;
-
}
-void MeshDataTool::set_vertex_meta(int p_idx,const Variant& p_meta){
-
- ERR_FAIL_INDEX(p_idx,vertices.size());
- vertices[p_idx].meta=p_meta;
+void MeshDataTool::set_vertex_meta(int p_idx, const Variant &p_meta) {
+ ERR_FAIL_INDEX(p_idx, vertices.size());
+ vertices[p_idx].meta = p_meta;
}
Vector<int> MeshDataTool::get_vertex_edges(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Vector<int>());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
return vertices[p_idx].edges;
-
}
-Vector<int> MeshDataTool::get_vertex_faces(int p_idx) const{
+Vector<int> MeshDataTool::get_vertex_faces(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,vertices.size(),Vector<int>());
+ ERR_FAIL_INDEX_V(p_idx, vertices.size(), Vector<int>());
return vertices[p_idx].faces;
-
}
-int MeshDataTool::get_edge_vertex(int p_edge,int p_vertex) const {
+int MeshDataTool::get_edge_vertex(int p_edge, int p_vertex) const {
- ERR_FAIL_INDEX_V(p_edge,edges.size(),-1);
- ERR_FAIL_INDEX_V(p_vertex,2,-1);
+ ERR_FAIL_INDEX_V(p_edge, edges.size(), -1);
+ ERR_FAIL_INDEX_V(p_vertex, 2, -1);
return edges[p_edge].vertex[p_vertex];
-
}
-Vector<int> MeshDataTool::get_edge_faces(int p_edge) const{
+Vector<int> MeshDataTool::get_edge_faces(int p_edge) const {
- ERR_FAIL_INDEX_V(p_edge,edges.size(),Vector<int>());
+ ERR_FAIL_INDEX_V(p_edge, edges.size(), Vector<int>());
return edges[p_edge].faces;
-
}
-Variant MeshDataTool::get_edge_meta(int p_idx) const{
+Variant MeshDataTool::get_edge_meta(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,edges.size(),Variant());
+ ERR_FAIL_INDEX_V(p_idx, edges.size(), Variant());
return edges[p_idx].meta;
-
}
-void MeshDataTool::set_edge_meta(int p_idx,const Variant& p_meta){
+void MeshDataTool::set_edge_meta(int p_idx, const Variant &p_meta) {
- ERR_FAIL_INDEX(p_idx,edges.size());
- edges[p_idx].meta=p_meta;
+ ERR_FAIL_INDEX(p_idx, edges.size());
+ edges[p_idx].meta = p_meta;
}
-int MeshDataTool::get_face_vertex(int p_face,int p_vertex) const {
+int MeshDataTool::get_face_vertex(int p_face, int p_vertex) const {
- ERR_FAIL_INDEX_V(p_face,faces.size(),-1);
- ERR_FAIL_INDEX_V(p_vertex,3,-1);
+ ERR_FAIL_INDEX_V(p_face, faces.size(), -1);
+ ERR_FAIL_INDEX_V(p_vertex, 3, -1);
return faces[p_face].v[p_vertex];
-
}
-int MeshDataTool::get_face_edge(int p_face,int p_vertex) const{
+int MeshDataTool::get_face_edge(int p_face, int p_vertex) const {
- ERR_FAIL_INDEX_V(p_face,faces.size(),-1);
- ERR_FAIL_INDEX_V(p_vertex,3,-1);
+ ERR_FAIL_INDEX_V(p_face, faces.size(), -1);
+ ERR_FAIL_INDEX_V(p_vertex, 3, -1);
return faces[p_face].edges[p_vertex];
-
}
-Variant MeshDataTool::get_face_meta(int p_face) const{
+Variant MeshDataTool::get_face_meta(int p_face) const {
- ERR_FAIL_INDEX_V(p_face,faces.size(),Variant());
+ ERR_FAIL_INDEX_V(p_face, faces.size(), Variant());
return faces[p_face].meta;
-
}
-void MeshDataTool::set_face_meta(int p_face,const Variant& p_meta){
+void MeshDataTool::set_face_meta(int p_face, const Variant &p_meta) {
- ERR_FAIL_INDEX(p_face,faces.size());
- faces[p_face].meta=p_meta;
+ ERR_FAIL_INDEX(p_face, faces.size());
+ faces[p_face].meta = p_meta;
}
Vector3 MeshDataTool::get_face_normal(int p_face) const {
- ERR_FAIL_INDEX_V(p_face,faces.size(),Vector3());
+ ERR_FAIL_INDEX_V(p_face, faces.size(), Vector3());
Vector3 v0 = vertices[faces[p_face].v[0]].vertex;
Vector3 v1 = vertices[faces[p_face].v[1]].vertex;
Vector3 v2 = vertices[faces[p_face].v[2]].vertex;
- return Plane(v0,v1,v2).normal;
-
+ return Plane(v0, v1, v2).normal;
}
Ref<Material> MeshDataTool::get_material() const {
@@ -559,71 +513,70 @@ Ref<Material> MeshDataTool::get_material() const {
void MeshDataTool::set_material(const Ref<Material> &p_material) {
- material=p_material;
+ material = p_material;
}
-
void MeshDataTool::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("clear"),&MeshDataTool::clear);
- ObjectTypeDB::bind_method(_MD("create_from_surface","mesh","surface"),&MeshDataTool::create_from_surface);
- ObjectTypeDB::bind_method(_MD("commit_to_surface","mesh"),&MeshDataTool::commit_to_surface);
+ ObjectTypeDB::bind_method(_MD("clear"), &MeshDataTool::clear);
+ ObjectTypeDB::bind_method(_MD("create_from_surface", "mesh", "surface"), &MeshDataTool::create_from_surface);
+ ObjectTypeDB::bind_method(_MD("commit_to_surface", "mesh"), &MeshDataTool::commit_to_surface);
- ObjectTypeDB::bind_method(_MD("get_format"),&MeshDataTool::get_format);
+ ObjectTypeDB::bind_method(_MD("get_format"), &MeshDataTool::get_format);
- ObjectTypeDB::bind_method(_MD("get_vertex_count"),&MeshDataTool::get_vertex_count);
- ObjectTypeDB::bind_method(_MD("get_edge_count"),&MeshDataTool::get_edge_count);
- ObjectTypeDB::bind_method(_MD("get_face_count"),&MeshDataTool::get_face_count);
+ ObjectTypeDB::bind_method(_MD("get_vertex_count"), &MeshDataTool::get_vertex_count);
+ ObjectTypeDB::bind_method(_MD("get_edge_count"), &MeshDataTool::get_edge_count);
+ ObjectTypeDB::bind_method(_MD("get_face_count"), &MeshDataTool::get_face_count);
- ObjectTypeDB::bind_method(_MD("set_vertex","idx","vertex"),&MeshDataTool::set_vertex);
- ObjectTypeDB::bind_method(_MD("get_vertex","idx"),&MeshDataTool::get_vertex);
+ ObjectTypeDB::bind_method(_MD("set_vertex", "idx", "vertex"), &MeshDataTool::set_vertex);
+ ObjectTypeDB::bind_method(_MD("get_vertex", "idx"), &MeshDataTool::get_vertex);
- ObjectTypeDB::bind_method(_MD("set_vertex_normal","idx","normal"),&MeshDataTool::set_vertex_normal);
- ObjectTypeDB::bind_method(_MD("get_vertex_normal","idx"),&MeshDataTool::get_vertex_normal);
+ ObjectTypeDB::bind_method(_MD("set_vertex_normal", "idx", "normal"), &MeshDataTool::set_vertex_normal);
+ ObjectTypeDB::bind_method(_MD("get_vertex_normal", "idx"), &MeshDataTool::get_vertex_normal);
- ObjectTypeDB::bind_method(_MD("set_vertex_tangent","idx","tangent"),&MeshDataTool::set_vertex_tangent);
- ObjectTypeDB::bind_method(_MD("get_vertex_tangent","idx"),&MeshDataTool::get_vertex_tangent);
+ ObjectTypeDB::bind_method(_MD("set_vertex_tangent", "idx", "tangent"), &MeshDataTool::set_vertex_tangent);
+ ObjectTypeDB::bind_method(_MD("get_vertex_tangent", "idx"), &MeshDataTool::get_vertex_tangent);
- ObjectTypeDB::bind_method(_MD("set_vertex_uv","idx","uv"),&MeshDataTool::set_vertex_uv);
- ObjectTypeDB::bind_method(_MD("get_vertex_uv","idx"),&MeshDataTool::get_vertex_uv);
+ ObjectTypeDB::bind_method(_MD("set_vertex_uv", "idx", "uv"), &MeshDataTool::set_vertex_uv);
+ ObjectTypeDB::bind_method(_MD("get_vertex_uv", "idx"), &MeshDataTool::get_vertex_uv);
- ObjectTypeDB::bind_method(_MD("set_vertex_uv2","idx","uv2"),&MeshDataTool::set_vertex_uv2);
- ObjectTypeDB::bind_method(_MD("get_vertex_uv2","idx"),&MeshDataTool::get_vertex_uv2);
+ ObjectTypeDB::bind_method(_MD("set_vertex_uv2", "idx", "uv2"), &MeshDataTool::set_vertex_uv2);
+ ObjectTypeDB::bind_method(_MD("get_vertex_uv2", "idx"), &MeshDataTool::get_vertex_uv2);
- ObjectTypeDB::bind_method(_MD("set_vertex_color","idx","color"),&MeshDataTool::set_vertex_color);
- ObjectTypeDB::bind_method(_MD("get_vertex_color","idx"),&MeshDataTool::get_vertex_color);
+ ObjectTypeDB::bind_method(_MD("set_vertex_color", "idx", "color"), &MeshDataTool::set_vertex_color);
+ ObjectTypeDB::bind_method(_MD("get_vertex_color", "idx"), &MeshDataTool::get_vertex_color);
- ObjectTypeDB::bind_method(_MD("set_vertex_bones","idx","bones"),&MeshDataTool::set_vertex_bones);
- ObjectTypeDB::bind_method(_MD("get_vertex_bones","idx"),&MeshDataTool::get_vertex_bones);
+ ObjectTypeDB::bind_method(_MD("set_vertex_bones", "idx", "bones"), &MeshDataTool::set_vertex_bones);
+ ObjectTypeDB::bind_method(_MD("get_vertex_bones", "idx"), &MeshDataTool::get_vertex_bones);
- ObjectTypeDB::bind_method(_MD("set_vertex_weights","idx","weights"),&MeshDataTool::set_vertex_weights);
- ObjectTypeDB::bind_method(_MD("get_vertex_weights","idx"),&MeshDataTool::get_vertex_weights);
+ ObjectTypeDB::bind_method(_MD("set_vertex_weights", "idx", "weights"), &MeshDataTool::set_vertex_weights);
+ ObjectTypeDB::bind_method(_MD("get_vertex_weights", "idx"), &MeshDataTool::get_vertex_weights);
- ObjectTypeDB::bind_method(_MD("set_vertex_meta","idx","meta"),&MeshDataTool::set_vertex_meta);
- ObjectTypeDB::bind_method(_MD("get_vertex_meta","idx"),&MeshDataTool::get_vertex_meta);
+ ObjectTypeDB::bind_method(_MD("set_vertex_meta", "idx", "meta"), &MeshDataTool::set_vertex_meta);
+ ObjectTypeDB::bind_method(_MD("get_vertex_meta", "idx"), &MeshDataTool::get_vertex_meta);
- ObjectTypeDB::bind_method(_MD("get_vertex_edges","idx"),&MeshDataTool::get_vertex_edges);
- ObjectTypeDB::bind_method(_MD("get_vertex_faces","idx"),&MeshDataTool::get_vertex_faces);
+ ObjectTypeDB::bind_method(_MD("get_vertex_edges", "idx"), &MeshDataTool::get_vertex_edges);
+ ObjectTypeDB::bind_method(_MD("get_vertex_faces", "idx"), &MeshDataTool::get_vertex_faces);
- ObjectTypeDB::bind_method(_MD("get_edge_vertex","idx","vertex"),&MeshDataTool::get_edge_vertex);
- ObjectTypeDB::bind_method(_MD("get_edge_faces","idx","faces"),&MeshDataTool::get_edge_faces);
+ ObjectTypeDB::bind_method(_MD("get_edge_vertex", "idx", "vertex"), &MeshDataTool::get_edge_vertex);
+ ObjectTypeDB::bind_method(_MD("get_edge_faces", "idx", "faces"), &MeshDataTool::get_edge_faces);
- ObjectTypeDB::bind_method(_MD("set_edge_meta","idx","meta"),&MeshDataTool::set_edge_meta);
- ObjectTypeDB::bind_method(_MD("get_edge_meta","idx"),&MeshDataTool::get_edge_meta);
+ ObjectTypeDB::bind_method(_MD("set_edge_meta", "idx", "meta"), &MeshDataTool::set_edge_meta);
+ ObjectTypeDB::bind_method(_MD("get_edge_meta", "idx"), &MeshDataTool::get_edge_meta);
- ObjectTypeDB::bind_method(_MD("get_face_vertex","idx","vertex"),&MeshDataTool::get_face_vertex);
- ObjectTypeDB::bind_method(_MD("get_face_edge","idx","edge"),&MeshDataTool::get_face_edge);
+ ObjectTypeDB::bind_method(_MD("get_face_vertex", "idx", "vertex"), &MeshDataTool::get_face_vertex);
+ ObjectTypeDB::bind_method(_MD("get_face_edge", "idx", "edge"), &MeshDataTool::get_face_edge);
- ObjectTypeDB::bind_method(_MD("set_face_meta","idx","meta"),&MeshDataTool::set_face_meta);
- ObjectTypeDB::bind_method(_MD("get_face_meta","idx"),&MeshDataTool::get_face_meta);
+ ObjectTypeDB::bind_method(_MD("set_face_meta", "idx", "meta"), &MeshDataTool::set_face_meta);
+ ObjectTypeDB::bind_method(_MD("get_face_meta", "idx"), &MeshDataTool::get_face_meta);
- ObjectTypeDB::bind_method(_MD("get_face_normal","idx"),&MeshDataTool::get_face_normal);
+ ObjectTypeDB::bind_method(_MD("get_face_normal", "idx"), &MeshDataTool::get_face_normal);
- ObjectTypeDB::bind_method(_MD("set_material","material:Material"),&MeshDataTool::set_material);
- ObjectTypeDB::bind_method(_MD("get_material","material"),&MeshDataTool::get_material);
+ ObjectTypeDB::bind_method(_MD("set_material", "material:Material"), &MeshDataTool::set_material);
+ ObjectTypeDB::bind_method(_MD("get_material", "material"), &MeshDataTool::get_material);
}
-MeshDataTool::MeshDataTool(){
+MeshDataTool::MeshDataTool() {
clear();
}
diff --git a/scene/resources/mesh_data_tool.h b/scene/resources/mesh_data_tool.h
index c0eb4c4b8..0f8869b23 100644
--- a/scene/resources/mesh_data_tool.h
+++ b/scene/resources/mesh_data_tool.h
@@ -31,10 +31,9 @@
#include "scene/resources/mesh.h"
-class MeshDataTool : public Reference {
-
- OBJ_TYPE(MeshDataTool,Reference);
+class MeshDataTool : public Reference {
+ OBJ_TYPE(MeshDataTool, Reference);
int format;
struct Vertex {
@@ -69,18 +68,17 @@ class MeshDataTool : public Reference {
Variant meta;
};
-
Vector<Face> faces;
Ref<Material> material;
-protected:
+protected:
static void _bind_methods();
-public:
+public:
void clear();
- Error create_from_surface(const Ref<Mesh>& p_mesh,int p_surface);
- Error commit_to_surface(const Ref<Mesh>& p_mesh);
+ Error create_from_surface(const Ref<Mesh> &p_mesh, int p_surface);
+ Error commit_to_surface(const Ref<Mesh> &p_mesh);
int get_format() const;
@@ -89,44 +87,44 @@ public:
int get_face_count() const;
Vector3 get_vertex(int p_idx) const;
- void set_vertex(int p_idx,const Vector3& p_vertex);
+ void set_vertex(int p_idx, const Vector3 &p_vertex);
Vector3 get_vertex_normal(int p_idx) const;
- void set_vertex_normal(int p_idx,const Vector3& p_normal);
+ void set_vertex_normal(int p_idx, const Vector3 &p_normal);
Plane get_vertex_tangent(int p_idx) const;
- void set_vertex_tangent(int p_idx,const Plane& p_tangent);
+ void set_vertex_tangent(int p_idx, const Plane &p_tangent);
Vector2 get_vertex_uv(int p_idx) const;
- void set_vertex_uv(int p_idx,const Vector2& p_uv);
+ void set_vertex_uv(int p_idx, const Vector2 &p_uv);
Vector2 get_vertex_uv2(int p_idx) const;
- void set_vertex_uv2(int p_idx,const Vector2& p_uv2);
+ void set_vertex_uv2(int p_idx, const Vector2 &p_uv2);
Color get_vertex_color(int p_idx) const;
- void set_vertex_color(int p_idx,const Color& p_color);
+ void set_vertex_color(int p_idx, const Color &p_color);
Vector<int> get_vertex_bones(int p_idx) const;
- void set_vertex_bones(int p_idx,const Vector<int>& p_bones);
+ void set_vertex_bones(int p_idx, const Vector<int> &p_bones);
Vector<float> get_vertex_weights(int p_idx) const;
- void set_vertex_weights(int p_idx,const Vector<float>& p_weights);
+ void set_vertex_weights(int p_idx, const Vector<float> &p_weights);
Variant get_vertex_meta(int p_idx) const;
- void set_vertex_meta(int p_idx,const Variant& p_meta);
+ void set_vertex_meta(int p_idx, const Variant &p_meta);
Vector<int> get_vertex_edges(int p_idx) const;
Vector<int> get_vertex_faces(int p_idx) const;
- int get_edge_vertex(int p_edge,int p_vertex) const;
+ int get_edge_vertex(int p_edge, int p_vertex) const;
Vector<int> get_edge_faces(int p_edge) const;
Variant get_edge_meta(int p_idx) const;
- void set_edge_meta(int p_idx,const Variant& p_meta);
+ void set_edge_meta(int p_idx, const Variant &p_meta);
- int get_face_vertex(int p_face,int p_vertex) const;
- int get_face_edge(int p_face,int p_vertex) const;
+ int get_face_vertex(int p_face, int p_vertex) const;
+ int get_face_edge(int p_face, int p_vertex) const;
Variant get_face_meta(int p_face) const;
- void set_face_meta(int p_face,const Variant& p_meta);
+ void set_face_meta(int p_face, const Variant &p_meta);
Vector3 get_face_normal(int p_face) const;
Ref<Material> get_material() const;
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index 329874767..5424d8720 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -28,28 +28,26 @@
/*************************************************************************/
#include "mesh_library.h"
+bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) {
-
-bool MeshLibrary::_set(const StringName& p_name, const Variant& p_value) {
-
- String name=p_name;
+ String name = p_name;
if (name.begins_with("item/")) {
- int idx = name.get_slicec('/',1).to_int();
- String what = name.get_slicec('/',2);
+ int idx = name.get_slicec('/', 1).to_int();
+ String what = name.get_slicec('/', 2);
if (!item_map.has(idx))
create_item(idx);
- if(what=="name")
- set_item_name(idx,p_value);
- else if(what=="mesh")
- set_item_mesh(idx,p_value);
- else if(what=="shape")
- set_item_shape(idx,p_value);
- else if(what=="preview")
- set_item_preview(idx,p_value);
- else if(what=="navmesh")
- set_item_navmesh(idx,p_value);
+ if (what == "name")
+ set_item_name(idx, p_value);
+ else if (what == "mesh")
+ set_item_mesh(idx, p_value);
+ else if (what == "shape")
+ set_item_shape(idx, p_value);
+ else if (what == "preview")
+ set_item_preview(idx, p_value);
+ else if (what == "navmesh")
+ set_item_navmesh(idx, p_value);
else
return false;
@@ -59,137 +57,125 @@ bool MeshLibrary::_set(const StringName& p_name, const Variant& p_value) {
return false;
}
-bool MeshLibrary::_get(const StringName& p_name,Variant &r_ret) const {
+bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const {
- String name=p_name;
- int idx = name.get_slicec('/',1).to_int();
- ERR_FAIL_COND_V(!item_map.has(idx),false);
- String what = name.get_slicec('/',2);
+ String name = p_name;
+ int idx = name.get_slicec('/', 1).to_int();
+ ERR_FAIL_COND_V(!item_map.has(idx), false);
+ String what = name.get_slicec('/', 2);
- if(what=="name")
- r_ret= get_item_name(idx);
- else if(what=="mesh")
- r_ret= get_item_mesh(idx);
- else if(what=="shape")
- r_ret= get_item_shape(idx);
- else if(what=="navmesh")
- r_ret= get_item_navmesh(idx);
- else if(what=="preview")
- r_ret= get_item_preview(idx);
+ if (what == "name")
+ r_ret = get_item_name(idx);
+ else if (what == "mesh")
+ r_ret = get_item_mesh(idx);
+ else if (what == "shape")
+ r_ret = get_item_shape(idx);
+ else if (what == "navmesh")
+ r_ret = get_item_navmesh(idx);
+ else if (what == "preview")
+ r_ret = get_item_preview(idx);
else
return false;
return true;
}
-void MeshLibrary::_get_property_list( List<PropertyInfo> *p_list) const {
+void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
- for(Map<int,Item>::Element *E=item_map.front();E;E=E->next()) {
+ for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) {
- String name="item/"+itos(E->key())+"/";
- p_list->push_back( PropertyInfo(Variant::STRING,name+"name"));
- p_list->push_back( PropertyInfo(Variant::OBJECT,name+"mesh",PROPERTY_HINT_RESOURCE_TYPE,"Mesh"));
- p_list->push_back( PropertyInfo(Variant::OBJECT,name+"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape"));
- p_list->push_back( PropertyInfo(Variant::OBJECT,name+"navmesh",PROPERTY_HINT_RESOURCE_TYPE,"NavigationMesh"));
- p_list->push_back( PropertyInfo(Variant::OBJECT,name+"preview",PROPERTY_HINT_RESOURCE_TYPE,"Texture",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_EDITOR_HELPER));
+ String name = "item/" + itos(E->key()) + "/";
+ p_list->push_back(PropertyInfo(Variant::STRING, name + "name"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, name + "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, name + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, name + "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, name + "preview", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER));
}
}
-
-
void MeshLibrary::create_item(int p_item) {
- ERR_FAIL_COND(p_item<0);
+ ERR_FAIL_COND(p_item < 0);
ERR_FAIL_COND(item_map.has(p_item));
- item_map[p_item]=Item();
+ item_map[p_item] = Item();
_change_notify();
}
-void MeshLibrary::set_item_name(int p_item,const String& p_name) {
+void MeshLibrary::set_item_name(int p_item, const String &p_name) {
ERR_FAIL_COND(!item_map.has(p_item));
- item_map[p_item].name=p_name;
+ item_map[p_item].name = p_name;
emit_changed();
_change_notify();
-
}
-void MeshLibrary::set_item_mesh(int p_item,const Ref<Mesh>& p_mesh) {
+void MeshLibrary::set_item_mesh(int p_item, const Ref<Mesh> &p_mesh) {
ERR_FAIL_COND(!item_map.has(p_item));
- item_map[p_item].mesh=p_mesh;
+ item_map[p_item].mesh = p_mesh;
notify_change_to_owners();
emit_changed();
_change_notify();
-
-
}
-void MeshLibrary::set_item_shape(int p_item,const Ref<Shape>& p_shape) {
+void MeshLibrary::set_item_shape(int p_item, const Ref<Shape> &p_shape) {
ERR_FAIL_COND(!item_map.has(p_item));
- item_map[p_item].shape=p_shape;
+ item_map[p_item].shape = p_shape;
_change_notify();
notify_change_to_owners();
emit_changed();
_change_notify();
-
}
-
-void MeshLibrary::set_item_navmesh(int p_item,const Ref<NavigationMesh>& p_navmesh) {
+void MeshLibrary::set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh) {
ERR_FAIL_COND(!item_map.has(p_item));
- item_map[p_item].navmesh=p_navmesh;
+ item_map[p_item].navmesh = p_navmesh;
_change_notify();
notify_change_to_owners();
emit_changed();
_change_notify();
-
}
-void MeshLibrary::set_item_preview(int p_item,const Ref<Texture>& p_preview) {
+void MeshLibrary::set_item_preview(int p_item, const Ref<Texture> &p_preview) {
ERR_FAIL_COND(!item_map.has(p_item));
- item_map[p_item].preview=p_preview;
+ item_map[p_item].preview = p_preview;
emit_changed();
_change_notify();
-
}
String MeshLibrary::get_item_name(int p_item) const {
- ERR_FAIL_COND_V(!item_map.has(p_item),"");
+ ERR_FAIL_COND_V(!item_map.has(p_item), "");
return item_map[p_item].name;
-
}
Ref<Mesh> MeshLibrary::get_item_mesh(int p_item) const {
- ERR_FAIL_COND_V(!item_map.has(p_item),Ref<Mesh>());
+ ERR_FAIL_COND_V(!item_map.has(p_item), Ref<Mesh>());
return item_map[p_item].mesh;
-
}
Ref<Shape> MeshLibrary::get_item_shape(int p_item) const {
- ERR_FAIL_COND_V(!item_map.has(p_item),Ref<Shape>());
+ ERR_FAIL_COND_V(!item_map.has(p_item), Ref<Shape>());
return item_map[p_item].shape;
}
Ref<NavigationMesh> MeshLibrary::get_item_navmesh(int p_item) const {
- ERR_FAIL_COND_V(!item_map.has(p_item),Ref<NavigationMesh>());
+ ERR_FAIL_COND_V(!item_map.has(p_item), Ref<NavigationMesh>());
return item_map[p_item].navmesh;
}
-
Ref<Texture> MeshLibrary::get_item_preview(int p_item) const {
- ERR_FAIL_COND_V(!item_map.has(p_item),Ref<Texture>());
+ ERR_FAIL_COND_V(!item_map.has(p_item), Ref<Texture>());
return item_map[p_item].preview;
}
bool MeshLibrary::has_item(int p_item) const {
- return item_map.has(p_item) ;
+ return item_map.has(p_item);
}
void MeshLibrary::remove_item(int p_item) {
@@ -198,7 +184,6 @@ void MeshLibrary::remove_item(int p_item) {
notify_change_to_owners();
_change_notify();
emit_changed();
-
}
void MeshLibrary::clear() {
@@ -213,20 +198,20 @@ Vector<int> MeshLibrary::get_item_list() const {
Vector<int> ret;
ret.resize(item_map.size());
- int idx=0;
- for(Map<int,Item>::Element *E=item_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) {
- ret[idx++]=E->key();
+ ret[idx++] = E->key();
}
return ret;
}
-int MeshLibrary::find_item_name(const String& p_name) const {
+int MeshLibrary::find_item_name(const String &p_name) const {
- for(Map<int,Item>::Element *E=item_map.front();E;E=E->next()) {
+ for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) {
- if (E->get().name==p_name)
+ if (E->get().name == p_name)
return E->key();
}
return -1;
@@ -237,33 +222,27 @@ int MeshLibrary::get_last_unused_item_id() const {
if (!item_map.size())
return 0;
else
- return item_map.back()->key()+1;
+ return item_map.back()->key() + 1;
}
-
-
void MeshLibrary::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create_item","id"),&MeshLibrary::create_item);
- ObjectTypeDB::bind_method(_MD("set_item_name","id","name"),&MeshLibrary::set_item_name);
- ObjectTypeDB::bind_method(_MD("set_item_mesh","id","mesh:Mesh"),&MeshLibrary::set_item_mesh);
- ObjectTypeDB::bind_method(_MD("set_item_navmesh","id","navmesh:NavigationMesh"),&MeshLibrary::set_item_navmesh);
- ObjectTypeDB::bind_method(_MD("set_item_shape","id","shape:Shape"),&MeshLibrary::set_item_shape);
- ObjectTypeDB::bind_method(_MD("get_item_name","id"),&MeshLibrary::get_item_name);
- ObjectTypeDB::bind_method(_MD("get_item_mesh:Mesh","id"),&MeshLibrary::get_item_mesh);
- ObjectTypeDB::bind_method(_MD("get_item_navmesh:NavigationMesh","id"),&MeshLibrary::get_item_navmesh);
- ObjectTypeDB::bind_method(_MD("get_item_shape:Shape","id"),&MeshLibrary::get_item_shape);
- ObjectTypeDB::bind_method(_MD("remove_item","id"),&MeshLibrary::remove_item);
- ObjectTypeDB::bind_method(_MD("clear"),&MeshLibrary::clear);
- ObjectTypeDB::bind_method(_MD("get_item_list"),&MeshLibrary::get_item_list);
- ObjectTypeDB::bind_method(_MD("get_last_unused_item_id"),&MeshLibrary::get_last_unused_item_id);
+ ObjectTypeDB::bind_method(_MD("create_item", "id"), &MeshLibrary::create_item);
+ ObjectTypeDB::bind_method(_MD("set_item_name", "id", "name"), &MeshLibrary::set_item_name);
+ ObjectTypeDB::bind_method(_MD("set_item_mesh", "id", "mesh:Mesh"), &MeshLibrary::set_item_mesh);
+ ObjectTypeDB::bind_method(_MD("set_item_navmesh", "id", "navmesh:NavigationMesh"), &MeshLibrary::set_item_navmesh);
+ ObjectTypeDB::bind_method(_MD("set_item_shape", "id", "shape:Shape"), &MeshLibrary::set_item_shape);
+ ObjectTypeDB::bind_method(_MD("get_item_name", "id"), &MeshLibrary::get_item_name);
+ ObjectTypeDB::bind_method(_MD("get_item_mesh:Mesh", "id"), &MeshLibrary::get_item_mesh);
+ ObjectTypeDB::bind_method(_MD("get_item_navmesh:NavigationMesh", "id"), &MeshLibrary::get_item_navmesh);
+ ObjectTypeDB::bind_method(_MD("get_item_shape:Shape", "id"), &MeshLibrary::get_item_shape);
+ ObjectTypeDB::bind_method(_MD("remove_item", "id"), &MeshLibrary::remove_item);
+ ObjectTypeDB::bind_method(_MD("clear"), &MeshLibrary::clear);
+ ObjectTypeDB::bind_method(_MD("get_item_list"), &MeshLibrary::get_item_list);
+ ObjectTypeDB::bind_method(_MD("get_last_unused_item_id"), &MeshLibrary::get_last_unused_item_id);
}
MeshLibrary::MeshLibrary() {
-
-
}
MeshLibrary::~MeshLibrary() {
-
-
}
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index 66b688ab2..b8c81ff63 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -29,15 +29,15 @@
#ifndef GRID_THEME_H
#define GRID_THEME_H
-#include "resource.h"
-#include "mesh.h"
-#include "shape.h"
#include "map.h"
+#include "mesh.h"
+#include "resource.h"
#include "scene/3d/navigation_mesh.h"
+#include "shape.h"
class MeshLibrary : public Resource {
- OBJ_TYPE(MeshLibrary,Resource);
+ OBJ_TYPE(MeshLibrary, Resource);
RES_BASE_EXTENSION("gt");
struct Item {
@@ -48,24 +48,22 @@ class MeshLibrary : public Resource {
Ref<NavigationMesh> navmesh;
};
- Map<int,Item> item_map;
+ Map<int, Item> item_map;
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
-public:
-
+public:
void create_item(int p_item);
- void set_item_name(int p_item,const String& p_name);
- void set_item_mesh(int p_item,const Ref<Mesh>& p_mesh);
- void set_item_navmesh(int p_item, const Ref<NavigationMesh>& p_navmesh);
- void set_item_shape(int p_item,const Ref<Shape>& p_shape);
- void set_item_preview(int p_item,const Ref<Texture>& p_preview);
+ void set_item_name(int p_item, const String &p_name);
+ void set_item_mesh(int p_item, const Ref<Mesh> &p_mesh);
+ void set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh);
+ void set_item_shape(int p_item, const Ref<Shape> &p_shape);
+ void set_item_preview(int p_item, const Ref<Texture> &p_preview);
String get_item_name(int p_item) const;
Ref<Mesh> get_item_mesh(int p_item) const;
Ref<NavigationMesh> get_item_navmesh(int p_item) const;
@@ -77,7 +75,7 @@ public:
void clear();
- int find_item_name(const String& p_name) const;
+ int find_item_name(const String &p_name) const;
Vector<int> get_item_list() const;
int get_last_unused_item_id() const;
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index 2554b17a9..a0e1e76ab 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -29,224 +29,193 @@
#include "multimesh.h"
#include "servers/visual_server.h"
-
-
-void MultiMesh::_set_transform_array(const DVector<Vector3>& p_array) {
+void MultiMesh::_set_transform_array(const DVector<Vector3> &p_array) {
int instance_count = get_instance_count();
DVector<Vector3> xforms = p_array;
- int len=xforms.size();
- ERR_FAIL_COND((len/4) != instance_count);
- if (len==0)
+ int len = xforms.size();
+ ERR_FAIL_COND((len / 4) != instance_count);
+ if (len == 0)
return;
DVector<Vector3>::Read r = xforms.read();
- for(int i=0;i<len/4;i++) {
+ for (int i = 0; i < len / 4; i++) {
Transform t;
- t.basis[0]=r[i*4+0];
- t.basis[1]=r[i*4+1];
- t.basis[2]=r[i*4+2];
- t.origin=r[i*4+3];
+ t.basis[0] = r[i * 4 + 0];
+ t.basis[1] = r[i * 4 + 1];
+ t.basis[2] = r[i * 4 + 2];
+ t.origin = r[i * 4 + 3];
- set_instance_transform(i,t);
+ set_instance_transform(i, t);
}
-
}
DVector<Vector3> MultiMesh::_get_transform_array() const {
int instance_count = get_instance_count();
- if (instance_count==0)
+ if (instance_count == 0)
return DVector<Vector3>();
DVector<Vector3> xforms;
- xforms.resize(instance_count*4);
+ xforms.resize(instance_count * 4);
DVector<Vector3>::Write w = xforms.write();
- for(int i=0;i<instance_count;i++) {
+ for (int i = 0; i < instance_count; i++) {
- Transform t=get_instance_transform(i);
- w[i*4+0]=t.basis[0];
- w[i*4+1]=t.basis[1];
- w[i*4+2]=t.basis[2];
- w[i*4+3]=t.origin;
+ Transform t = get_instance_transform(i);
+ w[i * 4 + 0] = t.basis[0];
+ w[i * 4 + 1] = t.basis[1];
+ w[i * 4 + 2] = t.basis[2];
+ w[i * 4 + 3] = t.origin;
}
return xforms;
-
}
-
-void MultiMesh::_set_color_array(const DVector<Color>& p_array) {
+void MultiMesh::_set_color_array(const DVector<Color> &p_array) {
int instance_count = get_instance_count();
DVector<Color> colors = p_array;
- int len=colors.size();
+ int len = colors.size();
ERR_FAIL_COND(len != instance_count);
- if (len==0)
+ if (len == 0)
return;
DVector<Color>::Read r = colors.read();
- for(int i=0;i<len;i++) {
+ for (int i = 0; i < len; i++) {
- set_instance_color(i,r[i]);
+ set_instance_color(i, r[i]);
}
-
}
DVector<Color> MultiMesh::_get_color_array() const {
int instance_count = get_instance_count();
- if (instance_count==0)
+ if (instance_count == 0)
return DVector<Color>();
DVector<Color> colors;
colors.resize(instance_count);
- for(int i=0;i<instance_count;i++) {
+ for (int i = 0; i < instance_count; i++) {
- colors.set(i,get_instance_color(i));
+ colors.set(i, get_instance_color(i));
}
return colors;
-
}
+void MultiMesh::set_mesh(const Ref<Mesh> &p_mesh) {
-
-
-void MultiMesh::set_mesh(const Ref<Mesh>& p_mesh) {
-
- mesh=p_mesh;
+ mesh = p_mesh;
if (!mesh.is_null())
- VisualServer::get_singleton()->multimesh_set_mesh(multimesh,mesh->get_rid());
+ VisualServer::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid());
else
- VisualServer::get_singleton()->multimesh_set_mesh(multimesh,RID());
-
+ VisualServer::get_singleton()->multimesh_set_mesh(multimesh, RID());
}
Ref<Mesh> MultiMesh::get_mesh() const {
return mesh;
-
}
void MultiMesh::set_instance_count(int p_count) {
- VisualServer::get_singleton()->multimesh_set_instance_count(multimesh,p_count);
-
+ VisualServer::get_singleton()->multimesh_set_instance_count(multimesh, p_count);
}
int MultiMesh::get_instance_count() const {
return VisualServer::get_singleton()->multimesh_get_instance_count(multimesh);
-
}
-void MultiMesh::set_instance_transform(int p_instance, const Transform& p_transform) {
-
- VisualServer::get_singleton()->multimesh_instance_set_transform(multimesh,p_instance,p_transform);
-
+void MultiMesh::set_instance_transform(int p_instance, const Transform &p_transform) {
+ VisualServer::get_singleton()->multimesh_instance_set_transform(multimesh, p_instance, p_transform);
}
Transform MultiMesh::get_instance_transform(int p_instance) const {
- return VisualServer::get_singleton()->multimesh_instance_get_transform(multimesh,p_instance);
-
+ return VisualServer::get_singleton()->multimesh_instance_get_transform(multimesh, p_instance);
}
-void MultiMesh::set_instance_color(int p_instance, const Color& p_color) {
-
-
- VisualServer::get_singleton()->multimesh_instance_set_color(multimesh,p_instance,p_color);
+void MultiMesh::set_instance_color(int p_instance, const Color &p_color) {
+ VisualServer::get_singleton()->multimesh_instance_set_color(multimesh, p_instance, p_color);
}
Color MultiMesh::get_instance_color(int p_instance) const {
- return VisualServer::get_singleton()->multimesh_instance_get_color(multimesh,p_instance);
-
+ return VisualServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance);
}
-void MultiMesh::set_aabb(const AABB& p_aabb) {
-
- aabb=p_aabb;
- VisualServer::get_singleton()->multimesh_set_aabb(multimesh,p_aabb);
-
+void MultiMesh::set_aabb(const AABB &p_aabb) {
+ aabb = p_aabb;
+ VisualServer::get_singleton()->multimesh_set_aabb(multimesh, p_aabb);
}
AABB MultiMesh::get_aabb() const {
return aabb;
-
}
void MultiMesh::generate_aabb() {
-
-
ERR_EXPLAIN("Cannot generate AABB if mesh is null.");
ERR_FAIL_COND(mesh.is_null());
- AABB base_aabb=mesh->get_aabb();
+ AABB base_aabb = mesh->get_aabb();
- aabb=AABB();
+ aabb = AABB();
int instance_count = get_instance_count();
- for(int i=0;i<instance_count;i++) {
-
+ for (int i = 0; i < instance_count; i++) {
Transform xform = get_instance_transform(i);
- if(i==0)
- aabb=xform.xform(base_aabb);
+ if (i == 0)
+ aabb = xform.xform(base_aabb);
else
aabb.merge_with(xform.xform(base_aabb));
-
}
set_aabb(aabb);
-
}
RID MultiMesh::get_rid() const {
return multimesh;
-
}
void MultiMesh::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MultiMesh::set_mesh);
- ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"),&MultiMesh::get_mesh);
- ObjectTypeDB::bind_method(_MD("set_instance_count","count"),&MultiMesh::set_instance_count);
- ObjectTypeDB::bind_method(_MD("get_instance_count"),&MultiMesh::get_instance_count);
- ObjectTypeDB::bind_method(_MD("set_instance_transform","instance","transform"),&MultiMesh::set_instance_transform);
- ObjectTypeDB::bind_method(_MD("get_instance_transform","instance"),&MultiMesh::get_instance_transform);
- ObjectTypeDB::bind_method(_MD("set_instance_color","instance","color"),&MultiMesh::set_instance_color);
- ObjectTypeDB::bind_method(_MD("get_instance_color","instance"),&MultiMesh::get_instance_color);
- ObjectTypeDB::bind_method(_MD("set_aabb","visibility_aabb"),&MultiMesh::set_aabb);
- ObjectTypeDB::bind_method(_MD("get_aabb"),&MultiMesh::get_aabb);
-
- ObjectTypeDB::bind_method(_MD("generate_aabb"),&MultiMesh::generate_aabb);
-
- ObjectTypeDB::bind_method(_MD("_set_transform_array"),&MultiMesh::_set_transform_array);
- ObjectTypeDB::bind_method(_MD("_get_transform_array"),&MultiMesh::_get_transform_array);
- ObjectTypeDB::bind_method(_MD("_set_color_array"),&MultiMesh::_set_color_array);
- ObjectTypeDB::bind_method(_MD("_get_color_array"),&MultiMesh::_get_color_array);
+ ObjectTypeDB::bind_method(_MD("set_mesh", "mesh:Mesh"), &MultiMesh::set_mesh);
+ ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"), &MultiMesh::get_mesh);
+ ObjectTypeDB::bind_method(_MD("set_instance_count", "count"), &MultiMesh::set_instance_count);
+ ObjectTypeDB::bind_method(_MD("get_instance_count"), &MultiMesh::get_instance_count);
+ ObjectTypeDB::bind_method(_MD("set_instance_transform", "instance", "transform"), &MultiMesh::set_instance_transform);
+ ObjectTypeDB::bind_method(_MD("get_instance_transform", "instance"), &MultiMesh::get_instance_transform);
+ ObjectTypeDB::bind_method(_MD("set_instance_color", "instance", "color"), &MultiMesh::set_instance_color);
+ ObjectTypeDB::bind_method(_MD("get_instance_color", "instance"), &MultiMesh::get_instance_color);
+ ObjectTypeDB::bind_method(_MD("set_aabb", "visibility_aabb"), &MultiMesh::set_aabb);
+ ObjectTypeDB::bind_method(_MD("get_aabb"), &MultiMesh::get_aabb);
+ ObjectTypeDB::bind_method(_MD("generate_aabb"), &MultiMesh::generate_aabb);
- ADD_PROPERTY(PropertyInfo(Variant::INT,"instance_count",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_instance_count"), _SCS("get_instance_count"));
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"mesh",PROPERTY_HINT_RESOURCE_TYPE,"Mesh"), _SCS("set_mesh"), _SCS("get_mesh"));
- ADD_PROPERTY(PropertyInfo(Variant::_AABB,"aabb"), _SCS("set_aabb"), _SCS("get_aabb") );
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"transform_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_transform_array"), _SCS("_get_transform_array"));
- ADD_PROPERTY(PropertyInfo(Variant::COLOR_ARRAY,"color_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_color_array"), _SCS("_get_color_array"));
+ ObjectTypeDB::bind_method(_MD("_set_transform_array"), &MultiMesh::_set_transform_array);
+ ObjectTypeDB::bind_method(_MD("_get_transform_array"), &MultiMesh::_get_transform_array);
+ ObjectTypeDB::bind_method(_MD("_set_color_array"), &MultiMesh::_set_color_array);
+ ObjectTypeDB::bind_method(_MD("_get_color_array"), &MultiMesh::_get_color_array);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "instance_count", PROPERTY_HINT_RANGE, "0,16384,1"), _SCS("set_instance_count"), _SCS("get_instance_count"));
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), _SCS("set_mesh"), _SCS("get_mesh"));
+ ADD_PROPERTY(PropertyInfo(Variant::_AABB, "aabb"), _SCS("set_aabb"), _SCS("get_aabb"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY, "transform_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_transform_array"), _SCS("_get_transform_array"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR_ARRAY, "color_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_color_array"), _SCS("_get_color_array"));
}
MultiMesh::MultiMesh() {
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index 448b4b341..aff6f8153 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -31,40 +31,38 @@
#include "scene/resources/mesh.h"
-
class MultiMesh : public Resource {
- OBJ_TYPE( MultiMesh, Resource );
+ OBJ_TYPE(MultiMesh, Resource);
RES_BASE_EXTENSION("mmsh");
AABB aabb;
Ref<Mesh> mesh;
RID multimesh;
-protected:
+protected:
static void _bind_methods();
- void _set_transform_array(const DVector<Vector3>& p_array);
+ void _set_transform_array(const DVector<Vector3> &p_array);
DVector<Vector3> _get_transform_array() const;
- void _set_color_array(const DVector<Color>& p_array);
+ void _set_color_array(const DVector<Color> &p_array);
DVector<Color> _get_color_array() const;
public:
-
- void set_mesh(const Ref<Mesh>& p_mesh);
+ void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;
void set_instance_count(int p_count);
int get_instance_count() const;
- void set_instance_transform(int p_instance, const Transform& p_transform);
+ void set_instance_transform(int p_instance, const Transform &p_transform);
Transform get_instance_transform(int p_instance) const;
- void set_instance_color(int p_instance, const Color& p_color);
+ void set_instance_color(int p_instance, const Color &p_color);
Color get_instance_color(int p_instance) const;
- void set_aabb(const AABB& p_aabb);
+ void set_aabb(const AABB &p_aabb);
virtual AABB get_aabb() const;
void generate_aabb();
@@ -73,7 +71,6 @@ public:
MultiMesh();
~MultiMesh();
-
};
#endif // MULTI_MESH_H
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 7e0302291..eec362d7a 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -27,192 +27,185 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "packed_scene.h"
+#include "core/core_string_names.h"
#include "globals.h"
#include "io/resource_loader.h"
+#include "scene/2d/node_2d.h"
#include "scene/3d/spatial.h"
#include "scene/gui/control.h"
-#include "scene/2d/node_2d.h"
#include "scene/main/instance_placeholder.h"
-#include "core/core_string_names.h"
#define PACK_VERSION 2
bool SceneState::can_instance() const {
- return nodes.size()>0;
+ return nodes.size() > 0;
}
-
Node *SceneState::instance(bool p_gen_edit_state) const {
// nodes where instancing failed (because something is missing)
- List<Node*> stray_instances;
+ List<Node *> stray_instances;
-#define NODE_FROM_ID(p_name,p_id)\
- Node *p_name;\
- if (p_id&FLAG_ID_IS_PATH) {\
- NodePath np=node_paths[p_id&FLAG_MASK];\
- p_name=ret_nodes[0]->_get_node(np);\
- } else {\
- ERR_FAIL_INDEX_V(p_id&FLAG_MASK,nc,NULL);\
- p_name=ret_nodes[p_id&FLAG_MASK];\
+#define NODE_FROM_ID(p_name, p_id) \
+ Node *p_name; \
+ if (p_id & FLAG_ID_IS_PATH) { \
+ NodePath np = node_paths[p_id & FLAG_MASK]; \
+ p_name = ret_nodes[0]->_get_node(np); \
+ } else { \
+ ERR_FAIL_INDEX_V(p_id &FLAG_MASK, nc, NULL); \
+ p_name = ret_nodes[p_id & FLAG_MASK]; \
}
int nc = nodes.size();
- ERR_FAIL_COND_V(nc==0,NULL);
+ ERR_FAIL_COND_V(nc == 0, NULL);
- const StringName*snames=NULL;
- int sname_count=names.size();
+ const StringName *snames = NULL;
+ int sname_count = names.size();
if (sname_count)
- snames=&names[0];
+ snames = &names[0];
- const Variant*props=NULL;
- int prop_count=variants.size();
+ const Variant *props = NULL;
+ int prop_count = variants.size();
if (prop_count)
- props=&variants[0];
+ props = &variants[0];
//Vector<Variant> properties;
const NodeData *nd = &nodes[0];
- Node **ret_nodes=(Node**)alloca( sizeof(Node*)*nc );
+ Node **ret_nodes = (Node **)alloca(sizeof(Node *) * nc);
- bool gen_node_path_cache=p_gen_edit_state && node_path_cache.empty();
+ bool gen_node_path_cache = p_gen_edit_state && node_path_cache.empty();
- for(int i=0;i<nc;i++) {
+ for (int i = 0; i < nc; i++) {
- const NodeData &n=nd[i];
+ const NodeData &n = nd[i];
- Node *parent=NULL;
+ Node *parent = NULL;
- if (i>0) {
+ if (i > 0) {
- NODE_FROM_ID(nparent,n.parent);
+ NODE_FROM_ID(nparent, n.parent);
#ifdef DEBUG_ENABLED
- if (!nparent && n.parent&FLAG_ID_IS_PATH) {
-
- WARN_PRINT(String("Parent path '"+String(node_paths[n.parent&FLAG_MASK])+"' for node '"+String(snames[n.name])+"' has vanished when instancing: '"+get_path()+"'.").ascii().get_data());
+ if (!nparent && n.parent & FLAG_ID_IS_PATH) {
+ WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data());
}
#endif
- parent=nparent;
+ parent = nparent;
}
- Node *node=NULL;
-
+ Node *node = NULL;
- if (i==0 && base_scene_idx>=0) {
+ if (i == 0 && base_scene_idx >= 0) {
//scene inheritance on root node
- //print_line("scene inherit");
- Ref<PackedScene> sdata = props[ base_scene_idx ];
- ERR_FAIL_COND_V( !sdata.is_valid(), NULL);
+ //print_line("scene inherit");
+ Ref<PackedScene> sdata = props[base_scene_idx];
+ ERR_FAIL_COND_V(!sdata.is_valid(), NULL);
node = sdata->instance(p_gen_edit_state);
- ERR_FAIL_COND_V(!node,NULL);
+ ERR_FAIL_COND_V(!node, NULL);
if (p_gen_edit_state) {
node->set_scene_inherited_state(sdata->get_state());
}
- } else if (n.instance>=0) {
+ } else if (n.instance >= 0) {
//instance a scene into this node
- //print_line("instance");
- if (n.instance&FLAG_INSTANCE_IS_PLACEHOLDER) {
+ //print_line("instance");
+ if (n.instance & FLAG_INSTANCE_IS_PLACEHOLDER) {
- String path = props[n.instance&FLAG_MASK];
+ String path = props[n.instance & FLAG_MASK];
if (disable_placeholders) {
- Ref<PackedScene> sdata = ResourceLoader::load(path,"PackedScene");
- ERR_FAIL_COND_V( !sdata.is_valid(), NULL);
+ Ref<PackedScene> sdata = ResourceLoader::load(path, "PackedScene");
+ ERR_FAIL_COND_V(!sdata.is_valid(), NULL);
node = sdata->instance(p_gen_edit_state);
- ERR_FAIL_COND_V(!node,NULL);
+ ERR_FAIL_COND_V(!node, NULL);
} else {
- InstancePlaceholder *ip = memnew( InstancePlaceholder );
+ InstancePlaceholder *ip = memnew(InstancePlaceholder);
ip->set_instance_path(path);
- node=ip;
+ node = ip;
}
node->set_scene_instance_load_placeholder(true);
} else {
- Ref<PackedScene> sdata = props[ n.instance&FLAG_MASK ];
- ERR_FAIL_COND_V( !sdata.is_valid(), NULL);
+ Ref<PackedScene> sdata = props[n.instance & FLAG_MASK];
+ ERR_FAIL_COND_V(!sdata.is_valid(), NULL);
node = sdata->instance(p_gen_edit_state);
- ERR_FAIL_COND_V(!node,NULL);
-
+ ERR_FAIL_COND_V(!node, NULL);
}
- } else if (n.type==TYPE_INSTANCED) {
+ } else if (n.type == TYPE_INSTANCED) {
//print_line("instanced");
//get the node from somewhere, it likely already exists from another instance
if (parent) {
- node=parent->_get_child_by_name(snames[n.name]);
+ node = parent->_get_child_by_name(snames[n.name]);
#ifdef DEBUG_ENABLED
if (!node) {
- WARN_PRINT(String("Node '"+String(ret_nodes[0]->get_path_to(parent))+"/"+String(snames[n.name])+"' was modified from inside a instance, but it has vanished.").ascii().get_data());
+ WARN_PRINT(String("Node '" + String(ret_nodes[0]->get_path_to(parent)) + "/" + String(snames[n.name]) + "' was modified from inside a instance, but it has vanished.").ascii().get_data());
}
#endif
}
} else if (ObjectTypeDB::is_type_enabled(snames[n.type])) {
- //print_line("created");
+ //print_line("created");
//node belongs to this scene and must be created
- Object * obj = ObjectTypeDB::instance(snames[ n.type ]);
+ Object *obj = ObjectTypeDB::instance(snames[n.type]);
if (!obj || !obj->cast_to<Node>()) {
if (obj) {
memdelete(obj);
- obj=NULL;
+ obj = NULL;
}
- WARN_PRINT(String("Warning node of type "+snames[n.type].operator String()+" does not exist.").ascii().get_data());
- if (n.parent>=0 && n.parent<nc && ret_nodes[n.parent]) {
+ WARN_PRINT(String("Warning node of type " + snames[n.type].operator String() + " does not exist.").ascii().get_data());
+ if (n.parent >= 0 && n.parent < nc && ret_nodes[n.parent]) {
if (ret_nodes[n.parent]->cast_to<Spatial>()) {
- obj = memnew( Spatial );
+ obj = memnew(Spatial);
} else if (ret_nodes[n.parent]->cast_to<Control>()) {
- obj = memnew( Control );
+ obj = memnew(Control);
} else if (ret_nodes[n.parent]->cast_to<Node2D>()) {
- obj = memnew( Node2D );
+ obj = memnew(Node2D);
}
-
}
if (!obj) {
- obj = memnew( Node );
+ obj = memnew(Node);
}
}
node = obj->cast_to<Node>();
-
}
-
if (node) {
// may not have found the node (part of instanced scene and removed)
// if found all is good, otherwise ignore
//properties
- int nprop_count=n.properties.size();
+ int nprop_count = n.properties.size();
if (nprop_count) {
- const NodeData::Property* nprops=&n.properties[0];
+ const NodeData::Property *nprops = &n.properties[0];
- for(int j=0;j<nprop_count;j++) {
+ for (int j = 0; j < nprop_count; j++) {
bool valid;
- ERR_FAIL_INDEX_V( nprops[j].name, sname_count, NULL );
- ERR_FAIL_INDEX_V( nprops[j].value, prop_count, NULL );
+ ERR_FAIL_INDEX_V(nprops[j].name, sname_count, NULL);
+ ERR_FAIL_INDEX_V(nprops[j].value, prop_count, NULL);
- if (snames[ nprops[j].name ]==CoreStringNames::get_singleton()->_script) {
+ if (snames[nprops[j].name] == CoreStringNames::get_singleton()->_script) {
//work around to avoid old script variables from disappearing, should be the proper fix to:
//https://github.com/godotengine/godot/issues/2958
//store old state
- List<Pair<StringName,Variant> > old_state;
+ List<Pair<StringName, Variant> > old_state;
if (node->get_script_instance()) {
node->get_script_instance()->get_property_state(old_state);
}
- node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid);
+ node->set(snames[nprops[j].name], props[nprops[j].value], &valid);
//restore old state for new script, if exists
- for (List<Pair<StringName,Variant> >::Element *E=old_state.front();E;E=E->next()) {
- node->set(E->get().first,E->get().second);
+ for (List<Pair<StringName, Variant> >::Element *E = old_state.front(); E; E = E->next()) {
+ node->set(E->get().first, E->get().second);
}
} else {
- node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid);
+ node->set(snames[nprops[j].name], props[nprops[j].value], &valid);
}
}
}
@@ -220,60 +213,56 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
//name
//groups
- for(int j=0;j<n.groups.size();j++) {
+ for (int j = 0; j < n.groups.size(); j++) {
- ERR_FAIL_INDEX_V( n.groups[j], sname_count, NULL );
- node->add_to_group( snames[ n.groups[j] ], true );
+ ERR_FAIL_INDEX_V(n.groups[j], sname_count, NULL);
+ node->add_to_group(snames[n.groups[j]], true);
}
- if (n.instance>=0 || n.type!=TYPE_INSTANCED || i==0) {
+ if (n.instance >= 0 || n.type != TYPE_INSTANCED || i == 0) {
//if node was not part of instance, must set it's name, parenthood and ownership
- if (i>0) {
+ if (i > 0) {
if (parent) {
- parent->_add_child_nocheck(node,snames[n.name]);
+ parent->_add_child_nocheck(node, snames[n.name]);
} else {
//it may be possible that an instanced scene has changed
//and the node has nowhere to go anymore
stray_instances.push_back(node); //can't be added, go to stray list
}
} else {
- node->_set_name_nocheck( snames[ n.name ] );
+ node->_set_name_nocheck(snames[n.name]);
}
}
- if (n.owner>=0) {
+ if (n.owner >= 0) {
- NODE_FROM_ID(owner,n.owner);
+ NODE_FROM_ID(owner, n.owner);
if (owner)
node->_set_owner_nocheck(owner);
}
-
-
}
-
- ret_nodes[i]=node;
+ ret_nodes[i] = node;
if (node && gen_node_path_cache && ret_nodes[0]) {
NodePath n = ret_nodes[0]->get_path_to(node);
- node_path_cache[n]=i;
+ node_path_cache[n] = i;
}
}
-
//do connections
int cc = connections.size();
const ConnectionData *cdata = connections.ptr();
- for(int i=0;i<cc;i++) {
+ for (int i = 0; i < cc; i++) {
- const ConnectionData &c=cdata[i];
+ const ConnectionData &c = cdata[i];
//ERR_FAIL_INDEX_V( c.from, nc, NULL );
//ERR_FAIL_INDEX_V( c.to, nc, NULL );
- NODE_FROM_ID(cfrom,c.from);
- NODE_FROM_ID(cto,c.to);
+ NODE_FROM_ID(cfrom, c.from);
+ NODE_FROM_ID(cto, c.to);
if (!cfrom || !cto)
continue;
@@ -281,56 +270,52 @@ Node *SceneState::instance(bool p_gen_edit_state) const {
Vector<Variant> binds;
if (c.binds.size()) {
binds.resize(c.binds.size());
- for(int j=0;j<c.binds.size();j++)
- binds[j]=props[ c.binds[j] ];
+ for (int j = 0; j < c.binds.size(); j++)
+ binds[j] = props[c.binds[j]];
}
-
- cfrom->connect( snames[ c.signal], cto, snames[ c.method], binds,CONNECT_PERSIST|c.flags );
+ cfrom->connect(snames[c.signal], cto, snames[c.method], binds, CONNECT_PERSIST | c.flags);
}
//Node *s = ret_nodes[0];
//remove nodes that could not be added, likely as a result that
- while(stray_instances.size()) {
+ while (stray_instances.size()) {
memdelete(stray_instances.front()->get());
stray_instances.pop_front();
}
- for(int i=0;i<editable_instances.size();i++) {
+ for (int i = 0; i < editable_instances.size(); i++) {
Node *ei = ret_nodes[0]->_get_node(editable_instances[i]);
if (ei) {
- ret_nodes[0]->set_editable_instance(ei,true);
+ ret_nodes[0]->set_editable_instance(ei, true);
}
}
return ret_nodes[0];
-
}
-
-static int _nm_get_string(const String& p_string, Map<StringName,int> &name_map) {
+static int _nm_get_string(const String &p_string, Map<StringName, int> &name_map) {
if (name_map.has(p_string))
return name_map[p_string];
int idx = name_map.size();
- name_map[p_string]=idx;
+ name_map[p_string] = idx;
return idx;
}
-static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) {
+static int _vm_get_variant(const Variant &p_variant, HashMap<Variant, int, VariantHasher> &variant_map) {
if (variant_map.has(p_variant))
return variant_map[p_variant];
int idx = variant_map.size();
- variant_map[p_variant]=idx;
+ variant_map[p_variant] = idx;
return idx;
}
-Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) {
-
+Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map) {
// this function handles all the work related to properly packing scenes, be it
// instanced or inherited.
@@ -338,18 +323,18 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
// document it. if you fail to understand something, please ask!
//discard nodes that do not belong to be processed
- if (p_node!=p_owner && p_node->get_owner()!=p_owner && !p_owner->is_editable_instance(p_node->get_owner()))
+ if (p_node != p_owner && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner()))
return OK;
// save the child instanced scenes that are chosen as editable, so they can be restored
// upon load back
- if (p_node!=p_owner && p_node->get_filename()!=String() && p_owner->is_editable_instance(p_node))
+ if (p_node != p_owner && p_node->get_filename() != String() && p_owner->is_editable_instance(p_node))
editable_instances.push_back(p_owner->get_path_to(p_node));
NodeData nd;
- nd.name=_nm_get_string(p_node->get_name(),name_map);
- nd.instance=-1; //not instanced by default
+ nd.name = _nm_get_string(p_node->get_name(), name_map);
+ nd.instance = -1; //not instanced by default
// if this node is part of an instanced scene or sub-instanced scene
// we need to get the corresponding instance states.
@@ -358,34 +343,34 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
List<PackState> pack_state_stack;
- bool instanced_by_owner=true;
+ bool instanced_by_owner = true;
{
- Node *n=p_node;
+ Node *n = p_node;
- while(n) {
+ while (n) {
- if (n==p_owner) {
+ if (n == p_owner) {
Ref<SceneState> state = n->get_scene_inherited_state();
if (state.is_valid()) {
int node = state->find_node_by_path(n->get_path_to(p_node));
- if (node>=0) {
+ if (node >= 0) {
//this one has state for this node, save
PackState ps;
- ps.node=node;
- ps.state=state;
+ ps.node = node;
+ ps.state = state;
pack_state_stack.push_back(ps);
- instanced_by_owner=false;
+ instanced_by_owner = false;
}
}
- if (p_node->get_filename()!=String() && p_node->get_owner()==p_owner && instanced_by_owner) {
+ if (p_node->get_filename() != String() && p_node->get_owner() == p_owner && instanced_by_owner) {
if (p_node->get_scene_instance_load_placeholder()) {
//it's a placeholder, use the placeholder path
- nd.instance=_vm_get_variant(p_node->get_filename(),variant_map);
- nd.instance|=FLAG_INSTANCE_IS_PLACEHOLDER;
+ nd.instance = _vm_get_variant(p_node->get_filename(), variant_map);
+ nd.instance |= FLAG_INSTANCE_IS_PLACEHOLDER;
} else {
//must instance ourselves
Ref<PackedScene> instance = ResourceLoader::load(p_node->get_filename());
@@ -393,27 +378,26 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
return ERR_CANT_OPEN;
}
- nd.instance=_vm_get_variant(instance,variant_map);
+ nd.instance = _vm_get_variant(instance, variant_map);
}
}
- n=NULL;
+ n = NULL;
} else {
- if (n->get_filename()!=String()) {
+ if (n->get_filename() != String()) {
//is an instance
Ref<SceneState> state = n->get_scene_instance_state();
if (state.is_valid()) {
int node = state->find_node_by_path(n->get_path_to(p_node));
- if (node>=0) {
+ if (node >= 0) {
//this one has state for this node, save
PackState ps;
- ps.node=node;
- ps.state=state;
+ ps.node = node;
+ ps.state = state;
pack_state_stack.push_back(ps);
}
}
-
}
- n=n->get_owner();
+ n = n->get_owner();
}
}
}
@@ -478,24 +462,20 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
List<PropertyInfo> plist;
p_node->get_property_list(&plist);
- for (List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
-
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
continue;
}
String name = E->get().name;
- Variant value = p_node->get( E->get().name );
-
+ Variant value = p_node->get(E->get().name);
bool isdefault = ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one());
-// if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) {
-// continue;
-// }
-
-
+ // if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) {
+ // continue;
+ // }
//print_line("PASSED!");
//print_line("at: "+String(p_node->get_name())+"::"+name+": - nz: "+itos(E->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO)+" no: "+itos(E->get().usage&PROPERTY_USAGE_STORE_IF_NONONE));
@@ -507,37 +487,36 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
// only save what has been changed
// only save changed properties in instance
- if (E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE || E->get().name=="__meta__") {
+ if (E->get().usage & PROPERTY_USAGE_NO_INSTANCE_STATE || E->get().name == "__meta__") {
//property has requested that no instance state is saved, sorry
//also, meta won't be overriden or saved
continue;
}
- bool exists=false;
+ bool exists = false;
Variant original;
- for (List<PackState>::Element *F=pack_state_stack.back();F;F=F->prev()) {
+ for (List<PackState>::Element *F = pack_state_stack.back(); F; F = F->prev()) {
//check all levels of pack to see if the property exists somewhere
- const PackState &ps=F->get();
+ const PackState &ps = F->get();
- original = ps.state->get_property_value(ps.node,E->get().name,exists);
+ original = ps.state->get_property_value(ps.node, E->get().name, exists);
if (exists) {
break;
}
}
-
if (exists) {
//check if already exists and did not change
- if (value.get_type()==Variant::REAL && original.get_type()==Variant::REAL) {
+ if (value.get_type() == Variant::REAL && original.get_type() == Variant::REAL) {
//this must be done because, as some scenes save as text, there might be a tiny difference in floats due to numerical error
float a = value;
float b = original;
- if (Math::abs(a-b)<CMP_EPSILON)
+ if (Math::abs(a - b) < CMP_EPSILON)
continue;
- } else if (bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) {
+ } else if (bool(Variant::evaluate(Variant::OP_EQUAL, value, original))) {
continue;
}
@@ -549,8 +528,7 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
continue;
}
-
- } else {
+ } else {
if (isdefault) {
//it's the default value, no point in saving it
@@ -559,32 +537,30 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
}
NodeData::Property prop;
- prop.name=_nm_get_string( name,name_map);
- prop.value=_vm_get_variant( value, variant_map);
+ prop.name = _nm_get_string(name, name_map);
+ prop.value = _vm_get_variant(value, variant_map);
nd.properties.push_back(prop);
-
}
-
// save the groups this node is into
// discard groups that come from the original scene
List<Node::GroupInfo> groups;
p_node->get_groups(&groups);
- for(List<Node::GroupInfo>::Element *E=groups.front();E;E=E->next()) {
- Node::GroupInfo &gi=E->get();
+ for (List<Node::GroupInfo>::Element *E = groups.front(); E; E = E->next()) {
+ Node::GroupInfo &gi = E->get();
if (!gi.persistent)
continue;
-// if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name))
-// continue; //group was instanced, don't add here
+ // if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name))
+ // continue; //group was instanced, don't add here
- bool skip=false;
- for (List<PackState>::Element *F=pack_state_stack.front();F;F=F->next()) {
+ bool skip = false;
+ for (List<PackState>::Element *F = pack_state_stack.front(); F; F = F->next()) {
//check all levels of pack to see if the group was added somewhere
- const PackState &ps=F->get();
- if (ps.state->is_node_in_group(ps.node,gi.name)) {
- skip=true;
+ const PackState &ps = F->get();
+ if (ps.state->is_node_in_group(ps.node, gi.name)) {
+ skip = true;
break;
}
}
@@ -592,24 +568,23 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
if (skip)
continue;
- nd.groups.push_back(_nm_get_string(gi.name,name_map));
+ nd.groups.push_back(_nm_get_string(gi.name, name_map));
}
-
// save the right owner
// for the saved scene root this is -1
// for nodes of the saved scene this is 0
// for nodes of instanced scenes this is >0
- if (p_node==p_owner) {
+ if (p_node == p_owner) {
//saved scene root
- nd.owner=-1;
- } else if (p_node->get_owner()==p_owner) {
+ nd.owner = -1;
+ } else if (p_node->get_owner() == p_owner) {
//part of saved scene
- nd.owner=0;
+ nd.owner = 0;
} else {
- nd.owner=-1;
+ nd.owner = -1;
#if 0
// this is pointless, if this was instanced by something else,
// the owner will already be set.
@@ -631,22 +606,19 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
}
#endif
-
-
}
// Save the right type. If this node was created by an instance
// then flag that the node should not be created but reused
if (pack_state_stack.empty()) {
//this node is not part of an instancing process, so save the type
- nd.type=_nm_get_string(p_node->get_type(),name_map);
+ nd.type = _nm_get_string(p_node->get_type(), name_map);
} else {
// this node is part of an instanced process, so do not save the type.
// instead, save that it was instanced
- nd.type=TYPE_INSTANCED;
+ nd.type = TYPE_INSTANCED;
}
-
// determine whether to save this node or not
// if this node is part of an instanced sub-scene, we can skip storing it if basically
// no properties changed and no groups were added to it.
@@ -654,59 +626,54 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
// that hold changes
bool save_node = nd.properties.size() || nd.groups.size(); // some local properties or groups exist
- save_node = save_node || p_node==p_owner; // owner is always saved
- save_node = save_node || (p_node->get_owner()==p_owner && instanced_by_owner); //part of scene and not instanced
-
+ save_node = save_node || p_node == p_owner; // owner is always saved
+ save_node = save_node || (p_node->get_owner() == p_owner && instanced_by_owner); //part of scene and not instanced
int idx = nodes.size();
- int parent_node=NO_PARENT_SAVED;
+ int parent_node = NO_PARENT_SAVED;
if (save_node) {
//don't save the node if nothing and subscene
- node_map[p_node]=idx;
+ node_map[p_node] = idx;
//ok validate parent node
- if (p_parent_idx==NO_PARENT_SAVED) {
+ if (p_parent_idx == NO_PARENT_SAVED) {
int sidx;
if (nodepath_map.has(p_node->get_parent())) {
- sidx=nodepath_map[p_node->get_parent()];
+ sidx = nodepath_map[p_node->get_parent()];
} else {
- sidx=nodepath_map.size();
- nodepath_map[p_node->get_parent()]=sidx;
+ sidx = nodepath_map.size();
+ nodepath_map[p_node->get_parent()] = sidx;
}
- nd.parent=FLAG_ID_IS_PATH|sidx;
+ nd.parent = FLAG_ID_IS_PATH | sidx;
} else {
- nd.parent=p_parent_idx;
+ nd.parent = p_parent_idx;
}
- parent_node=idx;
+ parent_node = idx;
nodes.push_back(nd);
-
}
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- for(int i=0;i<p_node->get_child_count();i++) {
-
- Node *c=p_node->get_child(i);
- Error err = _parse_node(p_owner,c,parent_node,name_map,variant_map,node_map,nodepath_map);
+ Node *c = p_node->get_child(i);
+ Error err = _parse_node(p_owner, c, parent_node, name_map, variant_map, node_map, nodepath_map);
if (err)
return err;
}
return OK;
-
}
-Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) {
+Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map) {
- if (p_node!=p_owner && p_node->get_owner() && p_node->get_owner()!=p_owner && !p_owner->is_editable_instance(p_node->get_owner()))
+ if (p_node != p_owner && p_node->get_owner() && p_node->get_owner() != p_owner && !p_owner->is_editable_instance(p_node->get_owner()))
return OK;
-
List<MethodInfo> _signals;
p_node->get_signal_list(&_signals);
_signals.sort();
@@ -714,27 +681,24 @@ Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,
//ERR_FAIL_COND_V( !node_map.has(p_node), ERR_BUG);
//NodeData &nd = nodes[node_map[p_node]];
-
- for(List<MethodInfo>::Element *E=_signals.front();E;E=E->next()) {
+ for (List<MethodInfo>::Element *E = _signals.front(); E; E = E->next()) {
List<Node::Connection> conns;
- p_node->get_signal_connection_list(E->get().name,&conns);
+ p_node->get_signal_connection_list(E->get().name, &conns);
conns.sort();
- for(List<Node::Connection>::Element *F=conns.front();F;F=F->next()) {
+ for (List<Node::Connection>::Element *F = conns.front(); F; F = F->next()) {
const Node::Connection &c = F->get();
- if (!(c.flags&CONNECT_PERSIST)) //only persistent connections get saved
+ if (!(c.flags & CONNECT_PERSIST)) //only persistent connections get saved
continue;
// only connections that originate or end into main saved scene are saved
// everything else is discarded
-
- Node *target=c.target->cast_to<Node>();
-
+ Node *target = c.target->cast_to<Node>();
if (!target) {
continue;
@@ -745,150 +709,139 @@ Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,
ERR_CONTINUE(!common_parent);
- if (common_parent!=p_owner && common_parent->get_filename()==String()) {
- common_parent=common_parent->get_owner();
+ if (common_parent != p_owner && common_parent->get_filename() == String()) {
+ common_parent = common_parent->get_owner();
}
- bool exists=false;
+ bool exists = false;
//go through ownership chain to see if this exists
- while(common_parent) {
-
-
+ while (common_parent) {
Ref<SceneState> ps;
- if (common_parent==p_owner)
- ps=common_parent->get_scene_inherited_state();
+ if (common_parent == p_owner)
+ ps = common_parent->get_scene_inherited_state();
else
- ps=common_parent->get_scene_instance_state();
-
+ ps = common_parent->get_scene_instance_state();
if (ps.is_valid()) {
NodePath signal_from = common_parent->get_path_to(p_node);
NodePath signal_to = common_parent->get_path_to(target);
- if (ps->has_connection(signal_from,c.signal,signal_to,c.method)) {
- exists=true;
+ if (ps->has_connection(signal_from, c.signal, signal_to, c.method)) {
+ exists = true;
break;
}
-
}
- if (common_parent==p_owner)
+ if (common_parent == p_owner)
break;
else
- common_parent=common_parent->get_owner();
+ common_parent = common_parent->get_owner();
}
if (exists) { //already exists (comes from instance or inheritance), so don't save
continue;
}
-
-
{
- Node *nl=p_node;
+ Node *nl = p_node;
- bool exists=false;
+ bool exists = false;
- while(nl) {
+ while (nl) {
- if (nl==p_owner) {
+ if (nl == p_owner) {
Ref<SceneState> state = nl->get_scene_inherited_state();
if (state.is_valid()) {
int from_node = state->find_node_by_path(nl->get_path_to(p_node));
int to_node = state->find_node_by_path(nl->get_path_to(target));
- if (from_node>=0 && to_node>=0) {
+ if (from_node >= 0 && to_node >= 0) {
//this one has state for this node, save
- if (state->is_connection(from_node,c.signal,to_node,c.method)) {
- exists=true;
+ if (state->is_connection(from_node, c.signal, to_node, c.method)) {
+ exists = true;
break;
}
}
}
- nl=NULL;
+ nl = NULL;
} else {
- if (nl->get_filename()!=String()) {
+ if (nl->get_filename() != String()) {
//is an instance
Ref<SceneState> state = nl->get_scene_instance_state();
if (state.is_valid()) {
int from_node = state->find_node_by_path(nl->get_path_to(p_node));
int to_node = state->find_node_by_path(nl->get_path_to(target));
- if (from_node>=0 && to_node>=0) {
+ if (from_node >= 0 && to_node >= 0) {
//this one has state for this node, save
- if (state->is_connection(from_node,c.signal,to_node,c.method)) {
- exists=true;
+ if (state->is_connection(from_node, c.signal, to_node, c.method)) {
+ exists = true;
break;
}
}
}
-
}
- nl=nl->get_owner();
+ nl = nl->get_owner();
}
}
if (exists) {
continue;
}
-
}
-
int src_id;
if (node_map.has(p_node)) {
- src_id=node_map[p_node];
+ src_id = node_map[p_node];
} else {
if (nodepath_map.has(p_node)) {
- src_id=FLAG_ID_IS_PATH|nodepath_map[p_node];
+ src_id = FLAG_ID_IS_PATH | nodepath_map[p_node];
} else {
- int sidx=nodepath_map.size();
- nodepath_map[p_node]=sidx;
- src_id=FLAG_ID_IS_PATH|sidx;
+ int sidx = nodepath_map.size();
+ nodepath_map[p_node] = sidx;
+ src_id = FLAG_ID_IS_PATH | sidx;
}
}
-
-
int target_id;
if (node_map.has(target)) {
- target_id=node_map[target];
+ target_id = node_map[target];
} else {
if (nodepath_map.has(target)) {
- target_id=FLAG_ID_IS_PATH|nodepath_map[target];
+ target_id = FLAG_ID_IS_PATH | nodepath_map[target];
} else {
- int sidx=nodepath_map.size();
- nodepath_map[target]=sidx;
- target_id=FLAG_ID_IS_PATH|sidx;
+ int sidx = nodepath_map.size();
+ nodepath_map[target] = sidx;
+ target_id = FLAG_ID_IS_PATH | sidx;
}
}
ConnectionData cd;
- cd.from=src_id;
- cd.to=target_id;
- cd.method=_nm_get_string(c.method,name_map);
- cd.signal=_nm_get_string(c.signal,name_map);
- cd.flags=c.flags;
- for(int i=0;i<c.binds.size();i++) {
+ cd.from = src_id;
+ cd.to = target_id;
+ cd.method = _nm_get_string(c.method, name_map);
+ cd.signal = _nm_get_string(c.signal, name_map);
+ cd.flags = c.flags;
+ for (int i = 0; i < c.binds.size(); i++) {
- cd.binds.push_back( _vm_get_variant(c.binds[i],variant_map));
+ cd.binds.push_back(_vm_get_variant(c.binds[i], variant_map));
}
connections.push_back(cd);
}
}
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- Node *c=p_node->get_child(i);
- Error err = _parse_connections(p_owner,c,name_map,variant_map,node_map,nodepath_map);
+ Node *c = p_node->get_child(i);
+ Error err = _parse_connections(p_owner, c, name_map, variant_map, node_map, nodepath_map);
if (err)
return err;
}
@@ -896,19 +849,17 @@ Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,
return OK;
}
-
Error SceneState::pack(Node *p_scene) {
- ERR_FAIL_NULL_V( p_scene, ERR_INVALID_PARAMETER );
-
+ ERR_FAIL_NULL_V(p_scene, ERR_INVALID_PARAMETER);
clear();
Node *scene = p_scene;
- Map<StringName,int> name_map;
- HashMap<Variant,int,VariantHasher> variant_map;
- Map<Node*,int> node_map;
- Map<Node*,int> nodepath_map;
+ Map<StringName, int> name_map;
+ HashMap<Variant, int, VariantHasher> variant_map;
+ Map<Node *, int> node_map;
+ Map<Node *, int> nodepath_map;
//if using scene inheritance, pack the scene it inherits from
if (scene->get_scene_inherited_state().is_valid()) {
@@ -916,19 +867,18 @@ Error SceneState::pack(Node *p_scene) {
Ref<PackedScene> instance = ResourceLoader::load(path);
if (instance.is_valid()) {
- base_scene_idx=_vm_get_variant(instance,variant_map);
+ base_scene_idx = _vm_get_variant(instance, variant_map);
}
}
//instanced, only direct sub-scnes are supported of course
-
- Error err = _parse_node(scene,scene,-1,name_map,variant_map,node_map,nodepath_map);
+ Error err = _parse_node(scene, scene, -1, name_map, variant_map, node_map, nodepath_map);
if (err) {
clear();
ERR_FAIL_V(err);
}
- err = _parse_connections(scene,scene,name_map,variant_map,node_map,nodepath_map);
+ err = _parse_connections(scene, scene, name_map, variant_map, node_map, nodepath_map);
if (err) {
clear();
ERR_FAIL_V(err);
@@ -936,35 +886,34 @@ Error SceneState::pack(Node *p_scene) {
names.resize(name_map.size());
- for(Map<StringName,int>::Element *E=name_map.front();E;E=E->next()) {
+ for (Map<StringName, int>::Element *E = name_map.front(); E; E = E->next()) {
- names[E->get()]=E->key();
+ names[E->get()] = E->key();
}
variants.resize(variant_map.size());
- const Variant *K=NULL;
- while((K=variant_map.next(K))) {
+ const Variant *K = NULL;
+ while ((K = variant_map.next(K))) {
int idx = variant_map[*K];
- variants[idx]=*K;
+ variants[idx] = *K;
}
node_paths.resize(nodepath_map.size());
- for(Map<Node*,int>::Element *E=nodepath_map.front();E;E=E->next()) {
+ for (Map<Node *, int>::Element *E = nodepath_map.front(); E; E = E->next()) {
- node_paths[E->get()]=scene->get_path_to(E->key());
+ node_paths[E->get()] = scene->get_path_to(E->key());
}
-
return OK;
}
void SceneState::set_path(const String &p_path) {
- path=p_path;
+ path = p_path;
}
-String SceneState::get_path() const{
+String SceneState::get_path() const {
return path;
}
@@ -978,13 +927,12 @@ void SceneState::clear() {
node_path_cache.clear();
node_paths.clear();
editable_instances.clear();
- base_scene_idx=-1;
-
+ base_scene_idx = -1;
}
Ref<SceneState> SceneState::_get_base_scene_state() const {
- if (base_scene_idx>=0) {
+ if (base_scene_idx >= 0) {
Ref<PackedScene> ps = variants[base_scene_idx];
if (ps.is_valid()) {
@@ -995,16 +943,16 @@ Ref<SceneState> SceneState::_get_base_scene_state() const {
return Ref<SceneState>();
}
-int SceneState::find_node_by_path(const NodePath& p_node) const {
+int SceneState::find_node_by_path(const NodePath &p_node) const {
if (!node_path_cache.has(p_node)) {
if (_get_base_scene_state().is_valid()) {
int idx = _get_base_scene_state()->find_node_by_path(p_node);
- if (idx>=0) {
- int rkey=_find_base_scene_node_remap_key(idx);
- if (rkey==-1) {
- rkey=nodes.size() + base_scene_node_remap.size();
- base_scene_node_remap[rkey]=idx;
+ if (idx >= 0) {
+ int rkey = _find_base_scene_node_remap_key(idx);
+ if (rkey == -1) {
+ rkey = nodes.size() + base_scene_node_remap.size();
+ base_scene_node_remap[rkey] = idx;
}
return rkey;
}
@@ -1019,8 +967,8 @@ int SceneState::find_node_by_path(const NodePath& p_node) const {
//the node in the instanced scene, as a property may be missing
//from the local one
int idx = _get_base_scene_state()->find_node_by_path(p_node);
- if (idx!=-1) {
- base_scene_node_remap[nid]=idx;
+ if (idx != -1) {
+ base_scene_node_remap[nid] = idx;
}
}
@@ -1029,29 +977,29 @@ int SceneState::find_node_by_path(const NodePath& p_node) const {
int SceneState::_find_base_scene_node_remap_key(int p_idx) const {
- for (Map<int, int>::Element* E=base_scene_node_remap.front();E;E=E->next()) {
- if (E->value()==p_idx) {
+ for (Map<int, int>::Element *E = base_scene_node_remap.front(); E; E = E->next()) {
+ if (E->value() == p_idx) {
return E->key();
}
}
return -1;
}
-Variant SceneState::get_property_value(int p_node, const StringName& p_property, bool &found) const {
+Variant SceneState::get_property_value(int p_node, const StringName &p_property, bool &found) const {
- found=false;
+ found = false;
- ERR_FAIL_COND_V(p_node<0,Variant());
+ ERR_FAIL_COND_V(p_node < 0, Variant());
- if (p_node<nodes.size()) {
+ if (p_node < nodes.size()) {
//find in built-in nodes
int pc = nodes[p_node].properties.size();
- const StringName* namep = names.ptr();
+ const StringName *namep = names.ptr();
- const NodeData::Property *p=nodes[p_node].properties.ptr();
- for(int i=0;i<pc;i++) {
- if (p_property==namep[p[i].name]) {
- found=true;
+ const NodeData::Property *p = nodes[p_node].properties.ptr();
+ for (int i = 0; i < pc; i++) {
+ if (p_property == namep[p[i].name]) {
+ found = true;
return variants[p[i].value];
}
}
@@ -1060,61 +1008,61 @@ Variant SceneState::get_property_value(int p_node, const StringName& p_property,
//property not found, try on instance
if (base_scene_node_remap.has(p_node)) {
- return _get_base_scene_state()->get_property_value(base_scene_node_remap[p_node],p_property,found);
+ return _get_base_scene_state()->get_property_value(base_scene_node_remap[p_node], p_property, found);
}
return Variant();
}
-bool SceneState::is_node_in_group(int p_node,const StringName& p_group) const {
+bool SceneState::is_node_in_group(int p_node, const StringName &p_group) const {
- ERR_FAIL_COND_V(p_node<0,false);
+ ERR_FAIL_COND_V(p_node < 0, false);
- if (p_node<nodes.size()) {
- const StringName* namep = names.ptr();
- for(int i=0;i<nodes[p_node].groups.size();i++) {
- if (namep[nodes[p_node].groups[i]]==p_group)
+ if (p_node < nodes.size()) {
+ const StringName *namep = names.ptr();
+ for (int i = 0; i < nodes[p_node].groups.size(); i++) {
+ if (namep[nodes[p_node].groups[i]] == p_group)
return true;
}
}
if (base_scene_node_remap.has(p_node)) {
- return _get_base_scene_state()->is_node_in_group(base_scene_node_remap[p_node],p_group);
+ return _get_base_scene_state()->is_node_in_group(base_scene_node_remap[p_node], p_group);
}
return false;
}
-bool SceneState::disable_placeholders=false;
+bool SceneState::disable_placeholders = false;
void SceneState::set_disable_placeholders(bool p_disable) {
- disable_placeholders=p_disable;
+ disable_placeholders = p_disable;
}
-bool SceneState::is_connection(int p_node,const StringName& p_signal,int p_to_node,const StringName& p_to_method) const {
+bool SceneState::is_connection(int p_node, const StringName &p_signal, int p_to_node, const StringName &p_to_method) const {
- ERR_FAIL_COND_V(p_node<0,false);
- ERR_FAIL_COND_V(p_to_node<0,false);
+ ERR_FAIL_COND_V(p_node < 0, false);
+ ERR_FAIL_COND_V(p_to_node < 0, false);
- if (p_node<nodes.size() && p_to_node<nodes.size()) {
+ if (p_node < nodes.size() && p_to_node < nodes.size()) {
- int signal_idx=-1;
- int method_idx=-1;
- for(int i=0;i<names.size();i++) {
- if (names[i]==p_signal) {
- signal_idx=i;
- } else if (names[i]==p_to_method) {
- method_idx=i;
+ int signal_idx = -1;
+ int method_idx = -1;
+ for (int i = 0; i < names.size(); i++) {
+ if (names[i] == p_signal) {
+ signal_idx = i;
+ } else if (names[i] == p_to_method) {
+ method_idx = i;
}
}
- if (signal_idx>=0 && method_idx>=0) {
+ if (signal_idx >= 0 && method_idx >= 0) {
//signal and method strings are stored..
- for(int i=0;i<connections.size();i++) {
+ for (int i = 0; i < connections.size(); i++) {
- if (connections[i].from==p_node && connections[i].to==p_to_node && connections[i].signal==signal_idx && connections[i].method==method_idx) {
+ if (connections[i].from == p_node && connections[i].to == p_to_node && connections[i].signal == signal_idx && connections[i].method == method_idx) {
return true;
}
@@ -1123,30 +1071,27 @@ bool SceneState::is_connection(int p_node,const StringName& p_signal,int p_to_no
}
if (base_scene_node_remap.has(p_node) && base_scene_node_remap.has(p_to_node)) {
- return _get_base_scene_state()->is_connection(base_scene_node_remap[p_node],p_signal,base_scene_node_remap[p_to_node],p_to_method);
+ return _get_base_scene_state()->is_connection(base_scene_node_remap[p_node], p_signal, base_scene_node_remap[p_to_node], p_to_method);
}
return false;
-
}
+void SceneState::set_bundled_scene(const Dictionary &d) {
-void SceneState::set_bundled_scene(const Dictionary& d) {
-
-
- ERR_FAIL_COND( !d.has("names"));
- ERR_FAIL_COND( !d.has("variants"));
- ERR_FAIL_COND( !d.has("node_count"));
- ERR_FAIL_COND( !d.has("nodes"));
- ERR_FAIL_COND( !d.has("conn_count"));
- ERR_FAIL_COND( !d.has("conns"));
-// ERR_FAIL_COND( !d.has("path"));
+ ERR_FAIL_COND(!d.has("names"));
+ ERR_FAIL_COND(!d.has("variants"));
+ ERR_FAIL_COND(!d.has("node_count"));
+ ERR_FAIL_COND(!d.has("nodes"));
+ ERR_FAIL_COND(!d.has("conn_count"));
+ ERR_FAIL_COND(!d.has("conns"));
+ // ERR_FAIL_COND( !d.has("path"));
- int version=1;
+ int version = 1;
if (d.has("version"))
- version=d["version"];
+ version = d["version"];
- if (version>PACK_VERSION) {
+ if (version > PACK_VERSION) {
ERR_EXPLAIN("Save format version too new!");
ERR_FAIL();
}
@@ -1156,19 +1101,19 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
int namecount = snames.size();
names.resize(namecount);
- DVector<String>::Read r =snames.read();
- for(int i=0;i<names.size();i++)
- names[i]=r[i];
+ DVector<String>::Read r = snames.read();
+ for (int i = 0; i < names.size(); i++)
+ names[i] = r[i];
}
Array svariants = d["variants"];
if (svariants.size()) {
- int varcount=svariants.size();
+ int varcount = svariants.size();
variants.resize(varcount);
- for(int i=0;i<varcount;i++) {
+ for (int i = 0; i < varcount; i++) {
- variants[i]=svariants[i];
+ variants[i] = svariants[i];
}
} else {
@@ -1176,83 +1121,80 @@ void SceneState::set_bundled_scene(const Dictionary& d) {
}
nodes.resize(d["node_count"]);
- int nc=nodes.size();
+ int nc = nodes.size();
if (nc) {
DVector<int> snodes = d["nodes"];
DVector<int>::Read r = snodes.read();
- int idx=0;
- for(int i=0;i<nc;i++) {
+ int idx = 0;
+ for (int i = 0; i < nc; i++) {
NodeData &nd = nodes[i];
- nd.parent=r[idx++];
- nd.owner=r[idx++];
- nd.type=r[idx++];
- nd.name=r[idx++];
- nd.instance=r[idx++];
+ nd.parent = r[idx++];
+ nd.owner = r[idx++];
+ nd.type = r[idx++];
+ nd.name = r[idx++];
+ nd.instance = r[idx++];
nd.properties.resize(r[idx++]);
- for(int j=0;j<nd.properties.size();j++) {
+ for (int j = 0; j < nd.properties.size(); j++) {
- nd.properties[j].name=r[idx++];
- nd.properties[j].value=r[idx++];
+ nd.properties[j].name = r[idx++];
+ nd.properties[j].value = r[idx++];
}
nd.groups.resize(r[idx++]);
- for(int j=0;j<nd.groups.size();j++) {
+ for (int j = 0; j < nd.groups.size(); j++) {
- nd.groups[j]=r[idx++];
+ nd.groups[j] = r[idx++];
}
}
-
}
connections.resize(d["conn_count"]);
- int cc=connections.size();
+ int cc = connections.size();
if (cc) {
DVector<int> sconns = d["conns"];
DVector<int>::Read r = sconns.read();
- int idx=0;
- for(int i=0;i<cc;i++) {
+ int idx = 0;
+ for (int i = 0; i < cc; i++) {
ConnectionData &cd = connections[i];
- cd.from=r[idx++];
- cd.to=r[idx++];
- cd.signal=r[idx++];
- cd.method=r[idx++];
- cd.flags=r[idx++];
+ cd.from = r[idx++];
+ cd.to = r[idx++];
+ cd.signal = r[idx++];
+ cd.method = r[idx++];
+ cd.flags = r[idx++];
cd.binds.resize(r[idx++]);
- for(int j=0;j<cd.binds.size();j++) {
+ for (int j = 0; j < cd.binds.size(); j++) {
- cd.binds[j]=r[idx++];
+ cd.binds[j] = r[idx++];
}
}
-
}
Array np;
if (d.has("node_paths")) {
- np=d["node_paths"];
+ np = d["node_paths"];
}
node_paths.resize(np.size());
- for(int i=0;i<np.size();i++) {
- node_paths[i]=np[i];
+ for (int i = 0; i < np.size(); i++) {
+ node_paths[i] = np[i];
}
Array ei;
if (d.has("editable_instances")) {
- ei=d["editable_instances"];
+ ei = d["editable_instances"];
}
if (d.has("base_scene")) {
- base_scene_idx=d["base_scene"];
+ base_scene_idx = d["base_scene"];
}
editable_instances.resize(ei.size());
- for(int i=0;i<editable_instances.size();i++) {
- editable_instances[i]=ei[i];
+ for (int i = 0; i < editable_instances.size(); i++) {
+ editable_instances[i] = ei[i];
}
-// path=d["path"];
-
+ // path=d["path"];
}
Dictionary SceneState::get_bundled_scene() const {
@@ -1262,85 +1204,82 @@ Dictionary SceneState::get_bundled_scene() const {
if (names.size()) {
- DVector<String>::Write r=rnames.write();
+ DVector<String>::Write r = rnames.write();
- for(int i=0;i<names.size();i++)
- r[i]=names[i];
+ for (int i = 0; i < names.size(); i++)
+ r[i] = names[i];
}
Dictionary d;
- d["names"]=rnames;
- d["variants"]=variants;
+ d["names"] = rnames;
+ d["variants"] = variants;
Vector<int> rnodes;
- d["node_count"]=nodes.size();
+ d["node_count"] = nodes.size();
- for(int i=0;i<nodes.size();i++) {
+ for (int i = 0; i < nodes.size(); i++) {
- const NodeData &nd=nodes[i];
+ const NodeData &nd = nodes[i];
rnodes.push_back(nd.parent);
rnodes.push_back(nd.owner);
rnodes.push_back(nd.type);
rnodes.push_back(nd.name);
rnodes.push_back(nd.instance);
rnodes.push_back(nd.properties.size());
- for(int j=0;j<nd.properties.size();j++) {
+ for (int j = 0; j < nd.properties.size(); j++) {
rnodes.push_back(nd.properties[j].name);
rnodes.push_back(nd.properties[j].value);
}
rnodes.push_back(nd.groups.size());
- for(int j=0;j<nd.groups.size();j++) {
+ for (int j = 0; j < nd.groups.size(); j++) {
rnodes.push_back(nd.groups[j]);
}
}
- d["nodes"]=rnodes;
+ d["nodes"] = rnodes;
Vector<int> rconns;
- d["conn_count"]=connections.size();
+ d["conn_count"] = connections.size();
- for(int i=0;i<connections.size();i++) {
+ for (int i = 0; i < connections.size(); i++) {
- const ConnectionData &cd=connections[i];
+ const ConnectionData &cd = connections[i];
rconns.push_back(cd.from);
rconns.push_back(cd.to);
rconns.push_back(cd.signal);
rconns.push_back(cd.method);
rconns.push_back(cd.flags);
rconns.push_back(cd.binds.size());
- for(int j=0;j<cd.binds.size();j++)
+ for (int j = 0; j < cd.binds.size(); j++)
rconns.push_back(cd.binds[j]);
-
}
- d["conns"]=rconns;
+ d["conns"] = rconns;
Array rnode_paths;
rnode_paths.resize(node_paths.size());
- for(int i=0;i<node_paths.size();i++) {
- rnode_paths[i]=node_paths[i];
+ for (int i = 0; i < node_paths.size(); i++) {
+ rnode_paths[i] = node_paths[i];
}
- d["node_paths"]=rnode_paths;
+ d["node_paths"] = rnode_paths;
Array reditable_instances;
reditable_instances.resize(editable_instances.size());
- for(int i=0;i<editable_instances.size();i++) {
- reditable_instances[i]=editable_instances[i];
+ for (int i = 0; i < editable_instances.size(); i++) {
+ reditable_instances[i] = editable_instances[i];
}
- d["editable_instances"]=reditable_instances;
- if (base_scene_idx>=0) {
- d["base_scene"]=base_scene_idx;
+ d["editable_instances"] = reditable_instances;
+ if (base_scene_idx >= 0) {
+ d["base_scene"] = base_scene_idx;
}
- d["version"]=PACK_VERSION;
+ d["version"] = PACK_VERSION;
-// d["path"]=path;
+ // d["path"]=path;
return d;
-
-
}
int SceneState::get_node_count() const {
@@ -1350,76 +1289,68 @@ int SceneState::get_node_count() const {
StringName SceneState::get_node_type(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),StringName());
- if (nodes[p_idx].type==TYPE_INSTANCED)
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), StringName());
+ if (nodes[p_idx].type == TYPE_INSTANCED)
return StringName();
return names[nodes[p_idx].type];
}
StringName SceneState::get_node_name(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),StringName());
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), StringName());
return names[nodes[p_idx].name];
}
-
bool SceneState::is_node_instance_placeholder(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),false);
-
- return nodes[p_idx].instance>=0 && nodes[p_idx].instance&FLAG_INSTANCE_IS_PLACEHOLDER;
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), false);
+ return nodes[p_idx].instance >= 0 && nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER;
}
Ref<PackedScene> SceneState::get_node_instance(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),Ref<PackedScene>());
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), Ref<PackedScene>());
- if (nodes[p_idx].instance>=0) {
- if (nodes[p_idx].instance&FLAG_INSTANCE_IS_PLACEHOLDER)
+ if (nodes[p_idx].instance >= 0) {
+ if (nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER)
return Ref<PackedScene>();
else
- return variants[nodes[p_idx].instance&FLAG_MASK];
- } else if (nodes[p_idx].parent<0 || nodes[p_idx].parent==NO_PARENT_SAVED) {
+ return variants[nodes[p_idx].instance & FLAG_MASK];
+ } else if (nodes[p_idx].parent < 0 || nodes[p_idx].parent == NO_PARENT_SAVED) {
- if (base_scene_idx>=0) {
+ if (base_scene_idx >= 0) {
return variants[base_scene_idx];
}
}
-
-
return Ref<PackedScene>();
-
-
}
String SceneState::get_node_instance_placeholder(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),String());
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), String());
- if (nodes[p_idx].instance>=0 && nodes[p_idx].instance&FLAG_INSTANCE_IS_PLACEHOLDER) {
- return variants[nodes[p_idx].instance&FLAG_MASK];
+ if (nodes[p_idx].instance >= 0 && nodes[p_idx].instance & FLAG_INSTANCE_IS_PLACEHOLDER) {
+ return variants[nodes[p_idx].instance & FLAG_MASK];
}
return String();
-
}
-Vector<StringName> SceneState::get_node_groups(int p_idx) const{
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),Vector<StringName>());
+Vector<StringName> SceneState::get_node_groups(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), Vector<StringName>());
Vector<StringName> groups;
- for(int i=0;i<nodes[p_idx].groups.size();i++) {
+ for (int i = 0; i < nodes[p_idx].groups.size(); i++) {
groups.push_back(names[nodes[p_idx].groups[i]]);
}
return groups;
}
+NodePath SceneState::get_node_path(int p_idx, bool p_for_parent) const {
-NodePath SceneState::get_node_path(int p_idx,bool p_for_parent) const {
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), NodePath());
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),NodePath());
-
- if (nodes[p_idx].parent<0 || nodes[p_idx].parent==NO_PARENT_SAVED) {
+ if (nodes[p_idx].parent < 0 || nodes[p_idx].parent == NO_PARENT_SAVED) {
if (p_for_parent) {
return NodePath();
} else {
@@ -1429,67 +1360,63 @@ NodePath SceneState::get_node_path(int p_idx,bool p_for_parent) const {
Vector<StringName> sub_path;
NodePath base_path;
- int nidx=p_idx;
- while(true) {
- if (nodes[nidx].parent==NO_PARENT_SAVED || nodes[nidx].parent<0) {
+ int nidx = p_idx;
+ while (true) {
+ if (nodes[nidx].parent == NO_PARENT_SAVED || nodes[nidx].parent < 0) {
- sub_path.insert(0,".");
+ sub_path.insert(0, ".");
break;
}
- if (!p_for_parent || p_idx!=nidx) {
- sub_path.insert(0,names[nodes[nidx].name]);
+ if (!p_for_parent || p_idx != nidx) {
+ sub_path.insert(0, names[nodes[nidx].name]);
}
- if (nodes[nidx].parent&FLAG_ID_IS_PATH) {
- base_path=node_paths[nodes[nidx].parent&FLAG_MASK];
+ if (nodes[nidx].parent & FLAG_ID_IS_PATH) {
+ base_path = node_paths[nodes[nidx].parent & FLAG_MASK];
break;
} else {
- nidx=nodes[nidx].parent&FLAG_MASK;
+ nidx = nodes[nidx].parent & FLAG_MASK;
}
}
- for(int i=base_path.get_name_count()-1;i>=0;i--) {
- sub_path.insert(0,base_path.get_name(i));
+ for (int i = base_path.get_name_count() - 1; i >= 0; i--) {
+ sub_path.insert(0, base_path.get_name(i));
}
if (sub_path.empty()) {
return NodePath(".");
}
- return NodePath(sub_path,false);
-
+ return NodePath(sub_path, false);
}
int SceneState::get_node_property_count(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),-1);
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), -1);
return nodes[p_idx].properties.size();
-
}
-StringName SceneState::get_node_property_name(int p_idx,int p_prop) const{
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),StringName());
- ERR_FAIL_INDEX_V(p_prop,nodes[p_idx].properties.size(),StringName());
+StringName SceneState::get_node_property_name(int p_idx, int p_prop) const {
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), StringName());
+ ERR_FAIL_INDEX_V(p_prop, nodes[p_idx].properties.size(), StringName());
return names[nodes[p_idx].properties[p_prop].name];
-
}
-Variant SceneState::get_node_property_value(int p_idx,int p_prop) const{
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),Variant());
- ERR_FAIL_INDEX_V(p_prop,nodes[p_idx].properties.size(),Variant());
+Variant SceneState::get_node_property_value(int p_idx, int p_prop) const {
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), Variant());
+ ERR_FAIL_INDEX_V(p_prop, nodes[p_idx].properties.size(), Variant());
return variants[nodes[p_idx].properties[p_prop].value];
}
-
NodePath SceneState::get_node_owner_path(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,nodes.size(),NodePath());
- if (nodes[p_idx].owner<0 || nodes[p_idx].owner==NO_PARENT_SAVED)
+ ERR_FAIL_INDEX_V(p_idx, nodes.size(), NodePath());
+ if (nodes[p_idx].owner < 0 || nodes[p_idx].owner == NO_PARENT_SAVED)
return NodePath(); //root likely
- if (nodes[p_idx].owner&FLAG_ID_IS_PATH) {
- return node_paths[nodes[p_idx].owner&FLAG_MASK];
+ if (nodes[p_idx].owner & FLAG_ID_IS_PATH) {
+ return node_paths[nodes[p_idx].owner & FLAG_MASK];
} else {
- return get_node_path(nodes[p_idx].owner&FLAG_MASK);
+ return get_node_path(nodes[p_idx].owner & FLAG_MASK);
}
}
@@ -1497,91 +1424,86 @@ int SceneState::get_connection_count() const {
return connections.size();
}
-NodePath SceneState::get_connection_source(int p_idx) const{
+NodePath SceneState::get_connection_source(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,connections.size(),NodePath());
- if (connections[p_idx].from&FLAG_ID_IS_PATH) {
- return node_paths[connections[p_idx].from&FLAG_MASK];
+ ERR_FAIL_INDEX_V(p_idx, connections.size(), NodePath());
+ if (connections[p_idx].from & FLAG_ID_IS_PATH) {
+ return node_paths[connections[p_idx].from & FLAG_MASK];
} else {
- return get_node_path(connections[p_idx].from&FLAG_MASK);
+ return get_node_path(connections[p_idx].from & FLAG_MASK);
}
-
}
-StringName SceneState::get_connection_signal(int p_idx) const{
+StringName SceneState::get_connection_signal(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,connections.size(),StringName());
+ ERR_FAIL_INDEX_V(p_idx, connections.size(), StringName());
return names[connections[p_idx].signal];
-
}
-NodePath SceneState::get_connection_target(int p_idx) const{
+NodePath SceneState::get_connection_target(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,connections.size(),NodePath());
- if (connections[p_idx].to&FLAG_ID_IS_PATH) {
- return node_paths[connections[p_idx].to&FLAG_MASK];
+ ERR_FAIL_INDEX_V(p_idx, connections.size(), NodePath());
+ if (connections[p_idx].to & FLAG_ID_IS_PATH) {
+ return node_paths[connections[p_idx].to & FLAG_MASK];
} else {
- return get_node_path(connections[p_idx].to&FLAG_MASK);
+ return get_node_path(connections[p_idx].to & FLAG_MASK);
}
-
}
-StringName SceneState::get_connection_method(int p_idx) const{
+StringName SceneState::get_connection_method(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,connections.size(),StringName());
+ ERR_FAIL_INDEX_V(p_idx, connections.size(), StringName());
return names[connections[p_idx].method];
-
}
+int SceneState::get_connection_flags(int p_idx) const {
-int SceneState::get_connection_flags(int p_idx) const{
-
- ERR_FAIL_INDEX_V(p_idx,connections.size(),-1);
+ ERR_FAIL_INDEX_V(p_idx, connections.size(), -1);
return connections[p_idx].flags;
}
Array SceneState::get_connection_binds(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,connections.size(),Array());
+ ERR_FAIL_INDEX_V(p_idx, connections.size(), Array());
Array binds;
- for(int i=0;i<connections[p_idx].binds.size();i++) {
+ for (int i = 0; i < connections[p_idx].binds.size(); i++) {
binds.push_back(variants[connections[p_idx].binds[i]]);
}
return binds;
}
-bool SceneState::has_connection(const NodePath& p_node_from, const StringName& p_signal, const NodePath& p_node_to, const StringName& p_method) {
+bool SceneState::has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) {
// this method cannot be const because of this
- Ref<SceneState> ss=this;
+ Ref<SceneState> ss = this;
do {
- for(int i=0;i<ss->connections.size();i++) {
+ for (int i = 0; i < ss->connections.size(); i++) {
const ConnectionData &c = ss->connections[i];
NodePath np_from;
- if (c.from&FLAG_ID_IS_PATH) {
- np_from=ss->node_paths[c.from&FLAG_MASK];
+ if (c.from & FLAG_ID_IS_PATH) {
+ np_from = ss->node_paths[c.from & FLAG_MASK];
} else {
- np_from=ss->get_node_path(c.from);
+ np_from = ss->get_node_path(c.from);
}
NodePath np_to;
- if (c.to&FLAG_ID_IS_PATH) {
- np_to=ss->node_paths[c.to&FLAG_MASK];
+ if (c.to & FLAG_ID_IS_PATH) {
+ np_to = ss->node_paths[c.to & FLAG_MASK];
} else {
- np_to=ss->get_node_path(c.to);
+ np_to = ss->get_node_path(c.to);
}
- StringName sn_signal=ss->names[c.signal];
- StringName sn_method=ss->names[c.method];
+ StringName sn_signal = ss->names[c.signal];
+ StringName sn_method = ss->names[c.method];
- if (np_from==p_node_from && sn_signal==p_signal && np_to==p_node_to && sn_method==p_method) {
+ if (np_from == p_node_from && sn_signal == p_signal && np_to == p_node_to && sn_method == p_method) {
return true;
}
}
- ss=ss->_get_base_scene_state();
+ ss = ss->_get_base_scene_state();
} while (ss.is_valid());
return false;
@@ -1592,88 +1514,86 @@ Vector<NodePath> SceneState::get_editable_instances() const {
}
//add
-int SceneState::add_name(const StringName& p_name) {
+int SceneState::add_name(const StringName &p_name) {
names.push_back(p_name);
- return names.size()-1;
+ return names.size() - 1;
}
-int SceneState::find_name(const StringName& p_name) const {
+int SceneState::find_name(const StringName &p_name) const {
- for(int i=0;i<names.size();i++) {
- if (names[i]==p_name)
+ for (int i = 0; i < names.size(); i++) {
+ if (names[i] == p_name)
return i;
}
return -1;
}
-int SceneState::add_value(const Variant& p_value) {
+int SceneState::add_value(const Variant &p_value) {
variants.push_back(p_value);
- return variants.size()-1;
+ return variants.size() - 1;
}
-int SceneState::add_node_path(const NodePath& p_path){
+int SceneState::add_node_path(const NodePath &p_path) {
node_paths.push_back(p_path);
- return (node_paths.size()-1)|FLAG_ID_IS_PATH;
+ return (node_paths.size() - 1) | FLAG_ID_IS_PATH;
}
-int SceneState::add_node(int p_parent,int p_owner,int p_type,int p_name, int p_instance){
+int SceneState::add_node(int p_parent, int p_owner, int p_type, int p_name, int p_instance) {
NodeData nd;
- nd.parent=p_parent;
- nd.owner=p_owner;
- nd.type=p_type;
- nd.name=p_name;
- nd.instance=p_instance;
+ nd.parent = p_parent;
+ nd.owner = p_owner;
+ nd.type = p_type;
+ nd.name = p_name;
+ nd.instance = p_instance;
nodes.push_back(nd);
- return nodes.size()-1;
+ return nodes.size() - 1;
}
-void SceneState::add_node_property(int p_node,int p_name,int p_value){
+void SceneState::add_node_property(int p_node, int p_name, int p_value) {
- ERR_FAIL_INDEX(p_node,nodes.size());
- ERR_FAIL_INDEX(p_name,names.size());
- ERR_FAIL_INDEX(p_value,variants.size());
+ ERR_FAIL_INDEX(p_node, nodes.size());
+ ERR_FAIL_INDEX(p_name, names.size());
+ ERR_FAIL_INDEX(p_value, variants.size());
NodeData::Property prop;
- prop.name=p_name;
- prop.value=p_value;
+ prop.name = p_name;
+ prop.value = p_value;
nodes[p_node].properties.push_back(prop);
}
-void SceneState::add_node_group(int p_node,int p_group){
+void SceneState::add_node_group(int p_node, int p_group) {
- ERR_FAIL_INDEX(p_node,nodes.size());
- ERR_FAIL_INDEX(p_group,names.size());
+ ERR_FAIL_INDEX(p_node, nodes.size());
+ ERR_FAIL_INDEX(p_group, names.size());
nodes[p_node].groups.push_back(p_group);
-
}
-void SceneState::set_base_scene(int p_idx){
+void SceneState::set_base_scene(int p_idx) {
- ERR_FAIL_INDEX(p_idx,variants.size());
- base_scene_idx=p_idx;
+ ERR_FAIL_INDEX(p_idx, variants.size());
+ base_scene_idx = p_idx;
}
-void SceneState::add_connection(int p_from,int p_to, int p_signal, int p_method, int p_flags,const Vector<int>& p_binds){
+void SceneState::add_connection(int p_from, int p_to, int p_signal, int p_method, int p_flags, const Vector<int> &p_binds) {
- ERR_FAIL_INDEX(p_signal,names.size());
- ERR_FAIL_INDEX(p_method,names.size());
+ ERR_FAIL_INDEX(p_signal, names.size());
+ ERR_FAIL_INDEX(p_method, names.size());
- for(int i=0;i<p_binds.size();i++) {
- ERR_FAIL_INDEX(p_binds[i],variants.size());
+ for (int i = 0; i < p_binds.size(); i++) {
+ ERR_FAIL_INDEX(p_binds[i], variants.size());
}
ConnectionData c;
- c.from=p_from;
- c.to=p_to;
- c.signal=p_signal;
- c.method=p_method;
- c.flags=p_flags;
- c.binds=p_binds;
+ c.from = p_from;
+ c.to = p_to;
+ c.signal = p_signal;
+ c.method = p_method;
+ c.flags = p_flags;
+ c.binds = p_binds;
connections.push_back(c);
-
}
-void SceneState::add_editable_instance(const NodePath& p_path){
+void SceneState::add_editable_instance(const NodePath &p_path) {
editable_instances.push_back(p_path);
}
@@ -1683,7 +1603,7 @@ DVector<String> SceneState::_get_node_groups(int p_idx) const {
Vector<StringName> groups = get_node_groups(p_idx);
DVector<String> ret;
- for(int i=0;i<groups.size();i++)
+ for (int i = 0; i < groups.size(); i++)
ret.push_back(groups[i]);
return ret;
@@ -1693,39 +1613,36 @@ void SceneState::_bind_methods() {
//unbuild API
- ObjectTypeDB::bind_method(_MD("get_node_count"),&SceneState::get_node_count);
- ObjectTypeDB::bind_method(_MD("get_node_type","idx"),&SceneState::get_node_type);
- ObjectTypeDB::bind_method(_MD("get_node_name","idx"),&SceneState::get_node_name);
- ObjectTypeDB::bind_method(_MD("get_node_path","idx","for_parent"),&SceneState::get_node_path,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_node_owner_path","idx"),&SceneState::get_node_owner_path);
- ObjectTypeDB::bind_method(_MD("is_node_instance_placeholder","idx"),&SceneState::is_node_instance_placeholder);
- ObjectTypeDB::bind_method(_MD("get_node_instance_placeholder","idx"),&SceneState::get_node_instance_placeholder);
- ObjectTypeDB::bind_method(_MD("get_node_instance:PackedScene","idx"),&SceneState::get_node_instance);
- ObjectTypeDB::bind_method(_MD("get_node_groups","idx"),&SceneState::_get_node_groups);
- ObjectTypeDB::bind_method(_MD("get_node_property_count","idx"),&SceneState::get_node_property_count);
- ObjectTypeDB::bind_method(_MD("get_node_property_name","idx","prop_idx"),&SceneState::get_node_property_name);
- ObjectTypeDB::bind_method(_MD("get_node_property_value","idx","prop_idx"),&SceneState::get_node_property_value);
- ObjectTypeDB::bind_method(_MD("get_connection_count"),&SceneState::get_connection_count);
- ObjectTypeDB::bind_method(_MD("get_connection_source","idx"),&SceneState::get_connection_source);
- ObjectTypeDB::bind_method(_MD("get_connection_signal","idx"),&SceneState::get_connection_signal);
- ObjectTypeDB::bind_method(_MD("get_connection_target","idx"),&SceneState::get_connection_target);
- ObjectTypeDB::bind_method(_MD("get_connection_method","idx"),&SceneState::get_connection_method);
- ObjectTypeDB::bind_method(_MD("get_connection_flags","idx"),&SceneState::get_connection_flags);
- ObjectTypeDB::bind_method(_MD("get_connection_binds","idx"),&SceneState::get_connection_binds);
+ ObjectTypeDB::bind_method(_MD("get_node_count"), &SceneState::get_node_count);
+ ObjectTypeDB::bind_method(_MD("get_node_type", "idx"), &SceneState::get_node_type);
+ ObjectTypeDB::bind_method(_MD("get_node_name", "idx"), &SceneState::get_node_name);
+ ObjectTypeDB::bind_method(_MD("get_node_path", "idx", "for_parent"), &SceneState::get_node_path, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("get_node_owner_path", "idx"), &SceneState::get_node_owner_path);
+ ObjectTypeDB::bind_method(_MD("is_node_instance_placeholder", "idx"), &SceneState::is_node_instance_placeholder);
+ ObjectTypeDB::bind_method(_MD("get_node_instance_placeholder", "idx"), &SceneState::get_node_instance_placeholder);
+ ObjectTypeDB::bind_method(_MD("get_node_instance:PackedScene", "idx"), &SceneState::get_node_instance);
+ ObjectTypeDB::bind_method(_MD("get_node_groups", "idx"), &SceneState::_get_node_groups);
+ ObjectTypeDB::bind_method(_MD("get_node_property_count", "idx"), &SceneState::get_node_property_count);
+ ObjectTypeDB::bind_method(_MD("get_node_property_name", "idx", "prop_idx"), &SceneState::get_node_property_name);
+ ObjectTypeDB::bind_method(_MD("get_node_property_value", "idx", "prop_idx"), &SceneState::get_node_property_value);
+ ObjectTypeDB::bind_method(_MD("get_connection_count"), &SceneState::get_connection_count);
+ ObjectTypeDB::bind_method(_MD("get_connection_source", "idx"), &SceneState::get_connection_source);
+ ObjectTypeDB::bind_method(_MD("get_connection_signal", "idx"), &SceneState::get_connection_signal);
+ ObjectTypeDB::bind_method(_MD("get_connection_target", "idx"), &SceneState::get_connection_target);
+ ObjectTypeDB::bind_method(_MD("get_connection_method", "idx"), &SceneState::get_connection_method);
+ ObjectTypeDB::bind_method(_MD("get_connection_flags", "idx"), &SceneState::get_connection_flags);
+ ObjectTypeDB::bind_method(_MD("get_connection_binds", "idx"), &SceneState::get_connection_binds);
}
SceneState::SceneState() {
- base_scene_idx=-1;
- last_modified_time=0;
+ base_scene_idx = -1;
+ last_modified_time = 0;
}
-
////////////////
-
-
-void PackedScene::_set_bundled_scene(const Dictionary& d) {
+void PackedScene::_set_bundled_scene(const Dictionary &d) {
state->set_bundled_scene(d);
}
@@ -1735,7 +1652,6 @@ Dictionary PackedScene::_get_bundled_scene() const {
return state->get_bundled_scene();
}
-
Error PackedScene::pack(Node *p_scene) {
return state->pack(p_scene);
@@ -1756,7 +1672,7 @@ Node *PackedScene::instance(bool p_gen_edit_state) const {
#ifndef TOOLS_ENABLED
if (p_gen_edit_state) {
ERR_EXPLAIN("Edit state is only for editors, does not work without tools compiled");
- ERR_FAIL_COND_V(p_gen_edit_state,NULL);
+ ERR_FAIL_COND_V(p_gen_edit_state, NULL);
}
#endif
@@ -1768,10 +1684,9 @@ Node *PackedScene::instance(bool p_gen_edit_state) const {
s->set_scene_instance_state(state);
}
- if (get_path()!="" && get_path().find("::")==-1)
+ if (get_path() != "" && get_path().find("::") == -1)
s->set_filename(get_path());
-
s->notification(Node::NOTIFICATION_INSTANCED);
return s;
@@ -1779,17 +1694,16 @@ Node *PackedScene::instance(bool p_gen_edit_state) const {
void PackedScene::replace_state(Ref<SceneState> p_by) {
- state=p_by;
+ state = p_by;
state->set_path(get_path());
#ifdef TOOLS_ENABLED
state->set_last_modified_time(get_last_modified_time());
#endif
-
}
void PackedScene::recreate_state() {
- state = Ref<SceneState>( memnew( SceneState ));
+ state = Ref<SceneState>(memnew(SceneState));
state->set_path(get_path());
#ifdef TOOLS_ENABLED
state->set_last_modified_time(get_last_modified_time());
@@ -1801,28 +1715,25 @@ Ref<SceneState> PackedScene::get_state() {
return state;
}
-void PackedScene::set_path(const String& p_path,bool p_take_over) {
+void PackedScene::set_path(const String &p_path, bool p_take_over) {
state->set_path(p_path);
- Resource::set_path(p_path,p_take_over);
+ Resource::set_path(p_path, p_take_over);
}
-
void PackedScene::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("pack","path:Node"),&PackedScene::pack);
- ObjectTypeDB::bind_method(_MD("instance:Node","gen_edit_state"),&PackedScene::instance,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("can_instance"),&PackedScene::can_instance);
- ObjectTypeDB::bind_method(_MD("_set_bundled_scene"),&PackedScene::_set_bundled_scene);
- ObjectTypeDB::bind_method(_MD("_get_bundled_scene"),&PackedScene::_get_bundled_scene);
- ObjectTypeDB::bind_method(_MD("get_state:SceneState"),&PackedScene::get_state);
-
- ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled"),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene"));
+ ObjectTypeDB::bind_method(_MD("pack", "path:Node"), &PackedScene::pack);
+ ObjectTypeDB::bind_method(_MD("instance:Node", "gen_edit_state"), &PackedScene::instance, DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("can_instance"), &PackedScene::can_instance);
+ ObjectTypeDB::bind_method(_MD("_set_bundled_scene"), &PackedScene::_set_bundled_scene);
+ ObjectTypeDB::bind_method(_MD("_get_bundled_scene"), &PackedScene::_get_bundled_scene);
+ ObjectTypeDB::bind_method(_MD("get_state:SceneState"), &PackedScene::get_state);
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_bundled"), _SCS("_set_bundled_scene"), _SCS("_get_bundled_scene"));
}
PackedScene::PackedScene() {
- state = Ref<SceneState>( memnew( SceneState ));
-
+ state = Ref<SceneState>(memnew(SceneState));
}
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index c7c30354e..6f096bdb7 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -32,23 +32,21 @@
#include "resource.h"
#include "scene/main/node.h"
-
class SceneState : public Reference {
- OBJ_TYPE( SceneState, Reference );
-
+ OBJ_TYPE(SceneState, Reference);
Vector<StringName> names;
Vector<Variant> variants;
Vector<NodePath> node_paths;
Vector<NodePath> editable_instances;
- mutable HashMap<NodePath,int> node_path_cache;
- mutable Map<int,int> base_scene_node_remap;
+ mutable HashMap<NodePath, int> node_path_cache;
+ mutable Map<int, int> base_scene_node_remap;
int base_scene_idx;
enum {
- NO_PARENT_SAVED=0x7FFFFFFF,
+ NO_PARENT_SAVED = 0x7FFFFFFF,
};
struct NodeData {
@@ -67,13 +65,12 @@ class SceneState : public Reference {
Vector<Property> properties;
Vector<int> groups;
-
};
struct PackState {
Ref<SceneState> state;
int node;
- PackState() { node=-1; }
+ PackState() { node = -1; }
};
Vector<NodeData> nodes;
@@ -90,9 +87,8 @@ class SceneState : public Reference {
Vector<ConnectionData> connections;
-
- Error _parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map);
- Error _parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map);
+ Error _parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map);
+ Error _parse_connections(Node *p_owner, Node *p_node, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map, Map<Node *, int> &nodepath_map);
String path;
@@ -107,27 +103,24 @@ class SceneState : public Reference {
int _find_base_scene_node_remap_key(int p_idx) const;
protected:
-
static void _bind_methods();
public:
-
enum {
- FLAG_ID_IS_PATH=(1<<30),
- TYPE_INSTANCED=0x7FFFFFFF,
- FLAG_INSTANCE_IS_PLACEHOLDER=(1<<30),
- FLAG_MASK=(1<<24)-1,
+ FLAG_ID_IS_PATH = (1 << 30),
+ TYPE_INSTANCED = 0x7FFFFFFF,
+ FLAG_INSTANCE_IS_PLACEHOLDER = (1 << 30),
+ FLAG_MASK = (1 << 24) - 1,
};
static void set_disable_placeholders(bool p_disable);
- int find_node_by_path(const NodePath& p_node) const;
- Variant get_property_value(int p_node,const StringName& p_property,bool &found) const;
- bool is_node_in_group(int p_node,const StringName& p_group) const;
- bool is_connection(int p_node,const StringName& p_signal,int p_to_node,const StringName& p_to_method) const;
-
+ int find_node_by_path(const NodePath &p_node) const;
+ Variant get_property_value(int p_node, const StringName &p_property, bool &found) const;
+ bool is_node_in_group(int p_node, const StringName &p_group) const;
+ bool is_connection(int p_node, const StringName &p_signal, int p_to_node, const StringName &p_to_method) const;
- void set_bundled_scene(const Dictionary& p_dictionary);
+ void set_bundled_scene(const Dictionary &p_dictionary);
Dictionary get_bundled_scene() const;
Error pack(Node *p_scene);
@@ -138,15 +131,14 @@ public:
void clear();
bool can_instance() const;
- Node *instance(bool p_gen_edit_state=false) const;
-
+ Node *instance(bool p_gen_edit_state = false) const;
//unbuild API
int get_node_count() const;
StringName get_node_type(int p_idx) const;
StringName get_node_name(int p_idx) const;
- NodePath get_node_path(int p_idx,bool p_for_parent=false) const;
+ NodePath get_node_path(int p_idx, bool p_for_parent = false) const;
NodePath get_node_owner_path(int p_idx) const;
Ref<PackedScene> get_node_instance(int p_idx) const;
String get_node_instance_placeholder(int p_idx) const;
@@ -154,8 +146,8 @@ public:
Vector<StringName> get_node_groups(int p_idx) const;
int get_node_property_count(int p_idx) const;
- StringName get_node_property_name(int p_idx,int p_prop) const;
- Variant get_node_property_value(int p_idx,int p_prop) const;
+ StringName get_node_property_name(int p_idx, int p_prop) const;
+ Variant get_node_property_value(int p_idx, int p_prop) const;
int get_connection_count() const;
NodePath get_connection_source(int p_idx) const;
@@ -165,58 +157,55 @@ public:
int get_connection_flags(int p_idx) const;
Array get_connection_binds(int p_idx) const;
- bool has_connection(const NodePath &p_node_from, const StringName& p_signal, const NodePath &p_node_to, const StringName& p_method);
+ bool has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method);
Vector<NodePath> get_editable_instances() const;
//build API
- int add_name(const StringName& p_name);
- int find_name(const StringName& p_name) const;
- int add_value(const Variant& p_value);
- int add_node_path(const NodePath& p_path);
- int add_node(int p_parent,int p_owner,int p_type,int p_name, int p_instance);
- void add_node_property(int p_node,int p_name,int p_value);
- void add_node_group(int p_node,int p_group);
+ int add_name(const StringName &p_name);
+ int find_name(const StringName &p_name) const;
+ int add_value(const Variant &p_value);
+ int add_node_path(const NodePath &p_path);
+ int add_node(int p_parent, int p_owner, int p_type, int p_name, int p_instance);
+ void add_node_property(int p_node, int p_name, int p_value);
+ void add_node_group(int p_node, int p_group);
void set_base_scene(int p_idx);
- void add_connection(int p_from,int p_to, int p_signal, int p_method, int p_flags,const Vector<int>& p_binds);
- void add_editable_instance(const NodePath& p_path);
+ void add_connection(int p_from, int p_to, int p_signal, int p_method, int p_flags, const Vector<int> &p_binds);
+ void add_editable_instance(const NodePath &p_path);
- virtual void set_last_modified_time(uint64_t p_time) { last_modified_time=p_time; }
+ virtual void set_last_modified_time(uint64_t p_time) { last_modified_time = p_time; }
uint64_t get_last_modified_time() const { return last_modified_time; }
-
SceneState();
};
class PackedScene : public Resource {
- OBJ_TYPE(PackedScene, Resource );
+ OBJ_TYPE(PackedScene, Resource);
RES_BASE_EXTENSION("scn");
Ref<SceneState> state;
- void _set_bundled_scene(const Dictionary& p_scene);
+ void _set_bundled_scene(const Dictionary &p_scene);
Dictionary _get_bundled_scene() const;
protected:
-
virtual bool editor_can_reload_from_file() { return false; } // this is handled by editor better
static void _bind_methods();
-public:
-
+public:
Error pack(Node *p_scene);
void clear();
bool can_instance() const;
- Node *instance(bool p_gen_edit_state=false) const;
+ Node *instance(bool p_gen_edit_state = false) const;
void recreate_state();
void replace_state(Ref<SceneState> p_by);
- virtual void set_path(const String& p_path,bool p_take_over=false);
+ virtual void set_path(const String &p_path, bool p_take_over = false);
#ifdef TOOLS_ENABLED
virtual void set_last_modified_time(uint64_t p_time) { state->set_last_modified_time(p_time); }
@@ -224,7 +213,6 @@ public:
Ref<SceneState> get_state();
PackedScene();
-
};
#endif // SCENE_PRELOADER_H
diff --git a/scene/resources/plane_shape.cpp b/scene/resources/plane_shape.cpp
index c739d24da..2c1b2bf05 100644
--- a/scene/resources/plane_shape.cpp
+++ b/scene/resources/plane_shape.cpp
@@ -38,11 +38,11 @@ Vector<Vector3> PlaneShape::_gen_debug_mesh_lines() {
Vector3 n1 = p.get_any_perpendicular_normal();
Vector3 n2 = p.normal.cross(n1).normalized();
- Vector3 pface[4]={
- p.normal*p.d+n1*10.0+n2*10.0,
- p.normal*p.d+n1*10.0+n2*-10.0,
- p.normal*p.d+n1*-10.0+n2*-10.0,
- p.normal*p.d+n1*-10.0+n2*10.0,
+ Vector3 pface[4] = {
+ p.normal * p.d + n1 * 10.0 + n2 * 10.0,
+ p.normal * p.d + n1 * 10.0 + n2 * -10.0,
+ p.normal * p.d + n1 * -10.0 + n2 * -10.0,
+ p.normal * p.d + n1 * -10.0 + n2 * 10.0,
};
points.push_back(pface[0]);
@@ -53,20 +53,20 @@ Vector<Vector3> PlaneShape::_gen_debug_mesh_lines() {
points.push_back(pface[3]);
points.push_back(pface[3]);
points.push_back(pface[0]);
- points.push_back(p.normal*p.d);
- points.push_back(p.normal*p.d+p.normal*3);
+ points.push_back(p.normal * p.d);
+ points.push_back(p.normal * p.d + p.normal * 3);
return points;
}
void PlaneShape::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),plane);
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), plane);
}
void PlaneShape::set_plane(Plane p_plane) {
- plane=p_plane;
+ plane = p_plane;
_update_shape();
notify_change_to_owners();
_change_notify("plane");
@@ -77,17 +77,16 @@ Plane PlaneShape::get_plane() const {
return plane;
}
-
void PlaneShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_plane","plane"),&PlaneShape::set_plane);
- ObjectTypeDB::bind_method(_MD("get_plane"),&PlaneShape::get_plane);
-
- ADD_PROPERTY( PropertyInfo(Variant::PLANE,"plane"), _SCS("set_plane"), _SCS("get_plane") );
+ ObjectTypeDB::bind_method(_MD("set_plane", "plane"), &PlaneShape::set_plane);
+ ObjectTypeDB::bind_method(_MD("get_plane"), &PlaneShape::get_plane);
+ ADD_PROPERTY(PropertyInfo(Variant::PLANE, "plane"), _SCS("set_plane"), _SCS("get_plane"));
}
-PlaneShape::PlaneShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) {
+PlaneShape::PlaneShape()
+ : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) {
- set_plane(Plane(0,1,0,0));
+ set_plane(Plane(0, 1, 0, 0));
}
diff --git a/scene/resources/plane_shape.h b/scene/resources/plane_shape.h
index d911ce78a..9117d7d54 100644
--- a/scene/resources/plane_shape.h
+++ b/scene/resources/plane_shape.h
@@ -33,17 +33,16 @@
class PlaneShape : public Shape {
- OBJ_TYPE(PlaneShape,Shape);
+ OBJ_TYPE(PlaneShape, Shape);
Plane plane;
protected:
-
static void _bind_methods();
virtual void _update_shape();
virtual Vector<Vector3> _gen_debug_mesh_lines();
-public:
+public:
void set_plane(Plane p_plane);
Plane get_plane() const;
diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp
index 5ab9618e0..c6203bb99 100644
--- a/scene/resources/polygon_path_finder.cpp
+++ b/scene/resources/polygon_path_finder.cpp
@@ -29,107 +29,98 @@
#include "polygon_path_finder.h"
#include "geometry.h"
+bool PolygonPathFinder::_is_point_inside(const Vector2 &p_point) const {
-bool PolygonPathFinder::_is_point_inside(const Vector2& p_point) const {
+ int crosses = 0;
- int crosses=0;
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
-
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
-
-
- const Edge& e=E->get();
+ const Edge &e = E->get();
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
-
- if (Geometry::segment_intersects_segment_2d(a,b,p_point,outside_point,NULL)) {
+ if (Geometry::segment_intersects_segment_2d(a, b, p_point, outside_point, NULL)) {
crosses++;
}
}
- return crosses&1;
+ return crosses & 1;
}
-void PolygonPathFinder::setup(const Vector<Vector2>& p_points, const Vector<int>& p_connections) {
-
+void PolygonPathFinder::setup(const Vector<Vector2> &p_points, const Vector<int> &p_connections) {
- ERR_FAIL_COND(p_connections.size()&1);
+ ERR_FAIL_COND(p_connections.size() & 1);
points.clear();
edges.clear();
//insert points
- int point_count=p_points.size();
- points.resize(point_count+2);
- bounds=Rect2();
+ int point_count = p_points.size();
+ points.resize(point_count + 2);
+ bounds = Rect2();
- for(int i=0;i<p_points.size();i++) {
+ for (int i = 0; i < p_points.size(); i++) {
- points[i].pos=p_points[i];
- points[i].penalty=0;
+ points[i].pos = p_points[i];
+ points[i].penalty = 0;
- outside_point.x = i==0?p_points[0].x:(MAX( p_points[i].x, outside_point.x ));
- outside_point.y = i==0?p_points[0].y:(MAX( p_points[i].y, outside_point.y ));
+ outside_point.x = i == 0 ? p_points[0].x : (MAX(p_points[i].x, outside_point.x));
+ outside_point.y = i == 0 ? p_points[0].y : (MAX(p_points[i].y, outside_point.y));
- if (i==0) {
- bounds.pos=points[i].pos;
+ if (i == 0) {
+ bounds.pos = points[i].pos;
} else {
bounds.expand_to(points[i].pos);
}
}
- outside_point.x+=20.451+Math::randf()*10.2039;
- outside_point.y+=21.193+Math::randf()*12.5412;
+ outside_point.x += 20.451 + Math::randf() * 10.2039;
+ outside_point.y += 21.193 + Math::randf() * 12.5412;
//insert edges (which are also connetions)
- for(int i=0;i<p_connections.size();i+=2) {
+ for (int i = 0; i < p_connections.size(); i += 2) {
- Edge e(p_connections[i],p_connections[i+1]);
- ERR_FAIL_INDEX(e.points[0],point_count);
- ERR_FAIL_INDEX(e.points[1],point_count);
- points[p_connections[i]].connections.insert(p_connections[i+1]);
- points[p_connections[i+1]].connections.insert(p_connections[i]);
+ Edge e(p_connections[i], p_connections[i + 1]);
+ ERR_FAIL_INDEX(e.points[0], point_count);
+ ERR_FAIL_INDEX(e.points[1], point_count);
+ points[p_connections[i]].connections.insert(p_connections[i + 1]);
+ points[p_connections[i + 1]].connections.insert(p_connections[i]);
edges.insert(e);
}
-
//fill the remaining connections based on visibility
- for(int i=0;i<point_count;i++) {
+ for (int i = 0; i < point_count; i++) {
- for(int j=i+1;j<point_count;j++) {
+ for (int j = i + 1; j < point_count; j++) {
- if (edges.has(Edge(i,j)))
+ if (edges.has(Edge(i, j)))
continue; //if in edge ignore
- Vector2 from=points[i].pos;
- Vector2 to=points[j].pos;
+ Vector2 from = points[i].pos;
+ Vector2 to = points[j].pos;
- if (!_is_point_inside(from*0.5+to*0.5)) //connection between points in inside space
+ if (!_is_point_inside(from * 0.5 + to * 0.5)) //connection between points in inside space
continue;
- bool valid=true;
+ bool valid = true;
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge& e=E->get();
- if (e.points[0]==i || e.points[1]==i || e.points[0]==j || e.points[1]==j )
+ const Edge &e = E->get();
+ if (e.points[0] == i || e.points[1] == i || e.points[0] == j || e.points[1] == j)
continue;
-
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
-
- if (Geometry::segment_intersects_segment_2d(a,b,from,to,NULL)) {
- valid=false;
+ if (Geometry::segment_intersects_segment_2d(a, b, from, to, NULL)) {
+ valid = false;
break;
}
-
}
if (valid) {
@@ -140,92 +131,86 @@ void PolygonPathFinder::setup(const Vector<Vector2>& p_points, const Vector<int>
}
}
-
-Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector2& p_to) {
+Vector<Vector2> PolygonPathFinder::find_path(const Vector2 &p_from, const Vector2 &p_to) {
Vector<Vector2> path;
- Vector2 from=p_from;
- Vector2 to=p_to;
- Edge ignore_from_edge(-1,-1);
- Edge ignore_to_edge(-1,-1);
+ Vector2 from = p_from;
+ Vector2 to = p_to;
+ Edge ignore_from_edge(-1, -1);
+ Edge ignore_to_edge(-1, -1);
if (!_is_point_inside(from)) {
- float closest_dist=1e20;
+ float closest_dist = 1e20;
Vector2 closest_point;
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge& e=E->get();
- Vector2 seg[2]={
+ const Edge &e = E->get();
+ Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
};
-
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(from,seg);
+ Vector2 closest = Geometry::get_closest_point_to_segment_2d(from, seg);
float d = from.distance_squared_to(closest);
- if (d<closest_dist) {
- ignore_from_edge=E->get();
- closest_dist=d;
- closest_point=closest;
+ if (d < closest_dist) {
+ ignore_from_edge = E->get();
+ closest_dist = d;
+ closest_point = closest;
}
}
- from=closest_point;
+ from = closest_point;
};
-
if (!_is_point_inside(to)) {
- float closest_dist=1e20;
+ float closest_dist = 1e20;
Vector2 closest_point;
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge& e=E->get();
- Vector2 seg[2]={
+ const Edge &e = E->get();
+ Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
};
-
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(to,seg);
+ Vector2 closest = Geometry::get_closest_point_to_segment_2d(to, seg);
float d = to.distance_squared_to(closest);
- if (d<closest_dist) {
- ignore_to_edge=E->get();
- closest_dist=d;
- closest_point=closest;
+ if (d < closest_dist) {
+ ignore_to_edge = E->get();
+ closest_dist = d;
+ closest_point = closest;
}
}
- to=closest_point;
+ to = closest_point;
};
//test direct connection
{
- bool can_see_eachother=true;
+ bool can_see_eachother = true;
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge& e=E->get();
- if (e.points[0]==ignore_from_edge.points[0] && e.points[1]==ignore_from_edge.points[1])
+ const Edge &e = E->get();
+ if (e.points[0] == ignore_from_edge.points[0] && e.points[1] == ignore_from_edge.points[1])
continue;
- if (e.points[0]==ignore_to_edge.points[0] && e.points[1]==ignore_to_edge.points[1])
+ if (e.points[0] == ignore_to_edge.points[0] && e.points[1] == ignore_to_edge.points[1])
continue;
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
-
- if (Geometry::segment_intersects_segment_2d(a,b,from,to,NULL)) {
- can_see_eachother=false;
+ if (Geometry::segment_intersects_segment_2d(a, b, from, to, NULL)) {
+ can_see_eachother = false;
break;
}
-
}
if (can_see_eachother) {
@@ -238,85 +223,72 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
//add to graph
- int aidx = points.size()-2;
- int bidx = points.size()-1;
- points[aidx].pos=from;
- points[bidx].pos=to;
- points[aidx].distance=0;
- points[bidx].distance=0;
- points[aidx].prev=-1;
- points[bidx].prev=-1;
- points[aidx].penalty=0;
- points[bidx].penalty=0;
-
-
-
- for(int i=0;i<points.size()-2;i++) {
+ int aidx = points.size() - 2;
+ int bidx = points.size() - 1;
+ points[aidx].pos = from;
+ points[bidx].pos = to;
+ points[aidx].distance = 0;
+ points[bidx].distance = 0;
+ points[aidx].prev = -1;
+ points[bidx].prev = -1;
+ points[aidx].penalty = 0;
+ points[bidx].penalty = 0;
+ for (int i = 0; i < points.size() - 2; i++) {
- bool valid_a=true;
- bool valid_b=true;
- points[i].prev=-1;
- points[i].distance=0;
-
- if (!_is_point_inside(from*0.5+points[i].pos*0.5)) {
- valid_a=false;
+ bool valid_a = true;
+ bool valid_b = true;
+ points[i].prev = -1;
+ points[i].distance = 0;
+ if (!_is_point_inside(from * 0.5 + points[i].pos * 0.5)) {
+ valid_a = false;
}
-
- if (!_is_point_inside(to*0.5+points[i].pos*0.5)) {
- valid_b=false;
-
+ if (!_is_point_inside(to * 0.5 + points[i].pos * 0.5)) {
+ valid_b = false;
}
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
+ const Edge &e = E->get();
- const Edge& e=E->get();
-
- if (e.points[0]==i || e.points[1]==i)
+ if (e.points[0] == i || e.points[1] == i)
continue;
-
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
if (valid_a) {
- if (e.points[0]!=ignore_from_edge.points[1] &&
- e.points[1]!=ignore_from_edge.points[1] &&
- e.points[0]!=ignore_from_edge.points[0] &&
- e.points[1]!=ignore_from_edge.points[0]) {
+ if (e.points[0] != ignore_from_edge.points[1] &&
+ e.points[1] != ignore_from_edge.points[1] &&
+ e.points[0] != ignore_from_edge.points[0] &&
+ e.points[1] != ignore_from_edge.points[0]) {
-
- if (Geometry::segment_intersects_segment_2d(a,b,from,points[i].pos,NULL)) {
- valid_a=false;
+ if (Geometry::segment_intersects_segment_2d(a, b, from, points[i].pos, NULL)) {
+ valid_a = false;
}
}
}
if (valid_b) {
- if (e.points[0]!=ignore_to_edge.points[1] &&
- e.points[1]!=ignore_to_edge.points[1] &&
- e.points[0]!=ignore_to_edge.points[0] &&
- e.points[1]!=ignore_to_edge.points[0]) {
-
+ if (e.points[0] != ignore_to_edge.points[1] &&
+ e.points[1] != ignore_to_edge.points[1] &&
+ e.points[0] != ignore_to_edge.points[0] &&
+ e.points[1] != ignore_to_edge.points[0]) {
- if (Geometry::segment_intersects_segment_2d(a,b,to,points[i].pos,NULL)) {
- valid_b=false;
+ if (Geometry::segment_intersects_segment_2d(a, b, to, points[i].pos, NULL)) {
+ valid_b = false;
}
}
}
if (!valid_a && !valid_b)
break;
-
-
}
-
if (valid_a) {
points[i].connections.insert(aidx);
points[aidx].connections.insert(i);
@@ -326,82 +298,76 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
points[i].connections.insert(bidx);
points[bidx].connections.insert(i);
}
-
}
//solve graph
Set<int> open_list;
- points[aidx].distance=0;
- points[aidx].prev=aidx;
- for(Set<int>::Element *E=points[aidx].connections.front();E;E=E->next()) {
+ points[aidx].distance = 0;
+ points[aidx].prev = aidx;
+ for (Set<int>::Element *E = points[aidx].connections.front(); E; E = E->next()) {
open_list.insert(E->get());
- points[E->get()].distance=from.distance_to(points[E->get()].pos);
- points[E->get()].prev=aidx;
-
+ points[E->get()].distance = from.distance_to(points[E->get()].pos);
+ points[E->get()].prev = aidx;
}
+ bool found_route = false;
- bool found_route=false;
-
- while(true) {
+ while (true) {
- if (open_list.size()==0) {
+ if (open_list.size() == 0) {
printf("open list empty\n");
break;
}
//check open list
- int least_cost_point=-1;
- float least_cost=1e30;
+ int least_cost_point = -1;
+ float least_cost = 1e30;
//this could be faster (cache previous results)
- for (Set<int>::Element *E=open_list.front();E;E=E->next()) {
+ for (Set<int>::Element *E = open_list.front(); E; E = E->next()) {
- const Point& p =points[E->get()];
+ const Point &p = points[E->get()];
float cost = p.distance;
- cost+=p.pos.distance_to(to);
- cost+=p.penalty;
+ cost += p.pos.distance_to(to);
+ cost += p.penalty;
- if (cost<least_cost) {
+ if (cost < least_cost) {
- least_cost_point=E->get();
- least_cost=cost;
+ least_cost_point = E->get();
+ least_cost = cost;
}
}
-
Point &np = points[least_cost_point];
//open the neighbours for search
- for(Set<int>::Element *E=np.connections.front();E;E=E->next()) {
+ for (Set<int>::Element *E = np.connections.front(); E; E = E->next()) {
- Point& p =points[E->get()];
+ Point &p = points[E->get()];
float distance = np.pos.distance_to(p.pos) + np.distance;
- if (p.prev!=-1) {
+ if (p.prev != -1) {
//oh this was visited already, can we win the cost?
- if (p.distance>distance) {
+ if (p.distance > distance) {
- p.prev=least_cost_point; //reasign previous
- p.distance=distance;
+ p.prev = least_cost_point; //reasign previous
+ p.distance = distance;
}
} else {
//add to open neighbours
- p.prev=least_cost_point;
- p.distance=distance;
+ p.prev = least_cost_point;
+ p.distance = distance;
open_list.insert(E->get());
- if (E->get()==bidx) {
+ if (E->get() == bidx) {
//oh my reached end! stop algorithm
- found_route=true;
+ found_route = true;
break;
-
}
-
}
}
@@ -415,186 +381,179 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
int at = bidx;
path.push_back(points[at].pos);
do {
- at=points[at].prev;
+ at = points[at].prev;
path.push_back(points[at].pos);
- } while (at!=aidx);
+ } while (at != aidx);
path.invert();
}
- for(int i=0;i<points.size()-2;i++) {
+ for (int i = 0; i < points.size() - 2; i++) {
points[i].connections.erase(aidx);
points[i].connections.erase(bidx);
- points[i].prev=-1;
- points[i].distance=0;
+ points[i].prev = -1;
+ points[i].distance = 0;
}
points[aidx].connections.clear();
- points[aidx].prev=-1;
- points[aidx].distance=0;
+ points[aidx].prev = -1;
+ points[aidx].distance = 0;
points[bidx].connections.clear();
- points[bidx].prev=-1;
- points[bidx].distance=0;
+ points[bidx].prev = -1;
+ points[bidx].distance = 0;
return path;
}
-void PolygonPathFinder::_set_data(const Dictionary& p_data) {
-
+void PolygonPathFinder::_set_data(const Dictionary &p_data) {
ERR_FAIL_COND(!p_data.has("points"));
ERR_FAIL_COND(!p_data.has("connections"));
ERR_FAIL_COND(!p_data.has("segments"));
ERR_FAIL_COND(!p_data.has("bounds"));
- DVector<Vector2> p=p_data["points"];
- Array c=p_data["connections"];
+ DVector<Vector2> p = p_data["points"];
+ Array c = p_data["connections"];
- ERR_FAIL_COND(c.size()!=p.size());
+ ERR_FAIL_COND(c.size() != p.size());
if (c.size())
return;
int pc = p.size();
- points.resize(pc+2);
+ points.resize(pc + 2);
- DVector<Vector2>::Read pr=p.read();
- for(int i=0;i<pc;i++) {
- points[i].pos=pr[i];
- DVector<int> con=c[i];
- DVector<int>::Read cr=con.read();
- int cc=con.size();
- for(int j=0;j<cc;j++) {
+ DVector<Vector2>::Read pr = p.read();
+ for (int i = 0; i < pc; i++) {
+ points[i].pos = pr[i];
+ DVector<int> con = c[i];
+ DVector<int>::Read cr = con.read();
+ int cc = con.size();
+ for (int j = 0; j < cc; j++) {
points[i].connections.insert(cr[j]);
}
-
}
if (p_data.has("penalties")) {
- DVector<float> penalties=p_data["penalties"];
- if (penalties.size()==pc) {
+ DVector<float> penalties = p_data["penalties"];
+ if (penalties.size() == pc) {
DVector<float>::Read pr = penalties.read();
- for(int i=0;i<pc;i++) {
- points[i].penalty=pr[i];
+ for (int i = 0; i < pc; i++) {
+ points[i].penalty = pr[i];
}
}
}
- DVector<int> segs=p_data["segments"];
- int sc=segs.size();
- ERR_FAIL_COND(sc&1);
+ DVector<int> segs = p_data["segments"];
+ int sc = segs.size();
+ ERR_FAIL_COND(sc & 1);
DVector<int>::Read sr = segs.read();
- for(int i=0;i<sc;i+=2) {
+ for (int i = 0; i < sc; i += 2) {
- Edge e(sr[i],sr[i+1]);
+ Edge e(sr[i], sr[i + 1]);
edges.insert(e);
}
- bounds=p_data["bounds"];
-
+ bounds = p_data["bounds"];
}
-Dictionary PolygonPathFinder::_get_data() const{
+Dictionary PolygonPathFinder::_get_data() const {
Dictionary d;
DVector<Vector2> p;
DVector<int> ind;
Array connections;
- p.resize(points.size()-2);
- connections.resize(points.size()-2);
- ind.resize(edges.size()*2);
+ p.resize(points.size() - 2);
+ connections.resize(points.size() - 2);
+ ind.resize(edges.size() * 2);
DVector<float> penalties;
- penalties.resize(points.size()-2);
+ penalties.resize(points.size() - 2);
{
- DVector<Vector2>::Write wp=p.write();
- DVector<float>::Write pw=penalties.write();
+ DVector<Vector2>::Write wp = p.write();
+ DVector<float>::Write pw = penalties.write();
- for(int i=0;i<points.size()-2;i++) {
- wp[i]=points[i].pos;
- pw[i]=points[i].penalty;
+ for (int i = 0; i < points.size() - 2; i++) {
+ wp[i] = points[i].pos;
+ pw[i] = points[i].penalty;
DVector<int> c;
c.resize(points[i].connections.size());
{
- DVector<int>::Write cw=c.write();
- int idx=0;
- for (Set<int>::Element *E=points[i].connections.front();E;E=E->next()) {
- cw[idx++]=E->get();
+ DVector<int>::Write cw = c.write();
+ int idx = 0;
+ for (Set<int>::Element *E = points[i].connections.front(); E; E = E->next()) {
+ cw[idx++] = E->get();
}
}
- connections[i]=c;
+ connections[i] = c;
}
}
{
- DVector<int>::Write iw=ind.write();
- int idx=0;
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
- iw[idx++]=E->get().points[0];
- iw[idx++]=E->get().points[1];
+ DVector<int>::Write iw = ind.write();
+ int idx = 0;
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
+ iw[idx++] = E->get().points[0];
+ iw[idx++] = E->get().points[1];
}
-
}
- d["bounds"]=bounds;
- d["points"]=p;
- d["penalties"]=penalties;
- d["connections"]=connections;
- d["segments"]=ind;
+ d["bounds"] = bounds;
+ d["points"] = p;
+ d["penalties"] = penalties;
+ d["connections"] = connections;
+ d["segments"] = ind;
return d;
-
}
-bool PolygonPathFinder::is_point_inside(const Vector2& p_point) const {
+bool PolygonPathFinder::is_point_inside(const Vector2 &p_point) const {
return _is_point_inside(p_point);
}
-Vector2 PolygonPathFinder::get_closest_point(const Vector2& p_point) const {
+Vector2 PolygonPathFinder::get_closest_point(const Vector2 &p_point) const {
- float closest_dist=1e20;
+ float closest_dist = 1e20;
Vector2 closest_point;
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
- const Edge& e=E->get();
- Vector2 seg[2]={
+ const Edge &e = E->get();
+ Vector2 seg[2] = {
points[e.points[0]].pos,
points[e.points[1]].pos
};
-
- Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point,seg);
+ Vector2 closest = Geometry::get_closest_point_to_segment_2d(p_point, seg);
float d = p_point.distance_squared_to(closest);
- if (d<closest_dist) {
- closest_dist=d;
- closest_point=closest;
+ if (d < closest_dist) {
+ closest_dist = d;
+ closest_point = closest;
}
}
- ERR_FAIL_COND_V(closest_dist==1e20,Vector2());
+ ERR_FAIL_COND_V(closest_dist == 1e20, Vector2());
return closest_point;
}
-Vector<Vector2> PolygonPathFinder::get_intersections(const Vector2& p_from, const Vector2& p_to) const {
+Vector<Vector2> PolygonPathFinder::get_intersections(const Vector2 &p_from, const Vector2 &p_to) const {
Vector<Vector2> inters;
- for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
+ for (Set<Edge>::Element *E = edges.front(); E; E = E->next()) {
Vector2 a = points[E->get().points[0]].pos;
Vector2 b = points[E->get().points[1]].pos;
Vector2 res;
- if (Geometry::segment_intersects_segment_2d(a,b,p_from,p_to,&res)) {
+ if (Geometry::segment_intersects_segment_2d(a, b, p_from, p_to, &res)) {
inters.push_back(res);
}
}
return inters;
-
}
Rect2 PolygonPathFinder::get_bounds() const {
@@ -602,40 +561,34 @@ Rect2 PolygonPathFinder::get_bounds() const {
return bounds;
}
-void PolygonPathFinder::set_point_penalty(int p_point,float p_penalty) {
+void PolygonPathFinder::set_point_penalty(int p_point, float p_penalty) {
- ERR_FAIL_INDEX(p_point,points.size()-2);
- points[p_point].penalty=p_penalty;
+ ERR_FAIL_INDEX(p_point, points.size() - 2);
+ points[p_point].penalty = p_penalty;
}
float PolygonPathFinder::get_point_penalty(int p_point) const {
- ERR_FAIL_INDEX_V(p_point,points.size()-2,0);
+ ERR_FAIL_INDEX_V(p_point, points.size() - 2, 0);
return points[p_point].penalty;
-
}
-
void PolygonPathFinder::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("setup","points","connections"),&PolygonPathFinder::setup);
- ObjectTypeDB::bind_method(_MD("find_path","from","to"),&PolygonPathFinder::find_path);
- ObjectTypeDB::bind_method(_MD("get_intersections","from","to"),&PolygonPathFinder::get_intersections);
- ObjectTypeDB::bind_method(_MD("get_closest_point","point"),&PolygonPathFinder::get_closest_point);
- ObjectTypeDB::bind_method(_MD("is_point_inside","point"),&PolygonPathFinder::is_point_inside);
- ObjectTypeDB::bind_method(_MD("set_point_penalty","idx","penalty"),&PolygonPathFinder::set_point_penalty);
- ObjectTypeDB::bind_method(_MD("get_point_penalty","idx"),&PolygonPathFinder::get_point_penalty);
-
- ObjectTypeDB::bind_method(_MD("get_bounds"),&PolygonPathFinder::get_bounds);
- ObjectTypeDB::bind_method(_MD("_set_data"),&PolygonPathFinder::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&PolygonPathFinder::_get_data);
+ ObjectTypeDB::bind_method(_MD("setup", "points", "connections"), &PolygonPathFinder::setup);
+ ObjectTypeDB::bind_method(_MD("find_path", "from", "to"), &PolygonPathFinder::find_path);
+ ObjectTypeDB::bind_method(_MD("get_intersections", "from", "to"), &PolygonPathFinder::get_intersections);
+ ObjectTypeDB::bind_method(_MD("get_closest_point", "point"), &PolygonPathFinder::get_closest_point);
+ ObjectTypeDB::bind_method(_MD("is_point_inside", "point"), &PolygonPathFinder::is_point_inside);
+ ObjectTypeDB::bind_method(_MD("set_point_penalty", "idx", "penalty"), &PolygonPathFinder::set_point_penalty);
+ ObjectTypeDB::bind_method(_MD("get_point_penalty", "idx"), &PolygonPathFinder::get_point_penalty);
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
+ ObjectTypeDB::bind_method(_MD("get_bounds"), &PolygonPathFinder::get_bounds);
+ ObjectTypeDB::bind_method(_MD("_set_data"), &PolygonPathFinder::_set_data);
+ ObjectTypeDB::bind_method(_MD("_get_data"), &PolygonPathFinder::_get_data);
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data"));
}
-PolygonPathFinder::PolygonPathFinder()
-{
+PolygonPathFinder::PolygonPathFinder() {
}
-
-
diff --git a/scene/resources/polygon_path_finder.h b/scene/resources/polygon_path_finder.h
index 2459704ac..8bcc2f735 100644
--- a/scene/resources/polygon_path_finder.h
+++ b/scene/resources/polygon_path_finder.h
@@ -33,7 +33,7 @@
class PolygonPathFinder : public Resource {
- OBJ_TYPE(PolygonPathFinder,Resource);
+ OBJ_TYPE(PolygonPathFinder, Resource);
struct Point {
Vector2 pos;
@@ -47,18 +47,18 @@ class PolygonPathFinder : public Resource {
int points[2];
- _FORCE_INLINE_ bool operator<(const Edge& p_edge) const {
+ _FORCE_INLINE_ bool operator<(const Edge &p_edge) const {
- if (points[0]==p_edge.points[0])
- return points[1]<p_edge.points[1];
+ if (points[0] == p_edge.points[0])
+ return points[1] < p_edge.points[1];
else
- return points[0]<p_edge.points[0];
+ return points[0] < p_edge.points[0];
}
- Edge(int a=0, int b=0) {
+ Edge(int a = 0, int b = 0) {
- if (a>b) {
- SWAP(a,b);
+ if (a > b) {
+ SWAP(a, b);
}
points[0] = a;
points[1] = b;
@@ -71,28 +71,26 @@ class PolygonPathFinder : public Resource {
Vector<Point> points;
Set<Edge> edges;
- bool _is_point_inside(const Vector2& p_point) const;
+ bool _is_point_inside(const Vector2 &p_point) const;
- void _set_data(const Dictionary& p_data);
+ void _set_data(const Dictionary &p_data);
Dictionary _get_data() const;
-protected:
+protected:
static void _bind_methods();
-public:
+public:
+ void setup(const Vector<Vector2> &p_points, const Vector<int> &p_connections);
+ Vector<Vector2> find_path(const Vector2 &p_from, const Vector2 &p_to);
- void setup(const Vector<Vector2>& p_points, const Vector<int>& p_connections);
- Vector<Vector2> find_path(const Vector2& p_from, const Vector2& p_to);
-
- void set_point_penalty(int p_point,float p_penalty);
+ void set_point_penalty(int p_point, float p_penalty);
float get_point_penalty(int p_point) const;
- bool is_point_inside(const Vector2& p_point) const;
- Vector2 get_closest_point(const Vector2& p_point) const;
- Vector<Vector2> get_intersections(const Vector2& p_from, const Vector2& p_to) const;
+ bool is_point_inside(const Vector2 &p_point) const;
+ Vector2 get_closest_point(const Vector2 &p_point) const;
+ Vector<Vector2> get_intersections(const Vector2 &p_from, const Vector2 &p_to) const;
Rect2 get_bounds() const;
-
PolygonPathFinder();
};
diff --git a/scene/resources/ray_shape.cpp b/scene/resources/ray_shape.cpp
index cbf9c2c17..a66c93ba8 100644
--- a/scene/resources/ray_shape.cpp
+++ b/scene/resources/ray_shape.cpp
@@ -34,20 +34,20 @@ Vector<Vector3> RayShape::_gen_debug_mesh_lines() {
Vector<Vector3> points;
points.push_back(Vector3());
- points.push_back(Vector3(0,0,get_length()));
+ points.push_back(Vector3(0, 0, get_length()));
return points;
}
void RayShape::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),length);
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), length);
emit_changed();
}
void RayShape::set_length(float p_length) {
- length=p_length;
+ length = p_length;
_update_shape();
notify_change_to_owners();
}
@@ -57,17 +57,16 @@ float RayShape::get_length() const {
return length;
}
-
void RayShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_length","length"),&RayShape::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&RayShape::get_length);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"length",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_length"), _SCS("get_length") );
+ ObjectTypeDB::bind_method(_MD("set_length", "length"), &RayShape::set_length);
+ ObjectTypeDB::bind_method(_MD("get_length"), &RayShape::get_length);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_length"), _SCS("get_length"));
}
-RayShape::RayShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_RAY)) {
+RayShape::RayShape()
+ : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_RAY)) {
set_length(1.0);
}
diff --git a/scene/resources/ray_shape.h b/scene/resources/ray_shape.h
index ee56adde7..6067478a2 100644
--- a/scene/resources/ray_shape.h
+++ b/scene/resources/ray_shape.h
@@ -32,16 +32,15 @@
class RayShape : public Shape {
- OBJ_TYPE(RayShape,Shape);
+ OBJ_TYPE(RayShape, Shape);
float length;
protected:
-
static void _bind_methods();
virtual void _update_shape();
virtual Vector<Vector3> _gen_debug_mesh_lines();
-public:
+public:
void set_length(float p_length);
float get_length() const;
diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp
index 04a26bc54..d9775d22d 100644
--- a/scene/resources/rectangle_shape_2d.cpp
+++ b/scene/resources/rectangle_shape_2d.cpp
@@ -32,14 +32,13 @@
#include "servers/visual_server.h"
void RectangleShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),extents);
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), extents);
emit_changed();
}
+void RectangleShape2D::set_extents(const Vector2 &p_extents) {
-void RectangleShape2D::set_extents(const Vector2& p_extents) {
-
- extents=p_extents;
+ extents = p_extents;
_update_shape();
}
@@ -48,33 +47,27 @@ Vector2 RectangleShape2D::get_extents() const {
return extents;
}
-void RectangleShape2D::draw(const RID& p_to_rid,const Color& p_color) {
-
-
- VisualServer::get_singleton()->canvas_item_add_rect(p_to_rid,Rect2(-extents,extents*2.0),p_color);
+void RectangleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
+ VisualServer::get_singleton()->canvas_item_add_rect(p_to_rid, Rect2(-extents, extents * 2.0), p_color);
}
Rect2 RectangleShape2D::get_rect() const {
- return Rect2(-extents,extents*2.0);
-
+ return Rect2(-extents, extents * 2.0);
}
-
void RectangleShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_extents","extents"),&RectangleShape2D::set_extents);
- ObjectTypeDB::bind_method(_MD("get_extents"),&RectangleShape2D::get_extents);
-
-
-
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"extents"),_SCS("set_extents"),_SCS("get_extents") );
+ ObjectTypeDB::bind_method(_MD("set_extents", "extents"), &RectangleShape2D::set_extents);
+ ObjectTypeDB::bind_method(_MD("get_extents"), &RectangleShape2D::get_extents);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "extents"), _SCS("set_extents"), _SCS("get_extents"));
}
-RectangleShape2D::RectangleShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RECTANGLE)) {
+RectangleShape2D::RectangleShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RECTANGLE)) {
- extents=Vector2(10,10);
+ extents = Vector2(10, 10);
_update_shape();
}
diff --git a/scene/resources/rectangle_shape_2d.h b/scene/resources/rectangle_shape_2d.h
index 2c9ee04e0..d89af1a81 100644
--- a/scene/resources/rectangle_shape_2d.h
+++ b/scene/resources/rectangle_shape_2d.h
@@ -32,20 +32,20 @@
#include "scene/resources/shape_2d.h"
class RectangleShape2D : public Shape2D {
- OBJ_TYPE( RectangleShape2D, Shape2D );
+ OBJ_TYPE(RectangleShape2D, Shape2D);
Vector2 extents;
void _update_shape();
-protected:
+protected:
static void _bind_methods();
-public:
- void set_extents(const Vector2& p_extents);
+public:
+ void set_extents(const Vector2 &p_extents);
Vector2 get_extents() const;
- virtual void draw(const RID& p_to_rid,const Color& p_color);
- virtual Rect2 get_rect() const ;
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
+ virtual Rect2 get_rect() const;
RectangleShape2D();
};
diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp
index dee2ea8ea..acad538ea 100644
--- a/scene/resources/room.cpp
+++ b/scene/resources/room.cpp
@@ -30,15 +30,14 @@
#include "servers/visual_server.h"
-
RID RoomBounds::get_rid() const {
return area;
}
-void RoomBounds::set_bounds( const BSP_Tree& p_bounds ) {
+void RoomBounds::set_bounds(const BSP_Tree &p_bounds) {
- VisualServer::get_singleton()->room_set_bounds(area,p_bounds);
+ VisualServer::get_singleton()->room_set_bounds(area, p_bounds);
emit_signal("changed");
}
@@ -47,9 +46,9 @@ BSP_Tree RoomBounds::get_bounds() const {
return VisualServer::get_singleton()->room_get_bounds(area);
}
-void RoomBounds::set_geometry_hint(const DVector<Face3>& p_geometry_hint) {
+void RoomBounds::set_geometry_hint(const DVector<Face3> &p_geometry_hint) {
- geometry_hint=p_geometry_hint;
+ geometry_hint = p_geometry_hint;
}
DVector<Face3> RoomBounds::get_geometry_hint() const {
@@ -61,51 +60,45 @@ void RoomBounds::_regenerate_bsp_cubic() {
if (geometry_hint.size()) {
- float err=0;
- geometry_hint= Geometry::wrap_geometry( geometry_hint, &err ); ///< create a "wrap" that encloses the given geometry
+ float err = 0;
+ geometry_hint = Geometry::wrap_geometry(geometry_hint, &err); ///< create a "wrap" that encloses the given geometry
- BSP_Tree new_bounds(geometry_hint,err);
+ BSP_Tree new_bounds(geometry_hint, err);
set_bounds(new_bounds);
}
-
}
void RoomBounds::_regenerate_bsp() {
if (geometry_hint.size()) {
- BSP_Tree new_bounds(geometry_hint,0);
+ BSP_Tree new_bounds(geometry_hint, 0);
set_bounds(new_bounds);
}
}
void RoomBounds::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_bounds","bsp_tree"),&RoomBounds::set_bounds);
- ObjectTypeDB::bind_method(_MD("get_bounds"),&RoomBounds::get_bounds);
+ ObjectTypeDB::bind_method(_MD("set_bounds", "bsp_tree"), &RoomBounds::set_bounds);
+ ObjectTypeDB::bind_method(_MD("get_bounds"), &RoomBounds::get_bounds);
- ObjectTypeDB::bind_method(_MD("set_geometry_hint","triangles"),&RoomBounds::set_geometry_hint);
- ObjectTypeDB::bind_method(_MD("get_geometry_hint"),&RoomBounds::get_geometry_hint);
- ObjectTypeDB::bind_method(_MD("regenerate_bsp"),&RoomBounds::_regenerate_bsp);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regenerate_bsp"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("regenerate_bsp_cubic"),&RoomBounds::_regenerate_bsp_cubic);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regenerate_bsp_cubic"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
-
- ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), _SCS("set_bounds"),_SCS("get_bounds") );
- ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "geometry_hint"),_SCS("set_geometry_hint"),_SCS("get_geometry_hint") );
+ ObjectTypeDB::bind_method(_MD("set_geometry_hint", "triangles"), &RoomBounds::set_geometry_hint);
+ ObjectTypeDB::bind_method(_MD("get_geometry_hint"), &RoomBounds::get_geometry_hint);
+ ObjectTypeDB::bind_method(_MD("regenerate_bsp"), &RoomBounds::_regenerate_bsp);
+ ObjectTypeDB::set_method_flags(get_type_static(), _SCS("regenerate_bsp"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ObjectTypeDB::bind_method(_MD("regenerate_bsp_cubic"), &RoomBounds::_regenerate_bsp_cubic);
+ ObjectTypeDB::set_method_flags(get_type_static(), _SCS("regenerate_bsp_cubic"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "bounds"), _SCS("set_bounds"), _SCS("get_bounds"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY, "geometry_hint"), _SCS("set_geometry_hint"), _SCS("get_geometry_hint"));
}
RoomBounds::RoomBounds() {
- area=VisualServer::get_singleton()->room_create();
+ area = VisualServer::get_singleton()->room_create();
}
-
RoomBounds::~RoomBounds() {
VisualServer::get_singleton()->free(area);
-
}
-
-
diff --git a/scene/resources/room.h b/scene/resources/room.h
index 5b0950ce3..912948731 100644
--- a/scene/resources/room.h
+++ b/scene/resources/room.h
@@ -29,14 +29,14 @@
#ifndef ROOM_BOUNDS_H
#define ROOM_BOUNDS_H
-#include "resource.h"
#include "bsp_tree.h"
+#include "resource.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class RoomBounds : public Resource {
- OBJ_TYPE( RoomBounds, Resource );
+ OBJ_TYPE(RoomBounds, Resource);
RES_BASE_EXTENSION("room");
RID area;
@@ -44,23 +44,21 @@ class RoomBounds : public Resource {
void _regenerate_bsp();
void _regenerate_bsp_cubic();
-protected:
+protected:
static void _bind_methods();
public:
-
virtual RID get_rid() const;
- void set_bounds( const BSP_Tree& p_bounds );
+ void set_bounds(const BSP_Tree &p_bounds);
BSP_Tree get_bounds() const;
- void set_geometry_hint(const DVector<Face3>& geometry_hint);
+ void set_geometry_hint(const DVector<Face3> &geometry_hint);
DVector<Face3> get_geometry_hint() const;
RoomBounds();
~RoomBounds();
-
};
#endif // ROOM_H
diff --git a/scene/resources/sample.cpp b/scene/resources/sample.cpp
index 995dc4290..9b14132cc 100644
--- a/scene/resources/sample.cpp
+++ b/scene/resources/sample.cpp
@@ -28,39 +28,38 @@
/*************************************************************************/
#include "sample.h"
-
-void Sample::_set_data(const Dictionary& p_data) {
+void Sample::_set_data(const Dictionary &p_data) {
ERR_FAIL_COND(!p_data.has("packing"));
String packing = p_data["packing"];
- if (packing=="raw") {
+ if (packing == "raw") {
- ERR_FAIL_COND( !p_data.has("stereo"));
- ERR_FAIL_COND( !p_data.has("format"));
- ERR_FAIL_COND( !p_data.has("length"));
- bool stereo=p_data["stereo"];
- int length=p_data["length"];
+ ERR_FAIL_COND(!p_data.has("stereo"));
+ ERR_FAIL_COND(!p_data.has("format"));
+ ERR_FAIL_COND(!p_data.has("length"));
+ bool stereo = p_data["stereo"];
+ int length = p_data["length"];
Format fmt;
- String fmtstr=p_data["format"];
- if (fmtstr=="pcm8")
- fmt=FORMAT_PCM8;
- else if (fmtstr=="pcm16")
- fmt=FORMAT_PCM16;
- else if (fmtstr=="ima_adpcm")
- fmt=FORMAT_IMA_ADPCM;
+ String fmtstr = p_data["format"];
+ if (fmtstr == "pcm8")
+ fmt = FORMAT_PCM8;
+ else if (fmtstr == "pcm16")
+ fmt = FORMAT_PCM16;
+ else if (fmtstr == "ima_adpcm")
+ fmt = FORMAT_IMA_ADPCM;
else {
- ERR_EXPLAIN("Invalid format for sample: "+fmtstr);
+ ERR_EXPLAIN("Invalid format for sample: " + fmtstr);
ERR_FAIL();
}
ERR_FAIL_COND(!p_data.has("data"));
- create(fmt,stereo,length);
+ create(fmt, stereo, length);
set_data(p_data["data"]);
} else {
- ERR_EXPLAIN("Invalid packing for sample data: "+packing);
+ ERR_EXPLAIN("Invalid packing for sample data: " + packing);
ERR_FAIL();
}
}
@@ -68,62 +67,56 @@ void Sample::_set_data(const Dictionary& p_data) {
Dictionary Sample::_get_data() const {
Dictionary d;
- switch(get_format()) {
+ switch (get_format()) {
- case FORMAT_PCM8: d["format"]="pcm8"; break;
- case FORMAT_PCM16: d["format"]="pcm16"; break;
- case FORMAT_IMA_ADPCM: d["format"]="ima_adpcm"; break;
+ case FORMAT_PCM8: d["format"] = "pcm8"; break;
+ case FORMAT_PCM16: d["format"] = "pcm16"; break;
+ case FORMAT_IMA_ADPCM: d["format"] = "ima_adpcm"; break;
}
- d["stereo"]=is_stereo();
- d["length"]=get_length();
- d["packing"]="raw";
- d["data"]=get_data();
+ d["stereo"] = is_stereo();
+ d["length"] = get_length();
+ d["packing"] = "raw";
+ d["data"] = get_data();
return d;
-
}
void Sample::create(Format p_format, bool p_stereo, int p_length) {
- if (p_length<1)
+ if (p_length < 1)
return;
if (sample.is_valid())
AudioServer::get_singleton()->free(sample);
+ mix_rate = 44100;
+ stereo = p_stereo;
+ length = p_length;
+ format = p_format;
+ loop_format = LOOP_NONE;
+ loop_begin = 0;
+ loop_end = 0;
- mix_rate=44100;
- stereo=p_stereo;
- length=p_length;
- format=p_format;
- loop_format=LOOP_NONE;
- loop_begin=0;
- loop_end=0;
-
- sample=AudioServer::get_singleton()->sample_create((AudioServer::SampleFormat)p_format,p_stereo,p_length);
+ sample = AudioServer::get_singleton()->sample_create((AudioServer::SampleFormat)p_format, p_stereo, p_length);
}
-
Sample::Format Sample::get_format() const {
return format;
}
bool Sample::is_stereo() const {
-
return stereo;
}
int Sample::get_length() const {
-
return length;
}
-void Sample::set_data(const DVector<uint8_t>& p_buffer) {
+void Sample::set_data(const DVector<uint8_t> &p_buffer) {
if (sample.is_valid())
- AudioServer::get_singleton()->sample_set_data(sample,p_buffer);
-
+ AudioServer::get_singleton()->sample_set_data(sample, p_buffer);
}
DVector<uint8_t> Sample::get_data() const {
@@ -131,15 +124,13 @@ DVector<uint8_t> Sample::get_data() const {
return AudioServer::get_singleton()->sample_get_data(sample);
return DVector<uint8_t>();
-
}
void Sample::set_mix_rate(int p_rate) {
- mix_rate=p_rate;
+ mix_rate = p_rate;
if (sample.is_valid())
- return AudioServer::get_singleton()->sample_set_mix_rate(sample,mix_rate);
-
+ return AudioServer::get_singleton()->sample_set_mix_rate(sample, mix_rate);
}
int Sample::get_mix_rate() const {
@@ -149,8 +140,8 @@ int Sample::get_mix_rate() const {
void Sample::set_loop_format(LoopFormat p_format) {
if (sample.is_valid())
- AudioServer::get_singleton()->sample_set_loop_format(sample,(AudioServer::SampleLoopFormat)p_format);
- loop_format=p_format;
+ AudioServer::get_singleton()->sample_set_loop_format(sample, (AudioServer::SampleLoopFormat)p_format);
+ loop_format = p_format;
}
Sample::LoopFormat Sample::get_loop_format() const {
@@ -161,9 +152,8 @@ Sample::LoopFormat Sample::get_loop_format() const {
void Sample::set_loop_begin(int p_pos) {
if (sample.is_valid())
- AudioServer::get_singleton()->sample_set_loop_begin(sample,p_pos);
- loop_begin=p_pos;
-
+ AudioServer::get_singleton()->sample_set_loop_begin(sample, p_pos);
+ loop_begin = p_pos;
}
int Sample::get_loop_begin() const {
@@ -173,8 +163,8 @@ int Sample::get_loop_begin() const {
void Sample::set_loop_end(int p_pos) {
if (sample.is_valid())
- AudioServer::get_singleton()->sample_set_loop_end(sample,p_pos);
- loop_end=p_pos;
+ AudioServer::get_singleton()->sample_set_loop_end(sample, p_pos);
+ loop_end = p_pos;
}
int Sample::get_loop_end() const {
@@ -187,58 +177,53 @@ RID Sample::get_rid() const {
return sample;
}
+void Sample::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("create", "format", "stereo", "length"), &Sample::create);
+ ObjectTypeDB::bind_method(_MD("get_format"), &Sample::get_format);
+ ObjectTypeDB::bind_method(_MD("is_stereo"), &Sample::is_stereo);
+ ObjectTypeDB::bind_method(_MD("get_length"), &Sample::get_length);
+ ObjectTypeDB::bind_method(_MD("set_data", "data"), &Sample::set_data);
+ ObjectTypeDB::bind_method(_MD("get_data"), &Sample::get_data);
+ ObjectTypeDB::bind_method(_MD("set_mix_rate", "hz"), &Sample::set_mix_rate);
+ ObjectTypeDB::bind_method(_MD("get_mix_rate"), &Sample::get_mix_rate);
+ ObjectTypeDB::bind_method(_MD("set_loop_format", "format"), &Sample::set_loop_format);
+ ObjectTypeDB::bind_method(_MD("get_loop_format"), &Sample::get_loop_format);
+ ObjectTypeDB::bind_method(_MD("set_loop_begin", "pos"), &Sample::set_loop_begin);
+ ObjectTypeDB::bind_method(_MD("get_loop_begin"), &Sample::get_loop_begin);
+ ObjectTypeDB::bind_method(_MD("set_loop_end", "pos"), &Sample::set_loop_end);
+ ObjectTypeDB::bind_method(_MD("get_loop_end"), &Sample::get_loop_end);
-void Sample::_bind_methods(){
-
-
- ObjectTypeDB::bind_method(_MD("create","format","stereo","length"),&Sample::create);
- ObjectTypeDB::bind_method(_MD("get_format"),&Sample::get_format);
- ObjectTypeDB::bind_method(_MD("is_stereo"),&Sample::is_stereo);
- ObjectTypeDB::bind_method(_MD("get_length"),&Sample::get_length);
- ObjectTypeDB::bind_method(_MD("set_data","data"),&Sample::set_data);
- ObjectTypeDB::bind_method(_MD("get_data"),&Sample::get_data);
- ObjectTypeDB::bind_method(_MD("set_mix_rate","hz"),&Sample::set_mix_rate);
- ObjectTypeDB::bind_method(_MD("get_mix_rate"),&Sample::get_mix_rate);
- ObjectTypeDB::bind_method(_MD("set_loop_format","format"),&Sample::set_loop_format);
- ObjectTypeDB::bind_method(_MD("get_loop_format"),&Sample::get_loop_format);
- ObjectTypeDB::bind_method(_MD("set_loop_begin","pos"),&Sample::set_loop_begin);
- ObjectTypeDB::bind_method(_MD("get_loop_begin"),&Sample::get_loop_begin);
- ObjectTypeDB::bind_method(_MD("set_loop_end","pos"),&Sample::set_loop_end);
- ObjectTypeDB::bind_method(_MD("get_loop_end"),&Sample::get_loop_end);
+ ObjectTypeDB::bind_method(_MD("_set_data"), &Sample::_set_data);
+ ObjectTypeDB::bind_method(_MD("_get_data"), &Sample::_get_data);
- ObjectTypeDB::bind_method(_MD("_set_data"),&Sample::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&Sample::_get_data);
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "stereo"), _SCS(""), _SCS("is_stereo"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "length", PROPERTY_HINT_RANGE, "0,999999999"), _SCS(""), _SCS("get_length"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_rate", PROPERTY_HINT_RANGE, "1,192000,1"), _SCS("set_mix_rate"), _SCS("get_mix_rate"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_format", PROPERTY_HINT_ENUM, "None,Forward,PingPong"), _SCS("set_loop_format"), _SCS("get_loop_format"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_begin", PROPERTY_HINT_RANGE, "0," + itos(999999999) + ",1"), _SCS("set_loop_begin"), _SCS("get_loop_begin"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "loop_end", PROPERTY_HINT_RANGE, "0," + itos(999999999) + ",1"), _SCS("set_loop_end"), _SCS("get_loop_end"));
- ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "stereo"), _SCS(""), _SCS("is_stereo") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "length",PROPERTY_HINT_RANGE,"0,999999999"), _SCS(""), _SCS("get_length") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "mix_rate", PROPERTY_HINT_RANGE,"1,192000,1" ), _SCS("set_mix_rate"), _SCS("get_mix_rate") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_format", PROPERTY_HINT_ENUM,"None,Forward,PingPong" ), _SCS("set_loop_format"), _SCS("get_loop_format") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_begin", PROPERTY_HINT_RANGE,"0,"+itos(999999999)+",1"), _SCS("set_loop_begin"), _SCS("get_loop_begin") );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "loop_end", PROPERTY_HINT_RANGE,"0,"+itos(999999999)+",1"), _SCS("set_loop_end"), _SCS("get_loop_end") );
-
- BIND_CONSTANT( FORMAT_PCM8 );
- BIND_CONSTANT( FORMAT_PCM16 );
- BIND_CONSTANT( FORMAT_IMA_ADPCM );
-
- BIND_CONSTANT( LOOP_NONE );
- BIND_CONSTANT( LOOP_FORWARD );
- BIND_CONSTANT( LOOP_PING_PONG );
+ BIND_CONSTANT(FORMAT_PCM8);
+ BIND_CONSTANT(FORMAT_PCM16);
+ BIND_CONSTANT(FORMAT_IMA_ADPCM);
+ BIND_CONSTANT(LOOP_NONE);
+ BIND_CONSTANT(LOOP_FORWARD);
+ BIND_CONSTANT(LOOP_PING_PONG);
}
Sample::Sample() {
- format=FORMAT_PCM8;
- length=0;
- stereo=false;
-
- loop_format=LOOP_NONE;
- loop_begin=0;
- loop_end=0;
- mix_rate=44100;
+ format = FORMAT_PCM8;
+ length = 0;
+ stereo = false;
+ loop_format = LOOP_NONE;
+ loop_begin = 0;
+ loop_end = 0;
+ mix_rate = 44100;
}
Sample::~Sample() {
diff --git a/scene/resources/sample.h b/scene/resources/sample.h
index a59c52fd9..2197d9aa5 100644
--- a/scene/resources/sample.h
+++ b/scene/resources/sample.h
@@ -29,15 +29,15 @@
#ifndef SAMPLE_H
#define SAMPLE_H
-#include "servers/audio_server.h"
#include "resource.h"
+#include "servers/audio_server.h"
class Sample : public Resource {
- OBJ_TYPE(Sample, Resource );
+ OBJ_TYPE(Sample, Resource);
RES_BASE_EXTENSION("smp");
-public:
+public:
enum Format {
FORMAT_PCM8,
@@ -53,7 +53,6 @@ public:
};
private:
-
Format format;
int length;
bool stereo;
@@ -65,24 +64,20 @@ private:
RID sample;
-
- void _set_data(const Dictionary& p_data);
+ void _set_data(const Dictionary &p_data);
Dictionary _get_data() const;
protected:
-
static void _bind_methods();
public:
-
-
void create(Format p_format, bool p_stereo, int p_length);
Format get_format() const;
bool is_stereo() const;
int get_length() const;
- void set_data(const DVector<uint8_t>& p_buffer);
+ void set_data(const DVector<uint8_t> &p_buffer);
DVector<uint8_t> get_data() const;
void set_mix_rate(int p_rate);
@@ -102,7 +97,7 @@ public:
~Sample();
};
-VARIANT_ENUM_CAST( Sample::Format );
-VARIANT_ENUM_CAST( Sample::LoopFormat );
+VARIANT_ENUM_CAST(Sample::Format);
+VARIANT_ENUM_CAST(Sample::LoopFormat);
#endif // SAMPLE_H
diff --git a/scene/resources/sample_library.cpp b/scene/resources/sample_library.cpp
index 7de646b6e..e6ccdceb3 100644
--- a/scene/resources/sample_library.cpp
+++ b/scene/resources/sample_library.cpp
@@ -28,32 +28,30 @@
/*************************************************************************/
#include "sample_library.h"
-
-bool SampleLibrary::_set(const StringName& p_name, const Variant& p_value) {
-
+bool SampleLibrary::_set(const StringName &p_name, const Variant &p_value) {
if (String(p_name).begins_with("samples/")) {
- String name=String(p_name).get_slicec('/',1);
- if (p_value.get_type()==Variant::NIL)
+ String name = String(p_name).get_slicec('/', 1);
+ if (p_value.get_type() == Variant::NIL)
sample_map.erase(name);
else {
SampleData sd;
- if (p_value.get_type()==Variant::OBJECT)
- sd.sample=p_value;
- else if (p_value.get_type()==Variant::DICTIONARY) {
+ if (p_value.get_type() == Variant::OBJECT)
+ sd.sample = p_value;
+ else if (p_value.get_type() == Variant::DICTIONARY) {
Dictionary d = p_value;
- ERR_FAIL_COND_V(!d.has("sample"),false);
- ERR_FAIL_COND_V(!d.has("pitch"),false);
- ERR_FAIL_COND_V(!d.has("db"),false);
- sd.sample=d["sample"];
- sd.pitch_scale=d["pitch"];
- sd.db=d["db"];
+ ERR_FAIL_COND_V(!d.has("sample"), false);
+ ERR_FAIL_COND_V(!d.has("pitch"), false);
+ ERR_FAIL_COND_V(!d.has("db"), false);
+ sd.sample = d["sample"];
+ sd.pitch_scale = d["pitch"];
+ sd.db = d["db"];
}
- sample_map[name]=sd;
+ sample_map[name] = sd;
}
return true;
@@ -62,17 +60,17 @@ bool SampleLibrary::_set(const StringName& p_name, const Variant& p_value) {
return false;
}
-bool SampleLibrary::_get(const StringName& p_name,Variant &r_ret) const {
+bool SampleLibrary::_get(const StringName &p_name, Variant &r_ret) const {
if (String(p_name).begins_with("samples/")) {
- String name=String(p_name).get_slicec('/',1);
- if(sample_map.has(name)) {
+ String name = String(p_name).get_slicec('/', 1);
+ if (sample_map.has(name)) {
Dictionary d;
- d["sample"]=sample_map[name].sample;
- d["pitch"]=sample_map[name].pitch_scale;
- d["db"]=sample_map[name].db;
- r_ret=d;
+ d["sample"] = sample_map[name].sample;
+ d["pitch"] = sample_map[name].pitch_scale;
+ d["db"] = sample_map[name].db;
+ r_ret = d;
} else {
return false;
}
@@ -81,67 +79,63 @@ bool SampleLibrary::_get(const StringName& p_name,Variant &r_ret) const {
}
return false;
-
-
}
-void SampleLibrary::add_sample(const StringName& p_name, const Ref<Sample>& p_sample) {
+void SampleLibrary::add_sample(const StringName &p_name, const Ref<Sample> &p_sample) {
ERR_FAIL_COND(p_sample.is_null());
SampleData sd;
- sd.sample=p_sample;
- sample_map[p_name]=sd;
+ sd.sample = p_sample;
+ sample_map[p_name] = sd;
}
-Ref<Sample> SampleLibrary::get_sample(const StringName& p_name) const {
+Ref<Sample> SampleLibrary::get_sample(const StringName &p_name) const {
- ERR_FAIL_COND_V(!sample_map.has(p_name),Ref<Sample>());
+ ERR_FAIL_COND_V(!sample_map.has(p_name), Ref<Sample>());
return sample_map[p_name].sample;
}
-void SampleLibrary::remove_sample(const StringName& p_name) {
+void SampleLibrary::remove_sample(const StringName &p_name) {
sample_map.erase(p_name);
}
void SampleLibrary::get_sample_list(List<StringName> *p_samples) const {
- for(const Map<StringName,SampleData >::Element *E=sample_map.front();E;E=E->next()) {
+ for (const Map<StringName, SampleData>::Element *E = sample_map.front(); E; E = E->next()) {
p_samples->push_back(E->key());
}
-
}
-bool SampleLibrary::has_sample(const StringName& p_name) const {
+bool SampleLibrary::has_sample(const StringName &p_name) const {
return sample_map.has(p_name);
}
void SampleLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
-
List<PropertyInfo> tpl;
- for(Map<StringName,SampleData>::Element *E=sample_map.front();E;E=E->next()) {
+ for (Map<StringName, SampleData>::Element *E = sample_map.front(); E; E = E->next()) {
- tpl.push_back( PropertyInfo( Variant::DICTIONARY, "samples/"+E->key(),PROPERTY_HINT_RESOURCE_TYPE,"Sample",PROPERTY_USAGE_NOEDITOR ) );
+ tpl.push_back(PropertyInfo(Variant::DICTIONARY, "samples/" + E->key(), PROPERTY_HINT_RESOURCE_TYPE, "Sample", PROPERTY_USAGE_NOEDITOR));
}
tpl.sort();
//sort so order is kept
- for(List<PropertyInfo>::Element *E=tpl.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = tpl.front(); E; E = E->next()) {
p_list->push_back(E->get());
}
}
StringName SampleLibrary::get_sample_idx(int p_idx) const {
- int idx=0;
- for (Map<StringName, SampleData >::Element *E=sample_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (Map<StringName, SampleData>::Element *E = sample_map.front(); E; E = E->next()) {
- if (p_idx==idx)
+ if (p_idx == idx)
return E->key();
idx++;
}
@@ -149,30 +143,29 @@ StringName SampleLibrary::get_sample_idx(int p_idx) const {
return "";
}
-void SampleLibrary::sample_set_volume_db(const StringName& p_name, float p_db) {
-
- ERR_FAIL_COND( !sample_map.has(p_name) );
- sample_map[p_name].db=p_db;
+void SampleLibrary::sample_set_volume_db(const StringName &p_name, float p_db) {
+ ERR_FAIL_COND(!sample_map.has(p_name));
+ sample_map[p_name].db = p_db;
}
-float SampleLibrary::sample_get_volume_db(const StringName& p_name) const{
+float SampleLibrary::sample_get_volume_db(const StringName &p_name) const {
- ERR_FAIL_COND_V( !sample_map.has(p_name),0 );
+ ERR_FAIL_COND_V(!sample_map.has(p_name), 0);
return sample_map[p_name].db;
}
-void SampleLibrary::sample_set_pitch_scale(const StringName& p_name, float p_pitch){
+void SampleLibrary::sample_set_pitch_scale(const StringName &p_name, float p_pitch) {
- ERR_FAIL_COND( !sample_map.has(p_name) );
+ ERR_FAIL_COND(!sample_map.has(p_name));
- sample_map[p_name].pitch_scale=p_pitch;
+ sample_map[p_name].pitch_scale = p_pitch;
}
-float SampleLibrary::sample_get_pitch_scale(const StringName& p_name) const{
+float SampleLibrary::sample_get_pitch_scale(const StringName &p_name) const {
- ERR_FAIL_COND_V( !sample_map.has(p_name),0 );
+ ERR_FAIL_COND_V(!sample_map.has(p_name), 0);
return sample_map[p_name].pitch_scale;
}
@@ -185,7 +178,7 @@ Array SampleLibrary::_get_sample_list() const {
snames.sort_custom<StringName::AlphCompare>();
Array ret;
- for (List<StringName>::Element *E=snames.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = snames.front(); E; E = E->next()) {
ret.push_back(E->get());
}
@@ -194,22 +187,19 @@ Array SampleLibrary::_get_sample_list() const {
void SampleLibrary::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_sample","name","sample:Sample"),&SampleLibrary::add_sample );
- ObjectTypeDB::bind_method(_MD("get_sample:Sample","name"),&SampleLibrary::get_sample );
- ObjectTypeDB::bind_method(_MD("has_sample","name"),&SampleLibrary::has_sample );
- ObjectTypeDB::bind_method(_MD("remove_sample","name"),&SampleLibrary::remove_sample );
-
- ObjectTypeDB::bind_method(_MD("get_sample_list"),&SampleLibrary::_get_sample_list );
-
- ObjectTypeDB::bind_method(_MD("sample_set_volume_db","name","db"),&SampleLibrary::sample_set_volume_db );
- ObjectTypeDB::bind_method(_MD("sample_get_volume_db","name"),&SampleLibrary::sample_get_volume_db );
+ ObjectTypeDB::bind_method(_MD("add_sample", "name", "sample:Sample"), &SampleLibrary::add_sample);
+ ObjectTypeDB::bind_method(_MD("get_sample:Sample", "name"), &SampleLibrary::get_sample);
+ ObjectTypeDB::bind_method(_MD("has_sample", "name"), &SampleLibrary::has_sample);
+ ObjectTypeDB::bind_method(_MD("remove_sample", "name"), &SampleLibrary::remove_sample);
- ObjectTypeDB::bind_method(_MD("sample_set_pitch_scale","name","pitch"),&SampleLibrary::sample_set_pitch_scale );
- ObjectTypeDB::bind_method(_MD("sample_get_pitch_scale","name"),&SampleLibrary::sample_get_pitch_scale );
+ ObjectTypeDB::bind_method(_MD("get_sample_list"), &SampleLibrary::_get_sample_list);
+ ObjectTypeDB::bind_method(_MD("sample_set_volume_db", "name", "db"), &SampleLibrary::sample_set_volume_db);
+ ObjectTypeDB::bind_method(_MD("sample_get_volume_db", "name"), &SampleLibrary::sample_get_volume_db);
+ ObjectTypeDB::bind_method(_MD("sample_set_pitch_scale", "name", "pitch"), &SampleLibrary::sample_set_pitch_scale);
+ ObjectTypeDB::bind_method(_MD("sample_get_pitch_scale", "name"), &SampleLibrary::sample_get_pitch_scale);
}
-SampleLibrary::SampleLibrary()
-{
+SampleLibrary::SampleLibrary() {
}
diff --git a/scene/resources/sample_library.h b/scene/resources/sample_library.h
index 0cb6186fd..1928e55bb 100644
--- a/scene/resources/sample_library.h
+++ b/scene/resources/sample_library.h
@@ -29,13 +29,13 @@
#ifndef SAMPLE_LIBRARY_H
#define SAMPLE_LIBRARY_H
+#include "map.h"
#include "resource.h"
#include "scene/resources/sample.h"
-#include "map.h"
class SampleLibrary : public Resource {
- OBJ_TYPE(SampleLibrary,Resource);
+ OBJ_TYPE(SampleLibrary, Resource);
struct SampleData {
@@ -43,33 +43,33 @@ class SampleLibrary : public Resource {
float db;
float pitch_scale;
- SampleData() { db=0; pitch_scale=1; }
+ SampleData() {
+ db = 0;
+ pitch_scale = 1;
+ }
};
- Map<StringName,SampleData > sample_map;
+ Map<StringName, SampleData> sample_map;
Array _get_sample_list() const;
-protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
+protected:
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
-
-
-
- void add_sample(const StringName& p_name, const Ref<Sample>& p_sample);
- bool has_sample(const StringName& p_name) const;
- void sample_set_volume_db(const StringName& p_name, float p_db);
- float sample_get_volume_db(const StringName& p_name) const;
- void sample_set_pitch_scale(const StringName& p_name, float p_pitch);
- float sample_get_pitch_scale(const StringName& p_name) const;
- Ref<Sample> get_sample(const StringName& p_name) const;
+ void add_sample(const StringName &p_name, const Ref<Sample> &p_sample);
+ bool has_sample(const StringName &p_name) const;
+ void sample_set_volume_db(const StringName &p_name, float p_db);
+ float sample_get_volume_db(const StringName &p_name) const;
+ void sample_set_pitch_scale(const StringName &p_name, float p_pitch);
+ float sample_get_pitch_scale(const StringName &p_name) const;
+ Ref<Sample> get_sample(const StringName &p_name) const;
void get_sample_list(List<StringName> *p_samples) const;
- void remove_sample(const StringName& p_name);
+ void remove_sample(const StringName &p_name);
StringName get_sample_idx(int p_idx) const;
SampleLibrary();
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index 43834d1ce..d269f6938 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -29,24 +29,21 @@
#include "scene_format_text.h"
#include "globals.h"
-#include "version.h"
#include "os/dir_access.h"
+#include "version.h"
#define FORMAT_VERSION 1
-#include "version.h"
#include "os/dir_access.h"
+#include "version.h"
-#define _printerr() ERR_PRINT(String(res_path+":"+itos(lines)+" - Parse Error: "+error_text).utf8().get_data());
-
-
-
+#define _printerr() ERR_PRINT(String(res_path + ":" + itos(lines) + " - Parse Error: " + error_text).utf8().get_data());
///
-void ResourceInteractiveLoaderText::set_local_path(const String& p_local_path) {
+void ResourceInteractiveLoaderText::set_local_path(const String &p_local_path) {
- res_path=p_local_path;
+ res_path = p_local_path;
}
Ref<Resource> ResourceInteractiveLoaderText::get_resource() {
@@ -54,47 +51,46 @@ Ref<Resource> ResourceInteractiveLoaderText::get_resource() {
return resource;
}
-Error ResourceInteractiveLoaderText::_parse_sub_resource(VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str) {
+Error ResourceInteractiveLoaderText::_parse_sub_resource(VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str) {
VariantParser::Token token;
- VariantParser::get_token(p_stream,token,line,r_err_str);
- if (token.type!=VariantParser::TK_NUMBER) {
- r_err_str="Expected number (sub-resource index)";
+ VariantParser::get_token(p_stream, token, line, r_err_str);
+ if (token.type != VariantParser::TK_NUMBER) {
+ r_err_str = "Expected number (sub-resource index)";
return ERR_PARSE_ERROR;
}
int index = token.value;
- String path = local_path+"::"+itos(index);
+ String path = local_path + "::" + itos(index);
if (!ignore_resource_parsing) {
if (!ResourceCache::has(path)) {
- r_err_str="Can't load cached sub-resource: "+path;
+ r_err_str = "Can't load cached sub-resource: " + path;
return ERR_PARSE_ERROR;
}
- r_value_res=RES(ResourceCache::get(path));
+ r_value_res = RES(ResourceCache::get(path));
} else {
- r_value_res=RES();
+ r_value_res = RES();
}
- VariantParser::get_token(p_stream,token,line,r_err_str);
- if (token.type!=VariantParser::TK_PARENTHESIS_CLOSE) {
- r_err_str="Expected ')'";
+ VariantParser::get_token(p_stream, token, line, r_err_str);
+ if (token.type != VariantParser::TK_PARENTHESIS_CLOSE) {
+ r_err_str = "Expected ')'";
return ERR_PARSE_ERROR;
}
-
return OK;
}
-Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str){
+Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str) {
VariantParser::Token token;
- VariantParser::get_token(p_stream,token,line,r_err_str);
- if (token.type!=VariantParser::TK_NUMBER) {
- r_err_str="Expected number (sub-resource index)";
+ VariantParser::get_token(p_stream, token, line, r_err_str);
+ if (token.type != VariantParser::TK_NUMBER) {
+ r_err_str = "Expected number (sub-resource index)";
return ERR_PARSE_ERROR;
}
@@ -103,72 +99,67 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream*
if (!ignore_resource_parsing) {
if (!ext_resources.has(id)) {
- r_err_str="Can't load cached ext-resource #"+itos(id);
+ r_err_str = "Can't load cached ext-resource #" + itos(id);
return ERR_PARSE_ERROR;
}
String path = ext_resources[id].path;
String type = ext_resources[id].type;
- if (path.find("://")==-1 && path.is_rel_path()) {
+ if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
-
+ path = Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
- RES res = ResourceLoader::load(path,type);
+ RES res = ResourceLoader::load(path, type);
if (res.is_null()) {
- WARN_PRINT(String("Couldn't load external resource: "+path).utf8().get_data());
+ WARN_PRINT(String("Couldn't load external resource: " + path).utf8().get_data());
}
- r_value_res=res;
+ r_value_res = res;
} else {
- r_value_res=RES();
+ r_value_res = RES();
}
- VariantParser::get_token(p_stream,token,line,r_err_str);
- if (token.type!=VariantParser::TK_PARENTHESIS_CLOSE) {
- r_err_str="Expected ')'";
+ VariantParser::get_token(p_stream, token, line, r_err_str);
+ if (token.type != VariantParser::TK_PARENTHESIS_CLOSE) {
+ r_err_str = "Expected ')'";
return ERR_PARSE_ERROR;
}
-
return OK;
}
-
-Error ResourceInteractiveLoaderText::_parse_sub_resource_export(VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str) {
+Error ResourceInteractiveLoaderText::_parse_sub_resource_export(VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str) {
VariantParser::Token token;
- VariantParser::get_token(p_stream,token,line,r_err_str);
-
+ VariantParser::get_token(p_stream, token, line, r_err_str);
- if (token.type!=VariantParser::TK_NUMBER) {
- r_err_str="Expected number (sub-resource index)";
+ if (token.type != VariantParser::TK_NUMBER) {
+ r_err_str = "Expected number (sub-resource index)";
return ERR_PARSE_ERROR;
}
int index = token.value;
- r_value_res="@RESLOCAL:"+itos(index);
+ r_value_res = "@RESLOCAL:" + itos(index);
- VariantParser::get_token(p_stream,token,line,r_err_str);
- if (token.type!=VariantParser::TK_PARENTHESIS_CLOSE) {
- r_err_str="Expected ')'";
+ VariantParser::get_token(p_stream, token, line, r_err_str);
+ if (token.type != VariantParser::TK_PARENTHESIS_CLOSE) {
+ r_err_str = "Expected ')'";
return ERR_PARSE_ERROR;
}
-
return OK;
}
-Error ResourceInteractiveLoaderText::_parse_ext_resource_export(VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str){
+Error ResourceInteractiveLoaderText::_parse_ext_resource_export(VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str) {
VariantParser::Token token;
- VariantParser::get_token(p_stream,token,line,r_err_str);
- if (token.type!=VariantParser::TK_NUMBER) {
- r_err_str="Expected number (sub-resource index)";
+ VariantParser::get_token(p_stream, token, line, r_err_str);
+ if (token.type != VariantParser::TK_NUMBER) {
+ r_err_str = "Expected number (sub-resource index)";
return ERR_PARSE_ERROR;
}
@@ -176,76 +167,70 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource_export(VariantParser::S
{
- r_value_res="@RESEXTERNAL:"+itos(id);
-
+ r_value_res = "@RESEXTERNAL:" + itos(id);
}
- VariantParser::get_token(p_stream,token,line,r_err_str);
- if (token.type!=VariantParser::TK_PARENTHESIS_CLOSE) {
- r_err_str="Expected ')'";
+ VariantParser::get_token(p_stream, token, line, r_err_str);
+ if (token.type != VariantParser::TK_PARENTHESIS_CLOSE) {
+ r_err_str = "Expected ')'";
return ERR_PARSE_ERROR;
}
-
return OK;
}
-
-
Error ResourceInteractiveLoaderText::poll() {
- if (error!=OK)
+ if (error != OK)
return error;
- if (next_tag.name=="ext_resource") {
-
+ if (next_tag.name == "ext_resource") {
if (!next_tag.fields.has("path")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'path' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'path' in external resource tag";
_printerr();
return error;
}
if (!next_tag.fields.has("type")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'type' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'type' in external resource tag";
_printerr();
return error;
}
if (!next_tag.fields.has("id")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'id' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'id' in external resource tag";
_printerr();
return error;
}
- String path=next_tag.fields["path"];
- String type=next_tag.fields["type"];
- int index=next_tag.fields["id"];
-
+ String path = next_tag.fields["path"];
+ String type = next_tag.fields["type"];
+ int index = next_tag.fields["id"];
- if (path.find("://")==-1 && path.is_rel_path()) {
+ if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path=Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
+ path = Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
}
if (remaps.has(path)) {
- path=remaps[path];
+ path = remaps[path];
}
- RES res = ResourceLoader::load(path,type);
+ RES res = ResourceLoader::load(path, type);
if (res.is_null()) {
if (ResourceLoader::get_abort_on_missing_resources()) {
- error=ERR_FILE_CORRUPT;
- error_text="[ext_resource] referenced nonexistent resource at: "+path;
+ error = ERR_FILE_CORRUPT;
+ error_text = "[ext_resource] referenced nonexistent resource at: " + path;
_printerr();
return error;
} else {
- ResourceLoader::notify_dependency_error(local_path,path,type);
+ ResourceLoader::notify_dependency_error(local_path, path, type);
}
} else {
@@ -253,11 +238,11 @@ Error ResourceInteractiveLoaderText::poll() {
}
ExtResource er;
- er.path=path;
- er.type=type;
- ext_resources[index]=er;
+ er.path = path;
+ er.type = type;
+ ext_resources[index] = er;
- error = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
+ error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
if (error) {
_printerr();
@@ -266,138 +251,130 @@ Error ResourceInteractiveLoaderText::poll() {
resource_current++;
return error;
-
- } else if (next_tag.name=="sub_resource") {
-
+ } else if (next_tag.name == "sub_resource") {
if (!next_tag.fields.has("type")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'type' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'type' in external resource tag";
_printerr();
return error;
}
if (!next_tag.fields.has("id")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'index' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'index' in external resource tag";
_printerr();
return error;
}
- String type=next_tag.fields["type"];
- int id=next_tag.fields["id"];
-
- String path = local_path+"::"+itos(id);
+ String type = next_tag.fields["type"];
+ int id = next_tag.fields["id"];
+ String path = local_path + "::" + itos(id);
//bool exists=ResourceCache::has(path);
Ref<Resource> res;
- if ( !ResourceCache::has(path)) { //only if it doesn't exist
+ if (!ResourceCache::has(path)) { //only if it doesn't exist
Object *obj = ObjectTypeDB::instance(type);
if (!obj) {
- error_text+="Can't create sub resource of type: "+type;
+ error_text += "Can't create sub resource of type: " + type;
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
-
Resource *r = obj->cast_to<Resource>();
if (!r) {
- error_text+="Can't create sub resource of type, because not a resource: "+type;
+ error_text += "Can't create sub resource of type, because not a resource: " + type;
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
- res=Ref<Resource>(r);
+ res = Ref<Resource>(r);
resource_cache.push_back(res);
res->set_path(path);
-
}
resource_current++;
- while(true) {
+ while (true) {
String assign;
Variant value;
- error = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,&rp);
+ error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp);
if (error) {
_printerr();
return error;
}
- if (assign!=String()) {
+ if (assign != String()) {
if (res.is_valid()) {
- res->set(assign,value);
+ res->set(assign, value);
}
//it's assignment
- } else if (next_tag.name!=String()) {
+ } else if (next_tag.name != String()) {
- error=OK;
+ error = OK;
break;
} else {
- error=ERR_FILE_CORRUPT;
- error_text="Premature end of file while parsing [sub_resource]";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Premature end of file while parsing [sub_resource]";
_printerr();
return error;
}
-
-
}
return OK;
- } else if (next_tag.name=="resource") {
+ } else if (next_tag.name == "resource") {
if (is_scene) {
- error_text+="found the 'resource' tag on a scene file!";
+ error_text += "found the 'resource' tag on a scene file!";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
Object *obj = ObjectTypeDB::instance(res_type);
if (!obj) {
- error_text+="Can't create sub resource of type: "+res_type;
+ error_text += "Can't create sub resource of type: " + res_type;
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
-
Resource *r = obj->cast_to<Resource>();
if (!r) {
- error_text+="Can't create sub resource of type, because not a resource: "+res_type;
+ error_text += "Can't create sub resource of type, because not a resource: " + res_type;
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
- resource=Ref<Resource>(r);
+ resource = Ref<Resource>(r);
resource_current++;
- while(true) {
+ while (true) {
String assign;
Variant value;
- error = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,&rp);
+ error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp);
if (error) {
- if (error!=ERR_FILE_EOF) {
+ if (error != ERR_FILE_EOF) {
_printerr();
} else {
if (!ResourceCache::has(res_path)) {
@@ -407,31 +384,30 @@ Error ResourceInteractiveLoaderText::poll() {
return error;
}
- if (assign!=String()) {
- resource->set(assign,value);
+ if (assign != String()) {
+ resource->set(assign, value);
//it's assignment
- } else if (next_tag.name!=String()) {
+ } else if (next_tag.name != String()) {
- error=ERR_FILE_CORRUPT;
- error_text="Extra tag found when parsing main resource file";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Extra tag found when parsing main resource file";
_printerr();
return error;
} else {
- error=ERR_FILE_EOF;
+ error = ERR_FILE_EOF;
return error;
}
-
}
return OK;
- } else if (next_tag.name=="node") {
+ } else if (next_tag.name == "node") {
if (!is_scene) {
- error_text+="found the 'node' tag on a resource file!";
+ error_text += "found the 'node' tag on a resource file!";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
@@ -448,87 +424,84 @@ Error ResourceInteractiveLoaderText::poll() {
*/
- int parent=-1;
- int owner=-1;
- int type=-1;
- int name=-1;
- int instance=-1;
-// int base_scene=-1;
+ int parent = -1;
+ int owner = -1;
+ int type = -1;
+ int name = -1;
+ int instance = -1;
+ // int base_scene=-1;
if (next_tag.fields.has("name")) {
- name=packed_scene->get_state()->add_name(next_tag.fields["name"]);
+ name = packed_scene->get_state()->add_name(next_tag.fields["name"]);
}
if (next_tag.fields.has("parent")) {
NodePath np = next_tag.fields["parent"];
np.prepend_period(); //compatible to how it manages paths internally
- parent=packed_scene->get_state()->add_node_path(np);
+ parent = packed_scene->get_state()->add_node_path(np);
}
-
-
if (next_tag.fields.has("type")) {
- type=packed_scene->get_state()->add_name(next_tag.fields["type"]);
+ type = packed_scene->get_state()->add_name(next_tag.fields["type"]);
} else {
- type=SceneState::TYPE_INSTANCED; //no type? assume this was instanced
+ type = SceneState::TYPE_INSTANCED; //no type? assume this was instanced
}
-
if (next_tag.fields.has("instance")) {
- instance=packed_scene->get_state()->add_value(next_tag.fields["instance"]);
+ instance = packed_scene->get_state()->add_value(next_tag.fields["instance"]);
- if (packed_scene->get_state()->get_node_count()==0 && parent==-1) {
+ if (packed_scene->get_state()->get_node_count() == 0 && parent == -1) {
packed_scene->get_state()->set_base_scene(instance);
- instance=-1;
+ instance = -1;
}
}
if (next_tag.fields.has("instance_placeholder")) {
- String path=next_tag.fields["instance_placeholder"];
+ String path = next_tag.fields["instance_placeholder"];
int path_v = packed_scene->get_state()->add_value(path);
- if (packed_scene->get_state()->get_node_count()==0) {
- error=ERR_FILE_CORRUPT;
- error_text="Instance Placeholder can't be used for inheritance.";
+ if (packed_scene->get_state()->get_node_count() == 0) {
+ error = ERR_FILE_CORRUPT;
+ error_text = "Instance Placeholder can't be used for inheritance.";
_printerr();
return error;
}
- instance=path_v|SceneState::FLAG_INSTANCE_IS_PLACEHOLDER;
+ instance = path_v | SceneState::FLAG_INSTANCE_IS_PLACEHOLDER;
}
if (next_tag.fields.has("owner")) {
- owner=packed_scene->get_state()->add_node_path(next_tag.fields["owner"]);
+ owner = packed_scene->get_state()->add_node_path(next_tag.fields["owner"]);
} else {
- if (parent!=-1 && !(type==SceneState::TYPE_INSTANCED && instance==-1))
- owner=0; //if no owner, owner is root
+ if (parent != -1 && !(type == SceneState::TYPE_INSTANCED && instance == -1))
+ owner = 0; //if no owner, owner is root
}
- int node_id = packed_scene->get_state()->add_node(parent,owner,type,name,instance);
+ int node_id = packed_scene->get_state()->add_node(parent, owner, type, name, instance);
if (next_tag.fields.has("groups")) {
Array groups = next_tag.fields["groups"];
- for (int i=0;i<groups.size();i++) {
- packed_scene->get_state()->add_node_group(node_id,packed_scene->get_state()->add_name(groups[i]));
+ for (int i = 0; i < groups.size(); i++) {
+ packed_scene->get_state()->add_node_group(node_id, packed_scene->get_state()->add_name(groups[i]));
}
}
- while(true) {
+ while (true) {
String assign;
Variant value;
- error = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,&rp);
+ error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp);
if (error) {
- if (error!=ERR_FILE_EOF) {
+ if (error != ERR_FILE_EOF) {
_printerr();
} else {
- resource=packed_scene;
+ resource = packed_scene;
if (!ResourceCache::has(res_path)) {
packed_scene->set_path(res_path);
}
@@ -536,57 +509,56 @@ Error ResourceInteractiveLoaderText::poll() {
return error;
}
- if (assign!=String()) {
+ if (assign != String()) {
int nameidx = packed_scene->get_state()->add_name(assign);
int valueidx = packed_scene->get_state()->add_value(value);
- packed_scene->get_state()->add_node_property(node_id,nameidx,valueidx);
+ packed_scene->get_state()->add_node_property(node_id, nameidx, valueidx);
//it's assignment
- } else if (next_tag.name!=String()) {
+ } else if (next_tag.name != String()) {
- error=OK;
+ error = OK;
return error;
} else {
- resource=packed_scene;
- error=ERR_FILE_EOF;
+ resource = packed_scene;
+ error = ERR_FILE_EOF;
return error;
}
-
}
return OK;
- } else if (next_tag.name=="connection") {
+ } else if (next_tag.name == "connection") {
if (!is_scene) {
- error_text+="found the 'connection' tag on a resource file!";
+ error_text += "found the 'connection' tag on a resource file!";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
if (!next_tag.fields.has("from")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'from' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'from' field fron connection tag";
return error;
}
if (!next_tag.fields.has("to")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'to' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'to' field fron connection tag";
return error;
}
if (!next_tag.fields.has("signal")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'signal' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'signal' field fron connection tag";
return error;
}
if (!next_tag.fields.has("method")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'method' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'method' field fron connection tag";
return error;
}
@@ -594,55 +566,54 @@ Error ResourceInteractiveLoaderText::poll() {
NodePath to = next_tag.fields["to"];
StringName method = next_tag.fields["method"];
StringName signal = next_tag.fields["signal"];
- int flags=CONNECT_PERSIST;
+ int flags = CONNECT_PERSIST;
Array binds;
if (next_tag.fields.has("flags")) {
- flags=next_tag.fields["flags"];
+ flags = next_tag.fields["flags"];
}
if (next_tag.fields.has("binds")) {
- binds=next_tag.fields["binds"];
+ binds = next_tag.fields["binds"];
}
Vector<int> bind_ints;
- for(int i=0;i<binds.size();i++) {
- bind_ints.push_back( packed_scene->get_state()->add_value( binds[i] ) );
+ for (int i = 0; i < binds.size(); i++) {
+ bind_ints.push_back(packed_scene->get_state()->add_value(binds[i]));
}
packed_scene->get_state()->add_connection(
- packed_scene->get_state()->add_node_path(from.simplified()),
- packed_scene->get_state()->add_node_path(to.simplified()),
- packed_scene->get_state()->add_name(signal),
- packed_scene->get_state()->add_name(method),
- flags,
- bind_ints
- );
+ packed_scene->get_state()->add_node_path(from.simplified()),
+ packed_scene->get_state()->add_node_path(to.simplified()),
+ packed_scene->get_state()->add_name(signal),
+ packed_scene->get_state()->add_name(method),
+ flags,
+ bind_ints);
- error = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
+ error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
if (error) {
- if (error!=ERR_FILE_EOF) {
+ if (error != ERR_FILE_EOF) {
_printerr();
} else {
- resource=packed_scene;
+ resource = packed_scene;
}
}
return error;
- } else if (next_tag.name=="editable") {
+ } else if (next_tag.name == "editable") {
if (!is_scene) {
- error_text+="found the 'editable' tag on a resource file!";
+ error_text += "found the 'editable' tag on a resource file!";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
if (!next_tag.fields.has("path")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'path' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'path' field fron connection tag";
_printerr();
return error;
}
@@ -651,13 +622,13 @@ Error ResourceInteractiveLoaderText::poll() {
packed_scene->get_state()->add_editable_instance(path.simplified());
- error = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
+ error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
if (error) {
- if (error!=ERR_FILE_EOF) {
+ if (error != ERR_FILE_EOF) {
_printerr();
} else {
- resource=packed_scene;
+ resource = packed_scene;
}
}
@@ -665,9 +636,9 @@ Error ResourceInteractiveLoaderText::poll() {
} else {
- error_text+="Unknown tag in file: "+next_tag.name;
+ error_text += "Unknown tag in file: " + next_tag.name;
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
@@ -680,7 +651,7 @@ int ResourceInteractiveLoaderText::get_stage() const {
}
int ResourceInteractiveLoaderText::get_stage_count() const {
- return resources_total;//+ext_resources;
+ return resources_total; //+ext_resources;
}
ResourceInteractiveLoaderText::~ResourceInteractiveLoaderText() {
@@ -688,199 +659,184 @@ ResourceInteractiveLoaderText::~ResourceInteractiveLoaderText() {
memdelete(f);
}
-void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f,List<String> *p_dependencies,bool p_add_types) {
-
+void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f, List<String> *p_dependencies, bool p_add_types) {
open(f);
- ignore_resource_parsing=true;
- ERR_FAIL_COND(error!=OK);
+ ignore_resource_parsing = true;
+ ERR_FAIL_COND(error != OK);
- while(next_tag.name=="ext_resource") {
+ while (next_tag.name == "ext_resource") {
if (!next_tag.fields.has("type")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'type' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'type' in external resource tag";
_printerr();
return;
}
if (!next_tag.fields.has("id")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'index' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'index' in external resource tag";
_printerr();
return;
}
- String path=next_tag.fields["path"];
- String type=next_tag.fields["type"];
-
+ String path = next_tag.fields["path"];
+ String type = next_tag.fields["type"];
- if (path.find("://")==-1 && path.is_rel_path()) {
+ if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path=Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
+ path = Globals::get_singleton()->localize_path(local_path.get_base_dir().plus_file(path));
}
-
if (p_add_types) {
- path+="::"+type;
+ path += "::" + type;
}
p_dependencies->push_back(path);
- Error err = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
+ Error err = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
if (err) {
- print_line(error_text+" - "+itos(lines));
- error_text="Unexpected end of file";
+ print_line(error_text + " - " + itos(lines));
+ error_text = "Unexpected end of file";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
}
-
-
}
}
-Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData& r_export_data) {
-
+Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f, ExportData &r_export_data) {
open(p_f);
- ERR_FAIL_COND_V(error!=OK,error);
+ ERR_FAIL_COND_V(error != OK, error);
+ while (true) {
- while(true) {
-
- print_line("next tag is: "+next_tag.name);
-
- if (next_tag.name=="ext_resource") {
+ print_line("next tag is: " + next_tag.name);
+ if (next_tag.name == "ext_resource") {
if (!next_tag.fields.has("path")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'path' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'path' in external resource tag";
_printerr();
return error;
}
if (!next_tag.fields.has("type")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'type' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'type' in external resource tag";
_printerr();
return error;
}
if (!next_tag.fields.has("id")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'id' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'id' in external resource tag";
_printerr();
return error;
}
- String path=next_tag.fields["path"];
- String type=next_tag.fields["type"];
- int index=next_tag.fields["id"];
-
+ String path = next_tag.fields["path"];
+ String type = next_tag.fields["type"];
+ int index = next_tag.fields["id"];
ExportData::Dependency dep;
- dep.path=path;
- dep.type=type;
- r_export_data.dependencies[index]=dep;
+ dep.path = path;
+ dep.type = type;
+ r_export_data.dependencies[index] = dep;
- error = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp_export);
+ error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp_export);
if (error) {
_printerr();
return error;
}
-
- } else if (next_tag.name=="sub_resource") {
-
+ } else if (next_tag.name == "sub_resource") {
if (!next_tag.fields.has("type")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'type' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'type' in external resource tag";
_printerr();
return error;
}
if (!next_tag.fields.has("id")) {
- error=ERR_FILE_CORRUPT;
- error_text="Missing 'index' in external resource tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Missing 'index' in external resource tag";
_printerr();
return error;
}
- String type=next_tag.fields["type"];
- int id=next_tag.fields["id"];
-
- r_export_data.resources.resize( r_export_data.resources.size()+1 );
- ExportData::ResourceData &res_data=r_export_data.resources[ r_export_data.resources.size()-1 ];
+ String type = next_tag.fields["type"];
+ int id = next_tag.fields["id"];
- res_data.type=type;
- res_data.index=id;
+ r_export_data.resources.resize(r_export_data.resources.size() + 1);
+ ExportData::ResourceData &res_data = r_export_data.resources[r_export_data.resources.size() - 1];
+ res_data.type = type;
+ res_data.index = id;
- while(true) {
+ while (true) {
String assign;
Variant value;
- error = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,&rp_export);
- print_line("get prop: "+assign);
+ error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_export);
+ print_line("get prop: " + assign);
if (error) {
_printerr();
return error;
}
- if (assign!=String()) {
+ if (assign != String()) {
ExportData::PropertyData pdata;
- pdata.name=assign;
- pdata.value=value;
+ pdata.name = assign;
+ pdata.value = value;
res_data.properties.push_back(pdata);
//it's assignment
- } else if (next_tag.name!=String()) {
+ } else if (next_tag.name != String()) {
- error=OK;
+ error = OK;
break;
} else {
- error=ERR_FILE_CORRUPT;
- error_text="Premature end of file while parsing [sub_resource]";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Premature end of file while parsing [sub_resource]";
_printerr();
return error;
}
-
-
}
- } else if (next_tag.name=="resource") {
+ } else if (next_tag.name == "resource") {
if (is_scene) {
- error_text+="found the 'resource' tag on a scene file!";
+ error_text += "found the 'resource' tag on a scene file!";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
+ r_export_data.resources.resize(r_export_data.resources.size() + 1);
+ ExportData::ResourceData &res_data = r_export_data.resources[r_export_data.resources.size() - 1];
+ res_data.index = -1;
+ res_data.type = res_type;
- r_export_data.resources.resize( r_export_data.resources.size()+1 );
- ExportData::ResourceData &res_data=r_export_data.resources[ r_export_data.resources.size()-1 ];
- res_data.index=-1;
- res_data.type=res_type;
-
- while(true) {
+ while (true) {
String assign;
Variant value;
- error = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,&rp_export);
+ error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_export);
if (error) {
- if (error!=ERR_FILE_EOF) {
+ if (error != ERR_FILE_EOF) {
_printerr();
} else {
return OK;
@@ -888,53 +844,48 @@ Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData&
return error;
}
- if (assign!=String()) {
+ if (assign != String()) {
ExportData::PropertyData pdata;
- pdata.name=assign;
- pdata.value=value;
+ pdata.name = assign;
+ pdata.value = value;
res_data.properties.push_back(pdata);
//it's assignment
- } else if (next_tag.name!=String()) {
+ } else if (next_tag.name != String()) {
- error=ERR_FILE_CORRUPT;
- error_text="Extra tag found when parsing main resource file";
+ error = ERR_FILE_CORRUPT;
+ error_text = "Extra tag found when parsing main resource file";
_printerr();
return error;
} else {
return OK;
}
-
}
return OK;
- } else if (next_tag.name=="node") {
+ } else if (next_tag.name == "node") {
if (!is_scene) {
- error_text+="found the 'node' tag on a resource file!";
+ error_text += "found the 'node' tag on a resource file!";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
-
- r_export_data.nodes.resize( r_export_data.nodes.size()+1 );
- ExportData::NodeData &node_data=r_export_data.nodes[ r_export_data.nodes.size()-1 ];
-
+ r_export_data.nodes.resize(r_export_data.nodes.size() + 1);
+ ExportData::NodeData &node_data = r_export_data.nodes[r_export_data.nodes.size() - 1];
if (next_tag.fields.has("name")) {
- node_data.name=next_tag.fields["name"];
+ node_data.name = next_tag.fields["name"];
}
if (next_tag.fields.has("parent")) {
- node_data.parent=next_tag.fields["parent"];
+ node_data.parent = next_tag.fields["parent"];
}
-
-
if (next_tag.fields.has("type")) {
- node_data.type=next_tag.fields["type"];
+ node_data.type = next_tag.fields["type"];
}
if (next_tag.fields.has("instance")) {
@@ -948,46 +899,45 @@ Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData&
}
if (next_tag.fields.has("owner")) {
- node_data.owner=next_tag.fields["owner"];
+ node_data.owner = next_tag.fields["owner"];
}
if (next_tag.fields.has("groups")) {
Array groups = next_tag.fields["groups"];
- for (int i=0;i<groups.size();i++) {
+ for (int i = 0; i < groups.size(); i++) {
node_data.groups.push_back(groups[i]);
}
}
- while(true) {
+ while (true) {
String assign;
Variant value;
- error = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,&rp_export);
+ error = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, &rp_export);
- print_line("get prop: "+assign);
+ print_line("get prop: " + assign);
if (error) {
- if (error!=ERR_FILE_EOF) {
+ if (error != ERR_FILE_EOF) {
_printerr();
return error;
} else {
return OK;
}
-
}
- if (assign!=String()) {
+ if (assign != String()) {
ExportData::PropertyData pdata;
- pdata.name=assign;
- pdata.value=value;
+ pdata.name = assign;
+ pdata.value = value;
node_data.properties.push_back(pdata);
//it's assignment
- } else if (next_tag.name!=String()) {
+ } else if (next_tag.name != String()) {
print_line("found something else?");
break; //something else
} else {
@@ -995,42 +945,39 @@ Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData&
//all done?
return OK;
}
-
}
-
-
- } else if (next_tag.name=="connection") {
+ } else if (next_tag.name == "connection") {
if (!is_scene) {
- error_text+="found the 'connection' tag on a resource file!";
+ error_text += "found the 'connection' tag on a resource file!";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
if (!next_tag.fields.has("from")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'from' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'from' field fron connection tag";
return error;
}
if (!next_tag.fields.has("to")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'to' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'to' field fron connection tag";
return error;
}
if (!next_tag.fields.has("signal")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'signal' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'signal' field fron connection tag";
return error;
}
if (!next_tag.fields.has("method")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'method' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'method' field fron connection tag";
return error;
}
@@ -1038,31 +985,31 @@ Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData&
NodePath to = next_tag.fields["to"];
StringName method = next_tag.fields["method"];
StringName signal = next_tag.fields["signal"];
- int flags=CONNECT_PERSIST;
+ int flags = CONNECT_PERSIST;
Array binds;
if (next_tag.fields.has("flags")) {
- flags=next_tag.fields["flags"];
+ flags = next_tag.fields["flags"];
}
if (next_tag.fields.has("binds")) {
- binds=next_tag.fields["binds"];
+ binds = next_tag.fields["binds"];
}
ExportData::Connection conn;
- conn.from=from;
- conn.to=to;
- conn.method=method;
- conn.signal=signal;
- conn.binds=binds;
- conn.flags=flags;
+ conn.from = from;
+ conn.to = to;
+ conn.method = method;
+ conn.signal = signal;
+ conn.binds = binds;
+ conn.flags = flags;
r_export_data.connections.push_back(conn);
- error = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp_export);
+ error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp_export);
if (error) {
- if (error!=ERR_FILE_EOF) {
+ if (error != ERR_FILE_EOF) {
_printerr();
return error;
} else {
@@ -1072,19 +1019,19 @@ Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData&
continue;
- } else if (next_tag.name=="editable") {
+ } else if (next_tag.name == "editable") {
if (!is_scene) {
- error_text+="found the 'editable' tag on a resource file!";
+ error_text += "found the 'editable' tag on a resource file!";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
if (!next_tag.fields.has("path")) {
- error=ERR_FILE_CORRUPT;
- error_text="missing 'path' field fron connection tag";
+ error = ERR_FILE_CORRUPT;
+ error_text = "missing 'path' field fron connection tag";
_printerr();
return error;
}
@@ -1093,10 +1040,10 @@ Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData&
r_export_data.editables.push_back(path);
- error = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp_export);
+ error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp_export);
if (error) {
- if (error!=ERR_FILE_EOF) {
+ if (error != ERR_FILE_EOF) {
_printerr();
return error;
} else {
@@ -1108,9 +1055,9 @@ Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData&
} else {
- error_text+="Unknown tag in file: "+next_tag.name;
+ error_text += "Unknown tag in file: " + next_tag.name;
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
return error;
}
}
@@ -1118,37 +1065,32 @@ Error ResourceInteractiveLoaderText::get_export_data(FileAccess *p_f,ExportData&
ERR_FAIL_V(ERR_BUG);
}
-Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const String &p_path,const Map<String,String>& p_map) {
+Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const String &p_path, const Map<String, String> &p_map) {
-
- open(p_f,true);
- ERR_FAIL_COND_V(error!=OK,error);
- ignore_resource_parsing=true;
+ open(p_f, true);
+ ERR_FAIL_COND_V(error != OK, error);
+ ignore_resource_parsing = true;
//FileAccess
FileAccess *fw = NULL;
- String base_path=local_path.get_base_dir();
-
+ String base_path = local_path.get_base_dir();
uint64_t tag_end = f->get_pos();
+ while (true) {
- while(true) {
-
-
+ Error err = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
- Error err = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
-
- if (err!=OK) {
+ if (err != OK) {
if (fw) {
memdelete(fw);
}
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
ERR_FAIL_V(error);
}
- if (next_tag.name!="ext_resource") {
+ if (next_tag.name != "ext_resource") {
//nothing was done
if (!fw)
@@ -1156,22 +1098,21 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const
break;
-
} else {
if (!fw) {
- fw=FileAccess::open(p_path+".depren",FileAccess::WRITE);
+ fw = FileAccess::open(p_path + ".depren", FileAccess::WRITE);
if (is_scene) {
- fw->store_line("[gd_scene load_steps="+itos(resources_total)+" format="+itos(FORMAT_VERSION)+"]\n");
+ fw->store_line("[gd_scene load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + "]\n");
} else {
- fw->store_line("[gd_resource type=\""+res_type+"\" load_steps="+itos(resources_total)+" format="+itos(FORMAT_VERSION)+"]\n");
+ fw->store_line("[gd_resource type=\"" + res_type + "\" load_steps=" + itos(resources_total) + " format=" + itos(FORMAT_VERSION) + "]\n");
}
}
if (!next_tag.fields.has("path") || !next_tag.fields.has("id") || !next_tag.fields.has("type")) {
memdelete(fw);
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
ERR_FAIL_V(error);
}
@@ -1179,41 +1120,38 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const
int index = next_tag.fields["id"];
String type = next_tag.fields["type"];
-
- bool relative=false;
+ bool relative = false;
if (!path.begins_with("res://")) {
- path=base_path.plus_file(path).simplify_path();
- relative=true;
+ path = base_path.plus_file(path).simplify_path();
+ relative = true;
}
if (p_map.has(path)) {
- String np=p_map[path];
- path=np;
+ String np = p_map[path];
+ path = np;
}
if (relative) {
//restore relative
- path=base_path.path_to_file(path);
+ path = base_path.path_to_file(path);
}
- fw->store_line("[ext_resource path=\""+path+"\" type=\""+type+"\" id="+itos(index)+"]");
+ fw->store_line("[ext_resource path=\"" + path + "\" type=\"" + type + "\" id=" + itos(index) + "]");
tag_end = f->get_pos();
-
}
-
}
f->seek(tag_end);
- uint8_t c=f->get_8();
- while(!f->eof_reached()) {
+ uint8_t c = f->get_8();
+ while (!f->eof_reached()) {
fw->store_8(c);
- c=f->get_8();
+ c = f->get_8();
}
f->close();
- bool all_ok = fw->get_error()==OK;
+ bool all_ok = fw->get_error() == OK;
memdelete(fw);
@@ -1223,119 +1161,106 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
da->remove(p_path);
- da->rename(p_path+".depren",p_path);
+ da->rename(p_path + ".depren", p_path);
memdelete(da);
return OK;
-
}
+void ResourceInteractiveLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) {
-void ResourceInteractiveLoaderText::open(FileAccess *p_f,bool p_skip_first_tag) {
-
- error=OK;
-
- lines=1;
- f=p_f;
+ error = OK;
+ lines = 1;
+ f = p_f;
- stream.f=f;
- is_scene=false;
- ignore_resource_parsing=false;
- resource_current=0;
-
+ stream.f = f;
+ is_scene = false;
+ ignore_resource_parsing = false;
+ resource_current = 0;
VariantParser::Tag tag;
- Error err = VariantParser::parse_tag(&stream,lines,error_text,tag);
+ Error err = VariantParser::parse_tag(&stream, lines, error_text, tag);
if (err) {
- error=err;
+ error = err;
_printerr();
return;
}
if (tag.fields.has("format")) {
int fmt = tag.fields["format"];
- if (fmt>FORMAT_VERSION) {
- error_text="Saved with newer format version";
+ if (fmt > FORMAT_VERSION) {
+ error_text = "Saved with newer format version";
_printerr();
- error=ERR_PARSE_ERROR;
+ error = ERR_PARSE_ERROR;
return;
}
}
-
- if (tag.name=="gd_scene") {
- is_scene=true;
+ if (tag.name == "gd_scene") {
+ is_scene = true;
packed_scene.instance();
- } else if (tag.name=="gd_resource") {
+ } else if (tag.name == "gd_resource") {
if (!tag.fields.has("type")) {
- error_text="Missing 'type' field in 'gd_resource' tag";
+ error_text = "Missing 'type' field in 'gd_resource' tag";
_printerr();
- error=ERR_PARSE_ERROR;
+ error = ERR_PARSE_ERROR;
return;
}
- res_type=tag.fields["type"];
+ res_type = tag.fields["type"];
} else {
- error_text="Unrecognized file type: "+tag.name;
+ error_text = "Unrecognized file type: " + tag.name;
_printerr();
- error=ERR_PARSE_ERROR;
+ error = ERR_PARSE_ERROR;
return;
-
}
-
-
if (tag.fields.has("load_steps")) {
- resources_total=tag.fields["load_steps"];
+ resources_total = tag.fields["load_steps"];
} else {
- resources_total=0;
+ resources_total = 0;
}
if (!p_skip_first_tag) {
- err = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
+ err = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
if (err) {
- error_text="Unexpected end of file";
+ error_text = "Unexpected end of file";
_printerr();
- error=ERR_FILE_CORRUPT;
+ error = ERR_FILE_CORRUPT;
}
}
- rp.ext_func=_parse_ext_resources;
- rp.sub_func=_parse_sub_resources;
- rp.func=NULL;
- rp.userdata=this;
-
- rp_export.ext_func=_parse_ext_resources_export;
- rp_export.sub_func=_parse_sub_resources_export;
- rp_export.func=NULL;
- rp_export.userdata=this;
+ rp.ext_func = _parse_ext_resources;
+ rp.sub_func = _parse_sub_resources;
+ rp.func = NULL;
+ rp.userdata = this;
+ rp_export.ext_func = _parse_ext_resources_export;
+ rp_export.sub_func = _parse_sub_resources_export;
+ rp_export.func = NULL;
+ rp_export.userdata = this;
}
-
-
-
String ResourceInteractiveLoaderText::recognize(FileAccess *p_f) {
- error=OK;
+ error = OK;
- lines=1;
- f=p_f;
+ lines = 1;
+ f = p_f;
- stream.f=f;
-
- ignore_resource_parsing=true;
+ stream.f = f;
+ ignore_resource_parsing = true;
VariantParser::Tag tag;
- Error err = VariantParser::parse_tag(&stream,lines,error_text,tag);
+ Error err = VariantParser::parse_tag(&stream, lines, error_text, tag);
if (err) {
_printerr();
@@ -1344,30 +1269,26 @@ String ResourceInteractiveLoaderText::recognize(FileAccess *p_f) {
if (tag.fields.has("format")) {
int fmt = tag.fields["format"];
- if (fmt>FORMAT_VERSION) {
- error_text="Saved with newer format version";
+ if (fmt > FORMAT_VERSION) {
+ error_text = "Saved with newer format version";
_printerr();
return "";
}
}
- if (tag.name=="gd_scene")
+ if (tag.name == "gd_scene")
return "PackedScene";
- if (tag.name!="gd_resource")
+ if (tag.name != "gd_resource")
return "";
-
-
if (!tag.fields.has("type")) {
- error_text="Missing 'type' field in 'gd_resource' tag";
+ error_text = "Missing 'type' field in 'gd_resource' tag";
_printerr();
return "";
}
return tag.fields["type"];
-
-
}
/////////////////////
@@ -1375,134 +1296,124 @@ String ResourceInteractiveLoaderText::recognize(FileAccess *p_f) {
Ref<ResourceInteractiveLoader> ResourceFormatLoaderText::load_interactive(const String &p_path, Error *r_error) {
if (r_error)
- *r_error=ERR_CANT_OPEN;
+ *r_error = ERR_CANT_OPEN;
Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err);
-
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (err!=OK) {
+ if (err != OK) {
- ERR_FAIL_COND_V(err!=OK,Ref<ResourceInteractiveLoader>());
+ ERR_FAIL_COND_V(err != OK, Ref<ResourceInteractiveLoader>());
}
- Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
- ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
+ ria->local_path = Globals::get_singleton()->localize_path(p_path);
+ ria->res_path = ria->local_path;
+ // ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->open(f);
return ria;
}
-void ResourceFormatLoaderText::get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const {
+void ResourceFormatLoaderText::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
- if (p_type=="") {
+ if (p_type == "") {
get_recognized_extensions(p_extensions);
return;
}
- if (p_type=="PackedScene")
+ if (p_type == "PackedScene")
p_extensions->push_back("tscn");
else
p_extensions->push_back("tres");
-
}
-void ResourceFormatLoaderText::get_recognized_extensions(List<String> *p_extensions) const{
+void ResourceFormatLoaderText::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("tscn");
p_extensions->push_back("tres");
}
-bool ResourceFormatLoaderText::handles_type(const String& p_type) const{
+bool ResourceFormatLoaderText::handles_type(const String &p_type) const {
return true;
}
-String ResourceFormatLoaderText::get_resource_type(const String &p_path) const{
-
-
+String ResourceFormatLoaderText::get_resource_type(const String &p_path) const {
- String ext=p_path.extension().to_lower();
- if (ext=="tscn")
+ String ext = p_path.extension().to_lower();
+ if (ext == "tscn")
return "PackedScene";
- else if (ext!="tres")
+ else if (ext != "tres")
return String();
//for anyhting else must test..
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
return ""; //could not rwead
}
- Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
- ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
+ ria->local_path = Globals::get_singleton()->localize_path(p_path);
+ ria->res_path = ria->local_path;
+ // ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
return r;
}
+void ResourceFormatLoaderText::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
-void ResourceFormatLoaderText::get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types) {
-
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
ERR_FAIL();
}
- Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
- ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
- ria->get_dependencies(f,p_dependencies,p_add_types);
-
-
+ Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
+ ria->local_path = Globals::get_singleton()->localize_path(p_path);
+ ria->res_path = ria->local_path;
+ // ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ ria->get_dependencies(f, p_dependencies, p_add_types);
}
-ResourceFormatLoaderText* ResourceFormatLoaderText::singleton=NULL;
+ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = NULL;
-Error ResourceFormatLoaderText::get_export_data(const String& p_path,ExportData& r_export_data) {
+Error ResourceFormatLoaderText::get_export_data(const String &p_path, ExportData &r_export_data) {
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
ERR_FAIL_V(ERR_CANT_OPEN);
}
- Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
- ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
- Error err = ria->get_export_data(f,r_export_data);
- if (err!=OK) {
- ERR_PRINTS("ERROR: "+ria->error_text);
+ Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
+ ria->local_path = Globals::get_singleton()->localize_path(p_path);
+ ria->res_path = ria->local_path;
+ // ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ Error err = ria->get_export_data(f, r_export_data);
+ if (err != OK) {
+ ERR_PRINTS("ERROR: " + ria->error_text);
}
return err;
}
+Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
-
-Error ResourceFormatLoaderText::rename_dependencies(const String &p_path,const Map<String,String>& p_map) {
-
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ);
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
if (!f) {
ERR_FAIL_V(ERR_CANT_OPEN);
}
- Ref<ResourceInteractiveLoaderText> ria = memnew( ResourceInteractiveLoaderText );
- ria->local_path=Globals::get_singleton()->localize_path(p_path);
- ria->res_path=ria->local_path;
-// ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
- return ria->rename_dependencies(f,p_path,p_map);
+ Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
+ ria->local_path = Globals::get_singleton()->localize_path(p_path);
+ ria->res_path = ria->local_path;
+ // ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
+ return ria->rename_dependencies(f, p_path, p_map);
}
-
/*****************************************************************************************************/
/*****************************************************************************************************/
/*****************************************************************************************************/
@@ -1514,28 +1425,26 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path,const M
/*****************************************************************************************************/
/*****************************************************************************************************/
+String ResourceFormatSaverTextInstance::_write_resources(void *ud, const RES &p_resource) {
-String ResourceFormatSaverTextInstance::_write_resources(void *ud,const RES& p_resource) {
-
- ResourceFormatSaverTextInstance *rsi=(ResourceFormatSaverTextInstance*)ud;
+ ResourceFormatSaverTextInstance *rsi = (ResourceFormatSaverTextInstance *)ud;
return rsi->_write_resource(p_resource);
-
}
-String ResourceFormatSaverTextInstance::_write_resource(const RES& res) {
+String ResourceFormatSaverTextInstance::_write_resource(const RES &res) {
if (external_resources.has(res)) {
- return "ExtResource( "+itos(external_resources[res]+1)+" )";
+ return "ExtResource( " + itos(external_resources[res] + 1) + " )";
} else {
if (internal_resources.has(res)) {
- return "SubResource( "+itos(internal_resources[res])+" )";
- } else if (res->get_path().length() && res->get_path().find("::")==-1) {
+ return "SubResource( " + itos(internal_resources[res]) + " )";
+ } else if (res->get_path().length() && res->get_path().find("::") == -1) {
//external resource
- String path=relative_paths?local_path.path_to_file(res->get_path()):res->get_path();
- return "Resource( \""+path+"\" )";
+ String path = relative_paths ? local_path.path_to_file(res->get_path()) : res->get_path();
+ return "Resource( \"" + path + "\" )";
} else {
ERR_EXPLAIN("Resource was not pre cached for the resource section, bug?");
ERR_FAIL_V("null");
@@ -1546,21 +1455,19 @@ String ResourceFormatSaverTextInstance::_write_resource(const RES& res) {
return "null";
}
-void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,bool p_main) {
+void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, bool p_main) {
-
- switch(p_variant.get_type()) {
+ switch (p_variant.get_type()) {
case Variant::OBJECT: {
-
RES res = p_variant.operator RefPtr();
if (res.is_null() || external_resources.has(res))
return;
- if (!p_main && (!bundle_resources ) && res->get_path().length() && res->get_path().find("::") == -1 ) {
+ if (!p_main && (!bundle_resources) && res->get_path().length() && res->get_path().find("::") == -1) {
int index = external_resources.size();
- external_resources[res]=index;
+ external_resources[res] = index;
return;
}
@@ -1569,45 +1476,45 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,b
List<PropertyInfo> property_list;
- res->get_property_list( &property_list );
+ res->get_property_list(&property_list);
property_list.sort();
- List<PropertyInfo>::Element *I=property_list.front();
+ List<PropertyInfo>::Element *I = property_list.front();
- while(I) {
+ while (I) {
- PropertyInfo pi=I->get();
+ PropertyInfo pi = I->get();
- if (pi.usage&PROPERTY_USAGE_STORAGE || (bundle_resources && pi.usage&PROPERTY_USAGE_BUNDLE)) {
+ if (pi.usage & PROPERTY_USAGE_STORAGE || (bundle_resources && pi.usage & PROPERTY_USAGE_BUNDLE)) {
- Variant v=res->get(I->get().name);
+ Variant v = res->get(I->get().name);
_find_resources(v);
}
- I=I->next();
+ I = I->next();
}
- resource_set.insert( res ); //saved after, so the childs it needs are available when loaded
+ resource_set.insert(res); //saved after, so the childs it needs are available when loaded
saved_resources.push_back(res);
} break;
case Variant::ARRAY: {
- Array varray=p_variant;
- int len=varray.size();
- for(int i=0;i<len;i++) {
+ Array varray = p_variant;
+ int len = varray.size();
+ for (int i = 0; i < len; i++) {
- Variant v=varray.get(i);
+ Variant v = varray.get(i);
_find_resources(v);
}
} break;
case Variant::DICTIONARY: {
- Dictionary d=p_variant;
+ Dictionary d = p_variant;
List<Variant> keys;
d.get_key_list(&keys);
- for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
+ for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
Variant v = d[E->get()];
_find_resources(v);
@@ -1615,90 +1522,87 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,b
} break;
default: {}
}
-
}
-static String _valprop(const String& p_name) {
+static String _valprop(const String &p_name) {
- if (p_name.find("\"")!=-1 || p_name.find("=")!=-1 || p_name.find(" ")!=-1)
- return "\""+p_name.c_escape_multiline()+"\"";
+ if (p_name.find("\"") != -1 || p_name.find("=") != -1 || p_name.find(" ") != -1)
+ return "\"" + p_name.c_escape_multiline() + "\"";
return p_name;
}
-Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_resource,uint32_t p_flags) {
+Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
if (p_path.ends_with(".tscn")) {
- packed_scene=p_resource;
+ packed_scene = p_resource;
}
Error err;
- f = FileAccess::open(p_path, FileAccess::WRITE,&err);
- ERR_FAIL_COND_V( err, ERR_CANT_OPEN );
+ f = FileAccess::open(p_path, FileAccess::WRITE, &err);
+ ERR_FAIL_COND_V(err, ERR_CANT_OPEN);
FileAccessRef _fref(f);
local_path = Globals::get_singleton()->localize_path(p_path);
- relative_paths=p_flags&ResourceSaver::FLAG_RELATIVE_PATHS;
- skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
- bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES;
- takeover_paths=p_flags&ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
+ relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS;
+ skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
+ bundle_resources = p_flags & ResourceSaver::FLAG_BUNDLE_RESOURCES;
+ takeover_paths = p_flags & ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
if (!p_path.begins_with("res://")) {
- takeover_paths=false;
+ takeover_paths = false;
}
// save resources
- _find_resources(p_resource,true);
+ _find_resources(p_resource, true);
if (packed_scene.is_valid()) {
//add instances to external resources if saving a packed scene
- for(int i=0;i<packed_scene->get_state()->get_node_count();i++) {
+ for (int i = 0; i < packed_scene->get_state()->get_node_count(); i++) {
if (packed_scene->get_state()->is_node_instance_placeholder(i))
continue;
- Ref<PackedScene> instance=packed_scene->get_state()->get_node_instance(i);
+ Ref<PackedScene> instance = packed_scene->get_state()->get_node_instance(i);
if (instance.is_valid() && !external_resources.has(instance)) {
int index = external_resources.size();
- external_resources[instance]=index;
+ external_resources[instance] = index;
}
}
}
-
- ERR_FAIL_COND_V(err!=OK,err);
+ ERR_FAIL_COND_V(err != OK, err);
{
- String title=packed_scene.is_valid()?"[gd_scene ":"[gd_resource ";
+ String title = packed_scene.is_valid() ? "[gd_scene " : "[gd_resource ";
if (packed_scene.is_null())
- title+="type=\""+p_resource->get_type()+"\" ";
- int load_steps=saved_resources.size()+external_resources.size();
+ title += "type=\"" + p_resource->get_type() + "\" ";
+ int load_steps = saved_resources.size() + external_resources.size();
//if (packed_scene.is_valid()) {
// load_steps+=packed_scene->get_node_count();
//}
//no, better to not use load steps from nodes, no point to that
- if (load_steps>1) {
- title+="load_steps="+itos(load_steps)+" ";
+ if (load_steps > 1) {
+ title += "load_steps=" + itos(load_steps) + " ";
}
- title+="format="+itos(FORMAT_VERSION)+"";
+ title += "format=" + itos(FORMAT_VERSION) + "";
//title+="engine_version=\""+itos(VERSION_MAJOR)+"."+itos(VERSION_MINOR)+"\"";
f->store_string(title);
f->store_line("]\n"); //one empty line
}
-
Vector<RES> sorted_er;
sorted_er.resize(external_resources.size());
- for(Map<RES,int>::Element *E=external_resources.front();E;E=E->next()) {
+ for (Map<RES, int>::Element *E = external_resources.front(); E; E = E->next()) {
- sorted_er[E->get()]=E->key();
+ sorted_er[E->get()] = E->key();
}
- for(int i=0;i<sorted_er.size();i++) {
+ for (int i = 0; i < sorted_er.size(); i++) {
String p = sorted_er[i]->get_path();
- f->store_string("[ext_resource path=\""+p+"\" type=\""+sorted_er[i]->get_save_type()+"\" id="+itos(i+1)+"]\n"); //bundled
+ f->store_string("[ext_resource path=\"" + p + "\" type=\"" + sorted_er[i]->get_save_type() + "\" id=" + itos(i + 1) + "]\n"); //bundled
}
if (external_resources.size())
@@ -1706,12 +1610,12 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
Set<int> used_indices;
- for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) {
+ for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) {
RES res = E->get();
- if (E->next() && (res->get_path()=="" || res->get_path().find("::") != -1 )) {
+ if (E->next() && (res->get_path() == "" || res->get_path().find("::") != -1)) {
- if (res->get_subindex()!=0) {
+ if (res->get_subindex() != 0) {
if (used_indices.has(res->get_subindex())) {
res->set_subindex(0); //repeated
} else {
@@ -1721,11 +1625,11 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
}
}
- for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) {
+ for (List<RES>::Element *E = saved_resources.front(); E; E = E->next()) {
RES res = E->get();
ERR_CONTINUE(!resource_set.has(res));
- bool main = (E->next()==NULL);
+ bool main = (E->next() == NULL);
if (main && packed_scene.is_valid())
break; //save as a scene
@@ -1733,11 +1637,11 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
if (main) {
f->store_line("[resource]\n");
} else {
- String line="[sub_resource ";
- if (res->get_subindex()==0) {
- int new_subindex=1;
+ String line = "[sub_resource ";
+ if (res->get_subindex() == 0) {
+ int new_subindex = 1;
if (used_indices.size()) {
- new_subindex=used_indices.back()->get()+1;
+ new_subindex = used_indices.back()->get() + 1;
}
res->set_subindex(new_subindex);
@@ -1745,93 +1649,84 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
}
int idx = res->get_subindex();
- line+="type=\""+res->get_type()+"\" id="+itos(idx);
- f->store_line(line+"]\n");
+ line += "type=\"" + res->get_type() + "\" id=" + itos(idx);
+ f->store_line(line + "]\n");
if (takeover_paths) {
- res->set_path(p_path+"::"+itos(idx),true);
+ res->set_path(p_path + "::" + itos(idx), true);
}
- internal_resources[res]=idx;
-
+ internal_resources[res] = idx;
}
-
List<PropertyInfo> property_list;
res->get_property_list(&property_list);
-// property_list.sort();
- for(List<PropertyInfo>::Element *PE = property_list.front();PE;PE=PE->next()) {
-
+ // property_list.sort();
+ for (List<PropertyInfo>::Element *PE = property_list.front(); PE; PE = PE->next()) {
if (skip_editor && PE->get().name.begins_with("__editor"))
continue;
- if (PE->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && PE->get().usage&PROPERTY_USAGE_BUNDLE)) {
+ if (PE->get().usage & PROPERTY_USAGE_STORAGE || (bundle_resources && PE->get().usage & PROPERTY_USAGE_BUNDLE)) {
String name = PE->get().name;
Variant value = res->get(name);
-
- if ((PE->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero())||(PE->get().usage&PROPERTY_USAGE_STORE_IF_NONONE && value.is_one()) )
+ if ((PE->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero()) || (PE->get().usage & PROPERTY_USAGE_STORE_IF_NONONE && value.is_one()))
continue;
- if (PE->get().type==Variant::OBJECT && value.is_zero() && !(PE->get().usage&PROPERTY_USAGE_STORE_IF_NULL))
+ if (PE->get().type == Variant::OBJECT && value.is_zero() && !(PE->get().usage & PROPERTY_USAGE_STORE_IF_NULL))
continue;
String vars;
- VariantWriter::write_to_string(value,vars,_write_resources,this);
- f->store_string(_valprop(name)+" = "+vars+"\n");
+ VariantWriter::write_to_string(value, vars, _write_resources, this);
+ f->store_string(_valprop(name) + " = " + vars + "\n");
}
-
-
}
f->store_string("\n");
-
}
if (packed_scene.is_valid()) {
//if this is a scene, save nodes and connections!
Ref<SceneState> state = packed_scene->get_state();
- for(int i=0;i<state->get_node_count();i++) {
+ for (int i = 0; i < state->get_node_count(); i++) {
StringName type = state->get_node_type(i);
StringName name = state->get_node_name(i);
- NodePath path = state->get_node_path(i,true);
+ NodePath path = state->get_node_path(i, true);
NodePath owner = state->get_node_owner_path(i);
Ref<PackedScene> instance = state->get_node_instance(i);
String instance_placeholder = state->get_node_instance_placeholder(i);
Vector<StringName> groups = state->get_node_groups(i);
-
-
- String header="[node";
- header+=" name=\""+String(name)+"\"";
- if (type!=StringName()) {
- header+=" type=\""+String(type)+"\"";
+ String header = "[node";
+ header += " name=\"" + String(name) + "\"";
+ if (type != StringName()) {
+ header += " type=\"" + String(type) + "\"";
}
- if (path!=NodePath()) {
- header+=" parent=\""+String(path.simplified())+"\"";
+ if (path != NodePath()) {
+ header += " parent=\"" + String(path.simplified()) + "\"";
}
- if (owner!=NodePath() && owner!=NodePath(".")) {
- header+=" owner=\""+String(owner.simplified())+"\"";
+ if (owner != NodePath() && owner != NodePath(".")) {
+ header += " owner=\"" + String(owner.simplified()) + "\"";
}
if (groups.size()) {
- String sgroups=" groups=[\n";
- for(int j=0;j<groups.size();j++) {
- sgroups+="\""+String(groups[j]).c_escape()+"\",\n";
+ String sgroups = " groups=[\n";
+ for (int j = 0; j < groups.size(); j++) {
+ sgroups += "\"" + String(groups[j]).c_escape() + "\",\n";
}
- sgroups+="]";
- header+=sgroups;
+ sgroups += "]";
+ header += sgroups;
}
f->store_string(header);
- if (instance_placeholder!=String()) {
+ if (instance_placeholder != String()) {
String vars;
f->store_string(" instance_placeholder=");
- VariantWriter::write_to_string(instance_placeholder,vars,_write_resources,this);
+ VariantWriter::write_to_string(instance_placeholder, vars, _write_resources, this);
f->store_string(vars);
}
@@ -1839,47 +1734,44 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
String vars;
f->store_string(" instance=");
- VariantWriter::write_to_string(instance,vars,_write_resources,this);
+ VariantWriter::write_to_string(instance, vars, _write_resources, this);
f->store_string(vars);
-
}
f->store_line("]\n");
- for(int j=0;j<state->get_node_property_count(i);j++) {
+ for (int j = 0; j < state->get_node_property_count(i); j++) {
String vars;
- VariantWriter::write_to_string(state->get_node_property_value(i,j),vars,_write_resources,this);
+ VariantWriter::write_to_string(state->get_node_property_value(i, j), vars, _write_resources, this);
- f->store_string(_valprop(String(state->get_node_property_name(i,j)))+" = "+vars+"\n");
+ f->store_string(_valprop(String(state->get_node_property_name(i, j))) + " = " + vars + "\n");
}
if (state->get_node_property_count(i)) {
//add space
f->store_line(String());
}
-
}
- for(int i=0;i<state->get_connection_count();i++) {
+ for (int i = 0; i < state->get_connection_count(); i++) {
- String connstr="[connection";
- connstr+=" signal=\""+String(state->get_connection_signal(i))+"\"";
- connstr+=" from=\""+String(state->get_connection_source(i).simplified())+"\"";
- connstr+=" to=\""+String(state->get_connection_target(i).simplified())+"\"";
- connstr+=" method=\""+String(state->get_connection_method(i))+"\"";
+ String connstr = "[connection";
+ connstr += " signal=\"" + String(state->get_connection_signal(i)) + "\"";
+ connstr += " from=\"" + String(state->get_connection_source(i).simplified()) + "\"";
+ connstr += " to=\"" + String(state->get_connection_target(i).simplified()) + "\"";
+ connstr += " method=\"" + String(state->get_connection_method(i)) + "\"";
int flags = state->get_connection_flags(i);
- if (flags!=Object::CONNECT_PERSIST) {
- connstr+=" flags="+itos(flags);
+ if (flags != Object::CONNECT_PERSIST) {
+ connstr += " flags=" + itos(flags);
}
- Array binds=state->get_connection_binds(i);
+ Array binds = state->get_connection_binds(i);
f->store_string(connstr);
if (binds.size()) {
String vars;
- VariantWriter::write_to_string(binds,vars,_write_resources,this);
- f->store_string(" binds= "+vars);
-
+ VariantWriter::write_to_string(binds, vars, _write_resources, this);
+ f->store_string(" binds= " + vars);
}
f->store_line("]\n");
@@ -1888,12 +1780,12 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
f->store_line(String());
Vector<NodePath> editable_instances = state->get_editable_instances();
- for(int i=0;i<editable_instances.size();i++) {
- f->store_line("[editable path=\""+editable_instances[i].operator String()+"\"]");
+ for (int i = 0; i < editable_instances.size(); i++) {
+ f->store_line("[editable path=\"" + editable_instances[i].operator String() + "\"]");
}
}
- if (f->get_error()!=OK && f->get_error()!=ERR_FILE_EOF) {
+ if (f->get_error() != OK && f->get_error() != ERR_FILE_EOF) {
f->close();
return ERR_CANT_CREATE;
}
@@ -1904,34 +1796,29 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
return OK;
}
+Error ResourceFormatSaverText::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
-Error ResourceFormatSaverText::save(const String &p_path,const RES& p_resource,uint32_t p_flags) {
-
- if (p_path.ends_with(".sct") && p_resource->get_type()!="PackedScene") {
+ if (p_path.ends_with(".sct") && p_resource->get_type() != "PackedScene") {
return ERR_FILE_UNRECOGNIZED;
}
ResourceFormatSaverTextInstance saver;
- return saver.save(p_path,p_resource,p_flags);
-
+ return saver.save(p_path, p_resource, p_flags);
}
-bool ResourceFormatSaverText::recognize(const RES& p_resource) const {
-
+bool ResourceFormatSaverText::recognize(const RES &p_resource) const {
return true; // all recognized!
}
-void ResourceFormatSaverText::get_recognized_extensions(const RES& p_resource,List<String> *p_extensions) const {
+void ResourceFormatSaverText::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (p_resource->get_type()=="PackedScene")
+ if (p_resource->get_type() == "PackedScene")
p_extensions->push_back("tscn"); //text scene
else
p_extensions->push_back("tres"); //text resource
-
}
-ResourceFormatSaverText* ResourceFormatSaverText::singleton=NULL;
+ResourceFormatSaverText *ResourceFormatSaverText::singleton = NULL;
ResourceFormatSaverText::ResourceFormatSaverText() {
- singleton=this;
+ singleton = this;
}
diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h
index fdd7215f3..499c08455 100644
--- a/scene/resources/scene_format_text.h
+++ b/scene/resources/scene_format_text.h
@@ -35,8 +35,6 @@
#include "scene/resources/packed_scene.h"
#include "variant_parser.h"
-
-
class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
String local_path;
@@ -52,15 +50,14 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
String type;
};
-
bool is_scene;
String res_type;
bool ignore_resource_parsing;
-// Map<String,String> remaps;
+ // Map<String,String> remaps;
- Map<int,ExtResource> ext_resources;
+ Map<int, ExtResource> ext_resources;
int resources_total;
int resource_current;
@@ -70,30 +67,28 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
mutable int lines;
- Map<String,String> remaps;
+ Map<String, String> remaps;
//void _printerr();
- static Error _parse_sub_resources(void* p_self, VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText*>(p_self)->_parse_sub_resource(p_stream,r_value_res,line,r_err_str); }
- static Error _parse_ext_resources(void* p_self, VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText*>(p_self)->_parse_ext_resource(p_stream,r_value_res,line,r_err_str); }
+ static Error _parse_sub_resources(void *p_self, VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText *>(p_self)->_parse_sub_resource(p_stream, r_value_res, line, r_err_str); }
+ static Error _parse_ext_resources(void *p_self, VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText *>(p_self)->_parse_ext_resource(p_stream, r_value_res, line, r_err_str); }
- Error _parse_sub_resource(VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str);
- Error _parse_ext_resource(VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str);
+ Error _parse_sub_resource(VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str);
+ Error _parse_ext_resource(VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str);
VariantParser::ResourceParser rp;
- static Error _parse_sub_resources_export(void* p_self, VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText*>(p_self)->_parse_sub_resource_export(p_stream,r_value_res,line,r_err_str); }
- static Error _parse_ext_resources_export(void* p_self, VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText*>(p_self)->_parse_ext_resource_export(p_stream,r_value_res,line,r_err_str); }
+ static Error _parse_sub_resources_export(void *p_self, VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText *>(p_self)->_parse_sub_resource_export(p_stream, r_value_res, line, r_err_str); }
+ static Error _parse_ext_resources_export(void *p_self, VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText *>(p_self)->_parse_ext_resource_export(p_stream, r_value_res, line, r_err_str); }
- Error _parse_sub_resource_export(VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str);
- Error _parse_ext_resource_export(VariantParser::Stream* p_stream,Variant& r_value_res,int &line,String &r_err_str);
+ Error _parse_sub_resource_export(VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str);
+ Error _parse_ext_resource_export(VariantParser::Stream *p_stream, Variant &r_value_res, int &line, String &r_err_str);
VariantParser::ResourceParser rp_export;
-
Ref<PackedScene> packed_scene;
-
-friend class ResourceFormatLoaderText;
+ friend class ResourceFormatLoaderText;
List<RES> resource_cache;
Error error;
@@ -101,44 +96,37 @@ friend class ResourceFormatLoaderText;
RES resource;
public:
-
- virtual void set_local_path(const String& p_local_path);
+ virtual void set_local_path(const String &p_local_path);
virtual Ref<Resource> get_resource();
virtual Error poll();
virtual int get_stage() const;
virtual int get_stage_count() const;
- void open(FileAccess *p_f, bool p_skip_first_tag=false);
+ void open(FileAccess *p_f, bool p_skip_first_tag = false);
String recognize(FileAccess *p_f);
void get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types);
- Error rename_dependencies(FileAccess *p_f, const String &p_path,const Map<String,String>& p_map);
- Error get_export_data(FileAccess *p_f,ExportData& r_export_data);
-
+ Error rename_dependencies(FileAccess *p_f, const String &p_path, const Map<String, String> &p_map);
+ Error get_export_data(FileAccess *p_f, ExportData &r_export_data);
~ResourceInteractiveLoaderText();
-
};
-
-
class ResourceFormatLoaderText : public ResourceFormatLoader {
public:
-
- virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path,Error *r_error=NULL);
- virtual void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const;
+ virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, Error *r_error = NULL);
+ virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const;
virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
+ virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
- virtual void get_dependencies(const String& p_path, List<String> *p_dependencies, bool p_add_types=false);
- virtual Error rename_dependencies(const String &p_path,const Map<String,String>& p_map);
- virtual Error get_export_data(const String& p_path,ExportData& r_export_data);
+ virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false);
+ virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map);
+ virtual Error get_export_data(const String &p_path, ExportData &r_export_data);
- static ResourceFormatLoaderText* singleton;
- ResourceFormatLoaderText() { singleton=this;}
+ static ResourceFormatLoaderText *singleton;
+ ResourceFormatLoaderText() { singleton = this; }
};
-
-class ResourceFormatSaverTextInstance {
+class ResourceFormatSaverTextInstance {
String local_path;
@@ -151,31 +139,26 @@ class ResourceFormatSaverTextInstance {
FileAccess *f;
Set<RES> resource_set;
List<RES> saved_resources;
- Map<RES,int> external_resources;
- Map<RES,int> internal_resources;
-
- void _find_resources(const Variant& p_variant,bool p_main=false);
+ Map<RES, int> external_resources;
+ Map<RES, int> internal_resources;
- static String _write_resources(void *ud,const RES& p_resource);
- String _write_resource(const RES& res);
+ void _find_resources(const Variant &p_variant, bool p_main = false);
+ static String _write_resources(void *ud, const RES &p_resource);
+ String _write_resource(const RES &res);
public:
-
- Error save(const String &p_path,const RES& p_resource,uint32_t p_flags=0);
-
-
+ Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
};
class ResourceFormatSaverText : public ResourceFormatSaver {
public:
- static ResourceFormatSaverText* singleton;
- virtual Error save(const String &p_path,const RES& p_resource,uint32_t p_flags=0);
- virtual bool recognize(const RES& p_resource) const;
- virtual void get_recognized_extensions(const RES& p_resource,List<String> *p_extensions) const;
+ static ResourceFormatSaverText *singleton;
+ virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
+ virtual bool recognize(const RES &p_resource) const;
+ virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
ResourceFormatSaverText();
};
-
#endif // SCENE_FORMAT_TEXT_H
diff --git a/scene/resources/scene_preloader.cpp b/scene/resources/scene_preloader.cpp
index 6fa4e059e..7479a61ce 100644
--- a/scene/resources/scene_preloader.cpp
+++ b/scene/resources/scene_preloader.cpp
@@ -31,170 +31,160 @@
bool ScenePreloader::can_instance() const {
- return nodes.size()>0;
+ return nodes.size() > 0;
}
Node *ScenePreloader::instance() const {
int nc = nodes.size();
- ERR_FAIL_COND_V(nc==0,NULL);
+ ERR_FAIL_COND_V(nc == 0, NULL);
- const StringName*snames=NULL;
- int sname_count=names.size();
+ const StringName *snames = NULL;
+ int sname_count = names.size();
if (sname_count)
- snames=&names[0];
+ snames = &names[0];
- const Variant*props=NULL;
- int prop_count=variants.size();
+ const Variant *props = NULL;
+ int prop_count = variants.size();
if (prop_count)
- props=&variants[0];
+ props = &variants[0];
Vector<Variant> properties;
const NodeData *nd = &nodes[0];
- Node **ret_nodes=(Node**)alloca( sizeof(Node*)*nc );
+ Node **ret_nodes = (Node **)alloca(sizeof(Node *) * nc);
- for(int i=0;i<nc;i++) {
-
- const NodeData &n=nd[i];
+ for (int i = 0; i < nc; i++) {
+ const NodeData &n = nd[i];
if (!ObjectTypeDB::is_type_enabled(snames[n.type])) {
- ret_nodes[i]=NULL;
+ ret_nodes[i] = NULL;
continue;
}
- Object * obj = ObjectTypeDB::instance(snames[ n.type ]);
- ERR_FAIL_COND_V(!obj,NULL);
+ Object *obj = ObjectTypeDB::instance(snames[n.type]);
+ ERR_FAIL_COND_V(!obj, NULL);
Node *node = obj->cast_to<Node>();
- ERR_FAIL_COND_V(!node,NULL);
+ ERR_FAIL_COND_V(!node, NULL);
- int nprop_count=n.properties.size();
+ int nprop_count = n.properties.size();
if (nprop_count) {
- const NodeData::Property* nprops=&n.properties[0];
+ const NodeData::Property *nprops = &n.properties[0];
- for(int j=0;j<nprop_count;j++) {
+ for (int j = 0; j < nprop_count; j++) {
bool valid;
- node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid);
+ node->set(snames[nprops[j].name], props[nprops[j].value], &valid);
}
-
-
}
- node->set_name( snames[ n.name ] );
- ret_nodes[i]=node;
- if (i>0) {
- ERR_FAIL_INDEX_V(n.parent,i,NULL);
- ERR_FAIL_COND_V(!ret_nodes[n.parent],NULL);
+ node->set_name(snames[n.name]);
+ ret_nodes[i] = node;
+ if (i > 0) {
+ ERR_FAIL_INDEX_V(n.parent, i, NULL);
+ ERR_FAIL_COND_V(!ret_nodes[n.parent], NULL);
ret_nodes[n.parent]->add_child(node);
}
}
-
//do connections
int cc = connections.size();
const ConnectionData *cdata = connections.ptr();
- for(int i=0;i<cc;i++) {
+ for (int i = 0; i < cc; i++) {
- const ConnectionData &c=cdata[i];
- ERR_FAIL_INDEX_V( c.from, nc, NULL );
- ERR_FAIL_INDEX_V( c.to, nc, NULL );
+ const ConnectionData &c = cdata[i];
+ ERR_FAIL_INDEX_V(c.from, nc, NULL);
+ ERR_FAIL_INDEX_V(c.to, nc, NULL);
Vector<Variant> binds;
if (c.binds.size()) {
binds.resize(c.binds.size());
- for(int j=0;j<c.binds.size();j++)
- binds[j]=props[ c.binds[j] ];
+ for (int j = 0; j < c.binds.size(); j++)
+ binds[j] = props[c.binds[j]];
}
if (!ret_nodes[c.from] || !ret_nodes[c.to])
continue;
- ret_nodes[c.from]->connect( snames[ c.signal], ret_nodes[ c.to ], snames[ c.method], binds,CONNECT_PERSIST );
+ ret_nodes[c.from]->connect(snames[c.signal], ret_nodes[c.to], snames[c.method], binds, CONNECT_PERSIST);
}
return ret_nodes[0];
-
}
-
-static int _nm_get_string(const String& p_string, Map<StringName,int> &name_map) {
+static int _nm_get_string(const String &p_string, Map<StringName, int> &name_map) {
if (name_map.has(p_string))
return name_map[p_string];
int idx = name_map.size();
- name_map[p_string]=idx;
+ name_map[p_string] = idx;
return idx;
}
-static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) {
+static int _vm_get_variant(const Variant &p_variant, HashMap<Variant, int, VariantHasher> &variant_map) {
if (variant_map.has(p_variant))
return variant_map[p_variant];
int idx = variant_map.size();
- variant_map[p_variant]=idx;
+ variant_map[p_variant] = idx;
return idx;
}
-void ScenePreloader::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map) {
+void ScenePreloader::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map) {
- if (p_node!=p_owner && !p_node->get_owner())
+ if (p_node != p_owner && !p_node->get_owner())
return;
NodeData nd;
- nd.name=_nm_get_string(p_node->get_name(),name_map);
- nd.type=_nm_get_string(p_node->get_type(),name_map);
- nd.parent=p_parent_idx;
+ nd.name = _nm_get_string(p_node->get_name(), name_map);
+ nd.type = _nm_get_string(p_node->get_type(), name_map);
+ nd.parent = p_parent_idx;
List<PropertyInfo> plist;
p_node->get_property_list(&plist);
- for (List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
NodeData::Property prop;
- prop.name=_nm_get_string(E->get().name,name_map);
- prop.value=_vm_get_variant( p_node->get( E->get().name ), variant_map);
+ prop.name = _nm_get_string(E->get().name, name_map);
+ prop.value = _vm_get_variant(p_node->get(E->get().name), variant_map);
nd.properties.push_back(prop);
}
int idx = nodes.size();
- node_map[p_node]=idx;
+ node_map[p_node] = idx;
nodes.push_back(nd);
- for(int i=0;i<p_node->get_child_count();i++) {
+ for (int i = 0; i < p_node->get_child_count(); i++) {
- Node *c=p_node->get_child(i);
- _parse_node(p_owner,c,idx,name_map,variant_map,node_map);
+ Node *c = p_node->get_child(i);
+ _parse_node(p_owner, c, idx, name_map, variant_map, node_map);
}
-
-
-
}
-void ScenePreloader::_parse_connections(Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,bool p_instance) {
-
+void ScenePreloader::_parse_connections(Node *p_node, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map, bool p_instance) {
List<MethodInfo> signals;
p_node->get_signal_list(&signals);
- for(List<MethodInfo>::Element *E=signals.front();E;E=E->next()) {
+ for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) {
List<Node::Connection> conns;
- p_node->get_signal_connection_list(E->get().name,&conns);
- for(List<Node::Connection>::Element *F=conns.front();F;F=F->next()) {
+ p_node->get_signal_connection_list(E->get().name, &conns);
+ for (List<Node::Connection>::Element *F = conns.front(); F; F = F->next()) {
const Node::Connection &c = F->get();
- if (!(c.flags&CONNECT_PERSIST))
+ if (!(c.flags & CONNECT_PERSIST))
continue;
- Node *n=c.target->cast_to<Node>();
+ Node *n = c.target->cast_to<Node>();
if (!n)
continue;
@@ -202,22 +192,20 @@ void ScenePreloader::_parse_connections(Node *p_node, Map<StringName,int> &name_
continue;
ConnectionData cd;
- cd.from=node_map[p_node];
- cd.to=node_map[n];
- cd.method=_nm_get_string(c.method,name_map);
- cd.signal=_nm_get_string(c.signal,name_map);
- for(int i=0;i<c.binds.size();i++) {
+ cd.from = node_map[p_node];
+ cd.to = node_map[n];
+ cd.method = _nm_get_string(c.method, name_map);
+ cd.signal = _nm_get_string(c.signal, name_map);
+ for (int i = 0; i < c.binds.size(); i++) {
- cd.binds.push_back( _vm_get_variant(c.binds[i],variant_map));
+ cd.binds.push_back(_vm_get_variant(c.binds[i], variant_map));
}
connections.push_back(cd);
}
}
-
}
-
-Error ScenePreloader::load_scene(const String& p_path) {
+Error ScenePreloader::load_scene(const String &p_path) {
return ERR_CANT_OPEN;
#if 0
@@ -272,38 +260,36 @@ void ScenePreloader::clear() {
variants.clear();
nodes.clear();
connections.clear();
-
}
-void ScenePreloader::_set_bundled_scene(const Dictionary& d) {
+void ScenePreloader::_set_bundled_scene(const Dictionary &d) {
-
- ERR_FAIL_COND( !d.has("names"));
- ERR_FAIL_COND( !d.has("variants"));
- ERR_FAIL_COND( !d.has("node_count"));
- ERR_FAIL_COND( !d.has("nodes"));
- ERR_FAIL_COND( !d.has("conn_count"));
- ERR_FAIL_COND( !d.has("conns"));
- ERR_FAIL_COND( !d.has("path"));
+ ERR_FAIL_COND(!d.has("names"));
+ ERR_FAIL_COND(!d.has("variants"));
+ ERR_FAIL_COND(!d.has("node_count"));
+ ERR_FAIL_COND(!d.has("nodes"));
+ ERR_FAIL_COND(!d.has("conn_count"));
+ ERR_FAIL_COND(!d.has("conns"));
+ ERR_FAIL_COND(!d.has("path"));
DVector<String> snames = d["names"];
if (snames.size()) {
int namecount = snames.size();
names.resize(namecount);
- DVector<String>::Read r =snames.read();
- for(int i=0;i<names.size();i++)
- names[i]=r[i];
+ DVector<String>::Read r = snames.read();
+ for (int i = 0; i < names.size(); i++)
+ names[i] = r[i];
}
Array svariants = d["variants"];
if (svariants.size()) {
- int varcount=svariants.size();
+ int varcount = svariants.size();
variants.resize(varcount);
- for(int i=0;i<varcount;i++) {
+ for (int i = 0; i < varcount; i++) {
- variants[i]=svariants[i];
+ variants[i] = svariants[i];
}
} else {
@@ -311,53 +297,48 @@ void ScenePreloader::_set_bundled_scene(const Dictionary& d) {
}
nodes.resize(d["node_count"]);
- int nc=nodes.size();
+ int nc = nodes.size();
if (nc) {
DVector<int> snodes = d["nodes"];
DVector<int>::Read r = snodes.read();
- int idx=0;
- for(int i=0;i<nc;i++) {
+ int idx = 0;
+ for (int i = 0; i < nc; i++) {
NodeData &nd = nodes[i];
- nd.parent=r[idx++];
- nd.type=r[idx++];
- nd.name=r[idx++];
+ nd.parent = r[idx++];
+ nd.type = r[idx++];
+ nd.name = r[idx++];
nd.properties.resize(r[idx++]);
- for(int j=0;j<nd.properties.size();j++) {
+ for (int j = 0; j < nd.properties.size(); j++) {
- nd.properties[j].name=r[idx++];
- nd.properties[j].value=r[idx++];
+ nd.properties[j].name = r[idx++];
+ nd.properties[j].value = r[idx++];
}
}
-
}
connections.resize(d["conn_count"]);
- int cc=connections.size();
+ int cc = connections.size();
if (cc) {
DVector<int> sconns = d["conns"];
DVector<int>::Read r = sconns.read();
- int idx=0;
- for(int i=0;i<nc;i++) {
+ int idx = 0;
+ for (int i = 0; i < nc; i++) {
ConnectionData &cd = connections[nc];
- cd.from=r[idx++];
- cd.to=r[idx++];
- cd.signal=r[idx++];
- cd.method=r[idx++];
+ cd.from = r[idx++];
+ cd.to = r[idx++];
+ cd.signal = r[idx++];
+ cd.method = r[idx++];
cd.binds.resize(r[idx++]);
- for(int j=0;j<cd.binds.size();j++) {
+ for (int j = 0; j < cd.binds.size(); j++) {
- cd.binds[j]=r[idx++];
+ cd.binds[j] = r[idx++];
}
}
-
}
-
-
- path=d["path"];
-
+ path = d["path"];
}
Dictionary ScenePreloader::_get_bundled_scene() const {
@@ -367,70 +348,67 @@ Dictionary ScenePreloader::_get_bundled_scene() const {
if (names.size()) {
- DVector<String>::Write r=rnames.write();
+ DVector<String>::Write r = rnames.write();
- for(int i=0;i<names.size();i++)
- r[i]=names[i];
+ for (int i = 0; i < names.size(); i++)
+ r[i] = names[i];
}
Dictionary d;
- d["names"]=rnames;
- d["variants"]=variants;
+ d["names"] = rnames;
+ d["variants"] = variants;
Vector<int> rnodes;
- d["node_count"]=nodes.size();
+ d["node_count"] = nodes.size();
- for(int i=0;i<nodes.size();i++) {
+ for (int i = 0; i < nodes.size(); i++) {
- const NodeData &nd=nodes[i];
+ const NodeData &nd = nodes[i];
rnodes.push_back(nd.parent);
rnodes.push_back(nd.type);
rnodes.push_back(nd.name);
rnodes.push_back(nd.properties.size());
- for(int j=0;j<nd.properties.size();j++) {
+ for (int j = 0; j < nd.properties.size(); j++) {
rnodes.push_back(nd.properties[j].name);
rnodes.push_back(nd.properties[j].value);
}
}
- d["nodes"]=rnodes;
+ d["nodes"] = rnodes;
Vector<int> rconns;
- d["conn_count"]=connections.size();
+ d["conn_count"] = connections.size();
- for(int i=0;i<connections.size();i++) {
+ for (int i = 0; i < connections.size(); i++) {
- const ConnectionData &cd=connections[i];
+ const ConnectionData &cd = connections[i];
rconns.push_back(cd.from);
rconns.push_back(cd.to);
rconns.push_back(cd.signal);
rconns.push_back(cd.method);
rconns.push_back(cd.binds.size());
- for(int j=0;j<cd.binds.size();j++)
+ for (int j = 0; j < cd.binds.size(); j++)
rconns.push_back(cd.binds[j]);
-
}
- d["conns"]=rconns;
+ d["conns"] = rconns;
- d["path"]=path;
+ d["path"] = path;
return d;
-
-
}
void ScenePreloader::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("load_scene","path"),&ScenePreloader::load_scene);
- ObjectTypeDB::bind_method(_MD("get_scene_path"),&ScenePreloader::get_scene_path);
- ObjectTypeDB::bind_method(_MD("instance:Node"),&ScenePreloader::instance);
- ObjectTypeDB::bind_method(_MD("can_instance"),&ScenePreloader::can_instance);
- ObjectTypeDB::bind_method(_MD("_set_bundled_scene"),&ScenePreloader::_set_bundled_scene);
- ObjectTypeDB::bind_method(_MD("_get_bundled_scene"),&ScenePreloader::_get_bundled_scene);
+ ObjectTypeDB::bind_method(_MD("load_scene", "path"), &ScenePreloader::load_scene);
+ ObjectTypeDB::bind_method(_MD("get_scene_path"), &ScenePreloader::get_scene_path);
+ ObjectTypeDB::bind_method(_MD("instance:Node"), &ScenePreloader::instance);
+ ObjectTypeDB::bind_method(_MD("can_instance"), &ScenePreloader::can_instance);
+ ObjectTypeDB::bind_method(_MD("_set_bundled_scene"), &ScenePreloader::_set_bundled_scene);
+ ObjectTypeDB::bind_method(_MD("_get_bundled_scene"), &ScenePreloader::_get_bundled_scene);
- ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_BUNDLE),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene"));
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_bundled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_BUNDLE), _SCS("_set_bundled_scene"), _SCS("_get_bundled_scene"));
#if 0
List<String> extensions;
SceneLoader::get_recognized_extensions(&extensions);
@@ -449,6 +427,4 @@ void ScenePreloader::_bind_methods() {
}
ScenePreloader::ScenePreloader() {
-
-
}
diff --git a/scene/resources/scene_preloader.h b/scene/resources/scene_preloader.h
index 6fe975bb7..f3fe717c5 100644
--- a/scene/resources/scene_preloader.h
+++ b/scene/resources/scene_preloader.h
@@ -34,7 +34,7 @@
class ScenePreloader : public Resource {
- OBJ_TYPE( ScenePreloader, Resource );
+ OBJ_TYPE(ScenePreloader, Resource);
Vector<StringName> names;
Vector<Variant> variants;
@@ -59,7 +59,6 @@ class ScenePreloader : public Resource {
Vector<Property> properties;
};
-
Vector<NodeData> nodes;
struct ConnectionData {
@@ -73,22 +72,19 @@ class ScenePreloader : public Resource {
Vector<ConnectionData> connections;
- void _parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map);
- void _parse_connections(Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,bool p_instance);
+ void _parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map);
+ void _parse_connections(Node *p_node, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map, bool p_instance);
String path;
- void _set_bundled_scene(const Dictionary& p_scene);
+ void _set_bundled_scene(const Dictionary &p_scene);
Dictionary _get_bundled_scene() const;
protected:
-
-
static void _bind_methods();
-public:
-
- Error load_scene(const String& p_path);
+public:
+ Error load_scene(const String &p_path);
String get_scene_path() const;
void clear();
diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp
index d0ae79190..70c95636d 100644
--- a/scene/resources/segment_shape_2d.cpp
+++ b/scene/resources/segment_shape_2d.cpp
@@ -34,138 +34,119 @@
void SegmentShape2D::_update_shape() {
Rect2 r;
- r.pos=a;
- r.size=b;
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),r);
+ r.pos = a;
+ r.size = b;
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), r);
emit_changed();
-
}
-void SegmentShape2D::set_a(const Vector2& p_a) {
+void SegmentShape2D::set_a(const Vector2 &p_a) {
- a=p_a;
+ a = p_a;
_update_shape();
-
}
Vector2 SegmentShape2D::get_a() const {
return a;
}
-void SegmentShape2D::set_b(const Vector2& p_b) {
+void SegmentShape2D::set_b(const Vector2 &p_b) {
- b=p_b;
+ b = p_b;
_update_shape();
-
}
Vector2 SegmentShape2D::get_b() const {
return b;
}
-void SegmentShape2D::draw(const RID& p_to_rid,const Color& p_color) {
+void SegmentShape2D::draw(const RID &p_to_rid, const Color &p_color) {
- VisualServer::get_singleton()->canvas_item_add_line(p_to_rid,a,b,p_color,3);
+ VisualServer::get_singleton()->canvas_item_add_line(p_to_rid, a, b, p_color, 3);
}
-Rect2 SegmentShape2D::get_rect() const{
+Rect2 SegmentShape2D::get_rect() const {
Rect2 rect;
- rect.pos=a;
+ rect.pos = a;
rect.expand_to(b);
return rect;
-
}
-
-
-
void SegmentShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_a","a"),&SegmentShape2D::set_a);
- ObjectTypeDB::bind_method(_MD("get_a"),&SegmentShape2D::get_a);
-
- ObjectTypeDB::bind_method(_MD("set_b","b"),&SegmentShape2D::set_b);
- ObjectTypeDB::bind_method(_MD("get_b"),&SegmentShape2D::get_b);
-
+ ObjectTypeDB::bind_method(_MD("set_a", "a"), &SegmentShape2D::set_a);
+ ObjectTypeDB::bind_method(_MD("get_a"), &SegmentShape2D::get_a);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"a"),_SCS("set_a"),_SCS("get_a") );
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"b"),_SCS("set_b"),_SCS("get_b") );
+ ObjectTypeDB::bind_method(_MD("set_b", "b"), &SegmentShape2D::set_b);
+ ObjectTypeDB::bind_method(_MD("get_b"), &SegmentShape2D::get_b);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "a"), _SCS("set_a"), _SCS("get_a"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "b"), _SCS("set_b"), _SCS("get_b"));
}
-SegmentShape2D::SegmentShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_SEGMENT)) {
+SegmentShape2D::SegmentShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_SEGMENT)) {
- a=Vector2();
- b=Vector2(0,10);
+ a = Vector2();
+ b = Vector2(0, 10);
_update_shape();
}
-
////////////////////////////////////////////////////////////
-
void RayShape2D::_update_shape() {
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),length);
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), length);
emit_changed();
-
}
+void RayShape2D::draw(const RID &p_to_rid, const Color &p_color) {
-void RayShape2D::draw(const RID& p_to_rid,const Color& p_color) {
-
-
- Vector2 tip = Vector2(0,get_length());
- VS::get_singleton()->canvas_item_add_line(p_to_rid,Vector2(),tip,p_color,3);
+ Vector2 tip = Vector2(0, get_length());
+ VS::get_singleton()->canvas_item_add_line(p_to_rid, Vector2(), tip, p_color, 3);
Vector<Vector2> pts;
- float tsize=4;
- pts.push_back(tip+Vector2(0,tsize));
- pts.push_back(tip+Vector2(0.707*tsize,0));
- pts.push_back(tip+Vector2(-0.707*tsize,0));
+ float tsize = 4;
+ pts.push_back(tip + Vector2(0, tsize));
+ pts.push_back(tip + Vector2(0.707 * tsize, 0));
+ pts.push_back(tip + Vector2(-0.707 * tsize, 0));
Vector<Color> cols;
- for(int i=0;i<3;i++)
+ for (int i = 0; i < 3; i++)
cols.push_back(p_color);
- VS::get_singleton()->canvas_item_add_primitive(p_to_rid,pts,cols,Vector<Point2>(),RID());
-
-
-
+ VS::get_singleton()->canvas_item_add_primitive(p_to_rid, pts, cols, Vector<Point2>(), RID());
}
Rect2 RayShape2D::get_rect() const {
Rect2 rect;
- rect.pos=Vector2();
- rect.expand_to(Vector2(0,length));
- rect=rect.grow(0.707*4);
+ rect.pos = Vector2();
+ rect.expand_to(Vector2(0, length));
+ rect = rect.grow(0.707 * 4);
return rect;
}
-
void RayShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_length","length"),&RayShape2D::set_length);
- ObjectTypeDB::bind_method(_MD("get_length"),&RayShape2D::get_length);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"length"),_SCS("set_length"),_SCS("get_length") );
+ ObjectTypeDB::bind_method(_MD("set_length", "length"), &RayShape2D::set_length);
+ ObjectTypeDB::bind_method(_MD("get_length"), &RayShape2D::get_length);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), _SCS("set_length"), _SCS("get_length"));
}
void RayShape2D::set_length(real_t p_length) {
- length=p_length;
+ length = p_length;
_update_shape();
}
real_t RayShape2D::get_length() const {
return length;
-
-
}
-RayShape2D::RayShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RAY)) {
+RayShape2D::RayShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RAY)) {
- length=20;
+ length = 20;
_update_shape();
}
diff --git a/scene/resources/segment_shape_2d.h b/scene/resources/segment_shape_2d.h
index 0a9de96f0..3a9067da1 100644
--- a/scene/resources/segment_shape_2d.h
+++ b/scene/resources/segment_shape_2d.h
@@ -32,49 +32,46 @@
#include "scene/resources/shape_2d.h"
class SegmentShape2D : public Shape2D {
- OBJ_TYPE( SegmentShape2D, Shape2D );
+ OBJ_TYPE(SegmentShape2D, Shape2D);
Vector2 a;
Vector2 b;
void _update_shape();
-protected:
+protected:
static void _bind_methods();
-public:
- void set_a(const Vector2& p_a);
- void set_b(const Vector2& p_b);
+public:
+ void set_a(const Vector2 &p_a);
+ void set_b(const Vector2 &p_b);
Vector2 get_a() const;
Vector2 get_b() const;
- virtual void draw(const RID& p_to_rid,const Color& p_color);
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
virtual Rect2 get_rect() const;
SegmentShape2D();
};
-
class RayShape2D : public Shape2D {
- OBJ_TYPE( RayShape2D, Shape2D );
-
+ OBJ_TYPE(RayShape2D, Shape2D);
real_t length;
void _update_shape();
-protected:
+protected:
static void _bind_methods();
-public:
+public:
void set_length(real_t p_length);
real_t get_length() const;
- virtual void draw(const RID& p_to_rid,const Color& p_color);
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
virtual Rect2 get_rect() const;
RayShape2D();
};
-
#endif // SEGMENT_SHAPE_2D_H
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 800094115..793535c38 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -27,26 +27,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "shader.h"
-#include "servers/visual_server.h"
-#include "texture.h"
#include "os/file_access.h"
#include "scene/scene_string_names.h"
-
-
+#include "servers/visual_server.h"
+#include "texture.h"
Shader::Mode Shader::get_mode() const {
return mode;
}
-void Shader::set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs,int p_light_ofs) {
+void Shader::set_code(const String &p_vertex, const String &p_fragment, const String &p_light, int p_fragment_ofs, int p_light_ofs) {
- VisualServer::get_singleton()->shader_set_code(shader,p_vertex,p_fragment,p_light,0,p_fragment_ofs,p_light_ofs);
- params_cache_dirty=true;
+ VisualServer::get_singleton()->shader_set_code(shader, p_vertex, p_fragment, p_light, 0, p_fragment_ofs, p_light_ofs);
+ params_cache_dirty = true;
emit_signal(SceneStringNames::get_singleton()->changed);
}
-
String Shader::get_vertex_code() const {
return VisualServer::get_singleton()->shader_get_vertex_code(shader);
@@ -55,16 +52,14 @@ String Shader::get_vertex_code() const {
String Shader::get_fragment_code() const {
return VisualServer::get_singleton()->shader_get_fragment_code(shader);
-
}
String Shader::get_light_code() const {
return VisualServer::get_singleton()->shader_get_light_code(shader);
-
}
-bool Shader::has_param(const StringName& p_param) const {
+bool Shader::has_param(const StringName &p_param) const {
if (params_cache_dirty)
get_param_list(NULL);
@@ -72,25 +67,23 @@ bool Shader::has_param(const StringName& p_param) const {
return (params_cache.has(p_param));
}
-
void Shader::get_param_list(List<PropertyInfo> *p_params) const {
-
List<PropertyInfo> local;
- VisualServer::get_singleton()->shader_get_param_list(shader,&local);
+ VisualServer::get_singleton()->shader_get_param_list(shader, &local);
params_cache.clear();
- params_cache_dirty=false;
+ params_cache_dirty = false;
- for(List<PropertyInfo>::Element *E=local.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = local.front(); E; E = E->next()) {
- PropertyInfo pi=E->get();
- pi.name="shader_param/"+pi.name;
- params_cache[pi.name]=E->get().name;
+ PropertyInfo pi = E->get();
+ pi.name = "shader_param/" + pi.name;
+ params_cache[pi.name] = E->get().name;
if (p_params) {
//small little hack
- if (pi.type==Variant::_RID)
- pi.type=Variant::OBJECT;
+ if (pi.type == Variant::_RID)
+ pi.type = Variant::OBJECT;
p_params->push_back(pi);
}
}
@@ -108,54 +101,54 @@ Dictionary Shader::_get_code() {
String ls = VisualServer::get_singleton()->shader_get_light_code(shader);
Dictionary c;
- c["fragment"]=fs;
- c["fragment_ofs"]=0;
- c["vertex"]=vs;
- c["vertex_ofs"]=0;
- c["light"]=ls;
- c["light_ofs"]=0;
+ c["fragment"] = fs;
+ c["fragment_ofs"] = 0;
+ c["vertex"] = vs;
+ c["vertex_ofs"] = 0;
+ c["light"] = ls;
+ c["light_ofs"] = 0;
Array arr;
- for(const Map<StringName,Ref<Texture> >::Element *E=default_textures.front();E;E=E->next()) {
+ for (const Map<StringName, Ref<Texture> >::Element *E = default_textures.front(); E; E = E->next()) {
arr.push_back(E->key());
arr.push_back(E->get());
}
if (arr.size())
- c["default_tex"]=arr;
+ c["default_tex"] = arr;
return c;
}
-void Shader::_set_code(const Dictionary& p_string) {
+void Shader::_set_code(const Dictionary &p_string) {
ERR_FAIL_COND(!p_string.has("fragment"));
ERR_FAIL_COND(!p_string.has("vertex"));
String light;
if (p_string.has("light"))
- light=p_string["light"];
+ light = p_string["light"];
- set_code(p_string["vertex"],p_string["fragment"],light);
+ set_code(p_string["vertex"], p_string["fragment"], light);
if (p_string.has("default_tex")) {
- Array arr=p_string["default_tex"];
- if ((arr.size()&1)==0) {
- for(int i=0;i<arr.size();i+=2) {
+ Array arr = p_string["default_tex"];
+ if ((arr.size() & 1) == 0) {
+ for (int i = 0; i < arr.size(); i += 2) {
- set_default_texture_param(arr[i],arr[i+1]);
+ set_default_texture_param(arr[i], arr[i + 1]);
}
}
}
}
-void Shader::set_default_texture_param(const StringName& p_param,const Ref<Texture>& p_texture) {
+void Shader::set_default_texture_param(const StringName &p_param, const Ref<Texture> &p_texture) {
if (p_texture.is_valid()) {
- default_textures[p_param]=p_texture;
- VS::get_singleton()->shader_set_default_texture_param(shader,p_param,p_texture->get_rid());
+ default_textures[p_param] = p_texture;
+ VS::get_singleton()->shader_set_default_texture_param(shader, p_param, p_texture->get_rid());
} else {
default_textures.erase(p_param);
- VS::get_singleton()->shader_set_default_texture_param(shader,p_param,RID());
+ VS::get_singleton()->shader_set_default_texture_param(shader, p_param, RID());
}
}
-Ref<Texture> Shader::get_default_texture_param(const StringName& p_param) const{
+Ref<Texture> Shader::get_default_texture_param(const StringName &p_param) const {
if (default_textures.has(p_param))
return default_textures[p_param];
@@ -163,49 +156,45 @@ Ref<Texture> Shader::get_default_texture_param(const StringName& p_param) const{
return Ref<Texture>();
}
-void Shader::get_default_texture_param_list(List<StringName>* r_textures) const{
+void Shader::get_default_texture_param_list(List<StringName> *r_textures) const {
- for(const Map<StringName,Ref<Texture> >::Element *E=default_textures.front();E;E=E->next()) {
+ for (const Map<StringName, Ref<Texture> >::Element *E = default_textures.front(); E; E = E->next()) {
r_textures->push_back(E->key());
}
-
}
-
void Shader::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_mode"),&Shader::get_mode);
+ ObjectTypeDB::bind_method(_MD("get_mode"), &Shader::get_mode);
- ObjectTypeDB::bind_method(_MD("set_code","vcode","fcode","lcode","fofs","lofs"),&Shader::set_code,DEFVAL(0),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("get_vertex_code"),&Shader::get_vertex_code);
- ObjectTypeDB::bind_method(_MD("get_fragment_code"),&Shader::get_fragment_code);
- ObjectTypeDB::bind_method(_MD("get_light_code"),&Shader::get_light_code);
+ ObjectTypeDB::bind_method(_MD("set_code", "vcode", "fcode", "lcode", "fofs", "lofs"), &Shader::set_code, DEFVAL(0), DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("get_vertex_code"), &Shader::get_vertex_code);
+ ObjectTypeDB::bind_method(_MD("get_fragment_code"), &Shader::get_fragment_code);
+ ObjectTypeDB::bind_method(_MD("get_light_code"), &Shader::get_light_code);
- ObjectTypeDB::bind_method(_MD("set_default_texture_param","param","texture:Texture"),&Shader::set_default_texture_param);
- ObjectTypeDB::bind_method(_MD("get_default_texture_param:Texture","param"),&Shader::get_default_texture_param);
+ ObjectTypeDB::bind_method(_MD("set_default_texture_param", "param", "texture:Texture"), &Shader::set_default_texture_param);
+ ObjectTypeDB::bind_method(_MD("get_default_texture_param:Texture", "param"), &Shader::get_default_texture_param);
- ObjectTypeDB::bind_method(_MD("has_param","name"),&Shader::has_param);
+ ObjectTypeDB::bind_method(_MD("has_param", "name"), &Shader::has_param);
- ObjectTypeDB::bind_method(_MD("_set_code","code"),&Shader::_set_code);
- ObjectTypeDB::bind_method(_MD("_get_code"),&Shader::_get_code);
+ ObjectTypeDB::bind_method(_MD("_set_code", "code"), &Shader::_set_code);
+ ObjectTypeDB::bind_method(_MD("_get_code"), &Shader::_get_code);
//ObjectTypeDB::bind_method(_MD("get_param_list"),&Shader::get_fragment_code);
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "_code", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_code"), _SCS("_get_code"));
- ADD_PROPERTY( PropertyInfo(Variant::STRING, "_code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_code"), _SCS("_get_code") );
-
- BIND_CONSTANT( MODE_MATERIAL );
- BIND_CONSTANT( MODE_CANVAS_ITEM );
- BIND_CONSTANT( MODE_POST_PROCESS );
-
+ BIND_CONSTANT(MODE_MATERIAL);
+ BIND_CONSTANT(MODE_CANVAS_ITEM);
+ BIND_CONSTANT(MODE_POST_PROCESS);
}
Shader::Shader(Mode p_mode) {
- mode=p_mode;
+ mode = p_mode;
shader = VisualServer::get_singleton()->shader_create(VS::ShaderMode(p_mode));
- params_cache_dirty=true;
+ params_cache_dirty = true;
}
Shader::~Shader() {
@@ -213,111 +202,105 @@ Shader::~Shader() {
VisualServer::get_singleton()->free(shader);
}
-
-
/************ Loader from text ***************/
-
-
-RES ResourceFormatLoaderShader::load(const String &p_path, const String& p_original_path, Error *r_error) {
+RES ResourceFormatLoaderShader::load(const String &p_path, const String &p_original_path, Error *r_error) {
if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
+ *r_error = ERR_FILE_CANT_OPEN;
String fragment_code;
String vertex_code;
String light_code;
- int mode=-1;
+ int mode = -1;
Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err);
-
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- ERR_EXPLAIN("Unable to open shader file: "+p_path);
- ERR_FAIL_COND_V(err,RES());
+ ERR_EXPLAIN("Unable to open shader file: " + p_path);
+ ERR_FAIL_COND_V(err, RES());
String base_path = p_path.get_base_dir();
if (r_error)
- *r_error=ERR_FILE_CORRUPT;
+ *r_error = ERR_FILE_CORRUPT;
- Ref<Shader> shader;//( memnew( Shader ) );
+ Ref<Shader> shader; //( memnew( Shader ) );
- int line=0;
+ int line = 0;
- while(!f->eof_reached()) {
+ while (!f->eof_reached()) {
String l = f->get_line();
line++;
- if (mode<=0) {
+ if (mode <= 0) {
l = l.strip_edges();
int comment = l.find(";");
- if (comment!=-1)
- l=l.substr(0,comment);
+ if (comment != -1)
+ l = l.substr(0, comment);
}
- if (mode<1)
- vertex_code+="\n";
- if (mode<2)
- fragment_code+="\n";
+ if (mode < 1)
+ vertex_code += "\n";
+ if (mode < 2)
+ fragment_code += "\n";
- if (mode < 1 && l=="")
+ if (mode < 1 && l == "")
continue;
if (l.begins_with("[")) {
- l=l.strip_edges();
- if (l=="[params]") {
- if (mode>=0) {
+ l = l.strip_edges();
+ if (l == "[params]") {
+ if (mode >= 0) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [params] section.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Misplaced [params] section.");
ERR_FAIL_V(RES());
}
- mode=0;
- } else if (l=="[vertex]") {
- if (mode>=1) {
+ mode = 0;
+ } else if (l == "[vertex]") {
+ if (mode >= 1) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [vertex] section.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Misplaced [vertex] section.");
ERR_FAIL_V(RES());
}
- mode=1;
- } else if (l=="[fragment]") {
- if (mode>=2) {
+ mode = 1;
+ } else if (l == "[fragment]") {
+ if (mode >= 2) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [fragment] section.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Misplaced [fragment] section.");
ERR_FAIL_V(RES());
}
- mode=1;
+ mode = 1;
} else {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Unknown section type: '"+l+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Unknown section type: '" + l + "'.");
ERR_FAIL_V(RES());
}
continue;
}
- if (mode==0) {
+ if (mode == 0) {
int eqpos = l.find("=");
- if (eqpos==-1) {
+ if (eqpos == -1) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected '='.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Expected '='.");
ERR_FAIL_V(RES());
}
-
- String right=l.substr(eqpos+1,l.length()).strip_edges();
- if (right=="") {
+ String right = l.substr(eqpos + 1, l.length()).strip_edges();
+ if (right == "") {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected value after '='.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Expected value after '='.");
ERR_FAIL_V(RES());
}
Variant value;
- if (right=="true") {
+ if (right == "true") {
value = true;
- } else if (right=="false") {
+ } else if (right == "false") {
value = false;
} else if (right.is_valid_float()) {
//is number
@@ -329,119 +312,112 @@ RES ResourceFormatLoaderShader::load(const String &p_path, const String& p_origi
//attempt to parse a constructor
int popenpos = right.find("(");
- if (popenpos==-1) {
+ if (popenpos == -1) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor syntax: "+right);
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid constructor syntax: " + right);
ERR_FAIL_V(RES());
}
int pclosepos = right.find_last(")");
- if (pclosepos==-1) {
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor parameter syntax: "+right);
+ if (pclosepos == -1) {
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid constructor parameter syntax: " + right);
ERR_FAIL_V(RES());
-
}
- String type = right.substr(0,popenpos);
- String param = right.substr(popenpos+1,pclosepos-popenpos-1).strip_edges();
-
+ String type = right.substr(0, popenpos);
+ String param = right.substr(popenpos + 1, pclosepos - popenpos - 1).strip_edges();
- if (type=="tex") {
+ if (type == "tex") {
- if (param=="") {
+ if (param == "") {
- value=RID();
+ value = RID();
} else {
String path;
if (param.is_abs_path())
- path=param;
+ path = param;
else
- path=base_path+"/"+param;
+ path = base_path + "/" + param;
Ref<Texture> texture = ResourceLoader::load(path);
if (!texture.is_valid()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Couldn't find icon at path: "+path);
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Couldn't find icon at path: " + path);
ERR_FAIL_V(RES());
}
- value=texture;
+ value = texture;
}
- } else if (type=="vec3") {
+ } else if (type == "vec3") {
- if (param=="") {
- value=Vector3();
+ if (param == "") {
+ value = Vector3();
} else {
Vector<String> params = param.split(",");
- if (params.size()!=3) {
+ if (params.size() != 3) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for vec3(): '"+right+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid param count for vec3(): '" + right + "'.");
ERR_FAIL_V(RES());
-
}
Vector3 v;
- for(int i=0;i<3;i++)
- v[i]=params[i].to_double();
- value=v;
+ for (int i = 0; i < 3; i++)
+ v[i] = params[i].to_double();
+ value = v;
}
+ } else if (type == "xform") {
- } else if (type=="xform") {
-
- if (param=="") {
- value=Transform();
+ if (param == "") {
+ value = Transform();
} else {
Vector<String> params = param.split(",");
- if (params.size()!=12) {
+ if (params.size() != 12) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for xform(): '"+right+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid param count for xform(): '" + right + "'.");
ERR_FAIL_V(RES());
-
}
Transform t;
- for(int i=0;i<9;i++)
- t.basis[i%3][i/3]=params[i].to_double();
- for(int i=0;i<3;i++)
- t.origin[i]=params[i-9].to_double();
+ for (int i = 0; i < 9; i++)
+ t.basis[i % 3][i / 3] = params[i].to_double();
+ for (int i = 0; i < 3; i++)
+ t.origin[i] = params[i - 9].to_double();
- value=t;
+ value = t;
}
} else {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor type: '"+type+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid constructor type: '" + type + "'.");
ERR_FAIL_V(RES());
-
}
-
}
- String left= l.substr(0,eqpos);
+ String left = l.substr(0, eqpos);
-// shader->set_param(left,value);
- } else if (mode==1) {
+ // shader->set_param(left,value);
+ } else if (mode == 1) {
- vertex_code+=l;
+ vertex_code += l;
- } else if (mode==2) {
+ } else if (mode == 2) {
- fragment_code+=l;
+ fragment_code += l;
}
}
- shader->set_code(vertex_code,fragment_code,light_code);
+ shader->set_code(vertex_code, fragment_code, light_code);
f->close();
memdelete(f);
if (r_error)
- *r_error=OK;
+ *r_error = OK;
return shader;
}
@@ -451,16 +427,14 @@ void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_exten
ObjectTypeDB::get_extensions_for_type("Shader", p_extensions);
}
-bool ResourceFormatLoaderShader::handles_type(const String& p_type) const {
+bool ResourceFormatLoaderShader::handles_type(const String &p_type) const {
return ObjectTypeDB::is_type(p_type, "Shader");
}
-
String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="shd")
+ if (p_path.extension().to_lower() == "shd")
return "Shader";
return "";
}
-
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 94ee04812..c2c808e5e 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -29,13 +29,13 @@
#ifndef SHADER_H
#define SHADER_H
-#include "resource.h"
#include "io/resource_loader.h"
+#include "resource.h"
#include "scene/resources/texture.h"
class Shader : public Resource {
- OBJ_TYPE(Shader,Resource);
- OBJ_SAVE_TYPE( Shader );
+ OBJ_TYPE(Shader, Resource);
+ OBJ_SAVE_TYPE(Shader);
RES_BASE_EXTENSION("shd");
public:
@@ -46,50 +46,44 @@ public:
MODE_POST_PROCESS,
MODE_MAX
};
+
private:
RID shader;
Mode mode;
Dictionary _get_code();
- void _set_code(const Dictionary& p_string);
-
+ void _set_code(const Dictionary &p_string);
// hack the name of performance
// shaders keep a list of ShaderMaterial -> VisualServer name translations, to make
// convertion fast and save memory.
mutable bool params_cache_dirty;
- mutable Map<StringName,StringName> params_cache; //map a shader param to a material param..
- Map<StringName,Ref<Texture> > default_textures;
-
-
+ mutable Map<StringName, StringName> params_cache; //map a shader param to a material param..
+ Map<StringName, Ref<Texture> > default_textures;
protected:
-
-
-
static void _bind_methods();
-public:
-
+public:
//void set_mode(Mode p_mode);
Mode get_mode() const;
- void set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs=0,int p_light_ofs=0);
+ void set_code(const String &p_vertex, const String &p_fragment, const String &p_light, int p_fragment_ofs = 0, int p_light_ofs = 0);
String get_vertex_code() const;
String get_fragment_code() const;
String get_light_code() const;
void get_param_list(List<PropertyInfo> *p_params) const;
- bool has_param(const StringName& p_param) const;
+ bool has_param(const StringName &p_param) const;
- void set_default_texture_param(const StringName& p_param, const Ref<Texture> &p_texture);
- Ref<Texture> get_default_texture_param(const StringName& p_param) const;
- void get_default_texture_param_list(List<StringName>* r_textures) const;
+ void set_default_texture_param(const StringName &p_param, const Ref<Texture> &p_texture);
+ Ref<Texture> get_default_texture_param(const StringName &p_param) const;
+ void get_default_texture_param_list(List<StringName> *r_textures) const;
- _FORCE_INLINE_ StringName remap_param(const StringName& p_param) const {
+ _FORCE_INLINE_ StringName remap_param(const StringName &p_param) const {
if (params_cache_dirty)
get_param_list(NULL);
- const Map<StringName,StringName>::Element *E=params_cache.find(p_param);
+ const Map<StringName, StringName>::Element *E = params_cache.find(p_param);
if (E)
return E->get();
return StringName();
@@ -99,39 +93,34 @@ public:
Shader(Mode p_mode);
~Shader();
-
};
-VARIANT_ENUM_CAST( Shader::Mode );
+VARIANT_ENUM_CAST(Shader::Mode);
class MaterialShader : public Shader {
- OBJ_TYPE(MaterialShader,Shader);
+ OBJ_TYPE(MaterialShader, Shader);
public:
-
- MaterialShader() : Shader(MODE_MATERIAL) {};
+ MaterialShader()
+ : Shader(MODE_MATERIAL){};
};
class CanvasItemShader : public Shader {
- OBJ_TYPE(CanvasItemShader,Shader);
+ OBJ_TYPE(CanvasItemShader, Shader);
public:
-
- CanvasItemShader() : Shader(MODE_CANVAS_ITEM) {};
+ CanvasItemShader()
+ : Shader(MODE_CANVAS_ITEM){};
};
-
-
class ResourceFormatLoaderShader : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
+ virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
};
-
-
#endif // SHADER_H
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index 7e549f778..ed146cc62 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -32,371 +32,360 @@
Array ShaderGraph::_get_node_list(ShaderType p_type) const {
List<int> nodes;
- get_node_list(p_type,&nodes);
+ get_node_list(p_type, &nodes);
Array arr(true);
- for (List<int>::Element *E=nodes.front();E;E=E->next())
+ for (List<int>::Element *E = nodes.front(); E; E = E->next())
arr.push_back(E->get());
return arr;
}
Array ShaderGraph::_get_connections(ShaderType p_type) const {
List<Connection> connections;
- get_node_connections(p_type,&connections);
+ get_node_connections(p_type, &connections);
Array arr(true);
- for (List<Connection>::Element *E=connections.front();E;E=E->next()) {
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
Dictionary d(true);
- d["src_id"]=E->get().src_id;
- d["src_slot"]=E->get().src_slot;
- d["dst_id"]=E->get().dst_id;
- d["dst_slot"]=E->get().dst_slot;
+ d["src_id"] = E->get().src_id;
+ d["src_slot"] = E->get().src_slot;
+ d["dst_id"] = E->get().dst_id;
+ d["dst_slot"] = E->get().dst_slot;
arr.push_back(d);
-
}
return arr;
}
void ShaderGraph::_set_data(const Dictionary &p_data) {
- Dictionary d=p_data;
+ Dictionary d = p_data;
ERR_FAIL_COND(!d.has("shaders"));
- Array sh=d["shaders"];
- ERR_FAIL_COND(sh.size()!=3);
+ Array sh = d["shaders"];
+ ERR_FAIL_COND(sh.size() != 3);
- for(int t=0;t<3;t++) {
- Array data=sh[t];
- ERR_FAIL_COND((data.size()%6)!=0);
+ for (int t = 0; t < 3; t++) {
+ Array data = sh[t];
+ ERR_FAIL_COND((data.size() % 6) != 0);
shader[t].node_map.clear();
- for(int i=0;i<data.size();i+=6) {
+ for (int i = 0; i < data.size(); i += 6) {
Node n;
- n.id=data[i+0];
- n.type=NodeType(int(data[i+1]));
- n.pos=data[i+2];
- n.param1=data[i+3];
- n.param2=data[i+4];
+ n.id = data[i + 0];
+ n.type = NodeType(int(data[i + 1]));
+ n.pos = data[i + 2];
+ n.param1 = data[i + 3];
+ n.param2 = data[i + 4];
- Array conns=data[i+5];
- ERR_FAIL_COND((conns.size()%3)!=0);
+ Array conns = data[i + 5];
+ ERR_FAIL_COND((conns.size() % 3) != 0);
- for(int j=0;j<conns.size();j+=3) {
+ for (int j = 0; j < conns.size(); j += 3) {
SourceSlot ss;
- int ls=conns[j+0];
+ int ls = conns[j + 0];
if (ls == SLOT_DEFAULT_VALUE) {
- n.defaults[conns[j+1]]=conns[j+2];
+ n.defaults[conns[j + 1]] = conns[j + 2];
} else {
- ss.id=conns[j+1];
- ss.slot=conns[j+2];
- n.connections[ls]=ss;
+ ss.id = conns[j + 1];
+ ss.slot = conns[j + 2];
+ n.connections[ls] = ss;
}
}
- shader[t].node_map[n.id]=n;
-
+ shader[t].node_map[n.id] = n;
}
}
- _pending_update_shader=true;
+ _pending_update_shader = true;
_update_shader();
-
}
Dictionary ShaderGraph::_get_data() const {
Array sh;
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
Array data;
int ec = shader[i].node_map.size();
- data.resize(ec*6);
- int idx=0;
- for (Map<int,Node>::Element*E=shader[i].node_map.front();E;E=E->next()) {
+ data.resize(ec * 6);
+ int idx = 0;
+ for (Map<int, Node>::Element *E = shader[i].node_map.front(); E; E = E->next()) {
- data[idx+0]=E->key();
- data[idx+1]=E->get().type;
- data[idx+2]=E->get().pos;
- data[idx+3]=E->get().param1;
- data[idx+4]=E->get().param2;
+ data[idx + 0] = E->key();
+ data[idx + 1] = E->get().type;
+ data[idx + 2] = E->get().pos;
+ data[idx + 3] = E->get().param1;
+ data[idx + 4] = E->get().param2;
Array conns;
- conns.resize(E->get().connections.size()*3+E->get().defaults.size()*3);
- int idx2=0;
- for(Map<int,SourceSlot>::Element*F=E->get().connections.front();F;F=F->next()) {
+ conns.resize(E->get().connections.size() * 3 + E->get().defaults.size() * 3);
+ int idx2 = 0;
+ for (Map<int, SourceSlot>::Element *F = E->get().connections.front(); F; F = F->next()) {
- conns[idx2+0]=F->key();
- conns[idx2+1]=F->get().id;
- conns[idx2+2]=F->get().slot;
- idx2+=3;
+ conns[idx2 + 0] = F->key();
+ conns[idx2 + 1] = F->get().id;
+ conns[idx2 + 2] = F->get().slot;
+ idx2 += 3;
}
- for(Map<int,Variant>::Element*F=E->get().defaults.front();F;F=F->next()) {
+ for (Map<int, Variant>::Element *F = E->get().defaults.front(); F; F = F->next()) {
- conns[idx2+0]=SLOT_DEFAULT_VALUE;
- conns[idx2+1]=F->key();
- conns[idx2+2]=F->get();
- idx2+=3;
+ conns[idx2 + 0] = SLOT_DEFAULT_VALUE;
+ conns[idx2 + 1] = F->key();
+ conns[idx2 + 2] = F->get();
+ idx2 += 3;
}
- data[idx+5]=conns;
- idx+=6;
+ data[idx + 5] = conns;
+ idx += 6;
}
sh.push_back(data);
}
Dictionary data;
- data["shaders"]=sh;
+ data["shaders"] = sh;
return data;
}
-
-
ShaderGraph::GraphError ShaderGraph::get_graph_error(ShaderType p_type) const {
- ERR_FAIL_INDEX_V(p_type,3,GRAPH_OK);
+ ERR_FAIL_INDEX_V(p_type, 3, GRAPH_OK);
return shader[p_type].error;
}
-int ShaderGraph::node_count(ShaderType p_which, int p_type)
-{
- int count=0;
- for (Map<int,Node>::Element *E=shader[p_which].node_map.front();E;E=E->next())
- if (E->get().type==p_type)
+int ShaderGraph::node_count(ShaderType p_which, int p_type) {
+ int count = 0;
+ for (Map<int, Node>::Element *E = shader[p_which].node_map.front(); E; E = E->next())
+ if (E->get().type == p_type)
count++;
return count;
}
void ShaderGraph::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader);
-
- ObjectTypeDB::bind_method(_MD("node_add","shader_type","node_type","id"),&ShaderGraph::node_add);
- ObjectTypeDB::bind_method(_MD("node_remove","shader_type","id"),&ShaderGraph::node_remove);
- ObjectTypeDB::bind_method(_MD("node_set_pos","shader_type","id","pos"),&ShaderGraph::node_set_pos);
- ObjectTypeDB::bind_method(_MD("node_get_pos","shader_type","id"),&ShaderGraph::node_get_pos);
+ ObjectTypeDB::bind_method(_MD("_update_shader"), &ShaderGraph::_update_shader);
- ObjectTypeDB::bind_method(_MD("node_get_type","shader_type","id"),&ShaderGraph::node_get_type);
+ ObjectTypeDB::bind_method(_MD("node_add", "shader_type", "node_type", "id"), &ShaderGraph::node_add);
+ ObjectTypeDB::bind_method(_MD("node_remove", "shader_type", "id"), &ShaderGraph::node_remove);
+ ObjectTypeDB::bind_method(_MD("node_set_pos", "shader_type", "id", "pos"), &ShaderGraph::node_set_pos);
+ ObjectTypeDB::bind_method(_MD("node_get_pos", "shader_type", "id"), &ShaderGraph::node_get_pos);
- ObjectTypeDB::bind_method(_MD("get_node_list","shader_type"),&ShaderGraph::_get_node_list);
+ ObjectTypeDB::bind_method(_MD("node_get_type", "shader_type", "id"), &ShaderGraph::node_get_type);
- ObjectTypeDB::bind_method(_MD("default_set_value","shader_type","id","param_id","value"), &ShaderGraph::default_set_value);
- ObjectTypeDB::bind_method(_MD("default_get_value","shader_type","id","param_id"), &ShaderGraph::default_get_value);
+ ObjectTypeDB::bind_method(_MD("get_node_list", "shader_type"), &ShaderGraph::_get_node_list);
- ObjectTypeDB::bind_method(_MD("scalar_const_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_const_node_set_value);
- ObjectTypeDB::bind_method(_MD("scalar_const_node_get_value","shader_type","id"),&ShaderGraph::scalar_const_node_get_value);
+ ObjectTypeDB::bind_method(_MD("default_set_value", "shader_type", "id", "param_id", "value"), &ShaderGraph::default_set_value);
+ ObjectTypeDB::bind_method(_MD("default_get_value", "shader_type", "id", "param_id"), &ShaderGraph::default_get_value);
- ObjectTypeDB::bind_method(_MD("vec_const_node_set_value","shader_type","id","value"),&ShaderGraph::vec_const_node_set_value);
- ObjectTypeDB::bind_method(_MD("vec_const_node_get_value","shader_type","id"),&ShaderGraph::vec_const_node_get_value);
+ ObjectTypeDB::bind_method(_MD("scalar_const_node_set_value", "shader_type", "id", "value"), &ShaderGraph::scalar_const_node_set_value);
+ ObjectTypeDB::bind_method(_MD("scalar_const_node_get_value", "shader_type", "id"), &ShaderGraph::scalar_const_node_get_value);
- ObjectTypeDB::bind_method(_MD("rgb_const_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_const_node_set_value);
- ObjectTypeDB::bind_method(_MD("rgb_const_node_get_value","shader_type","id"),&ShaderGraph::rgb_const_node_get_value);
+ ObjectTypeDB::bind_method(_MD("vec_const_node_set_value", "shader_type", "id", "value"), &ShaderGraph::vec_const_node_set_value);
+ ObjectTypeDB::bind_method(_MD("vec_const_node_get_value", "shader_type", "id"), &ShaderGraph::vec_const_node_get_value);
- ObjectTypeDB::bind_method(_MD("xform_const_node_set_value","shader_type","id","value"),&ShaderGraph::xform_const_node_set_value);
- ObjectTypeDB::bind_method(_MD("xform_const_node_get_value","shader_type","id"),&ShaderGraph::xform_const_node_get_value);
+ ObjectTypeDB::bind_method(_MD("rgb_const_node_set_value", "shader_type", "id", "value"), &ShaderGraph::rgb_const_node_set_value);
+ ObjectTypeDB::bind_method(_MD("rgb_const_node_get_value", "shader_type", "id"), &ShaderGraph::rgb_const_node_get_value);
+ ObjectTypeDB::bind_method(_MD("xform_const_node_set_value", "shader_type", "id", "value"), &ShaderGraph::xform_const_node_set_value);
+ ObjectTypeDB::bind_method(_MD("xform_const_node_get_value", "shader_type", "id"), &ShaderGraph::xform_const_node_get_value);
-// void get_node_list(ShaderType p_which,List<int> *p_node_list) const;
+ // void get_node_list(ShaderType p_which,List<int> *p_node_list) const;
- ObjectTypeDB::bind_method(_MD("texture_node_set_filter_size","shader_type","id","filter_size"),&ShaderGraph::texture_node_set_filter_size);
- ObjectTypeDB::bind_method(_MD("texture_node_get_filter_size","shader_type","id"),&ShaderGraph::texture_node_get_filter_size);
+ ObjectTypeDB::bind_method(_MD("texture_node_set_filter_size", "shader_type", "id", "filter_size"), &ShaderGraph::texture_node_set_filter_size);
+ ObjectTypeDB::bind_method(_MD("texture_node_get_filter_size", "shader_type", "id"), &ShaderGraph::texture_node_get_filter_size);
- ObjectTypeDB::bind_method(_MD("texture_node_set_filter_strength","shader_type","id","filter_strength"),&ShaderGraph::texture_node_set_filter_strength);
- ObjectTypeDB::bind_method(_MD("texture_node_get_filter_strength","shader_type","id"),&ShaderGraph::texture_node_get_filter_strength);
+ ObjectTypeDB::bind_method(_MD("texture_node_set_filter_strength", "shader_type", "id", "filter_strength"), &ShaderGraph::texture_node_set_filter_strength);
+ ObjectTypeDB::bind_method(_MD("texture_node_get_filter_strength", "shader_type", "id"), &ShaderGraph::texture_node_get_filter_strength);
- ObjectTypeDB::bind_method(_MD("scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::scalar_op_node_set_op);
- ObjectTypeDB::bind_method(_MD("scalar_op_node_get_op","shader_type","id"),&ShaderGraph::scalar_op_node_get_op);
+ ObjectTypeDB::bind_method(_MD("scalar_op_node_set_op", "shader_type", "id", "op"), &ShaderGraph::scalar_op_node_set_op);
+ ObjectTypeDB::bind_method(_MD("scalar_op_node_get_op", "shader_type", "id"), &ShaderGraph::scalar_op_node_get_op);
- ObjectTypeDB::bind_method(_MD("vec_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_op_node_set_op);
- ObjectTypeDB::bind_method(_MD("vec_op_node_get_op","shader_type","id"),&ShaderGraph::vec_op_node_get_op);
+ ObjectTypeDB::bind_method(_MD("vec_op_node_set_op", "shader_type", "id", "op"), &ShaderGraph::vec_op_node_set_op);
+ ObjectTypeDB::bind_method(_MD("vec_op_node_get_op", "shader_type", "id"), &ShaderGraph::vec_op_node_get_op);
- ObjectTypeDB::bind_method(_MD("vec_scalar_op_node_set_op","shader_type","id","op"),&ShaderGraph::vec_scalar_op_node_set_op);
- ObjectTypeDB::bind_method(_MD("vec_scalar_op_node_get_op","shader_type","id"),&ShaderGraph::vec_scalar_op_node_get_op);
+ ObjectTypeDB::bind_method(_MD("vec_scalar_op_node_set_op", "shader_type", "id", "op"), &ShaderGraph::vec_scalar_op_node_set_op);
+ ObjectTypeDB::bind_method(_MD("vec_scalar_op_node_get_op", "shader_type", "id"), &ShaderGraph::vec_scalar_op_node_get_op);
- ObjectTypeDB::bind_method(_MD("rgb_op_node_set_op","shader_type","id","op"),&ShaderGraph::rgb_op_node_set_op);
- ObjectTypeDB::bind_method(_MD("rgb_op_node_get_op","shader_type","id"),&ShaderGraph::rgb_op_node_get_op);
+ ObjectTypeDB::bind_method(_MD("rgb_op_node_set_op", "shader_type", "id", "op"), &ShaderGraph::rgb_op_node_set_op);
+ ObjectTypeDB::bind_method(_MD("rgb_op_node_get_op", "shader_type", "id"), &ShaderGraph::rgb_op_node_get_op);
+ ObjectTypeDB::bind_method(_MD("xform_vec_mult_node_set_no_translation", "shader_type", "id", "disable"), &ShaderGraph::xform_vec_mult_node_set_no_translation);
+ ObjectTypeDB::bind_method(_MD("xform_vec_mult_node_get_no_translation", "shader_type", "id"), &ShaderGraph::xform_vec_mult_node_get_no_translation);
- ObjectTypeDB::bind_method(_MD("xform_vec_mult_node_set_no_translation","shader_type","id","disable"),&ShaderGraph::xform_vec_mult_node_set_no_translation);
- ObjectTypeDB::bind_method(_MD("xform_vec_mult_node_get_no_translation","shader_type","id"),&ShaderGraph::xform_vec_mult_node_get_no_translation);
+ ObjectTypeDB::bind_method(_MD("scalar_func_node_set_function", "shader_type", "id", "func"), &ShaderGraph::scalar_func_node_set_function);
+ ObjectTypeDB::bind_method(_MD("scalar_func_node_get_function", "shader_type", "id"), &ShaderGraph::scalar_func_node_get_function);
- ObjectTypeDB::bind_method(_MD("scalar_func_node_set_function","shader_type","id","func"),&ShaderGraph::scalar_func_node_set_function);
- ObjectTypeDB::bind_method(_MD("scalar_func_node_get_function","shader_type","id"),&ShaderGraph::scalar_func_node_get_function);
+ ObjectTypeDB::bind_method(_MD("vec_func_node_set_function", "shader_type", "id", "func"), &ShaderGraph::vec_func_node_set_function);
+ ObjectTypeDB::bind_method(_MD("vec_func_node_get_function", "shader_type", "id"), &ShaderGraph::vec_func_node_get_function);
- ObjectTypeDB::bind_method(_MD("vec_func_node_set_function","shader_type","id","func"),&ShaderGraph::vec_func_node_set_function);
- ObjectTypeDB::bind_method(_MD("vec_func_node_get_function","shader_type","id"),&ShaderGraph::vec_func_node_get_function);
+ ObjectTypeDB::bind_method(_MD("input_node_set_name", "shader_type", "id", "name"), &ShaderGraph::input_node_set_name);
+ ObjectTypeDB::bind_method(_MD("input_node_get_name", "shader_type", "id"), &ShaderGraph::input_node_get_name);
- ObjectTypeDB::bind_method(_MD("input_node_set_name","shader_type","id","name"),&ShaderGraph::input_node_set_name);
- ObjectTypeDB::bind_method(_MD("input_node_get_name","shader_type","id"),&ShaderGraph::input_node_get_name);
+ ObjectTypeDB::bind_method(_MD("scalar_input_node_set_value", "shader_type", "id", "value"), &ShaderGraph::scalar_input_node_set_value);
+ ObjectTypeDB::bind_method(_MD("scalar_input_node_get_value", "shader_type", "id"), &ShaderGraph::scalar_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("scalar_input_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("scalar_input_node_get_value","shader_type","id"),&ShaderGraph::scalar_input_node_get_value);
+ ObjectTypeDB::bind_method(_MD("vec_input_node_set_value", "shader_type", "id", "value"), &ShaderGraph::vec_input_node_set_value);
+ ObjectTypeDB::bind_method(_MD("vec_input_node_get_value", "shader_type", "id"), &ShaderGraph::vec_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("vec_input_node_set_value","shader_type","id","value"),&ShaderGraph::vec_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("vec_input_node_get_value","shader_type","id"),&ShaderGraph::vec_input_node_get_value);
+ ObjectTypeDB::bind_method(_MD("rgb_input_node_set_value", "shader_type", "id", "value"), &ShaderGraph::rgb_input_node_set_value);
+ ObjectTypeDB::bind_method(_MD("rgb_input_node_get_value", "shader_type", "id"), &ShaderGraph::rgb_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("rgb_input_node_set_value","shader_type","id","value"),&ShaderGraph::rgb_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("rgb_input_node_get_value","shader_type","id"),&ShaderGraph::rgb_input_node_get_value);
+ ObjectTypeDB::bind_method(_MD("xform_input_node_set_value", "shader_type", "id", "value"), &ShaderGraph::xform_input_node_set_value);
+ ObjectTypeDB::bind_method(_MD("xform_input_node_get_value", "shader_type", "id"), &ShaderGraph::xform_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("xform_input_node_set_value","shader_type","id","value"),&ShaderGraph::xform_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("xform_input_node_get_value","shader_type","id"),&ShaderGraph::xform_input_node_get_value);
+ ObjectTypeDB::bind_method(_MD("texture_input_node_set_value", "shader_type", "id", "value:Texture"), &ShaderGraph::texture_input_node_set_value);
+ ObjectTypeDB::bind_method(_MD("texture_input_node_get_value:Texture", "shader_type", "id"), &ShaderGraph::texture_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("texture_input_node_set_value","shader_type","id","value:Texture"),&ShaderGraph::texture_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("texture_input_node_get_value:Texture","shader_type","id"),&ShaderGraph::texture_input_node_get_value);
+ ObjectTypeDB::bind_method(_MD("cubemap_input_node_set_value", "shader_type", "id", "value:CubeMap"), &ShaderGraph::cubemap_input_node_set_value);
+ ObjectTypeDB::bind_method(_MD("cubemap_input_node_get_value:CubeMap", "shader_type", "id"), &ShaderGraph::cubemap_input_node_get_value);
- ObjectTypeDB::bind_method(_MD("cubemap_input_node_set_value","shader_type","id","value:CubeMap"),&ShaderGraph::cubemap_input_node_set_value);
- ObjectTypeDB::bind_method(_MD("cubemap_input_node_get_value:CubeMap","shader_type","id"),&ShaderGraph::cubemap_input_node_get_value);
+ ObjectTypeDB::bind_method(_MD("comment_node_set_text", "shader_type", "id", "text"), &ShaderGraph::comment_node_set_text);
+ ObjectTypeDB::bind_method(_MD("comment_node_get_text", "shader_type", "id"), &ShaderGraph::comment_node_get_text);
- ObjectTypeDB::bind_method(_MD("comment_node_set_text","shader_type","id","text"),&ShaderGraph::comment_node_set_text);
- ObjectTypeDB::bind_method(_MD("comment_node_get_text","shader_type","id"),&ShaderGraph::comment_node_get_text);
+ ObjectTypeDB::bind_method(_MD("color_ramp_node_set_ramp", "shader_type", "id", "colors", "offsets"), &ShaderGraph::color_ramp_node_set_ramp);
+ ObjectTypeDB::bind_method(_MD("color_ramp_node_get_colors", "shader_type", "id"), &ShaderGraph::color_ramp_node_get_colors);
+ ObjectTypeDB::bind_method(_MD("color_ramp_node_get_offsets", "shader_type", "id"), &ShaderGraph::color_ramp_node_get_offsets);
- ObjectTypeDB::bind_method(_MD("color_ramp_node_set_ramp","shader_type","id","colors","offsets"),&ShaderGraph::color_ramp_node_set_ramp);
- ObjectTypeDB::bind_method(_MD("color_ramp_node_get_colors","shader_type","id"),&ShaderGraph::color_ramp_node_get_colors);
- ObjectTypeDB::bind_method(_MD("color_ramp_node_get_offsets","shader_type","id"),&ShaderGraph::color_ramp_node_get_offsets);
+ ObjectTypeDB::bind_method(_MD("curve_map_node_set_points", "shader_type", "id", "points"), &ShaderGraph::curve_map_node_set_points);
+ ObjectTypeDB::bind_method(_MD("curve_map_node_get_points", "shader_type", "id"), &ShaderGraph::curve_map_node_get_points);
- ObjectTypeDB::bind_method(_MD("curve_map_node_set_points","shader_type","id","points"),&ShaderGraph::curve_map_node_set_points);
- ObjectTypeDB::bind_method(_MD("curve_map_node_get_points","shader_type","id"),&ShaderGraph::curve_map_node_get_points);
+ ObjectTypeDB::bind_method(_MD("connect_node:Error", "shader_type", "src_id", "src_slot", "dst_id", "dst_slot"), &ShaderGraph::connect_node);
+ ObjectTypeDB::bind_method(_MD("is_node_connected", "shader_type", "src_id", "src_slot", "dst_id", "dst_slot"), &ShaderGraph::is_node_connected);
+ ObjectTypeDB::bind_method(_MD("disconnect_node", "shader_type", "src_id", "src_slot", "dst_id", "dst_slot"), &ShaderGraph::disconnect_node);
+ ObjectTypeDB::bind_method(_MD("get_node_connections", "shader_type"), &ShaderGraph::_get_connections);
- ObjectTypeDB::bind_method(_MD("connect_node:Error","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::connect_node);
- ObjectTypeDB::bind_method(_MD("is_node_connected","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::is_node_connected);
- ObjectTypeDB::bind_method(_MD("disconnect_node","shader_type","src_id","src_slot","dst_id","dst_slot"),&ShaderGraph::disconnect_node);
- ObjectTypeDB::bind_method(_MD("get_node_connections","shader_type"),&ShaderGraph::_get_connections);
+ ObjectTypeDB::bind_method(_MD("clear", "shader_type"), &ShaderGraph::clear);
- ObjectTypeDB::bind_method(_MD("clear","shader_type"),&ShaderGraph::clear);
+ ObjectTypeDB::bind_method(_MD("node_set_state", "shader_type", "id", "state"), &ShaderGraph::node_set_state);
+ ObjectTypeDB::bind_method(_MD("node_get_state:Variant", "shader_type", "id"), &ShaderGraph::node_get_state);
- ObjectTypeDB::bind_method(_MD("node_set_state","shader_type","id","state"),&ShaderGraph::node_set_state);
- ObjectTypeDB::bind_method(_MD("node_get_state:Variant","shader_type","id"),&ShaderGraph::node_get_state);
+ ObjectTypeDB::bind_method(_MD("_set_data"), &ShaderGraph::_set_data);
+ ObjectTypeDB::bind_method(_MD("_get_data"), &ShaderGraph::_get_data);
- ObjectTypeDB::bind_method(_MD("_set_data"),&ShaderGraph::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&ShaderGraph::_get_data);
-
- ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data"));
+ ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data"));
//void get_connections(ShaderType p_which,List<Connection> *p_connections) const;
+ BIND_CONSTANT(NODE_INPUT); // all inputs (shader type dependent)
+ BIND_CONSTANT(NODE_SCALAR_CONST); //scalar constant
+ BIND_CONSTANT(NODE_VEC_CONST); //vec3 constant
+ BIND_CONSTANT(NODE_RGB_CONST); //rgb constant (shows a color picker instead)
+ BIND_CONSTANT(NODE_XFORM_CONST); // 4x4 matrix constant
+ BIND_CONSTANT(NODE_TIME); // time in seconds
+ BIND_CONSTANT(NODE_SCREEN_TEX); // screen texture sampler (takes UV) (only usable in fragment shader)
+ BIND_CONSTANT(NODE_SCALAR_OP); // scalar vs scalar op (mul ); add ); div ); etc)
+ BIND_CONSTANT(NODE_VEC_OP); // vec3 vs vec3 op (mul );ad );div );crossprod );etc)
+ BIND_CONSTANT(NODE_VEC_SCALAR_OP); // vec3 vs scalar op (mul ); add ); div ); etc)
+ BIND_CONSTANT(NODE_RGB_OP); // vec3 vs vec3 rgb op (with scalar amount) ); like brighten ); darken ); burn ); dodge ); multiply ); etc.
+ BIND_CONSTANT(NODE_XFORM_MULT); // mat4 x mat4
+ BIND_CONSTANT(NODE_XFORM_VEC_MULT); // mat4 x vec3 mult (with no-translation option)
+ BIND_CONSTANT(NODE_XFORM_VEC_INV_MULT); // mat4 x vec3 inverse mult (with no-translation option)
+ BIND_CONSTANT(NODE_SCALAR_FUNC); // scalar function (sin ); cos ); etc)
+ BIND_CONSTANT(NODE_VEC_FUNC); // vector function (normalize ); negate ); reciprocal ); rgb2hsv ); hsv2rgb ); etc ); etc)
+ BIND_CONSTANT(NODE_VEC_LEN); // vec3 length
+ BIND_CONSTANT(NODE_DOT_PROD); // vec3 . vec3 (dot product -> scalar output)
+ BIND_CONSTANT(NODE_VEC_TO_SCALAR); // 1 vec3 input ); 3 scalar outputs
+ BIND_CONSTANT(NODE_SCALAR_TO_VEC); // 3 scalar input ); 1 vec3 output
+ BIND_CONSTANT(NODE_VEC_TO_XFORM); // 3 vec input ); 1 xform output
+ BIND_CONSTANT(NODE_XFORM_TO_VEC); // 3 vec input ); 1 xform output
+ BIND_CONSTANT(NODE_SCALAR_INTERP); // scalar interpolation (with optional curve)
+ BIND_CONSTANT(NODE_VEC_INTERP); // vec3 interpolation (with optional curve)
+ BIND_CONSTANT(NODE_COLOR_RAMP);
+ BIND_CONSTANT(NODE_CURVE_MAP);
+ BIND_CONSTANT(NODE_SCALAR_INPUT); // scalar uniform (assignable in material)
+ BIND_CONSTANT(NODE_VEC_INPUT); // vec3 uniform (assignable in material)
+ BIND_CONSTANT(NODE_RGB_INPUT); // color uniform (assignable in material)
+ BIND_CONSTANT(NODE_XFORM_INPUT); // mat4 uniform (assignable in material)
+ BIND_CONSTANT(NODE_TEXTURE_INPUT); // texture input (assignable in material)
+ BIND_CONSTANT(NODE_CUBEMAP_INPUT); // cubemap input (assignable in material)
+ BIND_CONSTANT(NODE_DEFAULT_TEXTURE);
+ BIND_CONSTANT(NODE_OUTPUT); // output (shader type dependent)
+ BIND_CONSTANT(NODE_COMMENT); // comment
+ BIND_CONSTANT(NODE_TYPE_MAX);
- BIND_CONSTANT( NODE_INPUT ); // all inputs (shader type dependent)
- BIND_CONSTANT( NODE_SCALAR_CONST ); //scalar constant
- BIND_CONSTANT( NODE_VEC_CONST ); //vec3 constant
- BIND_CONSTANT( NODE_RGB_CONST ); //rgb constant (shows a color picker instead)
- BIND_CONSTANT( NODE_XFORM_CONST ); // 4x4 matrix constant
- BIND_CONSTANT( NODE_TIME ); // time in seconds
- BIND_CONSTANT( NODE_SCREEN_TEX ); // screen texture sampler (takes UV) (only usable in fragment shader)
- BIND_CONSTANT( NODE_SCALAR_OP ); // scalar vs scalar op (mul ); add ); div ); etc)
- BIND_CONSTANT( NODE_VEC_OP ); // vec3 vs vec3 op (mul );ad );div );crossprod );etc)
- BIND_CONSTANT( NODE_VEC_SCALAR_OP ); // vec3 vs scalar op (mul ); add ); div ); etc)
- BIND_CONSTANT( NODE_RGB_OP ); // vec3 vs vec3 rgb op (with scalar amount) ); like brighten ); darken ); burn ); dodge ); multiply ); etc.
- BIND_CONSTANT( NODE_XFORM_MULT ); // mat4 x mat4
- BIND_CONSTANT( NODE_XFORM_VEC_MULT ); // mat4 x vec3 mult (with no-translation option)
- BIND_CONSTANT( NODE_XFORM_VEC_INV_MULT ); // mat4 x vec3 inverse mult (with no-translation option)
- BIND_CONSTANT( NODE_SCALAR_FUNC ); // scalar function (sin ); cos ); etc)
- BIND_CONSTANT( NODE_VEC_FUNC ); // vector function (normalize ); negate ); reciprocal ); rgb2hsv ); hsv2rgb ); etc ); etc)
- BIND_CONSTANT( NODE_VEC_LEN ); // vec3 length
- BIND_CONSTANT( NODE_DOT_PROD ); // vec3 . vec3 (dot product -> scalar output)
- BIND_CONSTANT( NODE_VEC_TO_SCALAR ); // 1 vec3 input ); 3 scalar outputs
- BIND_CONSTANT( NODE_SCALAR_TO_VEC ); // 3 scalar input ); 1 vec3 output
- BIND_CONSTANT( NODE_VEC_TO_XFORM ); // 3 vec input ); 1 xform output
- BIND_CONSTANT( NODE_XFORM_TO_VEC ); // 3 vec input ); 1 xform output
- BIND_CONSTANT( NODE_SCALAR_INTERP ); // scalar interpolation (with optional curve)
- BIND_CONSTANT( NODE_VEC_INTERP ); // vec3 interpolation (with optional curve)
- BIND_CONSTANT( NODE_COLOR_RAMP );
- BIND_CONSTANT( NODE_CURVE_MAP );
- BIND_CONSTANT( NODE_SCALAR_INPUT ); // scalar uniform (assignable in material)
- BIND_CONSTANT( NODE_VEC_INPUT ); // vec3 uniform (assignable in material)
- BIND_CONSTANT( NODE_RGB_INPUT ); // color uniform (assignable in material)
- BIND_CONSTANT( NODE_XFORM_INPUT ); // mat4 uniform (assignable in material)
- BIND_CONSTANT( NODE_TEXTURE_INPUT ); // texture input (assignable in material)
- BIND_CONSTANT( NODE_CUBEMAP_INPUT ); // cubemap input (assignable in material)
- BIND_CONSTANT( NODE_DEFAULT_TEXTURE );
- BIND_CONSTANT( NODE_OUTPUT ); // output (shader type dependent)
- BIND_CONSTANT( NODE_COMMENT ); // comment
- BIND_CONSTANT( NODE_TYPE_MAX );
-
- BIND_CONSTANT( SLOT_TYPE_SCALAR );
- BIND_CONSTANT( SLOT_TYPE_VEC );
- BIND_CONSTANT( SLOT_TYPE_XFORM );
- BIND_CONSTANT( SLOT_TYPE_TEXTURE );
- BIND_CONSTANT( SLOT_MAX );
-
- BIND_CONSTANT( SHADER_TYPE_VERTEX );
- BIND_CONSTANT( SHADER_TYPE_FRAGMENT );
- BIND_CONSTANT( SHADER_TYPE_LIGHT );
- BIND_CONSTANT( SHADER_TYPE_MAX );
+ BIND_CONSTANT(SLOT_TYPE_SCALAR);
+ BIND_CONSTANT(SLOT_TYPE_VEC);
+ BIND_CONSTANT(SLOT_TYPE_XFORM);
+ BIND_CONSTANT(SLOT_TYPE_TEXTURE);
+ BIND_CONSTANT(SLOT_MAX);
+ BIND_CONSTANT(SHADER_TYPE_VERTEX);
+ BIND_CONSTANT(SHADER_TYPE_FRAGMENT);
+ BIND_CONSTANT(SHADER_TYPE_LIGHT);
+ BIND_CONSTANT(SHADER_TYPE_MAX);
- BIND_CONSTANT( SLOT_IN );
- BIND_CONSTANT( SLOT_OUT );
+ BIND_CONSTANT(SLOT_IN);
+ BIND_CONSTANT(SLOT_OUT);
- BIND_CONSTANT( GRAPH_OK );
- BIND_CONSTANT( GRAPH_ERROR_CYCLIC );
- BIND_CONSTANT( GRAPH_ERROR_MISSING_CONNECTIONS );
+ BIND_CONSTANT(GRAPH_OK);
+ BIND_CONSTANT(GRAPH_ERROR_CYCLIC);
+ BIND_CONSTANT(GRAPH_ERROR_MISSING_CONNECTIONS);
- BIND_CONSTANT( SCALAR_OP_ADD );
- BIND_CONSTANT( SCALAR_OP_SUB );
- BIND_CONSTANT( SCALAR_OP_MUL );
- BIND_CONSTANT( SCALAR_OP_DIV );
- BIND_CONSTANT( SCALAR_OP_MOD );
- BIND_CONSTANT( SCALAR_OP_POW );
- BIND_CONSTANT( SCALAR_OP_MAX );
- BIND_CONSTANT( SCALAR_OP_MIN );
- BIND_CONSTANT( SCALAR_OP_ATAN2 );
- BIND_CONSTANT( SCALAR_MAX_OP );
+ BIND_CONSTANT(SCALAR_OP_ADD);
+ BIND_CONSTANT(SCALAR_OP_SUB);
+ BIND_CONSTANT(SCALAR_OP_MUL);
+ BIND_CONSTANT(SCALAR_OP_DIV);
+ BIND_CONSTANT(SCALAR_OP_MOD);
+ BIND_CONSTANT(SCALAR_OP_POW);
+ BIND_CONSTANT(SCALAR_OP_MAX);
+ BIND_CONSTANT(SCALAR_OP_MIN);
+ BIND_CONSTANT(SCALAR_OP_ATAN2);
+ BIND_CONSTANT(SCALAR_MAX_OP);
- BIND_CONSTANT( VEC_OP_ADD );
- BIND_CONSTANT( VEC_OP_SUB );
- BIND_CONSTANT( VEC_OP_MUL );
- BIND_CONSTANT( VEC_OP_DIV );
- BIND_CONSTANT( VEC_OP_MOD );
- BIND_CONSTANT( VEC_OP_POW );
- BIND_CONSTANT( VEC_OP_MAX );
- BIND_CONSTANT( VEC_OP_MIN );
- BIND_CONSTANT( VEC_OP_CROSS );
- BIND_CONSTANT( VEC_MAX_OP );
+ BIND_CONSTANT(VEC_OP_ADD);
+ BIND_CONSTANT(VEC_OP_SUB);
+ BIND_CONSTANT(VEC_OP_MUL);
+ BIND_CONSTANT(VEC_OP_DIV);
+ BIND_CONSTANT(VEC_OP_MOD);
+ BIND_CONSTANT(VEC_OP_POW);
+ BIND_CONSTANT(VEC_OP_MAX);
+ BIND_CONSTANT(VEC_OP_MIN);
+ BIND_CONSTANT(VEC_OP_CROSS);
+ BIND_CONSTANT(VEC_MAX_OP);
- BIND_CONSTANT( VEC_SCALAR_OP_MUL );
- BIND_CONSTANT( VEC_SCALAR_OP_DIV );
- BIND_CONSTANT( VEC_SCALAR_OP_POW );
- BIND_CONSTANT( VEC_SCALAR_MAX_OP );
+ BIND_CONSTANT(VEC_SCALAR_OP_MUL);
+ BIND_CONSTANT(VEC_SCALAR_OP_DIV);
+ BIND_CONSTANT(VEC_SCALAR_OP_POW);
+ BIND_CONSTANT(VEC_SCALAR_MAX_OP);
- BIND_CONSTANT( RGB_OP_SCREEN );
- BIND_CONSTANT( RGB_OP_DIFFERENCE );
- BIND_CONSTANT( RGB_OP_DARKEN );
- BIND_CONSTANT( RGB_OP_LIGHTEN );
- BIND_CONSTANT( RGB_OP_OVERLAY );
- BIND_CONSTANT( RGB_OP_DODGE );
- BIND_CONSTANT( RGB_OP_BURN );
- BIND_CONSTANT( RGB_OP_SOFT_LIGHT );
- BIND_CONSTANT( RGB_OP_HARD_LIGHT );
- BIND_CONSTANT( RGB_MAX_OP );
+ BIND_CONSTANT(RGB_OP_SCREEN);
+ BIND_CONSTANT(RGB_OP_DIFFERENCE);
+ BIND_CONSTANT(RGB_OP_DARKEN);
+ BIND_CONSTANT(RGB_OP_LIGHTEN);
+ BIND_CONSTANT(RGB_OP_OVERLAY);
+ BIND_CONSTANT(RGB_OP_DODGE);
+ BIND_CONSTANT(RGB_OP_BURN);
+ BIND_CONSTANT(RGB_OP_SOFT_LIGHT);
+ BIND_CONSTANT(RGB_OP_HARD_LIGHT);
+ BIND_CONSTANT(RGB_MAX_OP);
- BIND_CONSTANT( SCALAR_FUNC_SIN );
- BIND_CONSTANT( SCALAR_FUNC_COS );
- BIND_CONSTANT( SCALAR_FUNC_TAN );
- BIND_CONSTANT( SCALAR_FUNC_ASIN );
- BIND_CONSTANT( SCALAR_FUNC_ACOS );
- BIND_CONSTANT( SCALAR_FUNC_ATAN );
- BIND_CONSTANT( SCALAR_FUNC_SINH );
- BIND_CONSTANT( SCALAR_FUNC_COSH );
- BIND_CONSTANT( SCALAR_FUNC_TANH );
- BIND_CONSTANT( SCALAR_FUNC_LOG );
- BIND_CONSTANT( SCALAR_FUNC_EXP );
- BIND_CONSTANT( SCALAR_FUNC_SQRT );
- BIND_CONSTANT( SCALAR_FUNC_ABS );
- BIND_CONSTANT( SCALAR_FUNC_SIGN );
- BIND_CONSTANT( SCALAR_FUNC_FLOOR );
- BIND_CONSTANT( SCALAR_FUNC_ROUND );
- BIND_CONSTANT( SCALAR_FUNC_CEIL );
- BIND_CONSTANT( SCALAR_FUNC_FRAC );
- BIND_CONSTANT( SCALAR_FUNC_SATURATE );
- BIND_CONSTANT( SCALAR_FUNC_NEGATE );
- BIND_CONSTANT( SCALAR_MAX_FUNC );
+ BIND_CONSTANT(SCALAR_FUNC_SIN);
+ BIND_CONSTANT(SCALAR_FUNC_COS);
+ BIND_CONSTANT(SCALAR_FUNC_TAN);
+ BIND_CONSTANT(SCALAR_FUNC_ASIN);
+ BIND_CONSTANT(SCALAR_FUNC_ACOS);
+ BIND_CONSTANT(SCALAR_FUNC_ATAN);
+ BIND_CONSTANT(SCALAR_FUNC_SINH);
+ BIND_CONSTANT(SCALAR_FUNC_COSH);
+ BIND_CONSTANT(SCALAR_FUNC_TANH);
+ BIND_CONSTANT(SCALAR_FUNC_LOG);
+ BIND_CONSTANT(SCALAR_FUNC_EXP);
+ BIND_CONSTANT(SCALAR_FUNC_SQRT);
+ BIND_CONSTANT(SCALAR_FUNC_ABS);
+ BIND_CONSTANT(SCALAR_FUNC_SIGN);
+ BIND_CONSTANT(SCALAR_FUNC_FLOOR);
+ BIND_CONSTANT(SCALAR_FUNC_ROUND);
+ BIND_CONSTANT(SCALAR_FUNC_CEIL);
+ BIND_CONSTANT(SCALAR_FUNC_FRAC);
+ BIND_CONSTANT(SCALAR_FUNC_SATURATE);
+ BIND_CONSTANT(SCALAR_FUNC_NEGATE);
+ BIND_CONSTANT(SCALAR_MAX_FUNC);
- BIND_CONSTANT( VEC_FUNC_NORMALIZE );
- BIND_CONSTANT( VEC_FUNC_SATURATE );
- BIND_CONSTANT( VEC_FUNC_NEGATE );
- BIND_CONSTANT( VEC_FUNC_RECIPROCAL );
- BIND_CONSTANT( VEC_FUNC_RGB2HSV );
- BIND_CONSTANT( VEC_FUNC_HSV2RGB );
- BIND_CONSTANT( VEC_MAX_FUNC );
+ BIND_CONSTANT(VEC_FUNC_NORMALIZE);
+ BIND_CONSTANT(VEC_FUNC_SATURATE);
+ BIND_CONSTANT(VEC_FUNC_NEGATE);
+ BIND_CONSTANT(VEC_FUNC_RECIPROCAL);
+ BIND_CONSTANT(VEC_FUNC_RGB2HSV);
+ BIND_CONSTANT(VEC_FUNC_HSV2RGB);
+ BIND_CONSTANT(VEC_MAX_FUNC);
ADD_SIGNAL(MethodInfo("updated"));
-
#if 0
ObjectTypeDB::bind_method(_MD("node_add"),&ShaderGraph::node_add );
ObjectTypeDB::bind_method(_MD("node_remove"),&ShaderGraph::node_remove );
@@ -471,30 +460,26 @@ void ShaderGraph::_bind_methods() {
#endif
}
+String ShaderGraph::_find_unique_name(const String &p_base) {
-String ShaderGraph::_find_unique_name(const String& p_base) {
-
-
-
- int idx=1;
- while(true) {
- String tocmp=p_base;
- if (idx>1) {
- tocmp+="_"+itos(idx);
+ int idx = 1;
+ while (true) {
+ String tocmp = p_base;
+ if (idx > 1) {
+ tocmp += "_" + itos(idx);
}
- bool valid=true;
- for(int i=0;i<3;i++) {
+ bool valid = true;
+ for (int i = 0; i < 3; i++) {
if (!valid)
break;
- for (Map<int,Node>::Element *E=shader[i].node_map.front();E;E=E->next()) {
- if (E->get().type!=NODE_SCALAR_INPUT && E->get().type!=NODE_VEC_INPUT && E->get().type==NODE_RGB_INPUT && E->get().type==NODE_XFORM_INPUT && E->get().type==NODE_TEXTURE_INPUT && E->get().type==NODE_CUBEMAP_INPUT)
+ for (Map<int, Node>::Element *E = shader[i].node_map.front(); E; E = E->next()) {
+ if (E->get().type != NODE_SCALAR_INPUT && E->get().type != NODE_VEC_INPUT && E->get().type == NODE_RGB_INPUT && E->get().type == NODE_XFORM_INPUT && E->get().type == NODE_TEXTURE_INPUT && E->get().type == NODE_CUBEMAP_INPUT)
continue;
String name = E->get().param1;
- if (name==tocmp) {
- valid=false;
+ if (name == tocmp) {
+ valid = false;
break;
}
-
}
}
@@ -507,390 +492,426 @@ String ShaderGraph::_find_unique_name(const String& p_base) {
return String();
}
-void ShaderGraph::node_add(ShaderType p_type, NodeType p_node_type,int p_id) {
+void ShaderGraph::node_add(ShaderType p_type, NodeType p_node_type, int p_id) {
- ERR_FAIL_INDEX(p_type,3);
- ERR_FAIL_COND(p_id==0);
- ERR_FAIL_COND(p_node_type==NODE_OUTPUT); //can't create output
- ERR_FAIL_COND( shader[p_type].node_map.has(p_id ) );
- ERR_FAIL_INDEX( p_node_type, NODE_TYPE_MAX );
+ ERR_FAIL_INDEX(p_type, 3);
+ ERR_FAIL_COND(p_id == 0);
+ ERR_FAIL_COND(p_node_type == NODE_OUTPUT); //can't create output
+ ERR_FAIL_COND(shader[p_type].node_map.has(p_id));
+ ERR_FAIL_INDEX(p_node_type, NODE_TYPE_MAX);
Node node;
- if (p_node_type==NODE_INPUT) {
+ if (p_node_type == NODE_INPUT) {
//see if it already exists
- for(Map<int,Node>::Element *E=shader[p_type].node_map.front();E;E=E->next()) {
- if (E->get().type==NODE_INPUT) {
+ for (Map<int, Node>::Element *E = shader[p_type].node_map.front(); E; E = E->next()) {
+ if (E->get().type == NODE_INPUT) {
ERR_EXPLAIN("Only one input node can be added to the graph.");
- ERR_FAIL_COND(E->get().type==NODE_INPUT);
+ ERR_FAIL_COND(E->get().type == NODE_INPUT);
}
}
}
- node.type=p_node_type;
- node.id=p_id;
+ node.type = p_node_type;
+ node.id = p_id;
- switch(p_node_type) {
- case NODE_INPUT: {} break; // all inputs (shader type dependent)
- case NODE_SCALAR_CONST: { node.param1=0;} break; //scalar constant
- case NODE_VEC_CONST: {node.param1=Vector3();} break; //vec3 constant
- case NODE_RGB_CONST: {node.param1=Color();} break; //rgb constant (shows a color picker instead)
- case NODE_XFORM_CONST: {node.param1=Transform();} break; // 4x4 matrix constant
- case NODE_TIME: {} break; // time in seconds
- case NODE_SCREEN_TEX: {Array arr; arr.push_back(0); arr.push_back(0); node.param2=arr;} break; // screen texture sampler (takes UV) (only usable in fragment shader)
- case NODE_SCALAR_OP: {node.param1=SCALAR_OP_ADD;} break; // scalar vs scalar op (mul: {} break; add: {} break; div: {} break; etc)
- case NODE_VEC_OP: {node.param1=VEC_OP_ADD;} break; // vec3 vs vec3 op (mul: {} break;ad: {} break;div: {} break;crossprod: {} break;etc)
- case NODE_VEC_SCALAR_OP: {node.param1=VEC_SCALAR_OP_MUL;} break; // vec3 vs scalar op (mul: {} break; add: {} break; div: {} break; etc)
- case NODE_RGB_OP: {node.param1=RGB_OP_SCREEN;} break; // vec3 vs vec3 rgb op (with scalar amount): {} break; like brighten: {} break; darken: {} break; burn: {} break; dodge: {} break; multiply: {} break; etc.
- case NODE_XFORM_MULT: {} break; // mat4 x mat4
- case NODE_XFORM_VEC_MULT: {} break; // mat4 x vec3 mult (with no-translation option)
- case NODE_XFORM_VEC_INV_MULT: {} break; // mat4 x vec3 inverse mult (with no-translation option)
- case NODE_SCALAR_FUNC: {node.param1=SCALAR_FUNC_SIN;} break; // scalar function (sin: {} break; cos: {} break; etc)
- case NODE_VEC_FUNC: {node.param1=VEC_FUNC_NORMALIZE;} break; // vector function (normalize: {} break; negate: {} break; reciprocal: {} break; rgb2hsv: {} break; hsv2rgb: {} break; etc: {} break; etc)
- case NODE_VEC_LEN: {} break; // vec3 length
- case NODE_DOT_PROD: {} break; // vec3 . vec3 (dot product -> scalar output)
- case NODE_VEC_TO_SCALAR: {} break; // 1 vec3 input: {} break; 3 scalar outputs
- case NODE_SCALAR_TO_VEC: {} break; // 3 scalar input: {} break; 1 vec3 output
- case NODE_VEC_TO_XFORM: {} break; // 3 scalar input: {} break; 1 vec3 output
- case NODE_XFORM_TO_VEC: {} break; // 3 scalar input: {} break; 1 vec3 output
- case NODE_SCALAR_INTERP: {} break; // scalar interpolation (with optional curve)
- case NODE_VEC_INTERP: {} break; // vec3 interpolation (with optional curve)
- case NODE_COLOR_RAMP: { node.param1=DVector<Color>(); node.param2=DVector<real_t>();} break; // vec3 interpolation (with optional curve)
- case NODE_CURVE_MAP: { node.param1=DVector<Vector2>();} break; // vec3 interpolation (with optional curve)
- case NODE_SCALAR_INPUT: {node.param1=_find_unique_name("Scalar"); node.param2=0;} break; // scalar uniform (assignable in material)
- case NODE_VEC_INPUT: {node.param1=_find_unique_name("Vec3");node.param2=Vector3();} break; // vec3 uniform (assignable in material)
- case NODE_RGB_INPUT: {node.param1=_find_unique_name("Color");node.param2=Color();} break; // color uniform (assignable in material)
- case NODE_XFORM_INPUT: {node.param1=_find_unique_name("XForm"); node.param2=Transform();} break; // mat4 uniform (assignable in material)
- case NODE_TEXTURE_INPUT: {node.param1=_find_unique_name("Tex"); } break; // texture input (assignable in material)
- case NODE_CUBEMAP_INPUT: {node.param1=_find_unique_name("Cube"); } break; // cubemap input (assignable in material)
- case NODE_DEFAULT_TEXTURE: {}; break;
- case NODE_OUTPUT: {} break; // output (shader type dependent)
- case NODE_COMMENT: {} break; // comment
- case NODE_TYPE_MAX: {};
+ switch (p_node_type) {
+ case NODE_INPUT: {
+ } break; // all inputs (shader type dependent)
+ case NODE_SCALAR_CONST: {
+ node.param1 = 0;
+ } break; //scalar constant
+ case NODE_VEC_CONST: {
+ node.param1 = Vector3();
+ } break; //vec3 constant
+ case NODE_RGB_CONST: {
+ node.param1 = Color();
+ } break; //rgb constant (shows a color picker instead)
+ case NODE_XFORM_CONST: {
+ node.param1 = Transform();
+ } break; // 4x4 matrix constant
+ case NODE_TIME: {
+ } break; // time in seconds
+ case NODE_SCREEN_TEX: {
+ Array arr;
+ arr.push_back(0);
+ arr.push_back(0);
+ node.param2 = arr;
+ } break; // screen texture sampler (takes UV) (only usable in fragment shader)
+ case NODE_SCALAR_OP: {
+ node.param1 = SCALAR_OP_ADD;
+ } break; // scalar vs scalar op (mul: {} break; add: {} break; div: {} break; etc)
+ case NODE_VEC_OP: {
+ node.param1 = VEC_OP_ADD;
+ } break; // vec3 vs vec3 op (mul: {} break;ad: {} break;div: {} break;crossprod: {} break;etc)
+ case NODE_VEC_SCALAR_OP: {
+ node.param1 = VEC_SCALAR_OP_MUL;
+ } break; // vec3 vs scalar op (mul: {} break; add: {} break; div: {} break; etc)
+ case NODE_RGB_OP: {
+ node.param1 = RGB_OP_SCREEN;
+ } break; // vec3 vs vec3 rgb op (with scalar amount): {} break; like brighten: {} break; darken: {} break; burn: {} break; dodge: {} break; multiply: {} break; etc.
+ case NODE_XFORM_MULT: {
+ } break; // mat4 x mat4
+ case NODE_XFORM_VEC_MULT: {
+ } break; // mat4 x vec3 mult (with no-translation option)
+ case NODE_XFORM_VEC_INV_MULT: {
+ } break; // mat4 x vec3 inverse mult (with no-translation option)
+ case NODE_SCALAR_FUNC: {
+ node.param1 = SCALAR_FUNC_SIN;
+ } break; // scalar function (sin: {} break; cos: {} break; etc)
+ case NODE_VEC_FUNC: {
+ node.param1 = VEC_FUNC_NORMALIZE;
+ } break; // vector function (normalize: {} break; negate: {} break; reciprocal: {} break; rgb2hsv: {} break; hsv2rgb: {} break; etc: {} break; etc)
+ case NODE_VEC_LEN: {
+ } break; // vec3 length
+ case NODE_DOT_PROD: {
+ } break; // vec3 . vec3 (dot product -> scalar output)
+ case NODE_VEC_TO_SCALAR: {
+ } break; // 1 vec3 input: {} break; 3 scalar outputs
+ case NODE_SCALAR_TO_VEC: {
+ } break; // 3 scalar input: {} break; 1 vec3 output
+ case NODE_VEC_TO_XFORM: {
+ } break; // 3 scalar input: {} break; 1 vec3 output
+ case NODE_XFORM_TO_VEC: {
+ } break; // 3 scalar input: {} break; 1 vec3 output
+ case NODE_SCALAR_INTERP: {
+ } break; // scalar interpolation (with optional curve)
+ case NODE_VEC_INTERP: {
+ } break; // vec3 interpolation (with optional curve)
+ case NODE_COLOR_RAMP: {
+ node.param1 = DVector<Color>();
+ node.param2 = DVector<real_t>();
+ } break; // vec3 interpolation (with optional curve)
+ case NODE_CURVE_MAP: {
+ node.param1 = DVector<Vector2>();
+ } break; // vec3 interpolation (with optional curve)
+ case NODE_SCALAR_INPUT: {
+ node.param1 = _find_unique_name("Scalar");
+ node.param2 = 0;
+ } break; // scalar uniform (assignable in material)
+ case NODE_VEC_INPUT: {
+ node.param1 = _find_unique_name("Vec3");
+ node.param2 = Vector3();
+ } break; // vec3 uniform (assignable in material)
+ case NODE_RGB_INPUT: {
+ node.param1 = _find_unique_name("Color");
+ node.param2 = Color();
+ } break; // color uniform (assignable in material)
+ case NODE_XFORM_INPUT: {
+ node.param1 = _find_unique_name("XForm");
+ node.param2 = Transform();
+ } break; // mat4 uniform (assignable in material)
+ case NODE_TEXTURE_INPUT: {
+ node.param1 = _find_unique_name("Tex");
+ } break; // texture input (assignable in material)
+ case NODE_CUBEMAP_INPUT: {
+ node.param1 = _find_unique_name("Cube");
+ } break; // cubemap input (assignable in material)
+ case NODE_DEFAULT_TEXTURE: {
+ }; break;
+ case NODE_OUTPUT: {
+ } break; // output (shader type dependent)
+ case NODE_COMMENT: {
+ } break; // comment
+ case NODE_TYPE_MAX: {
+ };
}
- shader[p_type].node_map[p_id]=node;
+ shader[p_type].node_map[p_id] = node;
_request_update();
}
-void ShaderGraph::node_set_pos(ShaderType p_type,int p_id, const Vector2& p_pos) {
- ERR_FAIL_INDEX(p_type,3);
+void ShaderGraph::node_set_pos(ShaderType p_type, int p_id, const Vector2 &p_pos) {
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- shader[p_type].node_map[p_id].pos=p_pos;
+ shader[p_type].node_map[p_id].pos = p_pos;
_request_update();
-
}
-Vector2 ShaderGraph::node_get_pos(ShaderType p_type,int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Vector2());
+Vector2 ShaderGraph::node_get_pos(ShaderType p_type, int p_id) const {
+ ERR_FAIL_INDEX_V(p_type, 3, Vector2());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Vector2());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Vector2());
return shader[p_type].node_map[p_id].pos;
}
+void ShaderGraph::node_remove(ShaderType p_type, int p_id) {
-void ShaderGraph::node_remove(ShaderType p_type,int p_id) {
-
- ERR_FAIL_COND(p_id==0);
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_COND(p_id == 0);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
//erase connections associated with node
- for(Map<int,Node>::Element *E=shader[p_type].node_map.front();E;E=E->next()) {
- if (E->key()==p_id)
+ for (Map<int, Node>::Element *E = shader[p_type].node_map.front(); E; E = E->next()) {
+ if (E->key() == p_id)
continue; //no self
- for (Map<int,SourceSlot>::Element *F=E->get().connections.front();F;) {
- Map<int,SourceSlot>::Element *N=F->next();
+ for (Map<int, SourceSlot>::Element *F = E->get().connections.front(); F;) {
+ Map<int, SourceSlot>::Element *N = F->next();
- if (F->get().id==p_id) {
+ if (F->get().id == p_id) {
E->get().connections.erase(F);
}
- F=N;
+ F = N;
}
}
shader[p_type].node_map.erase(p_id);
_request_update();
-
}
+void ShaderGraph::get_node_list(ShaderType p_type, List<int> *p_node_list) const {
+ ERR_FAIL_INDEX(p_type, 3);
-void ShaderGraph::get_node_list(ShaderType p_type,List<int> *p_node_list) const {
+ Map<int, Node>::Element *E = shader[p_type].node_map.front();
- ERR_FAIL_INDEX(p_type,3);
-
- Map<int,Node>::Element *E = shader[p_type].node_map.front();
-
- while(E) {
+ while (E) {
p_node_list->push_back(E->key());
- E=E->next();
+ E = E->next();
}
}
+ShaderGraph::NodeType ShaderGraph::node_get_type(ShaderType p_type, int p_id) const {
-ShaderGraph::NodeType ShaderGraph::node_get_type(ShaderType p_type,int p_id) const {
-
- ERR_FAIL_INDEX_V(p_type,3,NODE_TYPE_MAX);
+ ERR_FAIL_INDEX_V(p_type, 3, NODE_TYPE_MAX);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),NODE_TYPE_MAX);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), NODE_TYPE_MAX);
return shader[p_type].node_map[p_id].type;
}
+Error ShaderGraph::connect_node(ShaderType p_type, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot) {
+ ERR_FAIL_INDEX_V(p_type, 3, ERR_INVALID_PARAMETER);
-Error ShaderGraph::connect_node(ShaderType p_type,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) {
- ERR_FAIL_INDEX_V(p_type,3,ERR_INVALID_PARAMETER);
-
- ERR_FAIL_COND_V(p_src_id==p_dst_id, ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_src_id == p_dst_id, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_src_id), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_dst_id), ERR_INVALID_PARAMETER);
- NodeType type_src=shader[p_type].node_map[p_src_id].type;
- NodeType type_dst=shader[p_type].node_map[p_dst_id].type;
- ERR_FAIL_INDEX_V( p_src_slot, get_node_output_slot_count(get_mode(),p_type,type_src), ERR_INVALID_PARAMETER );
- ERR_FAIL_INDEX_V( p_dst_slot, get_node_input_slot_count(get_mode(),p_type,type_dst), ERR_INVALID_PARAMETER );
- ERR_FAIL_COND_V(get_node_output_slot_type(get_mode(),p_type,type_src,p_src_slot) != get_node_input_slot_type(get_mode(),p_type,type_dst,p_dst_slot), ERR_INVALID_PARAMETER );
-
+ NodeType type_src = shader[p_type].node_map[p_src_id].type;
+ NodeType type_dst = shader[p_type].node_map[p_dst_id].type;
+ ERR_FAIL_INDEX_V(p_src_slot, get_node_output_slot_count(get_mode(), p_type, type_src), ERR_INVALID_PARAMETER);
+ ERR_FAIL_INDEX_V(p_dst_slot, get_node_input_slot_count(get_mode(), p_type, type_dst), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(get_node_output_slot_type(get_mode(), p_type, type_src, p_src_slot) != get_node_input_slot_type(get_mode(), p_type, type_dst, p_dst_slot), ERR_INVALID_PARAMETER);
SourceSlot ts;
- ts.id=p_src_id;
- ts.slot=p_src_slot;
- shader[p_type].node_map[p_dst_id].connections[p_dst_slot]=ts;
+ ts.id = p_src_id;
+ ts.slot = p_src_slot;
+ shader[p_type].node_map[p_dst_id].connections[p_dst_slot] = ts;
_request_update();
return OK;
}
-bool ShaderGraph::is_node_connected(ShaderType p_type,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) const {
+bool ShaderGraph::is_node_connected(ShaderType p_type, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot) const {
- ERR_FAIL_INDEX_V(p_type,3,false);
+ ERR_FAIL_INDEX_V(p_type, 3, false);
SourceSlot ts;
- ts.id=p_src_id;
- ts.slot=p_src_slot;
+ ts.id = p_src_id;
+ ts.slot = p_src_slot;
return shader[p_type].node_map.has(p_dst_id) && shader[p_type].node_map[p_dst_id].connections.has(p_dst_slot) &&
- shader[p_type].node_map[p_dst_id].connections[p_dst_slot]==ts;
+ shader[p_type].node_map[p_dst_id].connections[p_dst_slot] == ts;
}
-void ShaderGraph::disconnect_node(ShaderType p_type,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) {
- ERR_FAIL_INDEX(p_type,3);
+void ShaderGraph::disconnect_node(ShaderType p_type, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot) {
+ ERR_FAIL_INDEX(p_type, 3);
SourceSlot ts;
- ts.id=p_src_id;
- ts.slot=p_src_slot;
+ ts.id = p_src_id;
+ ts.slot = p_src_slot;
if (shader[p_type].node_map.has(p_dst_id) && shader[p_type].node_map[p_dst_id].connections.has(p_dst_slot) &&
- shader[p_type].node_map[p_dst_id].connections[p_dst_slot]==ts) {
+ shader[p_type].node_map[p_dst_id].connections[p_dst_slot] == ts) {
shader[p_type].node_map[p_dst_id].connections.erase(p_dst_slot);
-
}
_request_update();
-
}
-void ShaderGraph::get_node_connections(ShaderType p_type,List<Connection> *p_connections) const {
+void ShaderGraph::get_node_connections(ShaderType p_type, List<Connection> *p_connections) const {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
- for(const Map<int,Node>::Element *E=shader[p_type].node_map.front();E;E=E->next()) {
- for (const Map<int,SourceSlot>::Element *F=E->get().connections.front();F;F=F->next()) {
+ for (const Map<int, Node>::Element *E = shader[p_type].node_map.front(); E; E = E->next()) {
+ for (const Map<int, SourceSlot>::Element *F = E->get().connections.front(); F; F = F->next()) {
Connection c;
- c.dst_id=E->key();
- c.dst_slot=F->key();
- c.src_id=F->get().id;
- c.src_slot=F->get().slot;
+ c.dst_id = E->key();
+ c.dst_slot = F->key();
+ c.src_id = F->get().id;
+ c.src_slot = F->get().slot;
p_connections->push_back(c);
}
}
}
-bool ShaderGraph::is_slot_connected(ShaderGraph::ShaderType p_type, int p_dst_id, int slot_id)
-{
- for(const Map<int,Node>::Element *E=shader[p_type].node_map.front();E;E=E->next()) {
- for (const Map<int,SourceSlot>::Element *F=E->get().connections.front();F;F=F->next()) {
+bool ShaderGraph::is_slot_connected(ShaderGraph::ShaderType p_type, int p_dst_id, int slot_id) {
+ for (const Map<int, Node>::Element *E = shader[p_type].node_map.front(); E; E = E->next()) {
+ for (const Map<int, SourceSlot>::Element *F = E->get().connections.front(); F; F = F->next()) {
- if (p_dst_id == E->key() && slot_id==F->key())
+ if (p_dst_id == E->key() && slot_id == F->key())
return true;
}
}
return false;
}
-
void ShaderGraph::clear(ShaderType p_type) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
shader[p_type].node_map.clear();
Node out;
- out.pos=Vector2(300,300);
- out.type=NODE_OUTPUT;
- shader[p_type].node_map.insert(0,out);
+ out.pos = Vector2(300, 300);
+ out.type = NODE_OUTPUT;
+ shader[p_type].node_map.insert(0, out);
_request_update();
-
}
+void ShaderGraph::scalar_const_node_set_value(ShaderType p_type, int p_id, float p_value) {
-void ShaderGraph::scalar_const_node_set_value(ShaderType p_type,int p_id,float p_value) {
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_SCALAR_CONST);
- n.param1=p_value;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_SCALAR_CONST);
+ n.param1 = p_value;
_request_update();
-
}
-float ShaderGraph::scalar_const_node_get_value(ShaderType p_type,int p_id) const{
+float ShaderGraph::scalar_const_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,0);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),0);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_SCALAR_CONST,0);
+ ERR_FAIL_INDEX_V(p_type, 3, 0);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), 0);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_SCALAR_CONST, 0);
return n.param1;
}
-void ShaderGraph::vec_const_node_set_value(ShaderType p_type,int p_id,const Vector3& p_value){
+void ShaderGraph::vec_const_node_set_value(ShaderType p_type, int p_id, const Vector3 &p_value) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_VEC_CONST);
- n.param1=p_value;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_VEC_CONST);
+ n.param1 = p_value;
_request_update();
-
-
}
-Vector3 ShaderGraph::vec_const_node_get_value(ShaderType p_type,int p_id) const{
+Vector3 ShaderGraph::vec_const_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Vector3());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Vector3());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_VEC_CONST,Vector3());
+ ERR_FAIL_INDEX_V(p_type, 3, Vector3());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Vector3());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_VEC_CONST, Vector3());
return n.param1;
-
}
-void ShaderGraph::rgb_const_node_set_value(ShaderType p_type,int p_id,const Color& p_value){
+void ShaderGraph::rgb_const_node_set_value(ShaderType p_type, int p_id, const Color &p_value) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_RGB_CONST);
- n.param1=p_value;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_RGB_CONST);
+ n.param1 = p_value;
_request_update();
-
}
-Color ShaderGraph::rgb_const_node_get_value(ShaderType p_type,int p_id) const{
+Color ShaderGraph::rgb_const_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Color());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Color());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_RGB_CONST,Color());
+ ERR_FAIL_INDEX_V(p_type, 3, Color());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Color());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_RGB_CONST, Color());
return n.param1;
-
}
-void ShaderGraph::xform_const_node_set_value(ShaderType p_type,int p_id,const Transform& p_value){
+void ShaderGraph::xform_const_node_set_value(ShaderType p_type, int p_id, const Transform &p_value) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_XFORM_CONST);
- n.param1=p_value;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_XFORM_CONST);
+ n.param1 = p_value;
_request_update();
-
}
-Transform ShaderGraph::xform_const_node_get_value(ShaderType p_type,int p_id) const{
+Transform ShaderGraph::xform_const_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Transform());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Transform());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_XFORM_CONST,Transform());
+ ERR_FAIL_INDEX_V(p_type, 3, Transform());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Transform());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_XFORM_CONST, Transform());
return n.param1;
-
}
-void ShaderGraph::texture_node_set_filter_size(ShaderType p_type,int p_id,int p_size){
+void ShaderGraph::texture_node_set_filter_size(ShaderType p_type, int p_id, int p_size) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_TEXTURE_INPUT && n.type!=NODE_SCREEN_TEX);
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_TEXTURE_INPUT && n.type != NODE_SCREEN_TEX);
Array arr = n.param2;
- arr[0]=p_size;
- n.param2=arr;
+ arr[0] = p_size;
+ n.param2 = arr;
_request_update();
-
}
-int ShaderGraph::texture_node_get_filter_size(ShaderType p_type,int p_id) const{
+int ShaderGraph::texture_node_get_filter_size(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,0);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),0);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_TEXTURE_INPUT && n.type!=NODE_SCREEN_TEX,0);
+ ERR_FAIL_INDEX_V(p_type, 3, 0);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), 0);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_TEXTURE_INPUT && n.type != NODE_SCREEN_TEX, 0);
Array arr = n.param2;
return arr[0];
-
}
-void ShaderGraph::texture_node_set_filter_strength(ShaderType p_type,float p_id,float p_strength){
+void ShaderGraph::texture_node_set_filter_strength(ShaderType p_type, float p_id, float p_strength) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_TEXTURE_INPUT && n.type!=NODE_SCREEN_TEX);
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_TEXTURE_INPUT && n.type != NODE_SCREEN_TEX);
Array arr = n.param2;
- arr[1]=p_strength;
- n.param2=arr;
+ arr[1] = p_strength;
+ n.param2 = arr;
_request_update();
-
}
-float ShaderGraph::texture_node_get_filter_strength(ShaderType p_type,float p_id) const{
+float ShaderGraph::texture_node_get_filter_strength(ShaderType p_type, float p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,0);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),0);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_TEXTURE_INPUT && n.type!=NODE_SCREEN_TEX,0);
+ ERR_FAIL_INDEX_V(p_type, 3, 0);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), 0);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_TEXTURE_INPUT && n.type != NODE_SCREEN_TEX, 0);
Array arr = n.param2;
return arr[1];
}
-void ShaderGraph::duplicate_nodes(ShaderType p_which, List<int> &p_nodes)
-{
+void ShaderGraph::duplicate_nodes(ShaderType p_which, List<int> &p_nodes) {
//Create new node IDs
- Map<int,int> duplicates = Map<int,int>();
- int i=1;
- for(List<int>::Element *E=p_nodes.front();E; E=E->next()) {
+ Map<int, int> duplicates = Map<int, int>();
+ int i = 1;
+ for (List<int>::Element *E = p_nodes.front(); E; E = E->next()) {
while (shader[p_which].node_map.has(i))
i++;
duplicates.insert(E->get(), i);
i++;
}
- for(List<int>::Element *E = p_nodes.front();E; E=E->next()) {
+ for (List<int>::Element *E = p_nodes.front(); E; E = E->next()) {
- const Node &n=shader[p_which].node_map[E->get()];
- Node nn=n;
- nn.id=duplicates.find(n.id)->get();
- nn.pos += Vector2(0,100);
- for (Map<int,SourceSlot>::Element *C=nn.connections.front();C;C=C->next()) {
- SourceSlot &c=C->get();
+ const Node &n = shader[p_which].node_map[E->get()];
+ Node nn = n;
+ nn.id = duplicates.find(n.id)->get();
+ nn.pos += Vector2(0, 100);
+ for (Map<int, SourceSlot>::Element *C = nn.connections.front(); C; C = C->next()) {
+ SourceSlot &c = C->get();
if (p_nodes.find(c.id))
- c.id=duplicates.find(c.id)->get();
+ c.id = duplicates.find(c.id)->get();
}
- shader[p_which].node_map[nn.id]=nn;
+ shader[p_which].node_map[nn.id] = nn;
}
_request_update();
}
-List<int> ShaderGraph::generate_ids(ShaderType p_type, int count)
-{
+List<int> ShaderGraph::generate_ids(ShaderType p_type, int count) {
List<int> ids = List<int>();
- int i=1;
+ int i = 1;
while (ids.size() < count) {
while (shader[p_type].node_map.has(i))
i++;
@@ -900,403 +921,360 @@ List<int> ShaderGraph::generate_ids(ShaderType p_type, int count)
return ids;
}
+void ShaderGraph::scalar_op_node_set_op(ShaderType p_type, float p_id, ScalarOp p_op) {
-void ShaderGraph::scalar_op_node_set_op(ShaderType p_type,float p_id,ScalarOp p_op){
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_SCALAR_OP);
- n.param1=p_op;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_SCALAR_OP);
+ n.param1 = p_op;
_request_update();
-
}
-ShaderGraph::ScalarOp ShaderGraph::scalar_op_node_get_op(ShaderType p_type,float p_id) const{
+ShaderGraph::ScalarOp ShaderGraph::scalar_op_node_get_op(ShaderType p_type, float p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,SCALAR_MAX_OP);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),SCALAR_MAX_OP);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_SCALAR_OP,SCALAR_MAX_OP);
+ ERR_FAIL_INDEX_V(p_type, 3, SCALAR_MAX_OP);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), SCALAR_MAX_OP);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_SCALAR_OP, SCALAR_MAX_OP);
int op = n.param1;
return ScalarOp(op);
-
}
+void ShaderGraph::vec_op_node_set_op(ShaderType p_type, float p_id, VecOp p_op) {
-void ShaderGraph::vec_op_node_set_op(ShaderType p_type,float p_id,VecOp p_op){
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_VEC_OP);
- n.param1=p_op;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_VEC_OP);
+ n.param1 = p_op;
_request_update();
-
}
-ShaderGraph::VecOp ShaderGraph::vec_op_node_get_op(ShaderType p_type,float p_id) const{
+ShaderGraph::VecOp ShaderGraph::vec_op_node_get_op(ShaderType p_type, float p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,VEC_MAX_OP);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),VEC_MAX_OP);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_VEC_OP,VEC_MAX_OP);
+ ERR_FAIL_INDEX_V(p_type, 3, VEC_MAX_OP);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), VEC_MAX_OP);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_VEC_OP, VEC_MAX_OP);
int op = n.param1;
return VecOp(op);
-
}
+void ShaderGraph::vec_scalar_op_node_set_op(ShaderType p_type, float p_id, VecScalarOp p_op) {
-void ShaderGraph::vec_scalar_op_node_set_op(ShaderType p_type,float p_id,VecScalarOp p_op){
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_VEC_SCALAR_OP);
- n.param1=p_op;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_VEC_SCALAR_OP);
+ n.param1 = p_op;
_request_update();
-
}
-ShaderGraph::VecScalarOp ShaderGraph::vec_scalar_op_node_get_op(ShaderType p_type,float p_id) const{
+ShaderGraph::VecScalarOp ShaderGraph::vec_scalar_op_node_get_op(ShaderType p_type, float p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,VEC_SCALAR_MAX_OP);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),VEC_SCALAR_MAX_OP);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_VEC_SCALAR_OP,VEC_SCALAR_MAX_OP);
+ ERR_FAIL_INDEX_V(p_type, 3, VEC_SCALAR_MAX_OP);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), VEC_SCALAR_MAX_OP);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_VEC_SCALAR_OP, VEC_SCALAR_MAX_OP);
int op = n.param1;
return VecScalarOp(op);
-
}
-void ShaderGraph::rgb_op_node_set_op(ShaderType p_type,float p_id,RGBOp p_op){
+void ShaderGraph::rgb_op_node_set_op(ShaderType p_type, float p_id, RGBOp p_op) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_RGB_OP);
- n.param1=p_op;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_RGB_OP);
+ n.param1 = p_op;
_request_update();
-
}
-ShaderGraph::RGBOp ShaderGraph::rgb_op_node_get_op(ShaderType p_type,float p_id) const{
+ShaderGraph::RGBOp ShaderGraph::rgb_op_node_get_op(ShaderType p_type, float p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,RGB_MAX_OP);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),RGB_MAX_OP);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_RGB_OP,RGB_MAX_OP);
+ ERR_FAIL_INDEX_V(p_type, 3, RGB_MAX_OP);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), RGB_MAX_OP);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_RGB_OP, RGB_MAX_OP);
int op = n.param1;
return RGBOp(op);
-
}
+void ShaderGraph::xform_vec_mult_node_set_no_translation(ShaderType p_type, int p_id, bool p_no_translation) {
-void ShaderGraph::xform_vec_mult_node_set_no_translation(ShaderType p_type,int p_id,bool p_no_translation){
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_XFORM_VEC_MULT && n.type!=NODE_XFORM_VEC_INV_MULT);
- n.param1=p_no_translation;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_XFORM_VEC_MULT && n.type != NODE_XFORM_VEC_INV_MULT);
+ n.param1 = p_no_translation;
_request_update();
-
}
-bool ShaderGraph::xform_vec_mult_node_get_no_translation(ShaderType p_type,int p_id) const{
+bool ShaderGraph::xform_vec_mult_node_get_no_translation(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,false);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),false);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_XFORM_VEC_MULT && n.type!=NODE_XFORM_VEC_INV_MULT,false);
+ ERR_FAIL_INDEX_V(p_type, 3, false);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), false);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_XFORM_VEC_MULT && n.type != NODE_XFORM_VEC_INV_MULT, false);
return n.param1;
-
}
-void ShaderGraph::scalar_func_node_set_function(ShaderType p_type,int p_id,ScalarFunc p_func){
+void ShaderGraph::scalar_func_node_set_function(ShaderType p_type, int p_id, ScalarFunc p_func) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_SCALAR_FUNC);
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_SCALAR_FUNC);
int func = p_func;
- ERR_FAIL_INDEX(func,SCALAR_MAX_FUNC);
- n.param1=func;
+ ERR_FAIL_INDEX(func, SCALAR_MAX_FUNC);
+ n.param1 = func;
_request_update();
-
}
-ShaderGraph::ScalarFunc ShaderGraph::scalar_func_node_get_function(ShaderType p_type,int p_id) const{
+ShaderGraph::ScalarFunc ShaderGraph::scalar_func_node_get_function(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,SCALAR_MAX_FUNC);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),SCALAR_MAX_FUNC);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_SCALAR_FUNC,SCALAR_MAX_FUNC);
+ ERR_FAIL_INDEX_V(p_type, 3, SCALAR_MAX_FUNC);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), SCALAR_MAX_FUNC);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_SCALAR_FUNC, SCALAR_MAX_FUNC);
int func = n.param1;
return ScalarFunc(func);
}
-void ShaderGraph::default_set_value(ShaderGraph::ShaderType p_which, int p_id, int p_param, const Variant &p_value)
-{
- ERR_FAIL_INDEX(p_which,3);
+void ShaderGraph::default_set_value(ShaderGraph::ShaderType p_which, int p_id, int p_param, const Variant &p_value) {
+ ERR_FAIL_INDEX(p_which, 3);
ERR_FAIL_COND(!shader[p_which].node_map.has(p_id));
- Node& n = shader[p_which].node_map[p_id];
- if(p_value.get_type()==Variant::NIL)
+ Node &n = shader[p_which].node_map[p_id];
+ if (p_value.get_type() == Variant::NIL)
n.defaults.erase(n.defaults.find(p_param));
else
- n.defaults[p_param]=p_value;
+ n.defaults[p_param] = p_value;
_request_update();
-
}
-Variant ShaderGraph::default_get_value(ShaderGraph::ShaderType p_which, int p_id, int p_param)
-{
- ERR_FAIL_INDEX_V(p_which,3,Variant());
- ERR_FAIL_COND_V(!shader[p_which].node_map.has(p_id),Variant());
- const Node& n = shader[p_which].node_map[p_id];
+Variant ShaderGraph::default_get_value(ShaderGraph::ShaderType p_which, int p_id, int p_param) {
+ ERR_FAIL_INDEX_V(p_which, 3, Variant());
+ ERR_FAIL_COND_V(!shader[p_which].node_map.has(p_id), Variant());
+ const Node &n = shader[p_which].node_map[p_id];
if (!n.defaults.has(p_param))
return Variant();
return n.defaults[p_param];
}
+void ShaderGraph::vec_func_node_set_function(ShaderType p_type, int p_id, VecFunc p_func) {
-
-void ShaderGraph::vec_func_node_set_function(ShaderType p_type,int p_id,VecFunc p_func){
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_VEC_FUNC);
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_VEC_FUNC);
int func = p_func;
- ERR_FAIL_INDEX(func,VEC_MAX_FUNC);
- n.param1=func;
+ ERR_FAIL_INDEX(func, VEC_MAX_FUNC);
+ n.param1 = func;
_request_update();
-
}
-ShaderGraph::VecFunc ShaderGraph::vec_func_node_get_function(ShaderType p_type, int p_id) const{
+ShaderGraph::VecFunc ShaderGraph::vec_func_node_get_function(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,VEC_MAX_FUNC);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),VEC_MAX_FUNC);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_VEC_FUNC,VEC_MAX_FUNC);
+ ERR_FAIL_INDEX_V(p_type, 3, VEC_MAX_FUNC);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), VEC_MAX_FUNC);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_VEC_FUNC, VEC_MAX_FUNC);
int func = n.param1;
return VecFunc(func);
}
-void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type,int p_id,const DVector<Color>& p_colors, const DVector<real_t>& p_offsets){
+void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type, int p_id, const DVector<Color> &p_colors, const DVector<real_t> &p_offsets) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- ERR_FAIL_COND(p_colors.size()!=p_offsets.size());
- Node& n = shader[p_type].node_map[p_id];
- n.param1=p_colors;
- n.param2=p_offsets;
+ ERR_FAIL_COND(p_colors.size() != p_offsets.size());
+ Node &n = shader[p_type].node_map[p_id];
+ n.param1 = p_colors;
+ n.param2 = p_offsets;
_request_update();
-
}
-DVector<Color> ShaderGraph::color_ramp_node_get_colors(ShaderType p_type,int p_id) const{
+DVector<Color> ShaderGraph::color_ramp_node_get_colors(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,DVector<Color>());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector<Color>());
- const Node& n = shader[p_type].node_map[p_id];
+ ERR_FAIL_INDEX_V(p_type, 3, DVector<Color>());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), DVector<Color>());
+ const Node &n = shader[p_type].node_map[p_id];
return n.param1;
-
-
}
-DVector<real_t> ShaderGraph::color_ramp_node_get_offsets(ShaderType p_type,int p_id) const{
+DVector<real_t> ShaderGraph::color_ramp_node_get_offsets(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,DVector<real_t>());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector<real_t>());
- const Node& n = shader[p_type].node_map[p_id];
+ ERR_FAIL_INDEX_V(p_type, 3, DVector<real_t>());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), DVector<real_t>());
+ const Node &n = shader[p_type].node_map[p_id];
return n.param2;
-
}
+void ShaderGraph::curve_map_node_set_points(ShaderType p_type, int p_id, const DVector<Vector2> &p_points) {
-void ShaderGraph::curve_map_node_set_points(ShaderType p_type,int p_id,const DVector<Vector2>& p_points) {
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- n.param1=p_points;
+ Node &n = shader[p_type].node_map[p_id];
+ n.param1 = p_points;
_request_update();
-
}
-DVector<Vector2> ShaderGraph::curve_map_node_get_points(ShaderType p_type,int p_id) const{
+DVector<Vector2> ShaderGraph::curve_map_node_get_points(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,DVector<Vector2>());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector<Vector2>());
- const Node& n = shader[p_type].node_map[p_id];
+ ERR_FAIL_INDEX_V(p_type, 3, DVector<Vector2>());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), DVector<Vector2>());
+ const Node &n = shader[p_type].node_map[p_id];
return n.param1;
-
}
+void ShaderGraph::input_node_set_name(ShaderType p_type, int p_id, const String &p_name) {
-
-void ShaderGraph::input_node_set_name(ShaderType p_type,int p_id,const String& p_name){
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
ERR_FAIL_COND(!p_name.is_valid_identifier());
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_SCALAR_INPUT && n.type!=NODE_VEC_INPUT && n.type==NODE_RGB_INPUT && n.type==NODE_XFORM_INPUT && n.type==NODE_TEXTURE_INPUT && n.type==NODE_CUBEMAP_INPUT);
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_SCALAR_INPUT && n.type != NODE_VEC_INPUT && n.type == NODE_RGB_INPUT && n.type == NODE_XFORM_INPUT && n.type == NODE_TEXTURE_INPUT && n.type == NODE_CUBEMAP_INPUT);
- n.param1="";
- n.param1=_find_unique_name(p_name);
+ n.param1 = "";
+ n.param1 = _find_unique_name(p_name);
_request_update();
-
}
-String ShaderGraph::input_node_get_name(ShaderType p_type,int p_id){
+String ShaderGraph::input_node_get_name(ShaderType p_type, int p_id) {
- ERR_FAIL_INDEX_V(p_type,3,String());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),String());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_SCALAR_INPUT && n.type!=NODE_VEC_INPUT && n.type==NODE_RGB_INPUT && n.type==NODE_XFORM_INPUT && n.type==NODE_TEXTURE_INPUT && n.type==NODE_CUBEMAP_INPUT,String());
+ ERR_FAIL_INDEX_V(p_type, 3, String());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), String());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_SCALAR_INPUT && n.type != NODE_VEC_INPUT && n.type == NODE_RGB_INPUT && n.type == NODE_XFORM_INPUT && n.type == NODE_TEXTURE_INPUT && n.type == NODE_CUBEMAP_INPUT, String());
return n.param1;
}
+void ShaderGraph::scalar_input_node_set_value(ShaderType p_type, int p_id, float p_value) {
-void ShaderGraph::scalar_input_node_set_value(ShaderType p_type,int p_id,float p_value) {
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_SCALAR_INPUT);
- n.param2=p_value;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_SCALAR_INPUT);
+ n.param2 = p_value;
_request_update();
-
}
-float ShaderGraph::scalar_input_node_get_value(ShaderType p_type,int p_id) const{
+float ShaderGraph::scalar_input_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,0);
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),0);
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_SCALAR_INPUT,0);
+ ERR_FAIL_INDEX_V(p_type, 3, 0);
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), 0);
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_SCALAR_INPUT, 0);
return n.param2;
}
-void ShaderGraph::vec_input_node_set_value(ShaderType p_type,int p_id,const Vector3& p_value){
+void ShaderGraph::vec_input_node_set_value(ShaderType p_type, int p_id, const Vector3 &p_value) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_VEC_INPUT);
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_VEC_INPUT);
- n.param2=p_value;
+ n.param2 = p_value;
_request_update();
-
}
-Vector3 ShaderGraph::vec_input_node_get_value(ShaderType p_type,int p_id) const{
+Vector3 ShaderGraph::vec_input_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Vector3());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Vector3());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_VEC_INPUT,Vector3());
+ ERR_FAIL_INDEX_V(p_type, 3, Vector3());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Vector3());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_VEC_INPUT, Vector3());
return n.param2;
}
-void ShaderGraph::rgb_input_node_set_value(ShaderType p_type,int p_id,const Color& p_value){
+void ShaderGraph::rgb_input_node_set_value(ShaderType p_type, int p_id, const Color &p_value) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_RGB_INPUT);
- n.param2=p_value;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_RGB_INPUT);
+ n.param2 = p_value;
_request_update();
-
}
-Color ShaderGraph::rgb_input_node_get_value(ShaderType p_type,int p_id) const{
+Color ShaderGraph::rgb_input_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Color());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Color());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_RGB_INPUT,Color());
+ ERR_FAIL_INDEX_V(p_type, 3, Color());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Color());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_RGB_INPUT, Color());
return n.param2;
}
-void ShaderGraph::xform_input_node_set_value(ShaderType p_type,int p_id,const Transform& p_value){
+void ShaderGraph::xform_input_node_set_value(ShaderType p_type, int p_id, const Transform &p_value) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_XFORM_INPUT);
- n.param2=p_value;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_XFORM_INPUT);
+ n.param2 = p_value;
_request_update();
-
}
-Transform ShaderGraph::xform_input_node_get_value(ShaderType p_type,int p_id) const{
+Transform ShaderGraph::xform_input_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Transform());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Transform());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_XFORM_INPUT,Transform());
+ ERR_FAIL_INDEX_V(p_type, 3, Transform());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Transform());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_XFORM_INPUT, Transform());
return n.param2;
}
+void ShaderGraph::texture_input_node_set_value(ShaderType p_type, int p_id, const Ref<Texture> &p_texture) {
-void ShaderGraph::texture_input_node_set_value(ShaderType p_type,int p_id,const Ref<Texture>& p_texture) {
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_TEXTURE_INPUT);
- n.param2=p_texture;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_TEXTURE_INPUT);
+ n.param2 = p_texture;
_request_update();
-
}
-Ref<Texture> ShaderGraph::texture_input_node_get_value(ShaderType p_type,int p_id) const{
+Ref<Texture> ShaderGraph::texture_input_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Ref<Texture>());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Ref<Texture>());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_TEXTURE_INPUT,Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_type, 3, Ref<Texture>());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Ref<Texture>());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_TEXTURE_INPUT, Ref<Texture>());
return n.param2;
}
-void ShaderGraph::cubemap_input_node_set_value(ShaderType p_type,int p_id,const Ref<CubeMap>& p_cubemap){
+void ShaderGraph::cubemap_input_node_set_value(ShaderType p_type, int p_id, const Ref<CubeMap> &p_cubemap) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_CUBEMAP_INPUT);
- n.param2=p_cubemap;
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_CUBEMAP_INPUT);
+ n.param2 = p_cubemap;
_request_update();
-
}
-Ref<CubeMap> ShaderGraph::cubemap_input_node_get_value(ShaderType p_type,int p_id) const{
+Ref<CubeMap> ShaderGraph::cubemap_input_node_get_value(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Ref<CubeMap>());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Ref<CubeMap>());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_CUBEMAP_INPUT,Ref<CubeMap>());
+ ERR_FAIL_INDEX_V(p_type, 3, Ref<CubeMap>());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Ref<CubeMap>());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_CUBEMAP_INPUT, Ref<CubeMap>());
return n.param2;
-
}
+void ShaderGraph::comment_node_set_text(ShaderType p_type, int p_id, const String &p_comment) {
-void ShaderGraph::comment_node_set_text(ShaderType p_type,int p_id,const String& p_comment) {
-
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND(n.type!=NODE_COMMENT);
- n.param1=p_comment;
-
+ Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND(n.type != NODE_COMMENT);
+ n.param1 = p_comment;
}
-String ShaderGraph::comment_node_get_text(ShaderType p_type,int p_id) const{
+String ShaderGraph::comment_node_get_text(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,String());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),String());
- const Node& n = shader[p_type].node_map[p_id];
- ERR_FAIL_COND_V(n.type!=NODE_COMMENT,String());
+ ERR_FAIL_INDEX_V(p_type, 3, String());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), String());
+ const Node &n = shader[p_type].node_map[p_id];
+ ERR_FAIL_COND_V(n.type != NODE_COMMENT, String());
return n.param1;
-
}
void ShaderGraph::_request_update() {
@@ -1304,68 +1282,67 @@ void ShaderGraph::_request_update() {
if (_pending_update_shader)
return;
- _pending_update_shader=true;
+ _pending_update_shader = true;
call_deferred("_update_shader");
-
}
-Variant ShaderGraph::node_get_state(ShaderType p_type,int p_id) const {
+Variant ShaderGraph::node_get_state(ShaderType p_type, int p_id) const {
- ERR_FAIL_INDEX_V(p_type,3,Variant());
- ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),Variant());
- const Node& n = shader[p_type].node_map[p_id];
+ ERR_FAIL_INDEX_V(p_type, 3, Variant());
+ ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id), Variant());
+ const Node &n = shader[p_type].node_map[p_id];
Dictionary s;
- s["pos"]=n.pos;
- s["param1"]=n.param1;
- s["param2"]=n.param2;
+ s["pos"] = n.pos;
+ s["param1"] = n.param1;
+ s["param2"] = n.param2;
Array keys;
- for (Map<int,Variant>::Element *E=n.defaults.front();E;E=E->next()) {
+ for (Map<int, Variant>::Element *E = n.defaults.front(); E; E = E->next()) {
keys.append(E->key());
- s[E->key()]=E->get();
+ s[E->key()] = E->get();
}
- s["default_keys"]=keys;
+ s["default_keys"] = keys;
return s;
-
}
-void ShaderGraph::node_set_state(ShaderType p_type,int p_id,const Variant& p_state) {
+void ShaderGraph::node_set_state(ShaderType p_type, int p_id, const Variant &p_state) {
- ERR_FAIL_INDEX(p_type,3);
+ ERR_FAIL_INDEX(p_type, 3);
ERR_FAIL_COND(!shader[p_type].node_map.has(p_id));
- Node& n = shader[p_type].node_map[p_id];
+ Node &n = shader[p_type].node_map[p_id];
Dictionary d = p_state;
ERR_FAIL_COND(!d.has("pos"));
ERR_FAIL_COND(!d.has("param1"));
ERR_FAIL_COND(!d.has("param2"));
ERR_FAIL_COND(!d.has("default_keys"));
- n.pos=d["pos"];
- n.param1=d["param1"];
- n.param2=d["param2"];
+ n.pos = d["pos"];
+ n.param1 = d["param1"];
+ n.param2 = d["param2"];
Array keys = d["default_keys"];
- for(int i=0;i<keys.size();i++) {
- n.defaults[keys[i]]=d[keys[i]];
+ for (int i = 0; i < keys.size(); i++) {
+ n.defaults[keys[i]] = d[keys[i]];
}
}
-ShaderGraph::ShaderGraph(Mode p_mode) : Shader(p_mode) {
+ShaderGraph::ShaderGraph(Mode p_mode)
+ : Shader(p_mode) {
//shader = VisualServer::get_singleton()->shader_create();
- _pending_update_shader=false;
+ _pending_update_shader = false;
Node input;
- input.id=1;
- input.pos=Vector2(50,40);
- input.type=NODE_INPUT;
+ input.id = 1;
+ input.pos = Vector2(50, 40);
+ input.type = NODE_INPUT;
Node output;
- output.id=0;
- output.pos=Vector2(350,40);
- output.type=NODE_OUTPUT;
+ output.id = 0;
+ output.pos = Vector2(350, 40);
+ output.type = NODE_OUTPUT;
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
- shader[i].node_map.insert(0,output);
- shader[i].node_map.insert(1,input);
+ shader[i].node_map.insert(0, output);
+ shader[i].node_map.insert(1, input);
}
}
@@ -1374,214 +1351,210 @@ ShaderGraph::~ShaderGraph() {
//VisualServer::get_singleton()->free(shader);
}
-
-const ShaderGraph::InOutParamInfo ShaderGraph::inout_param_info[]={
+const ShaderGraph::InOutParamInfo ShaderGraph::inout_param_info[] = {
//material vertex in
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Vertex","SRC_VERTEX","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Normal","SRC_NORMAL","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Tangent","SRC_TANGENT","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"BinormalF","SRC_BINORMALF","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Color","SRC_COLOR","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Alpha","SRC_ALPHA","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"UV","SRC_UV","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"UV2","SRC_UV2","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"WorldMatrix","WORLD_MATRIX","",SLOT_TYPE_XFORM,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"InvCameraMatrix","INV_CAMERA_MATRIX","",SLOT_TYPE_XFORM,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"ProjectionMatrix","PROJECTION_MATRIX","",SLOT_TYPE_XFORM,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"ModelviewMatrix","MODELVIEW_MATRIX","",SLOT_TYPE_XFORM,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"InstanceID","INSTANCE_ID","",SLOT_TYPE_SCALAR,SLOT_IN},
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Vertex", "SRC_VERTEX", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Normal", "SRC_NORMAL", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Tangent", "SRC_TANGENT", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "BinormalF", "SRC_BINORMALF", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Color", "SRC_COLOR", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Alpha", "SRC_ALPHA", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "UV", "SRC_UV", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "UV2", "SRC_UV2", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "WorldMatrix", "WORLD_MATRIX", "", SLOT_TYPE_XFORM, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "InvCameraMatrix", "INV_CAMERA_MATRIX", "", SLOT_TYPE_XFORM, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "ProjectionMatrix", "PROJECTION_MATRIX", "", SLOT_TYPE_XFORM, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "ModelviewMatrix", "MODELVIEW_MATRIX", "", SLOT_TYPE_XFORM, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "InstanceID", "INSTANCE_ID", "", SLOT_TYPE_SCALAR, SLOT_IN },
//material vertex out
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Vertex","VERTEX","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Normal","NORMAL","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Tangent","TANGENT","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Binormal","BINORMAL","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"UV","UV",".xy",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"UV2","UV2",".xy",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Color","COLOR.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Alpha","COLOR.a","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Var1","VAR1.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"Var2","VAR2.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"SpecExp","SPEC_EXP","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_VERTEX,"PointSize","POINT_SIZE","",SLOT_TYPE_SCALAR,SLOT_OUT},
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Vertex", "VERTEX", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Normal", "NORMAL", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Tangent", "TANGENT", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Binormal", "BINORMAL", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "UV", "UV", ".xy", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "UV2", "UV2", ".xy", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Color", "COLOR.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Alpha", "COLOR.a", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Var1", "VAR1.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "Var2", "VAR2.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "SpecExp", "SPEC_EXP", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_VERTEX, "PointSize", "POINT_SIZE", "", SLOT_TYPE_SCALAR, SLOT_OUT },
//pixel vertex in
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Vertex","VERTEX","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Position","POSITION.xyz","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Normal","IN_NORMAL","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Tangent","TANGENT","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Binormal","BINORMAL","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"UV","vec3(UV,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"UV2","vec3(UV2,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"UVScreen","vec3(SCREEN_UV,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"PointCoord","POINT_COORD","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Color","COLOR.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Alpha","COLOR.a","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"InvCameraMatrix","INV_CAMERA_MATRIX","",SLOT_TYPE_XFORM,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Var1","VAR1.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Var2","VAR2.rgb","",SLOT_TYPE_VEC,SLOT_IN},
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Vertex", "VERTEX", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Position", "POSITION.xyz", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Normal", "IN_NORMAL", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Tangent", "TANGENT", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Binormal", "BINORMAL", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "UV", "vec3(UV,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "UV2", "vec3(UV2,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "UVScreen", "vec3(SCREEN_UV,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "PointCoord", "POINT_COORD", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Color", "COLOR.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Alpha", "COLOR.a", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "InvCameraMatrix", "INV_CAMERA_MATRIX", "", SLOT_TYPE_XFORM, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Var1", "VAR1.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Var2", "VAR2.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
//pixel vertex out
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Diffuse","DIFFUSE_OUT","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"DiffuseAlpha","ALPHA_OUT","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Specular","SPECULAR","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"SpecularExp","SPEC_EXP","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Emission","EMISSION","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Glow","GLOW","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"ShadeParam","SHADE_PARAM","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Normal","NORMAL","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"NormalMap","NORMALMAP","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"NormalMapDepth","NORMALMAP_DEPTH","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,"Discard","DISCARD",">0.5",SLOT_TYPE_SCALAR,SLOT_OUT},
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Diffuse", "DIFFUSE_OUT", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "DiffuseAlpha", "ALPHA_OUT", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Specular", "SPECULAR", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "SpecularExp", "SPEC_EXP", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Emission", "EMISSION", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Glow", "GLOW", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "ShadeParam", "SHADE_PARAM", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Normal", "NORMAL", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "NormalMap", "NORMALMAP", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "NormalMapDepth", "NORMALMAP_DEPTH", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, "Discard", "DISCARD", ">0.5", SLOT_TYPE_SCALAR, SLOT_OUT },
//light in
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"Normal","NORMAL","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"LightDir","LIGHT_DIR","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"LightDiffuse","LIGHT_DIFFUSE","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"LightSpecular","LIGHT_SPECULAR","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"EyeVec","EYE_VEC","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"Diffuse","DIFFUSE","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"Specular","SPECULAR","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"SpecExp","SPECULAR_EXP","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"ShadeParam","SHADE_PARAM","",SLOT_TYPE_SCALAR,SLOT_IN},
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "Normal", "NORMAL", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "LightDir", "LIGHT_DIR", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "LightDiffuse", "LIGHT_DIFFUSE", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "LightSpecular", "LIGHT_SPECULAR", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "EyeVec", "EYE_VEC", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "Diffuse", "DIFFUSE", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "Specular", "SPECULAR", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "SpecExp", "SPECULAR_EXP", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "ShadeParam", "SHADE_PARAM", "", SLOT_TYPE_SCALAR, SLOT_IN },
//light out
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"Light","LIGHT","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_MATERIAL,SHADER_TYPE_LIGHT,"Shadow", "SHADOW", "",SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "Light", "LIGHT", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_MATERIAL, SHADER_TYPE_LIGHT, "Shadow", "SHADOW", "", SLOT_TYPE_VEC, SLOT_OUT },
//canvas item vertex in
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"Vertex","vec3(SRC_VERTEX,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"UV","SRC_UV","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"Color","SRC_COLOR.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"Alpha","SRC_COLOR.a","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"WorldMatrix","WORLD_MATRIX","",SLOT_TYPE_XFORM,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"ExtraMatrix","EXTRA_MATRIX","",SLOT_TYPE_XFORM,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"ProjectionMatrix","PROJECTION_MATRIX","",SLOT_TYPE_XFORM,SLOT_IN},
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "Vertex", "vec3(SRC_VERTEX,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "UV", "SRC_UV", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "Color", "SRC_COLOR.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "Alpha", "SRC_COLOR.a", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "WorldMatrix", "WORLD_MATRIX", "", SLOT_TYPE_XFORM, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "ExtraMatrix", "EXTRA_MATRIX", "", SLOT_TYPE_XFORM, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "ProjectionMatrix", "PROJECTION_MATRIX", "", SLOT_TYPE_XFORM, SLOT_IN },
//canvas item vertex out
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"Vertex","VERTEX",".xy",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"UV","UV",".xy",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"Color","COLOR.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"Alpha","COLOR.a","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"Var1","VAR1.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"Var2","VAR2.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_VERTEX,"PointSize","POINT_SIZE","",SLOT_TYPE_SCALAR,SLOT_OUT},
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "Vertex", "VERTEX", ".xy", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "UV", "UV", ".xy", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "Color", "COLOR.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "Alpha", "COLOR.a", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "Var1", "VAR1.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "Var2", "VAR2.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_VERTEX, "PointSize", "POINT_SIZE", "", SLOT_TYPE_SCALAR, SLOT_OUT },
//canvas item fragment in
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Color","SRC_COLOR.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Alpha","SRC_COLOR.a","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"UV","vec3(UV,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"UVScreen","vec3(SCREEN_UV,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"TexPixelSize","vec3(TEXTURE_PIXEL_SIZE,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Var1","VAR1.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Var2","VAR2.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"PointCoord","POINT_COORD","",SLOT_TYPE_VEC,SLOT_IN},
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "Color", "SRC_COLOR.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "Alpha", "SRC_COLOR.a", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "UV", "vec3(UV,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "UVScreen", "vec3(SCREEN_UV,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "TexPixelSize", "vec3(TEXTURE_PIXEL_SIZE,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "Var1", "VAR1.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "Var2", "VAR2.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "PointCoord", "POINT_COORD", "", SLOT_TYPE_VEC, SLOT_IN },
//canvas item fragment out
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Color","COLOR.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Alpha","COLOR.a","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"Normal","NORMAL","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"NormalMap","NORMALMAP","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_FRAGMENT,"NormalMapDepth","NORMALMAP_DEPTH","",SLOT_TYPE_SCALAR,SLOT_OUT},
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "Color", "COLOR.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "Alpha", "COLOR.a", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "Normal", "NORMAL", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "NormalMap", "NORMALMAP", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_FRAGMENT, "NormalMapDepth", "NORMALMAP_DEPTH", "", SLOT_TYPE_SCALAR, SLOT_OUT },
//canvas item light in
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Color","COLOR.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Alpha","COLOR.a","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Normal","NORMAL","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"UV","vec3(UV,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightColor","LIGHT_COLOR.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightAlpha","LIGHT_COLOR.a","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightHeight","LIGHT_HEIGHT","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"ShadowColor","LIGHT_SHADOW.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"ShadowAlpha","LIGHT_SHADOW.a","",SLOT_TYPE_SCALAR,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"TexPixelSize","vec3(TEXTURE_PIXEL_SIZE,0)","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Var1","VAR1.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"Var2","VAR2.rgb","",SLOT_TYPE_VEC,SLOT_IN},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"PointCoord","POINT_COORD","",SLOT_TYPE_VEC,SLOT_IN},
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "Color", "COLOR.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "Alpha", "COLOR.a", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "Normal", "NORMAL", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "UV", "vec3(UV,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "LightColor", "LIGHT_COLOR.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "LightAlpha", "LIGHT_COLOR.a", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "LightHeight", "LIGHT_HEIGHT", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "ShadowColor", "LIGHT_SHADOW.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "ShadowAlpha", "LIGHT_SHADOW.a", "", SLOT_TYPE_SCALAR, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "TexPixelSize", "vec3(TEXTURE_PIXEL_SIZE,0)", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "Var1", "VAR1.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "Var2", "VAR2.rgb", "", SLOT_TYPE_VEC, SLOT_IN },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "PointCoord", "POINT_COORD", "", SLOT_TYPE_VEC, SLOT_IN },
//canvas item light out
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightColor","LIGHT.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"LightAlpha","LIGHT.a","",SLOT_TYPE_SCALAR,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"ShadowColor","SHADOW.rgb","",SLOT_TYPE_VEC,SLOT_OUT},
- {MODE_CANVAS_ITEM,SHADER_TYPE_LIGHT,"ShadowAlpha","SHADOW.a","",SLOT_TYPE_SCALAR,SLOT_OUT},
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "LightColor", "LIGHT.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "LightAlpha", "LIGHT.a", "", SLOT_TYPE_SCALAR, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "ShadowColor", "SHADOW.rgb", "", SLOT_TYPE_VEC, SLOT_OUT },
+ { MODE_CANVAS_ITEM, SHADER_TYPE_LIGHT, "ShadowAlpha", "SHADOW.a", "", SLOT_TYPE_SCALAR, SLOT_OUT },
//end
- {MODE_MATERIAL,SHADER_TYPE_FRAGMENT,NULL,NULL,NULL,SLOT_TYPE_SCALAR,SLOT_OUT},
-
-
+ { MODE_MATERIAL, SHADER_TYPE_FRAGMENT, NULL, NULL, NULL, SLOT_TYPE_SCALAR, SLOT_OUT },
};
-void ShaderGraph::get_input_output_node_slot_info(Mode p_mode, ShaderType p_type, List<SlotInfo> *r_slots) {
+void ShaderGraph::get_input_output_node_slot_info(Mode p_mode, ShaderType p_type, List<SlotInfo> *r_slots) {
- const InOutParamInfo* iop = &inout_param_info[0];
- while(iop->name) {
- if (p_mode==iop->shader_mode && p_type==iop->shader_type) {
+ const InOutParamInfo *iop = &inout_param_info[0];
+ while (iop->name) {
+ if (p_mode == iop->shader_mode && p_type == iop->shader_type) {
SlotInfo si;
- si.dir=iop->dir;
- si.name=iop->name;
- si.type=iop->slot_type;
+ si.dir = iop->dir;
+ si.name = iop->name;
+ si.type = iop->slot_type;
r_slots->push_back(si);
}
iop++;
}
}
+const ShaderGraph::NodeSlotInfo ShaderGraph::node_slot_info[] = {
-const ShaderGraph::NodeSlotInfo ShaderGraph::node_slot_info[]= {
-
- {NODE_SCALAR_CONST,{SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_MAX}}, //scalar constant
- {NODE_VEC_CONST,{SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, //vec3 constant
- {NODE_RGB_CONST,{SLOT_MAX},{SLOT_TYPE_VEC,SLOT_TYPE_SCALAR,SLOT_MAX}}, //rgb constant (shows a color picker instead)
- {NODE_XFORM_CONST,{SLOT_MAX},{SLOT_TYPE_XFORM,SLOT_MAX}}, // 4x4 matrix constant
- {NODE_TIME,{SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_MAX}}, // time in seconds
- {NODE_SCREEN_TEX,{SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, // screen texture sampler (takes UV) (only usable in fragment shader)
- {NODE_SCALAR_OP,{SLOT_TYPE_SCALAR,SLOT_TYPE_SCALAR,SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_MAX}}, // scalar vs scalar op (mul,{SLOT_MAX},{SLOT_MAX}}, add,{SLOT_MAX},{SLOT_MAX}}, div,{SLOT_MAX},{SLOT_MAX}}, etc)
- {NODE_VEC_OP,{SLOT_TYPE_VEC,SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, // scalar vs scalar op (mul,{SLOT_MAX},{SLOT_MAX}}, add,{SLOT_MAX},{SLOT_MAX}}, div,{SLOT_MAX},{SLOT_MAX}}, etc)
- {NODE_VEC_SCALAR_OP,{SLOT_TYPE_VEC,SLOT_TYPE_SCALAR,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, // vec3 vs scalar op (mul,{SLOT_MAX},{SLOT_MAX}}, add,{SLOT_MAX},{SLOT_MAX}}, div,{SLOT_MAX},{SLOT_MAX}}, etc)
- {NODE_RGB_OP,{SLOT_TYPE_VEC,SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, // vec3 vs scalar op (mul,{SLOT_MAX},{SLOT_MAX}}, add,{SLOT_MAX},{SLOT_MAX}}, div,{SLOT_MAX},{SLOT_MAX}}, etc)
- {NODE_XFORM_MULT,{SLOT_TYPE_XFORM,SLOT_TYPE_XFORM,SLOT_MAX},{SLOT_TYPE_XFORM,SLOT_MAX}}, // mat4 x mat4
- {NODE_XFORM_VEC_MULT,{SLOT_TYPE_XFORM,SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, // mat4 x vec3 mult (with no-translation option)
- {NODE_XFORM_VEC_INV_MULT,{SLOT_TYPE_VEC,SLOT_TYPE_XFORM,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, // mat4 x vec3 inverse mult (with no-translation option)
- {NODE_SCALAR_FUNC,{SLOT_TYPE_SCALAR,SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_MAX}}, // scalar function (sin,{SLOT_MAX},{SLOT_MAX}}, cos,{SLOT_MAX},{SLOT_MAX}}, etc)
- {NODE_VEC_FUNC,{SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, // vector function (normalize,{SLOT_MAX},{SLOT_MAX}}, negate,{SLOT_MAX},{SLOT_MAX}}, reciprocal,{SLOT_MAX},{SLOT_MAX}}, rgb2hsv,{SLOT_MAX},{SLOT_MAX}}, hsv2rgb,{SLOT_MAX},{SLOT_MAX}}, etc,{SLOT_MAX},{SLOT_MAX}}, etc)
- {NODE_VEC_LEN,{SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_MAX}}, // vec3 length
- {NODE_DOT_PROD,{SLOT_TYPE_VEC,SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_MAX}}, // vec3 . vec3 (dot product -> scalar output)
- {NODE_VEC_TO_SCALAR,{SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_TYPE_SCALAR,SLOT_TYPE_SCALAR}}, // 1 vec3 input,{SLOT_MAX},{SLOT_MAX}}, 3 scalar outputs
- {NODE_SCALAR_TO_VEC,{SLOT_TYPE_SCALAR,SLOT_TYPE_SCALAR,SLOT_TYPE_SCALAR},{SLOT_TYPE_VEC,SLOT_MAX}}, // 3 scalar input,{SLOT_MAX},{SLOT_MAX}}, 1 vec3 output
- {NODE_SCALAR_INTERP,{SLOT_TYPE_SCALAR,SLOT_TYPE_SCALAR,SLOT_TYPE_SCALAR},{SLOT_TYPE_SCALAR,SLOT_MAX}}, // scalar interpolation (with optional curve)
- {NODE_VEC_INTERP,{SLOT_TYPE_VEC,SLOT_TYPE_VEC,SLOT_TYPE_SCALAR},{SLOT_TYPE_VEC,SLOT_MAX}}, // vec3 interpolation (with optional curve)
- {NODE_COLOR_RAMP,{SLOT_TYPE_SCALAR,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_TYPE_SCALAR,SLOT_MAX}}, // vec3 interpolation (with optional curve)
- {NODE_CURVE_MAP,{SLOT_TYPE_SCALAR,SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_MAX}}, // vec3 interpolation (with optional curve)
- {NODE_SCALAR_INPUT,{SLOT_MAX},{SLOT_TYPE_SCALAR,SLOT_MAX}}, // scalar uniform (assignable in material)
- {NODE_VEC_INPUT,{SLOT_MAX},{SLOT_TYPE_VEC,SLOT_MAX}}, // vec3 uniform (assignable in material)
- {NODE_RGB_INPUT,{SLOT_MAX},{SLOT_TYPE_VEC,SLOT_TYPE_SCALAR,SLOT_MAX}}, // color uniform (assignable in material)
- {NODE_XFORM_INPUT,{SLOT_MAX},{SLOT_TYPE_XFORM,SLOT_MAX}}, // mat4 uniform (assignable in material)
- {NODE_TEXTURE_INPUT,{SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_TYPE_SCALAR,SLOT_MAX}}, // texture input (assignable in material)
- {NODE_CUBEMAP_INPUT,{SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_TYPE_SCALAR,SLOT_MAX}}, // cubemap input (assignable in material)
- {NODE_DEFAULT_TEXTURE,{SLOT_TYPE_VEC,SLOT_MAX},{SLOT_TYPE_VEC,SLOT_TYPE_SCALAR,SLOT_MAX}}, // cubemap input (assignable in material)
- {NODE_COMMENT,{SLOT_MAX},{SLOT_MAX}}, // comment
- {NODE_TYPE_MAX,{SLOT_MAX},{SLOT_MAX}}
+ { NODE_SCALAR_CONST, { SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, //scalar constant
+ { NODE_VEC_CONST, { SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, //vec3 constant
+ { NODE_RGB_CONST, { SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_TYPE_SCALAR, SLOT_MAX } }, //rgb constant (shows a color picker instead)
+ { NODE_XFORM_CONST, { SLOT_MAX }, { SLOT_TYPE_XFORM, SLOT_MAX } }, // 4x4 matrix constant
+ { NODE_TIME, { SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, // time in seconds
+ { NODE_SCREEN_TEX, { SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, // screen texture sampler (takes UV) (only usable in fragment shader)
+ { NODE_SCALAR_OP, { SLOT_TYPE_SCALAR, SLOT_TYPE_SCALAR, SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, // scalar vs scalar op (mul,{SLOT_MAX},{SLOT_MAX}}, add,{SLOT_MAX},{SLOT_MAX}}, div,{SLOT_MAX},{SLOT_MAX}}, etc)
+ { NODE_VEC_OP, { SLOT_TYPE_VEC, SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, // scalar vs scalar op (mul,{SLOT_MAX},{SLOT_MAX}}, add,{SLOT_MAX},{SLOT_MAX}}, div,{SLOT_MAX},{SLOT_MAX}}, etc)
+ { NODE_VEC_SCALAR_OP, { SLOT_TYPE_VEC, SLOT_TYPE_SCALAR, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, // vec3 vs scalar op (mul,{SLOT_MAX},{SLOT_MAX}}, add,{SLOT_MAX},{SLOT_MAX}}, div,{SLOT_MAX},{SLOT_MAX}}, etc)
+ { NODE_RGB_OP, { SLOT_TYPE_VEC, SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, // vec3 vs scalar op (mul,{SLOT_MAX},{SLOT_MAX}}, add,{SLOT_MAX},{SLOT_MAX}}, div,{SLOT_MAX},{SLOT_MAX}}, etc)
+ { NODE_XFORM_MULT, { SLOT_TYPE_XFORM, SLOT_TYPE_XFORM, SLOT_MAX }, { SLOT_TYPE_XFORM, SLOT_MAX } }, // mat4 x mat4
+ { NODE_XFORM_VEC_MULT, { SLOT_TYPE_XFORM, SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, // mat4 x vec3 mult (with no-translation option)
+ { NODE_XFORM_VEC_INV_MULT, { SLOT_TYPE_VEC, SLOT_TYPE_XFORM, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, // mat4 x vec3 inverse mult (with no-translation option)
+ { NODE_SCALAR_FUNC, { SLOT_TYPE_SCALAR, SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, // scalar function (sin,{SLOT_MAX},{SLOT_MAX}}, cos,{SLOT_MAX},{SLOT_MAX}}, etc)
+ { NODE_VEC_FUNC, { SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, // vector function (normalize,{SLOT_MAX},{SLOT_MAX}}, negate,{SLOT_MAX},{SLOT_MAX}}, reciprocal,{SLOT_MAX},{SLOT_MAX}}, rgb2hsv,{SLOT_MAX},{SLOT_MAX}}, hsv2rgb,{SLOT_MAX},{SLOT_MAX}}, etc,{SLOT_MAX},{SLOT_MAX}}, etc)
+ { NODE_VEC_LEN, { SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, // vec3 length
+ { NODE_DOT_PROD, { SLOT_TYPE_VEC, SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, // vec3 . vec3 (dot product -> scalar output)
+ { NODE_VEC_TO_SCALAR, { SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_TYPE_SCALAR, SLOT_TYPE_SCALAR } }, // 1 vec3 input,{SLOT_MAX},{SLOT_MAX}}, 3 scalar outputs
+ { NODE_SCALAR_TO_VEC, { SLOT_TYPE_SCALAR, SLOT_TYPE_SCALAR, SLOT_TYPE_SCALAR }, { SLOT_TYPE_VEC, SLOT_MAX } }, // 3 scalar input,{SLOT_MAX},{SLOT_MAX}}, 1 vec3 output
+ { NODE_SCALAR_INTERP, { SLOT_TYPE_SCALAR, SLOT_TYPE_SCALAR, SLOT_TYPE_SCALAR }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, // scalar interpolation (with optional curve)
+ { NODE_VEC_INTERP, { SLOT_TYPE_VEC, SLOT_TYPE_VEC, SLOT_TYPE_SCALAR }, { SLOT_TYPE_VEC, SLOT_MAX } }, // vec3 interpolation (with optional curve)
+ { NODE_COLOR_RAMP, { SLOT_TYPE_SCALAR, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_TYPE_SCALAR, SLOT_MAX } }, // vec3 interpolation (with optional curve)
+ { NODE_CURVE_MAP, { SLOT_TYPE_SCALAR, SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, // vec3 interpolation (with optional curve)
+ { NODE_SCALAR_INPUT, { SLOT_MAX }, { SLOT_TYPE_SCALAR, SLOT_MAX } }, // scalar uniform (assignable in material)
+ { NODE_VEC_INPUT, { SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_MAX } }, // vec3 uniform (assignable in material)
+ { NODE_RGB_INPUT, { SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_TYPE_SCALAR, SLOT_MAX } }, // color uniform (assignable in material)
+ { NODE_XFORM_INPUT, { SLOT_MAX }, { SLOT_TYPE_XFORM, SLOT_MAX } }, // mat4 uniform (assignable in material)
+ { NODE_TEXTURE_INPUT, { SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_TYPE_SCALAR, SLOT_MAX } }, // texture input (assignable in material)
+ { NODE_CUBEMAP_INPUT, { SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_TYPE_SCALAR, SLOT_MAX } }, // cubemap input (assignable in material)
+ { NODE_DEFAULT_TEXTURE, { SLOT_TYPE_VEC, SLOT_MAX }, { SLOT_TYPE_VEC, SLOT_TYPE_SCALAR, SLOT_MAX } }, // cubemap input (assignable in material)
+ { NODE_COMMENT, { SLOT_MAX }, { SLOT_MAX } }, // comment
+ { NODE_TYPE_MAX, { SLOT_MAX }, { SLOT_MAX } }
};
-int ShaderGraph::get_node_input_slot_count(Mode p_mode, ShaderType p_shader_type,NodeType p_type) {
+int ShaderGraph::get_node_input_slot_count(Mode p_mode, ShaderType p_shader_type, NodeType p_type) {
- if (p_type==NODE_INPUT || p_type==NODE_OUTPUT) {
+ if (p_type == NODE_INPUT || p_type == NODE_OUTPUT) {
- const InOutParamInfo* iop = &inout_param_info[0];
- int pc=0;
- while(iop->name) {
- if (p_mode==iop->shader_mode && p_shader_type==iop->shader_type) {
+ const InOutParamInfo *iop = &inout_param_info[0];
+ int pc = 0;
+ while (iop->name) {
+ if (p_mode == iop->shader_mode && p_shader_type == iop->shader_type) {
- if (iop->dir==SLOT_OUT)
+ if (iop->dir == SLOT_OUT)
pc++;
}
iop++;
}
return pc;
- } else if (p_type==NODE_VEC_TO_XFORM){
+ } else if (p_type == NODE_VEC_TO_XFORM) {
return 4;
- } else if (p_type==NODE_XFORM_TO_VEC){
+ } else if (p_type == NODE_XFORM_TO_VEC) {
return 1;
} else {
- const NodeSlotInfo*nsi=&node_slot_info[0];
- while(nsi->type!=NODE_TYPE_MAX) {
+ const NodeSlotInfo *nsi = &node_slot_info[0];
+ while (nsi->type != NODE_TYPE_MAX) {
- if (nsi->type==p_type) {
- int pc=0;
- for(int i=0;i<NodeSlotInfo::MAX_INS;i++) {
- if (nsi->ins[i]==SLOT_MAX)
+ if (nsi->type == p_type) {
+ int pc = 0;
+ for (int i = 0; i < NodeSlotInfo::MAX_INS; i++) {
+ if (nsi->ins[i] == SLOT_MAX)
break;
pc++;
}
@@ -1592,38 +1565,37 @@ int ShaderGraph::get_node_input_slot_count(Mode p_mode, ShaderType p_shader_typ
}
return 0;
-
}
}
-int ShaderGraph::get_node_output_slot_count(Mode p_mode, ShaderType p_shader_type,NodeType p_type){
+int ShaderGraph::get_node_output_slot_count(Mode p_mode, ShaderType p_shader_type, NodeType p_type) {
- if (p_type==NODE_INPUT || p_type==NODE_OUTPUT) {
+ if (p_type == NODE_INPUT || p_type == NODE_OUTPUT) {
- const InOutParamInfo* iop = &inout_param_info[0];
- int pc=0;
- while(iop->name) {
- if (p_mode==iop->shader_mode && p_shader_type==iop->shader_type) {
+ const InOutParamInfo *iop = &inout_param_info[0];
+ int pc = 0;
+ while (iop->name) {
+ if (p_mode == iop->shader_mode && p_shader_type == iop->shader_type) {
- if (iop->dir==SLOT_IN)
+ if (iop->dir == SLOT_IN)
pc++;
}
iop++;
}
return pc;
- } else if (p_type==NODE_VEC_TO_XFORM){
+ } else if (p_type == NODE_VEC_TO_XFORM) {
return 1;
- } else if (p_type==NODE_XFORM_TO_VEC){
+ } else if (p_type == NODE_XFORM_TO_VEC) {
return 4;
} else {
- const NodeSlotInfo*nsi=&node_slot_info[0];
- while(nsi->type!=NODE_TYPE_MAX) {
+ const NodeSlotInfo *nsi = &node_slot_info[0];
+ while (nsi->type != NODE_TYPE_MAX) {
- if (nsi->type==p_type) {
- int pc=0;
- for(int i=0;i<NodeSlotInfo::MAX_OUTS;i++) {
- if (nsi->outs[i]==SLOT_MAX)
+ if (nsi->type == p_type) {
+ int pc = 0;
+ for (int i = 0; i < NodeSlotInfo::MAX_OUTS; i++) {
+ if (nsi->outs[i] == SLOT_MAX)
break;
pc++;
}
@@ -1634,20 +1606,19 @@ int ShaderGraph::get_node_output_slot_count(Mode p_mode, ShaderType p_shader_ty
}
return 0;
-
}
}
-ShaderGraph::SlotType ShaderGraph::get_node_input_slot_type(Mode p_mode, ShaderType p_shader_type,NodeType p_type,int p_idx){
+ShaderGraph::SlotType ShaderGraph::get_node_input_slot_type(Mode p_mode, ShaderType p_shader_type, NodeType p_type, int p_idx) {
- if (p_type==NODE_INPUT || p_type==NODE_OUTPUT) {
+ if (p_type == NODE_INPUT || p_type == NODE_OUTPUT) {
- const InOutParamInfo* iop = &inout_param_info[0];
- int pc=0;
- while(iop->name) {
- if (p_mode==iop->shader_mode && p_shader_type==iop->shader_type) {
+ const InOutParamInfo *iop = &inout_param_info[0];
+ int pc = 0;
+ while (iop->name) {
+ if (p_mode == iop->shader_mode && p_shader_type == iop->shader_type) {
- if (iop->dir==SLOT_OUT) {
- if (pc==p_idx)
+ if (iop->dir == SLOT_OUT) {
+ if (pc == p_idx)
return iop->slot_type;
pc++;
}
@@ -1655,21 +1626,21 @@ ShaderGraph::SlotType ShaderGraph::get_node_input_slot_type(Mode p_mode, ShaderT
iop++;
}
ERR_FAIL_V(SLOT_MAX);
- } else if (p_type==NODE_VEC_TO_XFORM){
+ } else if (p_type == NODE_VEC_TO_XFORM) {
return SLOT_TYPE_VEC;
- } else if (p_type==NODE_XFORM_TO_VEC){
+ } else if (p_type == NODE_XFORM_TO_VEC) {
return SLOT_TYPE_XFORM;
} else {
- const NodeSlotInfo*nsi=&node_slot_info[0];
- while(nsi->type!=NODE_TYPE_MAX) {
+ const NodeSlotInfo *nsi = &node_slot_info[0];
+ while (nsi->type != NODE_TYPE_MAX) {
- if (nsi->type==p_type) {
- for(int i=0;i<NodeSlotInfo::MAX_INS;i++) {
+ if (nsi->type == p_type) {
+ for (int i = 0; i < NodeSlotInfo::MAX_INS; i++) {
- if (nsi->ins[i]==SLOT_MAX)
+ if (nsi->ins[i] == SLOT_MAX)
break;
- if (i==p_idx)
+ if (i == p_idx)
return nsi->ins[i];
}
}
@@ -1678,20 +1649,19 @@ ShaderGraph::SlotType ShaderGraph::get_node_input_slot_type(Mode p_mode, ShaderT
}
ERR_FAIL_V(SLOT_MAX);
-
}
}
-ShaderGraph::SlotType ShaderGraph::get_node_output_slot_type(Mode p_mode, ShaderType p_shader_type,NodeType p_type,int p_idx){
+ShaderGraph::SlotType ShaderGraph::get_node_output_slot_type(Mode p_mode, ShaderType p_shader_type, NodeType p_type, int p_idx) {
- if (p_type==NODE_INPUT || p_type==NODE_OUTPUT) {
+ if (p_type == NODE_INPUT || p_type == NODE_OUTPUT) {
- const InOutParamInfo* iop = &inout_param_info[0];
- int pc=0;
- while(iop->name) {
- if (p_mode==iop->shader_mode && p_shader_type==iop->shader_type) {
+ const InOutParamInfo *iop = &inout_param_info[0];
+ int pc = 0;
+ while (iop->name) {
+ if (p_mode == iop->shader_mode && p_shader_type == iop->shader_type) {
- if (iop->dir==SLOT_IN) {
- if (pc==p_idx)
+ if (iop->dir == SLOT_IN) {
+ if (pc == p_idx)
return iop->slot_type;
pc++;
}
@@ -1699,20 +1669,20 @@ ShaderGraph::SlotType ShaderGraph::get_node_output_slot_type(Mode p_mode, Shader
iop++;
}
ERR_FAIL_V(SLOT_MAX);
- } else if (p_type==NODE_VEC_TO_XFORM){
+ } else if (p_type == NODE_VEC_TO_XFORM) {
return SLOT_TYPE_XFORM;
- } else if (p_type==NODE_XFORM_TO_VEC){
+ } else if (p_type == NODE_XFORM_TO_VEC) {
return SLOT_TYPE_VEC;
} else {
- const NodeSlotInfo*nsi=&node_slot_info[0];
- while(nsi->type!=NODE_TYPE_MAX) {
+ const NodeSlotInfo *nsi = &node_slot_info[0];
+ while (nsi->type != NODE_TYPE_MAX) {
- if (nsi->type==p_type) {
- for(int i=0;i<NodeSlotInfo::MAX_OUTS;i++) {
- if (nsi->outs[i]==SLOT_MAX)
+ if (nsi->type == p_type) {
+ for (int i = 0; i < NodeSlotInfo::MAX_OUTS; i++) {
+ if (nsi->outs[i] == SLOT_MAX)
break;
- if (i==p_idx)
+ if (i == p_idx)
return nsi->outs[i];
}
}
@@ -1724,153 +1694,144 @@ ShaderGraph::SlotType ShaderGraph::get_node_output_slot_type(Mode p_mode, Shader
}
}
-
-
-
-
void ShaderGraph::_update_shader() {
-
String code[3];
List<StringName> names;
get_default_texture_param_list(&names);
- for (List<StringName>::Element *E=names.front();E;E=E->next()) {
+ for (List<StringName>::Element *E = names.front(); E; E = E->next()) {
- set_default_texture_param(E->get(),Ref<Texture>());
+ set_default_texture_param(E->get(), Ref<Texture>());
}
+ for (int i = 0; i < 3; i++) {
- for(int i=0;i<3;i++) {
-
- int idx=0;
- for (Map<int,Node>::Element *E=shader[i].node_map.front();E;E=E->next()) {
+ int idx = 0;
+ for (Map<int, Node>::Element *E = shader[i].node_map.front(); E; E = E->next()) {
- E->get().sort_order=idx++;
+ E->get().sort_order = idx++;
}
//simple method for graph solving using bubblesort derived algorithm
- int iters=0;
- int iter_max=shader[i].node_map.size()*shader[i].node_map.size();
+ int iters = 0;
+ int iter_max = shader[i].node_map.size() * shader[i].node_map.size();
- while(true) {
- if (iters>iter_max)
+ while (true) {
+ if (iters > iter_max)
break;
- int swaps=0;
- for (Map<int,Node>::Element *E=shader[i].node_map.front();E;E=E->next()) {
+ int swaps = 0;
+ for (Map<int, Node>::Element *E = shader[i].node_map.front(); E; E = E->next()) {
- for(Map<int,SourceSlot>::Element *F=E->get().connections.front();F;F=F->next()) {
+ for (Map<int, SourceSlot>::Element *F = E->get().connections.front(); F; F = F->next()) {
//this is kinda slow, could be sped up
- Map<int,Node>::Element *G = shader[i].node_map.find(F->get().id);
+ Map<int, Node>::Element *G = shader[i].node_map.find(F->get().id);
ERR_FAIL_COND(!G);
if (G->get().sort_order > E->get().sort_order) {
- SWAP(G->get().sort_order,E->get().sort_order);
+ SWAP(G->get().sort_order, E->get().sort_order);
swaps++;
}
}
}
iters++;
- if (swaps==0) {
- iters=0;
+ if (swaps == 0) {
+ iters = 0;
break;
}
}
- if (iters>0) {
+ if (iters > 0) {
- shader[i].error=GRAPH_ERROR_CYCLIC;
+ shader[i].error = GRAPH_ERROR_CYCLIC;
continue;
}
- Vector<Node*> order;
+ Vector<Node *> order;
order.resize(shader[i].node_map.size());
- for (Map<int,Node>::Element *E=shader[i].node_map.front();E;E=E->next()) {
+ for (Map<int, Node>::Element *E = shader[i].node_map.front(); E; E = E->next()) {
- order[E->get().sort_order]=&E->get();
+ order[E->get().sort_order] = &E->get();
}
//generate code for the ordered graph
- bool failed=false;
+ bool failed = false;
- if (i==SHADER_TYPE_FRAGMENT && get_mode()==MODE_MATERIAL) {
- code[i]+="vec3 DIFFUSE_OUT=vec3(0,0,0);\n";
- code[i]+="float ALPHA_OUT=0;\n";
+ if (i == SHADER_TYPE_FRAGMENT && get_mode() == MODE_MATERIAL) {
+ code[i] += "vec3 DIFFUSE_OUT=vec3(0,0,0);\n";
+ code[i] += "float ALPHA_OUT=0;\n";
}
-
- Map<String,String> inputs_xlate;
- Map<String,String> input_names_xlate;
+ Map<String, String> inputs_xlate;
+ Map<String, String> input_names_xlate;
Set<String> inputs_used;
- for(int j=0;j<order.size();j++) {
+ for (int j = 0; j < order.size(); j++) {
- Node *n=order[j];
- if (n->type==NODE_INPUT) {
+ Node *n = order[j];
+ if (n->type == NODE_INPUT) {
- const InOutParamInfo* iop = &inout_param_info[0];
- int idx=0;
- while(iop->name) {
- if (get_mode()==iop->shader_mode && i==iop->shader_type && SLOT_IN==iop->dir) {
+ const InOutParamInfo *iop = &inout_param_info[0];
+ int idx = 0;
+ while (iop->name) {
+ if (get_mode() == iop->shader_mode && i == iop->shader_type && SLOT_IN == iop->dir) {
- const char *typestr[4]={"float","vec3","mat4","texture"};
+ const char *typestr[4] = { "float", "vec3", "mat4", "texture" };
- String vname=("nd"+itos(n->id)+"sl"+itos(idx));
- inputs_xlate[vname]=String(typestr[iop->slot_type])+" "+vname+"="+iop->variable+";\n";
- input_names_xlate[vname]=iop->variable;
+ String vname = ("nd" + itos(n->id) + "sl" + itos(idx));
+ inputs_xlate[vname] = String(typestr[iop->slot_type]) + " " + vname + "=" + iop->variable + ";\n";
+ input_names_xlate[vname] = iop->variable;
idx++;
}
iop++;
}
- } else if (n->type==NODE_OUTPUT) {
-
+ } else if (n->type == NODE_OUTPUT) {
- bool use_alpha=false;
- const InOutParamInfo* iop = &inout_param_info[0];
- int idx=0;
- while(iop->name) {
- if (get_mode()==iop->shader_mode && i==iop->shader_type && SLOT_OUT==iop->dir) {
+ bool use_alpha = false;
+ const InOutParamInfo *iop = &inout_param_info[0];
+ int idx = 0;
+ while (iop->name) {
+ if (get_mode() == iop->shader_mode && i == iop->shader_type && SLOT_OUT == iop->dir) {
if (n->connections.has(idx)) {
- String iname=("nd"+itos(n->connections[idx].id)+"sl"+itos(n->connections[idx].slot));
- if (node_get_type(ShaderType(i),n->connections[idx].id)==NODE_INPUT)
+ String iname = ("nd" + itos(n->connections[idx].id) + "sl" + itos(n->connections[idx].slot));
+ if (node_get_type(ShaderType(i), n->connections[idx].id) == NODE_INPUT)
inputs_used.insert(iname);
- code[i]+=String(iop->variable)+"="+iname+String(iop->postfix)+";\n";
- if (i==SHADER_TYPE_FRAGMENT && get_mode()==MODE_MATERIAL && String(iop->name)=="DiffuseAlpha")
- use_alpha=true;
+ code[i] += String(iop->variable) + "=" + iname + String(iop->postfix) + ";\n";
+ if (i == SHADER_TYPE_FRAGMENT && get_mode() == MODE_MATERIAL && String(iop->name) == "DiffuseAlpha")
+ use_alpha = true;
}
idx++;
}
iop++;
}
- if (i==SHADER_TYPE_FRAGMENT && get_mode()==MODE_MATERIAL) {
+ if (i == SHADER_TYPE_FRAGMENT && get_mode() == MODE_MATERIAL) {
if (use_alpha) {
- code[i]+="DIFFUSE_ALPHA=vec4(DIFFUSE_OUT,ALPHA_OUT);\n";
+ code[i] += "DIFFUSE_ALPHA=vec4(DIFFUSE_OUT,ALPHA_OUT);\n";
} else {
- code[i]+="DIFFUSE=DIFFUSE_OUT;\n";
+ code[i] += "DIFFUSE=DIFFUSE_OUT;\n";
}
}
} else {
Vector<String> inputs;
- int max = get_node_input_slot_count(get_mode(),ShaderType(i),n->type);
- for(int k=0;k<max;k++) {
+ int max = get_node_input_slot_count(get_mode(), ShaderType(i), n->type);
+ for (int k = 0; k < max; k++) {
String iname;
if (!n->connections.has(k)) {
- iname="nd"+itos(n->id)+"sl"+itos(k)+"def";
+ iname = "nd" + itos(n->id) + "sl" + itos(k) + "def";
} else {
- iname="nd"+itos(n->connections[k].id)+"sl"+itos(n->connections[k].slot);
- if (node_get_type(ShaderType(i),n->connections[k].id)==NODE_INPUT) {
+ iname = "nd" + itos(n->connections[k].id) + "sl" + itos(n->connections[k].slot);
+ if (node_get_type(ShaderType(i), n->connections[k].id) == NODE_INPUT) {
inputs_used.insert(iname);
}
-
}
inputs.push_back(iname);
}
@@ -1878,57 +1839,50 @@ void ShaderGraph::_update_shader() {
if (failed)
break;
- if (n->type==NODE_TEXTURE_INPUT || n->type==NODE_CUBEMAP_INPUT) {
-
- set_default_texture_param(n->param1,n->param2);
+ if (n->type == NODE_TEXTURE_INPUT || n->type == NODE_CUBEMAP_INPUT) {
+ set_default_texture_param(n->param1, n->param2);
}
- _add_node_code(ShaderType(i),n,inputs,code[i]);
+ _add_node_code(ShaderType(i), n, inputs, code[i]);
}
-
}
if (failed)
continue;
+ for (Set<String>::Element *E = inputs_used.front(); E; E = E->next()) {
- for(Set<String>::Element *E=inputs_used.front();E;E=E->next()) {
-
- ERR_CONTINUE( !inputs_xlate.has(E->get()));
- code[i]=inputs_xlate[E->get()]+code[i];
- String name=input_names_xlate[E->get()];
+ ERR_CONTINUE(!inputs_xlate.has(E->get()));
+ code[i] = inputs_xlate[E->get()] + code[i];
+ String name = input_names_xlate[E->get()];
- if (i==SHADER_TYPE_VERTEX && get_mode()==MODE_MATERIAL) {
- if (name==("SRC_COLOR"))
- code[i]="vec3 SRC_COLOR=COLOR.rgb;\n"+code[i];
- if (name==("SRC_ALPHA"))
- code[i]="float SRC_ALPHA=COLOR.a;\n"+code[i];
- if (name==("SRC_UV"))
- code[i]="vec3 SRC_UV=vec3(UV,0);\n"+code[i];
- if (name==("SRC_UV2"))
- code[i]="float SRC_UV2=vec3(UV2,0);\n"+code[i];
- } else if (i==SHADER_TYPE_FRAGMENT && get_mode()==MODE_MATERIAL) {
- if (name==("IN_NORMAL"))
- code[i]="vec3 IN_NORMAL=NORMAL;\n"+code[i];
- } else if (i==SHADER_TYPE_VERTEX && get_mode()==MODE_CANVAS_ITEM) {
- if (name==("SRC_COLOR"))
- code[i]="vec3 SRC_COLOR=COLOR.rgb;\n"+code[i];
- if (name==("SRC_UV"))
- code[i]="vec3 SRC_UV=vec3(UV,0);\n"+code[i];
+ if (i == SHADER_TYPE_VERTEX && get_mode() == MODE_MATERIAL) {
+ if (name == ("SRC_COLOR"))
+ code[i] = "vec3 SRC_COLOR=COLOR.rgb;\n" + code[i];
+ if (name == ("SRC_ALPHA"))
+ code[i] = "float SRC_ALPHA=COLOR.a;\n" + code[i];
+ if (name == ("SRC_UV"))
+ code[i] = "vec3 SRC_UV=vec3(UV,0);\n" + code[i];
+ if (name == ("SRC_UV2"))
+ code[i] = "float SRC_UV2=vec3(UV2,0);\n" + code[i];
+ } else if (i == SHADER_TYPE_FRAGMENT && get_mode() == MODE_MATERIAL) {
+ if (name == ("IN_NORMAL"))
+ code[i] = "vec3 IN_NORMAL=NORMAL;\n" + code[i];
+ } else if (i == SHADER_TYPE_VERTEX && get_mode() == MODE_CANVAS_ITEM) {
+ if (name == ("SRC_COLOR"))
+ code[i] = "vec3 SRC_COLOR=COLOR.rgb;\n" + code[i];
+ if (name == ("SRC_UV"))
+ code[i] = "vec3 SRC_UV=vec3(UV,0);\n" + code[i];
}
-
}
-
-
- shader[i].error=GRAPH_OK;
-
+ shader[i].error = GRAPH_OK;
}
- bool all_ok=true;
- for(int i=0;i<3;i++) {
- if (shader[i].error!=GRAPH_OK)
- all_ok=false;
+ bool all_ok = true;
+ for (int i = 0; i < 3; i++) {
+ if (shader[i].error != GRAPH_OK)
+ all_ok = false;
}
/*print_line("VERTEX: \n"+code[0]);
@@ -1936,15 +1890,15 @@ void ShaderGraph::_update_shader() {
print_line("LIGHT: \n"+code[2]);*/
if (all_ok) {
- set_code(code[0],code[1],code[2]);
+ set_code(code[0], code[1], code[2]);
}
//do shader here
- _pending_update_shader=false;
+ _pending_update_shader = false;
emit_signal(SceneStringNames::get_singleton()->updated);
}
-void ShaderGraph::_plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector2& p_c,const Vector2& p_d,uint8_t* p_heights,bool *p_useds) {
+void ShaderGraph::_plot_curve(const Vector2 &p_a, const Vector2 &p_b, const Vector2 &p_c, const Vector2 &p_d, uint8_t *p_heights, bool *p_useds) {
float geometry[4][4];
float tmp1[4][4];
@@ -1956,13 +1910,13 @@ void ShaderGraph::_plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector
int lastx, lasty;
int newx, newy;
int ntimes;
- int i,j;
+ int i, j;
- int xmax=255;
- int ymax=255;
+ int xmax = 255;
+ int ymax = 255;
/* construct the geometry matrix from the segment */
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < 4; i++) {
geometry[i][2] = 0;
geometry[i][3] = 0;
}
@@ -1985,43 +1939,50 @@ void ShaderGraph::_plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector
d3 = d * d * d;
/* construct a temporary matrix for determining the forward differencing deltas */
- tmp2[0][0] = 0; tmp2[0][1] = 0; tmp2[0][2] = 0; tmp2[0][3] = 1;
- tmp2[1][0] = d3; tmp2[1][1] = d2; tmp2[1][2] = d; tmp2[1][3] = 0;
- tmp2[2][0] = 6*d3; tmp2[2][1] = 2*d2; tmp2[2][2] = 0; tmp2[2][3] = 0;
- tmp2[3][0] = 6*d3; tmp2[3][1] = 0; tmp2[3][2] = 0; tmp2[3][3] = 0;
+ tmp2[0][0] = 0;
+ tmp2[0][1] = 0;
+ tmp2[0][2] = 0;
+ tmp2[0][3] = 1;
+ tmp2[1][0] = d3;
+ tmp2[1][1] = d2;
+ tmp2[1][2] = d;
+ tmp2[1][3] = 0;
+ tmp2[2][0] = 6 * d3;
+ tmp2[2][1] = 2 * d2;
+ tmp2[2][2] = 0;
+ tmp2[2][3] = 0;
+ tmp2[3][0] = 6 * d3;
+ tmp2[3][1] = 0;
+ tmp2[3][2] = 0;
+ tmp2[3][3] = 0;
/* compose the basis and geometry matrices */
static const float CR_basis[4][4] = {
- { -0.5, 1.5, -1.5, 0.5 },
- { 1.0, -2.5, 2.0, -0.5 },
- { -0.5, 0.0, 0.5, 0.0 },
- { 0.0, 1.0, 0.0, 0.0 },
+ { -0.5, 1.5, -1.5, 0.5 },
+ { 1.0, -2.5, 2.0, -0.5 },
+ { -0.5, 0.0, 0.5, 0.0 },
+ { 0.0, 1.0, 0.0, 0.0 },
};
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- {
- tmp1[i][j] = (CR_basis[i][0] * geometry[0][j] +
- CR_basis[i][1] * geometry[1][j] +
- CR_basis[i][2] * geometry[2][j] +
- CR_basis[i][3] * geometry[3][j]);
- }
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ tmp1[i][j] = (CR_basis[i][0] * geometry[0][j] +
+ CR_basis[i][1] * geometry[1][j] +
+ CR_basis[i][2] * geometry[2][j] +
+ CR_basis[i][3] * geometry[3][j]);
}
+ }
/* compose the above results to get the deltas matrix */
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- {
- deltas[i][j] = (tmp2[i][0] * tmp1[0][j] +
- tmp2[i][1] * tmp1[1][j] +
- tmp2[i][2] * tmp1[2][j] +
- tmp2[i][3] * tmp1[3][j]);
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ deltas[i][j] = (tmp2[i][0] * tmp1[0][j] +
+ tmp2[i][1] * tmp1[1][j] +
+ tmp2[i][2] * tmp1[2][j] +
+ tmp2[i][3] * tmp1[3][j]);
}
- }
-
+ }
/* extract the x deltas */
x = deltas[0][0];
@@ -2035,16 +1996,14 @@ void ShaderGraph::_plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector
dy2 = deltas[2][1];
dy3 = deltas[3][1];
-
- lastx = CLAMP (x, 0, xmax);
- lasty = CLAMP (y, 0, ymax);
+ lastx = CLAMP(x, 0, xmax);
+ lasty = CLAMP(y, 0, ymax);
p_heights[lastx] = lasty;
p_useds[lastx] = true;
/* loop over the curve */
- for (i = 0; i < ntimes; i++)
- {
+ for (i = 0; i < ntimes; i++) {
/* increment the x values */
x += dx;
dx += dx2;
@@ -2055,14 +2014,13 @@ void ShaderGraph::_plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector
dy += dy2;
dy2 += dy3;
- newx = CLAMP ((Math::round (x)), 0, xmax);
- newy = CLAMP ((Math::round (y)), 0, ymax);
+ newx = CLAMP((Math::round(x)), 0, xmax);
+ newy = CLAMP((Math::round(y)), 0, ymax);
/* if this point is different than the last one...then draw it */
- if ((lastx != newx) || (lasty != newy))
- {
- p_useds[newx]=true;
- p_heights[newx]=newy;
+ if ((lastx != newx) || (lasty != newy)) {
+ p_useds[newx] = true;
+ p_heights[newx] = newy;
}
lastx = newx;
@@ -2070,165 +2028,161 @@ void ShaderGraph::_plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector
}
}
+void ShaderGraph::_add_node_code(ShaderType p_type, Node *p_node, const Vector<String> &p_inputs, String &code) {
-void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<String>& p_inputs,String& code) {
-
-
- const char *typestr[4]={"float","vec3","mat4","texture"};
-#define OUTNAME(id,slot) (String(typestr[get_node_output_slot_type(get_mode(),p_type,p_node->type,slot)])+" "+("nd"+itos(id)+"sl"+itos(slot)))
-#define OUTVAR(id,slot) ("nd"+itos(id)+"sl"+itos(slot))
-#define DEF_VEC(slot)\
- if (p_inputs[slot].ends_with("def")){\
- Vector3 v = p_node->defaults[slot];\
- code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+v+");\n";\
+ const char *typestr[4] = { "float", "vec3", "mat4", "texture" };
+#define OUTNAME(id, slot) (String(typestr[get_node_output_slot_type(get_mode(), p_type, p_node->type, slot)]) + " " + ("nd" + itos(id) + "sl" + itos(slot)))
+#define OUTVAR(id, slot) ("nd" + itos(id) + "sl" + itos(slot))
+#define DEF_VEC(slot) \
+ if (p_inputs[slot].ends_with("def")) { \
+ Vector3 v = p_node->defaults[slot]; \
+ code += String(typestr[1]) + " " + p_inputs[slot] + "=vec3(" + v + ");\n"; \
}
-#define DEF_SCALAR(slot)\
- if (p_inputs[slot].ends_with("def")){\
- double v = p_node->defaults[slot];\
- code+=String(typestr[0])+" "+p_inputs[slot]+"="+rtos(v)+";\n";\
+#define DEF_SCALAR(slot) \
+ if (p_inputs[slot].ends_with("def")) { \
+ double v = p_node->defaults[slot]; \
+ code += String(typestr[0]) + " " + p_inputs[slot] + "=" + rtos(v) + ";\n"; \
}
-#define DEF_COLOR(slot)\
- if (p_inputs[slot].ends_with("def")){\
- Color col = p_node->defaults[slot];\
- code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+rtos(col.r)+","+rtos(col.g)+","+rtos(col.b)+");\n";\
+#define DEF_COLOR(slot) \
+ if (p_inputs[slot].ends_with("def")) { \
+ Color col = p_node->defaults[slot]; \
+ code += String(typestr[1]) + " " + p_inputs[slot] + "=vec3(" + rtos(col.r) + "," + rtos(col.g) + "," + rtos(col.b) + ");\n"; \
}
-#define DEF_MATRIX(slot) \
- if (p_inputs[slot].ends_with("def")){\
- Transform xf = p_node->defaults[slot]; \
- code+=String(typestr[2])+" "+p_inputs[slot]+"=mat4(\n";\
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(0).x)+","+rtos(xf.basis.get_axis(0).y)+","+rtos(xf.basis.get_axis(0).z)+"),0),\n";\
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(1).x)+","+rtos(xf.basis.get_axis(1).y)+","+rtos(xf.basis.get_axis(1).z)+"),0),\n";\
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(2).x)+","+rtos(xf.basis.get_axis(2).y)+","+rtos(xf.basis.get_axis(2).z)+"),0),\n";\
- code+="\tvec4(vec3("+rtos(xf.origin.x)+","+rtos(xf.origin.y)+","+rtos(xf.origin.z)+"),1)\n";\
- code+=");\n";\
+#define DEF_MATRIX(slot) \
+ if (p_inputs[slot].ends_with("def")) { \
+ Transform xf = p_node->defaults[slot]; \
+ code += String(typestr[2]) + " " + p_inputs[slot] + "=mat4(\n"; \
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(0).x) + "," + rtos(xf.basis.get_axis(0).y) + "," + rtos(xf.basis.get_axis(0).z) + "),0),\n"; \
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(1).x) + "," + rtos(xf.basis.get_axis(1).y) + "," + rtos(xf.basis.get_axis(1).z) + "),0),\n"; \
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(2).x) + "," + rtos(xf.basis.get_axis(2).y) + "," + rtos(xf.basis.get_axis(2).z) + "),0),\n"; \
+ code += "\tvec4(vec3(" + rtos(xf.origin.x) + "," + rtos(xf.origin.y) + "," + rtos(xf.origin.z) + "),1)\n"; \
+ code += ");\n"; \
}
- switch(p_node->type) {
+ switch (p_node->type) {
case NODE_INPUT: {
-
- }break;
+ } break;
case NODE_SCALAR_CONST: {
double scalar = p_node->param1;
- code+=OUTNAME(p_node->id,0)+"="+rtos(scalar)+";\n";
- }break;
+ code += OUTNAME(p_node->id, 0) + "=" + rtos(scalar) + ";\n";
+ } break;
case NODE_VEC_CONST: {
Vector3 vec = p_node->param1;
- code+=OUTNAME(p_node->id,0)+"=vec3("+rtos(vec.x)+","+rtos(vec.y)+","+rtos(vec.z)+");\n";
- }break;
+ code += OUTNAME(p_node->id, 0) + "=vec3(" + rtos(vec.x) + "," + rtos(vec.y) + "," + rtos(vec.z) + ");\n";
+ } break;
case NODE_RGB_CONST: {
Color col = p_node->param1;
- code+=OUTNAME(p_node->id,0)+"=vec3("+rtos(col.r)+","+rtos(col.g)+","+rtos(col.b)+");\n";
- code+=OUTNAME(p_node->id,1)+"="+rtos(col.a)+";\n";
- }break;
+ code += OUTNAME(p_node->id, 0) + "=vec3(" + rtos(col.r) + "," + rtos(col.g) + "," + rtos(col.b) + ");\n";
+ code += OUTNAME(p_node->id, 1) + "=" + rtos(col.a) + ";\n";
+ } break;
case NODE_XFORM_CONST: {
Transform xf = p_node->param1;
- code+=OUTNAME(p_node->id,0)+"=mat4(\n";
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(0).x)+","+rtos(xf.basis.get_axis(0).y)+","+rtos(xf.basis.get_axis(0).z)+"),0),\n";
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(1).x)+","+rtos(xf.basis.get_axis(1).y)+","+rtos(xf.basis.get_axis(1).z)+"),0),\n";
- code+="\tvec4(vec3("+rtos(xf.basis.get_axis(2).x)+","+rtos(xf.basis.get_axis(2).y)+","+rtos(xf.basis.get_axis(2).z)+"),0),\n";
- code+="\tvec4(vec3("+rtos(xf.origin.x)+","+rtos(xf.origin.y)+","+rtos(xf.origin.z)+"),1)\n";
- code+=");";
+ code += OUTNAME(p_node->id, 0) + "=mat4(\n";
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(0).x) + "," + rtos(xf.basis.get_axis(0).y) + "," + rtos(xf.basis.get_axis(0).z) + "),0),\n";
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(1).x) + "," + rtos(xf.basis.get_axis(1).y) + "," + rtos(xf.basis.get_axis(1).z) + "),0),\n";
+ code += "\tvec4(vec3(" + rtos(xf.basis.get_axis(2).x) + "," + rtos(xf.basis.get_axis(2).y) + "," + rtos(xf.basis.get_axis(2).z) + "),0),\n";
+ code += "\tvec4(vec3(" + rtos(xf.origin.x) + "," + rtos(xf.origin.y) + "," + rtos(xf.origin.z) + "),1)\n";
+ code += ");";
- }break;
+ } break;
case NODE_TIME: {
- code+=OUTNAME(p_node->id,0)+"=TIME;\n";
- }break;
+ code += OUTNAME(p_node->id, 0) + "=TIME;\n";
+ } break;
case NODE_SCREEN_TEX: {
DEF_VEC(0);
- code+=OUTNAME(p_node->id,0)+"=texscreen("+p_inputs[0]+".xy);\n";
- }break;
+ code += OUTNAME(p_node->id, 0) + "=texscreen(" + p_inputs[0] + ".xy);\n";
+ } break;
case NODE_SCALAR_OP: {
DEF_SCALAR(0);
DEF_SCALAR(1);
int op = p_node->param1;
String optxt;
- switch(op) {
-
- case SCALAR_OP_ADD: optxt = p_inputs[0]+"+"+p_inputs[1]+";"; break;
- case SCALAR_OP_SUB: optxt = p_inputs[0]+"-"+p_inputs[1]+";"; break;
- case SCALAR_OP_MUL: optxt = p_inputs[0]+"*"+p_inputs[1]+";"; break;
- case SCALAR_OP_DIV: optxt = p_inputs[0]+"/"+p_inputs[1]+";"; break;
- case SCALAR_OP_MOD: optxt = "mod("+p_inputs[0]+","+p_inputs[1]+");"; break;
- case SCALAR_OP_POW: optxt = "pow("+p_inputs[0]+","+p_inputs[1]+");"; break;
- case SCALAR_OP_MAX: optxt = "max("+p_inputs[0]+","+p_inputs[1]+");"; break;
- case SCALAR_OP_MIN: optxt = "min("+p_inputs[0]+","+p_inputs[1]+");"; break;
- case SCALAR_OP_ATAN2: optxt = "atan2("+p_inputs[0]+","+p_inputs[1]+");"; break;
+ switch (op) {
+ case SCALAR_OP_ADD: optxt = p_inputs[0] + "+" + p_inputs[1] + ";"; break;
+ case SCALAR_OP_SUB: optxt = p_inputs[0] + "-" + p_inputs[1] + ";"; break;
+ case SCALAR_OP_MUL: optxt = p_inputs[0] + "*" + p_inputs[1] + ";"; break;
+ case SCALAR_OP_DIV: optxt = p_inputs[0] + "/" + p_inputs[1] + ";"; break;
+ case SCALAR_OP_MOD: optxt = "mod(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
+ case SCALAR_OP_POW: optxt = "pow(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
+ case SCALAR_OP_MAX: optxt = "max(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
+ case SCALAR_OP_MIN: optxt = "min(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
+ case SCALAR_OP_ATAN2: optxt = "atan2(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
}
- code+=OUTNAME(p_node->id,0)+"="+optxt+"\n";
+ code += OUTNAME(p_node->id, 0) + "=" + optxt + "\n";
- }break;
+ } break;
case NODE_VEC_OP: {
DEF_VEC(0);
DEF_VEC(1);
int op = p_node->param1;
String optxt;
- switch(op) {
- case VEC_OP_ADD: optxt = p_inputs[0]+"+"+p_inputs[1]+";"; break;
- case VEC_OP_SUB: optxt = p_inputs[0]+"-"+p_inputs[1]+";"; break;
- case VEC_OP_MUL: optxt = p_inputs[0]+"*"+p_inputs[1]+";"; break;
- case VEC_OP_DIV: optxt = p_inputs[0]+"/"+p_inputs[1]+";"; break;
- case VEC_OP_MOD: optxt = "mod("+p_inputs[0]+","+p_inputs[1]+");"; break;
- case VEC_OP_POW: optxt = "pow("+p_inputs[0]+","+p_inputs[1]+");"; break;
- case VEC_OP_MAX: optxt = "max("+p_inputs[0]+","+p_inputs[1]+");"; break;
- case VEC_OP_MIN: optxt = "min("+p_inputs[0]+","+p_inputs[1]+");"; break;
- case VEC_OP_CROSS: optxt = "cross("+p_inputs[0]+","+p_inputs[1]+");"; break;
+ switch (op) {
+ case VEC_OP_ADD: optxt = p_inputs[0] + "+" + p_inputs[1] + ";"; break;
+ case VEC_OP_SUB: optxt = p_inputs[0] + "-" + p_inputs[1] + ";"; break;
+ case VEC_OP_MUL: optxt = p_inputs[0] + "*" + p_inputs[1] + ";"; break;
+ case VEC_OP_DIV: optxt = p_inputs[0] + "/" + p_inputs[1] + ";"; break;
+ case VEC_OP_MOD: optxt = "mod(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
+ case VEC_OP_POW: optxt = "pow(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
+ case VEC_OP_MAX: optxt = "max(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
+ case VEC_OP_MIN: optxt = "min(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
+ case VEC_OP_CROSS: optxt = "cross(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
}
- code+=OUTNAME(p_node->id,0)+"="+optxt+"\n";
+ code += OUTNAME(p_node->id, 0) + "=" + optxt + "\n";
- }break;
+ } break;
case NODE_VEC_SCALAR_OP: {
DEF_VEC(0);
DEF_SCALAR(1);
int op = p_node->param1;
String optxt;
- switch(op) {
- case VEC_SCALAR_OP_MUL: optxt = p_inputs[0]+"*"+p_inputs[1]+";"; break;
- case VEC_SCALAR_OP_DIV: optxt = p_inputs[0]+"/"+p_inputs[1]+";"; break;
- case VEC_SCALAR_OP_POW: optxt = "pow("+p_inputs[0]+","+p_inputs[1]+");"; break;
+ switch (op) {
+ case VEC_SCALAR_OP_MUL: optxt = p_inputs[0] + "*" + p_inputs[1] + ";"; break;
+ case VEC_SCALAR_OP_DIV: optxt = p_inputs[0] + "/" + p_inputs[1] + ";"; break;
+ case VEC_SCALAR_OP_POW: optxt = "pow(" + p_inputs[0] + "," + p_inputs[1] + ");"; break;
}
- code+=OUTNAME(p_node->id,0)+"="+optxt+"\n";
+ code += OUTNAME(p_node->id, 0) + "=" + optxt + "\n";
- }break;
+ } break;
case NODE_RGB_OP: {
DEF_COLOR(0);
DEF_COLOR(1);
int op = p_node->param1;
- static const char*axisn[3]={"x","y","z"};
- switch(op) {
+ static const char *axisn[3] = { "x", "y", "z" };
+ switch (op) {
case RGB_OP_SCREEN: {
- code += OUTNAME(p_node->id,0)+"=vec3(1.0)-(vec3(1.0)-"+p_inputs[0]+")*(vec3(1.0)-"+p_inputs[1]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=vec3(1.0)-(vec3(1.0)-" + p_inputs[0] + ")*(vec3(1.0)-" + p_inputs[1] + ");\n";
} break;
case RGB_OP_DIFFERENCE: {
- code += OUTNAME(p_node->id,0)+"=abs("+p_inputs[0]+"-"+p_inputs[1]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=abs(" + p_inputs[0] + "-" + p_inputs[1] + ");\n";
} break;
case RGB_OP_DARKEN: {
- code += OUTNAME(p_node->id,0)+"=min("+p_inputs[0]+","+p_inputs[1]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=min(" + p_inputs[0] + "," + p_inputs[1] + ");\n";
} break;
case RGB_OP_LIGHTEN: {
- code += OUTNAME(p_node->id,0)+"=max("+p_inputs[0]+","+p_inputs[1]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=max(" + p_inputs[0] + "," + p_inputs[1] + ");\n";
} break;
case RGB_OP_OVERLAY: {
- code += OUTNAME(p_node->id,0)+";\n";
- for(int i=0;i<3;i++) {
+ code += OUTNAME(p_node->id, 0) + ";\n";
+ for (int i = 0; i < 3; i++) {
code += "{\n";
- code += "\tfloat base="+p_inputs[0]+"."+axisn[i]+";\n";
- code += "\tfloat blend="+p_inputs[1]+"."+axisn[i]+";\n";
+ code += "\tfloat base=" + p_inputs[0] + "." + axisn[i] + ";\n";
+ code += "\tfloat blend=" + p_inputs[1] + "." + axisn[i] + ";\n";
code += "\tif (base < 0.5) {\n";
- code += "\t\t"+OUTVAR(p_node->id,0)+"."+axisn[i]+" = 2.0 * base * blend;\n";
+ code += "\t\t" + OUTVAR(p_node->id, 0) + "." + axisn[i] + " = 2.0 * base * blend;\n";
code += "\t} else {\n";
- code += "\t\t"+OUTVAR(p_node->id,0)+"."+axisn[i]+" = 1.0 - 2.0 * (1.0 - blend) * (1.0 - base);\n";
+ code += "\t\t" + OUTVAR(p_node->id, 0) + "." + axisn[i] + " = 1.0 - 2.0 * (1.0 - blend) * (1.0 - base);\n";
code += "\t}\n";
code += "}\n";
}
@@ -2236,24 +2190,24 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
} break;
case RGB_OP_DODGE: {
- code += OUTNAME(p_node->id,0)+"=("+p_inputs[0]+")/(vec3(1.0)-"+p_inputs[1]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=(" + p_inputs[0] + ")/(vec3(1.0)-" + p_inputs[1] + ");\n";
} break;
case RGB_OP_BURN: {
- code += OUTNAME(p_node->id,0)+"=vec3(1.0)-(vec3(1.0)-"+p_inputs[0]+")/("+p_inputs[1]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=vec3(1.0)-(vec3(1.0)-" + p_inputs[0] + ")/(" + p_inputs[1] + ");\n";
} break;
case RGB_OP_SOFT_LIGHT: {
- code += OUTNAME(p_node->id,0)+";\n";
- for(int i=0;i<3;i++) {
+ code += OUTNAME(p_node->id, 0) + ";\n";
+ for (int i = 0; i < 3; i++) {
code += "{\n";
- code += "\tfloat base="+p_inputs[0]+"."+axisn[i]+";\n";
- code += "\tfloat blend="+p_inputs[1]+"."+axisn[i]+";\n";
+ code += "\tfloat base=" + p_inputs[0] + "." + axisn[i] + ";\n";
+ code += "\tfloat blend=" + p_inputs[1] + "." + axisn[i] + ";\n";
code += "\tif (base < 0.5) {\n";
- code += "\t\t"+OUTVAR(p_node->id,0)+"."+axisn[i]+" = (base * (blend+0.5));\n";
+ code += "\t\t" + OUTVAR(p_node->id, 0) + "." + axisn[i] + " = (base * (blend+0.5));\n";
code += "\t} else {\n";
- code += "\t\t"+OUTVAR(p_node->id,0)+"."+axisn[i]+" = (1 - (1-base) * (1-(blend-0.5)));\n";
+ code += "\t\t" + OUTVAR(p_node->id, 0) + "." + axisn[i] + " = (1 - (1-base) * (1-(blend-0.5)));\n";
code += "\t}\n";
code += "}\n";
}
@@ -2261,54 +2215,54 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
} break;
case RGB_OP_HARD_LIGHT: {
- code += OUTNAME(p_node->id,0)+";\n";
- for(int i=0;i<3;i++) {
+ code += OUTNAME(p_node->id, 0) + ";\n";
+ for (int i = 0; i < 3; i++) {
code += "{\n";
- code += "\tfloat base="+p_inputs[0]+"."+axisn[i]+";\n";
- code += "\tfloat blend="+p_inputs[1]+"."+axisn[i]+";\n";
+ code += "\tfloat base=" + p_inputs[0] + "." + axisn[i] + ";\n";
+ code += "\tfloat blend=" + p_inputs[1] + "." + axisn[i] + ";\n";
code += "\tif (base < 0.5) {\n";
- code += "\t\t"+OUTVAR(p_node->id,0)+"."+axisn[i]+" = (base * (2*blend));\n";
+ code += "\t\t" + OUTVAR(p_node->id, 0) + "." + axisn[i] + " = (base * (2*blend));\n";
code += "\t} else {\n";
- code += "\t\t"+OUTVAR(p_node->id,0)+"."+axisn[i]+" = (1 - (1-base) * (1-2*(blend-0.5)));\n";
+ code += "\t\t" + OUTVAR(p_node->id, 0) + "." + axisn[i] + " = (1 - (1-base) * (1-2*(blend-0.5)));\n";
code += "\t}\n";
code += "}\n";
}
} break;
}
- }break;
+ } break;
case NODE_XFORM_MULT: {
DEF_MATRIX(0);
DEF_MATRIX(1);
- code += OUTNAME(p_node->id,0)+"="+p_inputs[0]+"*"+p_inputs[1]+";\n";
+ code += OUTNAME(p_node->id, 0) + "=" + p_inputs[0] + "*" + p_inputs[1] + ";\n";
- }break;
+ } break;
case NODE_XFORM_VEC_MULT: {
DEF_MATRIX(0);
DEF_VEC(1);
bool no_translation = p_node->param1;
if (no_translation) {
- code += OUTNAME(p_node->id,0)+"=("+p_inputs[0]+"*vec4("+p_inputs[1]+",0)).xyz;\n";
+ code += OUTNAME(p_node->id, 0) + "=(" + p_inputs[0] + "*vec4(" + p_inputs[1] + ",0)).xyz;\n";
} else {
- code += OUTNAME(p_node->id,0)+"=("+p_inputs[0]+"*vec4("+p_inputs[1]+",1)).xyz;\n";
+ code += OUTNAME(p_node->id, 0) + "=(" + p_inputs[0] + "*vec4(" + p_inputs[1] + ",1)).xyz;\n";
}
- }break;
+ } break;
case NODE_XFORM_VEC_INV_MULT: {
DEF_VEC(0);
DEF_MATRIX(1);
bool no_translation = p_node->param1;
if (no_translation) {
- code += OUTNAME(p_node->id,0)+"=("+p_inputs[1]+"*vec4("+p_inputs[0]+",0)).xyz;\n";
+ code += OUTNAME(p_node->id, 0) + "=(" + p_inputs[1] + "*vec4(" + p_inputs[0] + ",0)).xyz;\n";
} else {
- code += OUTNAME(p_node->id,0)+"=("+p_inputs[1]+"*vec4("+p_inputs[0]+",1)).xyz;\n";
+ code += OUTNAME(p_node->id, 0) + "=(" + p_inputs[1] + "*vec4(" + p_inputs[0] + ",1)).xyz;\n";
}
- }break;
+ } break;
case NODE_SCALAR_FUNC: {
DEF_SCALAR(0);
- static const char*scalar_func_id[SCALAR_MAX_FUNC]={
+ static const char *scalar_func_id[SCALAR_MAX_FUNC] = {
"sin($)",
"cos($)",
"tan($)",
@@ -2332,13 +2286,13 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
};
int func = p_node->param1;
- ERR_FAIL_INDEX(func,SCALAR_MAX_FUNC);
- code += OUTNAME(p_node->id,0)+"="+String(scalar_func_id[func]).replace("$",p_inputs[0])+";\n";
+ ERR_FAIL_INDEX(func, SCALAR_MAX_FUNC);
+ code += OUTNAME(p_node->id, 0) + "=" + String(scalar_func_id[func]).replace("$", p_inputs[0]) + ";\n";
} break;
case NODE_VEC_FUNC: {
DEF_VEC(0);
- static const char*vec_func_id[VEC_MAX_FUNC]={
+ static const char *vec_func_id[VEC_MAX_FUNC] = {
"normalize($)",
"max(min($,vec3(1,1,1)),vec3(0,0,0))",
"-($)",
@@ -2347,71 +2301,73 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
"",
};
-
int func = p_node->param1;
- ERR_FAIL_INDEX(func,VEC_MAX_FUNC);
- if (func==VEC_FUNC_RGB2HSV) {
- code += OUTNAME(p_node->id,0)+";\n";
- code+="{\n";
- code+="\tvec3 c = "+p_inputs[0]+";\n";
- code+="\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n";
- code+="\tvec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n";
- code+="\tvec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n";
- code+="\tfloat d = q.x - min(q.w, q.y);\n";
- code+="\tfloat e = 1.0e-10;\n";
- code+="\t"+OUTVAR(p_node->id,0)+"=vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n";
- code+="}\n";
- } else if (func==VEC_FUNC_HSV2RGB) {
- code += OUTNAME(p_node->id,0)+";\n";
- code+="{\n";
- code+="\tvec3 c = "+p_inputs[0]+";\n";
- code+="\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n";
- code+="\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n";
- code+="\t"+OUTVAR(p_node->id,0)+"=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n";
- code+="}\n";
+ ERR_FAIL_INDEX(func, VEC_MAX_FUNC);
+ if (func == VEC_FUNC_RGB2HSV) {
+ code += OUTNAME(p_node->id, 0) + ";\n";
+ code += "{\n";
+ code += "\tvec3 c = " + p_inputs[0] + ";\n";
+ code += "\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n";
+ code += "\tvec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n";
+ code += "\tvec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n";
+ code += "\tfloat d = q.x - min(q.w, q.y);\n";
+ code += "\tfloat e = 1.0e-10;\n";
+ code += "\t" + OUTVAR(p_node->id, 0) + "=vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n";
+ code += "}\n";
+ } else if (func == VEC_FUNC_HSV2RGB) {
+ code += OUTNAME(p_node->id, 0) + ";\n";
+ code += "{\n";
+ code += "\tvec3 c = " + p_inputs[0] + ";\n";
+ code += "\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n";
+ code += "\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n";
+ code += "\t" + OUTVAR(p_node->id, 0) + "=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n";
+ code += "}\n";
} else {
- code += OUTNAME(p_node->id,0)+"="+String(vec_func_id[func]).replace("$",p_inputs[0])+";\n";
+ code += OUTNAME(p_node->id, 0) + "=" + String(vec_func_id[func]).replace("$", p_inputs[0]) + ";\n";
}
- }break;
+ } break;
case NODE_VEC_LEN: {
DEF_VEC(0);
- code += OUTNAME(p_node->id,0)+"=length("+p_inputs[0]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=length(" + p_inputs[0] + ");\n";
- }break;
+ } break;
case NODE_DOT_PROD: {
DEF_VEC(0);
DEF_VEC(1);
- code += OUTNAME(p_node->id,0)+"=dot("+p_inputs[1]+","+p_inputs[0]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=dot(" + p_inputs[1] + "," + p_inputs[0] + ");\n";
- }break;
+ } break;
case NODE_VEC_TO_SCALAR: {
DEF_VEC(0);
- code += OUTNAME(p_node->id,0)+"="+p_inputs[0]+".x;\n";
- code += OUTNAME(p_node->id,1)+"="+p_inputs[0]+".y;\n";
- code += OUTNAME(p_node->id,2)+"="+p_inputs[0]+".z;\n";
+ code += OUTNAME(p_node->id, 0) + "=" + p_inputs[0] + ".x;\n";
+ code += OUTNAME(p_node->id, 1) + "=" + p_inputs[0] + ".y;\n";
+ code += OUTNAME(p_node->id, 2) + "=" + p_inputs[0] + ".z;\n";
- }break;
+ } break;
case NODE_SCALAR_TO_VEC: {
DEF_SCALAR(0);
DEF_SCALAR(1);
DEF_SCALAR(2);
- code += OUTNAME(p_node->id,0)+"=vec3("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+""+");\n";
+ code += OUTNAME(p_node->id, 0) + "=vec3(" + p_inputs[0] + "," + p_inputs[1] + "," + p_inputs[2] + "" + ");\n";
- }break;
+ } break;
case NODE_VEC_TO_XFORM: {
DEF_VEC(0);
DEF_VEC(1);
DEF_VEC(2);
DEF_VEC(3);
code += OUTNAME(p_node->id, 0) + "=mat4(" +
- "vec4(" + p_inputs[0] + ".x," + p_inputs[0] + ".y," + p_inputs[0] + ".z, 0.0),"
- "vec4(" + p_inputs[1] + ".x," + p_inputs[1] + ".y," + p_inputs[1] + ".z, 0.0),"
- "vec4(" + p_inputs[2] + ".x," + p_inputs[2] + ".y," + p_inputs[2] + ".z, 0.0),"
- "vec4(" + p_inputs[3] + ".x," + p_inputs[3] + ".y," + p_inputs[3] + ".z, 1.0));\n";
+ "vec4(" + p_inputs[0] + ".x," + p_inputs[0] + ".y," + p_inputs[0] + ".z, 0.0),"
+ "vec4(" +
+ p_inputs[1] + ".x," + p_inputs[1] + ".y," + p_inputs[1] + ".z, 0.0),"
+ "vec4(" +
+ p_inputs[2] + ".x," + p_inputs[2] + ".y," + p_inputs[2] + ".z, 0.0),"
+ "vec4(" +
+ p_inputs[3] + ".x," + p_inputs[3] + ".y," + p_inputs[3] + ".z, 1.0));\n";
- }break;
+ } break;
case NODE_XFORM_TO_VEC: {
DEF_MATRIX(0);
code += OUTNAME(p_node->id, 0) + ";\n";
@@ -2428,110 +2384,110 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
code += "\t" + OUTVAR(p_node->id, 2) + "=vec3(xform_row_03.x, xform_row_03.y, xform_row_03.z);\n";
code += "\t" + OUTVAR(p_node->id, 3) + "=vec3(xform_row_04.x, xform_row_04.y, xform_row_04.z);\n";
code += "}\n";
- }break;
+ } break;
case NODE_SCALAR_INTERP: {
DEF_SCALAR(0);
DEF_SCALAR(1);
DEF_SCALAR(2);
- code += OUTNAME(p_node->id,0)+"=mix("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=mix(" + p_inputs[0] + "," + p_inputs[1] + "," + p_inputs[2] + ");\n";
- }break;
+ } break;
case NODE_VEC_INTERP: {
DEF_VEC(0);
DEF_VEC(1);
DEF_SCALAR(2);
- code += OUTNAME(p_node->id,0)+"=mix("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+");\n";
+ code += OUTNAME(p_node->id, 0) + "=mix(" + p_inputs[0] + "," + p_inputs[1] + "," + p_inputs[2] + ");\n";
- }break;
+ } break;
case NODE_COLOR_RAMP: {
DEF_SCALAR(0);
- static const int color_ramp_len=512;
+ static const int color_ramp_len = 512;
DVector<uint8_t> cramp;
- cramp.resize(color_ramp_len*4);
+ cramp.resize(color_ramp_len * 4);
{
- DVector<Color> colors=p_node->param1;
- DVector<real_t> offsets=p_node->param2;
- int cc =colors.size();
+ DVector<Color> colors = p_node->param1;
+ DVector<real_t> offsets = p_node->param2;
+ int cc = colors.size();
DVector<uint8_t>::Write crw = cramp.write();
DVector<Color>::Read cr = colors.read();
DVector<real_t>::Read ofr = offsets.read();
- int at=0;
- Color color_at(0,0,0,1);
- for(int i=0;i<=cc;i++) {
+ int at = 0;
+ Color color_at(0, 0, 0, 1);
+ for (int i = 0; i <= cc; i++) {
int pos;
Color to;
- if (i==cc) {
- if (at==color_ramp_len)
+ if (i == cc) {
+ if (at == color_ramp_len)
break;
- pos=color_ramp_len;
- to=Color(1,1,1,1);
+ pos = color_ramp_len;
+ to = Color(1, 1, 1, 1);
} else {
- to=cr[i];
- pos= MIN(ofr[i]*color_ramp_len,color_ramp_len);
+ to = cr[i];
+ pos = MIN(ofr[i] * color_ramp_len, color_ramp_len);
}
- for(int j=at;j<pos;j++) {
- float t = (j-at)/float(pos-at);
- Color c = color_at.linear_interpolate(to,t);
- crw[j*4+0]=Math::fast_ftoi( CLAMP(c.r*255.0,0,255) );
- crw[j*4+1]=Math::fast_ftoi( CLAMP(c.g*255.0,0,255) );
- crw[j*4+2]=Math::fast_ftoi( CLAMP(c.b*255.0,0,255) );
- crw[j*4+3]=Math::fast_ftoi( CLAMP(c.a*255.0,0,255) );
+ for (int j = at; j < pos; j++) {
+ float t = (j - at) / float(pos - at);
+ Color c = color_at.linear_interpolate(to, t);
+ crw[j * 4 + 0] = Math::fast_ftoi(CLAMP(c.r * 255.0, 0, 255));
+ crw[j * 4 + 1] = Math::fast_ftoi(CLAMP(c.g * 255.0, 0, 255));
+ crw[j * 4 + 2] = Math::fast_ftoi(CLAMP(c.b * 255.0, 0, 255));
+ crw[j * 4 + 3] = Math::fast_ftoi(CLAMP(c.a * 255.0, 0, 255));
}
- at=pos;
- color_at=to;
+ at = pos;
+ color_at = to;
}
}
- Image gradient(color_ramp_len,1,0,Image::FORMAT_RGBA,cramp);
- Ref<ImageTexture> it = memnew( ImageTexture );
- it->create_from_image(gradient,Texture::FLAG_FILTER|Texture::FLAG_MIPMAPS);
+ Image gradient(color_ramp_len, 1, 0, Image::FORMAT_RGBA, cramp);
+ Ref<ImageTexture> it = memnew(ImageTexture);
+ it->create_from_image(gradient, Texture::FLAG_FILTER | Texture::FLAG_MIPMAPS);
- String crampname= "cramp_"+itos(p_node->id);
- set_default_texture_param(crampname,it);
+ String crampname = "cramp_" + itos(p_node->id);
+ set_default_texture_param(crampname, it);
- code +="uniform texture "+crampname+";\n";
- code +="vec4 "+crampname+"_r=tex("+crampname+",vec2("+p_inputs[0]+",0));\n";
- code += OUTNAME(p_node->id,0)+"="+crampname+"_r.rgb;\n";
- code += OUTNAME(p_node->id,1)+"="+crampname+"_r.a;\n";
+ code += "uniform texture " + crampname + ";\n";
+ code += "vec4 " + crampname + "_r=tex(" + crampname + ",vec2(" + p_inputs[0] + ",0));\n";
+ code += OUTNAME(p_node->id, 0) + "=" + crampname + "_r.rgb;\n";
+ code += OUTNAME(p_node->id, 1) + "=" + crampname + "_r.a;\n";
- }break;
+ } break;
case NODE_CURVE_MAP: {
DEF_SCALAR(0);
- static const int curve_map_len=256;
+ static const int curve_map_len = 256;
bool mapped[256];
- zeromem(mapped,sizeof(mapped));
+ zeromem(mapped, sizeof(mapped));
DVector<uint8_t> cmap;
cmap.resize(curve_map_len);
{
- DVector<Point2> points=p_node->param1;
- int pc =points.size();
+ DVector<Point2> points = p_node->param1;
+ int pc = points.size();
DVector<uint8_t>::Write cmw = cmap.write();
DVector<Point2>::Read pr = points.read();
- Vector2 prev=Vector2(0,0);
- Vector2 prev2=Vector2(0,0);
+ Vector2 prev = Vector2(0, 0);
+ Vector2 prev2 = Vector2(0, 0);
- for(int i=-1;i<pc;i++) {
+ for (int i = -1; i < pc; i++) {
Vector2 next;
Vector2 next2;
- if (i+1>=pc) {
- next=Vector2(1,1);
+ if (i + 1 >= pc) {
+ next = Vector2(1, 1);
} else {
- next=Vector2(pr[i+1].x,pr[i+1].y);
+ next = Vector2(pr[i + 1].x, pr[i + 1].y);
}
- if (i+2>=pc) {
- next2=Vector2(1,1);
+ if (i + 2 >= pc) {
+ next2 = Vector2(1, 1);
} else {
- next2=Vector2(pr[i+2].x,pr[i+2].y);
+ next2 = Vector2(pr[i + 2].x, pr[i + 2].y);
}
/*if (i==-1 && prev.offset==next.offset) {
@@ -2539,119 +2495,114 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
continue;
}*/
- _plot_curve(prev2,prev,next,next2,cmw.ptr(),mapped);
+ _plot_curve(prev2, prev, next, next2, cmw.ptr(), mapped);
- prev2=prev;
- prev=next;
+ prev2 = prev;
+ prev = next;
}
- uint8_t pp=0;
- for(int i=0;i<curve_map_len;i++) {
+ uint8_t pp = 0;
+ for (int i = 0; i < curve_map_len; i++) {
if (!mapped[i]) {
- cmw[i]=pp;
+ cmw[i] = pp;
} else {
- pp=cmw[i];
+ pp = cmw[i];
}
}
}
+ Image gradient(curve_map_len, 1, 0, Image::FORMAT_GRAYSCALE, cmap);
+ Ref<ImageTexture> it = memnew(ImageTexture);
+ it->create_from_image(gradient, Texture::FLAG_FILTER | Texture::FLAG_MIPMAPS);
+ String cmapname = "cmap_" + itos(p_node->id);
+ set_default_texture_param(cmapname, it);
- Image gradient(curve_map_len,1,0,Image::FORMAT_GRAYSCALE,cmap);
- Ref<ImageTexture> it = memnew( ImageTexture );
- it->create_from_image(gradient,Texture::FLAG_FILTER|Texture::FLAG_MIPMAPS);
+ code += "uniform texture " + cmapname + ";\n";
+ code += OUTNAME(p_node->id, 0) + "=tex(" + cmapname + ",vec2(" + p_inputs[0] + ",0)).r;\n";
- String cmapname= "cmap_"+itos(p_node->id);
- set_default_texture_param(cmapname,it);
-
- code +="uniform texture "+cmapname+";\n";
- code += OUTNAME(p_node->id,0)+"=tex("+cmapname+",vec2("+p_inputs[0]+",0)).r;\n";
-
- }break;
+ } break;
case NODE_SCALAR_INPUT: {
String name = p_node->param1;
- float dv=p_node->param2;
- code +="uniform float "+name+"="+rtos(dv)+";\n";
- code += OUTNAME(p_node->id,0)+"="+name+";\n";
- }break;
+ float dv = p_node->param2;
+ code += "uniform float " + name + "=" + rtos(dv) + ";\n";
+ code += OUTNAME(p_node->id, 0) + "=" + name + ";\n";
+ } break;
case NODE_VEC_INPUT: {
String name = p_node->param1;
- Vector3 dv=p_node->param2;
- code +="uniform vec3 "+name+"=vec3("+rtos(dv.x)+","+rtos(dv.y)+","+rtos(dv.z)+");\n";
- code += OUTNAME(p_node->id,0)+"="+name+";\n";
- }break;
+ Vector3 dv = p_node->param2;
+ code += "uniform vec3 " + name + "=vec3(" + rtos(dv.x) + "," + rtos(dv.y) + "," + rtos(dv.z) + ");\n";
+ code += OUTNAME(p_node->id, 0) + "=" + name + ";\n";
+ } break;
case NODE_RGB_INPUT: {
String name = p_node->param1;
- Color dv= p_node->param2;
+ Color dv = p_node->param2;
- code +="uniform color "+name+"=vec4("+rtos(dv.r)+","+rtos(dv.g)+","+rtos(dv.b)+","+rtos(dv.a)+");\n";
- code += OUTNAME(p_node->id,0)+"="+name+".rgb;\n";
- code += OUTNAME(p_node->id,1)+"="+name+".a;\n";
+ code += "uniform color " + name + "=vec4(" + rtos(dv.r) + "," + rtos(dv.g) + "," + rtos(dv.b) + "," + rtos(dv.a) + ");\n";
+ code += OUTNAME(p_node->id, 0) + "=" + name + ".rgb;\n";
+ code += OUTNAME(p_node->id, 1) + "=" + name + ".a;\n";
- }break;
+ } break;
case NODE_XFORM_INPUT: {
String name = p_node->param1;
- Transform dv= p_node->param2;
+ Transform dv = p_node->param2;
- code +="uniform mat4 "+name+"=mat4(\n";
- code+="\tvec4(vec3("+rtos(dv.basis.get_axis(0).x)+","+rtos(dv.basis.get_axis(0).y)+","+rtos(dv.basis.get_axis(0).z)+"),0),\n";
- code+="\tvec4(vec3("+rtos(dv.basis.get_axis(1).x)+","+rtos(dv.basis.get_axis(1).y)+","+rtos(dv.basis.get_axis(1).z)+"),0),\n";
- code+="\tvec4(vec3("+rtos(dv.basis.get_axis(2).x)+","+rtos(dv.basis.get_axis(2).y)+","+rtos(dv.basis.get_axis(2).z)+"),0),\n";
- code+="\tvec4(vec3("+rtos(dv.origin.x)+","+rtos(dv.origin.y)+","+rtos(dv.origin.z)+"),1)\n";
- code+=");";
+ code += "uniform mat4 " + name + "=mat4(\n";
+ code += "\tvec4(vec3(" + rtos(dv.basis.get_axis(0).x) + "," + rtos(dv.basis.get_axis(0).y) + "," + rtos(dv.basis.get_axis(0).z) + "),0),\n";
+ code += "\tvec4(vec3(" + rtos(dv.basis.get_axis(1).x) + "," + rtos(dv.basis.get_axis(1).y) + "," + rtos(dv.basis.get_axis(1).z) + "),0),\n";
+ code += "\tvec4(vec3(" + rtos(dv.basis.get_axis(2).x) + "," + rtos(dv.basis.get_axis(2).y) + "," + rtos(dv.basis.get_axis(2).z) + "),0),\n";
+ code += "\tvec4(vec3(" + rtos(dv.origin.x) + "," + rtos(dv.origin.y) + "," + rtos(dv.origin.z) + "),1)\n";
+ code += ");";
- code += OUTNAME(p_node->id,0)+"="+name+";\n";
+ code += OUTNAME(p_node->id, 0) + "=" + name + ";\n";
- }break;
+ } break;
case NODE_TEXTURE_INPUT: {
DEF_VEC(0);
String name = p_node->param1;
- String rname="rt_read_tex"+itos(p_node->id);
- code +="uniform texture "+name+";";
- code +="vec4 "+rname+"=tex("+name+","+p_inputs[0]+".xy);\n";
- code += OUTNAME(p_node->id,0)+"="+rname+".rgb;\n";
- code += OUTNAME(p_node->id,1)+"="+rname+".a;\n";
+ String rname = "rt_read_tex" + itos(p_node->id);
+ code += "uniform texture " + name + ";";
+ code += "vec4 " + rname + "=tex(" + name + "," + p_inputs[0] + ".xy);\n";
+ code += OUTNAME(p_node->id, 0) + "=" + rname + ".rgb;\n";
+ code += OUTNAME(p_node->id, 1) + "=" + rname + ".a;\n";
- }break;
+ } break;
case NODE_CUBEMAP_INPUT: {
DEF_VEC(0);
String name = p_node->param1;
- code +="uniform cubemap "+name+";";
- String rname="rt_read_tex"+itos(p_node->id);
- code +="vec4 "+rname+"=texcube("+name+","+p_inputs[0]+".xy);\n";
- code += OUTNAME(p_node->id,0)+"="+rname+".rgb;\n";
- code += OUTNAME(p_node->id,1)+"="+rname+".a;\n";
- }break;
+ code += "uniform cubemap " + name + ";";
+ String rname = "rt_read_tex" + itos(p_node->id);
+ code += "vec4 " + rname + "=texcube(" + name + "," + p_inputs[0] + ".xy);\n";
+ code += OUTNAME(p_node->id, 0) + "=" + rname + ".rgb;\n";
+ code += OUTNAME(p_node->id, 1) + "=" + rname + ".a;\n";
+ } break;
case NODE_DEFAULT_TEXTURE: {
DEF_VEC(0);
- if (get_mode()==MODE_CANVAS_ITEM && p_type==SHADER_TYPE_FRAGMENT) {
+ if (get_mode() == MODE_CANVAS_ITEM && p_type == SHADER_TYPE_FRAGMENT) {
- String rname="rt_default_tex"+itos(p_node->id);
- code +="vec4 "+rname+"=tex(TEXTURE,"+p_inputs[0]+".xy);\n";
- code += OUTNAME(p_node->id,0)+"="+rname+".rgb;\n";
- code += OUTNAME(p_node->id,1)+"="+rname+".a;\n";
+ String rname = "rt_default_tex" + itos(p_node->id);
+ code += "vec4 " + rname + "=tex(TEXTURE," + p_inputs[0] + ".xy);\n";
+ code += OUTNAME(p_node->id, 0) + "=" + rname + ".rgb;\n";
+ code += OUTNAME(p_node->id, 1) + "=" + rname + ".a;\n";
} else {
//not supported
- code += OUTNAME(p_node->id,0)+"=vec3(0,0,0);\n";
- code += OUTNAME(p_node->id,1)+"=1.0;\n";
-
+ code += OUTNAME(p_node->id, 0) + "=vec3(0,0,0);\n";
+ code += OUTNAME(p_node->id, 1) + "=1.0;\n";
}
} break;
case NODE_OUTPUT: {
-
- }break;
+ } break;
case NODE_COMMENT: {
- }break;
+ } break;
case NODE_TYPE_MAX: {
-
}
}
#undef DEF_SCALAR
diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h
index 2dfe6b66d..73525bb2d 100644
--- a/scene/resources/shader_graph.h
+++ b/scene/resources/shader_graph.h
@@ -29,18 +29,15 @@
#ifndef SHADER_GRAPH_H
#define SHADER_GRAPH_H
-
-
#include "map.h"
#include "scene/resources/shader.h"
class ShaderGraph : public Shader {
- OBJ_TYPE( ShaderGraph, Shader );
+ OBJ_TYPE(ShaderGraph, Shader);
RES_BASE_EXTENSION("sgp");
public:
-
enum NodeType {
NODE_INPUT, // all inputs (shader type dependent)
NODE_SCALAR_CONST, //scalar constant
@@ -80,7 +77,6 @@ public:
NODE_TYPE_MAX
};
-
struct Connection {
int src_id;
@@ -117,16 +113,15 @@ public:
};
private:
+ String _find_unique_name(const String &p_base);
- String _find_unique_name(const String& p_base);
-
- enum {SLOT_DEFAULT_VALUE = 0x7FFFFFFF};
+ enum { SLOT_DEFAULT_VALUE = 0x7FFFFFFF };
struct SourceSlot {
int id;
int slot;
- bool operator==(const SourceSlot& p_slot) const {
- return id==p_slot.id && slot==p_slot.slot;
+ bool operator==(const SourceSlot &p_slot) const {
+ return id == p_slot.id && slot == p_slot.slot;
}
};
@@ -140,17 +135,14 @@ private:
int id;
mutable int order; // used for sorting
int sort_order;
- Map<int,SourceSlot> connections;
-
+ Map<int, SourceSlot> connections;
};
struct ShaderData {
- Map<int,Node> node_map;
+ Map<int, Node> node_map;
GraphError error;
} shader[3];
-
-
struct InOutParamInfo {
Mode shader_mode;
ShaderType shader_type;
@@ -165,7 +157,8 @@ private:
struct NodeSlotInfo {
- enum { MAX_INS=3, MAX_OUTS=3 };
+ enum { MAX_INS = 3,
+ MAX_OUTS = 3 };
NodeType type;
const SlotType ins[MAX_INS];
const SlotType outs[MAX_OUTS];
@@ -177,46 +170,44 @@ private:
void _update_shader();
void _request_update();
- void _plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector2& p_c,const Vector2& p_d,uint8_t* p_heights,bool *p_useds);
- void _add_node_code(ShaderType p_type,Node *p_node,const Vector<String>& p_inputs,String& code);
+ void _plot_curve(const Vector2 &p_a, const Vector2 &p_b, const Vector2 &p_c, const Vector2 &p_d, uint8_t *p_heights, bool *p_useds);
+ void _add_node_code(ShaderType p_type, Node *p_node, const Vector<String> &p_inputs, String &code);
Array _get_node_list(ShaderType p_type) const;
Array _get_connections(ShaderType p_type) const;
- void _set_data(const Dictionary& p_data);
+ void _set_data(const Dictionary &p_data);
Dictionary _get_data() const;
-protected:
+protected:
static void _bind_methods();
public:
-
-
void node_add(ShaderType p_type, NodeType p_node_type, int p_id);
- void node_remove(ShaderType p_which,int p_id);
- void node_set_pos(ShaderType p_which,int p_id,const Point2& p_pos);
- Point2 node_get_pos(ShaderType p_which,int p_id) const;
+ void node_remove(ShaderType p_which, int p_id);
+ void node_set_pos(ShaderType p_which, int p_id, const Point2 &p_pos);
+ Point2 node_get_pos(ShaderType p_which, int p_id) const;
- void get_node_list(ShaderType p_which,List<int> *p_node_list) const;
- NodeType node_get_type(ShaderType p_which,int p_id) const;
+ void get_node_list(ShaderType p_which, List<int> *p_node_list) const;
+ NodeType node_get_type(ShaderType p_which, int p_id) const;
- void scalar_const_node_set_value(ShaderType p_which,int p_id,float p_value);
- float scalar_const_node_get_value(ShaderType p_which,int p_id) const;
+ void scalar_const_node_set_value(ShaderType p_which, int p_id, float p_value);
+ float scalar_const_node_get_value(ShaderType p_which, int p_id) const;
- void vec_const_node_set_value(ShaderType p_which,int p_id,const Vector3& p_value);
- Vector3 vec_const_node_get_value(ShaderType p_which,int p_id) const;
+ void vec_const_node_set_value(ShaderType p_which, int p_id, const Vector3 &p_value);
+ Vector3 vec_const_node_get_value(ShaderType p_which, int p_id) const;
- void rgb_const_node_set_value(ShaderType p_which,int p_id,const Color& p_value);
- Color rgb_const_node_get_value(ShaderType p_which,int p_id) const;
+ void rgb_const_node_set_value(ShaderType p_which, int p_id, const Color &p_value);
+ Color rgb_const_node_get_value(ShaderType p_which, int p_id) const;
- void xform_const_node_set_value(ShaderType p_which,int p_id,const Transform& p_value);
- Transform xform_const_node_get_value(ShaderType p_which,int p_id) const;
+ void xform_const_node_set_value(ShaderType p_which, int p_id, const Transform &p_value);
+ Transform xform_const_node_get_value(ShaderType p_which, int p_id) const;
- void texture_node_set_filter_size(ShaderType p_which,int p_id,int p_size);
- int texture_node_get_filter_size(ShaderType p_which,int p_id) const;
+ void texture_node_set_filter_size(ShaderType p_which, int p_id, int p_size);
+ int texture_node_get_filter_size(ShaderType p_which, int p_id) const;
- void texture_node_set_filter_strength(ShaderType p_which,float p_id,float p_strength);
- float texture_node_get_filter_strength(ShaderType p_which,float p_id) const;
+ void texture_node_set_filter_strength(ShaderType p_which, float p_id, float p_strength);
+ float texture_node_get_filter_strength(ShaderType p_which, float p_id) const;
void duplicate_nodes(ShaderType p_which, List<int> &p_nodes);
@@ -235,10 +226,10 @@ public:
SCALAR_MAX_OP
};
- void scalar_op_node_set_op(ShaderType p_which,float p_id,ScalarOp p_op);
- ScalarOp scalar_op_node_get_op(ShaderType p_which,float p_id) const;
+ void scalar_op_node_set_op(ShaderType p_which, float p_id, ScalarOp p_op);
+ ScalarOp scalar_op_node_get_op(ShaderType p_which, float p_id) const;
- enum VecOp {
+ enum VecOp {
VEC_OP_ADD,
VEC_OP_SUB,
VEC_OP_MUL,
@@ -251,8 +242,8 @@ public:
VEC_MAX_OP
};
- void vec_op_node_set_op(ShaderType p_which,float p_id,VecOp p_op);
- VecOp vec_op_node_get_op(ShaderType p_which,float p_id) const;
+ void vec_op_node_set_op(ShaderType p_which, float p_id, VecOp p_op);
+ VecOp vec_op_node_get_op(ShaderType p_which, float p_id) const;
enum VecScalarOp {
VEC_SCALAR_OP_MUL,
@@ -261,8 +252,8 @@ public:
VEC_SCALAR_MAX_OP
};
- void vec_scalar_op_node_set_op(ShaderType p_which,float p_id,VecScalarOp p_op);
- VecScalarOp vec_scalar_op_node_get_op(ShaderType p_which,float p_id) const;
+ void vec_scalar_op_node_set_op(ShaderType p_which, float p_id, VecScalarOp p_op);
+ VecScalarOp vec_scalar_op_node_get_op(ShaderType p_which, float p_id) const;
enum RGBOp {
RGB_OP_SCREEN,
@@ -277,11 +268,11 @@ public:
RGB_MAX_OP
};
- void rgb_op_node_set_op(ShaderType p_which,float p_id,RGBOp p_op);
- RGBOp rgb_op_node_get_op(ShaderType p_which,float p_id) const;
+ void rgb_op_node_set_op(ShaderType p_which, float p_id, RGBOp p_op);
+ RGBOp rgb_op_node_get_op(ShaderType p_which, float p_id) const;
- void xform_vec_mult_node_set_no_translation(ShaderType p_which,int p_id,bool p_no_translation);
- bool xform_vec_mult_node_get_no_translation(ShaderType p_which,int p_id) const;
+ void xform_vec_mult_node_set_no_translation(ShaderType p_which, int p_id, bool p_no_translation);
+ bool xform_vec_mult_node_get_no_translation(ShaderType p_which, int p_id) const;
enum ScalarFunc {
SCALAR_FUNC_SIN,
@@ -307,8 +298,8 @@ public:
SCALAR_MAX_FUNC
};
- void scalar_func_node_set_function(ShaderType p_which,int p_id,ScalarFunc p_func);
- ScalarFunc scalar_func_node_get_function(ShaderType p_which,int p_id) const;
+ void scalar_func_node_set_function(ShaderType p_which, int p_id, ScalarFunc p_func);
+ ScalarFunc scalar_func_node_get_function(ShaderType p_which, int p_id) const;
enum VecFunc {
VEC_FUNC_NORMALIZE,
@@ -320,55 +311,55 @@ public:
VEC_MAX_FUNC
};
- void default_set_value(ShaderType p_which,int p_id,int p_param, const Variant& p_value);
- Variant default_get_value(ShaderType p_which,int p_id,int p_param);
+ void default_set_value(ShaderType p_which, int p_id, int p_param, const Variant &p_value);
+ Variant default_get_value(ShaderType p_which, int p_id, int p_param);
- void vec_func_node_set_function(ShaderType p_which,int p_id,VecFunc p_func);
- VecFunc vec_func_node_get_function(ShaderType p_which,int p_id) const;
+ void vec_func_node_set_function(ShaderType p_which, int p_id, VecFunc p_func);
+ VecFunc vec_func_node_get_function(ShaderType p_which, int p_id) const;
- void color_ramp_node_set_ramp(ShaderType p_which,int p_id,const DVector<Color>& p_colors, const DVector<real_t>& p_offsets);
- DVector<Color> color_ramp_node_get_colors(ShaderType p_which,int p_id) const;
- DVector<real_t> color_ramp_node_get_offsets(ShaderType p_which,int p_id) const;
+ void color_ramp_node_set_ramp(ShaderType p_which, int p_id, const DVector<Color> &p_colors, const DVector<real_t> &p_offsets);
+ DVector<Color> color_ramp_node_get_colors(ShaderType p_which, int p_id) const;
+ DVector<real_t> color_ramp_node_get_offsets(ShaderType p_which, int p_id) const;
- void curve_map_node_set_points(ShaderType p_which, int p_id, const DVector<Vector2>& p_points);
- DVector<Vector2> curve_map_node_get_points(ShaderType p_which,int p_id) const;
+ void curve_map_node_set_points(ShaderType p_which, int p_id, const DVector<Vector2> &p_points);
+ DVector<Vector2> curve_map_node_get_points(ShaderType p_which, int p_id) const;
- void input_node_set_name(ShaderType p_which,int p_id,const String& p_name);
- String input_node_get_name(ShaderType p_which,int p_id);
+ void input_node_set_name(ShaderType p_which, int p_id, const String &p_name);
+ String input_node_get_name(ShaderType p_which, int p_id);
- void scalar_input_node_set_value(ShaderType p_which,int p_id,float p_value);
- float scalar_input_node_get_value(ShaderType p_which,int p_id) const;
+ void scalar_input_node_set_value(ShaderType p_which, int p_id, float p_value);
+ float scalar_input_node_get_value(ShaderType p_which, int p_id) const;
- void vec_input_node_set_value(ShaderType p_which,int p_id,const Vector3& p_value);
- Vector3 vec_input_node_get_value(ShaderType p_which,int p_id) const;
+ void vec_input_node_set_value(ShaderType p_which, int p_id, const Vector3 &p_value);
+ Vector3 vec_input_node_get_value(ShaderType p_which, int p_id) const;
- void rgb_input_node_set_value(ShaderType p_which,int p_id,const Color& p_value);
- Color rgb_input_node_get_value(ShaderType p_which,int p_id) const;
+ void rgb_input_node_set_value(ShaderType p_which, int p_id, const Color &p_value);
+ Color rgb_input_node_get_value(ShaderType p_which, int p_id) const;
- void xform_input_node_set_value(ShaderType p_which,int p_id,const Transform& p_value);
- Transform xform_input_node_get_value(ShaderType p_which,int p_id) const;
+ void xform_input_node_set_value(ShaderType p_which, int p_id, const Transform &p_value);
+ Transform xform_input_node_get_value(ShaderType p_which, int p_id) const;
- void texture_input_node_set_value(ShaderType p_which,int p_id,const Ref<Texture>& p_texture);
- Ref<Texture> texture_input_node_get_value(ShaderType p_which,int p_id) const;
+ void texture_input_node_set_value(ShaderType p_which, int p_id, const Ref<Texture> &p_texture);
+ Ref<Texture> texture_input_node_get_value(ShaderType p_which, int p_id) const;
- void cubemap_input_node_set_value(ShaderType p_which,int p_id,const Ref<CubeMap>& p_cubemap);
- Ref<CubeMap> cubemap_input_node_get_value(ShaderType p_which,int p_id) const;
+ void cubemap_input_node_set_value(ShaderType p_which, int p_id, const Ref<CubeMap> &p_cubemap);
+ Ref<CubeMap> cubemap_input_node_get_value(ShaderType p_which, int p_id) const;
- void comment_node_set_text(ShaderType p_which,int p_id,const String& p_comment);
- String comment_node_get_text(ShaderType p_which,int p_id) const;
+ void comment_node_set_text(ShaderType p_which, int p_id, const String &p_comment);
+ String comment_node_get_text(ShaderType p_which, int p_id) const;
- Error connect_node(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot);
- bool is_node_connected(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot) const;
- void disconnect_node(ShaderType p_which,int p_src_id,int p_src_slot, int p_dst_id,int p_dst_slot);
+ Error connect_node(ShaderType p_which, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot);
+ bool is_node_connected(ShaderType p_which, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot) const;
+ void disconnect_node(ShaderType p_which, int p_src_id, int p_src_slot, int p_dst_id, int p_dst_slot);
- void get_node_connections(ShaderType p_which,List<Connection> *p_connections) const;
+ void get_node_connections(ShaderType p_which, List<Connection> *p_connections) const;
- bool is_slot_connected(ShaderType p_which,int p_dst_id,int slot_id);
+ bool is_slot_connected(ShaderType p_which, int p_dst_id, int slot_id);
void clear(ShaderType p_which);
Variant node_get_state(ShaderType p_type, int p_node) const;
- void node_set_state(ShaderType p_type, int p_id, const Variant& p_state);
+ void node_set_state(ShaderType p_type, int p_id, const Variant &p_state);
GraphError get_graph_error(ShaderType p_type) const;
@@ -376,10 +367,9 @@ public:
static int get_type_input_count(NodeType p_type);
static int get_type_output_count(NodeType p_type);
- static SlotType get_type_input_type(NodeType p_type,int p_idx);
- static SlotType get_type_output_type(NodeType p_type,int p_idx);
- static bool is_type_valid(Mode p_mode,ShaderType p_type);
-
+ static SlotType get_type_input_type(NodeType p_type, int p_idx);
+ static SlotType get_type_output_type(NodeType p_type, int p_idx);
+ static bool is_type_valid(Mode p_mode, ShaderType p_type);
struct SlotInfo {
String name;
@@ -387,13 +377,12 @@ public:
SlotDir dir;
};
- static void get_input_output_node_slot_info(Mode p_mode, ShaderType p_type, List<SlotInfo> *r_slots);
-
- static int get_node_input_slot_count(Mode p_mode, ShaderType p_shader_type,NodeType p_type);
- static int get_node_output_slot_count(Mode p_mode, ShaderType p_shader_type,NodeType p_type);
- static SlotType get_node_input_slot_type(Mode p_mode, ShaderType p_shader_type,NodeType p_type,int p_idx);
- static SlotType get_node_output_slot_type(Mode p_mode, ShaderType p_shader_type,NodeType p_type,int p_idx);
+ static void get_input_output_node_slot_info(Mode p_mode, ShaderType p_type, List<SlotInfo> *r_slots);
+ static int get_node_input_slot_count(Mode p_mode, ShaderType p_shader_type, NodeType p_type);
+ static int get_node_output_slot_count(Mode p_mode, ShaderType p_shader_type, NodeType p_type);
+ static SlotType get_node_input_slot_type(Mode p_mode, ShaderType p_shader_type, NodeType p_type, int p_idx);
+ static SlotType get_node_output_slot_type(Mode p_mode, ShaderType p_shader_type, NodeType p_type, int p_idx);
ShaderGraph(Mode p_mode);
~ShaderGraph();
@@ -401,44 +390,35 @@ public:
//helper functions
-
-
-
-VARIANT_ENUM_CAST( ShaderGraph::NodeType );
-VARIANT_ENUM_CAST( ShaderGraph::ShaderType );
-VARIANT_ENUM_CAST( ShaderGraph::SlotType );
-VARIANT_ENUM_CAST( ShaderGraph::ScalarOp );
-VARIANT_ENUM_CAST( ShaderGraph::VecOp );
-VARIANT_ENUM_CAST( ShaderGraph::VecScalarOp );
-VARIANT_ENUM_CAST( ShaderGraph::RGBOp );
-VARIANT_ENUM_CAST( ShaderGraph::ScalarFunc );
-VARIANT_ENUM_CAST( ShaderGraph::VecFunc );
-VARIANT_ENUM_CAST( ShaderGraph::GraphError );
-
+VARIANT_ENUM_CAST(ShaderGraph::NodeType);
+VARIANT_ENUM_CAST(ShaderGraph::ShaderType);
+VARIANT_ENUM_CAST(ShaderGraph::SlotType);
+VARIANT_ENUM_CAST(ShaderGraph::ScalarOp);
+VARIANT_ENUM_CAST(ShaderGraph::VecOp);
+VARIANT_ENUM_CAST(ShaderGraph::VecScalarOp);
+VARIANT_ENUM_CAST(ShaderGraph::RGBOp);
+VARIANT_ENUM_CAST(ShaderGraph::ScalarFunc);
+VARIANT_ENUM_CAST(ShaderGraph::VecFunc);
+VARIANT_ENUM_CAST(ShaderGraph::GraphError);
class MaterialShaderGraph : public ShaderGraph {
- OBJ_TYPE( MaterialShaderGraph, ShaderGraph );
+ OBJ_TYPE(MaterialShaderGraph, ShaderGraph);
public:
-
-
- MaterialShaderGraph() : ShaderGraph(MODE_MATERIAL) {
-
+ MaterialShaderGraph()
+ : ShaderGraph(MODE_MATERIAL) {
}
};
class CanvasItemShaderGraph : public ShaderGraph {
- OBJ_TYPE( CanvasItemShaderGraph, ShaderGraph );
+ OBJ_TYPE(CanvasItemShaderGraph, ShaderGraph);
public:
-
-
- CanvasItemShaderGraph() : ShaderGraph(MODE_CANVAS_ITEM) {
-
+ CanvasItemShaderGraph()
+ : ShaderGraph(MODE_CANVAS_ITEM) {
}
};
-
#endif // SHADER_GRAPH_H
diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp
index 3e91fd0ea..fbaf3323f 100644
--- a/scene/resources/shape.cpp
+++ b/scene/resources/shape.cpp
@@ -28,25 +28,23 @@
/*************************************************************************/
#include "shape.h"
-#include "servers/physics_server.h"
-#include "scene/resources/mesh.h"
#include "os/os.h"
#include "scene/main/scene_main_loop.h"
+#include "scene/resources/mesh.h"
+#include "servers/physics_server.h"
-
-void Shape::add_vertices_to_array(DVector<Vector3> &array, const Transform& p_xform) {
+void Shape::add_vertices_to_array(DVector<Vector3> &array, const Transform &p_xform) {
Vector<Vector3> toadd = _gen_debug_mesh_lines();
if (toadd.size()) {
- int base=array.size();
- array.resize(base+toadd.size());
+ int base = array.size();
+ array.resize(base + toadd.size());
DVector<Vector3>::Write w = array.write();
- for(int i=0;i<toadd.size();i++) {
- w[i+base]=p_xform.xform(toadd[i]);
+ for (int i = 0; i < toadd.size(); i++) {
+ w[i + base] = p_xform.xform(toadd[i]);
}
-
}
}
@@ -65,46 +63,39 @@ Ref<Mesh> Shape::get_debug_mesh() {
array.resize(lines.size());
{
- DVector<Vector3>::Write w=array.write();
- for(int i=0;i<lines.size();i++) {
- w[i]=lines[i];
+ DVector<Vector3>::Write w = array.write();
+ for (int i = 0; i < lines.size(); i++) {
+ w[i] = lines[i];
}
}
Array arr;
arr.resize(Mesh::ARRAY_MAX);
- arr[Mesh::ARRAY_VERTEX]=array;
+ arr[Mesh::ARRAY_VERTEX] = array;
- SceneTree *st=OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
+ SceneTree *st = OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
- debug_mesh_cache->add_surface(Mesh::PRIMITIVE_LINES,arr);
+ debug_mesh_cache->add_surface(Mesh::PRIMITIVE_LINES, arr);
if (st) {
- debug_mesh_cache->surface_set_material(0,st->get_debug_collision_material());
+ debug_mesh_cache->surface_set_material(0, st->get_debug_collision_material());
}
-
}
-
-
return debug_mesh_cache;
-
}
Shape::Shape() {
ERR_PRINT("Constructor must not be called!");
-
}
-
Shape::Shape(RID p_shape) {
- shape=p_shape;
+ shape = p_shape;
}
Shape::~Shape() {
PhysicsServer::get_singleton()->free(shape);
}
-
diff --git a/scene/resources/shape.h b/scene/resources/shape.h
index 8d8e3d35c..04622ae59 100644
--- a/scene/resources/shape.h
+++ b/scene/resources/shape.h
@@ -34,26 +34,24 @@ class Mesh;
class Shape : public Resource {
- OBJ_TYPE( Shape, Resource );
- OBJ_SAVE_TYPE( Shape );
+ OBJ_TYPE(Shape, Resource);
+ OBJ_SAVE_TYPE(Shape);
RES_BASE_EXTENSION("shp");
RID shape;
Ref<Mesh> debug_mesh_cache;
protected:
-
_FORCE_INLINE_ RID get_shape() const { return shape; }
Shape(RID p_shape);
- virtual Vector<Vector3> _gen_debug_mesh_lines()=0;// { return Vector<Vector3>(); }
+ virtual Vector<Vector3> _gen_debug_mesh_lines() = 0; // { return Vector<Vector3>(); }
public:
-
virtual RID get_rid() const { return shape; }
Ref<Mesh> get_debug_mesh();
- void add_vertices_to_array(DVector<Vector3> &array, const Transform& p_xform);
+ void add_vertices_to_array(DVector<Vector3> &array, const Transform &p_xform);
Shape();
~Shape();
diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp
index 969aeb973..6f864f7f9 100644
--- a/scene/resources/shape_2d.cpp
+++ b/scene/resources/shape_2d.cpp
@@ -33,96 +33,84 @@ RID Shape2D::get_rid() const {
return shape;
}
-
void Shape2D::set_custom_solver_bias(real_t p_bias) {
- custom_bias=p_bias;
- Physics2DServer::get_singleton()->shape_set_custom_solver_bias(shape,custom_bias);
+ custom_bias = p_bias;
+ Physics2DServer::get_singleton()->shape_set_custom_solver_bias(shape, custom_bias);
}
-real_t Shape2D::get_custom_solver_bias() const{
+real_t Shape2D::get_custom_solver_bias() const {
return custom_bias;
-
}
+bool Shape2D::collide_with_motion(const Matrix32 &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Matrix32 &p_shape_xform, const Vector2 &p_shape_motion) {
-bool Shape2D::collide_with_motion(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_shape_motion) {
-
- ERR_FAIL_COND_V(p_shape.is_null(),false);
+ ERR_FAIL_COND_V(p_shape.is_null(), false);
int r;
- return Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,p_local_motion,p_shape->get_rid(),p_shape_xform,p_shape_motion,NULL,0,r);
+ return Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, NULL, 0, r);
}
-bool Shape2D::collide(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform){
- ERR_FAIL_COND_V(p_shape.is_null(),false);
+bool Shape2D::collide(const Matrix32 &p_local_xform, const Ref<Shape2D> &p_shape, const Matrix32 &p_shape_xform) {
+ ERR_FAIL_COND_V(p_shape.is_null(), false);
int r;
- return Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,Vector2(),p_shape->get_rid(),p_shape_xform,Vector2(),NULL,0,r);
-
-
+ return Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), NULL, 0, r);
}
-Variant Shape2D::collide_with_motion_and_get_contacts(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_shape_motion){
+Variant Shape2D::collide_with_motion_and_get_contacts(const Matrix32 &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Matrix32 &p_shape_xform, const Vector2 &p_shape_motion) {
- ERR_FAIL_COND_V(p_shape.is_null(),Variant());
+ ERR_FAIL_COND_V(p_shape.is_null(), Variant());
const int max_contacts = 16;
- Vector2 result[max_contacts*2];
- int contacts=0;
+ Vector2 result[max_contacts * 2];
+ int contacts = 0;
- if (!Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,p_local_motion,p_shape->get_rid(),p_shape_xform,p_shape_motion,result,max_contacts,contacts))
+ if (!Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, p_local_motion, p_shape->get_rid(), p_shape_xform, p_shape_motion, result, max_contacts, contacts))
return Variant();
Array results;
- results.resize(contacts*2);
- for(int i=0;i<contacts;i++) {
- results[i]=result[i];
+ results.resize(contacts * 2);
+ for (int i = 0; i < contacts; i++) {
+ results[i] = result[i];
}
return results;
-
}
-Variant Shape2D::collide_and_get_contacts(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform){
+Variant Shape2D::collide_and_get_contacts(const Matrix32 &p_local_xform, const Ref<Shape2D> &p_shape, const Matrix32 &p_shape_xform) {
- ERR_FAIL_COND_V(p_shape.is_null(),Variant());
+ ERR_FAIL_COND_V(p_shape.is_null(), Variant());
const int max_contacts = 16;
- Vector2 result[max_contacts*2];
- int contacts=0;
+ Vector2 result[max_contacts * 2];
+ int contacts = 0;
- if (!Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,Vector2(),p_shape->get_rid(),p_shape_xform,Vector2(),result,max_contacts,contacts))
+ if (!Physics2DServer::get_singleton()->shape_collide(get_rid(), p_local_xform, Vector2(), p_shape->get_rid(), p_shape_xform, Vector2(), result, max_contacts, contacts))
return Variant();
Array results;
- results.resize(contacts*2);
- for(int i=0;i<contacts;i++) {
- results[i]=result[i];
+ results.resize(contacts * 2);
+ for (int i = 0; i < contacts; i++) {
+ results[i] = result[i];
}
return results;
-
-
}
void Shape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_custom_solver_bias","bias"),&Shape2D::set_custom_solver_bias);
- ObjectTypeDB::bind_method(_MD("get_custom_solver_bias"),&Shape2D::get_custom_solver_bias);
- ObjectTypeDB::bind_method(_MD("collide","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide);
- ObjectTypeDB::bind_method(_MD("collide_with_motion","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion);
- ObjectTypeDB::bind_method(_MD("collide_and_get_contacts:Variant","local_xform","with_shape:Shape2D","shape_xform"),&Shape2D::collide_and_get_contacts);
- ObjectTypeDB::bind_method(_MD("collide_with_motion_and_get_contacts:Variant","local_xform","local_motion","with_shape:Shape2D","shape_xform","shape_motion"),&Shape2D::collide_with_motion_and_get_contacts);
+ ObjectTypeDB::bind_method(_MD("set_custom_solver_bias", "bias"), &Shape2D::set_custom_solver_bias);
+ ObjectTypeDB::bind_method(_MD("get_custom_solver_bias"), &Shape2D::get_custom_solver_bias);
+ ObjectTypeDB::bind_method(_MD("collide", "local_xform", "with_shape:Shape2D", "shape_xform"), &Shape2D::collide);
+ ObjectTypeDB::bind_method(_MD("collide_with_motion", "local_xform", "local_motion", "with_shape:Shape2D", "shape_xform", "shape_motion"), &Shape2D::collide_with_motion);
+ ObjectTypeDB::bind_method(_MD("collide_and_get_contacts:Variant", "local_xform", "with_shape:Shape2D", "shape_xform"), &Shape2D::collide_and_get_contacts);
+ ObjectTypeDB::bind_method(_MD("collide_with_motion_and_get_contacts:Variant", "local_xform", "local_motion", "with_shape:Shape2D", "shape_xform", "shape_motion"), &Shape2D::collide_with_motion_and_get_contacts);
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_solver_bias",PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_custom_solver_bias"),_SCS("get_custom_solver_bias"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "custom_solver_bias", PROPERTY_HINT_RANGE, "0,1,0.001"), _SCS("set_custom_solver_bias"), _SCS("get_custom_solver_bias"));
}
-
-
-Shape2D::Shape2D(const RID& p_rid) {
- shape=p_rid;
- custom_bias=0;
+Shape2D::Shape2D(const RID &p_rid) {
+ shape = p_rid;
+ custom_bias = 0;
}
-
-
Shape2D::~Shape2D() {
Physics2DServer::get_singleton()->free(shape);
diff --git a/scene/resources/shape_2d.h b/scene/resources/shape_2d.h
index 758824a4b..f76016716 100644
--- a/scene/resources/shape_2d.h
+++ b/scene/resources/shape_2d.h
@@ -32,28 +32,27 @@
#include "resource.h"
class Shape2D : public Resource {
- OBJ_TYPE( Shape2D, Resource );
- OBJ_SAVE_TYPE( Shape2D );
+ OBJ_TYPE(Shape2D, Resource);
+ OBJ_SAVE_TYPE(Shape2D);
RID shape;
real_t custom_bias;
-protected:
-
+protected:
static void _bind_methods();
- Shape2D(const RID& p_rid);
-public:
+ Shape2D(const RID &p_rid);
+public:
void set_custom_solver_bias(real_t p_bias);
real_t get_custom_solver_bias() const;
- bool collide_with_motion(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_p_shape_motion);
- bool collide(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform);
+ bool collide_with_motion(const Matrix32 &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Matrix32 &p_shape_xform, const Vector2 &p_p_shape_motion);
+ bool collide(const Matrix32 &p_local_xform, const Ref<Shape2D> &p_shape, const Matrix32 &p_shape_xform);
- Variant collide_with_motion_and_get_contacts(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_p_shape_motion);
- Variant collide_and_get_contacts(const Matrix32& p_local_xform, const Ref<Shape2D>& p_shape, const Matrix32& p_shape_xform);
+ Variant collide_with_motion_and_get_contacts(const Matrix32 &p_local_xform, const Vector2 &p_local_motion, const Ref<Shape2D> &p_shape, const Matrix32 &p_shape_xform, const Vector2 &p_p_shape_motion);
+ Variant collide_and_get_contacts(const Matrix32 &p_local_xform, const Ref<Shape2D> &p_shape, const Matrix32 &p_shape_xform);
- virtual void draw(const RID& p_to_rid,const Color& p_color) {}
+ virtual void draw(const RID &p_to_rid, const Color &p_color) {}
virtual Rect2 get_rect() const { return Rect2(); }
virtual RID get_rid() const;
Shape2D();
diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp
index a86e4f050..1ce23881b 100644
--- a/scene/resources/shape_line_2d.cpp
+++ b/scene/resources/shape_line_2d.cpp
@@ -34,23 +34,20 @@ void LineShape2D::_update_shape() {
Array arr;
arr.push_back(normal);
arr.push_back(d);
- Physics2DServer::get_singleton()->shape_set_data(get_rid(),arr);
+ Physics2DServer::get_singleton()->shape_set_data(get_rid(), arr);
emit_changed();
-
}
-void LineShape2D::set_normal(const Vector2& p_normal) {
+void LineShape2D::set_normal(const Vector2 &p_normal) {
- normal=p_normal;
+ normal = p_normal;
_update_shape();
-
}
void LineShape2D::set_d(real_t p_d) {
- d=p_d;
+ d = p_d;
_update_shape();
-
}
Vector2 LineShape2D::get_normal() const {
@@ -62,48 +59,45 @@ real_t LineShape2D::get_d() const {
return d;
}
-
-void LineShape2D::draw(const RID& p_to_rid,const Color& p_color) {
+void LineShape2D::draw(const RID &p_to_rid, const Color &p_color) {
Vector2 point = get_d() * get_normal();
- Vector2 l1[2]={point-get_normal().tangent()*100,point+get_normal().tangent()*100};
- VS::get_singleton()->canvas_item_add_line(p_to_rid,l1[0],l1[1],p_color,3);
- Vector2 l2[2]={point,point+get_normal()*30};
- VS::get_singleton()->canvas_item_add_line(p_to_rid,l2[0],l2[1],p_color,3);
-
+ Vector2 l1[2] = { point - get_normal().tangent() * 100, point + get_normal().tangent() * 100 };
+ VS::get_singleton()->canvas_item_add_line(p_to_rid, l1[0], l1[1], p_color, 3);
+ Vector2 l2[2] = { point, point + get_normal() * 30 };
+ VS::get_singleton()->canvas_item_add_line(p_to_rid, l2[0], l2[1], p_color, 3);
}
-Rect2 LineShape2D::get_rect() const{
+Rect2 LineShape2D::get_rect() const {
Vector2 point = get_d() * get_normal();
- Vector2 l1[2]={point-get_normal().tangent()*100,point+get_normal().tangent()*100};
- Vector2 l2[2]={point,point+get_normal()*30};
+ Vector2 l1[2] = { point - get_normal().tangent() * 100, point + get_normal().tangent() * 100 };
+ Vector2 l2[2] = { point, point + get_normal() * 30 };
Rect2 rect;
- rect.pos=l1[0];
+ rect.pos = l1[0];
rect.expand_to(l1[1]);
rect.expand_to(l2[0]);
rect.expand_to(l2[1]);
return rect;
-
}
void LineShape2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_normal","normal"),&LineShape2D::set_normal);
- ObjectTypeDB::bind_method(_MD("get_normal"),&LineShape2D::get_normal);
-
- ObjectTypeDB::bind_method(_MD("set_d","d"),&LineShape2D::set_d);
- ObjectTypeDB::bind_method(_MD("get_d"),&LineShape2D::get_d);
+ ObjectTypeDB::bind_method(_MD("set_normal", "normal"), &LineShape2D::set_normal);
+ ObjectTypeDB::bind_method(_MD("get_normal"), &LineShape2D::get_normal);
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"normal"),_SCS("set_normal"),_SCS("get_normal") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"d"),_SCS("set_d"),_SCS("get_d") );
+ ObjectTypeDB::bind_method(_MD("set_d", "d"), &LineShape2D::set_d);
+ ObjectTypeDB::bind_method(_MD("get_d"), &LineShape2D::get_d);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), _SCS("set_normal"), _SCS("get_normal"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "d"), _SCS("set_d"), _SCS("get_d"));
}
-LineShape2D::LineShape2D() : Shape2D( Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_LINE)) {
+LineShape2D::LineShape2D()
+ : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_LINE)) {
- normal=Vector2(0,-1);
- d=0;
+ normal = Vector2(0, -1);
+ d = 0;
_update_shape();
}
diff --git a/scene/resources/shape_line_2d.h b/scene/resources/shape_line_2d.h
index 160dc17b4..189036c2a 100644
--- a/scene/resources/shape_line_2d.h
+++ b/scene/resources/shape_line_2d.h
@@ -32,24 +32,24 @@
#include "scene/resources/shape_2d.h"
class LineShape2D : public Shape2D {
- OBJ_TYPE( LineShape2D, Shape2D );
+ OBJ_TYPE(LineShape2D, Shape2D);
Vector2 normal;
real_t d;
void _update_shape();
-protected:
+protected:
static void _bind_methods();
-public:
- void set_normal(const Vector2& p_normal);
+public:
+ void set_normal(const Vector2 &p_normal);
void set_d(real_t p_d);
Vector2 get_normal() const;
real_t get_d() const;
- virtual void draw(const RID& p_to_rid,const Color& p_color);
+ virtual void draw(const RID &p_to_rid, const Color &p_color);
virtual Rect2 get_rect() const;
LineShape2D();
diff --git a/scene/resources/space_2d.cpp b/scene/resources/space_2d.cpp
index e95bfd69c..2302f1949 100644
--- a/scene/resources/space_2d.cpp
+++ b/scene/resources/space_2d.cpp
@@ -33,11 +33,10 @@ RID Space2D::get_rid() const {
return space;
}
-
void Space2D::set_active(bool p_active) {
- active=p_active;
- Physics2DServer::get_singleton()->space_set_active(space,active);
+ active = p_active;
+ Physics2DServer::get_singleton()->space_set_active(space, active);
}
bool Space2D::is_active() const {
@@ -45,24 +44,21 @@ bool Space2D::is_active() const {
return active;
}
-
void Space2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_active","active"),&Space2D::set_active);
- ObjectTypeDB::bind_method(_MD("is_active"),&Space2D::is_active);
-
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"active"),_SCS("set_active"),_SCS("is_active") );
+ ObjectTypeDB::bind_method(_MD("set_active", "active"), &Space2D::set_active);
+ ObjectTypeDB::bind_method(_MD("is_active"), &Space2D::is_active);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), _SCS("set_active"), _SCS("is_active"));
}
Space2D::Space2D() {
- active=false;
- space=Physics2DServer::get_singleton()->space_create();
+ active = false;
+ space = Physics2DServer::get_singleton()->space_create();
}
Space2D::~Space2D() {
Physics2DServer::get_singleton()->free(space);
}
-
diff --git a/scene/resources/space_2d.h b/scene/resources/space_2d.h
index b1577dcbe..5758a94ec 100644
--- a/scene/resources/space_2d.h
+++ b/scene/resources/space_2d.h
@@ -29,21 +29,19 @@
#ifndef SPACE_2D_H
#define SPACE_2D_H
-#include "servers/physics_2d_server.h"
#include "resource.h"
-
+#include "servers/physics_2d_server.h"
class Space2D : public Resource {
- OBJ_TYPE(Space2D,Resource);
+ OBJ_TYPE(Space2D, Resource);
bool active;
RID space;
-protected:
+protected:
static void _bind_methods();
-public:
-
+public:
void set_active(bool p_active);
bool is_active() const;
diff --git a/scene/resources/sphere_shape.cpp b/scene/resources/sphere_shape.cpp
index 5f632b140..71ef3aaba 100644
--- a/scene/resources/sphere_shape.cpp
+++ b/scene/resources/sphere_shape.cpp
@@ -31,24 +31,23 @@
Vector<Vector3> SphereShape::_gen_debug_mesh_lines() {
- float r=get_radius();
+ float r = get_radius();
Vector<Vector3> points;
- for(int i=0;i<=360;i++) {
+ for (int i = 0; i <= 360; i++) {
- float ra=Math::deg2rad(i);
- float rb=Math::deg2rad(i+1);
- Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
- Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
-
- points.push_back(Vector3(a.x,0,a.y));
- points.push_back(Vector3(b.x,0,b.y));
- points.push_back(Vector3(0,a.x,a.y));
- points.push_back(Vector3(0,b.x,b.y));
- points.push_back(Vector3(a.x,a.y,0));
- points.push_back(Vector3(b.x,b.y,0));
+ float ra = Math::deg2rad(i);
+ float rb = Math::deg2rad(i + 1);
+ Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
+ Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
+ points.push_back(Vector3(a.x, 0, a.y));
+ points.push_back(Vector3(b.x, 0, b.y));
+ points.push_back(Vector3(0, a.x, a.y));
+ points.push_back(Vector3(0, b.x, b.y));
+ points.push_back(Vector3(a.x, a.y, 0));
+ points.push_back(Vector3(b.x, b.y, 0));
}
return points;
@@ -56,12 +55,12 @@ Vector<Vector3> SphereShape::_gen_debug_mesh_lines() {
void SphereShape::_update_shape() {
- PhysicsServer::get_singleton()->shape_set_data(get_shape(),radius);
+ PhysicsServer::get_singleton()->shape_set_data(get_shape(), radius);
}
void SphereShape::set_radius(float p_radius) {
- radius=p_radius;
+ radius = p_radius;
_update_shape();
notify_change_to_owners();
_change_notify("radius");
@@ -72,17 +71,16 @@ float SphereShape::get_radius() const {
return radius;
}
-
void SphereShape::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_radius","radius"),&SphereShape::set_radius);
- ObjectTypeDB::bind_method(_MD("get_radius"),&SphereShape::get_radius);
-
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"radius",PROPERTY_HINT_RANGE,"0,4096,0.01"), _SCS("set_radius"), _SCS("get_radius"));
+ ObjectTypeDB::bind_method(_MD("set_radius", "radius"), &SphereShape::set_radius);
+ ObjectTypeDB::bind_method(_MD("get_radius"), &SphereShape::get_radius);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0,4096,0.01"), _SCS("set_radius"), _SCS("get_radius"));
}
-SphereShape::SphereShape() : Shape( PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) {
+SphereShape::SphereShape()
+ : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) {
set_radius(1.0);
}
diff --git a/scene/resources/sphere_shape.h b/scene/resources/sphere_shape.h
index 96a84ce48..ae8a11d78 100644
--- a/scene/resources/sphere_shape.h
+++ b/scene/resources/sphere_shape.h
@@ -29,22 +29,20 @@
#ifndef SPHERE_SHAPE_H
#define SPHERE_SHAPE_H
-
#include "scene/resources/shape.h"
class SphereShape : public Shape {
- OBJ_TYPE(SphereShape,Shape);
+ OBJ_TYPE(SphereShape, Shape);
float radius;
protected:
-
static void _bind_methods();
virtual void _update_shape();
virtual Vector<Vector3> _gen_debug_mesh_lines();
-public:
+public:
void set_radius(float p_radius);
float get_radius() const;
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index c3649850b..79a5a42d9 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -28,25 +28,24 @@
/*************************************************************************/
#include "style_box.h"
-bool StyleBox::test_mask(const Point2& p_point, const Rect2& p_rect) const {
+bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const {
return true;
}
void StyleBox::set_default_margin(Margin p_margin, float p_value) {
- margin[p_margin]=p_value;
+ margin[p_margin] = p_value;
emit_changed();
-
}
-float StyleBox::get_default_margin(Margin p_margin) const{
+float StyleBox::get_default_margin(Margin p_margin) const {
return margin[p_margin];
}
float StyleBox::get_margin(Margin p_margin) const {
- if (margin[p_margin]<0)
+ if (margin[p_margin] < 0)
return get_style_margin(p_margin);
else
return margin[p_margin];
@@ -54,13 +53,12 @@ float StyleBox::get_margin(Margin p_margin) const {
Size2 StyleBox::get_minimum_size() const {
- return Size2( get_margin( MARGIN_LEFT) + get_margin( MARGIN_RIGHT ) , get_margin( MARGIN_TOP) + get_margin( MARGIN_BOTTOM ) );
+ return Size2(get_margin(MARGIN_LEFT) + get_margin(MARGIN_RIGHT), get_margin(MARGIN_TOP) + get_margin(MARGIN_BOTTOM));
}
-
Point2 StyleBox::get_offset() const {
- return Point2( get_margin( MARGIN_LEFT), get_margin( MARGIN_TOP) );
+ return Point2(get_margin(MARGIN_LEFT), get_margin(MARGIN_TOP));
}
Size2 StyleBox::get_center_size() const {
@@ -70,57 +68,52 @@ Size2 StyleBox::get_center_size() const {
void StyleBox::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("test_mask","point","rect"),&StyleBox::test_mask);
-
- ObjectTypeDB::bind_method(_MD("set_default_margin","margin","offset"),&StyleBox::set_default_margin);
- ObjectTypeDB::bind_method(_MD("get_default_margin","margin"),&StyleBox::get_default_margin);
+ ObjectTypeDB::bind_method(_MD("test_mask", "point", "rect"), &StyleBox::test_mask);
-// ObjectTypeDB::bind_method(_MD("set_default_margin"),&StyleBox::set_default_margin);
-// ObjectTypeDB::bind_method(_MD("get_default_margin"),&StyleBox::get_default_margin);
+ ObjectTypeDB::bind_method(_MD("set_default_margin", "margin", "offset"), &StyleBox::set_default_margin);
+ ObjectTypeDB::bind_method(_MD("get_default_margin", "margin"), &StyleBox::get_default_margin);
- ObjectTypeDB::bind_method(_MD("get_margin","margin"),&StyleBox::get_margin);
- ObjectTypeDB::bind_method(_MD("get_minimum_size"),&StyleBox::get_minimum_size);
- ObjectTypeDB::bind_method(_MD("get_center_size"),&StyleBox::get_center_size);
- ObjectTypeDB::bind_method(_MD("get_offset"),&StyleBox::get_offset);
+ // ObjectTypeDB::bind_method(_MD("set_default_margin"),&StyleBox::set_default_margin);
+ // ObjectTypeDB::bind_method(_MD("get_default_margin"),&StyleBox::get_default_margin);
- ObjectTypeDB::bind_method(_MD("draw","canvas_item","rect"),&StyleBox::draw);
-
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin/left", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin/right", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin/top", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "content_margin/bottom", PROPERTY_HINT_RANGE,"-1,2048,1" ), _SCS("set_default_margin"),_SCS("get_default_margin"), MARGIN_BOTTOM );
+ ObjectTypeDB::bind_method(_MD("get_margin", "margin"), &StyleBox::get_margin);
+ ObjectTypeDB::bind_method(_MD("get_minimum_size"), &StyleBox::get_minimum_size);
+ ObjectTypeDB::bind_method(_MD("get_center_size"), &StyleBox::get_center_size);
+ ObjectTypeDB::bind_method(_MD("get_offset"), &StyleBox::get_offset);
+ ObjectTypeDB::bind_method(_MD("draw", "canvas_item", "rect"), &StyleBox::draw);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "content_margin/left", PROPERTY_HINT_RANGE, "-1,2048,1"), _SCS("set_default_margin"), _SCS("get_default_margin"), MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "content_margin/right", PROPERTY_HINT_RANGE, "-1,2048,1"), _SCS("set_default_margin"), _SCS("get_default_margin"), MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "content_margin/top", PROPERTY_HINT_RANGE, "-1,2048,1"), _SCS("set_default_margin"), _SCS("get_default_margin"), MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "content_margin/bottom", PROPERTY_HINT_RANGE, "-1,2048,1"), _SCS("set_default_margin"), _SCS("get_default_margin"), MARGIN_BOTTOM);
}
StyleBox::StyleBox() {
- for (int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- margin[i]=-1;
+ margin[i] = -1;
}
}
-
void StyleBoxTexture::set_texture(RES p_texture) {
- if (texture==p_texture)
+ if (texture == p_texture)
return;
- texture=p_texture;
+ texture = p_texture;
emit_signal("texture_changed");
emit_changed();
-
}
RES StyleBoxTexture::get_texture() const {
return texture;
}
-void StyleBoxTexture::set_margin_size(Margin p_margin,float p_size) {
+void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) {
- margin[p_margin]=p_size;
+ margin[p_margin] = p_size;
emit_changed();
-
}
float StyleBoxTexture::get_margin_size(Margin p_margin) const {
@@ -132,23 +125,22 @@ float StyleBoxTexture::get_style_margin(Margin p_margin) const {
return margin[p_margin];
}
-void StyleBoxTexture::draw(RID p_canvas_item,const Rect2& p_rect) const {
+void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const {
if (texture.is_null())
return;
- Rect2 r=p_rect;
- r.pos.x-=expand_margin[MARGIN_LEFT];
- r.pos.y-=expand_margin[MARGIN_TOP];
- r.size.x+=expand_margin[MARGIN_LEFT]+expand_margin[MARGIN_RIGHT];
- r.size.y+=expand_margin[MARGIN_TOP]+expand_margin[MARGIN_BOTTOM];
- VisualServer::get_singleton()->canvas_item_add_style_box( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center);
+ Rect2 r = p_rect;
+ r.pos.x -= expand_margin[MARGIN_LEFT];
+ r.pos.y -= expand_margin[MARGIN_TOP];
+ r.size.x += expand_margin[MARGIN_LEFT] + expand_margin[MARGIN_RIGHT];
+ r.size.y += expand_margin[MARGIN_TOP] + expand_margin[MARGIN_BOTTOM];
+ VisualServer::get_singleton()->canvas_item_add_style_box(p_canvas_item, r, region_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), draw_center);
}
void StyleBoxTexture::set_draw_center(bool p_draw) {
- draw_center=p_draw;
+ draw_center = p_draw;
emit_changed();
-
}
bool StyleBoxTexture::get_draw_center() const {
@@ -164,26 +156,25 @@ Size2 StyleBoxTexture::get_center_size() const {
return texture->get_size() - get_minimum_size();
}
-void StyleBoxTexture::set_expand_margin_size(Margin p_expand_margin,float p_size) {
+void StyleBoxTexture::set_expand_margin_size(Margin p_expand_margin, float p_size) {
- ERR_FAIL_INDEX(p_expand_margin,4);
- expand_margin[p_expand_margin]=p_size;
+ ERR_FAIL_INDEX(p_expand_margin, 4);
+ expand_margin[p_expand_margin] = p_size;
emit_changed();
-
}
float StyleBoxTexture::get_expand_margin_size(Margin p_expand_margin) const {
- ERR_FAIL_INDEX_V(p_expand_margin,4,0);
+ ERR_FAIL_INDEX_V(p_expand_margin, 4, 0);
return expand_margin[p_expand_margin];
}
-void StyleBoxTexture::set_region_rect(const Rect2& p_region_rect) {
+void StyleBoxTexture::set_region_rect(const Rect2 &p_region_rect) {
- if (region_rect==p_region_rect)
+ if (region_rect == p_region_rect)
return;
- region_rect=p_region_rect;
+ region_rect = p_region_rect;
emit_changed();
}
@@ -192,75 +183,66 @@ Rect2 StyleBoxTexture::get_region_rect() const {
return region_rect;
}
-
void StyleBoxTexture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture:Texture"),&StyleBoxTexture::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture"),&StyleBoxTexture::get_texture);
+ ObjectTypeDB::bind_method(_MD("set_texture", "texture:Texture"), &StyleBoxTexture::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture"), &StyleBoxTexture::get_texture);
- ObjectTypeDB::bind_method(_MD("set_margin_size","margin","size"),&StyleBoxTexture::set_margin_size);
- ObjectTypeDB::bind_method(_MD("get_margin_size","margin"),&StyleBoxTexture::get_margin_size);
+ ObjectTypeDB::bind_method(_MD("set_margin_size", "margin", "size"), &StyleBoxTexture::set_margin_size);
+ ObjectTypeDB::bind_method(_MD("get_margin_size", "margin"), &StyleBoxTexture::get_margin_size);
- ObjectTypeDB::bind_method(_MD("set_expand_margin_size","margin","size"),&StyleBoxTexture::set_expand_margin_size);
- ObjectTypeDB::bind_method(_MD("get_expand_margin_size","margin"),&StyleBoxTexture::get_expand_margin_size);
+ ObjectTypeDB::bind_method(_MD("set_expand_margin_size", "margin", "size"), &StyleBoxTexture::set_expand_margin_size);
+ ObjectTypeDB::bind_method(_MD("get_expand_margin_size", "margin"), &StyleBoxTexture::get_expand_margin_size);
- ObjectTypeDB::bind_method(_MD("set_region_rect","region"),&StyleBoxTexture::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&StyleBoxTexture::get_region_rect);
+ ObjectTypeDB::bind_method(_MD("set_region_rect", "region"), &StyleBoxTexture::set_region_rect);
+ ObjectTypeDB::bind_method(_MD("get_region_rect"), &StyleBoxTexture::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_draw_center","enable"),&StyleBoxTexture::set_draw_center);
- ObjectTypeDB::bind_method(_MD("get_draw_center"),&StyleBoxTexture::get_draw_center);
+ ObjectTypeDB::bind_method(_MD("set_draw_center", "enable"), &StyleBoxTexture::set_draw_center);
+ ObjectTypeDB::bind_method(_MD("get_draw_center"), &StyleBoxTexture::get_draw_center);
ADD_SIGNAL(MethodInfo("texture_changed"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin/left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_TOP);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_margin_size"),_SCS("get_margin_size"), MARGIN_BOTTOM );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "draw_center" ) , _SCS("set_draw_center"),_SCS("get_draw_center"));
-
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"), _SCS("get_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::RECT2, "region_rect"), _SCS("set_region_rect"), _SCS("get_region_rect"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "margin/left", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_margin_size"), _SCS("get_margin_size"), MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "margin/right", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_margin_size"), _SCS("get_margin_size"), MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "margin/top", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_margin_size"), _SCS("get_margin_size"), MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "margin/bottom", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_margin_size"), _SCS("get_margin_size"), MARGIN_BOTTOM);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin/left", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_expand_margin_size"), _SCS("get_expand_margin_size"), MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_expand_margin_size"), _SCS("get_expand_margin_size"), MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_expand_margin_size"), _SCS("get_expand_margin_size"), MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_expand_margin_size"), _SCS("get_expand_margin_size"), MARGIN_BOTTOM);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_center"), _SCS("set_draw_center"), _SCS("get_draw_center"));
}
StyleBoxTexture::StyleBoxTexture() {
-
- for (int i=0;i<4;i++) {
- margin[i]=0;
- expand_margin[i]=0;
+ for (int i = 0; i < 4; i++) {
+ margin[i] = 0;
+ expand_margin[i] = 0;
}
- draw_center=true;
-
+ draw_center = true;
}
StyleBoxTexture::~StyleBoxTexture() {
-
-
}
////////////////
-void StyleBoxFlat::set_bg_color(const Color& p_color) {
+void StyleBoxFlat::set_bg_color(const Color &p_color) {
- bg_color=p_color;
+ bg_color = p_color;
emit_changed();
-
}
-void StyleBoxFlat::set_light_color(const Color& p_color) {
+void StyleBoxFlat::set_light_color(const Color &p_color) {
- light_color=p_color;
+ light_color = p_color;
emit_changed();
-
}
-void StyleBoxFlat::set_dark_color(const Color& p_color) {
+void StyleBoxFlat::set_dark_color(const Color &p_color) {
- dark_color=p_color;
+ dark_color = p_color;
emit_changed();
-
}
Color StyleBoxFlat::get_bg_color() const {
@@ -276,37 +258,31 @@ Color StyleBoxFlat::get_dark_color() const {
return dark_color;
}
-
void StyleBoxFlat::set_border_size(int p_size) {
- border_size=p_size;
+ border_size = p_size;
emit_changed();
-
}
int StyleBoxFlat::get_border_size() const {
return border_size;
-
}
void StyleBoxFlat::set_border_blend(bool p_blend) {
- blend=p_blend;
+ blend = p_blend;
emit_changed();
-
}
bool StyleBoxFlat::get_border_blend() const {
return blend;
-
}
void StyleBoxFlat::set_draw_center(bool p_draw) {
- draw_center=p_draw;
+ draw_center = p_draw;
emit_changed();
-
}
bool StyleBoxFlat::get_draw_center() const {
@@ -317,48 +293,41 @@ Size2 StyleBoxFlat::get_center_size() const {
return Size2();
}
-
-void StyleBoxFlat::draw(RID p_canvas_item,const Rect2& p_rect) const {
+void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
VisualServer *vs = VisualServer::get_singleton();
Rect2i r = p_rect;
- for (int i=0;i<border_size;i++) {
-
+ for (int i = 0; i < border_size; i++) {
-
- Color color_upleft=light_color;
- Color color_downright=dark_color;
+ Color color_upleft = light_color;
+ Color color_downright = dark_color;
if (blend) {
- color_upleft.r=(border_size-i)*color_upleft.r/border_size + i*bg_color.r/border_size;
- color_upleft.g=(border_size-i)*color_upleft.g/border_size + i*bg_color.g/border_size;
- color_upleft.b=(border_size-i)*color_upleft.b/border_size + i*bg_color.b/border_size;
-
- color_downright.r=(border_size-i)*color_downright.r/border_size + i*bg_color.r/border_size;
- color_downright.g=(border_size-i)*color_downright.g/border_size + i*bg_color.g/border_size;
- color_downright.b=(border_size-i)*color_downright.b/border_size + i*bg_color.b/border_size;
+ color_upleft.r = (border_size - i) * color_upleft.r / border_size + i * bg_color.r / border_size;
+ color_upleft.g = (border_size - i) * color_upleft.g / border_size + i * bg_color.g / border_size;
+ color_upleft.b = (border_size - i) * color_upleft.b / border_size + i * bg_color.b / border_size;
+ color_downright.r = (border_size - i) * color_downright.r / border_size + i * bg_color.r / border_size;
+ color_downright.g = (border_size - i) * color_downright.g / border_size + i * bg_color.g / border_size;
+ color_downright.b = (border_size - i) * color_downright.b / border_size + i * bg_color.b / border_size;
}
- vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i( r.pos.x,r.pos.y+r.size.y-1), Size2(r.size.x ,1 )),color_downright);
- vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i( r.pos.x+r.size.x-1,r.pos.y ), Size2( 1 ,r.size.y )), color_downright);
-
- vs->canvas_item_add_rect(p_canvas_item, Rect2( r.pos, Size2(r.size.x ,1 )), color_upleft);
- vs->canvas_item_add_rect(p_canvas_item, Rect2( r.pos, Size2( 1 ,r.size.y )), color_upleft);
+ vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r.pos.x, r.pos.y + r.size.y - 1), Size2(r.size.x, 1)), color_downright);
+ vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r.pos.x + r.size.x - 1, r.pos.y), Size2(1, r.size.y)), color_downright);
+ vs->canvas_item_add_rect(p_canvas_item, Rect2(r.pos, Size2(r.size.x, 1)), color_upleft);
+ vs->canvas_item_add_rect(p_canvas_item, Rect2(r.pos, Size2(1, r.size.y)), color_upleft);
r.pos.x++;
r.pos.y++;
- r.size.x-=2;
- r.size.y-=2;
+ r.size.x -= 2;
+ r.size.y -= 2;
}
if (draw_center)
- vs->canvas_item_add_rect(p_canvas_item, Rect2( r.pos, r.size) , bg_color );
-
-
+ vs->canvas_item_add_rect(p_canvas_item, Rect2(r.pos, r.size), bg_color);
}
float StyleBoxFlat::get_style_margin(Margin p_margin) const {
@@ -367,164 +336,150 @@ float StyleBoxFlat::get_style_margin(Margin p_margin) const {
}
void StyleBoxFlat::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_bg_color","color"),&StyleBoxFlat::set_bg_color);
- ObjectTypeDB::bind_method(_MD("get_bg_color"),&StyleBoxFlat::get_bg_color);
- ObjectTypeDB::bind_method(_MD("set_light_color","color"),&StyleBoxFlat::set_light_color);
- ObjectTypeDB::bind_method(_MD("get_light_color"),&StyleBoxFlat::get_light_color);
- ObjectTypeDB::bind_method(_MD("set_dark_color","color"),&StyleBoxFlat::set_dark_color);
- ObjectTypeDB::bind_method(_MD("get_dark_color"),&StyleBoxFlat::get_dark_color);
- ObjectTypeDB::bind_method(_MD("set_border_size","size"),&StyleBoxFlat::set_border_size);
- ObjectTypeDB::bind_method(_MD("get_border_size"),&StyleBoxFlat::get_border_size);
- ObjectTypeDB::bind_method(_MD("set_border_blend","blend"),&StyleBoxFlat::set_border_blend);
- ObjectTypeDB::bind_method(_MD("get_border_blend"),&StyleBoxFlat::get_border_blend);
- ObjectTypeDB::bind_method(_MD("set_draw_center","size"),&StyleBoxFlat::set_draw_center);
- ObjectTypeDB::bind_method(_MD("get_draw_center"),&StyleBoxFlat::get_draw_center);
-
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "bg_color"), _SCS("set_bg_color"),_SCS("get_bg_color") );
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "light_color"),_SCS("set_light_color"),_SCS("get_light_color"));
- ADD_PROPERTY( PropertyInfo( Variant::COLOR, "dark_color"),_SCS("set_dark_color"),_SCS("get_dark_color"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "border_size",PROPERTY_HINT_RANGE,"0,4096"),_SCS("set_border_size"),_SCS("get_border_size"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "border_blend"),_SCS("set_border_blend"),_SCS("get_border_blend"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "draw_bg"),_SCS("set_draw_center"),_SCS("get_draw_center"));
+ ObjectTypeDB::bind_method(_MD("set_bg_color", "color"), &StyleBoxFlat::set_bg_color);
+ ObjectTypeDB::bind_method(_MD("get_bg_color"), &StyleBoxFlat::get_bg_color);
+ ObjectTypeDB::bind_method(_MD("set_light_color", "color"), &StyleBoxFlat::set_light_color);
+ ObjectTypeDB::bind_method(_MD("get_light_color"), &StyleBoxFlat::get_light_color);
+ ObjectTypeDB::bind_method(_MD("set_dark_color", "color"), &StyleBoxFlat::set_dark_color);
+ ObjectTypeDB::bind_method(_MD("get_dark_color"), &StyleBoxFlat::get_dark_color);
+ ObjectTypeDB::bind_method(_MD("set_border_size", "size"), &StyleBoxFlat::set_border_size);
+ ObjectTypeDB::bind_method(_MD("get_border_size"), &StyleBoxFlat::get_border_size);
+ ObjectTypeDB::bind_method(_MD("set_border_blend", "blend"), &StyleBoxFlat::set_border_blend);
+ ObjectTypeDB::bind_method(_MD("get_border_blend"), &StyleBoxFlat::get_border_blend);
+ ObjectTypeDB::bind_method(_MD("set_draw_center", "size"), &StyleBoxFlat::set_draw_center);
+ ObjectTypeDB::bind_method(_MD("get_draw_center"), &StyleBoxFlat::get_draw_center);
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "bg_color"), _SCS("set_bg_color"), _SCS("get_bg_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), _SCS("set_light_color"), _SCS("get_light_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "dark_color"), _SCS("set_dark_color"), _SCS("get_dark_color"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "border_size", PROPERTY_HINT_RANGE, "0,4096"), _SCS("set_border_size"), _SCS("get_border_size"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "border_blend"), _SCS("set_border_blend"), _SCS("get_border_blend"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_bg"), _SCS("set_draw_center"), _SCS("get_draw_center"));
}
StyleBoxFlat::StyleBoxFlat() {
- bg_color=Color(0.6,0.6,0.6);
- light_color=Color(0.8,0.8,0.8);
- dark_color=Color(0.8,0.8,0.8);
- draw_center=true;
- blend=true;
- border_size=0;
-
+ bg_color = Color(0.6, 0.6, 0.6);
+ light_color = Color(0.8, 0.8, 0.8);
+ dark_color = Color(0.8, 0.8, 0.8);
+ draw_center = true;
+ blend = true;
+ border_size = 0;
}
StyleBoxFlat::~StyleBoxFlat() {
-
-
}
////////////////
-
-
void StyleBoxImageMask::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_image","image"),&StyleBoxImageMask::set_image);
- ObjectTypeDB::bind_method(_MD("get_image"),&StyleBoxImageMask::get_image);
- ObjectTypeDB::bind_method(_MD("set_expand","expand"),&StyleBoxImageMask::set_expand);
- ObjectTypeDB::bind_method(_MD("get_expand"),&StyleBoxImageMask::get_expand);
- ObjectTypeDB::bind_method(_MD("set_expand_margin_size","margin","size"),&StyleBoxImageMask::set_expand_margin_size);
- ObjectTypeDB::bind_method(_MD("get_expand_margin_size","margin"),&StyleBoxImageMask::get_expand_margin_size);
-
- ADD_PROPERTY( PropertyInfo(Variant::IMAGE, "image"), _SCS("set_image"), _SCS("get_image"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "expand"), _SCS("set_expand"), _SCS("get_expand"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
+ ObjectTypeDB::bind_method(_MD("set_image", "image"), &StyleBoxImageMask::set_image);
+ ObjectTypeDB::bind_method(_MD("get_image"), &StyleBoxImageMask::get_image);
+ ObjectTypeDB::bind_method(_MD("set_expand", "expand"), &StyleBoxImageMask::set_expand);
+ ObjectTypeDB::bind_method(_MD("get_expand"), &StyleBoxImageMask::get_expand);
+ ObjectTypeDB::bind_method(_MD("set_expand_margin_size", "margin", "size"), &StyleBoxImageMask::set_expand_margin_size);
+ ObjectTypeDB::bind_method(_MD("get_expand_margin_size", "margin"), &StyleBoxImageMask::get_expand_margin_size);
+ ADD_PROPERTY(PropertyInfo(Variant::IMAGE, "image"), _SCS("set_image"), _SCS("get_image"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), _SCS("set_expand"), _SCS("get_expand"));
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin/left", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_expand_margin_size"), _SCS("get_expand_margin_size"), MARGIN_LEFT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_expand_margin_size"), _SCS("get_expand_margin_size"), MARGIN_RIGHT);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_expand_margin_size"), _SCS("get_expand_margin_size"), MARGIN_TOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE, "0,2048,1"), _SCS("set_expand_margin_size"), _SCS("get_expand_margin_size"), MARGIN_BOTTOM);
}
-
-bool StyleBoxImageMask::test_mask(const Point2& p_point, const Rect2& p_rect) const {
+bool StyleBoxImageMask::test_mask(const Point2 &p_point, const Rect2 &p_rect) const {
if (image.empty())
return false;
- if (p_rect.size.x<1)
+ if (p_rect.size.x < 1)
return false;
- if (p_rect.size.y<1)
+ if (p_rect.size.y < 1)
return false;
- Size2i imgsize(image.get_width(),image.get_height());
- if (imgsize.x<=0 || imgsize.y<=0)
+ Size2i imgsize(image.get_width(), image.get_height());
+ if (imgsize.x <= 0 || imgsize.y <= 0)
return false;
- Point2i img_expand_size( imgsize.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], imgsize.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
- Point2i rect_expand_size( p_rect.size.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], p_rect.size.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
- if (rect_expand_size.x<1)
- rect_expand_size.x=1;
- if (rect_expand_size.y<1)
- rect_expand_size.y=1;
-
+ Point2i img_expand_size(imgsize.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], imgsize.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
+ Point2i rect_expand_size(p_rect.size.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], p_rect.size.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
+ if (rect_expand_size.x < 1)
+ rect_expand_size.x = 1;
+ if (rect_expand_size.y < 1)
+ rect_expand_size.y = 1;
Point2i click_pos;
-
//treat x
- if (p_point.x<p_rect.pos.x)
- click_pos.x=0;
+ if (p_point.x < p_rect.pos.x)
+ click_pos.x = 0;
else if (expand) {
- if (p_point.x>=p_rect.pos.x+p_rect.size.x)
- click_pos.x=imgsize.x-1;
- else if ((p_point.x-p_rect.pos.x)<expand_margin[MARGIN_LEFT])
- click_pos.x=p_point.x;
- else if ((p_point.x-(p_rect.pos.x+p_rect.size.x))<expand_margin[MARGIN_RIGHT])
- click_pos.x=imgsize.x-(p_point.x-(p_rect.pos.x+p_rect.size.x));
- else //expand
- click_pos.x=(p_point.x-p_rect.pos.x-expand_margin[MARGIN_LEFT])*img_expand_size.x/rect_expand_size.x;
- } else if ((p_point.x-p_rect.pos.x) > imgsize.x)
- click_pos.x=imgsize.x;
+ if (p_point.x >= p_rect.pos.x + p_rect.size.x)
+ click_pos.x = imgsize.x - 1;
+ else if ((p_point.x - p_rect.pos.x) < expand_margin[MARGIN_LEFT])
+ click_pos.x = p_point.x;
+ else if ((p_point.x - (p_rect.pos.x + p_rect.size.x)) < expand_margin[MARGIN_RIGHT])
+ click_pos.x = imgsize.x - (p_point.x - (p_rect.pos.x + p_rect.size.x));
+ else //expand
+ click_pos.x = (p_point.x - p_rect.pos.x - expand_margin[MARGIN_LEFT]) * img_expand_size.x / rect_expand_size.x;
+ } else if ((p_point.x - p_rect.pos.x) > imgsize.x)
+ click_pos.x = imgsize.x;
//treat y
- if (p_point.y<p_rect.pos.y)
- click_pos.y=0;
+ if (p_point.y < p_rect.pos.y)
+ click_pos.y = 0;
else if (expand) {
- if (p_point.y>=p_rect.pos.y+p_rect.size.y)
- click_pos.y=imgsize.y-1;
- else if ((p_point.y-p_rect.pos.y)<expand_margin[MARGIN_TOP])
- click_pos.y=p_point.y;
- else if ((p_point.y-(p_rect.pos.y+p_rect.size.y))<expand_margin[MARGIN_BOTTOM])
- click_pos.y=imgsize.y-(p_point.y-(p_rect.pos.y+p_rect.size.y));
- else //expand
- click_pos.y=(p_point.y-p_rect.pos.y-expand_margin[MARGIN_TOP])*img_expand_size.y/rect_expand_size.y;
- } else if ((p_point.y-p_rect.pos.y) > imgsize.y)
- click_pos.y=imgsize.y;
-
- return image.get_pixel(click_pos.x,click_pos.y).gray()>0.5;
+ if (p_point.y >= p_rect.pos.y + p_rect.size.y)
+ click_pos.y = imgsize.y - 1;
+ else if ((p_point.y - p_rect.pos.y) < expand_margin[MARGIN_TOP])
+ click_pos.y = p_point.y;
+ else if ((p_point.y - (p_rect.pos.y + p_rect.size.y)) < expand_margin[MARGIN_BOTTOM])
+ click_pos.y = imgsize.y - (p_point.y - (p_rect.pos.y + p_rect.size.y));
+ else //expand
+ click_pos.y = (p_point.y - p_rect.pos.y - expand_margin[MARGIN_TOP]) * img_expand_size.y / rect_expand_size.y;
+ } else if ((p_point.y - p_rect.pos.y) > imgsize.y)
+ click_pos.y = imgsize.y;
+ return image.get_pixel(click_pos.x, click_pos.y).gray() > 0.5;
}
+void StyleBoxImageMask::set_image(const Image &p_image) {
-void StyleBoxImageMask::set_image(const Image& p_image) {
-
- image=p_image;
+ image = p_image;
}
Image StyleBoxImageMask::get_image() const {
return image;
}
-
void StyleBoxImageMask::set_expand(bool p_expand) {
- expand=p_expand;
+ expand = p_expand;
}
bool StyleBoxImageMask::get_expand() const {
return expand;
}
-void StyleBoxImageMask::set_expand_margin_size(Margin p_expand_margin,float p_size) {
+void StyleBoxImageMask::set_expand_margin_size(Margin p_expand_margin, float p_size) {
- ERR_FAIL_INDEX(p_expand_margin,4);
- expand_margin[p_expand_margin]=p_size;
+ ERR_FAIL_INDEX(p_expand_margin, 4);
+ expand_margin[p_expand_margin] = p_size;
}
-
float StyleBoxImageMask::get_expand_margin_size(Margin p_expand_margin) const {
- ERR_FAIL_INDEX_V(p_expand_margin,4,0);
+ ERR_FAIL_INDEX_V(p_expand_margin, 4, 0);
return expand_margin[p_expand_margin];
}
StyleBoxImageMask::StyleBoxImageMask() {
- for (int i=0;i<4;i++) {
- expand_margin[i]=0;
+ for (int i = 0; i < 4; i++) {
+ expand_margin[i] = 0;
}
- expand=true;
+ expand = true;
}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index 22ae67cfe..fb44c073f 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -30,32 +30,31 @@
#define STYLE_BOX_H
#include "resource.h"
-#include "servers/visual_server.h"
#include "scene/resources/texture.h"
+#include "servers/visual_server.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class StyleBox : public Resource {
- OBJ_TYPE( StyleBox, Resource );
+ OBJ_TYPE(StyleBox, Resource);
RES_BASE_EXTENSION("sbx");
- OBJ_SAVE_TYPE( StyleBox );
+ OBJ_SAVE_TYPE(StyleBox);
float margin[4];
protected:
-
- virtual float get_style_margin(Margin p_margin) const=0;
+ virtual float get_style_margin(Margin p_margin) const = 0;
static void _bind_methods();
-public:
- virtual bool test_mask(const Point2& p_point, const Rect2& p_rect) const;
+public:
+ virtual bool test_mask(const Point2 &p_point, const Rect2 &p_rect) const;
void set_default_margin(Margin p_margin, float p_value);
float get_default_margin(Margin p_margin) const;
float get_margin(Margin p_margin) const;
virtual Size2 get_center_size() const;
- virtual void draw(RID p_canvas_item,const Rect2& p_rect) const=0;
+ virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const = 0;
Size2 get_minimum_size() const;
Point2 get_offset() const;
@@ -65,19 +64,17 @@ public:
class StyleBoxEmpty : public StyleBox {
- OBJ_TYPE( StyleBoxEmpty, StyleBox );
+ OBJ_TYPE(StyleBoxEmpty, StyleBox);
virtual float get_style_margin(Margin p_margin) const { return 0; }
-public:
- virtual void draw(RID p_canvas_item,const Rect2& p_rect) const {}
+public:
+ virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const {}
StyleBoxEmpty() {}
-
};
class StyleBoxTexture : public StyleBox {
- OBJ_TYPE( StyleBoxTexture, StyleBox );
-
+ OBJ_TYPE(StyleBoxTexture, StyleBox);
float expand_margin[4];
float margin[4];
@@ -85,21 +82,18 @@ class StyleBoxTexture : public StyleBox {
Ref<Texture> texture;
bool draw_center;
-
protected:
-
virtual float get_style_margin(Margin p_margin) const;
static void _bind_methods();
public:
-
- void set_expand_margin_size(Margin p_expand_margin,float p_size);
+ void set_expand_margin_size(Margin p_expand_margin, float p_size);
float get_expand_margin_size(Margin p_expand_margin) const;
- void set_margin_size(Margin p_margin,float p_size);
+ void set_margin_size(Margin p_margin, float p_size);
float get_margin_size(Margin p_margin) const;
- void set_region_rect(const Rect2& p_region_rect);
+ void set_region_rect(const Rect2 &p_region_rect);
Rect2 get_region_rect() const;
void set_texture(RES p_texture);
@@ -109,17 +103,15 @@ public:
bool get_draw_center() const;
virtual Size2 get_center_size() const;
-
- virtual void draw(RID p_canvas_item,const Rect2& p_rect) const;
+ virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
StyleBoxTexture();
~StyleBoxTexture();
-
};
class StyleBoxFlat : public StyleBox {
- OBJ_TYPE( StyleBoxFlat, StyleBox );
+ OBJ_TYPE(StyleBoxFlat, StyleBox);
Color bg_color;
Color light_color;
@@ -131,15 +123,13 @@ class StyleBoxFlat : public StyleBox {
bool blend;
protected:
-
virtual float get_style_margin(Margin p_margin) const;
static void _bind_methods();
public:
-
- void set_bg_color(const Color& p_color);
- void set_light_color(const Color& p_color);
- void set_dark_color(const Color& p_color);
+ void set_bg_color(const Color &p_color);
+ void set_light_color(const Color &p_color);
+ void set_dark_color(const Color &p_color);
Color get_bg_color() const;
Color get_light_color() const;
@@ -155,17 +145,15 @@ public:
bool get_draw_center() const;
virtual Size2 get_center_size() const;
- virtual void draw(RID p_canvas_item,const Rect2& p_rect) const;
+ virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const;
StyleBoxFlat();
~StyleBoxFlat();
-
};
-
class StyleBoxImageMask : public StyleBox {
- OBJ_TYPE( StyleBoxImageMask, StyleBox );
+ OBJ_TYPE(StyleBoxImageMask, StyleBox);
virtual float get_style_margin(Margin p_margin) const { return 0; }
Image image;
@@ -173,25 +161,21 @@ class StyleBoxImageMask : public StyleBox {
bool expand;
protected:
-
static void _bind_methods();
public:
+ virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const {}
+ virtual bool test_mask(const Point2 &p_point, const Rect2 &p_rect) const;
- virtual void draw(RID p_canvas_item,const Rect2& p_rect) const {}
- virtual bool test_mask(const Point2& p_point, const Rect2& p_rect) const;
-
- void set_image(const Image& p_image);
+ void set_image(const Image &p_image);
Image get_image() const;
void set_expand(bool p_expand);
bool get_expand() const;
- void set_expand_margin_size(Margin p_expand_margin,float p_size);
+ void set_expand_margin_size(Margin p_expand_margin, float p_size);
float get_expand_margin_size(Margin p_expand_margin) const;
StyleBoxImageMask();
-
};
-
#endif
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index e48616754..556213317 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -32,56 +32,53 @@
#define _VERTEX_SNAP 0.0001
#define EQ_VERTEX_DIST 0.00001
+bool SurfaceTool::Vertex::operator==(const Vertex &p_b) const {
-bool SurfaceTool::Vertex::operator==(const Vertex& p_b) const {
-
-
- if (vertex!=p_b.vertex)
+ if (vertex != p_b.vertex)
return false;
- if (uv!=p_b.uv)
+ if (uv != p_b.uv)
return false;
- if (uv2!=p_b.uv2)
+ if (uv2 != p_b.uv2)
return false;
- if (normal!=p_b.normal)
+ if (normal != p_b.normal)
return false;
- if (binormal!=p_b.binormal)
+ if (binormal != p_b.binormal)
return false;
- if (color!=p_b.color)
+ if (color != p_b.color)
return false;
- if (bones.size()!=p_b.bones.size())
+ if (bones.size() != p_b.bones.size())
return false;
- for(int i=0;i<bones.size();i++) {
- if (bones[i]!=p_b.bones[i])
+ for (int i = 0; i < bones.size(); i++) {
+ if (bones[i] != p_b.bones[i])
return false;
}
- for(int i=0;i<weights.size();i++) {
- if (weights[i]!=p_b.weights[i])
+ for (int i = 0; i < weights.size(); i++) {
+ if (weights[i] != p_b.weights[i])
return false;
}
return true;
}
-
uint32_t SurfaceTool::VertexHasher::hash(const Vertex &p_vtx) {
- uint32_t h = hash_djb2_buffer((const uint8_t*)&p_vtx.vertex,sizeof(real_t)*3);
- h = hash_djb2_buffer((const uint8_t*)&p_vtx.normal,sizeof(real_t)*3,h);
- h = hash_djb2_buffer((const uint8_t*)&p_vtx.binormal,sizeof(real_t)*3,h);
- h = hash_djb2_buffer((const uint8_t*)&p_vtx.tangent,sizeof(real_t)*3,h);
- h = hash_djb2_buffer((const uint8_t*)&p_vtx.uv,sizeof(real_t)*2,h);
- h = hash_djb2_buffer((const uint8_t*)&p_vtx.uv2,sizeof(real_t)*2,h);
- h = hash_djb2_buffer((const uint8_t*)&p_vtx.color,sizeof(real_t)*4,h);
- h = hash_djb2_buffer((const uint8_t*)p_vtx.bones.ptr(),p_vtx.bones.size()*sizeof(int),h);
- h = hash_djb2_buffer((const uint8_t*)p_vtx.weights.ptr(),p_vtx.weights.size()*sizeof(float),h);
+ uint32_t h = hash_djb2_buffer((const uint8_t *)&p_vtx.vertex, sizeof(real_t) * 3);
+ h = hash_djb2_buffer((const uint8_t *)&p_vtx.normal, sizeof(real_t) * 3, h);
+ h = hash_djb2_buffer((const uint8_t *)&p_vtx.binormal, sizeof(real_t) * 3, h);
+ h = hash_djb2_buffer((const uint8_t *)&p_vtx.tangent, sizeof(real_t) * 3, h);
+ h = hash_djb2_buffer((const uint8_t *)&p_vtx.uv, sizeof(real_t) * 2, h);
+ h = hash_djb2_buffer((const uint8_t *)&p_vtx.uv2, sizeof(real_t) * 2, h);
+ h = hash_djb2_buffer((const uint8_t *)&p_vtx.color, sizeof(real_t) * 4, h);
+ h = hash_djb2_buffer((const uint8_t *)p_vtx.bones.ptr(), p_vtx.bones.size() * sizeof(int), h);
+ h = hash_djb2_buffer((const uint8_t *)p_vtx.weights.ptr(), p_vtx.weights.size() * sizeof(float), h);
return h;
}
@@ -89,165 +86,154 @@ void SurfaceTool::begin(Mesh::PrimitiveType p_primitive) {
clear();
- primitive=p_primitive;
- begun=true;
- first=true;
+ primitive = p_primitive;
+ begun = true;
+ first = true;
}
-void SurfaceTool::add_vertex( const Vector3& p_vertex) {
+void SurfaceTool::add_vertex(const Vector3 &p_vertex) {
ERR_FAIL_COND(!begun);
Vertex vtx;
- vtx.vertex=p_vertex;
- vtx.color=last_color;
- vtx.normal=last_normal;
- vtx.uv=last_uv;
- vtx.weights=last_weights;
- vtx.bones=last_bones;
- vtx.tangent=last_tangent.normal;
- vtx.binormal=last_normal.cross(last_tangent.normal).normalized() * last_tangent.d;
+ vtx.vertex = p_vertex;
+ vtx.color = last_color;
+ vtx.normal = last_normal;
+ vtx.uv = last_uv;
+ vtx.weights = last_weights;
+ vtx.bones = last_bones;
+ vtx.tangent = last_tangent.normal;
+ vtx.binormal = last_normal.cross(last_tangent.normal).normalized() * last_tangent.d;
vertex_array.push_back(vtx);
- first=false;
- format|=Mesh::ARRAY_FORMAT_VERTEX;
-
+ first = false;
+ format |= Mesh::ARRAY_FORMAT_VERTEX;
}
-void SurfaceTool::add_color( Color p_color ) {
+void SurfaceTool::add_color(Color p_color) {
ERR_FAIL_COND(!begun);
- ERR_FAIL_COND( !first && !(format&Mesh::ARRAY_FORMAT_COLOR));
+ ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_COLOR));
- format|=Mesh::ARRAY_FORMAT_COLOR;
- last_color=p_color;
+ format |= Mesh::ARRAY_FORMAT_COLOR;
+ last_color = p_color;
}
-void SurfaceTool::add_normal( const Vector3& p_normal) {
+void SurfaceTool::add_normal(const Vector3 &p_normal) {
ERR_FAIL_COND(!begun);
- ERR_FAIL_COND( !first && !(format&Mesh::ARRAY_FORMAT_NORMAL));
+ ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_NORMAL));
- format|=Mesh::ARRAY_FORMAT_NORMAL;
- last_normal=p_normal;
+ format |= Mesh::ARRAY_FORMAT_NORMAL;
+ last_normal = p_normal;
}
-
-void SurfaceTool::add_tangent( const Plane& p_tangent ) {
+void SurfaceTool::add_tangent(const Plane &p_tangent) {
ERR_FAIL_COND(!begun);
- ERR_FAIL_COND( !first && !(format&Mesh::ARRAY_FORMAT_TANGENT));
-
- format|=Mesh::ARRAY_FORMAT_TANGENT;
- last_tangent=p_tangent;
-
+ ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_TANGENT));
+ format |= Mesh::ARRAY_FORMAT_TANGENT;
+ last_tangent = p_tangent;
}
-
-void SurfaceTool::add_uv( const Vector2& p_uv) {
+void SurfaceTool::add_uv(const Vector2 &p_uv) {
ERR_FAIL_COND(!begun);
- ERR_FAIL_COND( !first && !(format&Mesh::ARRAY_FORMAT_TEX_UV));
-
- format|=Mesh::ARRAY_FORMAT_TEX_UV;
- last_uv=p_uv;
+ ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_TEX_UV));
+ format |= Mesh::ARRAY_FORMAT_TEX_UV;
+ last_uv = p_uv;
}
-void SurfaceTool::add_uv2( const Vector2& p_uv2) {
+void SurfaceTool::add_uv2(const Vector2 &p_uv2) {
ERR_FAIL_COND(!begun);
- ERR_FAIL_COND( !first && !(format&Mesh::ARRAY_FORMAT_TEX_UV2));
-
- format|=Mesh::ARRAY_FORMAT_TEX_UV2;
- last_uv2=p_uv2;
+ ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_TEX_UV2));
+ format |= Mesh::ARRAY_FORMAT_TEX_UV2;
+ last_uv2 = p_uv2;
}
-void SurfaceTool::add_bones( const Vector<int>& p_bones) {
+void SurfaceTool::add_bones(const Vector<int> &p_bones) {
ERR_FAIL_COND(!begun);
- ERR_FAIL_COND(p_bones.size()!=4);
- ERR_FAIL_COND( !first && !(format&Mesh::ARRAY_FORMAT_BONES));
+ ERR_FAIL_COND(p_bones.size() != 4);
+ ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_BONES));
- format|=Mesh::ARRAY_FORMAT_BONES;
- last_bones=p_bones;
+ format |= Mesh::ARRAY_FORMAT_BONES;
+ last_bones = p_bones;
}
-void SurfaceTool::add_weights( const Vector<float>& p_weights) {
+void SurfaceTool::add_weights(const Vector<float> &p_weights) {
ERR_FAIL_COND(!begun);
- ERR_FAIL_COND(p_weights.size()!=4);
- ERR_FAIL_COND( !first && !(format&Mesh::ARRAY_FORMAT_WEIGHTS));
-
- format|=Mesh::ARRAY_FORMAT_WEIGHTS;
- last_weights=p_weights;
+ ERR_FAIL_COND(p_weights.size() != 4);
+ ERR_FAIL_COND(!first && !(format & Mesh::ARRAY_FORMAT_WEIGHTS));
+ format |= Mesh::ARRAY_FORMAT_WEIGHTS;
+ last_weights = p_weights;
}
void SurfaceTool::add_smooth_group(bool p_smooth) {
ERR_FAIL_COND(!begun);
if (index_array.size()) {
- smooth_groups[index_array.size()]=p_smooth;
+ smooth_groups[index_array.size()] = p_smooth;
} else {
- smooth_groups[vertex_array.size()]=p_smooth;
+ smooth_groups[vertex_array.size()] = p_smooth;
}
}
-void SurfaceTool::add_triangle_fan(const Vector<Vector3>& p_vertexes, const Vector<Vector2>& p_uvs, const Vector<Color>& p_colors,const Vector<Vector2>& p_uv2s, const Vector<Vector3>& p_normals, const Vector<Plane>& p_tangents) {
+void SurfaceTool::add_triangle_fan(const Vector<Vector3> &p_vertexes, const Vector<Vector2> &p_uvs, const Vector<Color> &p_colors, const Vector<Vector2> &p_uv2s, const Vector<Vector3> &p_normals, const Vector<Plane> &p_tangents) {
ERR_FAIL_COND(!begun);
- ERR_FAIL_COND(primitive!=Mesh::PRIMITIVE_TRIANGLES);
- ERR_FAIL_COND(p_vertexes.size()<3);
+ ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES);
+ ERR_FAIL_COND(p_vertexes.size() < 3);
-#define ADD_POINT(n)\
- {\
- if(p_colors.size() > n)\
- add_color(p_colors[n]);\
- if(p_uvs.size() > n)\
- add_uv(p_uvs[n]);\
- if(p_uv2s.size() > n)\
- add_uv2(p_uv2s[n]);\
- if(p_normals.size() > n)\
- add_normal(p_normals[n]);\
- if(p_tangents.size() > n)\
- add_tangent(p_tangents[n]);\
- add_vertex(p_vertexes[n]);\
+#define ADD_POINT(n) \
+ { \
+ if (p_colors.size() > n) \
+ add_color(p_colors[n]); \
+ if (p_uvs.size() > n) \
+ add_uv(p_uvs[n]); \
+ if (p_uv2s.size() > n) \
+ add_uv2(p_uv2s[n]); \
+ if (p_normals.size() > n) \
+ add_normal(p_normals[n]); \
+ if (p_tangents.size() > n) \
+ add_tangent(p_tangents[n]); \
+ add_vertex(p_vertexes[n]); \
}
- for(int i=0;i<p_vertexes.size() - 2;i++) {
+ for (int i = 0; i < p_vertexes.size() - 2; i++) {
ADD_POINT(0);
- ADD_POINT(i+1);
- ADD_POINT(i+2);
+ ADD_POINT(i + 1);
+ ADD_POINT(i + 2);
}
#undef ADD_POINT
-
}
-void SurfaceTool::add_index( int p_index) {
+void SurfaceTool::add_index(int p_index) {
ERR_FAIL_COND(!begun);
- format|=Mesh::ARRAY_FORMAT_INDEX;
+ format |= Mesh::ARRAY_FORMAT_INDEX;
index_array.push_back(p_index);
}
-Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
-
+Ref<Mesh> SurfaceTool::commit(const Ref<Mesh> &p_existing) {
Ref<Mesh> mesh;
if (p_existing.is_valid())
- mesh=p_existing;
+ mesh = p_existing;
else
- mesh= Ref<Mesh>( memnew( Mesh ) );
+ mesh = Ref<Mesh>(memnew(Mesh));
- int varr_len=vertex_array.size();
+ int varr_len = vertex_array.size();
-
- if (varr_len==0)
+ if (varr_len == 0)
return mesh;
int surface = mesh->get_surface_count();
@@ -255,9 +241,9 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
Array a;
a.resize(Mesh::ARRAY_MAX);
- for (int i=0;i<Mesh::ARRAY_MAX;i++) {
+ for (int i = 0; i < Mesh::ARRAY_MAX; i++) {
- switch(format&(1<<i)) {
+ switch (format & (1 << i)) {
case Mesh::ARRAY_FORMAT_VERTEX:
case Mesh::ARRAY_FORMAT_NORMAL: {
@@ -266,24 +252,23 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
array.resize(varr_len);
DVector<Vector3>::Write w = array.write();
- int idx=0;
- for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) {
+ int idx = 0;
+ for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx++) {
- const Vertex &v=E->get();
+ const Vertex &v = E->get();
- switch(i) {
+ switch (i) {
case Mesh::ARRAY_VERTEX: {
- w[idx]=v.vertex;
+ w[idx] = v.vertex;
} break;
case Mesh::ARRAY_NORMAL: {
- w[idx]=v.normal;
+ w[idx] = v.normal;
} break;
}
-
}
- w=DVector<Vector3>::Write();
- a[i]=array;
+ w = DVector<Vector3>::Write();
+ a[i] = array;
} break;
@@ -294,125 +279,120 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
array.resize(varr_len);
DVector<Vector2>::Write w = array.write();
- int idx=0;
- for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) {
+ int idx = 0;
+ for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx++) {
- const Vertex &v=E->get();
+ const Vertex &v = E->get();
- switch(i) {
+ switch (i) {
case Mesh::ARRAY_TEX_UV: {
- w[idx]=v.uv;
+ w[idx] = v.uv;
} break;
case Mesh::ARRAY_TEX_UV2: {
- w[idx]=v.uv2;
+ w[idx] = v.uv2;
} break;
}
-
}
- w=DVector<Vector2>::Write();
- a[i]=array;
+ w = DVector<Vector2>::Write();
+ a[i] = array;
} break;
case Mesh::ARRAY_FORMAT_TANGENT: {
-
DVector<float> array;
- array.resize(varr_len*4);
+ array.resize(varr_len * 4);
DVector<float>::Write w = array.write();
- int idx=0;
- for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
+ int idx = 0;
+ for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx += 4) {
- const Vertex &v=E->get();
+ const Vertex &v = E->get();
- w[idx+0]=v.tangent.x;
- w[idx+1]=v.tangent.y;
- w[idx+2]=v.tangent.z;
+ w[idx + 0] = v.tangent.x;
+ w[idx + 1] = v.tangent.y;
+ w[idx + 2] = v.tangent.z;
//float d = v.tangent.dot(v.binormal,v.normal);
- float d = v.binormal.dot( v.normal.cross(v.tangent));
- w[idx+3]=d<0 ? -1 : 1;
+ float d = v.binormal.dot(v.normal.cross(v.tangent));
+ w[idx + 3] = d < 0 ? -1 : 1;
}
- w=DVector<float>::Write();
- a[i]=array;
+ w = DVector<float>::Write();
+ a[i] = array;
} break;
- case Mesh::ARRAY_FORMAT_COLOR: {
+ case Mesh::ARRAY_FORMAT_COLOR: {
DVector<Color> array;
array.resize(varr_len);
DVector<Color>::Write w = array.write();
- int idx=0;
- for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx++) {
+ int idx = 0;
+ for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx++) {
- const Vertex &v=E->get();
- w[idx]=v.color;
+ const Vertex &v = E->get();
+ w[idx] = v.color;
}
- w=DVector<Color>::Write();
- a[i]=array;
+ w = DVector<Color>::Write();
+ a[i] = array;
} break;
case Mesh::ARRAY_FORMAT_BONES:
case Mesh::ARRAY_FORMAT_WEIGHTS: {
-
DVector<float> array;
- array.resize(varr_len*4);
+ array.resize(varr_len * 4);
DVector<float>::Write w = array.write();
- int idx=0;
- for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
+ int idx = 0;
+ for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next(), idx += 4) {
- const Vertex &v=E->get();
+ const Vertex &v = E->get();
- for(int j=0;j<4;j++) {
- switch(i) {
+ for (int j = 0; j < 4; j++) {
+ switch (i) {
case Mesh::ARRAY_WEIGHTS: {
- ERR_CONTINUE( v.weights.size()!=4 );
- w[idx+j]=v.weights[j];
+ ERR_CONTINUE(v.weights.size() != 4);
+ w[idx + j] = v.weights[j];
} break;
case Mesh::ARRAY_BONES: {
- ERR_CONTINUE( v.bones.size()!=4 );
- w[idx+j]=v.bones[j];
+ ERR_CONTINUE(v.bones.size() != 4);
+ w[idx + j] = v.bones[j];
} break;
}
}
-
}
- w=DVector<float>::Write();
- a[i]=array;
+ w = DVector<float>::Write();
+ a[i] = array;
} break;
case Mesh::ARRAY_FORMAT_INDEX: {
- ERR_CONTINUE( index_array.size() ==0 );
+ ERR_CONTINUE(index_array.size() == 0);
DVector<int> array;
array.resize(index_array.size());
DVector<int>::Write w = array.write();
- int idx=0;
- for(List< int>::Element *E=index_array.front();E;E=E->next(),idx++) {
+ int idx = 0;
+ for (List<int>::Element *E = index_array.front(); E; E = E->next(), idx++) {
- w[idx]=E->get();
+ w[idx] = E->get();
}
- w=DVector<int>::Write();
- a[i]=array;
+ w = DVector<int>::Write();
+ a[i] = array;
} break;
default: {}
}
-
}
- mesh->add_surface(primitive,a);
+ mesh->add_surface(primitive, a);
if (material.is_valid())
- mesh->surface_set_material(surface,material);
+ mesh->surface_set_material(surface, material);
return mesh;
}
@@ -422,57 +402,54 @@ void SurfaceTool::index() {
if (index_array.size())
return; //already indexed
-
- HashMap<Vertex,int,VertexHasher> indices;
+ HashMap<Vertex, int, VertexHasher> indices;
List<Vertex> new_vertices;
- for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next()) {
+ for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next()) {
- int *idxptr=indices.getptr(E->get());
+ int *idxptr = indices.getptr(E->get());
int idx;
if (!idxptr) {
- idx=indices.size();
+ idx = indices.size();
new_vertices.push_back(E->get());
- indices[E->get()]=idx;
+ indices[E->get()] = idx;
} else {
- idx=*idxptr;
+ idx = *idxptr;
}
index_array.push_back(idx);
-
}
vertex_array.clear();
- vertex_array=new_vertices;
+ vertex_array = new_vertices;
- format|=Mesh::ARRAY_FORMAT_INDEX;
+ format |= Mesh::ARRAY_FORMAT_INDEX;
}
void SurfaceTool::deindex() {
- if (index_array.size()==0)
+ if (index_array.size() == 0)
return; //nothing to deindex
- Vector< Vertex > varr;
+ Vector<Vertex> varr;
varr.resize(vertex_array.size());
- int idx=0;
- for (List< Vertex >::Element *E=vertex_array.front();E;E=E->next()) {
+ int idx = 0;
+ for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next()) {
- varr[idx++]=E->get();
+ varr[idx++] = E->get();
}
vertex_array.clear();
- for (List<int>::Element *E=index_array.front();E;E=E->next()) {
+ for (List<int>::Element *E = index_array.front(); E; E = E->next()) {
- ERR_FAIL_INDEX(E->get(),varr.size());
+ ERR_FAIL_INDEX(E->get(), varr.size());
vertex_array.push_back(varr[E->get()]);
}
- format&=~Mesh::ARRAY_FORMAT_INDEX;
+ format &= ~Mesh::ARRAY_FORMAT_INDEX;
}
-
-void SurfaceTool::_create_list(const Ref<Mesh>& p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index, int& lformat) {
+void SurfaceTool::_create_list(const Ref<Mesh> &p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index, int &lformat) {
Array arr = p_existing->surface_get_arrays(p_surface);
- ERR_FAIL_COND( arr.size() !=VS::ARRAY_MAX );
+ ERR_FAIL_COND(arr.size() != VS::ARRAY_MAX);
DVector<Vector3> varr = arr[VS::ARRAY_VERTEX];
DVector<Vector3> narr = arr[VS::ARRAY_NORMAL];
@@ -485,90 +462,90 @@ void SurfaceTool::_create_list(const Ref<Mesh>& p_existing, int p_surface, List<
int vc = varr.size();
- if (vc==0)
+ if (vc == 0)
return;
- lformat=0;
+ lformat = 0;
DVector<Vector3>::Read rv;
if (varr.size()) {
- lformat|=VS::ARRAY_FORMAT_VERTEX;
- rv=varr.read();
+ lformat |= VS::ARRAY_FORMAT_VERTEX;
+ rv = varr.read();
}
DVector<Vector3>::Read rn;
if (narr.size()) {
- lformat|=VS::ARRAY_FORMAT_NORMAL;
- rn=narr.read();
+ lformat |= VS::ARRAY_FORMAT_NORMAL;
+ rn = narr.read();
}
DVector<float>::Read rt;
if (tarr.size()) {
- lformat|=VS::ARRAY_FORMAT_TANGENT;
- rt=tarr.read();
+ lformat |= VS::ARRAY_FORMAT_TANGENT;
+ rt = tarr.read();
}
DVector<Color>::Read rc;
if (carr.size()) {
- lformat|=VS::ARRAY_FORMAT_COLOR;
- rc=carr.read();
+ lformat |= VS::ARRAY_FORMAT_COLOR;
+ rc = carr.read();
}
DVector<Vector2>::Read ruv;
if (uvarr.size()) {
- lformat|=VS::ARRAY_FORMAT_TEX_UV;
- ruv=uvarr.read();
+ lformat |= VS::ARRAY_FORMAT_TEX_UV;
+ ruv = uvarr.read();
}
DVector<Vector2>::Read ruv2;
if (uv2arr.size()) {
- lformat|=VS::ARRAY_FORMAT_TEX_UV2;
- ruv2=uv2arr.read();
+ lformat |= VS::ARRAY_FORMAT_TEX_UV2;
+ ruv2 = uv2arr.read();
}
DVector<int>::Read rb;
if (barr.size()) {
- lformat|=VS::ARRAY_FORMAT_BONES;
- rb=barr.read();
+ lformat |= VS::ARRAY_FORMAT_BONES;
+ rb = barr.read();
}
DVector<float>::Read rw;
if (warr.size()) {
- lformat|=VS::ARRAY_FORMAT_WEIGHTS;
- rw=warr.read();
+ lformat |= VS::ARRAY_FORMAT_WEIGHTS;
+ rw = warr.read();
}
- for(int i=0;i<vc;i++) {
+ for (int i = 0; i < vc; i++) {
Vertex v;
- if (lformat&VS::ARRAY_FORMAT_VERTEX)
- v.vertex=varr[i];
- if (lformat&VS::ARRAY_FORMAT_NORMAL)
- v.normal=narr[i];
- if (lformat&VS::ARRAY_FORMAT_TANGENT) {
- Plane p( tarr[i*4+0], tarr[i*4+1], tarr[i*4+2], tarr[i*4+3] );
- v.tangent=p.normal;
- v.binormal=p.normal.cross(last_normal).normalized() * p.d;
+ if (lformat & VS::ARRAY_FORMAT_VERTEX)
+ v.vertex = varr[i];
+ if (lformat & VS::ARRAY_FORMAT_NORMAL)
+ v.normal = narr[i];
+ if (lformat & VS::ARRAY_FORMAT_TANGENT) {
+ Plane p(tarr[i * 4 + 0], tarr[i * 4 + 1], tarr[i * 4 + 2], tarr[i * 4 + 3]);
+ v.tangent = p.normal;
+ v.binormal = p.normal.cross(last_normal).normalized() * p.d;
}
- if (lformat&VS::ARRAY_FORMAT_COLOR)
- v.color=carr[i];
- if (lformat&VS::ARRAY_FORMAT_TEX_UV)
- v.uv=uvarr[i];
- if (lformat&VS::ARRAY_FORMAT_TEX_UV2)
- v.uv2=uv2arr[i];
- if (lformat&VS::ARRAY_FORMAT_BONES) {
+ if (lformat & VS::ARRAY_FORMAT_COLOR)
+ v.color = carr[i];
+ if (lformat & VS::ARRAY_FORMAT_TEX_UV)
+ v.uv = uvarr[i];
+ if (lformat & VS::ARRAY_FORMAT_TEX_UV2)
+ v.uv2 = uv2arr[i];
+ if (lformat & VS::ARRAY_FORMAT_BONES) {
Vector<int> b;
b.resize(4);
- b[0]=barr[i*4+0];
- b[1]=barr[i*4+1];
- b[2]=barr[i*4+2];
- b[3]=barr[i*4+3];
- v.bones=b;
+ b[0] = barr[i * 4 + 0];
+ b[1] = barr[i * 4 + 1];
+ b[2] = barr[i * 4 + 2];
+ b[3] = barr[i * 4 + 3];
+ v.bones = b;
}
- if (lformat&VS::ARRAY_FORMAT_WEIGHTS) {
+ if (lformat & VS::ARRAY_FORMAT_WEIGHTS) {
Vector<float> w;
w.resize(4);
- w[0]=warr[i*4+0];
- w[1]=warr[i*4+1];
- w[2]=warr[i*4+2];
- w[3]=warr[i*4+3];
- v.weights=w;
+ w[0] = warr[i * 4 + 0];
+ w[1] = warr[i * 4 + 1];
+ w[2] = warr[i * 4 + 2];
+ w[3] = warr[i * 4 + 3];
+ v.weights = w;
}
r_vertex->push_back(v);
@@ -576,303 +553,277 @@ void SurfaceTool::_create_list(const Ref<Mesh>& p_existing, int p_surface, List<
//indices
- DVector<int> idx= arr[VS::ARRAY_INDEX];
+ DVector<int> idx = arr[VS::ARRAY_INDEX];
int is = idx.size();
if (is) {
- lformat|=VS::ARRAY_FORMAT_INDEX;
- DVector<int>::Read iarr=idx.read();
- for(int i=0;i<is;i++) {
+ lformat |= VS::ARRAY_FORMAT_INDEX;
+ DVector<int>::Read iarr = idx.read();
+ for (int i = 0; i < is; i++) {
r_index->push_back(iarr[i]);
}
-
}
-
-
}
-
-void SurfaceTool::create_from(const Ref<Mesh>& p_existing, int p_surface) {
+void SurfaceTool::create_from(const Ref<Mesh> &p_existing, int p_surface) {
clear();
- primitive=p_existing->surface_get_primitive_type(p_surface);
- _create_list(p_existing,p_surface,&vertex_array,&index_array,format);
- material=p_existing->surface_get_material(p_surface);
-
+ primitive = p_existing->surface_get_primitive_type(p_surface);
+ _create_list(p_existing, p_surface, &vertex_array, &index_array, format);
+ material = p_existing->surface_get_material(p_surface);
}
-void SurfaceTool::append_from(const Ref<Mesh>& p_existing, int p_surface,const Transform& p_xform) {
+void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const Transform &p_xform) {
- if (vertex_array.size()==0) {
- primitive=p_existing->surface_get_primitive_type(p_surface);
- format=0;
+ if (vertex_array.size() == 0) {
+ primitive = p_existing->surface_get_primitive_type(p_surface);
+ format = 0;
}
int nformat;
List<Vertex> nvertices;
List<int> nindices;
- _create_list(p_existing,p_surface,&nvertices,&nindices,nformat);
- format|=nformat;
+ _create_list(p_existing, p_surface, &nvertices, &nindices, nformat);
+ format |= nformat;
int vfrom = vertex_array.size();
+ for (List<Vertex>::Element *E = nvertices.front(); E; E = E->next()) {
- for(List<Vertex>::Element *E=nvertices.front();E;E=E->next()) {
-
- Vertex v=E->get();
- v.vertex=p_xform.xform(v.vertex);
- if (nformat&VS::ARRAY_FORMAT_NORMAL) {
- v.normal=p_xform.basis.xform(v.normal);
+ Vertex v = E->get();
+ v.vertex = p_xform.xform(v.vertex);
+ if (nformat & VS::ARRAY_FORMAT_NORMAL) {
+ v.normal = p_xform.basis.xform(v.normal);
}
- if (nformat&VS::ARRAY_FORMAT_TANGENT) {
- v.tangent=p_xform.basis.xform(v.tangent);
- v.binormal=p_xform.basis.xform(v.binormal);
+ if (nformat & VS::ARRAY_FORMAT_TANGENT) {
+ v.tangent = p_xform.basis.xform(v.tangent);
+ v.binormal = p_xform.basis.xform(v.binormal);
}
vertex_array.push_back(v);
}
- for(List<int>::Element *E=nindices.front();E;E=E->next()) {
+ for (List<int>::Element *E = nindices.front(); E; E = E->next()) {
- int dst_index = E->get()+vfrom;
+ int dst_index = E->get() + vfrom;
//if (dst_index <0 || dst_index>=vertex_array.size()) {
// print_line("invalid index!");
//}
index_array.push_back(dst_index);
}
- if (index_array.size()%3)
+ if (index_array.size() % 3)
print_line("IA not div of 3?");
-
}
//mikktspace callbacks
-int SurfaceTool::mikktGetNumFaces(const SMikkTSpaceContext * pContext) {
+int SurfaceTool::mikktGetNumFaces(const SMikkTSpaceContext *pContext) {
- Vector<List<Vertex>::Element*> &varr = *((Vector<List<Vertex>::Element*>*)pContext->m_pUserData);
- return varr.size()/3;
+ Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
+ return varr.size() / 3;
}
-int SurfaceTool::mikktGetNumVerticesOfFace(const SMikkTSpaceContext * pContext, const int iFace){
+int SurfaceTool::mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace) {
return 3; //always 3
}
-void SurfaceTool::mikktGetPosition(const SMikkTSpaceContext * pContext, float fvPosOut[], const int iFace, const int iVert){
-
- Vector<List<Vertex>::Element*> &varr = *((Vector<List<Vertex>::Element*>*)pContext->m_pUserData);
- Vector3 v = varr[iFace*3+iVert]->get().vertex;
- fvPosOut[0]=v.x;
- fvPosOut[1]=v.y;
- fvPosOut[2]=v.z;
-
+void SurfaceTool::mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert) {
+ Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
+ Vector3 v = varr[iFace * 3 + iVert]->get().vertex;
+ fvPosOut[0] = v.x;
+ fvPosOut[1] = v.y;
+ fvPosOut[2] = v.z;
}
-void SurfaceTool::mikktGetNormal(const SMikkTSpaceContext * pContext, float fvNormOut[], const int iFace, const int iVert){
-
-
- Vector<List<Vertex>::Element*> &varr = *((Vector<List<Vertex>::Element*>*)pContext->m_pUserData);
- Vector3 v = varr[iFace*3+iVert]->get().normal;
- fvNormOut[0]=v.x;
- fvNormOut[1]=v.y;
- fvNormOut[2]=v.z;
+void SurfaceTool::mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert) {
+ Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
+ Vector3 v = varr[iFace * 3 + iVert]->get().normal;
+ fvNormOut[0] = v.x;
+ fvNormOut[1] = v.y;
+ fvNormOut[2] = v.z;
}
-void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext * pContext, float fvTexcOut[], const int iFace, const int iVert){
+void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert) {
- Vector<List<Vertex>::Element*> &varr = *((Vector<List<Vertex>::Element*>*)pContext->m_pUserData);
- Vector2 v = varr[iFace*3+iVert]->get().uv;
- fvTexcOut[0]=v.x;
- fvTexcOut[1]=v.y;
+ Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
+ Vector2 v = varr[iFace * 3 + iVert]->get().uv;
+ fvTexcOut[0] = v.x;
+ fvTexcOut[1] = v.y;
//fvTexcOut[1]=1.0-v.y;
-
}
-void SurfaceTool::mikktSetTSpaceBasic(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert){
+void SurfaceTool::mikktSetTSpaceBasic(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert) {
- Vector<List<Vertex>::Element*> &varr = *((Vector<List<Vertex>::Element*>*)pContext->m_pUserData);
- Vertex &vtx = varr[iFace*3+iVert]->get();
+ Vector<List<Vertex>::Element *> &varr = *((Vector<List<Vertex>::Element *> *)pContext->m_pUserData);
+ Vertex &vtx = varr[iFace * 3 + iVert]->get();
- vtx.tangent = Vector3(fvTangent[0],fvTangent[1],fvTangent[2]);
+ vtx.tangent = Vector3(fvTangent[0], fvTangent[1], fvTangent[2]);
vtx.binormal = vtx.normal.cross(vtx.tangent) * fSign;
}
-
void SurfaceTool::generate_tangents() {
- ERR_FAIL_COND(!(format&Mesh::ARRAY_FORMAT_TEX_UV));
- ERR_FAIL_COND(!(format&Mesh::ARRAY_FORMAT_NORMAL));
+ ERR_FAIL_COND(!(format & Mesh::ARRAY_FORMAT_TEX_UV));
+ ERR_FAIL_COND(!(format & Mesh::ARRAY_FORMAT_NORMAL));
- bool indexed = index_array.size()>0;
+ bool indexed = index_array.size() > 0;
if (indexed)
deindex();
-
SMikkTSpaceInterface mkif;
- mkif.m_getNormal=mikktGetNormal;
- mkif.m_getNumFaces=mikktGetNumFaces;
- mkif.m_getNumVerticesOfFace=mikktGetNumVerticesOfFace;
- mkif.m_getPosition=mikktGetPosition;
- mkif.m_getTexCoord=mikktGetTexCoord;
- mkif.m_setTSpaceBasic=mikktSetTSpaceBasic;
- mkif.m_setTSpace=NULL;
+ mkif.m_getNormal = mikktGetNormal;
+ mkif.m_getNumFaces = mikktGetNumFaces;
+ mkif.m_getNumVerticesOfFace = mikktGetNumVerticesOfFace;
+ mkif.m_getPosition = mikktGetPosition;
+ mkif.m_getTexCoord = mikktGetTexCoord;
+ mkif.m_setTSpaceBasic = mikktSetTSpaceBasic;
+ mkif.m_setTSpace = NULL;
SMikkTSpaceContext msc;
- msc.m_pInterface=&mkif;
+ msc.m_pInterface = &mkif;
- Vector<List<Vertex>::Element*> vtx;
+ Vector<List<Vertex>::Element *> vtx;
vtx.resize(vertex_array.size());
- int idx=0;
- for (List<Vertex>::Element *E=vertex_array.front();E;E=E->next()) {
- vtx[idx++]=E;
- E->get().binormal=Vector3();
- E->get().tangent=Vector3();
+ int idx = 0;
+ for (List<Vertex>::Element *E = vertex_array.front(); E; E = E->next()) {
+ vtx[idx++] = E;
+ E->get().binormal = Vector3();
+ E->get().tangent = Vector3();
}
- msc.m_pUserData=&vtx;
+ msc.m_pUserData = &vtx;
bool res = genTangSpaceDefault(&msc);
ERR_FAIL_COND(!res);
- format|=Mesh::ARRAY_FORMAT_TANGENT;
+ format |= Mesh::ARRAY_FORMAT_TANGENT;
if (indexed)
index();
-
-
}
void SurfaceTool::generate_normals() {
- ERR_FAIL_COND(primitive!=Mesh::PRIMITIVE_TRIANGLES);
+ ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES);
- bool was_indexed=index_array.size();
+ bool was_indexed = index_array.size();
deindex();
- HashMap<Vertex,Vector3,VertexHasher> vertex_hash;
+ HashMap<Vertex, Vector3, VertexHasher> vertex_hash;
- int count=0;
- bool smooth=false;
+ int count = 0;
+ bool smooth = false;
if (smooth_groups.has(0))
- smooth=smooth_groups[0];
+ smooth = smooth_groups[0];
- List< Vertex >::Element *B=vertex_array.front();
- for(List< Vertex >::Element *E=B;E;) {
+ List<Vertex>::Element *B = vertex_array.front();
+ for (List<Vertex>::Element *E = B; E;) {
- List< Vertex >::Element *v[3];
- v[0]=E;
- v[1]=v[0]->next();
+ List<Vertex>::Element *v[3];
+ v[0] = E;
+ v[1] = v[0]->next();
ERR_FAIL_COND(!v[1]);
- v[2]=v[1]->next();
+ v[2] = v[1]->next();
ERR_FAIL_COND(!v[2]);
- E=v[2]->next();
+ E = v[2]->next();
- Vector3 normal = Plane(v[0]->get().vertex,v[1]->get().vertex,v[2]->get().vertex).normal;
+ Vector3 normal = Plane(v[0]->get().vertex, v[1]->get().vertex, v[2]->get().vertex).normal;
if (smooth) {
- for(int i=0;i<3;i++) {
+ for (int i = 0; i < 3; i++) {
- Vector3 *lv=vertex_hash.getptr(v[i]->get());
+ Vector3 *lv = vertex_hash.getptr(v[i]->get());
if (!lv) {
- vertex_hash.set(v[i]->get(),normal);
+ vertex_hash.set(v[i]->get(), normal);
} else {
- (*lv)+=normal;
+ (*lv) += normal;
}
}
} else {
- for(int i=0;i<3;i++) {
-
- v[i]->get().normal=normal;
+ for (int i = 0; i < 3; i++) {
+ v[i]->get().normal = normal;
}
}
- count+=3;
+ count += 3;
if (smooth_groups.has(count) || !E) {
if (vertex_hash.size()) {
- while (B!=E) {
+ while (B != E) {
-
- Vector3* lv=vertex_hash.getptr(B->get());
+ Vector3 *lv = vertex_hash.getptr(B->get());
if (lv) {
- B->get().normal=lv->normalized();
+ B->get().normal = lv->normalized();
}
- B=B->next();
+ B = B->next();
}
} else {
- B=E;
+ B = E;
}
vertex_hash.clear();
if (E) {
- smooth=smooth_groups[count];
- print_line("SMOOTH AT "+itos(count)+": "+itos(smooth));
-
+ smooth = smooth_groups[count];
+ print_line("SMOOTH AT " + itos(count) + ": " + itos(smooth));
}
}
-
}
- format|=Mesh::ARRAY_FORMAT_NORMAL;
+ format |= Mesh::ARRAY_FORMAT_NORMAL;
if (was_indexed) {
index();
smooth_groups.clear();
}
-
}
-void SurfaceTool::set_material(const Ref<Material>& p_material) {
+void SurfaceTool::set_material(const Ref<Material> &p_material) {
- material=p_material;
+ material = p_material;
}
void SurfaceTool::clear() {
- begun=false;
- primitive=Mesh::PRIMITIVE_LINES;
- format=0;
+ begun = false;
+ primitive = Mesh::PRIMITIVE_LINES;
+ format = 0;
last_bones.clear();
last_weights.clear();
index_array.clear();
vertex_array.clear();
smooth_groups.clear();
-
}
void SurfaceTool::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("begin","primitive"),&SurfaceTool::begin);
- ObjectTypeDB::bind_method(_MD("add_vertex","vertex"),&SurfaceTool::add_vertex);
- ObjectTypeDB::bind_method(_MD("add_color","color"),&SurfaceTool::add_color);
- ObjectTypeDB::bind_method(_MD("add_normal","normal"),&SurfaceTool::add_normal);
- ObjectTypeDB::bind_method(_MD("add_tangent","tangent"),&SurfaceTool::add_tangent);
- ObjectTypeDB::bind_method(_MD("add_uv","uv"),&SurfaceTool::add_uv);
- ObjectTypeDB::bind_method(_MD("add_uv2","uv2"),&SurfaceTool::add_uv2);
- ObjectTypeDB::bind_method(_MD("add_bones","bones"),&SurfaceTool::add_bones);
- ObjectTypeDB::bind_method(_MD("add_weights","weights"),&SurfaceTool::add_weights);
- ObjectTypeDB::bind_method(_MD("add_smooth_group","smooth"),&SurfaceTool::add_smooth_group);
- ObjectTypeDB::bind_method(_MD("add_triangle_fan", "vertexes", "uvs", "colors", "uv2s", "normals", "tangents"),&SurfaceTool::add_triangle_fan, DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Color>()), DEFVAL(Vector<Vector2>()),DEFVAL(Vector<Vector3>()), DEFVAL(Vector<Plane>()));
- ObjectTypeDB::bind_method(_MD("set_material","material:Material"),&SurfaceTool::set_material);
- ObjectTypeDB::bind_method(_MD("index"),&SurfaceTool::index);
- ObjectTypeDB::bind_method(_MD("deindex"),&SurfaceTool::deindex);
+ ObjectTypeDB::bind_method(_MD("begin", "primitive"), &SurfaceTool::begin);
+ ObjectTypeDB::bind_method(_MD("add_vertex", "vertex"), &SurfaceTool::add_vertex);
+ ObjectTypeDB::bind_method(_MD("add_color", "color"), &SurfaceTool::add_color);
+ ObjectTypeDB::bind_method(_MD("add_normal", "normal"), &SurfaceTool::add_normal);
+ ObjectTypeDB::bind_method(_MD("add_tangent", "tangent"), &SurfaceTool::add_tangent);
+ ObjectTypeDB::bind_method(_MD("add_uv", "uv"), &SurfaceTool::add_uv);
+ ObjectTypeDB::bind_method(_MD("add_uv2", "uv2"), &SurfaceTool::add_uv2);
+ ObjectTypeDB::bind_method(_MD("add_bones", "bones"), &SurfaceTool::add_bones);
+ ObjectTypeDB::bind_method(_MD("add_weights", "weights"), &SurfaceTool::add_weights);
+ ObjectTypeDB::bind_method(_MD("add_smooth_group", "smooth"), &SurfaceTool::add_smooth_group);
+ ObjectTypeDB::bind_method(_MD("add_triangle_fan", "vertexes", "uvs", "colors", "uv2s", "normals", "tangents"), &SurfaceTool::add_triangle_fan, DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Color>()), DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Vector3>()), DEFVAL(Vector<Plane>()));
+ ObjectTypeDB::bind_method(_MD("set_material", "material:Material"), &SurfaceTool::set_material);
+ ObjectTypeDB::bind_method(_MD("index"), &SurfaceTool::index);
+ ObjectTypeDB::bind_method(_MD("deindex"), &SurfaceTool::deindex);
///ObjectTypeDB::bind_method(_MD("generate_flat_normals"),&SurfaceTool::generate_flat_normals);
- ObjectTypeDB::bind_method(_MD("generate_normals"),&SurfaceTool::generate_normals);
+ ObjectTypeDB::bind_method(_MD("generate_normals"), &SurfaceTool::generate_normals);
ObjectTypeDB::bind_method(_MD("add_index", "index"), &SurfaceTool::add_index);
- ObjectTypeDB::bind_method(_MD("commit:Mesh","existing:Mesh"),&SurfaceTool::commit,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("clear"),&SurfaceTool::clear);
-
+ ObjectTypeDB::bind_method(_MD("commit:Mesh", "existing:Mesh"), &SurfaceTool::commit, DEFVAL(Variant()));
+ ObjectTypeDB::bind_method(_MD("clear"), &SurfaceTool::clear);
}
-
SurfaceTool::SurfaceTool() {
- first=false;
- begun=false;
- primitive=Mesh::PRIMITIVE_LINES;
- format=0;
-
+ first = false;
+ begun = false;
+ primitive = Mesh::PRIMITIVE_LINES;
+ format = 0;
}
-
diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h
index 5fa300a04..d19fe0d66 100644
--- a/scene/resources/surface_tool.h
+++ b/scene/resources/surface_tool.h
@@ -29,34 +29,32 @@
#ifndef SURFACE_TOOL_H
#define SURFACE_TOOL_H
-#include "scene/resources/mesh.h"
#include "mikktspace.h"
-
+#include "scene/resources/mesh.h"
class SurfaceTool : public Reference {
- OBJ_TYPE(SurfaceTool, Reference );
+ OBJ_TYPE(SurfaceTool, Reference);
+
public:
struct Vertex {
- Vector3 vertex;
- Color color;
- Vector3 normal; // normal, binormal, tangent
- Vector3 binormal;
- Vector3 tangent;
- Vector2 uv;
- Vector2 uv2;
- Vector<int> bones;
- Vector<float> weights;
+ Vector3 vertex;
+ Color color;
+ Vector3 normal; // normal, binormal, tangent
+ Vector3 binormal;
+ Vector3 tangent;
+ Vector2 uv;
+ Vector2 uv2;
+ Vector<int> bones;
+ Vector<float> weights;
- bool operator==(const Vertex& p_vertex) const;
+ bool operator==(const Vertex &p_vertex) const;
- Vertex() { }
+ Vertex() {}
};
-
private:
-
struct VertexHasher {
static _FORCE_INLINE_ uint32_t hash(const Vertex &p_vtx);
};
@@ -67,9 +65,9 @@ private:
int format;
Ref<Material> material;
//arrays
- List< Vertex > vertex_array;
- List< int > index_array;
- Map<int,bool> smooth_groups;
+ List<Vertex> vertex_array;
+ List<int> index_array;
+ Map<int, bool> smooth_groups;
//memory
Color last_color;
@@ -80,57 +78,54 @@ private:
Vector<float> last_weights;
Plane last_tangent;
- void _create_list(const Ref<Mesh>& p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index,int &lformat);
-
+ void _create_list(const Ref<Mesh> &p_existing, int p_surface, List<Vertex> *r_vertex, List<int> *r_index, int &lformat);
//mikktspace callbacks
- static int mikktGetNumFaces(const SMikkTSpaceContext * pContext);
- static int mikktGetNumVerticesOfFace(const SMikkTSpaceContext * pContext, const int iFace);
- static void mikktGetPosition(const SMikkTSpaceContext * pContext, float fvPosOut[], const int iFace, const int iVert);
- static void mikktGetNormal(const SMikkTSpaceContext * pContext, float fvNormOut[], const int iFace, const int iVert);
- static void mikktGetTexCoord(const SMikkTSpaceContext * pContext, float fvTexcOut[], const int iFace, const int iVert);
- static void mikktSetTSpaceBasic(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert);
-protected:
+ static int mikktGetNumFaces(const SMikkTSpaceContext *pContext);
+ static int mikktGetNumVerticesOfFace(const SMikkTSpaceContext *pContext, const int iFace);
+ static void mikktGetPosition(const SMikkTSpaceContext *pContext, float fvPosOut[], const int iFace, const int iVert);
+ static void mikktGetNormal(const SMikkTSpaceContext *pContext, float fvNormOut[], const int iFace, const int iVert);
+ static void mikktGetTexCoord(const SMikkTSpaceContext *pContext, float fvTexcOut[], const int iFace, const int iVert);
+ static void mikktSetTSpaceBasic(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert);
+protected:
static void _bind_methods();
public:
-
void begin(Mesh::PrimitiveType p_primitive);
- void add_vertex( const Vector3& p_vertex);
- void add_color( Color p_color );
- void add_normal( const Vector3& p_normal);
- void add_tangent( const Plane& p_tangent );
- void add_uv( const Vector2& p_uv);
- void add_uv2( const Vector2& p_uv);
- void add_bones( const Vector<int>& p_indices);
- void add_weights( const Vector<float>& p_weights);
+ void add_vertex(const Vector3 &p_vertex);
+ void add_color(Color p_color);
+ void add_normal(const Vector3 &p_normal);
+ void add_tangent(const Plane &p_tangent);
+ void add_uv(const Vector2 &p_uv);
+ void add_uv2(const Vector2 &p_uv);
+ void add_bones(const Vector<int> &p_indices);
+ void add_weights(const Vector<float> &p_weights);
void add_smooth_group(bool p_smooth);
- void add_triangle_fan( const Vector<Vector3>& p_vertexes, const Vector<Vector2>& p_uvs=Vector<Vector2>(), const Vector<Color>& p_colors=Vector<Color>(), const Vector<Vector2>& p_uv2s=Vector<Vector2>(), const Vector<Vector3>& p_normals=Vector<Vector3>(), const Vector<Plane>& p_tangents=Vector<Plane>() );
+ void add_triangle_fan(const Vector<Vector3> &p_vertexes, const Vector<Vector2> &p_uvs = Vector<Vector2>(), const Vector<Color> &p_colors = Vector<Color>(), const Vector<Vector2> &p_uv2s = Vector<Vector2>(), const Vector<Vector3> &p_normals = Vector<Vector3>(), const Vector<Plane> &p_tangents = Vector<Plane>());
- void add_index( int p_index);
+ void add_index(int p_index);
void index();
void deindex();
void generate_normals();
void generate_tangents();
- void add_to_format(int p_flags) { format|=p_flags; }
+ void add_to_format(int p_flags) { format |= p_flags; }
- void set_material(const Ref<Material>& p_material);
+ void set_material(const Ref<Material> &p_material);
void clear();
- List< Vertex > &get_vertex_array() { return vertex_array; }
+ List<Vertex> &get_vertex_array() { return vertex_array; }
- void create_from(const Ref<Mesh>& p_existing, int p_surface);
- void append_from(const Ref<Mesh>& p_existing, int p_surface,const Transform& p_xform);
- Ref<Mesh> commit(const Ref<Mesh>& p_existing=Ref<Mesh>());
+ void create_from(const Ref<Mesh> &p_existing, int p_surface);
+ void append_from(const Ref<Mesh> &p_existing, int p_surface, const Transform &p_xform);
+ Ref<Mesh> commit(const Ref<Mesh> &p_existing = Ref<Mesh>());
SurfaceTool();
};
-
#endif
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index f511e2ece..2b14d3558 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -27,214 +27,185 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "texture.h"
-#include "io/image_loader.h"
#include "core/os/os.h"
-
-
+#include "io/image_loader.h"
Size2 Texture::get_size() const {
- return Size2(get_width(),get_height());
+ return Size2(get_width(), get_height());
}
+void Texture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
-void Texture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
-
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,Rect2( p_pos, get_size()),get_rid(),false,p_modulate,p_transpose);
-
+ VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose);
}
-void Texture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
-
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,p_rect,get_rid(),p_tile,p_modulate,p_transpose);
+void Texture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
+ VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose);
}
-void Texture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const{
+void Texture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) const {
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,p_rect,get_rid(),p_src_rect,p_modulate,p_transpose);
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose);
}
-bool Texture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const {
+bool Texture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
- r_rect=p_rect;
- r_src_rect=p_src_rect;
+ r_rect = p_rect;
+ r_src_rect = p_src_rect;
return true;
}
void Texture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_width"),&Texture::get_width);
- ObjectTypeDB::bind_method(_MD("get_height"),&Texture::get_height);
- ObjectTypeDB::bind_method(_MD("get_size"),&Texture::get_size);
- ObjectTypeDB::bind_method(_MD("get_rid"),&Texture::get_rid);
- ObjectTypeDB::bind_method(_MD("has_alpha"),&Texture::has_alpha);
- ObjectTypeDB::bind_method(_MD("set_flags","flags"),&Texture::set_flags);
- ObjectTypeDB::bind_method(_MD("get_flags"),&Texture::get_flags);
- ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","modulate","transpose"),&Texture::draw,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_rect","canvas_item","rect","tile","modulate","transpose"),&Texture::draw_rect,DEFVAL(Color(1,1,1)),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("draw_rect_region","canvas_item","rect","src_rect","modulate","transpose"),&Texture::draw_rect_region,DEFVAL(Color(1,1,1)),DEFVAL(false));
-
- BIND_CONSTANT( FLAG_MIPMAPS );
- BIND_CONSTANT( FLAG_REPEAT );
- BIND_CONSTANT( FLAG_FILTER );
- BIND_CONSTANT( FLAG_VIDEO_SURFACE );
- BIND_CONSTANT( FLAGS_DEFAULT );
- BIND_CONSTANT( FLAG_ANISOTROPIC_FILTER );
- BIND_CONSTANT( FLAG_CONVERT_TO_LINEAR );
- BIND_CONSTANT( FLAG_MIRRORED_REPEAT );
+ ObjectTypeDB::bind_method(_MD("get_width"), &Texture::get_width);
+ ObjectTypeDB::bind_method(_MD("get_height"), &Texture::get_height);
+ ObjectTypeDB::bind_method(_MD("get_size"), &Texture::get_size);
+ ObjectTypeDB::bind_method(_MD("get_rid"), &Texture::get_rid);
+ ObjectTypeDB::bind_method(_MD("has_alpha"), &Texture::has_alpha);
+ ObjectTypeDB::bind_method(_MD("set_flags", "flags"), &Texture::set_flags);
+ ObjectTypeDB::bind_method(_MD("get_flags"), &Texture::get_flags);
+ ObjectTypeDB::bind_method(_MD("draw", "canvas_item", "pos", "modulate", "transpose"), &Texture::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose"), &Texture::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
+ BIND_CONSTANT(FLAG_MIPMAPS);
+ BIND_CONSTANT(FLAG_REPEAT);
+ BIND_CONSTANT(FLAG_FILTER);
+ BIND_CONSTANT(FLAG_VIDEO_SURFACE);
+ BIND_CONSTANT(FLAGS_DEFAULT);
+ BIND_CONSTANT(FLAG_ANISOTROPIC_FILTER);
+ BIND_CONSTANT(FLAG_CONVERT_TO_LINEAR);
+ BIND_CONSTANT(FLAG_MIRRORED_REPEAT);
}
Texture::Texture() {
-
-
-
}
-
-
/////////////////////
-
-
-
-
void ImageTexture::reload_from_file() {
- String path=get_path();
+ String path = get_path();
if (!path.is_resource_file())
return;
uint32_t flags = get_flags();
Image img;
- Error err = ImageLoader::load_image(path,&img);
- ERR_FAIL_COND(err!=OK);
-
- create_from_image(img,flags);
+ Error err = ImageLoader::load_image(path, &img);
+ ERR_FAIL_COND(err != OK);
+ create_from_image(img, flags);
}
-bool ImageTexture::_set(const StringName& p_name, const Variant& p_value) {
+bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) {
- if (p_name=="image" && p_value.get_type()==Variant::IMAGE)
- create_from_image( p_value,flags );
- else if (p_name=="flags")
- if (w*h==0)
- flags=p_value;
+ if (p_name == "image" && p_value.get_type() == Variant::IMAGE)
+ create_from_image(p_value, flags);
+ else if (p_name == "flags")
+ if (w * h == 0)
+ flags = p_value;
else
set_flags(p_value);
- else if (p_name=="size") {
+ else if (p_name == "size") {
Size2 s = p_value;
- w=s.width;
- h=s.height;
- VisualServer::get_singleton()->texture_set_size_override(texture,w,h);
- } else if (p_name=="storage") {
- storage=Storage(p_value.operator int());
- } else if (p_name=="lossy_quality") {
- lossy_storage_quality=p_value;
- } else if (p_name=="_data") {
+ w = s.width;
+ h = s.height;
+ VisualServer::get_singleton()->texture_set_size_override(texture, w, h);
+ } else if (p_name == "storage") {
+ storage = Storage(p_value.operator int());
+ } else if (p_name == "lossy_quality") {
+ lossy_storage_quality = p_value;
+ } else if (p_name == "_data") {
_set_data(p_value);
} else
return false;
return true;
-
}
-bool ImageTexture::_get(const StringName& p_name,Variant &r_ret) const {
-
+bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name=="image_data") {
+ if (p_name == "image_data") {
- } else if (p_name=="image")
- r_ret= get_data();
- else if (p_name=="flags")
- r_ret= flags;
- else if (p_name=="size")
- r_ret=Size2(w,h);
- else if (p_name=="storage")
- r_ret= storage;
- else if (p_name=="lossy_quality")
- r_ret= lossy_storage_quality;
+ } else if (p_name == "image")
+ r_ret = get_data();
+ else if (p_name == "flags")
+ r_ret = flags;
+ else if (p_name == "size")
+ r_ret = Size2(w, h);
+ else if (p_name == "storage")
+ r_ret = storage;
+ else if (p_name == "lossy_quality")
+ r_ret = lossy_storage_quality;
else
return false;
return true;
}
+void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const {
-
-
-void ImageTexture::_get_property_list( List<PropertyInfo> *p_list) const {
-
-
- PropertyHint img_hint=PROPERTY_HINT_NONE;
- if (storage==STORAGE_COMPRESS_LOSSY) {
- img_hint=PROPERTY_HINT_IMAGE_COMPRESS_LOSSY;
- } else if (storage==STORAGE_COMPRESS_LOSSLESS) {
- img_hint=PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS;
+ PropertyHint img_hint = PROPERTY_HINT_NONE;
+ if (storage == STORAGE_COMPRESS_LOSSY) {
+ img_hint = PROPERTY_HINT_IMAGE_COMPRESS_LOSSY;
+ } else if (storage == STORAGE_COMPRESS_LOSSLESS) {
+ img_hint = PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS;
}
-
-
- p_list->push_back( PropertyInfo( Variant::INT, "flags", PROPERTY_HINT_FLAGS,"Mipmaps,Repeat,Filter,Anisotropic,sRGB,Mirrored Repeat") );
- p_list->push_back( PropertyInfo( Variant::IMAGE, "image", img_hint,String::num(lossy_storage_quality)) );
- p_list->push_back( PropertyInfo( Variant::VECTOR2, "size",PROPERTY_HINT_NONE, ""));
- p_list->push_back( PropertyInfo( Variant::INT, "storage", PROPERTY_HINT_ENUM,"Uncompressed,Compress Lossy,Compress Lossless"));
- p_list->push_back( PropertyInfo( Variant::REAL, "lossy_quality", PROPERTY_HINT_RANGE,"0.0,1.0,0.01" ));
+ p_list->push_back(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic,sRGB,Mirrored Repeat"));
+ p_list->push_back(PropertyInfo(Variant::IMAGE, "image", img_hint, String::num(lossy_storage_quality)));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, ""));
+ p_list->push_back(PropertyInfo(Variant::INT, "storage", PROPERTY_HINT_ENUM, "Uncompressed,Compress Lossy,Compress Lossless"));
+ p_list->push_back(PropertyInfo(Variant::REAL, "lossy_quality", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));
}
-void ImageTexture::_reload_hook(const RID& p_hook) {
+void ImageTexture::_reload_hook(const RID &p_hook) {
- String path=get_path();
+ String path = get_path();
if (!path.is_resource_file())
return;
Image img;
- Error err = ImageLoader::load_image(path,&img);
-
- ERR_FAIL_COND(err!=OK);
+ Error err = ImageLoader::load_image(path, &img);
+ ERR_FAIL_COND(err != OK);
- VisualServer::get_singleton()->texture_set_data(texture,img);
+ VisualServer::get_singleton()->texture_set_data(texture, img);
_change_notify();
}
-void ImageTexture::create(int p_width, int p_height,Image::Format p_format,uint32_t p_flags) {
-
- flags=p_flags;
- VisualServer::get_singleton()->texture_allocate(texture,p_width, p_height, p_format, p_flags);
- format=p_format;
- w=p_width;
- h=p_height;
+void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags) {
+ flags = p_flags;
+ VisualServer::get_singleton()->texture_allocate(texture, p_width, p_height, p_format, p_flags);
+ format = p_format;
+ w = p_width;
+ h = p_height;
}
-void ImageTexture::create_from_image(const Image& p_image, uint32_t p_flags) {
+void ImageTexture::create_from_image(const Image &p_image, uint32_t p_flags) {
- flags=p_flags;
- w=p_image.get_width();
- h=p_image.get_height();
- format=p_image.get_format();
+ flags = p_flags;
+ w = p_image.get_width();
+ h = p_image.get_height();
+ format = p_image.get_format();
- VisualServer::get_singleton()->texture_allocate(texture,p_image.get_width(),p_image.get_height(), p_image.get_format(), p_flags);
- VisualServer::get_singleton()->texture_set_data(texture,p_image);
+ VisualServer::get_singleton()->texture_allocate(texture, p_image.get_width(), p_image.get_height(), p_image.get_format(), p_flags);
+ VisualServer::get_singleton()->texture_set_data(texture, p_image);
_change_notify();
}
void ImageTexture::set_flags(uint32_t p_flags) {
-
-
-/* uint32_t cube = flags & FLAG_CUBEMAP;
+ /* uint32_t cube = flags & FLAG_CUBEMAP;
if (flags == p_flags&cube)
return;
flags=p_flags|cube; */
- flags=p_flags;
- VisualServer::get_singleton()->texture_set_flags(texture,p_flags);
-
+ flags = p_flags;
+ VisualServer::get_singleton()->texture_set_flags(texture, p_flags);
}
uint32_t ImageTexture::get_flags() const {
@@ -247,32 +218,31 @@ Image::Format ImageTexture::get_format() const {
return format;
}
-void ImageTexture::load(const String& p_path) {
-
- Image img;
- img.load(p_path);
- create_from_image(img);
+void ImageTexture::load(const String &p_path) {
+ Image img;
+ img.load(p_path);
+ create_from_image(img);
}
-void ImageTexture::set_data(const Image& p_image) {
+void ImageTexture::set_data(const Image &p_image) {
- VisualServer::get_singleton()->texture_set_data(texture,p_image);
- VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName()); //hook is erased if data is changed
+ VisualServer::get_singleton()->texture_set_data(texture, p_image);
+ VisualServer::get_singleton()->texture_set_reload_hook(texture, 0, StringName()); //hook is erased if data is changed
_change_notify();
}
void ImageTexture::_resource_path_changed() {
- String path=get_path();
+ String path = get_path();
if (VS::get_singleton()->has_feature(VS::FEATURE_NEEDS_RELOAD_HOOK)) {
//this needs to be done much better, but probably will end up being deprecated as technology advances
if (path.is_resource_file() && ImageLoader::recognize(path.extension())) {
//hook is set only if path is hookable
- VisualServer::get_singleton()->texture_set_reload_hook(texture,get_instance_ID(),"_reload_hook");
+ VisualServer::get_singleton()->texture_set_reload_hook(texture, get_instance_ID(), "_reload_hook");
} else {
- VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName());
+ VisualServer::get_singleton()->texture_set_reload_hook(texture, 0, StringName());
}
}
}
@@ -292,7 +262,6 @@ int ImageTexture::get_height() const {
return h;
}
-
RID ImageTexture::get_rid() const {
return texture;
@@ -300,7 +269,7 @@ RID ImageTexture::get_rid() const {
void ImageTexture::fix_alpha_edges() {
- if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+ if (format == Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
Image img = get_data();
img.fix_alpha_edges();
@@ -310,7 +279,7 @@ void ImageTexture::fix_alpha_edges() {
void ImageTexture::premultiply_alpha() {
- if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+ if (format == Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
Image img = get_data();
img.premultiply_alpha();
@@ -322,69 +291,64 @@ void ImageTexture::normal_to_xy() {
Image img = get_data();
img.normalmap_to_xy();
- create_from_image(img,flags);
+ create_from_image(img, flags);
}
void ImageTexture::shrink_x2_and_keep_size() {
- Size2 sizeov=get_size();
+ Size2 sizeov = get_size();
Image img = get_data();
- img.resize(img.get_width()/2,img.get_height()/2,Image::INTERPOLATE_BILINEAR);
- create_from_image(img,flags);
+ img.resize(img.get_width() / 2, img.get_height() / 2, Image::INTERPOLATE_BILINEAR);
+ create_from_image(img, flags);
set_size_override(sizeov);
-
}
bool ImageTexture::has_alpha() const {
- return ( format==Image::FORMAT_GRAYSCALE_ALPHA || format==Image::FORMAT_INDEXED_ALPHA || format==Image::FORMAT_RGBA );
+ return (format == Image::FORMAT_GRAYSCALE_ALPHA || format == Image::FORMAT_INDEXED_ALPHA || format == Image::FORMAT_RGBA);
}
+void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
-void ImageTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
-
- if ((w|h)==0)
+ if ((w | h) == 0)
return;
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,Rect2( p_pos, Size2(w,h)),texture,false,p_modulate,p_transpose);
-
+ VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose);
}
-void ImageTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
+void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
- if ((w|h)==0)
+ if ((w | h) == 0)
return;
- VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item,p_rect,texture,p_tile,p_modulate,p_transpose);
-
+ VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose);
}
-void ImageTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const{
+void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) const {
- if ((w|h)==0)
+ if ((w | h) == 0)
return;
- VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,p_rect,texture,p_src_rect,p_modulate,p_transpose);
+ VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose);
}
-void ImageTexture::set_size_override(const Size2& p_size) {
+void ImageTexture::set_size_override(const Size2 &p_size) {
- Size2 s=p_size;
- if (s.x!=0)
- w=s.x;
- if (s.y!=0)
- h=s.y;
- VisualServer::get_singleton()->texture_set_size_override(texture,w,h);
+ Size2 s = p_size;
+ if (s.x != 0)
+ w = s.x;
+ if (s.y != 0)
+ h = s.y;
+ VisualServer::get_singleton()->texture_set_size_override(texture, w, h);
}
-void ImageTexture::set_path(const String& p_path,bool p_take_over) {
+void ImageTexture::set_path(const String &p_path, bool p_take_over) {
if (texture.is_valid()) {
- VisualServer::get_singleton()->texture_set_path(texture,p_path);
+ VisualServer::get_singleton()->texture_set_path(texture, p_path);
}
- Resource::set_path(p_path,p_take_over);
+ Resource::set_path(p_path, p_take_over);
}
-
void ImageTexture::set_storage(Storage p_storage) {
- storage=p_storage;
+ storage = p_storage;
}
ImageTexture::Storage ImageTexture::get_storage() const {
@@ -394,7 +358,7 @@ ImageTexture::Storage ImageTexture::get_storage() const {
void ImageTexture::set_lossy_storage_quality(float p_lossy_storage_quality) {
- lossy_storage_quality=p_lossy_storage_quality;
+ lossy_storage_quality = p_lossy_storage_quality;
}
float ImageTexture::get_lossy_storage_quality() const {
@@ -417,75 +381,67 @@ void ImageTexture::_set_data(Dictionary p_data) {
void ImageTexture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create","width","height","format","flags"),&ImageTexture::create,DEFVAL(FLAGS_DEFAULT));
- ObjectTypeDB::bind_method(_MD("create_from_image","image","flags"),&ImageTexture::create_from_image,DEFVAL(FLAGS_DEFAULT));
- ObjectTypeDB::bind_method(_MD("get_format"),&ImageTexture::get_format);
- ObjectTypeDB::bind_method(_MD("load","path"),&ImageTexture::load);
- ObjectTypeDB::bind_method(_MD("set_data","image"),&ImageTexture::set_data);
- ObjectTypeDB::bind_method(_MD("get_data","cube_side"),&ImageTexture::get_data);
- ObjectTypeDB::bind_method(_MD("set_storage","mode"),&ImageTexture::set_storage);
- ObjectTypeDB::bind_method(_MD("get_storage"),&ImageTexture::get_storage);
- ObjectTypeDB::bind_method(_MD("set_lossy_storage_quality","quality"),&ImageTexture::set_lossy_storage_quality);
- ObjectTypeDB::bind_method(_MD("get_lossy_storage_quality"),&ImageTexture::get_lossy_storage_quality);
- ObjectTypeDB::bind_method(_MD("fix_alpha_edges"),&ImageTexture::fix_alpha_edges);
- ObjectTypeDB::bind_method(_MD("premultiply_alpha"),&ImageTexture::premultiply_alpha);
- ObjectTypeDB::bind_method(_MD("normal_to_xy"),&ImageTexture::normal_to_xy);
- ObjectTypeDB::bind_method(_MD("shrink_x2_and_keep_size"),&ImageTexture::shrink_x2_and_keep_size);
-
- ObjectTypeDB::bind_method(_MD("set_size_override","size"),&ImageTexture::set_size_override);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("fix_alpha_edges"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("premultiply_alpha"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("normal_to_xy"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("shrink_x2_and_keep_size"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("_reload_hook","rid"),&ImageTexture::_reload_hook);
-
-
- BIND_CONSTANT( STORAGE_RAW );
- BIND_CONSTANT( STORAGE_COMPRESS_LOSSY );
- BIND_CONSTANT( STORAGE_COMPRESS_LOSSLESS );
+ ObjectTypeDB::bind_method(_MD("create", "width", "height", "format", "flags"), &ImageTexture::create, DEFVAL(FLAGS_DEFAULT));
+ ObjectTypeDB::bind_method(_MD("create_from_image", "image", "flags"), &ImageTexture::create_from_image, DEFVAL(FLAGS_DEFAULT));
+ ObjectTypeDB::bind_method(_MD("get_format"), &ImageTexture::get_format);
+ ObjectTypeDB::bind_method(_MD("load", "path"), &ImageTexture::load);
+ ObjectTypeDB::bind_method(_MD("set_data", "image"), &ImageTexture::set_data);
+ ObjectTypeDB::bind_method(_MD("get_data", "cube_side"), &ImageTexture::get_data);
+ ObjectTypeDB::bind_method(_MD("set_storage", "mode"), &ImageTexture::set_storage);
+ ObjectTypeDB::bind_method(_MD("get_storage"), &ImageTexture::get_storage);
+ ObjectTypeDB::bind_method(_MD("set_lossy_storage_quality", "quality"), &ImageTexture::set_lossy_storage_quality);
+ ObjectTypeDB::bind_method(_MD("get_lossy_storage_quality"), &ImageTexture::get_lossy_storage_quality);
+ ObjectTypeDB::bind_method(_MD("fix_alpha_edges"), &ImageTexture::fix_alpha_edges);
+ ObjectTypeDB::bind_method(_MD("premultiply_alpha"), &ImageTexture::premultiply_alpha);
+ ObjectTypeDB::bind_method(_MD("normal_to_xy"), &ImageTexture::normal_to_xy);
+ ObjectTypeDB::bind_method(_MD("shrink_x2_and_keep_size"), &ImageTexture::shrink_x2_and_keep_size);
+ ObjectTypeDB::bind_method(_MD("set_size_override", "size"), &ImageTexture::set_size_override);
+ ObjectTypeDB::set_method_flags(get_type_static(), _SCS("fix_alpha_edges"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ObjectTypeDB::set_method_flags(get_type_static(), _SCS("premultiply_alpha"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ObjectTypeDB::set_method_flags(get_type_static(), _SCS("normal_to_xy"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ObjectTypeDB::set_method_flags(get_type_static(), _SCS("shrink_x2_and_keep_size"), METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR);
+ ObjectTypeDB::bind_method(_MD("_reload_hook", "rid"), &ImageTexture::_reload_hook);
+ BIND_CONSTANT(STORAGE_RAW);
+ BIND_CONSTANT(STORAGE_COMPRESS_LOSSY);
+ BIND_CONSTANT(STORAGE_COMPRESS_LOSSLESS);
}
ImageTexture::ImageTexture() {
- w=h=0;
- flags=FLAGS_DEFAULT;
+ w = h = 0;
+ flags = FLAGS_DEFAULT;
texture = VisualServer::get_singleton()->texture_create();
storage = STORAGE_RAW;
- lossy_storage_quality=0.7;
-
-
+ lossy_storage_quality = 0.7;
}
-
ImageTexture::~ImageTexture() {
- VisualServer::get_singleton()->free( texture );
+ VisualServer::get_singleton()->free(texture);
}
-
//////////////////////////////////////////
-
int AtlasTexture::get_width() const {
- if (region.size.width==0) {
+ if (region.size.width == 0) {
if (atlas.is_valid())
return atlas->get_width();
return 1;
} else {
- return region.size.width+margin.size.width;
+ return region.size.width + margin.size.width;
}
}
int AtlasTexture::get_height() const {
- if (region.size.height==0) {
+ if (region.size.height == 0) {
if (atlas.is_valid())
return atlas->get_height();
return 1;
} else {
- return region.size.height+margin.size.height;
+ return region.size.height + margin.size.height;
}
}
RID AtlasTexture::get_rid() const {
@@ -508,11 +464,9 @@ void AtlasTexture::set_flags(uint32_t p_flags) {
if (atlas.is_valid())
atlas->set_flags(p_flags);
-
}
-
-uint32_t AtlasTexture::get_flags() const{
+uint32_t AtlasTexture::get_flags() const {
if (atlas.is_valid())
return atlas->get_flags();
@@ -520,24 +474,23 @@ uint32_t AtlasTexture::get_flags() const{
return 0;
}
-void AtlasTexture::set_atlas(const Ref<Texture>& p_atlas){
+void AtlasTexture::set_atlas(const Ref<Texture> &p_atlas) {
- if (atlas==p_atlas)
+ if (atlas == p_atlas)
return;
- atlas=p_atlas;
+ atlas = p_atlas;
emit_changed();
emit_signal("atlas_changed");
}
-Ref<Texture> AtlasTexture::get_atlas() const{
+Ref<Texture> AtlasTexture::get_atlas() const {
return atlas;
}
-void AtlasTexture::set_region(const Rect2& p_region) {
+void AtlasTexture::set_region(const Rect2 &p_region) {
- region=p_region;
+ region = p_region;
emit_changed();
-
}
Rect2 AtlasTexture::get_region() const {
@@ -545,11 +498,10 @@ Rect2 AtlasTexture::get_region() const {
return region;
}
-void AtlasTexture::set_margin(const Rect2& p_margin) {
+void AtlasTexture::set_margin(const Rect2 &p_margin) {
- margin=p_margin;
+ margin = p_margin;
emit_changed();
-
}
Rect2 AtlasTexture::get_margin() const {
@@ -559,144 +511,128 @@ Rect2 AtlasTexture::get_margin() const {
void AtlasTexture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_atlas","atlas:Texture"),&AtlasTexture::set_atlas);
- ObjectTypeDB::bind_method(_MD("get_atlas:Texture"),&AtlasTexture::get_atlas);
+ ObjectTypeDB::bind_method(_MD("set_atlas", "atlas:Texture"), &AtlasTexture::set_atlas);
+ ObjectTypeDB::bind_method(_MD("get_atlas:Texture"), &AtlasTexture::get_atlas);
- ObjectTypeDB::bind_method(_MD("set_region","region"),&AtlasTexture::set_region);
- ObjectTypeDB::bind_method(_MD("get_region"),&AtlasTexture::get_region);
+ ObjectTypeDB::bind_method(_MD("set_region", "region"), &AtlasTexture::set_region);
+ ObjectTypeDB::bind_method(_MD("get_region"), &AtlasTexture::get_region);
- ObjectTypeDB::bind_method(_MD("set_margin","margin"),&AtlasTexture::set_margin);
- ObjectTypeDB::bind_method(_MD("get_margin"),&AtlasTexture::get_margin);
+ ObjectTypeDB::bind_method(_MD("set_margin", "margin"), &AtlasTexture::set_margin);
+ ObjectTypeDB::bind_method(_MD("get_margin"), &AtlasTexture::get_margin);
ADD_SIGNAL(MethodInfo("atlas_changed"));
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_atlas"),_SCS("get_atlas") );
- ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region"), _SCS("set_region"),_SCS("get_region") );
- ADD_PROPERTY( PropertyInfo( Variant::RECT2, "margin"), _SCS("set_margin"),_SCS("get_margin") );
-
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_atlas"), _SCS("get_atlas"));
+ ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region"), _SCS("set_region"), _SCS("get_region"));
+ ADD_PROPERTY(PropertyInfo(Variant::RECT2, "margin"), _SCS("set_margin"), _SCS("get_margin"));
}
+void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
-
-
-void AtlasTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
-
- Rect2 rc=region;
+ Rect2 rc = region;
if (!atlas.is_valid())
return;
- if (rc.size.width==0) {
- rc.size.width=atlas->get_width();
+ if (rc.size.width == 0) {
+ rc.size.width = atlas->get_width();
}
- if (rc.size.height==0) {
- rc.size.height=atlas->get_height();
+ if (rc.size.height == 0) {
+ rc.size.height = atlas->get_height();
}
- VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,Rect2(p_pos+margin.pos,rc.size),atlas->get_rid(),rc,p_modulate,p_transpose);
+ VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.pos, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose);
}
-void AtlasTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
+void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
- Rect2 rc=region;
+ Rect2 rc = region;
if (!atlas.is_valid())
return;
- if (rc.size.width==0) {
- rc.size.width=atlas->get_width();
+ if (rc.size.width == 0) {
+ rc.size.width = atlas->get_width();
}
- if (rc.size.height==0) {
- rc.size.height=atlas->get_height();
+ if (rc.size.height == 0) {
+ rc.size.height = atlas->get_height();
}
- Vector2 scale = p_rect.size / (region.size+margin.size);
- Rect2 dr( p_rect.pos+margin.pos*scale,rc.size*scale );
-
- VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),rc,p_modulate,p_transpose);
+ Vector2 scale = p_rect.size / (region.size + margin.size);
+ Rect2 dr(p_rect.pos + margin.pos * scale, rc.size * scale);
+ VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose);
}
-void AtlasTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const {
+void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) const {
//this might not necesarily work well if using a rect, needs to be fixed properly
- Rect2 rc=region;
+ Rect2 rc = region;
if (!atlas.is_valid())
return;
- Rect2 src=p_src_rect;
- src.pos+=(rc.pos-margin.pos);
+ Rect2 src = p_src_rect;
+ src.pos += (rc.pos - margin.pos);
Rect2 src_c = rc.clip(src);
- if (src_c.size==Size2())
+ if (src_c.size == Size2())
return;
- Vector2 ofs = (src_c.pos-src.pos);
+ Vector2 ofs = (src_c.pos - src.pos);
Vector2 scale = p_rect.size / p_src_rect.size;
- if(scale.x < 0)
- {
- float mx = (margin.size.width - margin.pos.x);
- mx -= margin.pos.x;
- ofs.x = -(ofs.x + mx);
- }
- if(scale.y < 0)
- {
- float my = margin.size.height - margin.pos.y;
- my -= margin.pos.y;
- ofs.y = -(ofs.y + my);
- }
- Rect2 dr( p_rect.pos+ofs*scale,src_c.size*scale );
+ if (scale.x < 0) {
+ float mx = (margin.size.width - margin.pos.x);
+ mx -= margin.pos.x;
+ ofs.x = -(ofs.x + mx);
+ }
+ if (scale.y < 0) {
+ float my = margin.size.height - margin.pos.y;
+ my -= margin.pos.y;
+ ofs.y = -(ofs.y + my);
+ }
+ Rect2 dr(p_rect.pos + ofs * scale, src_c.size * scale);
- VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),src_c,p_modulate,p_transpose);
+ VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose);
}
-bool AtlasTexture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const {
+bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
- Rect2 rc=region;
+ Rect2 rc = region;
if (!atlas.is_valid())
return false;
- Rect2 src=p_src_rect;
- src.pos+=(rc.pos-margin.pos);
+ Rect2 src = p_src_rect;
+ src.pos += (rc.pos - margin.pos);
Rect2 src_c = rc.clip(src);
- if (src_c.size==Size2())
+ if (src_c.size == Size2())
return false;
- Vector2 ofs = (src_c.pos-src.pos);
+ Vector2 ofs = (src_c.pos - src.pos);
Vector2 scale = p_rect.size / p_src_rect.size;
- if(scale.x < 0)
- {
- float mx = (margin.size.width - margin.pos.x);
- mx -= margin.pos.x;
- ofs.x = -(ofs.x + mx);
- }
- if(scale.y < 0)
- {
- float my = margin.size.height - margin.pos.y;
- my -= margin.pos.y;
- ofs.y = -(ofs.y + my);
- }
- Rect2 dr( p_rect.pos+ofs*scale,src_c.size*scale );
-
-
+ if (scale.x < 0) {
+ float mx = (margin.size.width - margin.pos.x);
+ mx -= margin.pos.x;
+ ofs.x = -(ofs.x + mx);
+ }
+ if (scale.y < 0) {
+ float my = margin.size.height - margin.pos.y;
+ my -= margin.pos.y;
+ ofs.y = -(ofs.y + my);
+ }
+ Rect2 dr(p_rect.pos + ofs * scale, src_c.size * scale);
- r_rect=dr;
- r_src_rect=src_c;
+ r_rect = dr;
+ r_src_rect = src_c;
return true;
}
-
AtlasTexture::AtlasTexture() {
-
-
}
-
//////////////////////////////////////////
-
int LargeTexture::get_width() const {
return size.width;
@@ -712,7 +648,7 @@ RID LargeTexture::get_rid() const {
bool LargeTexture::has_alpha() const {
- for(int i=0;i<pieces.size();i++) {
+ for (int i = 0; i < pieces.size(); i++) {
if (pieces[i].texture->has_alpha())
return true;
}
@@ -722,14 +658,12 @@ bool LargeTexture::has_alpha() const {
void LargeTexture::set_flags(uint32_t p_flags) {
- for(int i=0;i<pieces.size();i++) {
+ for (int i = 0; i < pieces.size(); i++) {
pieces[i].texture->set_flags(p_flags);
}
-
}
-
-uint32_t LargeTexture::get_flags() const{
+uint32_t LargeTexture::get_flags() const {
if (pieces.size())
return pieces[0].texture->get_flags();
@@ -737,168 +671,149 @@ uint32_t LargeTexture::get_flags() const{
return 0;
}
-
-int LargeTexture::add_piece(const Point2& p_offset,const Ref<Texture>& p_texture) {
+int LargeTexture::add_piece(const Point2 &p_offset, const Ref<Texture> &p_texture) {
ERR_FAIL_COND_V(p_texture.is_null(), -1);
Piece p;
- p.offset=p_offset;
- p.texture=p_texture;
+ p.offset = p_offset;
+ p.texture = p_texture;
pieces.push_back(p);
return pieces.size() - 1;
}
-void LargeTexture::set_piece_offset(int p_idx, const Point2& p_offset) {
+void LargeTexture::set_piece_offset(int p_idx, const Point2 &p_offset) {
ERR_FAIL_INDEX(p_idx, pieces.size());
pieces[p_idx].offset = p_offset;
};
-void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture>& p_texture) {
+void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture> &p_texture) {
ERR_FAIL_INDEX(p_idx, pieces.size());
pieces[p_idx].texture = p_texture;
};
+void LargeTexture::set_size(const Size2 &p_size) {
-
-void LargeTexture::set_size(const Size2& p_size){
-
- size=p_size;
+ size = p_size;
}
-void LargeTexture::clear(){
+void LargeTexture::clear() {
pieces.clear();
- size=Size2i();
+ size = Size2i();
}
Array LargeTexture::_get_data() const {
Array arr;
- for(int i=0;i<pieces.size();i++) {
+ for (int i = 0; i < pieces.size(); i++) {
arr.push_back(pieces[i].offset);
arr.push_back(pieces[i].texture);
}
arr.push_back(Size2(size));
return arr;
-
}
-void LargeTexture::_set_data(const Array& p_array) {
+void LargeTexture::_set_data(const Array &p_array) {
- ERR_FAIL_COND(p_array.size()<1);
- ERR_FAIL_COND(!(p_array.size()&1));
+ ERR_FAIL_COND(p_array.size() < 1);
+ ERR_FAIL_COND(!(p_array.size() & 1));
clear();
- for(int i=0;i<p_array.size()-1;i+=2) {
- add_piece(p_array[i],p_array[i+1]);
+ for (int i = 0; i < p_array.size() - 1; i += 2) {
+ add_piece(p_array[i], p_array[i + 1]);
}
- size=Size2(p_array[p_array.size()-1]);
+ size = Size2(p_array[p_array.size() - 1]);
}
int LargeTexture::get_piece_count() const {
return pieces.size();
}
-Vector2 LargeTexture::get_piece_offset(int p_idx) const{
+Vector2 LargeTexture::get_piece_offset(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,pieces.size(),Vector2());
+ ERR_FAIL_INDEX_V(p_idx, pieces.size(), Vector2());
return pieces[p_idx].offset;
}
-Ref<Texture> LargeTexture::get_piece_texture(int p_idx) const{
+Ref<Texture> LargeTexture::get_piece_texture(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx,pieces.size(),Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_idx, pieces.size(), Ref<Texture>());
return pieces[p_idx].texture;
-
}
-
void LargeTexture::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_piece","ofs","texture:Texture"),&LargeTexture::add_piece);
- ObjectTypeDB::bind_method(_MD("set_piece_offset", "idx", "ofs"),&LargeTexture::set_piece_offset);
- ObjectTypeDB::bind_method(_MD("set_piece_texture","idx", "texture:Texture"),&LargeTexture::set_piece_texture);
- ObjectTypeDB::bind_method(_MD("set_size","size"),&LargeTexture::set_size);
- ObjectTypeDB::bind_method(_MD("clear"),&LargeTexture::clear);
-
- ObjectTypeDB::bind_method(_MD("get_piece_count"),&LargeTexture::get_piece_count);
- ObjectTypeDB::bind_method(_MD("get_piece_offset","idx"),&LargeTexture::get_piece_offset);
- ObjectTypeDB::bind_method(_MD("get_piece_texture:Texture","idx"),&LargeTexture::get_piece_texture);
+ ObjectTypeDB::bind_method(_MD("add_piece", "ofs", "texture:Texture"), &LargeTexture::add_piece);
+ ObjectTypeDB::bind_method(_MD("set_piece_offset", "idx", "ofs"), &LargeTexture::set_piece_offset);
+ ObjectTypeDB::bind_method(_MD("set_piece_texture", "idx", "texture:Texture"), &LargeTexture::set_piece_texture);
+ ObjectTypeDB::bind_method(_MD("set_size", "size"), &LargeTexture::set_size);
+ ObjectTypeDB::bind_method(_MD("clear"), &LargeTexture::clear);
- ObjectTypeDB::bind_method(_MD("_set_data","data"),&LargeTexture::_set_data);
- ObjectTypeDB::bind_method(_MD("_get_data"),&LargeTexture::_get_data);
+ ObjectTypeDB::bind_method(_MD("get_piece_count"), &LargeTexture::get_piece_count);
+ ObjectTypeDB::bind_method(_MD("get_piece_offset", "idx"), &LargeTexture::get_piece_offset);
+ ObjectTypeDB::bind_method(_MD("get_piece_texture:Texture", "idx"), &LargeTexture::get_piece_texture);
- ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"),_SCS("_get_data") );
+ ObjectTypeDB::bind_method(_MD("_set_data", "data"), &LargeTexture::_set_data);
+ ObjectTypeDB::bind_method(_MD("_get_data"), &LargeTexture::_get_data);
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), _SCS("_set_data"), _SCS("_get_data"));
}
+void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
-
-
-void LargeTexture::draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate, bool p_transpose) const {
-
- for(int i=0;i<pieces.size();i++) {
+ for (int i = 0; i < pieces.size(); i++) {
// TODO
- pieces[i].texture->draw(p_canvas_item,pieces[i].offset+p_pos,p_modulate,p_transpose);
+ pieces[i].texture->draw(p_canvas_item, pieces[i].offset + p_pos, p_modulate, p_transpose);
}
}
-void LargeTexture::draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile,const Color& p_modulate, bool p_transpose) const {
+void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
//tiling not supported for this
- if (size.x==0 || size.y==0)
+ if (size.x == 0 || size.y == 0)
return;
- Size2 scale = p_rect.size/size;
+ Size2 scale = p_rect.size / size;
- for(int i=0;i<pieces.size();i++) {
+ for (int i = 0; i < pieces.size(); i++) {
// TODO
- pieces[i].texture->draw_rect(p_canvas_item,Rect2(pieces[i].offset*scale+p_rect.pos,pieces[i].texture->get_size()*scale),false,p_modulate,p_transpose);
+ pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.pos, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose);
}
}
-void LargeTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate, bool p_transpose) const {
-
+void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) const {
//tiling not supported for this
- if (p_src_rect.size.x==0 || p_src_rect.size.y==0)
+ if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0)
return;
- Size2 scale = p_rect.size/p_src_rect.size;
+ Size2 scale = p_rect.size / p_src_rect.size;
- for(int i=0;i<pieces.size();i++) {
+ for (int i = 0; i < pieces.size(); i++) {
// TODO
- Rect2 rect( pieces[i].offset, pieces[i].texture->get_size());
+ Rect2 rect(pieces[i].offset, pieces[i].texture->get_size());
if (!p_src_rect.intersects(rect))
continue;
Rect2 local = p_src_rect.clip(rect);
Rect2 target = local;
- target.size*=scale;
- target.pos=p_rect.pos+(p_src_rect.pos+rect.pos)*scale;
- local.pos-=rect.pos;
- pieces[i].texture->draw_rect_region(p_canvas_item,target,local,p_modulate,p_transpose);
+ target.size *= scale;
+ target.pos = p_rect.pos + (p_src_rect.pos + rect.pos) * scale;
+ local.pos -= rect.pos;
+ pieces[i].texture->draw_rect_region(p_canvas_item, target, local, p_modulate, p_transpose);
}
-
}
-
LargeTexture::LargeTexture() {
-
-
}
-
///////////////////////////////////////////////
-
-
-
void CubeMap::set_flags(uint32_t p_flags) {
- flags=p_flags;
+ flags = p_flags;
if (_is_valid())
- VS::get_singleton()->texture_set_flags(cubemap,flags|VS::TEXTURE_FLAG_CUBEMAP);
+ VS::get_singleton()->texture_set_flags(cubemap, flags | VS::TEXTURE_FLAG_CUBEMAP);
}
uint32_t CubeMap::get_flags() const {
@@ -906,27 +821,26 @@ uint32_t CubeMap::get_flags() const {
return flags;
}
-void CubeMap::set_side(Side p_side,const Image& p_image) {
+void CubeMap::set_side(Side p_side, const Image &p_image) {
ERR_FAIL_COND(p_image.empty());
- ERR_FAIL_INDEX(p_side,6);
+ ERR_FAIL_INDEX(p_side, 6);
if (!_is_valid()) {
format = p_image.get_format();
- w=p_image.get_width();
- h=p_image.get_height();
- VS::get_singleton()->texture_allocate(cubemap,w,h,p_image.get_format(),flags|VS::TEXTURE_FLAG_CUBEMAP);
+ w = p_image.get_width();
+ h = p_image.get_height();
+ VS::get_singleton()->texture_allocate(cubemap, w, h, p_image.get_format(), flags | VS::TEXTURE_FLAG_CUBEMAP);
}
- VS::get_singleton()->texture_set_data(cubemap,p_image,VS::CubeMapSide(p_side));
- valid[p_side]=true;
+ VS::get_singleton()->texture_set_data(cubemap, p_image, VS::CubeMapSide(p_side));
+ valid[p_side] = true;
}
Image CubeMap::get_side(Side p_side) const {
if (!valid[p_side])
return Image();
- return VS::get_singleton()->texture_get_data(cubemap,VS::CubeMapSide(p_side));
-
+ return VS::get_singleton()->texture_get_data(cubemap, VS::CubeMapSide(p_side));
}
Image::Format CubeMap::get_format() const {
@@ -947,10 +861,9 @@ RID CubeMap::get_rid() const {
return cubemap;
}
-
void CubeMap::set_storage(Storage p_storage) {
- storage=p_storage;
+ storage = p_storage;
}
CubeMap::Storage CubeMap::get_storage() const {
@@ -960,7 +873,7 @@ CubeMap::Storage CubeMap::get_storage() const {
void CubeMap::set_lossy_storage_quality(float p_lossy_storage_quality) {
- lossy_storage_quality=p_lossy_storage_quality;
+ lossy_storage_quality = p_lossy_storage_quality;
}
float CubeMap::get_lossy_storage_quality() const {
@@ -968,149 +881,133 @@ float CubeMap::get_lossy_storage_quality() const {
return lossy_storage_quality;
}
-void CubeMap::set_path(const String& p_path,bool p_take_over) {
+void CubeMap::set_path(const String &p_path, bool p_take_over) {
if (cubemap.is_valid()) {
- VisualServer::get_singleton()->texture_set_path(cubemap,p_path);
+ VisualServer::get_singleton()->texture_set_path(cubemap, p_path);
}
- Resource::set_path(p_path,p_take_over);
+ Resource::set_path(p_path, p_take_over);
}
+bool CubeMap::_set(const StringName &p_name, const Variant &p_value) {
-bool CubeMap::_set(const StringName& p_name, const Variant& p_value) {
-
- if (p_name=="side/left") {
- set_side(SIDE_LEFT,p_value);
- } else if (p_name=="side/right") {
- set_side(SIDE_RIGHT,p_value);
- } else if (p_name=="side/bottom") {
- set_side(SIDE_BOTTOM,p_value);
- } else if (p_name=="side/top") {
- set_side(SIDE_TOP,p_value);
- } else if (p_name=="side/front") {
- set_side(SIDE_FRONT,p_value);
- } else if (p_name=="side/back") {
- set_side(SIDE_BACK,p_value);
- } else if (p_name=="flags") {
+ if (p_name == "side/left") {
+ set_side(SIDE_LEFT, p_value);
+ } else if (p_name == "side/right") {
+ set_side(SIDE_RIGHT, p_value);
+ } else if (p_name == "side/bottom") {
+ set_side(SIDE_BOTTOM, p_value);
+ } else if (p_name == "side/top") {
+ set_side(SIDE_TOP, p_value);
+ } else if (p_name == "side/front") {
+ set_side(SIDE_FRONT, p_value);
+ } else if (p_name == "side/back") {
+ set_side(SIDE_BACK, p_value);
+ } else if (p_name == "flags") {
set_flags(p_value);
- } else if (p_name=="storage") {
- storage=Storage(p_value.operator int());
- } else if (p_name=="lossy_quality") {
- lossy_storage_quality=p_value;
+ } else if (p_name == "storage") {
+ storage = Storage(p_value.operator int());
+ } else if (p_name == "lossy_quality") {
+ lossy_storage_quality = p_value;
} else
return false;
return true;
-
}
-bool CubeMap::_get(const StringName& p_name,Variant &r_ret) const {
+bool CubeMap::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name=="side/left") {
- r_ret=get_side(SIDE_LEFT);
- } else if (p_name=="side/right") {
- r_ret=get_side(SIDE_RIGHT);
- } else if (p_name=="side/bottom") {
- r_ret=get_side(SIDE_BOTTOM);
- } else if (p_name=="side/top") {
- r_ret=get_side(SIDE_TOP);
- } else if (p_name=="side/front") {
- r_ret=get_side(SIDE_FRONT);
- } else if (p_name=="side/back") {
- r_ret=get_side(SIDE_BACK);
- } else if (p_name=="flags") {
- r_ret= flags;
- } else if (p_name=="storage") {
- r_ret= storage;
- } else if (p_name=="lossy_quality") {
- r_ret= lossy_storage_quality;
+ if (p_name == "side/left") {
+ r_ret = get_side(SIDE_LEFT);
+ } else if (p_name == "side/right") {
+ r_ret = get_side(SIDE_RIGHT);
+ } else if (p_name == "side/bottom") {
+ r_ret = get_side(SIDE_BOTTOM);
+ } else if (p_name == "side/top") {
+ r_ret = get_side(SIDE_TOP);
+ } else if (p_name == "side/front") {
+ r_ret = get_side(SIDE_FRONT);
+ } else if (p_name == "side/back") {
+ r_ret = get_side(SIDE_BACK);
+ } else if (p_name == "flags") {
+ r_ret = flags;
+ } else if (p_name == "storage") {
+ r_ret = storage;
+ } else if (p_name == "lossy_quality") {
+ r_ret = lossy_storage_quality;
} else
return false;
return true;
}
+void CubeMap::_get_property_list(List<PropertyInfo> *p_list) const {
-
-
-void CubeMap::_get_property_list( List<PropertyInfo> *p_list) const {
-
-
- PropertyHint img_hint=PROPERTY_HINT_NONE;
- if (storage==STORAGE_COMPRESS_LOSSY) {
- img_hint=PROPERTY_HINT_IMAGE_COMPRESS_LOSSY;
- } else if (storage==STORAGE_COMPRESS_LOSSLESS) {
- img_hint=PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS;
+ PropertyHint img_hint = PROPERTY_HINT_NONE;
+ if (storage == STORAGE_COMPRESS_LOSSY) {
+ img_hint = PROPERTY_HINT_IMAGE_COMPRESS_LOSSY;
+ } else if (storage == STORAGE_COMPRESS_LOSSLESS) {
+ img_hint = PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS;
}
-
- p_list->push_back( PropertyInfo( Variant::INT, "flags", PROPERTY_HINT_FLAGS,"Mipmaps,Repeat,Filter" ) );
- p_list->push_back( PropertyInfo( Variant::IMAGE, "side/left", img_hint,String::num(lossy_storage_quality)) );
- p_list->push_back( PropertyInfo( Variant::IMAGE, "side/right", img_hint,String::num(lossy_storage_quality)) );
- p_list->push_back( PropertyInfo( Variant::IMAGE, "side/bottom", img_hint,String::num(lossy_storage_quality)) );
- p_list->push_back( PropertyInfo( Variant::IMAGE, "side/top", img_hint,String::num(lossy_storage_quality)) );
- p_list->push_back( PropertyInfo( Variant::IMAGE, "side/front", img_hint,String::num(lossy_storage_quality)) );
- p_list->push_back( PropertyInfo( Variant::IMAGE, "side/back", img_hint,String::num(lossy_storage_quality)) );
- p_list->push_back( PropertyInfo( Variant::INT, "storage", PROPERTY_HINT_ENUM,"Uncompressed,Compress Lossy,Compress Lossless",PROPERTY_USAGE_EDITOR));
- p_list->push_back( PropertyInfo( Variant::REAL, "lossy_quality", PROPERTY_HINT_RANGE,"0.0,1.0,0.01" ) );
+ p_list->push_back(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter"));
+ p_list->push_back(PropertyInfo(Variant::IMAGE, "side/left", img_hint, String::num(lossy_storage_quality)));
+ p_list->push_back(PropertyInfo(Variant::IMAGE, "side/right", img_hint, String::num(lossy_storage_quality)));
+ p_list->push_back(PropertyInfo(Variant::IMAGE, "side/bottom", img_hint, String::num(lossy_storage_quality)));
+ p_list->push_back(PropertyInfo(Variant::IMAGE, "side/top", img_hint, String::num(lossy_storage_quality)));
+ p_list->push_back(PropertyInfo(Variant::IMAGE, "side/front", img_hint, String::num(lossy_storage_quality)));
+ p_list->push_back(PropertyInfo(Variant::IMAGE, "side/back", img_hint, String::num(lossy_storage_quality)));
+ p_list->push_back(PropertyInfo(Variant::INT, "storage", PROPERTY_HINT_ENUM, "Uncompressed,Compress Lossy,Compress Lossless", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::REAL, "lossy_quality", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));
}
void CubeMap::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_width"),&CubeMap::get_width);
- ObjectTypeDB::bind_method(_MD("get_height"),&CubeMap::get_height);
- ObjectTypeDB::bind_method(_MD("get_rid"),&CubeMap::get_rid);
- ObjectTypeDB::bind_method(_MD("set_flags","flags"),&CubeMap::set_flags);
- ObjectTypeDB::bind_method(_MD("get_flags"),&CubeMap::get_flags);
-
- ObjectTypeDB::bind_method(_MD("set_side","side","image"),&CubeMap::set_side);
- ObjectTypeDB::bind_method(_MD("get_side","side"),&CubeMap::get_side);
- ObjectTypeDB::bind_method(_MD("set_storage","mode"),&CubeMap::set_storage);
- ObjectTypeDB::bind_method(_MD("get_storage"),&CubeMap::get_storage);
- ObjectTypeDB::bind_method(_MD("set_lossy_storage_quality","quality"),&CubeMap::set_lossy_storage_quality);
- ObjectTypeDB::bind_method(_MD("get_lossy_storage_quality"),&CubeMap::get_lossy_storage_quality);
-
-
- BIND_CONSTANT( STORAGE_RAW );
- BIND_CONSTANT( STORAGE_COMPRESS_LOSSY );
- BIND_CONSTANT( STORAGE_COMPRESS_LOSSLESS );
- BIND_CONSTANT( SIDE_LEFT );
- BIND_CONSTANT( SIDE_RIGHT );
- BIND_CONSTANT( SIDE_BOTTOM );
- BIND_CONSTANT( SIDE_TOP );
- BIND_CONSTANT( SIDE_FRONT );
- BIND_CONSTANT( SIDE_BACK );
- BIND_CONSTANT( FLAG_MIPMAPS );
- BIND_CONSTANT( FLAG_REPEAT );
- BIND_CONSTANT( FLAG_FILTER );
- BIND_CONSTANT( FLAGS_DEFAULT );
+ ObjectTypeDB::bind_method(_MD("get_width"), &CubeMap::get_width);
+ ObjectTypeDB::bind_method(_MD("get_height"), &CubeMap::get_height);
+ ObjectTypeDB::bind_method(_MD("get_rid"), &CubeMap::get_rid);
+ ObjectTypeDB::bind_method(_MD("set_flags", "flags"), &CubeMap::set_flags);
+ ObjectTypeDB::bind_method(_MD("get_flags"), &CubeMap::get_flags);
+ ObjectTypeDB::bind_method(_MD("set_side", "side", "image"), &CubeMap::set_side);
+ ObjectTypeDB::bind_method(_MD("get_side", "side"), &CubeMap::get_side);
+ ObjectTypeDB::bind_method(_MD("set_storage", "mode"), &CubeMap::set_storage);
+ ObjectTypeDB::bind_method(_MD("get_storage"), &CubeMap::get_storage);
+ ObjectTypeDB::bind_method(_MD("set_lossy_storage_quality", "quality"), &CubeMap::set_lossy_storage_quality);
+ ObjectTypeDB::bind_method(_MD("get_lossy_storage_quality"), &CubeMap::get_lossy_storage_quality);
+ BIND_CONSTANT(STORAGE_RAW);
+ BIND_CONSTANT(STORAGE_COMPRESS_LOSSY);
+ BIND_CONSTANT(STORAGE_COMPRESS_LOSSLESS);
+ BIND_CONSTANT(SIDE_LEFT);
+ BIND_CONSTANT(SIDE_RIGHT);
+ BIND_CONSTANT(SIDE_BOTTOM);
+ BIND_CONSTANT(SIDE_TOP);
+ BIND_CONSTANT(SIDE_FRONT);
+ BIND_CONSTANT(SIDE_BACK);
+ BIND_CONSTANT(FLAG_MIPMAPS);
+ BIND_CONSTANT(FLAG_REPEAT);
+ BIND_CONSTANT(FLAG_FILTER);
+ BIND_CONSTANT(FLAGS_DEFAULT);
}
CubeMap::CubeMap() {
- w=h=0;
- flags=FLAGS_DEFAULT;
- for(int i=0;i<6;i++)
- valid[i]=false;
+ w = h = 0;
+ flags = FLAGS_DEFAULT;
+ for (int i = 0; i < 6; i++)
+ valid[i] = false;
cubemap = VisualServer::get_singleton()->texture_create();
storage = STORAGE_RAW;
- lossy_storage_quality=0.7;
-
-
+ lossy_storage_quality = 0.7;
}
-
CubeMap::~CubeMap() {
- VisualServer::get_singleton()->free( cubemap );
+ VisualServer::get_singleton()->free(cubemap);
}
-
-
-
/* BIND_CONSTANT( FLAG_CUBEMAP );
BIND_CONSTANT( CUBEMAP_LEFT );
BIND_CONSTANT( CUBEMAP_RIGHT );
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index abc2939f2..f14be0b1e 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -29,75 +29,70 @@
#ifndef TEXTURE_H
#define TEXTURE_H
+#include "math_2d.h"
#include "resource.h"
#include "servers/visual_server.h"
-#include "math_2d.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
-
class Texture : public Resource {
- OBJ_TYPE( Texture, Resource );
- OBJ_SAVE_TYPE( Texture ); //children are all saved as Texture, so they can be exchanged
+ OBJ_TYPE(Texture, Resource);
+ OBJ_SAVE_TYPE(Texture); //children are all saved as Texture, so they can be exchanged
protected:
-
static void _bind_methods();
-public:
+public:
enum Flags {
- FLAG_MIPMAPS=VisualServer::TEXTURE_FLAG_MIPMAPS,
- FLAG_REPEAT=VisualServer::TEXTURE_FLAG_REPEAT,
- FLAG_FILTER=VisualServer::TEXTURE_FLAG_FILTER,
- FLAG_ANISOTROPIC_FILTER=VisualServer::TEXTURE_FLAG_ANISOTROPIC_FILTER,
- FLAG_CONVERT_TO_LINEAR=VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR,
- FLAG_VIDEO_SURFACE=VisualServer::TEXTURE_FLAG_VIDEO_SURFACE,
- FLAGS_DEFAULT=FLAG_MIPMAPS|FLAG_REPEAT|FLAG_FILTER,
- FLAG_MIRRORED_REPEAT=VisualServer::TEXTURE_FLAG_MIRRORED_REPEAT
+ FLAG_MIPMAPS = VisualServer::TEXTURE_FLAG_MIPMAPS,
+ FLAG_REPEAT = VisualServer::TEXTURE_FLAG_REPEAT,
+ FLAG_FILTER = VisualServer::TEXTURE_FLAG_FILTER,
+ FLAG_ANISOTROPIC_FILTER = VisualServer::TEXTURE_FLAG_ANISOTROPIC_FILTER,
+ FLAG_CONVERT_TO_LINEAR = VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR,
+ FLAG_VIDEO_SURFACE = VisualServer::TEXTURE_FLAG_VIDEO_SURFACE,
+ FLAGS_DEFAULT = FLAG_MIPMAPS | FLAG_REPEAT | FLAG_FILTER,
+ FLAG_MIRRORED_REPEAT = VisualServer::TEXTURE_FLAG_MIRRORED_REPEAT
};
-
- virtual int get_width() const=0;
- virtual int get_height() const=0;
+ virtual int get_width() const = 0;
+ virtual int get_height() const = 0;
virtual Size2 get_size() const;
- virtual RID get_rid() const=0;
-
- virtual bool has_alpha() const=0;
+ virtual RID get_rid() const = 0;
- virtual void set_flags(uint32_t p_flags)=0;
- virtual uint32_t get_flags() const=0;
-
- virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const;
+ virtual bool has_alpha() const = 0;
+ virtual void set_flags(uint32_t p_flags) = 0;
+ virtual uint32_t get_flags() const = 0;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
Texture();
};
-VARIANT_ENUM_CAST( Texture::Flags );
-
+VARIANT_ENUM_CAST(Texture::Flags);
class ImageTexture : public Texture {
- OBJ_TYPE( ImageTexture, Texture );
+ OBJ_TYPE(ImageTexture, Texture);
RES_BASE_EXTENSION("tex");
+
public:
enum Storage {
STORAGE_RAW,
STORAGE_COMPRESS_LOSSY,
STORAGE_COMPRESS_LOSSLESS
};
+
private:
RID texture;
Image::Format format;
uint32_t flags;
- int w,h;
+ int w, h;
Storage storage;
Size2 size_override;
float lossy_storage_quality;
@@ -105,28 +100,25 @@ private:
protected:
virtual void reload_from_file();
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
- void _reload_hook(const RID& p_hook);
+ void _reload_hook(const RID &p_hook);
virtual void _resource_path_changed();
static void _bind_methods();
void _set_data(Dictionary p_data);
public:
-
-
- void create(int p_width, int p_height,Image::Format p_format,uint32_t p_flags=FLAGS_DEFAULT);
- void create_from_image(const Image& p_image, uint32_t p_flags=FLAGS_DEFAULT);
-
+ void create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags = FLAGS_DEFAULT);
+ void create_from_image(const Image &p_image, uint32_t p_flags = FLAGS_DEFAULT);
void set_flags(uint32_t p_flags);
uint32_t get_flags() const;
Image::Format get_format() const;
- void load(const String& p_path);
- void set_data(const Image& p_image);
+ void load(const String &p_path);
+ void set_data(const Image &p_image);
Image get_data() const;
int get_width() const;
@@ -135,9 +127,9 @@ public:
virtual RID get_rid() const;
bool has_alpha() const;
- virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
void set_storage(Storage p_storage);
Storage get_storage() const;
@@ -149,33 +141,29 @@ public:
void normal_to_xy();
void shrink_x2_and_keep_size();
+ void set_size_override(const Size2 &p_size);
- void set_size_override(const Size2& p_size);
-
- virtual void set_path(const String& p_path,bool p_take_over=false);
+ virtual void set_path(const String &p_path, bool p_take_over = false);
ImageTexture();
~ImageTexture();
-
};
-
-VARIANT_ENUM_CAST( ImageTexture::Storage );
+VARIANT_ENUM_CAST(ImageTexture::Storage);
class AtlasTexture : public Texture {
- OBJ_TYPE( AtlasTexture, Texture );
+ OBJ_TYPE(AtlasTexture, Texture);
RES_BASE_EXTENSION("atex");
-protected:
-
+protected:
Ref<Texture> atlas;
Rect2 region;
Rect2 margin;
static void _bind_methods();
-public:
+public:
virtual int get_width() const;
virtual int get_height() const;
virtual RID get_rid() const;
@@ -185,30 +173,29 @@ public:
virtual void set_flags(uint32_t p_flags);
virtual uint32_t get_flags() const;
- void set_atlas(const Ref<Texture>& p_atlas);
+ void set_atlas(const Ref<Texture> &p_atlas);
Ref<Texture> get_atlas() const;
- void set_region(const Rect2& p_region);
- Rect2 get_region() const ;
+ void set_region(const Rect2 &p_region);
+ Rect2 get_region() const;
- void set_margin(const Rect2& p_margin);
- Rect2 get_margin() const ;
-
- virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const;
+ void set_margin(const Rect2 &p_margin);
+ Rect2 get_margin() const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
AtlasTexture();
};
class LargeTexture : public Texture {
- OBJ_TYPE( LargeTexture, Texture );
+ OBJ_TYPE(LargeTexture, Texture);
RES_BASE_EXTENSION("ltex");
-protected:
+protected:
struct Piece {
Point2 offset;
@@ -218,12 +205,11 @@ protected:
Vector<Piece> pieces;
Size2i size;
-
Array _get_data() const;
- void _set_data(const Array& p_array);
+ void _set_data(const Array &p_array);
static void _bind_methods();
-public:
+public:
virtual int get_width() const;
virtual int get_height() const;
virtual RID get_rid() const;
@@ -233,31 +219,29 @@ public:
virtual void set_flags(uint32_t p_flags);
virtual uint32_t get_flags() const;
- int add_piece(const Point2& p_offset,const Ref<Texture>& p_texture);
- void set_piece_offset(int p_idx, const Point2& p_offset);
- void set_piece_texture(int p_idx, const Ref<Texture>& p_texture);
+ int add_piece(const Point2 &p_offset, const Ref<Texture> &p_texture);
+ void set_piece_offset(int p_idx, const Point2 &p_offset);
+ void set_piece_texture(int p_idx, const Ref<Texture> &p_texture);
- void set_size(const Size2& p_size);
+ void set_size(const Size2 &p_size);
void clear();
int get_piece_count() const;
Vector2 get_piece_offset(int p_idx) const;
Ref<Texture> get_piece_texture(int p_idx) const;
- virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
- virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1), bool p_transpose=false) const;
-
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
LargeTexture();
};
-
-
class CubeMap : public Resource {
- OBJ_TYPE( CubeMap, Resource );
+ OBJ_TYPE(CubeMap, Resource);
RES_BASE_EXTENSION("cbm");
+
public:
enum Storage {
STORAGE_RAW,
@@ -276,37 +260,40 @@ public:
};
enum Flags {
- FLAG_MIPMAPS=VisualServer::TEXTURE_FLAG_MIPMAPS,
- FLAG_REPEAT=VisualServer::TEXTURE_FLAG_REPEAT,
- FLAG_FILTER=VisualServer::TEXTURE_FLAG_FILTER,
- FLAGS_DEFAULT=FLAG_MIPMAPS|FLAG_REPEAT|FLAG_FILTER,
+ FLAG_MIPMAPS = VisualServer::TEXTURE_FLAG_MIPMAPS,
+ FLAG_REPEAT = VisualServer::TEXTURE_FLAG_REPEAT,
+ FLAG_FILTER = VisualServer::TEXTURE_FLAG_FILTER,
+ FLAGS_DEFAULT = FLAG_MIPMAPS | FLAG_REPEAT | FLAG_FILTER,
};
private:
-
bool valid[6];
RID cubemap;
Image::Format format;
uint32_t flags;
- int w,h;
+ int w, h;
Storage storage;
Size2 size_override;
float lossy_storage_quality;
- _FORCE_INLINE_ bool _is_valid() const { for(int i=0;i<6;i++) { if (valid[i]) return true; } return false; }
+ _FORCE_INLINE_ bool _is_valid() const {
+ for (int i = 0; i < 6; i++) {
+ if (valid[i]) return true;
+ }
+ return false;
+ }
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static void _bind_methods();
-public:
+public:
void set_flags(uint32_t p_flags);
uint32_t get_flags() const;
- void set_side(Side p_side,const Image& p_image);
+ void set_side(Side p_side, const Image &p_image);
Image get_side(Side p_side) const;
Image::Format get_format() const;
@@ -321,17 +308,15 @@ public:
void set_lossy_storage_quality(float p_lossy_storage_quality);
float get_lossy_storage_quality() const;
- virtual void set_path(const String& p_path,bool p_take_over=false);
+ virtual void set_path(const String &p_path, bool p_take_over = false);
CubeMap();
~CubeMap();
-
};
-VARIANT_ENUM_CAST( CubeMap::Flags );
-VARIANT_ENUM_CAST( CubeMap::Side );
-VARIANT_ENUM_CAST( CubeMap::Storage );
-
+VARIANT_ENUM_CAST(CubeMap::Flags);
+VARIANT_ENUM_CAST(CubeMap::Side);
+VARIANT_ENUM_CAST(CubeMap::Storage);
/*
enum CubeMapSide {
@@ -347,5 +332,4 @@ VARIANT_ENUM_CAST( CubeMap::Storage );
*/
//VARIANT_ENUM_CAST( Texture::CubeMapSide );
-
#endif
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 9f21158fe..b8be61dd2 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -27,64 +27,61 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "theme.h"
-#include "print_string.h"
#include "os/file_access.h"
-
+#include "print_string.h"
Ref<Theme> Theme::default_theme;
-
void Theme::_emit_theme_changed() {
emit_changed();
}
-void Theme::_ref_font( Ref<Font> p_sc) {
+void Theme::_ref_font(Ref<Font> p_sc) {
if (!font_refcount.has(p_sc)) {
- font_refcount[p_sc]=1;
- p_sc->connect("changed",this,"_emit_theme_changed");
+ font_refcount[p_sc] = 1;
+ p_sc->connect("changed", this, "_emit_theme_changed");
} else {
- font_refcount[p_sc]+=1;
+ font_refcount[p_sc] += 1;
}
}
-void Theme::_unref_font(Ref<Font> p_sc) {
+void Theme::_unref_font(Ref<Font> p_sc) {
ERR_FAIL_COND(!font_refcount.has(p_sc));
font_refcount[p_sc]--;
- if (font_refcount[p_sc]==0) {
- p_sc->disconnect("changed",this,"_emit_theme_changed");
+ if (font_refcount[p_sc] == 0) {
+ p_sc->disconnect("changed", this, "_emit_theme_changed");
font_refcount.erase(p_sc);
}
}
+bool Theme::_set(const StringName &p_name, const Variant &p_value) {
-bool Theme::_set(const StringName& p_name, const Variant& p_value) {
-
- String sname=p_name;
+ String sname = p_name;
- if (sname.find("/")!=-1) {
+ if (sname.find("/") != -1) {
- String type=sname.get_slicec('/',1);
- String node_type=sname.get_slicec('/',0);
- String name=sname.get_slicec('/',2);
+ String type = sname.get_slicec('/', 1);
+ String node_type = sname.get_slicec('/', 0);
+ String name = sname.get_slicec('/', 2);
- if (type=="icons") {
+ if (type == "icons") {
- set_icon(name,node_type,p_value);
- } else if (type=="styles") {
+ set_icon(name, node_type, p_value);
+ } else if (type == "styles") {
- set_stylebox(name,node_type,p_value);
- } else if (type=="fonts") {
+ set_stylebox(name, node_type, p_value);
+ } else if (type == "fonts") {
- set_font(name,node_type,p_value);
- } else if (type=="colors") {
+ set_font(name, node_type, p_value);
+ } else if (type == "colors") {
- set_color(name,node_type,p_value);
- } else if (type=="constants") {
+ set_color(name, node_type, p_value);
+ } else if (type == "constants") {
- set_constant(name,node_type,p_value);
+ set_constant(name, node_type, p_value);
} else
return false;
@@ -92,43 +89,42 @@ bool Theme::_set(const StringName& p_name, const Variant& p_value) {
}
return false;
-
}
-bool Theme::_get(const StringName& p_name,Variant &r_ret) const {
+bool Theme::_get(const StringName &p_name, Variant &r_ret) const {
- String sname=p_name;
+ String sname = p_name;
- if (sname.find("/")!=-1) {
+ if (sname.find("/") != -1) {
- String type=sname.get_slicec('/',1);
- String node_type=sname.get_slicec('/',0);
- String name=sname.get_slicec('/',2);
+ String type = sname.get_slicec('/', 1);
+ String node_type = sname.get_slicec('/', 0);
+ String name = sname.get_slicec('/', 2);
- if (type=="icons") {
+ if (type == "icons") {
- if (!has_icon(name,node_type))
- r_ret=Ref<Texture>();
+ if (!has_icon(name, node_type))
+ r_ret = Ref<Texture>();
else
- r_ret= get_icon(name,node_type);
- } else if (type=="styles") {
+ r_ret = get_icon(name, node_type);
+ } else if (type == "styles") {
- if (!has_stylebox(name,node_type))
- r_ret=Ref<StyleBox>();
+ if (!has_stylebox(name, node_type))
+ r_ret = Ref<StyleBox>();
else
- r_ret= get_stylebox(name,node_type);
- } else if (type=="fonts") {
+ r_ret = get_stylebox(name, node_type);
+ } else if (type == "fonts") {
- if (!has_font(name,node_type))
- r_ret=Ref<Font>();
+ if (!has_font(name, node_type))
+ r_ret = Ref<Font>();
else
- r_ret= get_font(name,node_type);
- } else if (type=="colors") {
+ r_ret = get_font(name, node_type);
+ } else if (type == "colors") {
- r_ret= get_color(name,node_type);
- } else if (type=="constants") {
+ r_ret = get_color(name, node_type);
+ } else if (type == "constants") {
- r_ret= get_constant(name,node_type);
+ r_ret = get_constant(name, node_type);
} else
return false;
@@ -138,77 +134,74 @@ bool Theme::_get(const StringName& p_name,Variant &r_ret) const {
return false;
}
-void Theme::_get_property_list( List<PropertyInfo> *p_list) const {
-
+void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
List<PropertyInfo> list;
- const StringName *key=NULL;
+ const StringName *key = NULL;
- while((key=icon_map.next(key))) {
+ while ((key = icon_map.next(key))) {
- const StringName *key2=NULL;
+ const StringName *key2 = NULL;
- while((key2=icon_map[*key].next(key2))) {
+ while ((key2 = icon_map[*key].next(key2))) {
- list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/icons/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_STORE_IF_NULL ) );
+ list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/icons/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
- key=NULL;
+ key = NULL;
- while((key=style_map.next(key))) {
+ while ((key = style_map.next(key))) {
- const StringName *key2=NULL;
+ const StringName *key2 = NULL;
- while((key2=style_map[*key].next(key2))) {
+ while ((key2 = style_map[*key].next(key2))) {
- list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/styles/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_STORE_IF_NULL ) );
+ list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/styles/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
- key=NULL;
+ key = NULL;
+ while ((key = font_map.next(key))) {
- while((key=font_map.next(key))) {
+ const StringName *key2 = NULL;
- const StringName *key2=NULL;
+ while ((key2 = font_map[*key].next(key2))) {
- while((key2=font_map[*key].next(key2))) {
-
- list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/fonts/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Font",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_STORE_IF_NULL ) );
+ list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/fonts/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
- key=NULL;
+ key = NULL;
- while((key=color_map.next(key))) {
+ while ((key = color_map.next(key))) {
- const StringName *key2=NULL;
+ const StringName *key2 = NULL;
- while((key2=color_map[*key].next(key2))) {
+ while ((key2 = color_map[*key].next(key2))) {
- list.push_back( PropertyInfo( Variant::COLOR, String()+*key+"/colors/"+*key2 ) );
+ list.push_back(PropertyInfo(Variant::COLOR, String() + *key + "/colors/" + *key2));
}
}
- key=NULL;
+ key = NULL;
- while((key=constant_map.next(key))) {
+ while ((key = constant_map.next(key))) {
- const StringName *key2=NULL;
+ const StringName *key2 = NULL;
- while((key2=constant_map[*key].next(key2))) {
+ while ((key2 = constant_map[*key].next(key2))) {
- list.push_back( PropertyInfo( Variant::INT, String()+*key+"/constants/"+*key2 ) );
+ list.push_back(PropertyInfo(Variant::INT, String() + *key + "/constants/" + *key2));
}
}
list.sort();
- for(List<PropertyInfo>::Element *E=list.front();E;E=E->next()) {
+ for (List<PropertyInfo>::Element *E = list.front(); E; E = E->next()) {
p_list->push_back(E->get());
}
-
}
Ref<Theme> Theme::get_default() {
@@ -216,17 +209,16 @@ Ref<Theme> Theme::get_default() {
return default_theme;
}
+void Theme::set_default_theme_font(const Ref<Font> &p_default_font) {
-void Theme::set_default_theme_font( const Ref<Font>& p_default_font ) {
-
- if (default_theme_font==p_default_font)
+ if (default_theme_font == p_default_font)
return;
if (default_theme_font.is_valid()) {
_unref_font(default_theme_font);
}
- default_theme_font=p_default_font;
+ default_theme_font = p_default_font;
if (default_theme_font.is_valid()) {
_ref_font(default_theme_font);
@@ -234,7 +226,6 @@ void Theme::set_default_theme_font( const Ref<Font>& p_default_font ) {
_change_notify();
emit_changed();
-
}
Ref<Font> Theme::get_default_theme_font() const {
@@ -242,43 +233,42 @@ Ref<Font> Theme::get_default_theme_font() const {
return default_theme_font;
}
-void Theme::set_default(const Ref<Theme>& p_default) {
+void Theme::set_default(const Ref<Theme> &p_default) {
- default_theme=p_default;
+ default_theme = p_default;
}
Ref<Texture> Theme::default_icon;
Ref<StyleBox> Theme::default_style;
Ref<Font> Theme::default_font;
+void Theme::set_default_icon(const Ref<Texture> &p_icon) {
-void Theme::set_default_icon( const Ref<Texture>& p_icon ) {
-
- default_icon=p_icon;
+ default_icon = p_icon;
}
-void Theme::set_default_style( const Ref<StyleBox>& p_style) {
+void Theme::set_default_style(const Ref<StyleBox> &p_style) {
- default_style=p_style;
+ default_style = p_style;
}
-void Theme::set_default_font( const Ref<Font>& p_font ) {
+void Theme::set_default_font(const Ref<Font> &p_font) {
- default_font=p_font;
+ default_font = p_font;
}
-void Theme::set_icon(const StringName& p_name,const StringName& p_type,const Ref<Texture>& p_icon) {
+void Theme::set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture> &p_icon) {
-// ERR_FAIL_COND(p_icon.is_null());
+ // ERR_FAIL_COND(p_icon.is_null());
- bool new_value=!icon_map.has(p_type) || !icon_map[p_type].has(p_name);
+ bool new_value = !icon_map.has(p_type) || !icon_map[p_type].has(p_name);
- icon_map[p_type][p_name]=p_icon;
+ icon_map[p_type][p_name] = p_icon;
if (new_value) {
_change_notify();
emit_changed();
}
}
-Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type) const {
+Ref<Texture> Theme::get_icon(const StringName &p_name, const StringName &p_type) const {
if (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) {
@@ -288,13 +278,12 @@ Ref<Texture> Theme::get_icon(const StringName& p_name,const StringName& p_type)
}
}
-bool Theme::has_icon(const StringName& p_name,const StringName& p_type) const {
+bool Theme::has_icon(const StringName &p_name, const StringName &p_type) const {
return (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid());
}
-
-void Theme::clear_icon(const StringName& p_name,const StringName& p_type) {
+void Theme::clear_icon(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!icon_map.has(p_type));
ERR_FAIL_COND(!icon_map[p_type].has(p_name));
@@ -302,7 +291,6 @@ void Theme::clear_icon(const StringName& p_name,const StringName& p_type) {
icon_map[p_type].erase(p_name);
_change_notify();
emit_changed();
-
}
void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const {
@@ -310,19 +298,18 @@ void Theme::get_icon_list(StringName p_type, List<StringName> *p_list) const {
if (!icon_map.has(p_type))
return;
- const StringName *key=NULL;
+ const StringName *key = NULL;
- while((key=icon_map[p_type].next(key))) {
+ while ((key = icon_map[p_type].next(key))) {
p_list->push_back(*key);
}
-
}
-void Theme::set_shader(const StringName &p_name,const StringName &p_type,const Ref<Shader>& p_shader) {
- bool new_value=!shader_map.has(p_type) || !shader_map[p_type].has(p_name);
+void Theme::set_shader(const StringName &p_name, const StringName &p_type, const Ref<Shader> &p_shader) {
+ bool new_value = !shader_map.has(p_type) || !shader_map[p_type].has(p_name);
- shader_map[p_type][p_name]=p_shader;
+ shader_map[p_type][p_name] = p_shader;
if (new_value) {
_change_notify();
@@ -355,48 +342,43 @@ void Theme::get_shader_list(const StringName &p_type, List<StringName> *p_list)
if (!shader_map.has(p_type))
return;
- const StringName *key=NULL;
+ const StringName *key = NULL;
- while((key=shader_map[p_type].next(key))) {
+ while ((key = shader_map[p_type].next(key))) {
p_list->push_back(*key);
}
-
}
+void Theme::set_stylebox(const StringName &p_name, const StringName &p_type, const Ref<StyleBox> &p_style) {
-void Theme::set_stylebox(const StringName& p_name,const StringName& p_type,const Ref<StyleBox>& p_style) {
-
-// ERR_FAIL_COND(p_style.is_null());
+ // ERR_FAIL_COND(p_style.is_null());
- bool new_value=!style_map.has(p_type) || !style_map[p_type].has(p_name);
+ bool new_value = !style_map.has(p_type) || !style_map[p_type].has(p_name);
- style_map[p_type][p_name]=p_style;
+ style_map[p_type][p_name] = p_style;
if (new_value)
_change_notify();
emit_changed();
-
}
-
-Ref<StyleBox> Theme::get_stylebox(const StringName& p_name,const StringName& p_type) const {
+Ref<StyleBox> Theme::get_stylebox(const StringName &p_name, const StringName &p_type) const {
if (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid()) {
return style_map[p_type][p_name];
} else {
return default_style;
-
}
}
-bool Theme::has_stylebox(const StringName& p_name,const StringName& p_type) const {
+bool Theme::has_stylebox(const StringName &p_name, const StringName &p_type) const {
return (style_map.has(p_type) && style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid());
}
-void Theme::clear_stylebox(const StringName& p_name,const StringName& p_type) {
+void Theme::clear_stylebox(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!style_map.has(p_type));
ERR_FAIL_COND(!style_map[p_type].has(p_name));
@@ -404,7 +386,6 @@ void Theme::clear_stylebox(const StringName& p_name,const StringName& p_type) {
style_map[p_type].erase(p_name);
_change_notify();
emit_changed();
-
}
void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const {
@@ -412,34 +393,33 @@ void Theme::get_stylebox_list(StringName p_type, List<StringName> *p_list) const
if (!style_map.has(p_type))
return;
- const StringName *key=NULL;
+ const StringName *key = NULL;
- while((key=style_map[p_type].next(key))) {
+ while ((key = style_map[p_type].next(key))) {
p_list->push_back(*key);
}
-
}
void Theme::get_stylebox_types(List<StringName> *p_list) const {
- const StringName *key=NULL;
- while((key=style_map.next(key))) {
+ const StringName *key = NULL;
+ while ((key = style_map.next(key))) {
p_list->push_back(*key);
}
}
-void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref<Font>& p_font) {
+void Theme::set_font(const StringName &p_name, const StringName &p_type, const Ref<Font> &p_font) {
-// ERR_FAIL_COND(p_font.is_null());
+ // ERR_FAIL_COND(p_font.is_null());
- bool new_value=!font_map.has(p_type) || !font_map[p_type].has(p_name);
+ bool new_value = !font_map.has(p_type) || !font_map[p_type].has(p_name);
if (!new_value) {
if (font_map[p_type][p_name].is_valid()) {
_unref_font(font_map[p_type][p_name]);
}
}
- font_map[p_type][p_name]=p_font;
+ font_map[p_type][p_name] = p_font;
if (p_font.is_valid()) {
_ref_font(p_font);
@@ -450,7 +430,7 @@ void Theme::set_font(const StringName& p_name,const StringName& p_type,const Ref
emit_changed();
}
}
-Ref<Font> Theme::get_font(const StringName& p_name,const StringName& p_type) const {
+Ref<Font> Theme::get_font(const StringName &p_name, const StringName &p_type) const {
if (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid())
return font_map[p_type][p_name];
@@ -458,15 +438,14 @@ Ref<Font> Theme::get_font(const StringName& p_name,const StringName& p_type) con
return default_theme_font;
else
return default_font;
-
}
-bool Theme::has_font(const StringName& p_name,const StringName& p_type) const {
+bool Theme::has_font(const StringName &p_name, const StringName &p_type) const {
return (font_map.has(p_type) && font_map[p_type].has(p_name) && font_map[p_type][p_name].is_valid());
}
-void Theme::clear_font(const StringName& p_name,const StringName& p_type) {
+void Theme::clear_font(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!font_map.has(p_type));
ERR_FAIL_COND(!font_map[p_type].has(p_name));
@@ -478,7 +457,6 @@ void Theme::clear_font(const StringName& p_name,const StringName& p_type) {
font_map[p_type].erase(p_name);
_change_notify();
emit_changed();
-
}
void Theme::get_font_list(StringName p_type, List<StringName> *p_list) const {
@@ -486,45 +464,40 @@ void Theme::get_font_list(StringName p_type, List<StringName> *p_list) const {
if (!font_map.has(p_type))
return;
- const StringName *key=NULL;
+ const StringName *key = NULL;
- while((key=font_map[p_type].next(key))) {
+ while ((key = font_map[p_type].next(key))) {
p_list->push_back(*key);
}
-
}
-void Theme::set_color(const StringName& p_name,const StringName& p_type,const Color& p_color) {
+void Theme::set_color(const StringName &p_name, const StringName &p_type, const Color &p_color) {
- bool new_value=!color_map.has(p_type) || !color_map[p_type].has(p_name);
+ bool new_value = !color_map.has(p_type) || !color_map[p_type].has(p_name);
- color_map[p_type][p_name]=p_color;
+ color_map[p_type][p_name] = p_color;
if (new_value) {
_change_notify();
emit_changed();
-
}
}
-
-
-Color Theme::get_color(const StringName& p_name,const StringName& p_type) const {
+Color Theme::get_color(const StringName &p_name, const StringName &p_type) const {
if (color_map.has(p_type) && color_map[p_type].has(p_name))
return color_map[p_type][p_name];
else
return Color();
-
}
-bool Theme::has_color(const StringName& p_name,const StringName& p_type) const {
+bool Theme::has_color(const StringName &p_name, const StringName &p_type) const {
return (color_map.has(p_type) && color_map[p_type].has(p_name));
}
-void Theme::clear_color(const StringName& p_name,const StringName& p_type) {
+void Theme::clear_color(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!color_map.has(p_type));
ERR_FAIL_COND(!color_map[p_type].has(p_name));
@@ -532,7 +505,6 @@ void Theme::clear_color(const StringName& p_name,const StringName& p_type) {
color_map[p_type].erase(p_name);
_change_notify();
emit_changed();
-
}
void Theme::get_color_list(StringName p_type, List<StringName> *p_list) const {
@@ -540,19 +512,18 @@ void Theme::get_color_list(StringName p_type, List<StringName> *p_list) const {
if (!color_map.has(p_type))
return;
- const StringName *key=NULL;
+ const StringName *key = NULL;
- while((key=color_map[p_type].next(key))) {
+ while ((key = color_map[p_type].next(key))) {
p_list->push_back(*key);
}
-
}
-void Theme::set_constant(const StringName& p_name,const StringName& p_type,int p_constant) {
+void Theme::set_constant(const StringName &p_name, const StringName &p_type, int p_constant) {
- bool new_value=!constant_map.has(p_type) || !constant_map[p_type].has(p_name);
- constant_map[p_type][p_name]=p_constant;
+ bool new_value = !constant_map.has(p_type) || !constant_map[p_type].has(p_name);
+ constant_map[p_type][p_name] = p_constant;
if (new_value) {
_change_notify();
@@ -560,22 +531,21 @@ void Theme::set_constant(const StringName& p_name,const StringName& p_type,int p
}
}
-int Theme::get_constant(const StringName& p_name,const StringName& p_type) const {
+int Theme::get_constant(const StringName &p_name, const StringName &p_type) const {
if (constant_map.has(p_type) && constant_map[p_type].has(p_name))
return constant_map[p_type][p_name];
else {
return 0;
}
-
}
-bool Theme::has_constant(const StringName& p_name,const StringName& p_type) const {
+bool Theme::has_constant(const StringName &p_name, const StringName &p_type) const {
return (constant_map.has(p_type) && constant_map[p_type].has(p_name));
}
-void Theme::clear_constant(const StringName& p_name,const StringName& p_type) {
+void Theme::clear_constant(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!constant_map.has(p_type));
ERR_FAIL_COND(!constant_map[p_type].has(p_name));
@@ -583,7 +553,6 @@ void Theme::clear_constant(const StringName& p_name,const StringName& p_type) {
constant_map[p_type].erase(p_name);
_change_notify();
emit_changed();
-
}
void Theme::get_constant_list(StringName p_type, List<StringName> *p_list) const {
@@ -591,192 +560,176 @@ void Theme::get_constant_list(StringName p_type, List<StringName> *p_list) const
if (!constant_map.has(p_type))
return;
- const StringName *key=NULL;
+ const StringName *key = NULL;
- while((key=constant_map[p_type].next(key))) {
+ while ((key = constant_map[p_type].next(key))) {
p_list->push_back(*key);
}
-
}
-
void Theme::copy_default_theme() {
- Ref<Theme> default_theme=get_default();
+ Ref<Theme> default_theme = get_default();
- icon_map=default_theme->icon_map;
- style_map=default_theme->style_map;
- font_map=default_theme->font_map;
- color_map=default_theme->color_map;
- constant_map=default_theme->constant_map;
+ icon_map = default_theme->icon_map;
+ style_map = default_theme->style_map;
+ font_map = default_theme->font_map;
+ color_map = default_theme->color_map;
+ constant_map = default_theme->constant_map;
_change_notify();
emit_changed();
-
}
void Theme::get_type_list(List<StringName> *p_list) const {
Set<StringName> types;
- const StringName *key=NULL;
+ const StringName *key = NULL;
- while((key=icon_map.next(key))) {
+ while ((key = icon_map.next(key))) {
types.insert(*key);
}
- key=NULL;
+ key = NULL;
- while((key=style_map.next(key))) {
+ while ((key = style_map.next(key))) {
types.insert(*key);
}
- key=NULL;
+ key = NULL;
- while((key=font_map.next(key))) {
+ while ((key = font_map.next(key))) {
types.insert(*key);
}
- key=NULL;
+ key = NULL;
- while((key=color_map.next(key))) {
+ while ((key = color_map.next(key))) {
types.insert(*key);
}
- key=NULL;
+ key = NULL;
- while((key=constant_map.next(key))) {
+ while ((key = constant_map.next(key))) {
types.insert(*key);
}
-
- for(Set<StringName>::Element *E=types.front();E;E=E->next()) {
+ for (Set<StringName>::Element *E = types.front(); E; E = E->next()) {
p_list->push_back(E->get());
}
}
-
void Theme::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_icon","name","type","texture:Texture"),&Theme::set_icon);
- ObjectTypeDB::bind_method(_MD("get_icon:Texture","name","type"),&Theme::get_icon);
- ObjectTypeDB::bind_method(_MD("has_icon","name","type"),&Theme::has_icon);
- ObjectTypeDB::bind_method(_MD("clear_icon","name","type"),&Theme::clear_icon);
- ObjectTypeDB::bind_method(_MD("get_icon_list","type"),&Theme::_get_icon_list);
-
- ObjectTypeDB::bind_method(_MD("set_stylebox","name","type","texture:StyleBox"),&Theme::set_stylebox);
- ObjectTypeDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Theme::get_stylebox);
- ObjectTypeDB::bind_method(_MD("has_stylebox","name","type"),&Theme::has_stylebox);
- ObjectTypeDB::bind_method(_MD("clear_stylebox","name","type"),&Theme::clear_stylebox);
- ObjectTypeDB::bind_method(_MD("get_stylebox_list","type"),&Theme::_get_stylebox_list);
- ObjectTypeDB::bind_method(_MD("get_stylebox_types"),&Theme::_get_stylebox_types);
+ ObjectTypeDB::bind_method(_MD("set_icon", "name", "type", "texture:Texture"), &Theme::set_icon);
+ ObjectTypeDB::bind_method(_MD("get_icon:Texture", "name", "type"), &Theme::get_icon);
+ ObjectTypeDB::bind_method(_MD("has_icon", "name", "type"), &Theme::has_icon);
+ ObjectTypeDB::bind_method(_MD("clear_icon", "name", "type"), &Theme::clear_icon);
+ ObjectTypeDB::bind_method(_MD("get_icon_list", "type"), &Theme::_get_icon_list);
- ObjectTypeDB::bind_method(_MD("set_font","name","type","font:Font"),&Theme::set_font);
- ObjectTypeDB::bind_method(_MD("get_font:Font","name","type"),&Theme::get_font);
- ObjectTypeDB::bind_method(_MD("has_font","name","type"),&Theme::has_font);
- ObjectTypeDB::bind_method(_MD("clear_font","name","type"),&Theme::clear_font);
- ObjectTypeDB::bind_method(_MD("get_font_list","type"),&Theme::_get_font_list);
+ ObjectTypeDB::bind_method(_MD("set_stylebox", "name", "type", "texture:StyleBox"), &Theme::set_stylebox);
+ ObjectTypeDB::bind_method(_MD("get_stylebox:StyleBox", "name", "type"), &Theme::get_stylebox);
+ ObjectTypeDB::bind_method(_MD("has_stylebox", "name", "type"), &Theme::has_stylebox);
+ ObjectTypeDB::bind_method(_MD("clear_stylebox", "name", "type"), &Theme::clear_stylebox);
+ ObjectTypeDB::bind_method(_MD("get_stylebox_list", "type"), &Theme::_get_stylebox_list);
+ ObjectTypeDB::bind_method(_MD("get_stylebox_types"), &Theme::_get_stylebox_types);
- ObjectTypeDB::bind_method(_MD("set_color","name","type","color"),&Theme::set_color);
- ObjectTypeDB::bind_method(_MD("get_color","name","type"),&Theme::get_color);
- ObjectTypeDB::bind_method(_MD("has_color","name","type"),&Theme::has_color);
- ObjectTypeDB::bind_method(_MD("clear_color","name","type"),&Theme::clear_color);
- ObjectTypeDB::bind_method(_MD("get_color_list","type"),&Theme::_get_color_list);
+ ObjectTypeDB::bind_method(_MD("set_font", "name", "type", "font:Font"), &Theme::set_font);
+ ObjectTypeDB::bind_method(_MD("get_font:Font", "name", "type"), &Theme::get_font);
+ ObjectTypeDB::bind_method(_MD("has_font", "name", "type"), &Theme::has_font);
+ ObjectTypeDB::bind_method(_MD("clear_font", "name", "type"), &Theme::clear_font);
+ ObjectTypeDB::bind_method(_MD("get_font_list", "type"), &Theme::_get_font_list);
- ObjectTypeDB::bind_method(_MD("set_constant","name","type","constant"),&Theme::set_constant);
- ObjectTypeDB::bind_method(_MD("get_constant","name","type"),&Theme::get_constant);
- ObjectTypeDB::bind_method(_MD("has_constant","name","type"),&Theme::has_constant);
- ObjectTypeDB::bind_method(_MD("clear_constant","name","type"),&Theme::clear_constant);
- ObjectTypeDB::bind_method(_MD("get_constant_list","type"),&Theme::_get_constant_list);
+ ObjectTypeDB::bind_method(_MD("set_color", "name", "type", "color"), &Theme::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color", "name", "type"), &Theme::get_color);
+ ObjectTypeDB::bind_method(_MD("has_color", "name", "type"), &Theme::has_color);
+ ObjectTypeDB::bind_method(_MD("clear_color", "name", "type"), &Theme::clear_color);
+ ObjectTypeDB::bind_method(_MD("get_color_list", "type"), &Theme::_get_color_list);
- ObjectTypeDB::bind_method(_MD("set_default_font","font"),&Theme::set_default_theme_font);
- ObjectTypeDB::bind_method(_MD("get_default_font"),&Theme::get_default_theme_font);
+ ObjectTypeDB::bind_method(_MD("set_constant", "name", "type", "constant"), &Theme::set_constant);
+ ObjectTypeDB::bind_method(_MD("get_constant", "name", "type"), &Theme::get_constant);
+ ObjectTypeDB::bind_method(_MD("has_constant", "name", "type"), &Theme::has_constant);
+ ObjectTypeDB::bind_method(_MD("clear_constant", "name", "type"), &Theme::clear_constant);
+ ObjectTypeDB::bind_method(_MD("get_constant_list", "type"), &Theme::_get_constant_list);
- ObjectTypeDB::bind_method(_MD("get_type_list","type"),&Theme::_get_type_list);
+ ObjectTypeDB::bind_method(_MD("set_default_font", "font"), &Theme::set_default_theme_font);
+ ObjectTypeDB::bind_method(_MD("get_default_font"), &Theme::get_default_theme_font);
- ObjectTypeDB::bind_method(_MD("_emit_theme_changed"),&Theme::_emit_theme_changed);
+ ObjectTypeDB::bind_method(_MD("get_type_list", "type"), &Theme::_get_type_list);
+ ObjectTypeDB::bind_method(_MD("_emit_theme_changed"), &Theme::_emit_theme_changed);
+ ObjectTypeDB::bind_method("copy_default_theme", &Theme::copy_default_theme);
-
- ObjectTypeDB::bind_method("copy_default_theme",&Theme::copy_default_theme);
-
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"default_font",PROPERTY_HINT_RESOURCE_TYPE,"Font"),_SCS("set_default_font"),_SCS("get_default_font"));
-
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), _SCS("set_default_font"), _SCS("get_default_font"));
}
Theme::Theme() {
-
-
}
-
-Theme::~Theme()
-{
+Theme::~Theme() {
}
-
-
-RES ResourceFormatLoaderTheme::load(const String &p_path, const String& p_original_path, Error *r_error) {
+RES ResourceFormatLoaderTheme::load(const String &p_path, const String &p_original_path, Error *r_error) {
if (r_error)
- *r_error=ERR_CANT_OPEN;
+ *r_error = ERR_CANT_OPEN;
Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err);
+ FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- ERR_EXPLAIN("Unable to open theme file: "+p_path);
- ERR_FAIL_COND_V(err,RES());
+ ERR_EXPLAIN("Unable to open theme file: " + p_path);
+ ERR_FAIL_COND_V(err, RES());
String base_path = p_path.get_base_dir();
- Ref<Theme> theme( memnew( Theme ) );
- Map<StringName,Variant> library;
+ Ref<Theme> theme(memnew(Theme));
+ Map<StringName, Variant> library;
if (r_error)
- *r_error=ERR_FILE_CORRUPT;
+ *r_error = ERR_FILE_CORRUPT;
- bool reading_library=false;
- int line=0;
+ bool reading_library = false;
+ int line = 0;
- while(!f->eof_reached()) {
+ while (!f->eof_reached()) {
String l = f->get_line().strip_edges();
line++;
int comment = l.find(";");
- if (comment!=-1)
- l=l.substr(0,comment);
- if (l=="")
+ if (comment != -1)
+ l = l.substr(0, comment);
+ if (l == "")
continue;
if (l.begins_with("[")) {
- if (l=="[library]") {
- reading_library=true;
- } else if (l=="[theme]") {
- reading_library=false;
+ if (l == "[library]") {
+ reading_library = true;
+ } else if (l == "[theme]") {
+ reading_library = false;
} else {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Unknown section type: '"+l+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Unknown section type: '" + l + "'.");
ERR_FAIL_V(RES());
}
continue;
}
int eqpos = l.find("=");
- if (eqpos==-1) {
+ if (eqpos == -1) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected '='.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Expected '='.");
ERR_FAIL_V(RES());
}
-
- String right=l.substr(eqpos+1,l.length()).strip_edges();
- if (right=="") {
+ String right = l.substr(eqpos + 1, l.length()).strip_edges();
+ if (right == "") {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected value after '='.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Expected value after '='.");
ERR_FAIL_V(RES());
}
@@ -790,15 +743,14 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String& p_origin
value = Color::html(right);
} else if (right.begins_with("@")) { //reference
- String reference = right.substr(1,right.length());
+ String reference = right.substr(1, right.length());
if (!library.has(reference)) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid reference to '"+reference+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid reference to '" + reference + "'.");
ERR_FAIL_V(RES());
-
}
- value=library[reference];
+ value = library[reference];
} else if (right.begins_with("default")) { //use default
//do none
@@ -806,135 +758,128 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String& p_origin
//attempt to parse a constructor
int popenpos = right.find("(");
- if (popenpos==-1) {
+ if (popenpos == -1) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor syntax: "+right);
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid constructor syntax: " + right);
ERR_FAIL_V(RES());
}
int pclosepos = right.find_last(")");
- if (pclosepos==-1) {
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor parameter syntax: "+right);
+ if (pclosepos == -1) {
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid constructor parameter syntax: " + right);
ERR_FAIL_V(RES());
-
}
- String type = right.substr(0,popenpos);
- String param = right.substr(popenpos+1,pclosepos-popenpos-1);
-
+ String type = right.substr(0, popenpos);
+ String param = right.substr(popenpos + 1, pclosepos - popenpos - 1);
-
- if (type=="icon") {
+ if (type == "icon") {
String path;
if (param.is_abs_path())
- path=param;
+ path = param;
else
- path=base_path+"/"+param;
+ path = base_path + "/" + param;
Ref<Texture> texture = ResourceLoader::load(path);
if (!texture.is_valid()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Couldn't find icon at path: "+path);
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Couldn't find icon at path: " + path);
ERR_FAIL_V(RES());
}
- value=texture;
+ value = texture;
- } else if (type=="sbox") {
+ } else if (type == "sbox") {
String path;
if (param.is_abs_path())
- path=param;
+ path = param;
else
- path=base_path+"/"+param;
+ path = base_path + "/" + param;
Ref<StyleBox> stylebox = ResourceLoader::load(path);
if (!stylebox.is_valid()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Couldn't find stylebox at path: "+path);
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Couldn't find stylebox at path: " + path);
ERR_FAIL_V(RES());
}
- value=stylebox;
+ value = stylebox;
- } else if (type=="sboxt") {
+ } else if (type == "sboxt") {
Vector<String> params = param.split(",");
- if (params.size()!=5 && params.size()!=9) {
+ if (params.size() != 5 && params.size() != 9) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for sboxt(): '"+right+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid param count for sboxt(): '" + right + "'.");
ERR_FAIL_V(RES());
-
}
- String path=params[0];
+ String path = params[0];
if (!param.is_abs_path())
- path=base_path+"/"+path;
+ path = base_path + "/" + path;
Ref<Texture> tex = ResourceLoader::load(path);
if (tex.is_null()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Could not open texture for sboxt at path: '"+params[0]+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Could not open texture for sboxt at path: '" + params[0] + "'.");
ERR_FAIL_V(RES());
-
}
- Ref<StyleBoxTexture> sbtex( memnew(StyleBoxTexture) );
+ Ref<StyleBoxTexture> sbtex(memnew(StyleBoxTexture));
sbtex->set_texture(tex);
- for(int i=0;i<4;i++) {
- if (!params[i+1].is_valid_integer()) {
+ for (int i = 0; i < 4; i++) {
+ if (!params[i + 1].is_valid_integer()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid expand margin parameter for sboxt #"+itos(i+1) +", expected integer constant, got: '"+params[i+1]+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid expand margin parameter for sboxt #" + itos(i + 1) + ", expected integer constant, got: '" + params[i + 1] + "'.");
ERR_FAIL_V(RES());
}
- int margin = params[i+1].to_int();
- sbtex->set_expand_margin_size(Margin(i),margin);
+ int margin = params[i + 1].to_int();
+ sbtex->set_expand_margin_size(Margin(i), margin);
}
- if (params.size()==9) {
+ if (params.size() == 9) {
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- if (!params[i+5].is_valid_integer()) {
+ if (!params[i + 5].is_valid_integer()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid expand margin parameter for sboxt #"+itos(i+5) +", expected integer constant, got: '"+params[i+5]+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid expand margin parameter for sboxt #" + itos(i + 5) + ", expected integer constant, got: '" + params[i + 5] + "'.");
ERR_FAIL_V(RES());
}
- int margin = params[i+5].to_int();
- sbtex->set_margin_size(Margin(i),margin);
+ int margin = params[i + 5].to_int();
+ sbtex->set_margin_size(Margin(i), margin);
}
}
value = sbtex;
- } else if (type=="sboxf") {
+ } else if (type == "sboxf") {
Vector<String> params = param.split(",");
- if (params.size()<2) {
+ if (params.size() < 2) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for sboxf(): '"+right+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid param count for sboxf(): '" + right + "'.");
ERR_FAIL_V(RES());
-
}
- Ref<StyleBoxFlat> sbflat( memnew(StyleBoxFlat) );
+ Ref<StyleBoxFlat> sbflat(memnew(StyleBoxFlat));
if (!params[0].is_valid_integer()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected integer numeric constant for parameter 0 (border size).");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Expected integer numeric constant for parameter 0 (border size).");
ERR_FAIL_V(RES());
-
}
sbflat->set_border_size(params[0].to_int());
@@ -942,19 +887,17 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String& p_origin
if (!params[0].is_valid_integer()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected integer numeric constant for parameter 0 (border size).");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Expected integer numeric constant for parameter 0 (border size).");
ERR_FAIL_V(RES());
-
}
+ int left = MIN(params.size() - 1, 3);
- int left = MIN( params.size()-1, 3 );
+ int ccodes = 0;
- int ccodes=0;
+ for (int i = 0; i < left; i++) {
- for(int i=0;i<left;i++) {
-
- if (params[i+1].is_valid_html_color())
+ if (params[i + 1].is_valid_html_color())
ccodes++;
else
break;
@@ -964,173 +907,164 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String& p_origin
Color bright;
Color dark;
- if (ccodes<1) {
+ if (ccodes < 1) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected at least 1, 2 or 3 html color codes.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Expected at least 1, 2 or 3 html color codes.");
ERR_FAIL_V(RES());
- } else if (ccodes==1) {
+ } else if (ccodes == 1) {
- normal=Color::html(params[1]);
- bright=Color::html(params[1]);
- dark=Color::html(params[1]);
- } else if (ccodes==2) {
+ normal = Color::html(params[1]);
+ bright = Color::html(params[1]);
+ dark = Color::html(params[1]);
+ } else if (ccodes == 2) {
- normal=Color::html(params[1]);
- bright=Color::html(params[2]);
- dark=Color::html(params[2]);
+ normal = Color::html(params[1]);
+ bright = Color::html(params[2]);
+ dark = Color::html(params[2]);
} else {
- normal=Color::html(params[1]);
- bright=Color::html(params[2]);
- dark=Color::html(params[3]);
+ normal = Color::html(params[1]);
+ bright = Color::html(params[2]);
+ dark = Color::html(params[3]);
}
sbflat->set_dark_color(dark);
sbflat->set_light_color(bright);
sbflat->set_bg_color(normal);
- if (params.size()==ccodes+5) {
+ if (params.size() == ccodes + 5) {
//margins
- for(int i=0;i<4;i++) {
+ for (int i = 0; i < 4; i++) {
- if (!params[i+ccodes+1].is_valid_integer()) {
+ if (!params[i + ccodes + 1].is_valid_integer()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid expand margin parameter for sboxf #"+itos(i+ccodes+1) +", expected integer constant, got: '"+params[i+ccodes+1]+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid expand margin parameter for sboxf #" + itos(i + ccodes + 1) + ", expected integer constant, got: '" + params[i + ccodes + 1] + "'.");
ERR_FAIL_V(RES());
}
-// int margin = params[i+ccodes+1].to_int();
+ // int margin = params[i+ccodes+1].to_int();
//sbflat->set_margin_size(Margin(i),margin);
}
- } else if (params.size()!=ccodes+1) {
+ } else if (params.size() != ccodes + 1) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid amount of margin parameters for sboxt.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid amount of margin parameters for sboxt.");
ERR_FAIL_V(RES());
-
}
-
- value=sbflat;
+ value = sbflat;
} else {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor type: '"+type+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid constructor type: '" + type + "'.");
ERR_FAIL_V(RES());
-
}
-
}
-
//parse left and do something with it
- String left= l.substr(0,eqpos);
+ String left = l.substr(0, eqpos);
if (reading_library) {
- left=left.strip_edges();
+ left = left.strip_edges();
if (!left.is_valid_identifier()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": <LibraryItem> is not a valid identifier.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": <LibraryItem> is not a valid identifier.");
ERR_FAIL_V(RES());
}
if (library.has(left)) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Already in library: '"+left+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Already in library: '" + left + "'.");
ERR_FAIL_V(RES());
}
- library[left]=value;
+ library[left] = value;
} else {
int pointpos = left.find(".");
- if (pointpos==-1) {
+ if (pointpos == -1) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected 'control.item=..' assign syntax.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Expected 'control.item=..' assign syntax.");
ERR_FAIL_V(RES());
}
- String control=left.substr(0,pointpos).strip_edges();
+ String control = left.substr(0, pointpos).strip_edges();
if (!control.is_valid_identifier()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": <Control> is not a valid identifier.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": <Control> is not a valid identifier.");
ERR_FAIL_V(RES());
}
- String item=left.substr(pointpos+1,left.size()).strip_edges();
+ String item = left.substr(pointpos + 1, left.size()).strip_edges();
if (!item.is_valid_identifier()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": <Item> is not a valid identifier.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": <Item> is not a valid identifier.");
ERR_FAIL_V(RES());
}
- if (value.get_type()==Variant::NIL) {
+ if (value.get_type() == Variant::NIL) {
//try to use exiting
- if (Theme::get_default()->has_stylebox(item,control))
- value=Theme::get_default()->get_stylebox(item,control);
- else if (Theme::get_default()->has_font(item,control))
- value=Theme::get_default()->get_font(item,control);
- else if (Theme::get_default()->has_icon(item,control))
- value=Theme::get_default()->get_icon(item,control);
- else if (Theme::get_default()->has_color(item,control))
- value=Theme::get_default()->get_color(item,control);
- else if (Theme::get_default()->has_constant(item,control))
- value=Theme::get_default()->get_constant(item,control);
+ if (Theme::get_default()->has_stylebox(item, control))
+ value = Theme::get_default()->get_stylebox(item, control);
+ else if (Theme::get_default()->has_font(item, control))
+ value = Theme::get_default()->get_font(item, control);
+ else if (Theme::get_default()->has_icon(item, control))
+ value = Theme::get_default()->get_icon(item, control);
+ else if (Theme::get_default()->has_color(item, control))
+ value = Theme::get_default()->get_color(item, control);
+ else if (Theme::get_default()->has_constant(item, control))
+ value = Theme::get_default()->get_constant(item, control);
else {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Default not present for: '"+control+"."+item+"'.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Default not present for: '" + control + "." + item + "'.");
ERR_FAIL_V(RES());
}
-
}
- if (value.get_type()==Variant::OBJECT) {
+ if (value.get_type() == Variant::OBJECT) {
Ref<Resource> res = value;
if (!res.is_valid()) {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid resource (NULL).");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid resource (NULL).");
ERR_FAIL_V(RES());
}
if (res->cast_to<StyleBox>()) {
- theme->set_stylebox(item,control,res);
+ theme->set_stylebox(item, control, res);
} else if (res->cast_to<Font>()) {
- theme->set_font(item,control,res);
+ theme->set_font(item, control, res);
} else if (res->cast_to<Font>()) {
- theme->set_font(item,control,res);
+ theme->set_font(item, control, res);
} else if (res->cast_to<Texture>()) {
- theme->set_icon(item,control,res);
+ theme->set_icon(item, control, res);
} else {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid resource type.");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Invalid resource type.");
ERR_FAIL_V(RES());
}
- } else if (value.get_type()==Variant::COLOR) {
+ } else if (value.get_type() == Variant::COLOR) {
- theme->set_color(item,control,value);
+ theme->set_color(item, control, value);
- } else if (value.get_type()==Variant::INT) {
+ } else if (value.get_type() == Variant::INT) {
- theme->set_constant(item,control,value);
+ theme->set_constant(item, control, value);
} else {
memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Couldn't even determine what this setting is! what did you do!?");
+ ERR_EXPLAIN(p_path + ":" + itos(line) + ": Couldn't even determine what this setting is! what did you do!?");
ERR_FAIL_V(RES());
}
-
}
-
-
}
f->close();
memdelete(f);
if (r_error)
- *r_error=OK;
+ *r_error = OK;
return theme;
}
@@ -1140,14 +1074,14 @@ void ResourceFormatLoaderTheme::get_recognized_extensions(List<String> *p_extens
p_extensions->push_back("theme");
}
-bool ResourceFormatLoaderTheme::handles_type(const String& p_type) const {
+bool ResourceFormatLoaderTheme::handles_type(const String &p_type) const {
- return p_type=="Theme";
+ return p_type == "Theme";
}
String ResourceFormatLoaderTheme::get_resource_type(const String &p_path) const {
- if (p_path.extension().to_lower()=="theme")
+ if (p_path.extension().to_lower() == "theme")
return "Theme";
return "";
}
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index 1bce5e121..79e7e69ed 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -29,42 +29,41 @@
#ifndef THEME_H
#define THEME_H
+#include "io/resource_loader.h"
#include "resource.h"
#include "scene/resources/font.h"
+#include "scene/resources/shader.h"
#include "scene/resources/style_box.h"
#include "scene/resources/texture.h"
-#include "scene/resources/shader.h"
-#include "io/resource_loader.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class Theme : public Resource {
- OBJ_TYPE( Theme, Resource );
+ OBJ_TYPE(Theme, Resource);
RES_BASE_EXTENSION("thm");
static Ref<Theme> default_theme;
-
//keep a reference count to font, so each time the font changes, we emit theme changed too
- Map< Ref<Font>, int> font_refcount;
+ Map<Ref<Font>, int> font_refcount;
void _ref_font(Ref<Font> p_sc);
- void _unref_font( Ref<Font> p_sc);
+ void _unref_font(Ref<Font> p_sc);
void _emit_theme_changed();
+ HashMap<StringName, HashMap<StringName, Ref<Texture>, StringNameHasher>, StringNameHasher> icon_map;
+ HashMap<StringName, HashMap<StringName, Ref<StyleBox>, StringNameHasher>, StringNameHasher> style_map;
+ HashMap<StringName, HashMap<StringName, Ref<Font>, StringNameHasher>, StringNameHasher> font_map;
+ HashMap<StringName, HashMap<StringName, Ref<Shader>, StringNameHasher>, StringNameHasher> shader_map;
+ HashMap<StringName, HashMap<StringName, Color, StringNameHasher>, StringNameHasher> color_map;
+ HashMap<StringName, HashMap<StringName, int, StringNameHasher>, StringNameHasher> constant_map;
- HashMap<StringName,HashMap<StringName,Ref<Texture>,StringNameHasher >, StringNameHasher > icon_map;
- HashMap<StringName,HashMap<StringName,Ref<StyleBox>,StringNameHasher >,StringNameHasher > style_map;
- HashMap<StringName,HashMap<StringName,Ref<Font>,StringNameHasher >,StringNameHasher > font_map;
- HashMap<StringName,HashMap<StringName,Ref<Shader>,StringNameHasher >, StringNameHasher > shader_map;
- HashMap<StringName,HashMap<StringName,Color,StringNameHasher >,StringNameHasher > color_map;
- HashMap<StringName,HashMap<StringName,int,StringNameHasher>,StringNameHasher > constant_map;
protected:
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
static Ref<Texture> default_icon;
static Ref<StyleBox> default_style;
@@ -72,84 +71,134 @@ protected:
Ref<Font> default_theme_font;
- DVector<String> _get_icon_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_icon_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_stylebox_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_stylebox_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_stylebox_types(void) const { DVector<String> ilret; List<StringName> il; get_stylebox_types(&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_font_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_font_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_color_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_color_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_constant_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_constant_list(p_type,&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
- DVector<String> _get_type_list(const String& p_type) const { DVector<String> ilret; List<StringName> il; get_type_list(&il); for(List<StringName>::Element *E=il.front();E;E=E->next()) { ilret.push_back(E->get()); } return ilret; }
+ DVector<String> _get_icon_list(const String &p_type) const {
+ DVector<String> ilret;
+ List<StringName> il;
+ get_icon_list(p_type, &il);
+ for (List<StringName>::Element *E = il.front(); E; E = E->next()) {
+ ilret.push_back(E->get());
+ }
+ return ilret;
+ }
+ DVector<String> _get_stylebox_list(const String &p_type) const {
+ DVector<String> ilret;
+ List<StringName> il;
+ get_stylebox_list(p_type, &il);
+ for (List<StringName>::Element *E = il.front(); E; E = E->next()) {
+ ilret.push_back(E->get());
+ }
+ return ilret;
+ }
+ DVector<String> _get_stylebox_types(void) const {
+ DVector<String> ilret;
+ List<StringName> il;
+ get_stylebox_types(&il);
+ for (List<StringName>::Element *E = il.front(); E; E = E->next()) {
+ ilret.push_back(E->get());
+ }
+ return ilret;
+ }
+ DVector<String> _get_font_list(const String &p_type) const {
+ DVector<String> ilret;
+ List<StringName> il;
+ get_font_list(p_type, &il);
+ for (List<StringName>::Element *E = il.front(); E; E = E->next()) {
+ ilret.push_back(E->get());
+ }
+ return ilret;
+ }
+ DVector<String> _get_color_list(const String &p_type) const {
+ DVector<String> ilret;
+ List<StringName> il;
+ get_color_list(p_type, &il);
+ for (List<StringName>::Element *E = il.front(); E; E = E->next()) {
+ ilret.push_back(E->get());
+ }
+ return ilret;
+ }
+ DVector<String> _get_constant_list(const String &p_type) const {
+ DVector<String> ilret;
+ List<StringName> il;
+ get_constant_list(p_type, &il);
+ for (List<StringName>::Element *E = il.front(); E; E = E->next()) {
+ ilret.push_back(E->get());
+ }
+ return ilret;
+ }
+ DVector<String> _get_type_list(const String &p_type) const {
+ DVector<String> ilret;
+ List<StringName> il;
+ get_type_list(&il);
+ for (List<StringName>::Element *E = il.front(); E; E = E->next()) {
+ ilret.push_back(E->get());
+ }
+ return ilret;
+ }
static void _bind_methods();
-public:
+public:
static Ref<Theme> get_default();
- static void set_default(const Ref<Theme>& p_default);
+ static void set_default(const Ref<Theme> &p_default);
- static void set_default_icon( const Ref<Texture>& p_icon );
- static void set_default_style( const Ref<StyleBox>& p_default_style);
- static void set_default_font( const Ref<Font>& p_default_font );
+ static void set_default_icon(const Ref<Texture> &p_icon);
+ static void set_default_style(const Ref<StyleBox> &p_default_style);
+ static void set_default_font(const Ref<Font> &p_default_font);
- void set_default_theme_font( const Ref<Font>& p_default_font );
+ void set_default_theme_font(const Ref<Font> &p_default_font);
Ref<Font> get_default_theme_font() const;
- void set_icon(const StringName& p_name,const StringName& p_type,const Ref<Texture>& p_icon);
- Ref<Texture> get_icon(const StringName& p_name,const StringName& p_type) const;
- bool has_icon(const StringName& p_name,const StringName& p_type) const;
- void clear_icon(const StringName& p_name,const StringName& p_type);
+ void set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture> &p_icon);
+ Ref<Texture> get_icon(const StringName &p_name, const StringName &p_type) const;
+ bool has_icon(const StringName &p_name, const StringName &p_type) const;
+ void clear_icon(const StringName &p_name, const StringName &p_type);
void get_icon_list(StringName p_type, List<StringName> *p_list) const;
- void set_shader(const StringName& p_name,const StringName& p_type,const Ref<Shader>& p_shader);
- Ref<Shader> get_shader(const StringName& p_name,const StringName& p_type) const;
- bool has_shader(const StringName& p_name,const StringName& p_type) const;
- void clear_shader(const StringName& p_name,const StringName& p_type);
- void get_shader_list(const StringName& p_name, List<StringName> *p_list) const;
+ void set_shader(const StringName &p_name, const StringName &p_type, const Ref<Shader> &p_shader);
+ Ref<Shader> get_shader(const StringName &p_name, const StringName &p_type) const;
+ bool has_shader(const StringName &p_name, const StringName &p_type) const;
+ void clear_shader(const StringName &p_name, const StringName &p_type);
+ void get_shader_list(const StringName &p_name, List<StringName> *p_list) const;
- void set_stylebox(const StringName& p_name,const StringName& p_type,const Ref<StyleBox>& p_style);
- Ref<StyleBox> get_stylebox(const StringName& p_name,const StringName& p_type) const;
- bool has_stylebox(const StringName& p_name,const StringName& p_type) const;
- void clear_stylebox(const StringName& p_name,const StringName& p_type);
+ void set_stylebox(const StringName &p_name, const StringName &p_type, const Ref<StyleBox> &p_style);
+ Ref<StyleBox> get_stylebox(const StringName &p_name, const StringName &p_type) const;
+ bool has_stylebox(const StringName &p_name, const StringName &p_type) const;
+ void clear_stylebox(const StringName &p_name, const StringName &p_type);
void get_stylebox_list(StringName p_type, List<StringName> *p_list) const;
void get_stylebox_types(List<StringName> *p_list) const;
- void set_font(const StringName& p_name,const StringName& p_type,const Ref<Font>& p_font);
- Ref<Font> get_font(const StringName& p_name,const StringName& p_type) const;
- bool has_font(const StringName& p_name,const StringName& p_type) const;
- void clear_font(const StringName& p_name,const StringName& p_type);
+ void set_font(const StringName &p_name, const StringName &p_type, const Ref<Font> &p_font);
+ Ref<Font> get_font(const StringName &p_name, const StringName &p_type) const;
+ bool has_font(const StringName &p_name, const StringName &p_type) const;
+ void clear_font(const StringName &p_name, const StringName &p_type);
void get_font_list(StringName p_type, List<StringName> *p_list) const;
- void set_color(const StringName& p_name,const StringName& p_type,const Color& p_color);
- Color get_color(const StringName& p_name,const StringName& p_type) const;
- bool has_color(const StringName& p_name,const StringName& p_type) const;
- void clear_color(const StringName& p_name,const StringName& p_type);
+ void set_color(const StringName &p_name, const StringName &p_type, const Color &p_color);
+ Color get_color(const StringName &p_name, const StringName &p_type) const;
+ bool has_color(const StringName &p_name, const StringName &p_type) const;
+ void clear_color(const StringName &p_name, const StringName &p_type);
void get_color_list(StringName p_type, List<StringName> *p_list) const;
- void set_constant(const StringName& p_name,const StringName& p_type,int p_constant);
- int get_constant(const StringName& p_name,const StringName& p_type) const;
- bool has_constant(const StringName& p_name,const StringName& p_type) const;
- void clear_constant(const StringName& p_name,const StringName& p_type);
+ void set_constant(const StringName &p_name, const StringName &p_type, int p_constant);
+ int get_constant(const StringName &p_name, const StringName &p_type) const;
+ bool has_constant(const StringName &p_name, const StringName &p_type) const;
+ void clear_constant(const StringName &p_name, const StringName &p_type);
void get_constant_list(StringName p_type, List<StringName> *p_list) const;
void get_type_list(List<StringName> *p_list) const;
-
void copy_default_theme();
Theme();
~Theme();
-
};
-
class ResourceFormatLoaderTheme : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
+ virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
-
};
-
-
#endif
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 67aadd284..89357893c 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -28,341 +28,318 @@
/*************************************************************************/
#include "tile_set.h"
-bool TileSet::_set(const StringName& p_name, const Variant& p_value) {
+bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
String n = p_name;
int slash = n.find("/");
- if (slash==-1)
+ if (slash == -1)
return false;
- int id = String::to_int(n.c_str(),slash);
+ int id = String::to_int(n.c_str(), slash);
if (!tile_map.has(id))
create_tile(id);
- String what = n.substr(slash+1,n.length());
+ String what = n.substr(slash + 1, n.length());
- if (what=="name")
- tile_set_name(id,p_value);
- else if (what=="texture")
- tile_set_texture(id,p_value);
- else if (what=="tex_offset")
- tile_set_texture_offset(id,p_value);
- else if (what=="material")
- tile_set_material(id,p_value);
- else if (what=="modulate")
- tile_set_modulate(id,p_value);
- else if (what=="shape_offset")
- tile_set_shape_offset(id,p_value);
- else if (what=="region")
- tile_set_region(id,p_value);
- else if (what=="shape")
- tile_set_shape(id,p_value);
- else if (what=="shapes")
- _tile_set_shapes(id,p_value);
- else if (what=="occluder")
- tile_set_light_occluder(id,p_value);
- else if (what=="occluder_offset")
- tile_set_occluder_offset(id,p_value);
- else if (what=="navigation")
- tile_set_navigation_polygon(id,p_value);
- else if (what=="navigation_offset")
- tile_set_navigation_polygon_offset(id,p_value);
+ if (what == "name")
+ tile_set_name(id, p_value);
+ else if (what == "texture")
+ tile_set_texture(id, p_value);
+ else if (what == "tex_offset")
+ tile_set_texture_offset(id, p_value);
+ else if (what == "material")
+ tile_set_material(id, p_value);
+ else if (what == "modulate")
+ tile_set_modulate(id, p_value);
+ else if (what == "shape_offset")
+ tile_set_shape_offset(id, p_value);
+ else if (what == "region")
+ tile_set_region(id, p_value);
+ else if (what == "shape")
+ tile_set_shape(id, p_value);
+ else if (what == "shapes")
+ _tile_set_shapes(id, p_value);
+ else if (what == "occluder")
+ tile_set_light_occluder(id, p_value);
+ else if (what == "occluder_offset")
+ tile_set_occluder_offset(id, p_value);
+ else if (what == "navigation")
+ tile_set_navigation_polygon(id, p_value);
+ else if (what == "navigation_offset")
+ tile_set_navigation_polygon_offset(id, p_value);
else
return false;
return true;
-
}
-bool TileSet::_get(const StringName& p_name,Variant &r_ret) const{
+bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
String n = p_name;
int slash = n.find("/");
- if (slash==-1)
+ if (slash == -1)
return false;
- int id = String::to_int(n.c_str(),slash);
+ int id = String::to_int(n.c_str(), slash);
- ERR_FAIL_COND_V(!tile_map.has(id),false);
+ ERR_FAIL_COND_V(!tile_map.has(id), false);
- String what = n.substr(slash+1,n.length());
+ String what = n.substr(slash + 1, n.length());
- if (what=="name")
- r_ret=tile_get_name(id);
- else if (what=="texture")
- r_ret=tile_get_texture(id);
- else if (what=="tex_offset")
- r_ret=tile_get_texture_offset(id);
- else if (what=="material")
- r_ret=tile_get_material(id);
- else if (what=="modulate")
- r_ret=tile_get_modulate(id);
- else if (what=="shape_offset")
- r_ret=tile_get_shape_offset(id);
- else if (what=="region")
- r_ret=tile_get_region(id);
- else if (what=="shape")
- r_ret=tile_get_shape(id);
- else if (what=="shapes")
- r_ret=_tile_get_shapes(id);
- else if (what=="occluder")
- r_ret=tile_get_light_occluder(id);
- else if (what=="occluder_offset")
- r_ret=tile_get_occluder_offset(id);
- else if (what=="navigation")
- r_ret=tile_get_navigation_polygon(id);
- else if (what=="navigation_offset")
- r_ret=tile_get_navigation_polygon_offset(id);
+ if (what == "name")
+ r_ret = tile_get_name(id);
+ else if (what == "texture")
+ r_ret = tile_get_texture(id);
+ else if (what == "tex_offset")
+ r_ret = tile_get_texture_offset(id);
+ else if (what == "material")
+ r_ret = tile_get_material(id);
+ else if (what == "modulate")
+ r_ret = tile_get_modulate(id);
+ else if (what == "shape_offset")
+ r_ret = tile_get_shape_offset(id);
+ else if (what == "region")
+ r_ret = tile_get_region(id);
+ else if (what == "shape")
+ r_ret = tile_get_shape(id);
+ else if (what == "shapes")
+ r_ret = _tile_get_shapes(id);
+ else if (what == "occluder")
+ r_ret = tile_get_light_occluder(id);
+ else if (what == "occluder_offset")
+ r_ret = tile_get_occluder_offset(id);
+ else if (what == "navigation")
+ r_ret = tile_get_navigation_polygon(id);
+ else if (what == "navigation_offset")
+ r_ret = tile_get_navigation_polygon_offset(id);
else
return false;
return true;
-
}
-void TileSet::_get_property_list( List<PropertyInfo> *p_list) const{
+void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
- for(Map<int,Data>::Element *E=tile_map.front();E;E=E->next()) {
+ for (Map<int, Data>::Element *E = tile_map.front(); E; E = E->next()) {
int id = E->key();
- String pre = itos(id)+"/";
- p_list->push_back(PropertyInfo(Variant::STRING,pre+"name"));
- p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"tex_offset"));
- p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"material",PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemMaterial"));
- p_list->push_back(PropertyInfo(Variant::COLOR,pre+"modulate"));
- p_list->push_back(PropertyInfo(Variant::RECT2,pre+"region"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"occluder_offset"));
- p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"occluder",PROPERTY_HINT_RESOURCE_TYPE,"OccluderPolygon2D"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"navigation_offset"));
- p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"navigation",PROPERTY_HINT_RESOURCE_TYPE,"NavigationPolygon"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2,pre+"shape_offset"));
- p_list->push_back(PropertyInfo(Variant::OBJECT,pre+"shape",PROPERTY_HINT_RESOURCE_TYPE,"Shape2D",PROPERTY_USAGE_EDITOR));
- p_list->push_back(PropertyInfo(Variant::ARRAY,pre+"shapes",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR));
+ String pre = itos(id) + "/";
+ p_list->push_back(PropertyInfo(Variant::STRING, pre + "name"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "tex_offset"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "material", PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"));
+ p_list->push_back(PropertyInfo(Variant::COLOR, pre + "modulate"));
+ p_list->push_back(PropertyInfo(Variant::RECT2, pre + "region"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "occluder_offset"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "occluder", PROPERTY_HINT_RESOURCE_TYPE, "OccluderPolygon2D"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "navigation_offset"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "navigation", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "shape_offset"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "shapes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
}
}
void TileSet::create_tile(int p_id) {
- ERR_FAIL_COND( tile_map.has(p_id) );
- tile_map[p_id]=Data();
+ ERR_FAIL_COND(tile_map.has(p_id));
+ tile_map[p_id] = Data();
_change_notify("");
emit_changed();
-
}
-void TileSet::tile_set_texture(int p_id,const Ref<Texture> &p_texture) {
+void TileSet::tile_set_texture(int p_id, const Ref<Texture> &p_texture) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].texture=p_texture;
+ tile_map[p_id].texture = p_texture;
emit_changed();
-
}
Ref<Texture> TileSet::tile_get_texture(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<Texture>());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture>());
return tile_map[p_id].texture;
-
}
-
-void TileSet::tile_set_material(int p_id,const Ref<CanvasItemMaterial> &p_material) {
+void TileSet::tile_set_material(int p_id, const Ref<CanvasItemMaterial> &p_material) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].material=p_material;
+ tile_map[p_id].material = p_material;
emit_changed();
-
}
-Ref<CanvasItemMaterial> TileSet::tile_get_material(int p_id) const{
+Ref<CanvasItemMaterial> TileSet::tile_get_material(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<CanvasItemMaterial>());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<CanvasItemMaterial>());
return tile_map[p_id].material;
}
-
-void TileSet::tile_set_modulate(int p_id,const Color &p_modulate) {
+void TileSet::tile_set_modulate(int p_id, const Color &p_modulate) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].modulate=p_modulate;
+ tile_map[p_id].modulate = p_modulate;
emit_changed();
-
}
-Color TileSet::tile_get_modulate(int p_id) const{
+Color TileSet::tile_get_modulate(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Color(1,1,1));
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Color(1, 1, 1));
return tile_map[p_id].modulate;
}
-void TileSet::tile_set_texture_offset(int p_id,const Vector2 &p_offset) {
+void TileSet::tile_set_texture_offset(int p_id, const Vector2 &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].offset=p_offset;
+ tile_map[p_id].offset = p_offset;
emit_changed();
}
Vector2 TileSet::tile_get_texture_offset(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
return tile_map[p_id].offset;
-
}
-void TileSet::tile_set_shape_offset(int p_id,const Vector2 &p_offset) {
+void TileSet::tile_set_shape_offset(int p_id, const Vector2 &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].shape_offset=p_offset;
+ tile_map[p_id].shape_offset = p_offset;
emit_changed();
}
Vector2 TileSet::tile_get_shape_offset(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
return tile_map[p_id].shape_offset;
-
}
-void TileSet::tile_set_region(int p_id,const Rect2 &p_region) {
+void TileSet::tile_set_region(int p_id, const Rect2 &p_region) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].region=p_region;
+ tile_map[p_id].region = p_region;
emit_changed();
}
Rect2 TileSet::tile_get_region(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Rect2());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Rect2());
return tile_map[p_id].region;
-
}
-
-void TileSet::tile_set_name(int p_id,const String &p_name) {
+void TileSet::tile_set_name(int p_id, const String &p_name) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].name=p_name;
+ tile_map[p_id].name = p_name;
emit_changed();
}
String TileSet::tile_get_name(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),String());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), String());
return tile_map[p_id].name;
-
}
-void TileSet::tile_set_shape(int p_id,const Ref<Shape2D> &p_shape) {
+void TileSet::tile_set_shape(int p_id, const Ref<Shape2D> &p_shape) {
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].shapes.resize(1);
- tile_map[p_id].shapes[0]=p_shape;
+ tile_map[p_id].shapes[0] = p_shape;
emit_changed();
-
}
Ref<Shape2D> TileSet::tile_get_shape(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<Shape2D>());
- if (tile_map[p_id].shapes.size()>0)
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Shape2D>());
+ if (tile_map[p_id].shapes.size() > 0)
return tile_map[p_id].shapes[0];
return Ref<Shape2D>();
-
}
-void TileSet::tile_set_light_occluder(int p_id,const Ref<OccluderPolygon2D> &p_light_occluder) {
+void TileSet::tile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D> &p_light_occluder) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].occluder=p_light_occluder;
-
+ tile_map[p_id].occluder = p_light_occluder;
}
-Ref<OccluderPolygon2D> TileSet::tile_get_light_occluder(int p_id) const{
+Ref<OccluderPolygon2D> TileSet::tile_get_light_occluder(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<OccluderPolygon2D>());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<OccluderPolygon2D>());
return tile_map[p_id].occluder;
-
}
-void TileSet::tile_set_navigation_polygon_offset(int p_id,const Vector2& p_offset) {
+void TileSet::tile_set_navigation_polygon_offset(int p_id, const Vector2 &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].navigation_polygon_offset=p_offset;
-
+ tile_map[p_id].navigation_polygon_offset = p_offset;
}
-Vector2 TileSet::tile_get_navigation_polygon_offset(int p_id) const{
- ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2());
+Vector2 TileSet::tile_get_navigation_polygon_offset(int p_id) const {
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
return tile_map[p_id].navigation_polygon_offset;
}
-void TileSet::tile_set_navigation_polygon(int p_id,const Ref<NavigationPolygon> &p_navigation_polygon) {
+void TileSet::tile_set_navigation_polygon(int p_id, const Ref<NavigationPolygon> &p_navigation_polygon) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].navigation_polygon=p_navigation_polygon;
-
+ tile_map[p_id].navigation_polygon = p_navigation_polygon;
}
Ref<NavigationPolygon> TileSet::tile_get_navigation_polygon(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Ref<NavigationPolygon>());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<NavigationPolygon>());
return tile_map[p_id].navigation_polygon;
-
}
-void TileSet::tile_set_occluder_offset(int p_id,const Vector2& p_offset) {
+void TileSet::tile_set_occluder_offset(int p_id, const Vector2 &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].occluder_offset=p_offset;
-
+ tile_map[p_id].occluder_offset = p_offset;
}
-Vector2 TileSet::tile_get_occluder_offset(int p_id) const{
- ERR_FAIL_COND_V(!tile_map.has(p_id),Vector2());
+Vector2 TileSet::tile_get_occluder_offset(int p_id) const {
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
return tile_map[p_id].occluder_offset;
}
-void TileSet::tile_set_shapes(int p_id,const Vector<Ref<Shape2D> > &p_shapes) {
+void TileSet::tile_set_shapes(int p_id, const Vector<Ref<Shape2D> > &p_shapes) {
ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].shapes=p_shapes;
+ tile_map[p_id].shapes = p_shapes;
emit_changed();
-
}
Vector<Ref<Shape2D> > TileSet::tile_get_shapes(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Vector<Ref<Shape2D> >());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Vector<Ref<Shape2D> >());
return tile_map[p_id].shapes;
}
-void TileSet::_tile_set_shapes(int p_id,const Array& p_shapes) {
+void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
ERR_FAIL_COND(!tile_map.has(p_id));
Vector<Ref<Shape2D> > shapes;
- for(int i=0;i<p_shapes.size();i++) {
+ for (int i = 0; i < p_shapes.size(); i++) {
Ref<Shape2D> s = p_shapes[i];
if (s.is_valid())
shapes.push_back(s);
}
- tile_set_shapes(p_id,shapes);
+ tile_set_shapes(p_id, shapes);
}
-Array TileSet::_tile_get_shapes(int p_id) const{
+Array TileSet::_tile_get_shapes(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id),Array());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Array());
Array arr;
- Vector<Ref<Shape2D> >shp = tile_map[p_id].shapes;
- for(int i=0;i<shp.size();i++)
+ Vector<Ref<Shape2D> > shp = tile_map[p_id].shapes;
+ for (int i = 0; i < shp.size(); i++)
arr.push_back(shp[i]);
return arr;
}
-Array TileSet::_get_tiles_ids() const{
+Array TileSet::_get_tiles_ids() const {
Array arr;
@@ -375,11 +352,10 @@ Array TileSet::_get_tiles_ids() const{
void TileSet::get_tile_list(List<int> *p_tiles) const {
- for(Map<int,Data>::Element *E=tile_map.front();E;E=E->next()) {
+ for (Map<int, Data>::Element *E = tile_map.front(); E; E = E->next()) {
p_tiles->push_back(E->key());
}
-
}
bool TileSet::has_tile(int p_id) const {
@@ -397,20 +373,17 @@ void TileSet::remove_tile(int p_id) {
int TileSet::get_last_unused_tile_id() const {
-
if (tile_map.size())
- return tile_map.back()->key()+1;
+ return tile_map.back()->key() + 1;
else
return 0;
-
}
-int TileSet::find_tile_by_name(const String& p_name) const {
+int TileSet::find_tile_by_name(const String &p_name) const {
+ for (Map<int, Data>::Element *E = tile_map.front(); E; E = E->next()) {
- for(Map<int,Data>::Element *E=tile_map.front();E;E=E->next()) {
-
- if (p_name==E->get().name)
+ if (p_name == E->get().name)
return E->key();
}
return -1;
@@ -425,42 +398,38 @@ void TileSet::clear() {
void TileSet::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("create_tile", "id"), &TileSet::create_tile);
+ ObjectTypeDB::bind_method(_MD("tile_set_name", "id", "name"), &TileSet::tile_set_name);
+ ObjectTypeDB::bind_method(_MD("tile_get_name", "id"), &TileSet::tile_get_name);
+ ObjectTypeDB::bind_method(_MD("tile_set_texture", "id", "texture:Texture"), &TileSet::tile_set_texture);
+ ObjectTypeDB::bind_method(_MD("tile_get_texture:Texture", "id"), &TileSet::tile_get_texture);
+ ObjectTypeDB::bind_method(_MD("tile_set_material", "id", "material:CanvasItemMaterial"), &TileSet::tile_set_material);
+ ObjectTypeDB::bind_method(_MD("tile_get_material:CanvasItemMaterial", "id"), &TileSet::tile_get_material);
+ ObjectTypeDB::bind_method(_MD("tile_set_texture_offset", "id", "texture_offset"), &TileSet::tile_set_texture_offset);
+ ObjectTypeDB::bind_method(_MD("tile_get_texture_offset", "id"), &TileSet::tile_get_texture_offset);
+ ObjectTypeDB::bind_method(_MD("tile_set_shape_offset", "id", "shape_offset"), &TileSet::tile_set_shape_offset);
+ ObjectTypeDB::bind_method(_MD("tile_get_shape_offset", "id"), &TileSet::tile_get_shape_offset);
+ ObjectTypeDB::bind_method(_MD("tile_set_region", "id", "region"), &TileSet::tile_set_region);
+ ObjectTypeDB::bind_method(_MD("tile_get_region", "id"), &TileSet::tile_get_region);
+ ObjectTypeDB::bind_method(_MD("tile_set_shape", "id", "shape:Shape2D"), &TileSet::tile_set_shape);
+ ObjectTypeDB::bind_method(_MD("tile_get_shape:Shape2D", "id"), &TileSet::tile_get_shape);
+ ObjectTypeDB::bind_method(_MD("tile_set_shapes", "id", "shapes"), &TileSet::_tile_set_shapes);
+ ObjectTypeDB::bind_method(_MD("tile_get_shapes", "id"), &TileSet::_tile_get_shapes);
+ ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon", "id", "navigation_polygon:NavigationPolygon"), &TileSet::tile_set_navigation_polygon);
+ ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon:NavigationPolygon", "id"), &TileSet::tile_get_navigation_polygon);
+ ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon_offset", "id", "navigation_polygon_offset"), &TileSet::tile_set_navigation_polygon_offset);
+ ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon_offset", "id"), &TileSet::tile_get_navigation_polygon_offset);
+ ObjectTypeDB::bind_method(_MD("tile_set_light_occluder", "id", "light_occluder:OccluderPolygon2D"), &TileSet::tile_set_light_occluder);
+ ObjectTypeDB::bind_method(_MD("tile_get_light_occluder:OccluderPolygon2D", "id"), &TileSet::tile_get_light_occluder);
+ ObjectTypeDB::bind_method(_MD("tile_set_occluder_offset", "id", "occluder_offset"), &TileSet::tile_set_occluder_offset);
+ ObjectTypeDB::bind_method(_MD("tile_get_occluder_offset", "id"), &TileSet::tile_get_occluder_offset);
- ObjectTypeDB::bind_method(_MD("create_tile","id"),&TileSet::create_tile);
- ObjectTypeDB::bind_method(_MD("tile_set_name","id","name"),&TileSet::tile_set_name);
- ObjectTypeDB::bind_method(_MD("tile_get_name","id"),&TileSet::tile_get_name);
- ObjectTypeDB::bind_method(_MD("tile_set_texture","id","texture:Texture"),&TileSet::tile_set_texture);
- ObjectTypeDB::bind_method(_MD("tile_get_texture:Texture","id"),&TileSet::tile_get_texture);
- ObjectTypeDB::bind_method(_MD("tile_set_material","id","material:CanvasItemMaterial"),&TileSet::tile_set_material);
- ObjectTypeDB::bind_method(_MD("tile_get_material:CanvasItemMaterial","id"),&TileSet::tile_get_material);
- ObjectTypeDB::bind_method(_MD("tile_set_texture_offset","id","texture_offset"),&TileSet::tile_set_texture_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_texture_offset","id"),&TileSet::tile_get_texture_offset);
- ObjectTypeDB::bind_method(_MD("tile_set_shape_offset","id","shape_offset"),&TileSet::tile_set_shape_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_shape_offset","id"),&TileSet::tile_get_shape_offset);
- ObjectTypeDB::bind_method(_MD("tile_set_region","id","region"),&TileSet::tile_set_region);
- ObjectTypeDB::bind_method(_MD("tile_get_region","id"),&TileSet::tile_get_region);
- ObjectTypeDB::bind_method(_MD("tile_set_shape","id","shape:Shape2D"),&TileSet::tile_set_shape);
- ObjectTypeDB::bind_method(_MD("tile_get_shape:Shape2D","id"),&TileSet::tile_get_shape);
- ObjectTypeDB::bind_method(_MD("tile_set_shapes","id","shapes"),&TileSet::_tile_set_shapes);
- ObjectTypeDB::bind_method(_MD("tile_get_shapes","id"),&TileSet::_tile_get_shapes);
- ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon","id","navigation_polygon:NavigationPolygon"),&TileSet::tile_set_navigation_polygon);
- ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon:NavigationPolygon","id"),&TileSet::tile_get_navigation_polygon);
- ObjectTypeDB::bind_method(_MD("tile_set_navigation_polygon_offset","id","navigation_polygon_offset"),&TileSet::tile_set_navigation_polygon_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_navigation_polygon_offset","id"),&TileSet::tile_get_navigation_polygon_offset);
- ObjectTypeDB::bind_method(_MD("tile_set_light_occluder","id","light_occluder:OccluderPolygon2D"),&TileSet::tile_set_light_occluder);
- ObjectTypeDB::bind_method(_MD("tile_get_light_occluder:OccluderPolygon2D","id"),&TileSet::tile_get_light_occluder);
- ObjectTypeDB::bind_method(_MD("tile_set_occluder_offset","id","occluder_offset"),&TileSet::tile_set_occluder_offset);
- ObjectTypeDB::bind_method(_MD("tile_get_occluder_offset","id"),&TileSet::tile_get_occluder_offset);
-
- ObjectTypeDB::bind_method(_MD("remove_tile","id"),&TileSet::remove_tile);
- ObjectTypeDB::bind_method(_MD("clear"),&TileSet::clear);
- ObjectTypeDB::bind_method(_MD("get_last_unused_tile_id"),&TileSet::get_last_unused_tile_id);
- ObjectTypeDB::bind_method(_MD("find_tile_by_name","name"),&TileSet::find_tile_by_name);
+ ObjectTypeDB::bind_method(_MD("remove_tile", "id"), &TileSet::remove_tile);
+ ObjectTypeDB::bind_method(_MD("clear"), &TileSet::clear);
+ ObjectTypeDB::bind_method(_MD("get_last_unused_tile_id"), &TileSet::get_last_unused_tile_id);
+ ObjectTypeDB::bind_method(_MD("find_tile_by_name", "name"), &TileSet::find_tile_by_name);
ObjectTypeDB::bind_method(_MD("get_tiles_ids", "name"), &TileSet::_get_tiles_ids);
-
}
-
TileSet::TileSet() {
-
}
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 7a922b40b..bf327f9ac 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -30,14 +30,14 @@
#define TILE_SET_H
#include "resource.h"
-#include "scene/resources/shape_2d.h"
-#include "scene/resources/texture.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/navigation_polygon.h"
+#include "scene/resources/shape_2d.h"
+#include "scene/resources/texture.h"
class TileSet : public Resource {
- OBJ_TYPE( TileSet, Resource );
+ OBJ_TYPE(TileSet, Resource);
struct Data {
@@ -55,72 +55,69 @@ class TileSet : public Resource {
Color modulate;
// Default modulate for back-compat
- explicit Data() : modulate(1,1,1) {}
+ explicit Data()
+ : modulate(1, 1, 1) {}
};
- Map<int,Data> tile_map;
-
+ Map<int, Data> tile_map;
protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
- void _tile_set_shapes(int p_id,const Array& p_shapes);
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+ void _get_property_list(List<PropertyInfo> *p_list) const;
+ void _tile_set_shapes(int p_id, const Array &p_shapes);
Array _tile_get_shapes(int p_id) const;
Array _get_tiles_ids() const;
static void _bind_methods();
-public:
-
-
+public:
void create_tile(int p_id);
- void tile_set_name(int p_id,const String &p_name);
+ void tile_set_name(int p_id, const String &p_name);
String tile_get_name(int p_id) const;
void tile_set_texture(int p_id, const Ref<Texture> &p_texture);
Ref<Texture> tile_get_texture(int p_id) const;
- void tile_set_texture_offset(int p_id,const Vector2 &p_offset);
+ void tile_set_texture_offset(int p_id, const Vector2 &p_offset);
Vector2 tile_get_texture_offset(int p_id) const;
- void tile_set_shape_offset(int p_id,const Vector2 &p_offset);
+ void tile_set_shape_offset(int p_id, const Vector2 &p_offset);
Vector2 tile_get_shape_offset(int p_id) const;
- void tile_set_region(int p_id,const Rect2 &p_region);
+ void tile_set_region(int p_id, const Rect2 &p_region);
Rect2 tile_get_region(int p_id) const;
- void tile_set_shape(int p_id,const Ref<Shape2D> &p_shape);
+ void tile_set_shape(int p_id, const Ref<Shape2D> &p_shape);
Ref<Shape2D> tile_get_shape(int p_id) const;
- void tile_set_material(int p_id,const Ref<CanvasItemMaterial> &p_material);
+ void tile_set_material(int p_id, const Ref<CanvasItemMaterial> &p_material);
Ref<CanvasItemMaterial> tile_get_material(int p_id) const;
- void tile_set_modulate(int p_id,const Color &p_color);
+ void tile_set_modulate(int p_id, const Color &p_color);
Color tile_get_modulate(int p_id) const;
- void tile_set_occluder_offset(int p_id,const Vector2& p_offset);
+ void tile_set_occluder_offset(int p_id, const Vector2 &p_offset);
Vector2 tile_get_occluder_offset(int p_id) const;
- void tile_set_light_occluder(int p_id,const Ref<OccluderPolygon2D> &p_light_occluder);
+ void tile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D> &p_light_occluder);
Ref<OccluderPolygon2D> tile_get_light_occluder(int p_id) const;
- void tile_set_navigation_polygon_offset(int p_id,const Vector2& p_offset);
+ void tile_set_navigation_polygon_offset(int p_id, const Vector2 &p_offset);
Vector2 tile_get_navigation_polygon_offset(int p_id) const;
- void tile_set_navigation_polygon(int p_id,const Ref<NavigationPolygon> &p_navigation_polygon);
+ void tile_set_navigation_polygon(int p_id, const Ref<NavigationPolygon> &p_navigation_polygon);
Ref<NavigationPolygon> tile_get_navigation_polygon(int p_id) const;
- void tile_set_shapes(int p_id,const Vector<Ref<Shape2D> > &p_shapes);
+ void tile_set_shapes(int p_id, const Vector<Ref<Shape2D> > &p_shapes);
Vector<Ref<Shape2D> > tile_get_shapes(int p_id) const;
void remove_tile(int p_id);
bool has_tile(int p_id) const;
- int find_tile_by_name(const String& p_name) const;
+ int find_tile_by_name(const String &p_name) const;
void get_tile_list(List<int> *p_tiles) const;
void clear();
diff --git a/scene/resources/video_stream.cpp b/scene/resources/video_stream.cpp
index 84186616d..47c40e4e6 100644
--- a/scene/resources/video_stream.cpp
+++ b/scene/resources/video_stream.cpp
@@ -28,12 +28,10 @@
/*************************************************************************/
#include "video_stream.h"
-void VideoStreamPlayback::_bind_methods() {
+void VideoStreamPlayback::_bind_methods(){
};
-
-VideoStreamPlayback::VideoStreamPlayback() {
+VideoStreamPlayback::VideoStreamPlayback(){
};
-
diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h
index ce01a766c..f298af1a3 100644
--- a/scene/resources/video_stream.h
+++ b/scene/resources/video_stream.h
@@ -32,62 +32,56 @@
#include "audio_stream_resampled.h"
#include "scene/resources/texture.h"
-
class VideoStreamPlayback : public Resource {
- OBJ_TYPE(VideoStreamPlayback,Resource);
+ OBJ_TYPE(VideoStreamPlayback, Resource);
protected:
static void _bind_methods();
public:
+ typedef int (*AudioMixCallback)(void *p_udata, const int16_t *p_data, int p_frames);
- typedef int (*AudioMixCallback)(void* p_udata,const int16_t *p_data,int p_frames);
-
- virtual void stop()=0;
- virtual void play()=0;
+ virtual void stop() = 0;
+ virtual void play() = 0;
- virtual bool is_playing() const=0;
+ virtual bool is_playing() const = 0;
- virtual void set_paused(bool p_paused)=0;
- virtual bool is_paused(bool p_paused) const=0;
+ virtual void set_paused(bool p_paused) = 0;
+ virtual bool is_paused(bool p_paused) const = 0;
- virtual void set_loop(bool p_enable)=0;
- virtual bool has_loop() const=0;
+ virtual void set_loop(bool p_enable) = 0;
+ virtual bool has_loop() const = 0;
- virtual float get_length() const=0;
+ virtual float get_length() const = 0;
- virtual float get_pos() const=0;
- virtual void seek_pos(float p_time)=0;
+ virtual float get_pos() const = 0;
+ virtual void seek_pos(float p_time) = 0;
- virtual void set_audio_track(int p_idx) =0;
+ virtual void set_audio_track(int p_idx) = 0;
//virtual int mix(int16_t* p_bufer,int p_frames)=0;
- virtual Ref<Texture> get_texture()=0;
- virtual void update(float p_delta)=0;
+ virtual Ref<Texture> get_texture() = 0;
+ virtual void update(float p_delta) = 0;
- virtual void set_mix_callback(AudioMixCallback p_callback,void *p_userdata)=0;
- virtual int get_channels() const=0;
- virtual int get_mix_rate() const=0;
+ virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) = 0;
+ virtual int get_channels() const = 0;
+ virtual int get_mix_rate() const = 0;
VideoStreamPlayback();
};
-
class VideoStream : public Resource {
- OBJ_TYPE( VideoStream, Resource );
- OBJ_SAVE_TYPE( VideoStream ); //children are all saved as AudioStream, so they can be exchanged
+ OBJ_TYPE(VideoStream, Resource);
+ OBJ_SAVE_TYPE(VideoStream); //children are all saved as AudioStream, so they can be exchanged
public:
-
- virtual void set_audio_track(int p_track)=0;
- virtual Ref<VideoStreamPlayback> instance_playback()=0;
+ virtual void set_audio_track(int p_track) = 0;
+ virtual Ref<VideoStreamPlayback> instance_playback() = 0;
VideoStream() {}
};
-
#endif
-
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index e75c4821d..8dfe5dc5f 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -27,76 +27,73 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "world.h"
+#include "camera_matrix.h"
+#include "octree.h"
#include "scene/3d/camera.h"
-#include "scene/3d/visibility_notifier.h"
#include "scene/3d/spatial_indexer.h"
+#include "scene/3d/visibility_notifier.h"
#include "scene/scene_string_names.h"
-#include "octree.h"
-#include "camera_matrix.h"
struct SpatialIndexer {
-
Octree<VisibilityNotifier> octree;
struct NotifierData {
AABB aabb;
OctreeElementID id;
-
};
- Map<VisibilityNotifier*,NotifierData> notifiers;
+ Map<VisibilityNotifier *, NotifierData> notifiers;
struct CameraData {
- Map<VisibilityNotifier*,uint64_t> notifiers;
+ Map<VisibilityNotifier *, uint64_t> notifiers;
};
- Map<Camera*,CameraData> cameras;
+ Map<Camera *, CameraData> cameras;
enum {
- VISIBILITY_CULL_MAX=32768
+ VISIBILITY_CULL_MAX = 32768
};
- Vector<VisibilityNotifier*> cull;
+ Vector<VisibilityNotifier *> cull;
bool changed;
uint64_t pass;
uint64_t last_frame;
- void _notifier_add(VisibilityNotifier* p_notifier,const AABB& p_rect) {
+ void _notifier_add(VisibilityNotifier *p_notifier, const AABB &p_rect) {
ERR_FAIL_COND(notifiers.has(p_notifier));
- notifiers[p_notifier].aabb=p_rect;
- notifiers[p_notifier].id = octree.create(p_notifier,p_rect);
- changed=true;
-
+ notifiers[p_notifier].aabb = p_rect;
+ notifiers[p_notifier].id = octree.create(p_notifier, p_rect);
+ changed = true;
}
- void _notifier_update(VisibilityNotifier* p_notifier,const AABB& p_rect) {
+ void _notifier_update(VisibilityNotifier *p_notifier, const AABB &p_rect) {
- Map<VisibilityNotifier*,NotifierData>::Element *E=notifiers.find(p_notifier);
+ Map<VisibilityNotifier *, NotifierData>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
- if (E->get().aabb==p_rect)
+ if (E->get().aabb == p_rect)
return;
- E->get().aabb=p_rect;
- octree.move(E->get().id,E->get().aabb);
- changed=true;
+ E->get().aabb = p_rect;
+ octree.move(E->get().id, E->get().aabb);
+ changed = true;
}
- void _notifier_remove(VisibilityNotifier* p_notifier) {
+ void _notifier_remove(VisibilityNotifier *p_notifier) {
- Map<VisibilityNotifier*,NotifierData>::Element *E=notifiers.find(p_notifier);
+ Map<VisibilityNotifier *, NotifierData>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
octree.erase(E->get().id);
notifiers.erase(p_notifier);
- List<Camera*> removed;
- for (Map<Camera*,CameraData>::Element*F=cameras.front();F;F=F->next()) {
+ List<Camera *> removed;
+ for (Map<Camera *, CameraData>::Element *F = cameras.front(); F; F = F->next()) {
- Map<VisibilityNotifier*,uint64_t>::Element*G=F->get().notifiers.find(p_notifier);
+ Map<VisibilityNotifier *, uint64_t>::Element *G = F->get().notifiers.find(p_notifier);
if (G) {
F->get().notifiers.erase(G);
@@ -104,170 +101,154 @@ struct SpatialIndexer {
}
}
- while(!removed.empty()) {
+ while (!removed.empty()) {
p_notifier->_exit_camera(removed.front()->get());
removed.pop_front();
}
-
- changed=true;
+ changed = true;
}
- void _add_camera(Camera* p_camera) {
+ void _add_camera(Camera *p_camera) {
ERR_FAIL_COND(cameras.has(p_camera));
CameraData vd;
- cameras[p_camera]=vd;
- changed=true;
-
+ cameras[p_camera] = vd;
+ changed = true;
}
- void _update_camera(Camera* p_camera) {
+ void _update_camera(Camera *p_camera) {
- Map<Camera*,CameraData>::Element *E= cameras.find(p_camera);
+ Map<Camera *, CameraData>::Element *E = cameras.find(p_camera);
ERR_FAIL_COND(!E);
- changed=true;
+ changed = true;
}
- void _remove_camera(Camera* p_camera) {
+ void _remove_camera(Camera *p_camera) {
ERR_FAIL_COND(!cameras.has(p_camera));
- List<VisibilityNotifier*> removed;
- for(Map<VisibilityNotifier*,uint64_t>::Element *E=cameras[p_camera].notifiers.front();E;E=E->next()) {
+ List<VisibilityNotifier *> removed;
+ for (Map<VisibilityNotifier *, uint64_t>::Element *E = cameras[p_camera].notifiers.front(); E; E = E->next()) {
removed.push_back(E->key());
}
- while(!removed.empty()) {
+ while (!removed.empty()) {
removed.front()->get()->_exit_camera(p_camera);
removed.pop_front();
}
cameras.erase(p_camera);
-
}
void _update(uint64_t p_frame) {
- if (p_frame==last_frame)
+ if (p_frame == last_frame)
return;
- last_frame=p_frame;
+ last_frame = p_frame;
if (!changed)
return;
-
-
- for (Map<Camera*,CameraData>::Element *E=cameras.front();E;E=E->next()) {
+ for (Map<Camera *, CameraData>::Element *E = cameras.front(); E; E = E->next()) {
pass++;
- Camera *c=E->key();
+ Camera *c = E->key();
Vector<Plane> planes = c->get_frustum();
- int culled = octree.cull_convex(planes,cull.ptr(),cull.size());
-
+ int culled = octree.cull_convex(planes, cull.ptr(), cull.size());
- VisibilityNotifier**ptr=cull.ptr();
+ VisibilityNotifier **ptr = cull.ptr();
- List<VisibilityNotifier*> added;
- List<VisibilityNotifier*> removed;
+ List<VisibilityNotifier *> added;
+ List<VisibilityNotifier *> removed;
- for(int i=0;i<culled;i++) {
+ for (int i = 0; i < culled; i++) {
//notifiers in frustum
- Map<VisibilityNotifier*,uint64_t>::Element *H=E->get().notifiers.find(ptr[i]);
+ Map<VisibilityNotifier *, uint64_t>::Element *H = E->get().notifiers.find(ptr[i]);
if (!H) {
- E->get().notifiers.insert(ptr[i],pass);
+ E->get().notifiers.insert(ptr[i], pass);
added.push_back(ptr[i]);
} else {
- H->get()=pass;
+ H->get() = pass;
}
-
-
}
- for (Map<VisibilityNotifier*,uint64_t>::Element *F=E->get().notifiers.front();F;F=F->next()) {
+ for (Map<VisibilityNotifier *, uint64_t>::Element *F = E->get().notifiers.front(); F; F = F->next()) {
- if (F->get()!=pass)
+ if (F->get() != pass)
removed.push_back(F->key());
}
- while(!added.empty()) {
+ while (!added.empty()) {
added.front()->get()->_enter_camera(E->key());
added.pop_front();
}
- while(!removed.empty()) {
+ while (!removed.empty()) {
E->get().notifiers.erase(removed.front()->get());
removed.front()->get()->_exit_camera(E->key());
removed.pop_front();
}
}
- changed=false;
+ changed = false;
}
-
SpatialIndexer() {
- pass=0;
- last_frame=0;
- changed=false;
+ pass = 0;
+ last_frame = 0;
+ changed = false;
cull.resize(VISIBILITY_CULL_MAX);
}
-
};
-
-
-void World::_register_camera(Camera* p_camera) {
+void World::_register_camera(Camera *p_camera) {
#ifndef _3D_DISABLED
indexer->_add_camera(p_camera);
#endif
}
-void World::_update_camera(Camera* p_camera){
+void World::_update_camera(Camera *p_camera) {
#ifndef _3D_DISABLED
indexer->_update_camera(p_camera);
#endif
}
-void World::_remove_camera(Camera* p_camera){
+void World::_remove_camera(Camera *p_camera) {
#ifndef _3D_DISABLED
indexer->_remove_camera(p_camera);
#endif
}
-
-
-
-void World::_register_notifier(VisibilityNotifier* p_notifier,const AABB& p_rect){
+void World::_register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) {
#ifndef _3D_DISABLED
- indexer->_notifier_add(p_notifier,p_rect);
+ indexer->_notifier_add(p_notifier, p_rect);
#endif
}
-void World::_update_notifier(VisibilityNotifier* p_notifier,const AABB& p_rect){
+void World::_update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) {
#ifndef _3D_DISABLED
- indexer->_notifier_update(p_notifier,p_rect);
+ indexer->_notifier_update(p_notifier, p_rect);
#endif
}
-void World::_remove_notifier(VisibilityNotifier* p_notifier){
+void World::_remove_notifier(VisibilityNotifier *p_notifier) {
#ifndef _3D_DISABLED
indexer->_notifier_remove(p_notifier);
#endif
}
-
void World::_update(uint64_t p_frame) {
#ifndef _3D_DISABLED
@@ -275,30 +256,26 @@ void World::_update(uint64_t p_frame) {
#endif
}
-
-
-
-
RID World::get_space() const {
return space;
}
-RID World::get_scenario() const{
+RID World::get_scenario() const {
return scenario;
}
-RID World::get_sound_space() const{
+RID World::get_sound_space() const {
return sound_space;
}
-void World::set_environment(const Ref<Environment>& p_environment) {
+void World::set_environment(const Ref<Environment> &p_environment) {
- environment=p_environment;
+ environment = p_environment;
if (environment.is_valid())
- VS::get_singleton()->scenario_set_environment(scenario,environment->get_rid());
+ VS::get_singleton()->scenario_set_environment(scenario, environment->get_rid());
else
- VS::get_singleton()->scenario_set_environment(scenario,RID());
+ VS::get_singleton()->scenario_set_environment(scenario, RID());
}
Ref<Environment> World::get_environment() const {
@@ -306,7 +283,6 @@ Ref<Environment> World::get_environment() const {
return environment;
}
-
PhysicsDirectSpaceState *World::get_direct_space_state() {
return PhysicsServer::get_singleton()->space_get_direct_state(space);
@@ -314,33 +290,31 @@ PhysicsDirectSpaceState *World::get_direct_space_state() {
void World::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_space"),&World::get_space);
- ObjectTypeDB::bind_method(_MD("get_scenario"),&World::get_scenario);
- ObjectTypeDB::bind_method(_MD("get_sound_space"),&World::get_sound_space);
- ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&World::set_environment);
- ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&World::get_environment);
- ObjectTypeDB::bind_method(_MD("get_direct_space_state:PhysicsDirectSpaceState"),&World::get_direct_space_state);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment"),_SCS("set_environment"),_SCS("get_environment"));
-
+ ObjectTypeDB::bind_method(_MD("get_space"), &World::get_space);
+ ObjectTypeDB::bind_method(_MD("get_scenario"), &World::get_scenario);
+ ObjectTypeDB::bind_method(_MD("get_sound_space"), &World::get_sound_space);
+ ObjectTypeDB::bind_method(_MD("set_environment", "env:Environment"), &World::set_environment);
+ ObjectTypeDB::bind_method(_MD("get_environment:Environment"), &World::get_environment);
+ ObjectTypeDB::bind_method(_MD("get_direct_space_state:PhysicsDirectSpaceState"), &World::get_direct_space_state);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), _SCS("set_environment"), _SCS("get_environment"));
}
-
World::World() {
space = PhysicsServer::get_singleton()->space_create();
scenario = VisualServer::get_singleton()->scenario_create();
sound_space = SpatialSoundServer::get_singleton()->space_create();
- PhysicsServer::get_singleton()->space_set_active(space,true);
- PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics/default_gravity",9.8));
- PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_GRAVITY_VECTOR,GLOBAL_DEF("physics/default_gravity_vector",Vector3(0,-1,0)));
- PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_LINEAR_DAMP,GLOBAL_DEF("physics/default_linear_damp",0.1));
- PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_ANGULAR_DAMP,GLOBAL_DEF("physics/default_angular_damp",0.1));
+ PhysicsServer::get_singleton()->space_set_active(space, true);
+ PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics/default_gravity", 9.8));
+ PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics/default_gravity_vector", Vector3(0, -1, 0)));
+ PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics/default_linear_damp", 0.1));
+ PhysicsServer::get_singleton()->area_set_param(space, PhysicsServer::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics/default_angular_damp", 0.1));
#ifdef _3D_DISABLED
indexer = NULL;
#else
- indexer = memnew( SpatialIndexer );
+ indexer = memnew(SpatialIndexer);
#endif
}
@@ -351,8 +325,6 @@ World::~World() {
SpatialSoundServer::get_singleton()->free(sound_space);
#ifndef _3D_DISABLED
- memdelete( indexer );
+ memdelete(indexer);
#endif
-
-
}
diff --git a/scene/resources/world.h b/scene/resources/world.h
index 84d69482b..e4a871012 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -30,10 +30,10 @@
#define WORLD_H
#include "resource.h"
+#include "scene/resources/environment.h"
#include "servers/physics_server.h"
-#include "servers/visual_server.h"
#include "servers/spatial_sound_server.h"
-#include "scene/resources/environment.h"
+#include "servers/visual_server.h"
class SpatialIndexer;
class Camera;
@@ -42,44 +42,41 @@ class VisibilityNotifier;
class World : public Resource {
OBJ_TYPE(World, Resource);
RES_BASE_EXTENSION("wrd");
+
private:
RID space;
RID scenario;
RID sound_space;
- SpatialIndexer* indexer;
+ SpatialIndexer *indexer;
Ref<Environment> environment;
protected:
-
static void _bind_methods();
-friend class Camera;
-friend class VisibilityNotifier;
+ friend class Camera;
+ friend class VisibilityNotifier;
- void _register_camera(Camera* p_camera);
- void _update_camera(Camera* p_camera);
- void _remove_camera(Camera* p_camera);
+ void _register_camera(Camera *p_camera);
+ void _update_camera(Camera *p_camera);
+ void _remove_camera(Camera *p_camera);
- void _register_notifier(VisibilityNotifier* p_notifier,const AABB& p_rect);
- void _update_notifier(VisibilityNotifier *p_notifier,const AABB& p_rect);
- void _remove_notifier(VisibilityNotifier* p_notifier);
-friend class Viewport;
+ void _register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect);
+ void _update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect);
+ void _remove_notifier(VisibilityNotifier *p_notifier);
+ friend class Viewport;
void _update(uint64_t p_frame);
-
public:
-
RID get_space() const;
RID get_scenario() const;
RID get_sound_space() const;
- void set_environment(const Ref<Environment>& p_environment);
+ void set_environment(const Ref<Environment> &p_environment);
Ref<Environment> get_environment() const;
PhysicsDirectSpaceState *get_direct_space_state();
World();
~World();
-
};
#endif // WORLD_H
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 8c39d70b2..77d55bf17 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -27,18 +27,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "world_2d.h"
-#include "servers/visual_server.h"
-#include "servers/physics_2d_server.h"
-#include "servers/spatial_sound_2d_server.h"
#include "globals.h"
+#include "globals.h"
+#include "scene/2d/camera_2d.h"
#include "scene/2d/visibility_notifier_2d.h"
#include "scene/main/viewport.h"
-#include "scene/2d/camera_2d.h"
-#include "globals.h"
+#include "servers/physics_2d_server.h"
+#include "servers/spatial_sound_2d_server.h"
+#include "servers/visual_server.h"
struct SpatialIndexer2D {
-
struct CellRef {
int ref;
@@ -53,12 +52,10 @@ struct SpatialIndexer2D {
}
_FORCE_INLINE_ CellRef() {
- ref=0;
+ ref = 0;
}
};
-
-
struct CellKey {
union {
@@ -69,61 +66,58 @@ struct SpatialIndexer2D {
uint64_t key;
};
- bool operator==(const CellKey& p_key) const { return key==p_key.key; }
- _FORCE_INLINE_ bool operator<(const CellKey& p_key) const {
+ bool operator==(const CellKey &p_key) const { return key == p_key.key; }
+ _FORCE_INLINE_ bool operator<(const CellKey &p_key) const {
return key < p_key.key;
}
-
};
struct CellData {
- Map<VisibilityNotifier2D*,CellRef> notifiers;
+ Map<VisibilityNotifier2D *, CellRef> notifiers;
};
-
- Map<CellKey,CellData> cells;
+ Map<CellKey, CellData> cells;
int cell_size;
- Map<VisibilityNotifier2D*,Rect2> notifiers;
+ Map<VisibilityNotifier2D *, Rect2> notifiers;
struct ViewportData {
- Map<VisibilityNotifier2D*,uint64_t> notifiers;
+ Map<VisibilityNotifier2D *, uint64_t> notifiers;
Rect2 rect;
};
- Map<Viewport*,ViewportData> viewports;
+ Map<Viewport *, ViewportData> viewports;
bool changed;
uint64_t pass;
-
- void _notifier_update_cells(VisibilityNotifier2D *p_notifier,const Rect2& p_rect,bool p_add) {
+ void _notifier_update_cells(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect, bool p_add) {
Point2i begin = p_rect.pos;
- begin/=cell_size;
- Point2i end = p_rect.pos+p_rect.size;
- end/=cell_size;
- for(int i=begin.x;i<=end.x;i++) {
+ begin /= cell_size;
+ Point2i end = p_rect.pos + p_rect.size;
+ end /= cell_size;
+ for (int i = begin.x; i <= end.x; i++) {
- for(int j=begin.y;j<=end.y;j++) {
+ for (int j = begin.y; j <= end.y; j++) {
CellKey ck;
- ck.x=i;
- ck.y=j;
- Map<CellKey,CellData>::Element *E=cells.find(ck);
+ ck.x = i;
+ ck.y = j;
+ Map<CellKey, CellData>::Element *E = cells.find(ck);
if (p_add) {
if (!E)
- E=cells.insert(ck,CellData());
+ E = cells.insert(ck, CellData());
E->get().notifiers[p_notifier].inc();
} else {
ERR_CONTINUE(!E);
- if (E->get().notifiers[p_notifier].dec()==0) {
+ if (E->get().notifiers[p_notifier].dec() == 0) {
E->get().notifiers.erase(p_notifier);
if (E->get().notifiers.empty()) {
@@ -135,38 +129,38 @@ struct SpatialIndexer2D {
}
}
- void _notifier_add(VisibilityNotifier2D* p_notifier,const Rect2& p_rect) {
+ void _notifier_add(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
ERR_FAIL_COND(notifiers.has(p_notifier));
- notifiers[p_notifier]=p_rect;
- _notifier_update_cells(p_notifier,p_rect,true);
- changed=true;
+ notifiers[p_notifier] = p_rect;
+ _notifier_update_cells(p_notifier, p_rect, true);
+ changed = true;
}
- void _notifier_update(VisibilityNotifier2D* p_notifier,const Rect2& p_rect) {
+ void _notifier_update(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
- Map<VisibilityNotifier2D*,Rect2>::Element *E=notifiers.find(p_notifier);
+ Map<VisibilityNotifier2D *, Rect2>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
- if (E->get()==p_rect)
+ if (E->get() == p_rect)
return;
- _notifier_update_cells(p_notifier,p_rect,true);
- _notifier_update_cells(p_notifier,E->get(),false);
- E->get()=p_rect;
- changed=true;
+ _notifier_update_cells(p_notifier, p_rect, true);
+ _notifier_update_cells(p_notifier, E->get(), false);
+ E->get() = p_rect;
+ changed = true;
}
- void _notifier_remove(VisibilityNotifier2D* p_notifier) {
+ void _notifier_remove(VisibilityNotifier2D *p_notifier) {
- Map<VisibilityNotifier2D*,Rect2>::Element *E=notifiers.find(p_notifier);
+ Map<VisibilityNotifier2D *, Rect2>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
- _notifier_update_cells(p_notifier,E->get(),false);
+ _notifier_update_cells(p_notifier, E->get(), false);
notifiers.erase(p_notifier);
- List<Viewport*> removed;
- for (Map<Viewport*,ViewportData>::Element*F=viewports.front();F;F=F->next()) {
+ List<Viewport *> removed;
+ for (Map<Viewport *, ViewportData>::Element *F = viewports.front(); F; F = F->next()) {
- Map<VisibilityNotifier2D*,uint64_t>::Element*G=F->get().notifiers.find(p_notifier);
+ Map<VisibilityNotifier2D *, uint64_t>::Element *G = F->get().notifiers.find(p_notifier);
if (G) {
F->get().notifiers.erase(G);
@@ -174,44 +168,43 @@ struct SpatialIndexer2D {
}
}
- while(!removed.empty()) {
+ while (!removed.empty()) {
p_notifier->_exit_viewport(removed.front()->get());
removed.pop_front();
}
- changed=true;
+ changed = true;
}
- void _add_viewport(Viewport* p_viewport,const Rect2& p_rect) {
+ void _add_viewport(Viewport *p_viewport, const Rect2 &p_rect) {
ERR_FAIL_COND(viewports.has(p_viewport));
ViewportData vd;
- vd.rect=p_rect;
- viewports[p_viewport]=vd;
- changed=true;
-
+ vd.rect = p_rect;
+ viewports[p_viewport] = vd;
+ changed = true;
}
- void _update_viewport(Viewport* p_viewport, const Rect2& p_rect) {
+ void _update_viewport(Viewport *p_viewport, const Rect2 &p_rect) {
- Map<Viewport*,ViewportData>::Element *E= viewports.find(p_viewport);
+ Map<Viewport *, ViewportData>::Element *E = viewports.find(p_viewport);
ERR_FAIL_COND(!E);
- if (E->get().rect==p_rect)
+ if (E->get().rect == p_rect)
return;
- E->get().rect=p_rect;
- changed=true;
+ E->get().rect = p_rect;
+ changed = true;
}
- void _remove_viewport(Viewport* p_viewport) {
+ void _remove_viewport(Viewport *p_viewport) {
ERR_FAIL_COND(!viewports.has(p_viewport));
- List<VisibilityNotifier2D*> removed;
- for(Map<VisibilityNotifier2D*,uint64_t>::Element *E=viewports[p_viewport].notifiers.front();E;E=E->next()) {
+ List<VisibilityNotifier2D *> removed;
+ for (Map<VisibilityNotifier2D *, uint64_t>::Element *E = viewports[p_viewport].notifiers.front(); E; E = E->next()) {
removed.push_back(E->key());
}
- while(!removed.empty()) {
+ while (!removed.empty()) {
removed.front()->get()->_exit_viewport(p_viewport);
removed.pop_front();
}
@@ -221,45 +214,44 @@ struct SpatialIndexer2D {
void _update() {
-
if (!changed)
return;
- for (Map<Viewport*,ViewportData>::Element *E=viewports.front();E;E=E->next()) {
+ for (Map<Viewport *, ViewportData>::Element *E = viewports.front(); E; E = E->next()) {
Point2i begin = E->get().rect.pos;
- begin/=cell_size;
- Point2i end = E->get().rect.pos+E->get().rect.size;
- end/=cell_size;
+ begin /= cell_size;
+ Point2i end = E->get().rect.pos + E->get().rect.size;
+ end /= cell_size;
pass++;
- List<VisibilityNotifier2D*> added;
- List<VisibilityNotifier2D*> removed;
+ List<VisibilityNotifier2D *> added;
+ List<VisibilityNotifier2D *> removed;
- int visible_cells=(end.x-begin.x)*(end.y-begin.y);
+ int visible_cells = (end.x - begin.x) * (end.y - begin.y);
- if (visible_cells>10000) {
+ if (visible_cells > 10000) {
//well you zoomed out a lot, it's your problem. To avoid freezing in the for loops below, we'll manually check cell by cell
- for (Map<CellKey,CellData>::Element *F=cells.front();F;F=F->next()) {
+ for (Map<CellKey, CellData>::Element *F = cells.front(); F; F = F->next()) {
- const CellKey &ck=F->key();
+ const CellKey &ck = F->key();
- if (ck.x<begin.x || ck.x>end.x)
+ if (ck.x < begin.x || ck.x > end.x)
continue;
- if (ck.y<begin.y || ck.y>end.y)
+ if (ck.y < begin.y || ck.y > end.y)
continue;
//notifiers in cell
- for (Map<VisibilityNotifier2D*,CellRef>::Element *G=F->get().notifiers.front();G;G=G->next()) {
+ for (Map<VisibilityNotifier2D *, CellRef>::Element *G = F->get().notifiers.front(); G; G = G->next()) {
- Map<VisibilityNotifier2D*,uint64_t>::Element *H=E->get().notifiers.find(G->key());
+ Map<VisibilityNotifier2D *, uint64_t>::Element *H = E->get().notifiers.find(G->key());
if (!H) {
- H=E->get().notifiers.insert(G->key(),pass);
+ H = E->get().notifiers.insert(G->key(), pass);
added.push_back(G->key());
} else {
- H->get()=pass;
+ H->get() = pass;
}
}
}
@@ -267,94 +259,87 @@ struct SpatialIndexer2D {
} else {
//check cells in grid fashion
- for(int i=begin.x;i<=end.x;i++) {
+ for (int i = begin.x; i <= end.x; i++) {
- for(int j=begin.y;j<=end.y;j++) {
+ for (int j = begin.y; j <= end.y; j++) {
CellKey ck;
- ck.x=i;
- ck.y=j;
+ ck.x = i;
+ ck.y = j;
- Map<CellKey,CellData>::Element *F=cells.find(ck);
+ Map<CellKey, CellData>::Element *F = cells.find(ck);
if (!F) {
continue;
}
-
//notifiers in cell
- for (Map<VisibilityNotifier2D*,CellRef>::Element *G=F->get().notifiers.front();G;G=G->next()) {
+ for (Map<VisibilityNotifier2D *, CellRef>::Element *G = F->get().notifiers.front(); G; G = G->next()) {
- Map<VisibilityNotifier2D*,uint64_t>::Element *H=E->get().notifiers.find(G->key());
+ Map<VisibilityNotifier2D *, uint64_t>::Element *H = E->get().notifiers.find(G->key());
if (!H) {
- H=E->get().notifiers.insert(G->key(),pass);
+ H = E->get().notifiers.insert(G->key(), pass);
added.push_back(G->key());
} else {
- H->get()=pass;
+ H->get() = pass;
}
}
}
}
}
- for (Map<VisibilityNotifier2D*,uint64_t>::Element *F=E->get().notifiers.front();F;F=F->next()) {
+ for (Map<VisibilityNotifier2D *, uint64_t>::Element *F = E->get().notifiers.front(); F; F = F->next()) {
- if (F->get()!=pass)
+ if (F->get() != pass)
removed.push_back(F->key());
}
- while(!added.empty()) {
+ while (!added.empty()) {
added.front()->get()->_enter_viewport(E->key());
added.pop_front();
}
- while(!removed.empty()) {
+ while (!removed.empty()) {
E->get().notifiers.erase(removed.front()->get());
removed.front()->get()->_exit_viewport(E->key());
removed.pop_front();
}
}
- changed=false;
+ changed = false;
}
-
SpatialIndexer2D() {
- pass=0;
- changed=false;
- cell_size=100; //should be configurable with GLOBAL_DEF("") i guess
+ pass = 0;
+ changed = false;
+ cell_size = 100; //should be configurable with GLOBAL_DEF("") i guess
}
-
};
+void World2D::_register_viewport(Viewport *p_viewport, const Rect2 &p_rect) {
-
-void World2D::_register_viewport(Viewport* p_viewport,const Rect2& p_rect) {
-
- indexer->_add_viewport(p_viewport,p_rect);
+ indexer->_add_viewport(p_viewport, p_rect);
}
-void World2D::_update_viewport(Viewport* p_viewport,const Rect2& p_rect){
-
- indexer->_update_viewport(p_viewport,p_rect);
+void World2D::_update_viewport(Viewport *p_viewport, const Rect2 &p_rect) {
+ indexer->_update_viewport(p_viewport, p_rect);
}
-void World2D::_remove_viewport(Viewport* p_viewport){
+void World2D::_remove_viewport(Viewport *p_viewport) {
indexer->_remove_viewport(p_viewport);
}
-void World2D::_register_notifier(VisibilityNotifier2D* p_notifier, const Rect2 &p_rect){
-
- indexer->_notifier_add(p_notifier,p_rect);
+void World2D::_register_notifier(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
+ indexer->_notifier_add(p_notifier, p_rect);
}
-void World2D::_update_notifier(VisibilityNotifier2D* p_notifier,const Rect2& p_rect){
+void World2D::_update_notifier(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect) {
- indexer->_notifier_update(p_notifier,p_rect);
+ indexer->_notifier_update(p_notifier, p_rect);
}
-void World2D::_remove_notifier(VisibilityNotifier2D* p_notifier){
+void World2D::_remove_notifier(VisibilityNotifier2D *p_notifier) {
indexer->_notifier_remove(p_notifier);
}
@@ -364,7 +349,6 @@ void World2D::_update() {
indexer->_update();
}
-
RID World2D::get_canvas() {
return canvas;
@@ -382,12 +366,11 @@ RID World2D::get_sound_space() {
void World2D::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_canvas"),&World2D::get_canvas);
- ObjectTypeDB::bind_method(_MD("get_space"),&World2D::get_space);
- ObjectTypeDB::bind_method(_MD("get_sound_space"),&World2D::get_sound_space);
-
- ObjectTypeDB::bind_method(_MD("get_direct_space_state:Physics2DDirectSpaceState"),&World2D::get_direct_space_state);
+ ObjectTypeDB::bind_method(_MD("get_canvas"), &World2D::get_canvas);
+ ObjectTypeDB::bind_method(_MD("get_space"), &World2D::get_space);
+ ObjectTypeDB::bind_method(_MD("get_sound_space"), &World2D::get_sound_space);
+ ObjectTypeDB::bind_method(_MD("get_direct_space_state:Physics2DDirectSpaceState"), &World2D::get_direct_space_state);
}
Physics2DDirectSpaceState *World2D::get_direct_space_state() {
@@ -395,7 +378,6 @@ Physics2DDirectSpaceState *World2D::get_direct_space_state() {
return Physics2DServer::get_singleton()->space_get_direct_state(space);
}
-
World2D::World2D() {
canvas = VisualServer::get_singleton()->canvas_create();
@@ -403,9 +385,9 @@ World2D::World2D() {
sound_space = SpatialSound2DServer::get_singleton()->space_create();
//set space2D to be more friendly with pixels than meters, by adjusting some constants
- Physics2DServer::get_singleton()->space_set_active(space,true);
- Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics_2d/default_gravity",98));
- Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_GRAVITY_VECTOR,GLOBAL_DEF("physics_2d/default_gravity_vector",Vector2(0,1)));
+ Physics2DServer::get_singleton()->space_set_active(space, true);
+ Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY, GLOBAL_DEF("physics_2d/default_gravity", 98));
+ Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_GRAVITY_VECTOR, GLOBAL_DEF("physics_2d/default_gravity_vector", Vector2(0, 1)));
// TODO: Remove this deprecation warning and compatibility code for 2.2 or 3.0
if (Globals::get_singleton()->get("physics_2d/default_density") && !Globals::get_singleton()->get("physics_2d/default_linear_damp")) {
WARN_PRINT("Deprecated parameter 'physics_2d/default_density'. It was renamed to 'physics_2d/default_linear_damp', adjusting your project settings accordingly (make sure to adjust scripts that potentially rely on 'physics_2d/default_density'.");
@@ -414,13 +396,11 @@ World2D::World2D() {
Globals::get_singleton()->set_persisting("physics_2d/default_density", false);
Globals::get_singleton()->save();
}
- Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_LINEAR_DAMP,GLOBAL_DEF("physics_2d/default_linear_damp",0.1));
- Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_ANGULAR_DAMP,GLOBAL_DEF("physics_2d/default_angular_damp",1));
- indexer = memnew( SpatialIndexer2D );
-
+ Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_LINEAR_DAMP, GLOBAL_DEF("physics_2d/default_linear_damp", 0.1));
+ Physics2DServer::get_singleton()->area_set_param(space, Physics2DServer::AREA_PARAM_ANGULAR_DAMP, GLOBAL_DEF("physics_2d/default_angular_damp", 1));
+ indexer = memnew(SpatialIndexer2D);
}
-
World2D::~World2D() {
VisualServer::get_singleton()->free(canvas);
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index 91ddc8f60..c8e7596b6 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -29,9 +29,9 @@
#ifndef WORLD_2D_H
#define WORLD_2D_H
+#include "globals.h"
#include "resource.h"
#include "servers/physics_2d_server.h"
-#include "globals.h"
class SpatialIndexer2D;
class VisibilityNotifier2D;
@@ -39,32 +39,30 @@ class Viewport;
class World2D : public Resource {
- OBJ_TYPE( World2D, Resource );
+ OBJ_TYPE(World2D, Resource);
RID canvas;
RID space;
RID sound_space;
- SpatialIndexer2D* indexer;
-protected:
+ SpatialIndexer2D *indexer;
+protected:
static void _bind_methods();
-friend class Viewport;
-friend class VisibilityNotifier2D;
+ friend class Viewport;
+ friend class VisibilityNotifier2D;
- void _register_viewport(Viewport* p_viewport,const Rect2& p_rect);
- void _update_viewport(Viewport* p_viewport,const Rect2& p_rect);
- void _remove_viewport(Viewport* p_viewport);
+ void _register_viewport(Viewport *p_viewport, const Rect2 &p_rect);
+ void _update_viewport(Viewport *p_viewport, const Rect2 &p_rect);
+ void _remove_viewport(Viewport *p_viewport);
- void _register_notifier(VisibilityNotifier2D* p_notifier,const Rect2& p_rect);
- void _update_notifier(VisibilityNotifier2D* p_notifier,const Rect2& p_rect);
- void _remove_notifier(VisibilityNotifier2D* p_notifier);
+ void _register_notifier(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect);
+ void _update_notifier(VisibilityNotifier2D *p_notifier, const Rect2 &p_rect);
+ void _remove_notifier(VisibilityNotifier2D *p_notifier);
void _update();
-public:
-
-
+public:
RID get_canvas();
RID get_space();
RID get_sound_space();
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index 9a2647327..458f5c220 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -28,37 +28,37 @@
/*************************************************************************/
#include "scene_string_names.h"
-SceneStringNames* SceneStringNames::singleton=NULL;
+SceneStringNames *SceneStringNames::singleton = NULL;
SceneStringNames::SceneStringNames() {
- resized=StaticCString::create("resized");
- dot=StaticCString::create(".");
- doubledot=StaticCString::create("..");
- draw=StaticCString::create("draw");
- _draw=StaticCString::create("_draw");
- hide=StaticCString::create("hide");
- visibility_changed=StaticCString::create("visibility_changed");
- input_event=StaticCString::create("input_event");
- shader_shader=StaticCString::create("shader/shader");
- shader_unshaded=StaticCString::create("shader/unshaded");
- shading_mode=StaticCString::create("shader/shading_mode");
- enter_tree=StaticCString::create("enter_tree");
- exit_tree=StaticCString::create("exit_tree");
- item_rect_changed=StaticCString::create("item_rect_changed");
- size_flags_changed=StaticCString::create("size_flags_changed");
- minimum_size_changed=StaticCString::create("minimum_size_changed");
- sleeping_state_changed=StaticCString::create("sleeping_state_changed");
+ resized = StaticCString::create("resized");
+ dot = StaticCString::create(".");
+ doubledot = StaticCString::create("..");
+ draw = StaticCString::create("draw");
+ _draw = StaticCString::create("_draw");
+ hide = StaticCString::create("hide");
+ visibility_changed = StaticCString::create("visibility_changed");
+ input_event = StaticCString::create("input_event");
+ shader_shader = StaticCString::create("shader/shader");
+ shader_unshaded = StaticCString::create("shader/unshaded");
+ shading_mode = StaticCString::create("shader/shading_mode");
+ enter_tree = StaticCString::create("enter_tree");
+ exit_tree = StaticCString::create("exit_tree");
+ item_rect_changed = StaticCString::create("item_rect_changed");
+ size_flags_changed = StaticCString::create("size_flags_changed");
+ minimum_size_changed = StaticCString::create("minimum_size_changed");
+ sleeping_state_changed = StaticCString::create("sleeping_state_changed");
- finished=StaticCString::create("finished");
- animation_changed=StaticCString::create("animation_changed");
- animation_started=StaticCString::create("animation_started");
+ finished = StaticCString::create("finished");
+ animation_changed = StaticCString::create("animation_changed");
+ animation_started = StaticCString::create("animation_started");
- mouse_enter=StaticCString::create("mouse_enter");
- mouse_exit=StaticCString::create("mouse_exit");
+ mouse_enter = StaticCString::create("mouse_enter");
+ mouse_exit = StaticCString::create("mouse_exit");
- focus_enter=StaticCString::create("focus_enter");
- focus_exit=StaticCString::create("focus_exit");
+ focus_enter = StaticCString::create("focus_enter");
+ focus_exit = StaticCString::create("focus_exit");
sort_children = StaticCString::create("sort_children");
@@ -73,40 +73,40 @@ SceneStringNames::SceneStringNames() {
_body_inout = StaticCString::create("_body_inout");
_area_inout = StaticCString::create("_area_inout");
- idle=StaticCString::create("idle");
- iteration=StaticCString::create("iteration");
- update=StaticCString::create("update");
- updated=StaticCString::create("updated");
+ idle = StaticCString::create("idle");
+ iteration = StaticCString::create("iteration");
+ update = StaticCString::create("update");
+ updated = StaticCString::create("updated");
- _get_gizmo_geometry=StaticCString::create("_get_gizmo_geometry");
- _can_gizmo_scale=StaticCString::create("_can_gizmo_scale");
+ _get_gizmo_geometry = StaticCString::create("_get_gizmo_geometry");
+ _can_gizmo_scale = StaticCString::create("_can_gizmo_scale");
- _fixed_process=StaticCString::create("_fixed_process");
- _process=StaticCString::create("_process");
+ _fixed_process = StaticCString::create("_fixed_process");
+ _process = StaticCString::create("_process");
- _enter_tree=StaticCString::create("_enter_tree");
- _exit_tree=StaticCString::create("_exit_tree");
- _enter_world=StaticCString::create("_enter_world");
- _exit_world=StaticCString::create("_exit_world");
- _ready=StaticCString::create("_ready");
+ _enter_tree = StaticCString::create("_enter_tree");
+ _exit_tree = StaticCString::create("_exit_tree");
+ _enter_world = StaticCString::create("_enter_world");
+ _exit_world = StaticCString::create("_exit_world");
+ _ready = StaticCString::create("_ready");
- _update_scroll=StaticCString::create("_update_scroll");
- _update_xform=StaticCString::create("_update_xform");
+ _update_scroll = StaticCString::create("_update_scroll");
+ _update_xform = StaticCString::create("_update_xform");
- _proxgroup_add=StaticCString::create("_proxgroup_add");
- _proxgroup_remove=StaticCString::create("_proxgroup_remove");
+ _proxgroup_add = StaticCString::create("_proxgroup_add");
+ _proxgroup_remove = StaticCString::create("_proxgroup_remove");
- grouped=StaticCString::create("grouped");
- ungrouped=StaticCString::create("ungrouped");
+ grouped = StaticCString::create("grouped");
+ ungrouped = StaticCString::create("ungrouped");
- enter_screen=StaticCString::create("enter_screen");
- exit_screen=StaticCString::create("exit_screen");
+ enter_screen = StaticCString::create("enter_screen");
+ exit_screen = StaticCString::create("exit_screen");
- enter_viewport=StaticCString::create("enter_viewport");
- exit_viewport=StaticCString::create("exit_viewport");
+ enter_viewport = StaticCString::create("enter_viewport");
+ exit_viewport = StaticCString::create("exit_viewport");
- enter_camera=StaticCString::create("enter_camera");
- exit_camera=StaticCString::create("exit_camera");
+ enter_camera = StaticCString::create("enter_camera");
+ exit_camera = StaticCString::create("exit_camera");
_body_enter_tree = StaticCString::create("_body_enter_tree");
_body_exit_tree = StaticCString::create("_body_exit_tree");
@@ -114,32 +114,32 @@ SceneStringNames::SceneStringNames() {
_area_enter_tree = StaticCString::create("_area_enter_tree");
_area_exit_tree = StaticCString::create("_area_exit_tree");
- _input_event=StaticCString::create("_input_event");
+ _input_event = StaticCString::create("_input_event");
- changed=StaticCString::create("changed");
- _shader_changed=StaticCString::create("_shader_changed");
+ changed = StaticCString::create("changed");
+ _shader_changed = StaticCString::create("_shader_changed");
- _spatial_editor_group=StaticCString::create("_spatial_editor_group");
- _request_gizmo=StaticCString::create("_request_gizmo");
+ _spatial_editor_group = StaticCString::create("_spatial_editor_group");
+ _request_gizmo = StaticCString::create("_request_gizmo");
- offset=StaticCString::create("offset");
- unit_offset=StaticCString::create("unit_offset");
- rotation_mode=StaticCString::create("rotation_mode");
- rotate=StaticCString::create("rotate");
- h_offset=StaticCString::create("h_offset");
- v_offset=StaticCString::create("v_offset");
+ offset = StaticCString::create("offset");
+ unit_offset = StaticCString::create("unit_offset");
+ rotation_mode = StaticCString::create("rotation_mode");
+ rotate = StaticCString::create("rotate");
+ h_offset = StaticCString::create("h_offset");
+ v_offset = StaticCString::create("v_offset");
- transform_pos=StaticCString::create("transform/pos");
- transform_rot=StaticCString::create("transform/rot");
- transform_scale=StaticCString::create("transform/scale");
+ transform_pos = StaticCString::create("transform/pos");
+ transform_rot = StaticCString::create("transform/rot");
+ transform_scale = StaticCString::create("transform/scale");
- _update_remote=StaticCString::create("_update_remote");
- _update_pairs=StaticCString::create("_update_pairs");
+ _update_remote = StaticCString::create("_update_remote");
+ _update_pairs = StaticCString::create("_update_pairs");
- get_minimum_size=StaticCString::create("get_minimum_size");
+ get_minimum_size = StaticCString::create("get_minimum_size");
- area_enter=StaticCString::create("area_enter");
- area_exit=StaticCString::create("area_exit");
+ area_enter = StaticCString::create("area_enter");
+ area_exit = StaticCString::create("area_exit");
has_point = StaticCString::create("has_point");
@@ -157,30 +157,30 @@ SceneStringNames::SceneStringNames() {
baked_light_changed = StaticCString::create("baked_light_changed");
_baked_light_changed = StaticCString::create("_baked_light_changed");
- _mouse_enter=StaticCString::create("_mouse_enter");
- _mouse_exit=StaticCString::create("_mouse_exit");
+ _mouse_enter = StaticCString::create("_mouse_enter");
+ _mouse_exit = StaticCString::create("_mouse_exit");
- _pressed=StaticCString::create("_pressed");
- _toggled=StaticCString::create("_toggled");
+ _pressed = StaticCString::create("_pressed");
+ _toggled = StaticCString::create("_toggled");
- frame_changed=StaticCString::create("frame_changed");
+ frame_changed = StaticCString::create("frame_changed");
- playback_speed=StaticCString::create("playback/speed");
- playback_active=StaticCString::create("playback/active");
- autoplay=StaticCString::create("autoplay");
- blend_times=StaticCString::create("blend_times");
- speed=StaticCString::create("speed");
+ playback_speed = StaticCString::create("playback/speed");
+ playback_active = StaticCString::create("playback/active");
+ autoplay = StaticCString::create("autoplay");
+ blend_times = StaticCString::create("blend_times");
+ speed = StaticCString::create("speed");
node_configuration_warning_changed = StaticCString::create("node_configuration_warning_changed");
- path_pp=NodePath("..");
+ path_pp = NodePath("..");
- _default=StaticCString::create("default");
+ _default = StaticCString::create("default");
- for(int i=0;i<MAX_MATERIALS;i++) {
+ for (int i = 0; i < MAX_MATERIALS; i++) {
- mesh_materials[i]="material/"+itos(i);
+ mesh_materials[i] = "material/" + itos(i);
}
- _mesh_changed=StaticCString::create("_mesh_changed");
+ _mesh_changed = StaticCString::create("_mesh_changed");
}
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 598f2fadb..6d0382ba7 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -29,22 +29,25 @@
#ifndef SCENE_STRING_NAMES_H
#define SCENE_STRING_NAMES_H
-#include "string_db.h"
#include "path_db.h"
+#include "string_db.h"
class SceneStringNames {
-friend void register_scene_types();
-friend void unregister_scene_types();
+ friend void register_scene_types();
+ friend void unregister_scene_types();
- static SceneStringNames* singleton;
+ static SceneStringNames *singleton;
static void create() { singleton = memnew(SceneStringNames); }
- static void free() { memdelete( singleton); singleton=NULL; }
+ static void free() {
+ memdelete(singleton);
+ singleton = NULL;
+ }
SceneStringNames();
-public:
- _FORCE_INLINE_ static SceneStringNames* get_singleton() { return singleton; }
+public:
+ _FORCE_INLINE_ static SceneStringNames *get_singleton() { return singleton; }
StringName resized;
StringName dot;
@@ -92,7 +95,6 @@ public:
StringName _body_inout;
StringName _area_inout;
-
StringName _get_gizmo_geometry;
StringName _can_gizmo_scale;
@@ -187,12 +189,10 @@ public:
StringName node_configuration_warning_changed;
enum {
- MAX_MATERIALS=32
+ MAX_MATERIALS = 32
};
StringName mesh_materials[MAX_MATERIALS];
StringName _mesh_changed;
-
};
-
#endif // SCENE_STRING_NAMES_H